private static void add_default_actuators(MechDef mechdef, SimGameState simgame) { void process_location(ChassisLocations location) { var total_slots = ArmActuatorSlot.None; foreach (var item in mechdef.Inventory.Where(i => i.MountedLocation == location && i.Is <ArmActuator>()).Select(i => i.GetComponent <ArmActuator>())) { total_slots = total_slots | item.Type; } AddDefaultToInventory(mechdef, simgame, location, ArmActuatorSlot.PartShoulder, ref total_slots); AddDefaultToInventory(mechdef, simgame, location, ArmActuatorSlot.PartUpper, ref total_slots); } process_location(ChassisLocations.RightArm); process_location(ChassisLocations.LeftArm); }
private static int GetTrueSpentExperienceValue(SimGameState sim, Pilot pilot) { var gunnery = sim.GetLevelRangeCost(1, pilot.pilotDef.SkillGunnery - 1); var piloting = sim.GetLevelRangeCost(1, pilot.pilotDef.SkillPiloting - 1); var guts = sim.GetLevelRangeCost(1, pilot.pilotDef.SkillGuts - 1); var tactics = sim.GetLevelRangeCost(1, pilot.pilotDef.SkillTactics - 1); // It's a bit dodgy to do this here... but... //"pilot_assassin" : "Decreased XP cost for leveling Gunnery." //"pilot_bookish" : "Decreased XP cost for leveling Tactics. Increased XP cost for leveling Guts." , //"pilot_klutz" : "Increased XP cost to level Piloting and a small chance to eject when knocked down.", //NB: reflects cost to reach their current levels from 1, not from where they actually started... if (pilot.pilotDef.PilotTags.Contains("pilot_assassin")) { gunnery = GetLevelRangeCostAdjusted(1, pilot.pilotDef.SkillGunnery - 1, 0.85f); Logger.Log($"Assassin gunnery: normal value would be = {sim.GetLevelRangeCost(1, pilot.pilotDef.SkillGunnery - 1)}, actual value = {gunnery}"); } if (pilot.pilotDef.PilotTags.Contains("pilot_bookish")) { tactics = GetLevelRangeCostAdjusted(1, pilot.pilotDef.SkillTactics - 1, 0.85f); Logger.Log($"Bookish tactics: normal value would be = {sim.GetLevelRangeCost(1, pilot.pilotDef.SkillTactics - 1)}, actual value = {tactics}"); guts = GetLevelRangeCostAdjusted(1, pilot.pilotDef.SkillGuts - 1, 1.15f); Logger.Log($"Bookish guts: normal value would be = {sim.GetLevelRangeCost(1, pilot.pilotDef.SkillGuts - 1)}, actual value = {guts}"); } if (pilot.pilotDef.PilotTags.Contains("pilot_klutz")) { piloting = GetLevelRangeCostAdjusted(1, pilot.pilotDef.SkillPiloting - 1, 1.15f); Logger.Log($"Klutz piloting: normal value would be = {sim.GetLevelRangeCost(1, pilot.pilotDef.SkillPiloting - 1)}, actual value = {piloting}"); } //Logger.Log($"Skill:\t{pilot.pilotDef.SkillGunnery}, {pilot.pilotDef.SkillPiloting}, {pilot.pilotDef.SkillGuts}, {pilot.pilotDef.SkillTactics}"); //Logger.Log($"Base:\t{pilot.pilotDef.BaseGunnery}, {pilot.pilotDef.BasePiloting}, {pilot.pilotDef.BaseGuts}, {pilot.pilotDef.BaseTactics}"); //Logger.Log($"Bonus:\t{pilot.pilotDef.BonusGunnery}, {pilot.pilotDef.BonusPiloting}, {pilot.pilotDef.BonusGuts}, {pilot.pilotDef.BonusTactics}"); //Logger.Log($"Spent:\t{gunnery} + {piloting} + {guts} + {tactics} = {gunnery + piloting + guts + tactics} =? {pilot.pilotDef.ExperienceSpent + pilot.pilotDef.ExperienceUnspent} = {pilot.pilotDef.ExperienceSpent} + {pilot.pilotDef.ExperienceUnspent}"); //var gunnery2 = sim.GetLevelRangeCost(pilot.pilotDef.BaseGunnery, pilot.pilotDef.SkillGunnery - 1); //var piloting2 = sim.GetLevelRangeCost(pilot.pilotDef.BasePiloting, pilot.pilotDef.SkillPiloting - 1); //var guts2 = sim.GetLevelRangeCost(pilot.pilotDef.BaseGuts, pilot.pilotDef.SkillGuts - 1); //var tactics2 = sim.GetLevelRangeCost(pilot.pilotDef.BaseTactics, pilot.pilotDef.SkillTactics - 1); //Logger.Log($"Skill/Base diff:\t{gunnery2} + {piloting2} + {guts2} + {tactics2} = {gunnery2 + piloting2 + guts2 + tactics2} =? {pilot.pilotDef.ExperienceSpent} spent"); return(gunnery + piloting + guts + tactics); }
public static void UnStorageOmniMechPopup(SimGameState s, MechDef d, Action onClose) { if (Settings.OmniMechTag == null) { onClose?.Invoke(); throw new InvalidOperationException("omnimechs disabled"); } int mechbay = s.GetFirstFreeMechBay(); if (mechbay < 0) { onClose?.Invoke(); return; } IEnumerable <MechDef> mechs = GetAllOmniVariants(s, d); string desc = "Yang: We know the following Omni variants. What should I ready this 'Mech as?\n\n"; GenericPopupBuilder pop = GenericPopupBuilder.Create("Ready 'Mech?", desc); pop.AddButton("nothing", onClose, true, null); foreach (MechDef m in mechs) { MechDef var = m; // new var to keep it for lambda if (!CheckOmniKnown(s, d, m)) { if (Settings.ShowAllVariantsInPopup) { pop.Body += $"unknown: [[DM.MechDefs[{m.Description.Id}],{m.Chassis.Description.UIName} {m.Chassis.VariantName}]]\n"; } continue; } pop.AddButton($"{var.Chassis.VariantName}", delegate { Log.Log("ready omni as: " + var.Description.Id); s.ScrapInactiveMech(d.Chassis.Description.Id, false); ReadyMech(s, new MechDef(var, s.GenerateSimGameUID(), false), mechbay); onClose?.Invoke(); }, true, null); int com = GetNumberOfMechsOwnedOfType(s, m); int cost = m.GetMechSellCost(s); pop.Body += $"[[DM.MechDefs[{m.Description.Id}],{m.Chassis.Description.UIName} {m.Chassis.VariantName}]] ({com} Complete) ({SimGameState.GetCBillString(cost)})\n"; } pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true); pop.Render(); }
public static MechDef GetSalvageRedirect(SimGameState s, MechDef m) { if (!SimpleMechAssembly_Main.Settings.UseOnlyCCAssemblyOptions) { if (SimpleMechAssembly_Main.Settings.StructurePointBasedSalvageMechPartSalvageRedirect.TryGetValue(m.Description.Id, out string red)) { if (s.DataManager.MechDefs.TryGet(red, out MechDef n) && n != null) { SimpleMechAssembly_Main.Log.Log($"mechpart salvage redirection (settings): {m.Description.Id}->{red}"); return(n); } } string c = m.MechTags.FirstOrDefault((x) => x.StartsWith("mech_MechPartSalvageRedirect_")); if (c != null) { c = c.Replace("mech_MechPartSalvageRedirect_", ""); if (s.DataManager.MechDefs.TryGet(c, out MechDef n) && n != null) { SimpleMechAssembly_Main.Log.Log($"mechpart salvage redirection (tag): {m.Description.Id}->{c}"); return(n); } } } IAssemblyVariant v = CCIntegration.GetCCAssemblyVariant(m.Chassis); if (v != null && v.Lootable != null) { if (s.DataManager.MechDefs.TryGet(v.Lootable, out MechDef o)) { SimpleMechAssembly_Main.Log.Log($"mechpart salvage redirection (lootable): {m.Description.Id}->{v.Lootable}"); return(o); } } if (!SimpleMechAssembly_Main.Settings.AllowNonMainVariants && !m.IsMechDefMain()) { MechDef ma = m.Chassis.GetMainMechDef(s.DataManager); if (ma != null) { SimpleMechAssembly_Main.Log.Log($"mechpart salvage redirection (main): {m.Description.Id}->{ma.Description.Id}"); return(ma); } } return(m); }
static void Prefix(SimGameState __instance, DropshipLocation state) { try { if (state == DropshipLocation.SHOP) { if (__instance.CurSystem.Shop == null) { __instance.CurSystem.InitializeShop(); } else { __instance.CurSystem.Shop.UpdateShop(true); } } } catch (Exception e) { Logger.LogError(e); } }
public static void Prefix(SimGameState __instance, ref bool __result, Dictionary <string, StarSystem> ___starDict, SimGameState.AddContractData contractData) { StarSystem AddContractSystem; if (!string.IsNullOrEmpty(contractData.TargetSystem)) { string validatedSystemString = __instance.GetValidatedSystemString(contractData.TargetSystem); if (!___starDict.ContainsKey(validatedSystemString)) { return; } AddContractSystem = ___starDict[validatedSystemString]; } else { AddContractSystem = __instance.CurSystem; } ModState.AddContractBiomes = AddContractSystem.Def.SupportedBiomes; }
static bool Prefix(SGContractsWidget __instance, ref int __result, Contract contract) { try { int difficulty = contract.Override.GetUIDifficulty(); if (Fields.settings.SortByRealDifficulty) { difficulty = contract.Difficulty; } int result = 100; SimGameState Sim = (SimGameState)ReflectionHelper.InvokePrivateMethode(__instance, "get_Sim", null); if (Sim.ContractUserMeetsReputation(contract)) { if (contract.Override.contractDisplayStyle == ContractDisplayStyle.BaseCampaignRestoration) { result = 0; } else if (contract.Override.contractDisplayStyle == ContractDisplayStyle.BaseCampaignStory) { result = 1; } else if (contract.TargetSystem.Replace("starsystemdef_", "").Equals(Sim.CurSystem.Name)) { result = difficulty + 1; } else { result = difficulty + 11; } } else { result = difficulty + 21; } __result = result; return(false); } catch (Exception e) { PersistentMapClient.Logger.LogError(e); return(false); } }
public static void Prefix(SimGameState __instance, MechDef def) { try { foreach (var mechComponentRef in def.Inventory) { if (mechComponentRef.DamageLevel == ComponentDamageLevel.Destroyed) { continue; } SimGameStateAddItemStatPatch.OnAddItemStat(__instance, mechComponentRef); } } catch (Exception e) { Control.mod.Logger.LogError(e); } }
public static bool Prefix(SimGameResultAction action, object additionalObject, ref bool __result) { SimGameState simulation = UnityGameInstance.BattleTechGame.Simulation; if (simulation == null) { return(true); } if (action.Type == SimGameResultAction.ActionType.System_SetDropship) { if (!action.value.ToLower().Contains("leopard") && !action.value.ToLower().Contains("argo")) { DifficultyOptionsMain.ApplyEventResult(simulation, action.valueConstant, action.additionalValues); __result = false; return(false); } } return(true); }
private static void DumpUpgrades(SimGameState s, StreamWriter w, StreamWriter csv) { List <DumperDataEntry> l = new List <DumperDataEntry>(); l.Add(GetCompDesc()); foreach (KeyValuePair <string, UpgradeDef> kv in s.DataManager.UpgradeDefs) { l.Add(FillComp(kv.Value)); } foreach (KeyValuePair <string, JumpJetDef> kv in s.DataManager.JumpJetDefs) { l.Add(FillComp(kv.Value)); } foreach (KeyValuePair <string, HeatSinkDef> kv in s.DataManager.HeatSinkDefs) { l.Add(FillComp(kv.Value)); } WriteDataEntries(l, w, csv); }
public static void Postfix(SimGameState __instance) { List <Pilot> pilotList = new List <Pilot>((IEnumerable <Pilot>)__instance.PilotRoster); pilotList.Add(__instance.Commander); foreach (Pilot pilot in pilotList) { bool decayed = PilotAffinityManager.Instance.onSimDayElapsed(pilot); if (decayed) { __instance.RoomManager.ShipRoom.AddEventToast(new Text(string.Format("{0} affinities decayed!", (object)pilot.Callsign), (object[])Array.Empty <object>())); } if (Main.settings.enablePilotQuirks) { PilotQuirkManager.Instance.stealAmount(pilot, __instance); } } }
public static void Postfix( SimGameState __instance, string mechSimGameUID, MechComponentRef mechComponent, ChassisLocations newLocation, ChassisLocations previousLocation, WorkOrderEntry_InstallComponent __result ) { try { var mechDef = __instance.GetMechByID(mechSimGameUID); WorkOrderCostsHandler.Shared.ComponentInstallWorkOrder(mechDef, mechComponent, newLocation, __result); } catch (Exception e) { Control.LogError(e); } }
static void Prefix(Contract __instance, SimGameState sim) { foreach (UnitResult unitResult in __instance.PlayerUnitResults) { bool MakeImmortal = true; foreach (Pilot pilot in sim.PilotRoster) { if (pilot.Name == unitResult.pilot.Name) { MakeImmortal = false; } } if (MakeImmortal) { Traverse.Create(unitResult.pilot.pilotDef).Property("IsImmortal").SetValue(true); } } }
private static void Postfix(ref SimGameState __instance, ref string mechSimGameUID, ref ChassisLocations location, ref int armorDiff, ref int frontArmor, ref int rearArmor, ref WorkOrderEntry_ModifyMechArmor __result) { string id = string.Format("MechLab - ModifyArmor - {0}", __instance.GenerateSimGameUID()); try { float mechTonnageModifier = 1f; int techCost = 0; int cbillCost = 0; foreach (MechDef mechDef in __instance.ActiveMechs.Values) { if (mechDef.GUID == mechSimGameUID) { // If ScaleArmorCostByTonnage is enabled, make the mech tonnage work as a percentage tech cost reduction (95 tons = 0.95 or "95%" of the cost, 50 tons = 0.05 or "50%" of the cost etc) if (ArmorRepair.ModSettings.ScaleArmorCostByTonnage) { mechTonnageModifier = mechDef.Chassis.Tonnage * 0.01f; } float locationTechCost = ((armorDiff * mechTonnageModifier) * __instance.Constants.MechLab.ArmorInstallTechPoints); float locationCbillCost = ((armorDiff * mechTonnageModifier) * __instance.Constants.MechLab.ArmorInstallCost); techCost = Mathf.CeilToInt(locationTechCost); cbillCost = Mathf.CeilToInt(locationCbillCost); Logger.LogDebug("Armor WO SubEntry Costing: "); Logger.LogDebug("***************************************"); Logger.LogDebug("location: " + location.ToString()); Logger.LogDebug("armorDifference: " + armorDiff); Logger.LogDebug("mechTonnage: " + mechDef.Chassis.Tonnage); Logger.LogDebug("mechTonnageModifier: " + mechTonnageModifier); Logger.LogDebug("techCost: " + techCost); Logger.LogDebug("cbillCost: " + cbillCost); Logger.LogDebug("***************************************"); } } __result = new WorkOrderEntry_ModifyMechArmor(id, string.Format("Modify Armor - {0}", location.ToString()), mechSimGameUID, techCost, location, frontArmor, rearArmor, cbillCost, string.Empty); } catch (Exception ex) { Logger.LogError(ex); } }
public Flareup(StarSystem flareupLocation, FactionValue attackerFaction, string flareupType, SimGameState __instance) { Settings s = WIIC.settings; sim = __instance; location = flareupLocation; locationID = flareupLocation.ID; attacker = attackerFaction; attackerName = attackerFaction.Name; type = flareupType; countdown = Utilities.rng.Next(s.minCountdown, s.maxCountdown); int v; attackerStrength = s.attackStrength.TryGetValue(attacker.Name, out v) ? v : s.defaultAttackStrength; defenderStrength = s.defenseStrength.TryGetValue(location.OwnerValue.Name, out v) ? v : s.defaultDefenseStrength; attackerStrength += Utilities.rng.Next(-s.strengthVariation, s.strengthVariation); defenderStrength += Utilities.rng.Next(-s.strengthVariation, s.strengthVariation); string stat = $"WIIC_{attacker.Name}_attack_strength"; attackerStrength += sim.CompanyStats.ContainsStatistic(stat) ? sim.CompanyStats.GetValue <int>(stat) : 0; stat = $"WIIC_{location.OwnerValue.Name}_defense_strength"; defenderStrength += sim.CompanyStats.ContainsStatistic(stat) ? sim.CompanyStats.GetValue <int>(stat) : 0; if (type == "Raid") { attackerStrength = (int)Math.Ceiling(attackerStrength * s.raidStrengthMultiplier); defenderStrength = (int)Math.Ceiling(defenderStrength * s.raidStrengthMultiplier); } string text = type == "Raid" ? "{0} launches raid on {1} at {2}" : "{0} attacks {1} for control of {2}"; text = Strings.T(text, attacker.FactionDef.ShortName, location.OwnerValue.FactionDef.ShortName, location.Name); Utilities.deferredToasts.Add(text); WIIC.modLog.Info?.Write(text); if (location == sim.CurSystem) { spawnParticipationContracts(); } }
public static void Postfix(Briefing __instance, Contract contract, SimGameState Sim) { if (Sim == null || contract.ContractType == ContractType.ArenaSkirmish) { return; } var actualSalvage = contract.SalvagePotential; if (actualSalvage > 0) { actualSalvage = Mathf.FloorToInt(contract.Override.salvagePotential * contract.PercentageContractSalvage); actualSalvage += Sim.Constants.Finances.ContractFloorSalvageBonus; } var actualPrioritySalvage = Math.Min(7, Mathf.FloorToInt(actualSalvage * Sim.Constants.Salvage.PrioritySalvageModifier)); Traverse.Create(__instance).Field("contractSalvageField").GetValue <TextMeshProUGUI>().text = $"{actualPrioritySalvage} / {actualSalvage}"; }
public static MechDef GetMechDef(string mechID, SimGameState __instance) { List <MechDef> list = new List <MechDef>(__instance.ActiveMechs.Values); if (__instance.ActiveMechs == null) { return(null); } for (int i = 0; i < list.Count; i++) { MechDef mechDef = list[i]; if (mechDef != null && string.Compare(mechID, mechDef.Description.Id) == 0) //&& (string.IsNullOrEmpty(uniqueID) || string.Compare(uniqueID, mechDef.GUID) == 0)) { return(mechDef); } } return(null); }
public static void Prefix(SimGameState __instance) { if (__instance.CompletedContract != null) { List <UnitResult> results = __instance.CompletedContract.PlayerUnitResults; List <Pilot> pilotList = new List <Pilot>((IEnumerable <Pilot>)__instance.PilotRoster); pilotList.Add(__instance.Commander); foreach (UnitResult result in results) { foreach (Pilot pilot in pilotList) { if (result.pilot.pilotDef.Description.Id == pilot.pilotDef.Description.Id) { PilotAffinityManager.Instance.incrementDeployCountWithMech(result); } } } } }
public static void Postfix(SimGameState __instance, GameInstanceSave gameInstanceSave, ref List <string> ___ignoredContractTargets) { var save = gameInstanceSave.SimGameSave; if (save.IgnoredContractTargets == null) { return; } ___ignoredContractTargets = new List <string>(); foreach (var factionID2 in save.IgnoredContractTargets) { var factionValue = FactionEnumeration.GetFactionByID(factionID2); if (!factionValue.IsCareerIgnoredContractTarget) { Mod.Log.Info?.Write($"FactionValueFix: {factionValue.Name} is no longer IsCareerIgnoredContractTarget = true, removing from ignoredContractTargets."); ___ignoredContractTargets.RemoveAll(x => x == factionValue.Name); } } }
public static void Postfix(SimGameState __instance, Pilot p, ref SVGAsset __result, Pilot ___commander) { try { BattleTech.Data.SVGCache cache = (BattleTech.Data.SVGCache)Traverse.Create(__instance.DataManager).Method("get_SVGCache").GetValue(); if (p.Description.Id == ___commander.Description.Id) { __result = cache.GetAsset("uixSvgIcon_mwrank_Commander"); } if (p.pilotDef.IsVanguard || p.pilotDef.IsRonin) { __result = cache.GetAsset("uixSvgIcon_mwrank_Ronin"); } } catch (Exception e) { Logger.LogError(e); } }
static bool Prefix(SimGameState __instance) { try { __instance.CurSystem.RefreshSystem(); if (__instance.UXAttached) { __instance.RoomManager.ShipRoom.RefreshData(); } __instance.SetReputation(FactionEnumeration.GetOwnerFactionValue(), __instance.CurSystem.OwnerReputation, StatCollection.StatOperation.Set, null); Fields.currBorderCons = 0; return(false); } catch (Exception e) { PersistentMapClient.Logger.LogError(e); return(false); } }
public static bool Prefix(SimGameState __instance, WorkOrderEntry_RepairMechStructure order) { if (order.IsMechLabComplete) { return(true); } else { MechDef mechByID = __instance.GetMechByID(order.MechLabParent.MechID); LocationLoadoutDef locationLoadoutDef = mechByID.GetLocationLoadoutDef(order.Location); locationLoadoutDef.CurrentInternalStructure = mechByID.GetChassisLocationDef(order.Location).InternalStructure; // Original method resets currentArmor to assignedArmor here for some reason! Removed them from this override Logger.LogDebug("ALERT: Intercepted armor reset from ML_RepairMech and prevented it."); mechByID.RefreshBattleValue(); order.SetMechLabComplete(true); return(false); // Prevent original method from firing } }
public static bool Prefix(SimGameState __instance, int baseDiff, out int minDiff, out int maxDiff) { Logger.Debug("----------------------------------------------------------------------------------------------------"); Logger.Debug("[SimGameState_GetDifficultyRangeForContract_PREFIX] SimGameState.Constants.Story.ContractDifficultyVariance: " + __instance.Constants.Story.ContractDifficultyVariance); int[] overrideContractDifficultyVariances = Utilities.GetContractDifficultyVariances(__instance.SimGameMode, __instance.CompanyTags); Logger.Debug("[SimGameState_GetDifficultyRangeForContract_PREFIX] overrideContractDifficultyVariances[0]: " + overrideContractDifficultyVariances[0]); Logger.Debug("[SimGameState_GetDifficultyRangeForContract_PREFIX] overrideContractDifficultyVariances[1]: " + overrideContractDifficultyVariances[1]); minDiff = Mathf.Max(1, baseDiff - overrideContractDifficultyVariances[0]); maxDiff = Mathf.Max(1, baseDiff + overrideContractDifficultyVariances[1]); Logger.Debug("[SimGameState_GetDifficultyRangeForContract_PREFIX] baseDiff: " + baseDiff); Logger.Debug("[SimGameState_GetDifficultyRangeForContract_PREFIX] minDiff: " + minDiff); Logger.Debug("[SimGameState_GetDifficultyRangeForContract_PREFIX] maxDiff: " + maxDiff); // Skip original method... return(false); }
private static void Prefix(SimGameState __instance, bool passDay) { var instance = __instance; bool auto1 = false; bool auto2 = false; if (instance.shipUpgrades.Any(u => u.Tags.Any(t => t.Contains("argo_mechBay_automation1")))) { auto1 = true; } if (instance.shipUpgrades.Any(u => u.Tags.Any(t => t.Contains("argo_mechBay_automation2")))) { auto2 = true; } if (instance.MechLabQueue.Count < 1 || !passDay) { return; } int numMechBayPods = instance.CompanyStats.GetValue <int>(__instance.Constants.Story.MechBayPodsID); if (instance.MechLabQueue.Count() >= 3 && numMechBayPods >= 3) { float corfact = 0.3333333f; if (auto2) { corfact = 1; } instance.MechLabQueue[2].PayCost(Convert.ToInt32(corfact * instance.MechTechSkill)); } if (instance.MechLabQueue.Count() >= 2 && numMechBayPods >= 2) { float corfact = 0.5f; if (auto1) { corfact = 1; } instance.MechLabQueue[1].PayCost(Convert.ToInt32(corfact * instance.MechTechSkill)); } }
public void setCompanyStats(SimGameState simGame) { companyStats = simGame.CompanyStats; int legacyCost = getLegacyCompanyCosts(simGame); for (int i = 0; i < DCECore.settings.averagedDrops; i++) { string statName = $"{DropCostStatPrefix}{i}"; if (!companyStats.ContainsStatistic(statName)) { DCECore.modLog.Info?.Write($"Initing Stat: {statName}, Value: {legacyCost}"); companyStats.AddStatistic <int>(statName, legacyCost); } } if (!companyStats.ContainsStatistic(DropCostIdxStat)) { companyStats.AddStatistic <int>(DropCostIdxStat, 0); } }
public static object SetCharactersVisible(TsEnvironment env, object[] inputs) { bool isVisible = env.ToBool(inputs[0]); string crewNamesGrouped = env.ToString(inputs[1]); Main.Logger.Log($"[SetCharactersVisible] crewnames '{crewNamesGrouped}' will be visible status {isVisible}."); string[] crewNames = crewNamesGrouped.Split(','); foreach (string crewName in crewNames) { SimGameState.SimGameCharacterType character = (SimGameState.SimGameCharacterType)Enum.Parse(typeof(SimGameState.SimGameCharacterType), crewName, true); SimGameState simulation = UnityGameInstance.BattleTechGame.Simulation; simulation.SetCharacterVisibility(character, isVisible); } Main.Logger.Log($"[SetCharactersVisible] Finished"); return(null); }
public static List <KeyValuePair <string, int> > GetUpkeepLabels(SimGameState sgs) { Mod.Log.Info?.Write($" === Calculating Active Mech Labels === "); List <KeyValuePair <string, int> > labels = new List <KeyValuePair <string, int> >(); foreach (KeyValuePair <int, MechDef> entry in sgs.ActiveMechs) { MechDef mechDef = entry.Value; int mechCost = CaculateUpkeepCost(mechDef); string mechName = string.IsNullOrEmpty(mechDef.Description.UIName) ? mechDef.Name : mechDef.Description.UIName; Mod.Log.Debug?.Write($" Adding mech:{mechName} with cost:{mechCost}"); string upkeepLabel = new Text(Mod.LocalizedText.Labels[ModText.LT_Label_Mech_Upkeep], new object[] { mechName }).ToString(); labels.Add(new KeyValuePair <string, int>(upkeepLabel, mechCost)); } return(labels); }
public static IEnumerable <MechDef> GetAllAssemblyVariants(SimGameState s, MechDef m) { if (m.IsVehicle()) { return(GetAllVehicleMechVariants(s, m)); } if (m.Chassis.IsOmni()) { return(GetAllOmniVariants(s, m)); } if (IsCrossAssemblyAllowed(s)) { return(GetAllNonOmniVariants(s, m)); } return(new List <MechDef>() { m }); }
static bool Prefix(SimGameState __instance, bool clearExistingContracts, Action onContractGenComplete, StarSystem systemOverride = null, bool useCoroutine = false) { try { if (systemOverride == null) { return(true); } else { LazySingletonBehavior <UnityGameInstance> .Instance.StartCoroutine(StartGeneratePotentialContractsRoutine(__instance, clearExistingContracts, onContractGenComplete, systemOverride, useCoroutine)); return(false); } } catch (Exception e) { Logger.LogError(e); return(false); } }
public static void Force(string param) { SimGameState simGameState = SceneSingletonBehavior <UnityGameInstance> .Instance.Game.Simulation; if (param == "help") { string help = ""; help += "• This command will let you force an event"; help += Environment.NewLine; help += "• Params: the desired event id"; help += Environment.NewLine; help += "• Example: '/event event_co_littleAccident'"; help += Environment.NewLine; help += Environment.NewLine; help += "Currently only events with scope 'Company' are supported"; PopupHelper.Info(help); return; } string message = ""; Pilot plt = null; SimGameForcedEvent evt = new SimGameForcedEvent { Scope = EventScope.Company, EventID = param, MinDaysWait = 0, MaxDaysWait = 0, Probability = 100, RetainPilot = false }; simGameState.AddSpecialEvent(evt, plt); message = $"Forced event '{param}' to occur the next day"; Logger.Debug($"[Cheater_Event_Force] {message}"); PopupHelper.Info(message); }