public static void Postfix(WorkOrderEntry_ReadyMech order) { var sim = UnityGameInstance.BattleTechGame.Simulation; if (Main.Settings.DependsOnArgoUpgrade && !sim.PurchasedArgoUpgrades.Contains(Main.Settings.ArgoUpgrade)) { return; } try { var TempTag = order.Mech.MechTags.First(x => x.StartsWith($"SO-Building-")); order.Mech.MechTags.Remove(TempTag); if (sim.Constants.Salvage.EquipMechOnSalvage && Main.EquippedMechs.Keys.Contains(order.Mech.Description.Id) && Main.EquippedMechs[order.Mech.Description.Id] > 0) { var NewMechDef = sim.DataManager.MechDefs.Get(order.MechID); order.Mech.SetInventory(NewMechDef.Inventory); Main.EquippedMechs[order.Mech.Description.Id]--; } } catch { } //var match = Regex.Match(TempTag, @"SO-Building-(.+)~(\d)$"); //var MDString = match.Groups[1].ToString(); //var MDCount = int.Parse(match.Groups[2].ToString()); //Logger.Log(MDString + MDCount); //Main.BuildingMechs[MDString].Remove(MDCount); //Logger.Log("Donezo"); }
public static void Prefix(WorkOrderEntry_ReadyMech order) { var sim = UnityGameInstance.BattleTechGame.Simulation; if (Main.Settings.DependsOnArgoUpgrade && !sim.PurchasedArgoUpgrades.Contains(Main.Settings.ArgoUpgrade)) { return; } MechDef mech = order.Mech; string tempTagName = mech.MechTags.First(x => x.StartsWith($"SO-Building-")); var match = Regex.Match(tempTagName, @"SO-Building-(.+)~(\d)$"); var MDString = match.Groups[1].ToString(); var MDCount = int.Parse(match.Groups[2].ToString()); if (!Main.BuiltMechs.Keys.Contains(MDString)) { var templist = new List <int>() { MDCount }; Main.BuiltMechs.Add(MDString, templist); } else { Main.BuiltMechs[MDString].Add(MDCount); } }
public static void ReadyMech(SimGameState s, MechDef d, int baySlot) { WorkOrderEntry_ReadyMech workOrderEntry_ReadyMech = new WorkOrderEntry_ReadyMech(string.Format("ReadyMech-{0}", d.GUID), string.Format("Readying 'Mech - {0}", new object[] { d.Chassis.Description.Name }), s.Constants.Story.MechReadyTime, baySlot, d, string.Format(s.Constants.Story.MechReadiedWorkOrderCompletedText, new object[] { d.Chassis.Description.Name })); s.MechLabQueue.Add(workOrderEntry_ReadyMech); s.ReadyingMechs[baySlot] = d; s.RoomManager.AddWorkQueueEntry(workOrderEntry_ReadyMech); s.UpdateMechLabWorkQueue(false); AudioEventManager.PlayAudioEvent("audioeventdef_simgame_vo_barks", "workqueue_readymech", WwiseManager.GlobalAudioObject, null); }
static bool Prefix(WorkOrderEntry_ReadyMech order, SimGameState __instance) { Logger.Debug("ML_ReadyMech Patch Installed"); if (order.IsMechLabComplete) { return(false); } var index = __instance.ReadyingMechs.First(item => item.Value == order.Mech).Key; __instance.ReadyingMechs.Remove(index); __instance.ActiveMechs[index] = order.Mech; order.Mech.RefreshBattleValue(); order.SetMechLabComplete(true); SortMechLabMechs(__instance.GetMaxActiveMechs(), __instance.ActiveMechs, __instance.ReadyingMechs); return(false); }
static bool Prefix(WorkOrderEntry_ReadyMech order, SimGameState __instance) { Logger.Debug("ML_Cancel_ReadyMech Patch Installed"); if (order.IsMechLabComplete) { Logger.Debug("wtf is happening how"); return(false); } var item = __instance.ReadyingMechs.First(readying => readying.Value == order.Mech); var index = item.Key; Logger.Debug($"cancel index: {index}\nmech? {item.Value.GUID} : {order.Mech.GUID} : {order.Mech.Chassis.VariantName}"); __instance.UnreadyMech(index, order.Mech); __instance.ReadyingMechs.Remove(index); SortMechLabMechs(__instance.GetMaxActiveMechs(), __instance.ActiveMechs, __instance.ReadyingMechs); return(false); }
public static void ReadyMech(SimGameState s, MechDef d, int baySlot, bool donotoverridetime = false) { int mechReadyTime = s.Constants.Story.MechReadyTime; if (Settings.AssembledMechsReadyingFlatCost > 0 && !donotoverridetime) { mechReadyTime = Settings.AssembledMechsReadyingFlatCost + Settings.AssembledMechsReadyingPerNonFixedComponentCost * d.Inventory.Where((a) => !a.IsFixed).Count(); } WorkOrderEntry_ReadyMech workOrderEntry_ReadyMech = new WorkOrderEntry_ReadyMech(string.Format("ReadyMech-{0}", d.GUID), $"Readying {d.GetMechOmniVehicle()} - {d.Chassis.Description.Name}", mechReadyTime, baySlot, d, string.Format(s.Constants.Story.MechReadiedWorkOrderCompletedText, new object[] { d.Chassis.Description.Name })); s.MechLabQueue.Add(workOrderEntry_ReadyMech); s.ReadyingMechs[baySlot] = d; s.RoomManager.AddWorkQueueEntry(workOrderEntry_ReadyMech); s.UpdateMechLabWorkQueue(false); AudioEventManager.PlayAudioEvent("audioeventdef_simgame_vo_barks", "workqueue_readymech", WwiseManager.GlobalAudioObject, null); s.CompanyStats.ModifyStat("Mission", 0, "COMPANY_MechsAdded", StatCollection.StatOperation.Int_Add, 1, -1, true); }
public static void Postfix(WorkOrderEntry_ReadyMech order) { var sim = UnityGameInstance.BattleTechGame.Simulation; if (Main.Settings.DependsOnArgoUpgrade && !sim.PurchasedArgoUpgrades.Contains(Main.Settings.ArgoUpgrade)) { return; } try { var TempTag = order.Mech.MechTags.First(x => x.StartsWith($"SO-Building-")); order.Mech.MechTags.Remove(TempTag); if (sim.Constants.Salvage.EquipMechOnSalvage && Main.EquippedMechs.Keys.Contains(order.Mech.Description.Id) && Main.EquippedMechs[order.Mech.Description.Id] > 0) { var NewMechDef = sim.DataManager.MechDefs.Get(order.Mech.Description.Id); // use the same code to clone inventory as MechDef.CopyFrom MechComponentRef[] clonedInv = new MechComponentRef[NewMechDef.Inventory.Length]; for (int i = 0; i < NewMechDef.Inventory.Length; i++) { clonedInv[i] = new MechComponentRef(NewMechDef.Inventory[i], null); clonedInv[i].DataManager = order.Mech.DataManager; clonedInv[i].RefreshComponentDef(); } order.Mech.SetInventory(clonedInv); Main.EquippedMechs[order.Mech.Description.Id]--; } } catch { } //var match = Regex.Match(TempTag, @"SO-Building-(.+)~(\d)$"); //var MDString = match.Groups[1].ToString(); //var MDCount = int.Parse(match.Groups[2].ToString()); //Logger.Log(MDString + MDCount); //Main.BuildingMechs[MDString].Remove(MDCount); //Logger.Log("Donezo"); }
private static void AddBullsharkLT(SimGameState s) { MechDef d = s.DataManager.MechDefs.Get("mechdef_bullshark_BSK-LT"); d = new MechDef(d, s.GenerateSimGameUID(), true); d.SetInventory(d.Inventory.Where((x) => x.IsFixed || x.ComponentDefID.Equals("Ammo_AmmunitionBox_Generic_LongTom")).ToArray()); int baySlot = s.GetFirstFreeMechBay(); int mechReadyTime = 625000; // about 50 days WorkOrderEntry_ReadyMech workOrderEntry_ReadyMech = new WorkOrderEntry_ReadyMech(string.Format("ReadyMech-{0}", d.GUID), string.Format("Readying 'Mech - {0}", new object[] { d.Chassis.Description.Name }), mechReadyTime, baySlot, d, string.Format(s.Constants.Story.MechReadiedWorkOrderCompletedText, new object[] { d.Chassis.Description.Name })); s.MechLabQueue.Add(workOrderEntry_ReadyMech); s.ReadyingMechs[baySlot] = d; s.RoomManager.AddWorkQueueEntry(workOrderEntry_ReadyMech); s.UpdateMechLabWorkQueue(false); AudioEventManager.PlayAudioEvent("audioeventdef_simgame_vo_barks", "workqueue_readymech", WwiseManager.GlobalAudioObject, null); }
public static bool ReadyVehicle(MechBayPanel __instance, MechBayChassisUnitElement chassisElement, ref MechBayChassisUnitElement ___selectedChassis, MechBayRowGroupWidget ___bayGroupWidget) { try { var chassisDef = chassisElement.ChassisDef; if (!chassisDef.IsVehicle()) { return(true); } var id = chassisElement.ChassisDef.Description.Id; var sim = __instance.Sim; int start = sim.VehicleShift(); int end = start + sim.GetMaxActiveMechs(); int baySlot = -1; for (int i = start; i < end; i++) { MechDef mech_in_slot = null; if (!sim.ActiveMechs.TryGetValue(i, out mech_in_slot)) { sim.ReadyingMechs.TryGetValue(i, out mech_in_slot); } if (mech_in_slot == null) { baySlot = i; break; } } if (baySlot < 0) { Control.Instance.LogDebug(DInfo.General, "No Free vehicle slots for {0}", id); return(false); } var mid = ChassisHandler.GetMDefFromCDef(id); var sim_id = sim.GenerateSimGameUID(); var stock = __instance.DataManager.MechDefs.Get(mid); var mech = new MechDef(chassisDef, sim_id, stock); mech.SetInventory(stock.Inventory); WorkOrderEntry_ReadyMech workOrderEntry_ReadyMech = new WorkOrderEntry_ReadyMech( string.Format("ReadyMech-{0}", sim_id), Strings.T("Readying 'Mech - {0}", new object[] { chassisDef.Description.Name }), sim.Constants.Story.MechReadyTime, baySlot, mech, Strings.T( sim.Constants.Story.MechReadiedWorkOrderCompletedText, new object[] { chassisDef.Description.Name })); sim.MechLabQueue.Add(workOrderEntry_ReadyMech); sim.ReadyingMechs[baySlot] = mech; sim.RoomManager.AddWorkQueueEntry(workOrderEntry_ReadyMech); sim.UpdateMechLabWorkQueue(false); sim.RemoveItemStat(id, typeof(MechDef), false); AudioEventManager.PlayAudioEvent("audioeventdef_simgame_vo_barks", "workqueue_readymech", WwiseManager.GlobalAudioObject, null); ___selectedChassis = null; __instance.RefreshData(true); __instance.ViewBays(); __instance.SelectMech(___bayGroupWidget.GetMechUnitForSlot(baySlot), true); } catch (Exception e) { Control.Instance.LogError(e); } return(false); }