public static void Postfix(MechBayChassisUnitElement __instance, Image ___mechImage, ChassisDef chassisDef, DataManager dataManager, int partsCount, int partsMax, int chassisQuantity) { if (partsMax > 0) { if (chassisDef.IsVehicle()) { ___mechImage.color = SimpleMechAssembly_Main.Settings.storage_vehiclepart; } else { ___mechImage.color = SimpleMechAssembly_Main.Settings.storage_parts; } } else if (chassisDef.IsVehicle()) { ___mechImage.color = SimpleMechAssembly_Main.Settings.storage_vehicle; } else if (chassisDef.IsOmni()) { ___mechImage.color = SimpleMechAssembly_Main.Settings.storage_omni; } else { ___mechImage.color = SimpleMechAssembly_Main.Settings.storage_mech; } }
public static string GetVariant(this ChassisDef d) { if (d.IsVehicle()) { VehicleChassisDef vd = d.GetVehicleChassisDefFromFakeVehicle(); if (vd == null) { return(d.Description.Id); } IVAssemblyVariant iVAssemblyVariant = GetCCVehicleAssemblyVariant(vd); //FileLog.Log($"vehicle {d.Description.Id} -> {iVAssemblyVariant?.PrefabID ?? d.Description.Id} null:{iVAssemblyVariant==null}"); return(iVAssemblyVariant?.PrefabID ?? d.Description.Id); } return(GetCCAssemblyVariant(d)?.PrefabID ?? d.Description.UIName); }
public static bool GetVehicleTags(ChassisDef chassis, DataManager dm, ref TagSet __result) { if (!chassis.IsVehicle()) { return(true); } var mid = ChassisHandler.GetMDefFromCDef(chassis.Description.Id); var mech = dm.VehicleDefs.Get(mid); if (mech == null) { Control.Instance.LogError("Cannot find vehicle with id " + mid); return(true); } __result = mech.VehicleTags; return(false); }
public static bool Prefix(MechBayChassisInfoWidget __instance, ChassisDef ___selectedChassis, MechBayPanel ___mechBay) { if (___selectedChassis == null) { return(true); } int bay = ___mechBay.Sim.GetFirstFreeMechBay(); MechDef d = ___selectedChassis.GetMainMechDef(___mechBay.Sim.DataManager); if (___selectedChassis.MechPartCount > 0) // this is actually a part that gets assembled { int p = SimpleMechAssembly_Main.GetNumPartsForAssembly(___mechBay.Sim, d); if (p < ___mechBay.Sim.Constants.Story.DefaultMechPartMax) { GenericPopupBuilder.Create($"{d.GetMechOmniVehicle()} Assembly", SimpleMechAssembly_Main.GetAssembleNotEnoughPartsText(___mechBay.Sim, d)).AddButton("Cancel", null, true, null) .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true).Render(); return(false); } ___mechBay.Sim.InterruptQueue.AddInterrupt(new SimpleMechAssembly_Main.SimpleMechAssembly_InterruptManager_AssembleMechEntry(___mechBay.Sim, d, delegate { ___mechBay.RefreshData(false); }), true); return(false); } if (___selectedChassis.MechPartCount < ___selectedChassis.MechPartMax) { return(true); } if (___selectedChassis.IsVehicle()) { bay = CUIntegration.GetFirstFreeMechBay(___mechBay.Sim, d); if (bay < 0) { GenericPopupBuilder.Create("Cannot Ready Vehicle", "There are no available slots in the Vehicle Bay. You must move an active Vehicle into storage before readying this chassis.") .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true).Render(); } else { GenericPopupBuilder.Create("Ready Vehicle?", $"It will take {Mathf.CeilToInt(___mechBay.Sim.Constants.Story.MechReadyTime / (float)___mechBay.Sim.MechTechSkill)} day(s) to ready this Vehicle for combat.") .AddButton("Cancel", null, true, null).AddButton("Ready", delegate { if (___mechBay.Sim.ScrapInactiveMech(___selectedChassis.Description.Id, false)) { SimpleMechAssembly_Main.ReadyMech(___mechBay.Sim, new MechDef(d, ___mechBay.Sim.GenerateSimGameUID(), true), bay, true); ___mechBay.RefreshData(false); ___mechBay.ViewBays(); } }).AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true).CancelOnEscape().Render(); } return(false); } if (!___selectedChassis.IsOmni()) { return(true); } if (bay < 0) { return(true); } ___mechBay.Sim.InterruptQueue.AddInterrupt(new SimpleMechAssembly_Main.SimpleMechAssembly_InterruptManager_UnStorageOmniEntry(___mechBay.Sim, d, delegate { ___mechBay.RefreshData(false); })); return(false); }