static bool Prefix(AAR_UnitsResult_Screen __instance) { try { if (CustomUnitsAPI.Detected()) { return(true); } Contract theContract = (Contract)AccessTools.Field(typeof(AAR_UnitsResult_Screen), "theContract").GetValue(__instance); List <AAR_UnitStatusWidget> UnitWidgets = (List <AAR_UnitStatusWidget>)AccessTools.Field(typeof(AAR_UnitsResult_Screen), "UnitWidgets").GetValue(__instance); List <UnitResult> UnitResults = (List <UnitResult>)AccessTools.Field(typeof(AAR_UnitsResult_Screen), "UnitResults").GetValue(__instance); int experienceEarned = theContract.ExperienceEarned; for (int i = 0; i < 8; i++) { UnitWidgets[i].SetMechIconValueTextActive(false); if (UnitResults[i] != null) { UnitWidgets[i].SetNoUnitDeployedOverlayActive(false); UnitWidgets[i].FillInData(experienceEarned); } else { UnitWidgets[i].SetNoUnitDeployedOverlayActive(true); } } AccessTools.Field(typeof(AAR_UnitsResult_Screen), "UnitWidgets").SetValue(__instance, UnitWidgets); return(false); } catch (Exception e) { Logger.LogError(e); return(true); } }
static void Postfix(SGCmdCenterLanceConfigBG __instance) { if (CustomUnitsAPI.Detected() == false) { BiggerDrops.baysAlreadyAdded = 0; __instance.LC.UpdateSlotsCount(Settings.MAX_ADDITINAL_MECH_SLOTS + BiggerDrops.settings.additinalMechSlots); } }
static void Postfix(LanceConfiguratorPanel __instance, ref LanceConfiguration __result, LanceLoadoutSlot[] ___loadoutSlots) { try { if (CustomUnitsAPI.Detected()) { return; } Fields.callsigns.Clear(); LanceConfiguration lanceConfiguration = new LanceConfiguration(); for (int i = 0; i < ___loadoutSlots.Length; i++) { LanceLoadoutSlot lanceLoadoutSlot = ___loadoutSlots[i]; MechDef mechDef = null; PilotDef pilotDef = null; if (lanceLoadoutSlot.SelectedMech != null) { mechDef = lanceLoadoutSlot.SelectedMech.MechDef; } if (lanceLoadoutSlot.SelectedPilot != null) { pilotDef = lanceLoadoutSlot.SelectedPilot.Pilot.pilotDef; } if (mechDef != null && pilotDef != null) { if (i < Settings.DEFAULT_MECH_SLOTS) { lanceConfiguration.AddUnit(__instance.playerGUID, mechDef, pilotDef); } else { //if (i >= BiggerDrops.settings.additinalMechSlots + Settings.DEFAULT_MECH_SLOTS) { break; } Logger.M.TWL(0, "LanceConfiguratorPanel.CreateLanceConfiguration. Index:" + i + " additional slots border:" + (BiggerDrops.settings.additinalMechSlots + Settings.DEFAULT_MECH_SLOTS) + " player slots border:" + (BiggerDrops.settings.additinalPlayerMechSlots + Settings.DEFAULT_MECH_SLOTS)); if (i >= BiggerDrops.settings.additinalPlayerMechSlots + Settings.DEFAULT_MECH_SLOTS) { Fields.callsigns.Add(pilotDef.Description.Callsign); //EMPLOYER ID Logger.M.WL(1, "adding to employer lance " + Settings.EMPLOYER_LANCE_GUID + " mech:" + mechDef.Description.Id + " pilot:" + pilotDef.Description.Id); lanceConfiguration.AddUnit(Settings.EMPLOYER_LANCE_GUID, mechDef, pilotDef); } else { Logger.M.WL(1, "adding to player lance " + __instance.playerGUID + " mech:" + mechDef.Description.Id + " pilot:" + pilotDef.Description.Id); lanceConfiguration.AddUnit(__instance.playerGUID, mechDef, pilotDef); } } } } __result = lanceConfiguration; } catch (Exception e) { Logger.LogError(e); } }
static bool Prefix(AAR_UnitsResult_Screen __instance, MissionResults mission, SimGameState sim, Contract contract) { try { if (CustomUnitsAPI.Detected()) { return(true); } List <AAR_UnitStatusWidget> UnitWidgets = (List <AAR_UnitStatusWidget>)AccessTools.Field(typeof(AAR_UnitsResult_Screen), "UnitWidgets").GetValue(__instance); GameObject nextButton = __instance.transform.FindRecursive("buttonPanel").gameObject; nextButton.transform.localPosition = new Vector3(150, 400, 0); Transform parent = UnitWidgets[0].transform.parent; parent.localPosition = new Vector3(0, 115, 0); foreach (AAR_UnitStatusWidget oldWidget in UnitWidgets) { oldWidget.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f); } GameObject newparent = GameObject.Instantiate(parent.gameObject); newparent.transform.parent = parent.parent; newparent.name = "newparent"; newparent.transform.localPosition = new Vector3(0, -325, 0); foreach (Transform t in newparent.transform) { UnitWidgets.Add(t.gameObject.GetComponent <AAR_UnitStatusWidget>()); } AccessTools.Field(typeof(AAR_UnitsResult_Screen), "UnitWidgets").SetValue(__instance, UnitWidgets); List <UnitResult> UnitResults = new List <UnitResult>(); for (int i = 0; i < 8; i++) { if (i < contract.PlayerUnitResults.Count) { UnitResults.Add(contract.PlayerUnitResults[i]); } else { UnitResults.Add(null); } } AccessTools.Field(typeof(AAR_UnitsResult_Screen), "simState").SetValue(__instance, sim); AccessTools.Field(typeof(AAR_UnitsResult_Screen), "missionResultParent").SetValue(__instance, mission); AccessTools.Field(typeof(AAR_UnitsResult_Screen), "theContract").SetValue(__instance, contract); AccessTools.Field(typeof(AAR_UnitsResult_Screen), "numUnits").SetValue(__instance, contract.PlayerUnitResults.Count); AccessTools.Field(typeof(AAR_UnitsResult_Screen), "UnitResults").SetValue(__instance, UnitResults); __instance.Visible = false; __instance.InitializeWidgets(); return(false); } catch (Exception e) { Logger.LogError(e); return(true); } }
public void UpdateCULances() { if (CustomUnitsAPI.Detected()) { int lanceCount = 1; int mCount = BiggerDrops.settings.additinalMechSlots; while (mCount > 0) { lanceCount++; mCount -= 4; } int vCount = BiggerDrops.settings.vehicleCount; while (vCount > 0) { lanceCount++; vCount -= 4; } int iBayCount = Math.Max(MIN_CU_MECHBAYS, companyStats.GetValue <int>("MechBayPods")); if (debugLanceLoadout) { CustomUnitsAPI.setLancesCount(3); CustomUnitsAPI.setLanceData(0, 6, 5, false); CustomUnitsAPI.setLanceData(1, 4, 4, false); CustomUnitsAPI.setLanceData(2, 4, 2, true); CustomUnitsAPI.setOverallDeployCount(6); CustomUnitsAPI.playerControl(-1, -1); } else { CustomUnitsAPI.setLancesCount(lanceCount); CustomUnitsAPI.setLanceData(0, DEFAULT_MECH_SLOTS, DEFAULT_MECH_SLOTS, false); int vStart = 1; mCount = BiggerDrops.settings.additinalMechSlots; while (mCount > 0) { CustomUnitsAPI.setLanceData(vStart, DEFAULT_MECH_SLOTS, mCount > DEFAULT_MECH_SLOTS ? DEFAULT_MECH_SLOTS : mCount, false); vStart++; mCount -= 4; } vCount = BiggerDrops.settings.vehicleCount; while (vCount > 0) { CustomUnitsAPI.setLanceData(vStart, DEFAULT_MECH_SLOTS, vCount > DEFAULT_MECH_SLOTS ? DEFAULT_MECH_SLOTS : vCount, true); vStart++; vCount -= 4; } CustomUnitsAPI.setOverallDeployCount(System.Math.Min(DEFAULT_MECH_SLOTS + BiggerDrops.settings.additinalMechSlots + BiggerDrops.settings.vehicleCount, MAX_CU_DROP_SIZE)); CustomUnitsAPI.playerControl(DEFAULT_MECH_SLOTS + BiggerDrops.settings.additinalPlayerMechSlots, BiggerDrops.settings.vehicleCount); CustomUnitsAPI.setMechBayCount(iBayCount); } } }
public static void FinishedLoading(List <string> loadOrder) { Logger.M.TWL(0, "FinishedLoading", true); try { foreach (string name in loadOrder) { if (name == "CustomUnits") { CustomUnitsAPI.CustomUnitsDetected(); break; } ; } } catch (Exception e) { Logger.M.TWL(0, e.ToString(), true); } }
static void Prefix(LanceConfiguratorPanel __instance, ref int maxUnits, Contract contract) { try { if (CustomUnitsAPI.Detected()) { return; } if (contract != null) { maxUnits = Settings.MAX_ADDITINAL_MECH_SLOTS + BiggerDrops.settings.additinalMechSlots; __instance.UpdateSlotsCount(maxUnits); if (contract.Override != null) { if (contract.IsFlashpointContract | contract.IsFlashpointCampaignContract) { if (BiggerDrops.settings.limitFlashpointDrop) { maxUnits = 4; } } if (BiggerDrops.settings.respectFourDropLimit) { if (contract.Override.maxNumberOfPlayerUnits != -1) { maxUnits = contract.Override.maxNumberOfPlayerUnits; } } else { if (contract.Override.maxNumberOfPlayerUnits < 4) { maxUnits = contract.Override.maxNumberOfPlayerUnits; } } } } else { maxUnits = Settings.MAX_ADDITINAL_MECH_SLOTS + Settings.MAX_ADDITINAL_MECH_SLOTS; BiggerDrops.baysAlreadyAdded = 0; __instance.UpdateSlotsCount(maxUnits); //SkirmishUIFix(__instance,maxUnits); } } catch (Exception e) { Logger.M.TWL(0, e.ToString()); } }
static void Prefix(Contract __instance) { try { if (CustomUnitsAPI.Detected()) { return; } CombatGameState combat = __instance.BattleTechGame.Combat; List <Mech> allMechs = combat.AllMechs; foreach (Mech mech in allMechs) { if (Fields.callsigns.Contains(mech.pilot.Callsign)) { AccessTools.Field(typeof(Mech), "_teamId").SetValue(mech, combat.LocalPlayerTeam.GUID); } } } catch (Exception e) { Logger.LogError(e); } }
static void Prefix(SkirmishMechBayPanel __instance, LanceDef lance) { try { if (CustomUnitsAPI.Detected()) { return; } int maxUnits = Settings.MAX_ADDITINAL_MECH_SLOTS + Settings.MAX_ADDITINAL_MECH_SLOTS; if (lance != null) { maxUnits = lance.LanceUnits.Length; } if (__instance.loadoutSlots.Length >= maxUnits) { return; } if (__instance.loadoutSlots.Length < 2) { maxUnits = __instance.loadoutSlots.Length; return; } ; float ydelta = __instance.loadoutSlots[1].GetComponent <RectTransform>().localPosition.y - __instance.loadoutSlots[0].GetComponent <RectTransform>().localPosition.y; int addUnits = maxUnits - __instance.loadoutSlots.Length; GameObject srcLayout = __instance.loadoutSlots[__instance.loadoutSlots.Length - 1].gameObject; List <LanceLoadoutSlot> slots = new List <LanceLoadoutSlot>(); slots.AddRange(__instance.loadoutSlots); for (int t = 0; t < addUnits; ++t) { GameObject nLayout = GameObject.Instantiate(srcLayout, srcLayout.transform.parent); RectTransform rt = nLayout.GetComponent <RectTransform>(); Vector3 pos = rt.localPosition; pos.y = srcLayout.GetComponent <RectTransform>().localPosition.y + (t + 1) * ydelta; rt.localPosition = pos; slots.Add(nLayout.GetComponent <LanceLoadoutSlot>()); } __instance.loadoutSlots = slots.ToArray(); } catch (Exception e) { Logger.M.TWL(0, e.ToString()); } }
public static void Postfix(CombatHUDMechwarriorTray __instance, CombatGameState Combat, CombatHUD HUD) { if (CustomUnitsAPI.Detected()) { return; } Logger.M.TWL(0, "CombatHUDMechwarriorTray.Init postfix"); try { if (__instance.PortraitHolders.Length <= 4) { return; } for (int index = 0; index < __instance.PortraitHolders.Length; ++index) { Vector3[] corners = new Vector3[4]; __instance.PortraitHolders[index].GetComponent <RectTransform>().GetWorldCorners(corners); Logger.M.WL(1, "portrait " + __instance.PortraitHolders[index].GetInstanceID() + ". index:" + index + " corners 0:" + corners[0] + " 1:" + corners[1] + " 2:" + corners[2] + " 3:" + corners[3]); foreach (Component component in __instance.PortraitHolders[index].GetComponentsInChildren <Component>()) { Logger.M.WL(3, component.name + ":" + component.GetType() + ":" + component.GetInstanceID()); } } for (int index = 0; index < __instance.portraitTweens.Length; ++index) { Vector3[] corners = new Vector3[4]; __instance.portraitTweens[index].gameObject.GetComponent <RectTransform>().GetWorldCorners(corners); Logger.M.WL(1, "tween " + __instance.portraitTweens[index].gameObject.GetInstanceID() + ". index:" + index + " corners 0:" + corners[0] + " 1:" + corners[1] + " 2:" + corners[2] + " 3:" + corners[3]); foreach (Component component in __instance.portraitTweens[index].gameObject.GetComponentsInChildren <Component>()) { Logger.M.WL(3, component.name + ":" + component.GetType() + ":" + component.GetInstanceID()); } } Logger.M.WL(0, "Moralebar diactivate"); CombatHUDMoraleBar combatHUDMoraleBar = (CombatHUDMoraleBar)typeof(CombatHUDMechwarriorTray).GetProperty("moraleDisplay", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance, new object[0] { }); combatHUDMoraleBar.gameObject.SetActive(false); } catch (Exception e) { Logger.M.TWL(0, e.ToString(), true); } }
public static void FinishedLoading(List <string> loadOrder, Dictionary <string, Dictionary <string, VersionManifestEntry> > customResources) { Logger.M.TWL(0, "FinishedLoading", true); try { foreach (string name in loadOrder) { if (name == "CustomUnits") { CustomUnitsAPI.CustomUnitsDetected(); break; } ; } foreach (var customResource in customResources) { Logger.M.TWL(0, "customResource:" + customResource.Key); if (customResource.Key == nameof(DropSlotDef)) { List <DropSlotDef> defs = new List <DropSlotDef>(); foreach (var custItem in customResource.Value) { try { Logger.M.WL(1, "Path:" + custItem.Value.FilePath); DropSlotDef def = JsonConvert.DeserializeObject <DropSlotDef>(File.ReadAllText(custItem.Value.FilePath)); Logger.M.WL(1, "id:" + def.Description.Id); Logger.M.WL(1, JsonConvert.SerializeObject(def, Formatting.Indented)); def.Register(); defs.Add(def); } catch (Exception e) { Logger.M.TWL(0, custItem.Key, true); Logger.M.WL(0, e.ToString(), true); } } DropManager.FindSlotOrder(defs); } } } catch (Exception e) { Logger.M.TWL(0, e.ToString(), true); } }
public static bool Prefix(CombatHUDMechwarriorTray __instance) { Logger.M.TWL(0, "CombatHUDMechwarriorTray.SetTrayState"); try { if (CustomUnitsAPI.Detected()) { return(true); } /*for (int index = 0; index < __instance.PortraitHolders.Length; ++index) { * Vector3[] corners = new Vector3[4]; * RectTransform prectt = __instance.PortraitHolders[index].GetComponent<RectTransform>(); * prectt.GetLocalCorners(corners); * Logger.M.WL(1, "portrait "+ prectt.name+ ":" + __instance.PortraitHolders[index].GetInstanceID() + ". index:" + index + " pos:" +prectt.localPosition+" corners 0:" + corners[0] + " 1:" + corners[1] + " 2:" + corners[2] + " 3:" + corners[3]); * }*/ if (__instance.PortraitHolders.Length <= 4) { return(true); } CombatHUDMoraleBar combatHUDMoraleBar = (CombatHUDMoraleBar)typeof(CombatHUDMechwarriorTray).GetProperty("moraleDisplay", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance, new object[0] { }); RectTransform rtr = combatHUDMoraleBar.gameObject.GetComponent <RectTransform>(); RectTransform prt = __instance.PortraitHolders[0].GetComponent <RectTransform>(); Vector3[] pcorners = new Vector3[4]; prt.GetLocalCorners(pcorners); Logger.M.WL(0, "portrait corners: bl:" + pcorners[0] + " tl:" + pcorners[1] + " tr:" + pcorners[2] + " br:" + pcorners[3]); Logger.M.WL(0, "moraleDisplay local pos:" + rtr.localPosition); Vector3 pos = rtr.localPosition; pos.x = pcorners[0].x + prt.localPosition.x - 10f; rtr.localPosition = pos; Logger.M.WL(0, "moraleDisplay local pos:" + rtr.localPosition); Logger.M.WL(0, "CombatHUDMechwarriorTray.SetTrayState"); combatHUDMoraleBar.gameObject.SetActive(true); } catch (Exception e) { Logger.M.TWL(0, e.ToString()); } return(true); }
public static bool Prefix(CombatHUDMechwarriorTray __instance, Team team, CombatGameState ___Combat) { try { if (CustomUnitsAPI.Detected()) { return(true); } //__instance.displayedTeam = team; Logger.M.TWL(0, "CombatHUDMechwarriorTray.RefreshTeam team:" + team.DisplayName + " unitCount:" + team.unitCount); foreach (var lance in ___Combat.ActiveContract.Lances.Lances) { Logger.M.WL(1, "lance:" + lance.Key + " " + lance.Value.Count); foreach (var unit in lance.Value) { Logger.M.WL(2, "pilot:" + unit.Pilot.Description.Id + " unit:" + (unit.Unit != null?unit.Unit.Description.Id:"not a mech") + " team:" + unit.TeamDefinitionGuid); } } typeof(CombatHUDMechwarriorTray).GetField("displayedTeam", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(__instance, team); CombatHUDPortrait[] Portraits = (CombatHUDPortrait[])typeof(CombatHUDMechwarriorTray).GetField("Portraits", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance); for (int index = 0; index < Portraits.Length; ++index) { Logger.M.WL(1, "set portrait " + index + " unit:" + (index < team.unitCount? team.units[index].DisplayName:"null")); if (index < team.unitCount) { Portraits[index].DisplayedActor = team.units[index]; } else { Portraits[index].DisplayedActor = null; } } return(false); } catch (Exception e) { Logger.LogLine(e.ToString()); return(true); } }
public static void UpdateSlotsCount(this LanceConfiguratorPanel panel, int maxUnits) { Logger.M.TWL(0, "LanceConfiguratorPanel.UpdateSlotsCount " + maxUnits); try { if (CustomUnitsAPI.Detected()) { return; } LanceLoadoutSlot[] loadoutSlots = (LanceLoadoutSlot[])AccessTools.Field(typeof(LanceConfiguratorPanel), "loadoutSlots").GetValue(panel); if (maxUnits <= loadoutSlots.Length) { Logger.M.TWL(1, "already fixed"); return; } ; Transform newLayoutTransform = panel.transform.FindRecursive("AlliedSlots"); GameObject newLayout; GameObject primelayout = panel.transform.FindRecursive("uixPrfPanel_LC_LanceSlots-Widget-MANAGED").gameObject; if (newLayoutTransform == null) { newLayout = GameObject.Instantiate(primelayout); newLayout.transform.parent = primelayout.transform.parent; newLayout.name = "AlliedSlots"; } else { newLayout = newLayoutTransform.gameObject; } GameObject slot1 = newLayout.transform.FindRecursive("lanceSlot1").gameObject; GameObject slot2 = newLayout.transform.FindRecursive("lanceSlot2").gameObject; GameObject slot3 = newLayout.transform.FindRecursive("lanceSlot3").gameObject; GameObject slot4 = newLayout.transform.FindRecursive("lanceSlot4").gameObject; primelayout.transform.FindRecursive("simbg").gameObject.active = false; newLayout.transform.FindRecursive("simbg").gameObject.active = false; newLayout.transform.FindRecursive("layout-lanceRating").gameObject.active = false; newLayout.transform.FindRecursive("lanceSlotHeader-Campaign").gameObject.active = true; newLayout.transform.FindRecursive("txt-unreadyLanceError").gameObject.active = false; TextMeshProUGUI aiText = newLayout.transform.FindRecursive("label-readyLanceHeading").gameObject.GetComponent <TextMeshProUGUI>(); aiText.text = BiggerDrops.settings.additionalLanceName; primelayout.transform.position = new Vector3(650, 315, primelayout.transform.position.z); primelayout.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f); newLayout.transform.position = new Vector3(650, 83, primelayout.transform.position.z); newLayout.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f); GameObject deployButton = panel.transform.FindRecursive("DeployBttn-layout").gameObject; deployButton.transform.position = new Vector3(1675, 175, deployButton.transform.position.z); //LanceLoadoutSlot[] loadoutSlots = (LanceLoadoutSlot[])AccessTools.Field(typeof(LanceConfiguratorPanel), "loadoutSlots").GetValue(panel); List <LanceLoadoutSlot> list = loadoutSlots.ToList(); int addUnits = maxUnits - Settings.DEFAULT_MECH_SLOTS; for (int i = 0; i < BiggerDrops.baysAlreadyAdded; i++) { list.RemoveAt(Settings.DEFAULT_MECH_SLOTS + i); } if (addUnits > 0) { list.Add(slot1.GetComponent <LanceLoadoutSlot>()); } if (addUnits > 1) { list.Add(slot2.GetComponent <LanceLoadoutSlot>()); } if (addUnits > 2) { list.Add(slot3.GetComponent <LanceLoadoutSlot>()); } if (addUnits > 3) { list.Add(slot4.GetComponent <LanceLoadoutSlot>()); } loadoutSlots = list.ToArray <LanceLoadoutSlot>(); AccessTools.Field(typeof(LanceConfiguratorPanel), "loadoutSlots").SetValue(panel, loadoutSlots); float[] slotMaxTonnages = (float[])AccessTools.Field(typeof(LanceConfiguratorPanel), "slotMaxTonnages").GetValue(panel); float[] slotMinTonnages = (float[])AccessTools.Field(typeof(LanceConfiguratorPanel), "slotMinTonnages").GetValue(panel); List <float> listMaxTonnages = slotMaxTonnages.ToList(); List <float> listMinTonnages = slotMinTonnages.ToList(); for (int i = 0; i < BiggerDrops.baysAlreadyAdded; i++) { listMaxTonnages.RemoveAt(Settings.DEFAULT_MECH_SLOTS + i); listMinTonnages.RemoveAt(Settings.DEFAULT_MECH_SLOTS + i); } if (addUnits > 0) { listMaxTonnages.Add(-1); } if (addUnits > 1) { listMaxTonnages.Add(-1); } if (addUnits > 2) { listMaxTonnages.Add(-1); } if (addUnits > 3) { listMaxTonnages.Add(-1); } if (addUnits > 0) { listMinTonnages.Add(-1); } if (addUnits > 1) { listMinTonnages.Add(-1); } if (addUnits > 2) { listMinTonnages.Add(-1); } if (addUnits > 3) { listMinTonnages.Add(-1); } slotMaxTonnages = listMaxTonnages.ToArray <float>(); slotMinTonnages = listMinTonnages.ToArray <float>(); AccessTools.Field(typeof(LanceConfiguratorPanel), "slotMaxTonnages").SetValue(panel, slotMaxTonnages); AccessTools.Field(typeof(LanceConfiguratorPanel), "slotMinTonnages").SetValue(panel, slotMinTonnages); BiggerDrops.baysAlreadyAdded = addUnits; Logger.M.TWL(0, "Skirmish UI fixed"); } catch (Exception e) { Logger.M.TWL(0, e.ToString()); } }
public static bool Prefix(CombatHUDMechwarriorTray __instance, CombatGameState Combat, CombatHUD HUD) { if (CustomUnitsAPI.Detected()) { return(true); } Logger.M.TWL(0, "CombatHUDMechwarriorTray.Init prefix"); if (BiggerDrops.settings.additinalPlayerMechSlots == 0) { Logger.M.WL(1, "no additional portraits needed"); return(true); } try { //int portraitsCount = 8; int portraitsCount = Combat.LocalPlayerTeam.unitCount > (Settings.DEFAULT_MECH_SLOTS + Settings.MAX_ADDITINAL_MECH_SLOTS) ? Settings.DEFAULT_MECH_SLOTS + Settings.MAX_ADDITINAL_MECH_SLOTS : Combat.LocalPlayerTeam.unitCount; if (__instance.PortraitHolders.Length >= portraitsCount) { Logger.M.WL(1, "no additional portraits needed"); return(true); } GameObject[] portraitHolders = new GameObject[portraitsCount]; HBSDOTweenToggle[] portraitTweens = new HBSDOTweenToggle[portraitsCount]; GameObject layout = __instance.PortraitHolders[0].transform.parent.gameObject; //layout.transform.localScale //GameObject elayout = GameObject.Instantiate(layout); //elayout.transform.localPosition += Vector3.up * (-30.0f); for (int index = 0; index < portraitHolders.Length; ++index) { if (index < __instance.PortraitHolders.Length) { portraitHolders[index] = __instance.PortraitHolders[index]; continue; } GameObject srcPortraitHolder = portraitHolders[index % (__instance.PortraitHolders.Length)]; GameObject newPortraitHolder = GameObject.Instantiate(srcPortraitHolder, srcPortraitHolder.transform.parent); Vector3[] corners = new Vector3[4]; srcPortraitHolder.GetComponent <RectTransform>().GetWorldCorners(corners); float height = corners[2].z - corners[0].z; //Logger.M.WL(1, "portrait. index:" + index + " corners 0:" + corners[0] + " 1:" + corners[1] + " 2:" + corners[2] + " 3:" + corners[3]); foreach (Component component in srcPortraitHolder.GetComponentsInChildren <Component>()) { Logger.M.WL(2, component.name + ":" + component.GetType() + ":" + component.GetInstanceID()); } newPortraitHolder.SetActive(true); portraitHolders[index] = newPortraitHolder; newPortraitHolder.GetComponent <RectTransform>().GetWorldCorners(corners); } __instance.PortraitHolders = portraitHolders; float spacing = 117.2f; if (__instance.portraitTweens.Length > 1) { Vector3[] corners0 = new Vector3[4]; __instance.portraitTweens[0].gameObject.GetComponent <RectTransform>().GetWorldCorners(corners0); Vector3[] corners1 = new Vector3[4]; __instance.portraitTweens[1].gameObject.GetComponent <RectTransform>().GetWorldCorners(corners1); spacing = corners1[0].x - corners0[0].x; } float diff = 0f; Vector3[] cornersl = new Vector3[4]; __instance.portraitTweens[__instance.portraitTweens.Length - 1].gameObject.GetComponent <RectTransform>().GetWorldCorners(cornersl); Vector3[] cornersf = new Vector3[4]; __instance.portraitTweens[0].gameObject.GetComponent <RectTransform>().GetWorldCorners(cornersf); diff = cornersl[0].x - cornersf[0].x + spacing; for (int index = 0; index < portraitTweens.Length; ++index) { if (index < __instance.portraitTweens.Length) { portraitTweens[index] = __instance.portraitTweens[index]; continue; } HBSDOTweenToggle srcPortraitTween = portraitTweens[index % (__instance.portraitTweens.Length)]; GameObject newPortraitTweenGO = GameObject.Instantiate(srcPortraitTween.gameObject, srcPortraitTween.gameObject.transform.parent); HBSDOTweenToggle newPortraitTween = newPortraitTweenGO.GetComponent <HBSDOTweenToggle>(); newPortraitTweenGO.transform.localPosition += Vector3.right * diff; newPortraitTween.TweenObjects[0] = portraitHolders[index]; //Logger.M.WL(1, "tween. index:" + index + " corners 0:" + corners[0] + " 1:" + corners[1] + " 2:" + corners[2] + " 3:" + corners[3]); portraitTweens[index] = newPortraitTween; //newPortraitTween.GetComponent<RectTransform>().GetWorldCorners(corners); //Logger.M.WL(1, "tween. index:" + (__instance.portraitTweens.Length + index) + " corners 0:" + corners[0] + " 1:" + corners[1] + " 2:" + corners[2] + " 3:" + corners[3]); } __instance.portraitTweens = portraitTweens; return(true); } catch (Exception e) { Logger.M.TWL(0, e.ToString(), true); return(true); } }