public static void Postfix(SGBarracksRosterSlot __instance) { if (__instance.Pilot == null) { return; } HBSTooltip tooltip = __instance.gameObject.GetComponent <HBSTooltip>() ?? __instance.gameObject.AddComponent <HBSTooltip>(); Pilot pilot = __instance.Pilot; string Desc = tooltip.GetText(); if (String.IsNullOrEmpty(Desc)) { Desc = ""; } foreach (PilotTooltipTag pqTag in Main.settings.pqTooltipTags) { if (pilot.pilotDef.PilotTags.Contains(pqTag.tag)) { Desc += $"{pqTag.tooltipText}\n\n"; } } Desc += PilotQuirkManager.Instance.getPilotToolTip(pilot); Desc += "<b>Pilot Affinities:</b>\n\n"; Desc += PilotAffinityManager.Instance.getPilotToolTip(pilot); var descriptionDef = new BaseDescriptionDef("Tags", pilot.Callsign, Desc, null); tooltip.SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(descriptionDef)); }
public static bool Prefix(SG_HiringHall_Screen __instance, SGBarracksRosterSlot slot) { var widget = __instance; bool newPilotClicked = widget.RosterList.SelectedSlot != slot; widget.RosterList.OnSlotSelected(slot); if (newPilotClicked) { if (modSettings.EnablePilotBarks) { widget.DetailPanel.PlayPilotSelectionVO(slot.Pilot); } } return(false); }
public static bool Prefix(SGBarracksWidget __instance, SGBarracksRosterSlot slot) { var widget = __instance; bool newPilotClicked = widget.rosterList.SelectedSlot != slot; widget.rosterList.OnSlotSelected(slot); if (newPilotClicked) { if (modSettings.EnablePilotBarks) { widget.mechWarriorDetails.PlayPilotChosenVO(slot.Pilot); } } return(false); }
public static void Postfix(SGBarracksRosterSlot __instance) { if (__instance.Pilot == null) { return; } var tooltip = __instance.gameObject.GetComponent <HBSTooltip>() ?? __instance.gameObject.AddComponent <HBSTooltip>(); var p = __instance.Pilot; string TagDesc = ""; if (p.pilotDef.PilotTags.Contains("pilot_fatigued")) { TagDesc += "<b>***PILOT FATIGUED***</b>\nPilot will suffer from Low Spirits if used in combat. The lance will also experience reduced Resolve per turn during combat.\n\n"; } else if (p.pilotDef.PilotTags.Contains("pilot_lightinjury")) { TagDesc += "<b>***PILOT LIGHT INJURY***</b>\nPilot cannot drop into combat. This pilot requires rest after dropping too frequently while fatigued.\n\n"; } foreach (var tag in p.pilotDef.PilotTags) { if (Pre_Control.settings.TagIDToDescription.Keys.Contains(tag)) { TagDesc += "<b>" + Pre_Control.settings.TagIDToNames[tag] + ": </b>" + Pre_Control.settings.TagIDToDescription[tag] + "\n\n"; } else if (tag == "PQ_Mech_Mastery") { TagDesc = MechMasterTagDescription(__instance.pilot, TagDesc); } } var descriptionDef = new BaseDescriptionDef("Tags", p.Callsign, TagDesc, null); tooltip.SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(descriptionDef)); }
static bool Prefix(SGBarracksRosterList __instance, Pilot pilot, UnityAction <SGBarracksRosterSlot> pilotSelectedOnClick, bool isInHireHall, Dictionary <string, SGBarracksRosterSlot> ___currentRoster) { if (ModState.SimGameState == null) { return(true); // Only patch if we're in SimGame } Mod.Log.Debug?.Write($"Adding pilot {pilot.Callsign} to roster list."); if (!___currentRoster.ContainsKey(pilot.GUID)) { SGBarracksRosterSlot slot = __instance.GetSlot(); if (isInHireHall) { slot.InitNoDrag(pilot, ModState.SimGameState, pilotSelectedOnClick, showTheCost: true); slot.SetDraggable(isDraggable: false); // Update the pilot's contract end date CrewDetails details = ModState.GetCrewDetails(pilot.pilotDef); details.ExpirationDay = ModState.SimGameState.DaysPassed + details.ContractTerm; Mod.Log.Debug?.Write($" - pilot's contract ends on day: {details.ExpirationDay}"); ModState.UpdateOrCreateCrewDetails(pilot.pilotDef, details); } else { slot.Init(pilot, __instance, pilotSelectedOnClick); } ___currentRoster.Add(pilot.GUID, slot); slot.AddToRadioSet(__instance.listRadioSet); // Performance tweak; skip //ForceRefreshImmediate(); } return(false); }
static void Postfix(SGBarracksRosterSlot __instance, Pilot ___pilot, GameObject ___AbilitiesObject, LocalizableText ___callsign, Image ___portrait, SVGImage ___roninIcon, SVGImage ___veteranIcon, LocalizableText ___expertise, HBSTooltip ___ExpertiseTooltip) { if (ModState.SimGameState == null) { return; // Only patch if we're in SimGame } if (___pilot == null) { return; } Mod.Log.Debug?.Write($"POST Calling refresh for pilot: {___pilot.Name}"); CrewDetails details = ModState.GetCrewDetails(___pilot.pilotDef); // Find the common GameObjects we need to manipulate GameObject portraitOverride = GetOrCreateProfileOverride(___portrait); if (details.IsAerospaceCrew || details.IsMechTechCrew || details.IsMedTechCrew || details.IsVehicleCrew) { portraitOverride.SetActive(true); } else { portraitOverride.SetActive(false); } GameObject crewBlock = GetOrCreateCrewBlock(___portrait.gameObject); if (details.IsAerospaceCrew || details.IsMechTechCrew || details.IsMedTechCrew) { crewBlock.SetActive(true); } else { crewBlock.SetActive(false); } GameObject mwStats = ___portrait.transform.parent.parent.gameObject.FindFirstChildNamed(ModConsts.GO_HBS_Profile_Stats_Block); if (details.IsAerospaceCrew || details.IsMechTechCrew || details.IsMedTechCrew) { mwStats.SetActive(false); } else { mwStats.SetActive(true); } GameObject layoutTitleGO = __instance.GameObject.FindFirstChildNamed(ModConsts.GO_HBS_Profile_Layout_Title); Image layoutTitleImg = layoutTitleGO.GetComponent <Image>(); if (details.IsAerospaceCrew) { Mod.Log.Debug?.Write($" -- pilot is Aerospace crew"); layoutTitleImg.color = Mod.Config.Crew.AerospaceColor; ___portrait.gameObject.SetActive(false); ___AbilitiesObject.SetActive(false); ___roninIcon.gameObject.SetActive(false); ___veteranIcon.gameObject.SetActive(false); // Set the portrait icon SVGAsset icon = ModState.SimGameState.DataManager.GetObjectOfType <SVGAsset>(Mod.Config.Icons.CrewPortrait_Aerospace, BattleTechResourceType.SVGAsset); if (icon == null) { Mod.Log.Warn?.Write($"ERROR READING ICON: {Mod.Config.Icons.CrewPortrait_Aerospace}"); } SVGImage image = portraitOverride.GetComponentInChildren <SVGImage>(); image.vectorGraphics = icon; // Set the crew size LocalizableText[] texts = crewBlock.GetComponentsInChildren <LocalizableText>(); LocalizableText lt1 = texts[0]; string sizeText = new Localize.Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Size], new object[] { details.SizeLabel, details.Size }).ToString(); lt1.SetText(sizeText); // Force the font size here, otherwise the right hand panel isn't correct lt1.fontSize = 16f; lt1.fontSizeMin = 16f; lt1.fontSizeMax = 16f; LocalizableText lt2 = texts[1]; string skillText = new Localize.Text(Mod.LocalizedText.Labels[ModText.LT_Skill_Aerospace_Points], new object[] { details.Value }).ToString(); lt2.SetText(skillText); // Force the font size here, otherwise the right hand panel isn't correct lt2.fontSize = 16f; lt2.fontSizeMin = 16f; lt2.fontSizeMax = 16f; // Set the expertise of the crew ___expertise.color = Color.white; ___expertise.SetText(details.ExpertiseLabel); } else if (details.IsMechTechCrew) { Mod.Log.Debug?.Write($" -- pilot is Mechtech crew"); layoutTitleImg.color = Mod.Config.Crew.MechTechCrewColor; ___portrait.gameObject.SetActive(false); ___AbilitiesObject.SetActive(false); ___roninIcon.gameObject.SetActive(false); ___veteranIcon.gameObject.SetActive(false); // Set the portrait icon SVGAsset icon = ModState.SimGameState.DataManager.GetObjectOfType <SVGAsset>(Mod.Config.Icons.CrewPortrait_MechTech, BattleTechResourceType.SVGAsset); if (icon == null) { Mod.Log.Warn?.Write($"ERROR READING ICON: {Mod.Config.Icons.CrewPortrait_MechTech}"); } SVGImage image = portraitOverride.GetComponentInChildren <SVGImage>(); image.vectorGraphics = icon; // Set the crew size LocalizableText[] texts = crewBlock.GetComponentsInChildren <LocalizableText>(); LocalizableText lt1 = texts[0]; string sizeText = new Localize.Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Size], new object[] { details.SizeLabel, details.Size }).ToString(); lt1.SetText(sizeText); // Force the font size here, otherwise the right hand panel isn't correct lt1.fontSize = 16f; lt1.fontSizeMin = 16f; lt1.fontSizeMax = 16f; LocalizableText lt2 = texts[1]; string skillText = new Localize.Text(Mod.LocalizedText.Labels[ModText.LT_Skill_MechTech_Points], new object[] { details.Value }).ToString(); lt2.SetText(skillText); // Force the font size here, otherwise the right hand panel isn't correct lt2.fontSize = 16f; lt2.fontSizeMin = 16f; lt2.fontSizeMax = 16f; // Set the expertise of the crew ___expertise.color = Color.white; ___expertise.SetText(details.ExpertiseLabel); } else if (details.IsMedTechCrew) { Mod.Log.Debug?.Write($" -- pilot is Medtech crew"); layoutTitleImg.color = Mod.Config.Crew.MedTechCrewColor; ___portrait.gameObject.SetActive(false); ___AbilitiesObject.SetActive(false); ___roninIcon.gameObject.SetActive(false); ___veteranIcon.gameObject.SetActive(false); // Set the portrait icon SVGAsset icon = ModState.SimGameState.DataManager.GetObjectOfType <SVGAsset>(Mod.Config.Icons.CrewPortrait_MedTech, BattleTechResourceType.SVGAsset); if (icon == null) { Mod.Log.Warn?.Write($"ERROR READING ICON: {Mod.Config.Icons.CrewPortrait_MedTech}"); } SVGImage image = portraitOverride.GetComponentInChildren <SVGImage>(); image.vectorGraphics = icon; // Set the crew size LocalizableText[] texts = crewBlock.GetComponentsInChildren <LocalizableText>(); LocalizableText lt1 = texts[0]; string sizeText = new Localize.Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Size], new object[] { details.SizeLabel, details.Size }).ToString(); lt1.SetText(sizeText); // Force the font size here, otherwise the right hand panel isn't correct lt1.fontSize = 16f; lt1.fontSizeMin = 16f; lt1.fontSizeMax = 16f; LocalizableText lt2 = texts[1]; string skillText = new Localize.Text(Mod.LocalizedText.Labels[ModText.LT_Skill_MedTech_Points], new object[] { details.Value }).ToString(); lt2.SetText(skillText); // Force the font size here, otherwise the right hand panel isn't correct lt2.fontSize = 16f; lt2.fontSizeMin = 16f; lt2.fontSizeMax = 16f; // Set the expertise of the crew ___expertise.color = Color.white; ___expertise.SetText(details.ExpertiseLabel); } else if (details.IsVehicleCrew) { Mod.Log.Debug?.Write($" -- pilot is Vehicle crew"); layoutTitleImg.color = Mod.Config.Crew.VehicleCrewColor; ___portrait.gameObject.SetActive(false); ___roninIcon.gameObject.SetActive(false); ___callsign.SetText("VCREW: " + ___pilot.Callsign); // Set the portrait icon SVGAsset icon = ModState.SimGameState.DataManager.GetObjectOfType <SVGAsset>(Mod.Config.Icons.CrewPortrait_Vehicle, BattleTechResourceType.SVGAsset); if (icon == null) { Mod.Log.Warn?.Write($"ERROR READING ICON: {Mod.Config.Icons.CrewPortrait_Vehicle}"); } SVGImage image = portraitOverride.GetComponentInChildren <SVGImage>(); image.vectorGraphics = icon; ___expertise.color = Color.white; } else { Mod.Log.Debug?.Write($" -- pilot is Mechwarrior"); ___portrait.gameObject.SetActive(true); } Mod.Log.Debug?.Write($"LayoutTitleImg color set to: {layoutTitleImg.color}"); }
public static int CompareByCrewTypeAndValue(SGBarracksRosterSlot slot1, SGBarracksRosterSlot slot2) { // Check nullity if (slot1 == null && slot2 == null) { return(0); } else if (slot1 != null && slot2 == null) { return(1); } else if (slot1 == null && slot2 != null) { return(-1); } // Check pilot vs. non-pilot if (slot1.Pilot == null && slot2.Pilot == null) { return(0); } else if (slot1.Pilot != null && slot2.Pilot == null) { return(1); } else if (slot1.Pilot == null && slot2.Pilot != null) { return(-1); } // Check pilot vs. non-pilot using pilotDefs if (slot1.Pilot.pilotDef == null && slot2.Pilot.pilotDef == null) { return(0); } else if (slot1.Pilot.pilotDef != null && slot2.Pilot.pilotDef == null) { return(1); } else if (slot1.Pilot.pilotDef == null && slot2.Pilot.pilotDef != null) { return(-1); } // Check details CrewDetails cd1 = ModState.GetCrewDetails(slot1.Pilot.pilotDef); CrewDetails cd2 = ModState.GetCrewDetails(slot2.Pilot.pilotDef); // Compare by type int typeComparison = CrewDetails.CompareByType(cd1, cd2); if (typeComparison != 0) { return(typeComparison); } // Compare by skill int skillComparison = CrewDetails.CompareByValue(cd1, cd2); if (skillComparison != 0) { return(skillComparison); } return(0); }