Seamless fix

This commit is contained in:
Bob Da Ross
2022-02-14 20:53:51 -06:00
parent 4bd456a05b
commit 9dec9a8986
3 changed files with 16 additions and 153 deletions

View File

@@ -69,6 +69,7 @@ namespace SeamlessClientPlugin.SeamlessTransfer
public static MethodInfo LoadPlayerInternal { get; private set; }
public static MethodInfo LoadMembersFromWorld { get; private set; }
public static MethodInfo LoadMultiplayer { get; private set; }
public static MethodInfo GPSRegisterChat { get; private set; }
public static MethodInfo SendPlayerData;
@@ -118,7 +119,7 @@ namespace SeamlessClientPlugin.SeamlessTransfer
LoadMultiplayer = GetMethod(typeof(MySession), "LoadMultiplayer", BindingFlags.Static | BindingFlags.NonPublic);
SendPlayerData = GetMethod(ClientType, "SendPlayerData", BindingFlags.Instance | BindingFlags.NonPublic);
UnloadProceduralWorldGenerator = GetMethod(typeof(MyProceduralWorldGenerator), "UnloadData", BindingFlags.Instance | BindingFlags.NonPublic);
GPSRegisterChat = GetMethod(typeof(MyGpsCollection), "RegisterChat", BindingFlags.Instance | BindingFlags.NonPublic);
@@ -128,7 +129,7 @@ namespace SeamlessClientPlugin.SeamlessTransfer
//Test patches
MethodInfo SetPlayerDed = GetMethod(typeof(MyPlayerCollection), "SetPlayerDeadInternal", BindingFlags.Instance | BindingFlags.NonPublic);
//MethodInfo SetPlayerDed = GetMethod(typeof(MyPlayerCollection), "SetPlayerDeadInternal", BindingFlags.Instance | BindingFlags.NonPublic);
@@ -140,7 +141,7 @@ namespace SeamlessClientPlugin.SeamlessTransfer
Patcher.Patch(LoadingScreenDraw, prefix: new HarmonyMethod(GetPatchMethod(nameof(DrawInternal))));
Patcher.Patch(OnJoin, postfix: new HarmonyMethod(GetPatchMethod(nameof(OnUserJoined))));
Patcher.Patch(LoadingAction, prefix: new HarmonyMethod(GetPatchMethod(nameof(LoadMultiplayerSession))));
Patcher.Patch(SetPlayerDed, prefix: new HarmonyMethod(GetPatchMethod(nameof(SetPlayerDeadInternal))));
//Patcher.Patch(SetPlayerDed, prefix: new HarmonyMethod(GetPatchMethod(nameof(SetPlayerDeadInternal))));
@@ -434,73 +435,6 @@ namespace SeamlessClientPlugin.SeamlessTransfer
{
throw Ex;
}
}
private static bool SetPlayerDeadInternal(MyPlayerCollection __instance, bool __result, ulong playerSteamId, int playerSerialId, bool deadState, bool resetIdentity)
{
FieldInfo ControlledEntities = typeof(MyPlayerCollection).GetField("m_controlledEntities", BindingFlags.Instance | BindingFlags.NonPublic);
MethodInfo RemoveControlledEntity = typeof(MyPlayerCollection).GetMethod("RemoveControlledEntityInternal", BindingFlags.Instance | BindingFlags.NonPublic);
CachingDictionary<long, MyPlayer.PlayerId> m_controlledEntities = (CachingDictionary<long, MyPlayer.PlayerId>)ControlledEntities.GetValue(__instance);
MyPlayer.PlayerId id = new MyPlayer.PlayerId(playerSteamId, playerSerialId);
MyPlayer playerById = Sync.Players.GetPlayerById(id);
if (playerById == null)
{
__result = false;
return false;
}
if (playerById.Identity == null)
{
__result = false;
return false;
}
playerById.Identity.SetDead(resetIdentity);
if (deadState)
{
SeamlessClient.TryShow($"Player: {playerSteamId}, SerialID: {playerSerialId} deadstate: {deadState}, resetIdentity: {resetIdentity}");
playerById.Controller.TakeControl(null);
foreach (KeyValuePair<long, MyPlayer.PlayerId> controlledEntity in m_controlledEntities)
{
if (controlledEntity.Value == playerById.Id)
{
MyEntity entity = null;
MyEntities.TryGetEntityById(controlledEntity.Key, out entity);
if (entity != null)
{
//RemoveControlledEntityInternal(entity, false);
RemoveControlledEntity.Invoke(__instance, new object[] { entity, false });
}
}
}
m_controlledEntities.ApplyRemovals();
if (Sync.Clients.LocalClient != null && playerById == Sync.Clients.LocalClient.FirstPlayer)
{
MyPlayer P = Sync.Clients.LocalClient.FirstPlayer;
SeamlessClient.TryShow($"FirstPlayerName: {P.DisplayName}, ID: {P.Id.SteamId}, Serial: {P.Id.SerialId}");
SeamlessClient.TryShow(Environment.StackTrace);
MyPlayerCollection.RequestLocalRespawn();
}
}
__result = true;
return false;
}
}
}