public void AddReactor(CyNukeReactorMono reactor)
 {
     if (!CyNukeReactors.Contains(reactor))
     {
         CyNukeReactors.Add(reactor);
     }
 }
 public static void RemoveReactor(CyNukeReactorMono reactor)
 {
     foreach (CyNukeManager mgr in MCUServices.Find.AllAuxCyclopsManagers <CyNukeManager>())
     {
         mgr.CyNukeReactors.Remove(reactor);
     }
 }
Пример #3
0
        public override Color StatusTextColor()
        {
            if (this.CyNukeReactors == null || this.CyNukeReactors.Count == 0)
            {
                return(Color.white);
            }

            int totalActiveRods = 0;
            int maxRods         = 0;

            for (int r = 0; r < this.CyNukeReactors.Count; r++)
            {
                CyNukeReactorMono reactor = this.CyNukeReactors[r];
                totalActiveRods += reactor.ActiveRodCount;
                maxRods         += reactor.MaxActiveSlots;
            }

            // All slots active
            if (totalActiveRods == maxRods)
            {
                return(Color.green);
            }

            // No slots active
            if (totalActiveRods == 0)
            {
                return(Color.white);
            }

            // Some slots depleted
            return(Color.yellow);
        }
        internal static void Postfix(uGUI_InventoryTab __instance)
        {
            if (__instance == null || !CyNukeReactorMono.PdaIsOpen)
            {
                return;
            }

            ItemsContainer    containerObj = __instance.storage.container;
            CyNukeReactorMono reactor      = CyNukeReactorMono.OpenInPda;

            reactor.ConnectToContainer(__instance.storage.items);
        }
Пример #5
0
        public override GameObject GetGameObject()
        {
            SubRoot cyclops = Player.main.currentSub;

            if (cyclops != null && cyclops.isCyclops)
            {
                CyNukeManager mgr = MCUServices.Find.AuxCyclopsManager <CyNukeManager>(cyclops);

                if (mgr != null && mgr.TrackedBuildablesCount >= CyNukeChargeManager.MaxReactors)
                {
                    ErrorMessage.AddMessage(OverLimitMessage());
                    return(null);
                }
            }

            var        prefab       = GameObject.Instantiate(_cyNukReactorPrefab);
            GameObject consoleModel = prefab.FindChild("model");

            // Update sky applier
            SkyApplier skyApplier = prefab.AddComponent <SkyApplier>();

            skyApplier.renderers = consoleModel.GetComponentsInChildren <MeshRenderer>();
            skyApplier.anchorSky = Skies.Auto;

            //Add the constructible component to the prefab
            Constructable constructible = prefab.AddComponent <Constructable>();

            constructible.allowedInBase           = false;
            constructible.allowedInSub            = true; // Only allowed in Cyclops
            constructible.allowedOutside          = false;
            constructible.allowedOnCeiling        = false;
            constructible.allowedOnGround         = true; // Only on ground
            constructible.allowedOnWall           = false;
            constructible.allowedOnConstructables = false;
            constructible.controlModelState       = true;
            constructible.rotationEnabled         = true;
            constructible.techType = TechTypeID;
            constructible.model    = consoleModel;

            //Add the prefabIdentifier
            PrefabIdentifier prefabID = prefab.AddComponent <PrefabIdentifier>();

            prefabID.ClassId = main.ClassID;

            // Add the custom component
            CyNukeReactorMono auxConsole = prefab.AddComponent <CyNukeReactorMono>(); // Moved to the bottom to allow constructible to be added

            return(prefab);
        }
Пример #6
0
        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 == null)
            {
                return; // Safety check
            }
            if (!Player.main.IsInSub() || !Player.main.currentSub.isCyclops)
            {
                return; // If not in Cyclops then all is irrelevant
            }
            uGUI_ItemsContainer storageUI = __instance.storage;

            if (storageUI == null)
            {
                return; // Not an equipment container
            }
            var container = (ItemsContainer)containerField.GetValue(storageUI);

            if (container == null)
            {
                return; // Safety check
            }
            string label = (container as IItemsContainer).label;

            if (label != CyNukReactorBuildable.StorageLabel())
            {
                return; // Not a CyNukReactor
            }
            List <CyNukeReactorMono> reactors = MCUServices.Find.AuxCyclopsManager <CyNukeManager>(Player.main.currentSub)?.CyNukeReactors;

            if (reactors == null || reactors.Count == 0)
            {
                return; // Cyclops has no reactors
            }
            // Look for the reactor that matches the container we just opened.
            CyNukeReactorMono reactor = reactors.Find(r => r.RodsContainer == container);

            if (reactor == null)
            {
                return; // Didn't find the reactor we were looking for. Could it be on another cyclops?
            }
            var lookup = (Dictionary <InventoryItem, uGUI_ItemIcon>)itemsField.GetValue(storageUI);

            reactor.ConnectToContainer(lookup); // Found!
        }
        public void SyncReactorsExternally()
        {
            var _tempCache = new List <CyNukeReactorMono>();

            CyNukeReactorMono[] foundReactors = Cyclops.GetAllComponentsInChildren <CyNukeReactorMono>();

            for (int r = 0; r < foundReactors.Length; r++)
            {
                CyNukeReactorMono reactor = foundReactors[r];
                if (_tempCache.Contains(reactor))
                {
                    continue; // This is a workaround because of the object references being returned twice in this array.
                }
                _tempCache.Add(reactor);

                if (reactor.ParentCyclops == null)
                {
                    QuickLogger.Debug("Cyclops Nuclear Reactor synced externally");
                    // This is a workaround to get a reference to the Cyclops into the CyNukeReactorMono
                    reactor.ConnectToCyclops(Cyclops, this);
                }
            }
        }
Пример #8
0
        protected override float DrainReserveEnergy(float requestedPower)
        {
            if (this.CyNukeReactors == null || this.CyNukeReactors.Count == 0)
            {
                return(0f);
            }

            float powerDeficit  = requestedPower;
            float producedPower = 0f;

            for (int r = 0; r < this.CyNukeReactors.Count; r++)
            {
                CyNukeReactorMono reactor = this.CyNukeReactors[r];
                if (!reactor.HasPower())
                {
                    continue;
                }

                producedPower += reactor.GetPower(ref powerDeficit);
            }

            return(producedPower);
        }