public static bool Prefix(ScienceManagerPlayer __instance, int progress) { Team team = TeamManager.GetTeamManager().GetTeam(__instance.Player); if (null == team) { return(true); } ScienceManagerPlayer fake_player_ScienceManager = ScienceManager.GetPlayerManager(team.fake_player); ResolvedResearchable research = ScienceManager.GetResearchable(__instance.ActiveResearch.research.GetKey()); if (fake_player_ScienceManager.HasCompleted(research)) { return(true); } if (fake_player_ScienceManager.ActiveResearch.research == __instance.ActiveResearch.research) { fake_player_ScienceManager.AddActiveResearchProgress(progress); } else { fake_player_ScienceManager.Select(research); fake_player_ScienceManager.AddActiveResearchProgress(progress); } return(true); }
public static void Postfix(ScienceManagerPlayer __instance) { //Not is fake_player if (__instance.Player.ID.type != NetworkID.IDType.Steam || __instance.Player.ID.steamID.GetEAccountType() != Steamworks.EAccountType.k_EAccountTypeAnonUser) { return; } ResolvedResearchable research = ScienceManager.GetResearchable(__instance.ActiveResearch.research.GetKey()); if (__instance.HasCompleted(research)) { foreach (Players.Player plr in TeamManager.GetTeamManager().GetTeamOfFakePlayer(__instance.Player).GetPlayers()) { ScienceManagerPlayer SMP = ScienceManager.GetPlayerManager(plr); if (null == SMP || SMP.HasCompleted(research)) { continue; } int addProgress = __instance.ActiveResearch.progress - SMP.ActiveResearch.progress; if (addProgress > 0) { if (__instance.ActiveResearch.research != SMP.ActiveResearch.research) { SMP.Select(research); } SMP.AddActiveResearchProgress(addProgress); } } } }
//Synchronization of research progess of the selected research public static void Postfix(ScienceManagerPlayer __instance) { //If NOT fake player if (__instance.Player.ID.type != NetworkID.IDType.Steam || __instance.Player.ID.steamID.GetEAccountType() != Steamworks.EAccountType.k_EAccountTypeAnonUser) { return; } ScienceManagerPlayer fake_player_ScienceManager = ScienceManager.GetPlayerManager(__instance.Player); if (!fake_player_ScienceManager.TryGetProgress(__instance.ActiveResearch.research, out ResearchProgress rp)) { return; } int addProgress = rp.progress - __instance.ActiveResearch.progress; if (addProgress > 0) { __instance.AddActiveResearchProgress(addProgress); } }