public static void Prefix(ref SubRoot __instance)
 {
     if (__instance.isCyclops)
     {
         CyclopsManager.GetManager(__instance);
     }
     // Set up a CyclopsManager early if possible
 }
Beispiel #2
0
 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();
     }
 }
        /// <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));
        }
Beispiel #4
0
        /// <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);
        }
Beispiel #5
0
        /// <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);
                }
            }
        }
        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.
        }
        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
        }
Beispiel #8
0
        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)
        {
            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());
        }
        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);
            }
        }
Beispiel #11
0
        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);
        }
        /// <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);
        }
        /// <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);
        }
Beispiel #14
0
        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;
                }
            }
        }
        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
        }
 /// <summary>
 /// Gets the upgrade handler at the specified Cyclops sub for the specified upgrade module <see cref="TechType" />.<para />
 /// Use this if you need to obtain a reference to your <seealso cref="UpgradeHandler" /> for something else in your mod.
 /// </summary>
 /// <param name="cyclops">The cyclops to search in.</param>
 /// <param name="upgradeId">The upgrade module techtype ID.</param>
 /// <returns>
 /// An <see cref="UpgradeHandler" /> if found by techtype; Otherwise returns null.
 /// </returns>
 public UpgradeHandler CyclopsUpgradeHandler(SubRoot cyclops, TechType upgradeId)
 {
     return(CyclopsManager.GetManager(ref cyclops)?.Upgrade?.GetUpgradeHandler <UpgradeHandler>(upgradeId));
 }
Beispiel #17
0
 public static void PowerRatingUpdate(SubRoot cyclops)
 {
     CyclopsManager.GetManager(ref cyclops)?.Engine?.UpdatePowerRating();
 }
 public static void QuickUpdate(CyclopsHelmHUDManager hudManager)
 {
     CyclopsManager.GetManager(ref hudManager.subRoot)?.HUD?.FastUpdate(hudManager);
 }
        public static void UpdatePowerDisplays(CyclopsUpgradeConsoleHUDManager consoleHUDManager)
        {
            PdaOverlayManager.UpdateIconOverlays();

            CyclopsManager.GetManager(ref consoleHUDManager.subRoot)?.HUD?.SlowUpdate(consoleHUDManager);
        }
 /// <summary>
 /// Applies the power rating modifier to the specified Cyclops.
 /// </summary>
 /// <param name="cyclops">The Cyclops sub to apply the modifier to.</param>
 /// <param name="techType">The source of the power rating modifier. Not allowed to be <see cref="TechType.None" />.</param>
 /// <param name="modifier">The modifier. Must be a positive value.<para />
 /// Values less than <c>1f</c> reduce engine efficienty rating.<para />
 /// Values greater than <c>1f</c> improve engine efficienty rating.</param>
 public void ApplyPowerRatingModifier(SubRoot cyclops, TechType techType, float modifier)
 {
     CyclopsManager.GetManager(ref cyclops)?.Engine.ApplyPowerRatingModifier(techType, modifier);
 }
 /// <summary>
 /// Gets the <see cref="IPowerRatingManager" /> manging the specified Cyclops sub;
 /// </summary>
 /// <param name="cyclops"></param>
 /// <returns></returns>
 public IPowerRatingManager GetPowerRatingManager(SubRoot cyclops)
 {
     return(CyclopsManager.GetManager(ref cyclops)?.Engine);
 }
 /// <summary>
 /// Gets the upgrade handler at the specified Cyclops sub for the specified upgrade module <see cref="TechType" />.<para />
 /// Use this if you need to obtain a reference to your <seealso cref="StackingGroupHandler" /> or <seealso cref="TieredGroupHandler{T}" /> for something else in your mod.
 /// </summary>
 /// <typeparam name="T">The class created by the <seealso cref="CreateUpgradeHandler" /> you passed into <seealso cref="IMCURegistration.CyclopsUpgradeHandler(CreateUpgradeHandler)" />.</typeparam>
 /// <param name="cyclops">The cyclops to search in.</param>
 /// <param name="upgradeId">The upgrade module techtype ID.</param>
 /// <param name="additionalIds">Additional techtype IDs for a more precise search.</param>
 /// <returns>
 /// A type casted <see cref="UpgradeHandler" /> if found by techtype; Otherwise returns null.
 /// </returns>
 public T CyclopsGroupUpgradeHandler <T>(SubRoot cyclops, TechType upgradeId, params TechType[] additionalIds) where T : UpgradeHandler, IGroupHandler
 {
     return(CyclopsManager.GetManager(ref cyclops)?.Upgrade?.GetGroupHandler <T>(upgradeId));
 }
Beispiel #23
0
 public static void Postfix(ref CyclopsHelmHUDManager __instance, ref int __state)
 {
     CyclopsManager.GetManager(__instance.subRoot)?.HUD.FastUpdate(__instance, __state);
 }
 /// <summary>
 /// Gets the typed <see cref="Charging.CyclopsCharger" /> at the specified Cyclops sub.<para />
 /// Use this if you need to obtain a reference to your <seealso cref="Charging.CyclopsCharger" /> for something else in your mod.
 /// </summary>
 /// <typeparam name="T">The class created by the <seealso cref="CreateCyclopsCharger" /> you passed into <seealso cref="IMCURegistration.CyclopsCharger(CreateCyclopsCharger)" />.</typeparam>
 /// <param name="cyclops">The cyclops to search in.</param>
 /// <returns>
 /// A type casted <see cref="Charging.CyclopsCharger" /> if found; Otherwise returns null.
 /// </returns>
 public T CyclopsCharger <T>(SubRoot cyclops) where T : CyclopsCharger
 {
     return(CyclopsManager.GetManager(ref cyclops)?.Charge.GetCharger <T>(typeof(T).Name));
 }
 /// <summary>
 /// Gets the upgrade handler at the specified Cyclops sub for the specified upgrade module <see cref="TechType" />.<para />
 /// Use this if you need to obtain a reference to your <seealso cref="UpgradeHandler" /> for something else in your mod.
 /// </summary>
 /// <typeparam name="T">The class created by the <seealso cref="CreateUpgradeHandler" /> you passed into <seealso cref="IMCURegistration.CyclopsUpgradeHandler(CreateUpgradeHandler)" />.</typeparam>
 /// <param name="cyclops">The cyclops to search in.</param>
 /// <param name="upgradeId">The upgrade module techtype ID.</param>
 /// <returns>
 /// A type casted <see cref="UpgradeHandler" /> if found by techtype; Otherwise returns null.
 /// </returns>
 public T CyclopsUpgradeHandler <T>(SubRoot cyclops, TechType upgradeId) where T : UpgradeHandler
 {
     return(CyclopsManager.GetManager(ref cyclops)?.Upgrade?.GetUpgradeHandler <T>(upgradeId));
 }
 public T AuxCyclopsManager <T>(SubRoot cyclops)
     where T : class, IAuxCyclopsManager
 {
     return(CyclopsManager.GetManager <T>(cyclops, typeof(T).Name));
 }