public static bool Prefix(ref SubRoot __instance) { UpgradeManager upgradeMgr = CyclopsManager.GetUpgradeManager(__instance); if (upgradeMgr == null) { return(true); } CrushDamage crushDmg = __instance.gameObject.GetComponent <CrushDamage>(); if (crushDmg == null) { return(true); } float orignialCrushDepth = crushDmg.crushDepth; crushDmg.SetExtraCrushDepth(upgradeMgr.BonusCrushDepth); if (orignialCrushDepth != crushDmg.crushDepth) { ErrorMessage.AddMessage(Language.main.GetFormat("CrushDepthNow", crushDmg.crushDepth)); } return(false); // Completely override the method and do not continue with original execution // The original method execution sucked anyways :P }
public static void SetUpgrades(SubRoot cyclops) { if (cyclops.live?.IsAlive() == true) { // If the Cyclops is alive, we can handle upgrades. CyclopsManager.GetManager(ref cyclops)?.Upgrade?.HandleUpgrades(); } }
public static void Prefix(ref SubRoot __instance) { if (__instance.isCyclops) { CyclopsManager.GetManager(__instance); } // Set up a CyclopsManager early if possible }
/// <summary> /// Gets the typed <see cref="IAuxCyclopsManager" /> for the specified Cyclops sub. /// </summary> /// <typeparam name="T">The class you created that implements <see cref="IAuxCyclopsManager" />.</typeparam> /// <param name="cyclops">The cyclops to search in.</param> /// <returns> /// A type casted <see cref="IAuxCyclopsManager" /> if found; Otherwise returns null if not found. /// </returns> /// <seealso cref="CreateAuxCyclopsManager" /> public T AuxCyclopsManager <T>(SubRoot cyclops) where T : class, IAuxCyclopsManager { if (cyclops == null) { return(null); } return(CyclopsManager.GetManager <T>(ref cyclops, typeof(T).Name)); }
/// <summary> /// Returns a collection of all upgrade handlers for the Cyclops sub. /// </summary> /// <param name="cyclops">The cyclops sub being accessed.</param> /// <returns>A read-only collection of all upgrade handlers managing this sub.</returns> public IMCUUpgradeCollection GetAllUpgradeHandlers(SubRoot cyclops) { var mgr = CyclopsManager.GetManager(ref cyclops); if (mgr?.Upgrade?.Initialized == true) { return(mgr.Upgrade.KnownsUpgradeModules); } return(null); }
public static void Postfix(ref CyclopsHelmHUDManager __instance) { CyclopsHUDManager hudMgr = CyclopsManager.GetHUDManager(__instance.subRoot); if (hudMgr == null) { return; } hudMgr.UpdateHelmHUD(__instance); }
public static bool Prefix(ref SubRoot __instance) { var mgr = CyclopsManager.GetManager(__instance); if (mgr == null) { return(true); // Safety Check } // If there is no mod taking over how thermal charging is done on the Cyclops, // then we will allow the original method to run so it provides the vanilla thermal charging. return(mgr.Charge.RechargeCyclops()); // Returns True if vanilla charging should proceed; Otherwise False. }
/// <summary> /// Gets an enumeration of all <see cref="UpgradeSlot"/>s in this Cyclops across all upgrade consoles. /// </summary> /// <param name="cyclops">The cyclops to search.</param> /// <returns>An iterator of <see cref="IEnumerable{UpgradeSlot}"/> the covers all upgrade slots in the Cyclops.</returns> public IEnumerable <UpgradeSlot> GetAllUpgradeSlots(SubRoot cyclops) { var mgr = CyclopsManager.GetManager(ref cyclops); if (mgr?.Upgrade?.Initialized == true) { foreach (var slot in mgr.Upgrade.UpgradeSlots) { yield return(slot); } } }
/// <summary> /// Registers a <see cref="IAuxCyclopsManagerCreator" /> class that can create a new <see cref="IAuxCyclopsManager" /> on demand.<para /> /// This method will be invoked only once for each Cyclops sub in the game world.<para /> /// Use this when you simply need to have a class that attaches one instance per Cyclops. /// </summary> /// <typeparam name="T">Your class that implements <see cref="IAuxCyclopsManager" />.</typeparam> /// <param name="managerCreator">The manager creator class instance.</param> public void AuxCyclopsManager <T>(IAuxCyclopsManagerCreator managerCreator) where T : IAuxCyclopsManager { if (CyclopsManager.TooLateToRegister) { QuickLogger.Error("AuxCyclopsManagerCreator have already been invoked. This method should only be called during patch time."); } else { CyclopsManager.RegisterAuxManagerCreator(managerCreator.CreateAuxCyclopsManager, typeof(T).Name); } }
public static void Postfix(ref CyclopsUpgradeConsoleHUDManager __instance) { var cyclopsManager = CyclopsManager.GetAllManagers(__instance.subRoot); if (cyclopsManager == null) { return; } cyclopsManager.UpgradeManager.SyncUpgradeConsoles(); cyclopsManager.PowerManager.UpdateConsoleHUD(__instance); }
public static bool Prefix(ref SubRoot __instance) { var mgr = CyclopsManager.GetManager(__instance); if (mgr == null) { return(true); // Safety Check } // Performing this custom handling was necessary as UpdatePowerRating wouldn't work with the AuxUpgradeConsole mgr.Engine.UpdatePowerRating(); return(false); // Completely override the method and do not continue with original execution }
public static bool Prefix(ref CyclopsUpgradeConsoleHUDManager __instance) { CyclopsHUDManager hudMgr = CyclopsManager.GetHUDManager(__instance.subRoot); if (hudMgr == null) { return(true); } hudMgr.UpdateConsoleHUD(__instance); return(false); }
internal bool Initialize(CyclopsManager manager) { if (this.Manager != null) { return(false); // Already initialized } this.Manager = manager; SimpleUpgradeActions.Add(TechType.CyclopsShieldModule, EnabledShield); SimpleUpgradeActions.Add(TechType.CyclopsSonarModule, EnableSonar); SimpleUpgradeActions.Add(TechType.CyclopsSeamothRepairModule, EnableRepairDock); SimpleUpgradeActions.Add(TechType.CyclopsDecoyModule, EnableExtraDecoySlots); SimpleUpgradeActions.Add(TechType.CyclopsFireSuppressionModule, EnableFireSuppressionSystem); SimpleUpgradeActions.Add(TechType.CyclopsThermalReactorModule, AddThermalModule); SimpleUpgradeActions.Add(TechType.PowerUpgradeModule, AddPowerMk1Module); SimpleUpgradeActions.Add(CyclopsModule.SolarChargerID, AddSolarModule); SimpleUpgradeActions.Add(CyclopsModule.SpeedBoosterModuleID, AddSpeedModule); SimpleUpgradeActions.Add(CyclopsModule.PowerUpgradeMk2ID, AddPowerMk2Module); SimpleUpgradeActions.Add(CyclopsModule.PowerUpgradeMk3ID, AddPowerMk3Module); SlotBoundUpgradeActions.Add(CyclopsModule.SolarChargerMk2ID, AddSolarMk2Module); SlotBoundUpgradeActions.Add(CyclopsModule.ThermalChargerMk2ID, AddThermalMk2Module); SlotBoundUpgradeActions.Add(CyclopsModule.NuclearChargerID, AddNuclearModule); ChargingModules.Add(CyclopsModule.SolarChargerID); ChargingModules.Add(CyclopsModule.SolarChargerMk2ID); ChargingModules.Add(TechType.CyclopsThermalReactorModule); ChargingModules.Add(CyclopsModule.ThermalChargerMk2ID); ChargingModules.Add(CyclopsModule.NuclearChargerID); AuxUpgradeConsole[] auxUpgradeConsoles = manager.Cyclops.GetAllComponentsInChildren <AuxUpgradeConsole>(); foreach (AuxUpgradeConsole auxConsole in auxUpgradeConsoles) { if (this.AuxUpgradeConsoles.Contains(auxConsole)) { continue; // This is a workaround because of the object references being returned twice in this array. } this.AuxUpgradeConsoles.Add(auxConsole); if (auxConsole.ParentCyclops == null) { // This is a workaround to get a reference to the Cyclops into the AuxUpgradeConsole auxConsole.ParentCyclops = this.Cyclops; ErrorMessage.AddMessage("Auxiliary Upgrade Console has been connected"); } } return(true); }
public BioBoosterUpgradeHandler() : base(CyclopsModule.BioReactorBoosterID) { this.MaxCount = CyBioReactorMono.MaxBoosters; OnFinishedUpgrades += (SubRoot cyclops) => { List <CyBioReactorMono> bioreactors = CyclopsManager.GetBioReactors(cyclops); if (bioreactors == null) { return; } QuickLogger.Debug($"Handling BioBooster at {this.Count}"); foreach (CyBioReactorMono reactor in bioreactors) { reactor.UpdateBoosterCount(this.Count); } }; OnFirstTimeMaxCountReached += () => { ErrorMessage.AddMessage(BioReactorBooster.MaxBoostAchived); }; IsAllowedToRemove += (SubRoot cyclops, Pickupable item, bool verbose) => { List <CyBioReactorMono> bioreactors = CyclopsManager.GetBioReactors(cyclops); if (bioreactors == null) { return(true); } foreach (CyBioReactorMono reactor in bioreactors) { if (!reactor.HasRoomToShrink()) { if (Time.time > errorDelay) { errorDelay = Time.time + delayInterval; ErrorMessage.AddMessage(BioReactorBooster.CannotRemove); } return(false); } } return(true); }; }
public static bool Prefix(ref SubRoot __instance) { var mgr = CyclopsManager.GetManager(ref __instance); if (mgr == null) { return(true); // Safety Check } // All charging handled here. // Even vanill thermal charging was replicated to allow enable it's own Power Indicator Icon. mgr.Charge.RechargeCyclops(); return(false); }
public static bool Prefix(ref SubRoot __instance) { PowerManager powerMgr = CyclopsManager.GetPowerManager(__instance); if (powerMgr == null) { return(true); // safety check } powerMgr.UpdatePowerSpeedRating(); // No need to execute original method anymore return(false); // Completely override the method and do not continue with original execution }
public static bool Prefix(ref CyclopsUpgradeConsoleHUDManager __instance) { PdaOverlayManager.UpdateIconOverlays(); CyclopsHUDManager hudMgr = CyclopsManager.GetManager(__instance.subRoot)?.HUD; if (hudMgr == null) { return(true); } hudMgr.SlowUpdate(__instance); return(false); }
internal void ConnectToCyclops(SubRoot parentCyclops, UpgradeManager manager = null) { ParentCyclops = parentCyclops; this.transform.SetParent(parentCyclops.transform); UpgradeManager = manager ?? CyclopsManager.GetManager(ref parentCyclops).Upgrade; if (UpgradeManager != null) { UpgradeManager.AddBuildable(this); Equipment console = this.Modules; UpgradeManager.AttachEquipmentEvents(ref console); QuickLogger.Debug("Auxiliary Upgrade Console has been connected", true); } }
public static bool Prefix(ref SubRoot __instance) { var mgr = CyclopsManager.GetManager(ref __instance); if (mgr == null) { return(true); // Safety Check } // If there is no mod taking over how thermal charging is done on the Cyclops, // then we will allow the original method to run so it provides the vanilla thermal charging. // The return value of RechargeCyclops will be True if vanilla charging should proceed; // Otherwise it returns False and the original code won't be run. return(mgr.Charge.RechargeCyclops()); }
private void Start() { SubRoot cyclops = GetComponentInParent <SubRoot>(); if (cyclops is null) { QuickLogger.Debug("CyUpgradeConsoleMono: Could not find Cyclops during Start. Attempting external syncronize."); CyclopsManager.SyncUpgradeConsoles(); } else { QuickLogger.Debug("CyUpgradeConsoleMono: Parent cyclops found!"); ConnectToCyclops(cyclops); } }
/// <summary> /// Checks whether the Cyclops has the specified upgrade module installed anywhere across all upgrade consoles. /// </summary> /// <param name="cyclops">The cyclops to search.</param> /// <param name="techType">The upgrade module's techtype ID.</param> /// <returns> /// <c>true</c> if the upgrade is found installed on the Cyclops; otherwise, <c>false</c>. /// </returns> public bool HasUpgradeInstalled(SubRoot cyclops, TechType techType) { var mgr = CyclopsManager.GetManager(ref cyclops); if (mgr == null) { return(false); } if (mgr.Upgrade.KnownsUpgradeModules.TryGetValue(techType, out UpgradeHandler handler)) { return(handler.HasUpgrade); } return(false); }
/// <summary> /// Gets the total number of the specified upgrade module currently installed in the Cyclops. /// </summary> /// <param name="cyclops">The cyclops to search.</param> /// <param name="techType">The upgrade module's techtype ID.</param> /// <returns> /// The number of upgrade modules of this techtype ID currently in the Cyclops. /// </returns> public int GetUpgradeCount(SubRoot cyclops, TechType techType) { var mgr = CyclopsManager.GetManager(ref cyclops); if (mgr == null) { return(0); } if (mgr.Upgrade.KnownsUpgradeModules.TryGetValue(techType, out UpgradeHandler handler)) { return(handler.Count); } return(0); }
private void Start() { ChargePerSecondPerItem = baselineChargeRate / this.TotalContainerSpaces * 2; SubRoot cyclops = GetComponentInParent <SubRoot>(); if (cyclops is null) { QuickLogger.Debug("CyBioReactorMono: Could not find Cyclops during Start. Attempting external syncronize."); CyclopsManager.SyncBioReactors(); } else { QuickLogger.Debug("CyBioReactorMono: Parent cyclops found!"); ConnectToCyclops(cyclops); } }
internal static void Postfix(uGUI_InventoryTab __instance) { // This event happens whenever the player opens their PDA. // We will make a series of checks to see if what they have opened is the Cyclops Bioreactor item container. if (__instance is null) { return; // Safety check } if (!Player.main.IsInSub() || !Player.main.currentSub.isCyclops) { return; // If not in Cyclops then all is irrelevant } if (__instance.storage is null) { return; // Safety check } ItemsContainer containerObj = __instance.storage.container; if (containerObj is null) { return; // If this isn't a non-null ItemsContainer, then it's not what we want. } string label = containerObj._label; if (label != CyBioReactor.StorageLabel) { return; // Not a Cyclops Bioreactor storage } List <CyBioReactorMono> reactors = CyclopsManager.GetBioReactors(Player.main.currentSub); if (reactors is null || reactors.Count == 0) { return; // Cyclops has no bioreactors } // Look for the reactor that matches the container we just opened. CyBioReactorMono reactor = reactors.Find(r => r.Container == containerObj); if (reactor is null) { return; // Didn't find the reactor we were looking for. Could it be on another cyclops? } Dictionary <InventoryItem, uGUI_ItemIcon> lookup = __instance.storage.items; reactor.ConnectToInventory(lookup); // Found! }
public static void Postfix(ref CyclopsHelmHUDManager __instance) { if (!__instance.LOD.IsFull() || // can't see !__instance.subLiveMixin.IsAlive()) // dead { return; } PowerManager powerMgr = CyclopsManager.GetPowerManager(__instance.subRoot); if (powerMgr == null) { return; } powerMgr.UpdateHelmHUD(__instance, ref lastReservePower); }
public static void Prefix(ref SubRoot __instance) { if (__instance.isCyclops) { // Set up a CyclopsManager early if possible var mgr = CyclopsManager.GetManager(ref __instance); // Big thanks to Waisie Milliams Hah for helping to fix the upgrade console lighting bug Transform consoleMesh = mgr.Cyclops.transform.Find("CyclopsMeshStatic/undamaged/cyclops_LOD0/cyclops_engine_room/cyclops_engine_console/Submarine_engine_GEO/submarine_engine_console_01_wide"); foreach (Renderer mesh in consoleMesh.GetComponentsInChildren <Renderer>()) { SkyApplier skyApplier = mesh.gameObject.EnsureComponent <SkyApplier>(); skyApplier.renderers = mesh.GetComponentsInChildren <MeshRenderer>(); skyApplier.anchorSky = Skies.Auto; } } }
internal void ConnectToCyclops(SubRoot parentCyclops, CyclopsManager manager = null) { this.ParentCyclops = parentCyclops; this.transform.SetParent(parentCyclops.transform); this.Manager = manager ?? CyclopsManager.GetAllManagers(parentCyclops); UpgradeManager upgradeManager = this.Manager.UpgradeManager; if (!upgradeManager.AuxUpgradeConsoles.Contains(this)) { upgradeManager.AuxUpgradeConsoles.Add(this); } Equipment console = this.Modules; upgradeManager.AttachEquipmentEvents(ref console); QuickLogger.Debug("Auxiliary Upgrade Console has been connected", true); }
public static bool Prefix(ref SubRoot __instance) { LiveMixin cyclopsLife = __instance.live; if (cyclopsLife == null || !cyclopsLife.IsAlive()) { return(true); // safety check } var mgr = CyclopsManager.GetManager(__instance); if (mgr == null) { return(true); // Safety Check } mgr.Upgrade.HandleUpgrades(); // No need to execute original method anymore return(false); // Completely override the method and do not continue with original execution }
public void ConnectToCyclops(SubRoot parentCyclops, CyclopsManager manager = null) { if (ParentCyclops != null) { return; } ParentCyclops = parentCyclops; this.transform.SetParent(parentCyclops.transform); Manager = manager ?? CyclopsManager.GetAllManagers(parentCyclops); if (!Manager.ChargeManager.CyBioReactors.Contains(this)) { Manager.ChargeManager.CyBioReactors.Add(this); } UpdateBoosterCount(Manager.ChargeManager.BioBoosters.Count); QuickLogger.Debug("Bioreactor has been connected to Cyclops", true); }
public bool Initialize(CyclopsManager manager) { if (this.Manager != null) { return(false); // Already initialized } this.Manager = manager; if (this.MotorMode == null) { return(false); } // Store the original values before we start to change them this.OriginalSpeeds[0] = this.MotorMode.motorModeSpeeds[0]; this.OriginalSpeeds[1] = this.MotorMode.motorModeSpeeds[1]; this.OriginalSpeeds[2] = this.MotorMode.motorModeSpeeds[2]; return(true); }