private void OnDestroy()
        {
            if (Manager != null)
            {
                Manager.CyNukeReactors.Remove(this);
            }
            else
            {
                CyNukeManager.RemoveReactor(this);
            }

            ParentCyclops = null;
            Manager       = null;
        }
Пример #2
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);
        }
Пример #3
0
        public CyNukeEnhancerHandler(SubRoot cyclops) : base(NoUpgradesValue, cyclops)
        {
            tier1          = CreateTier(CyNukeEnhancerMk1.TechTypeID, Mk1UpgradeValue);
            tier1.MaxCount = 1;
            tier2          = CreateTier(CyNukeEnhancerMk2.TechTypeID, Mk2UpgradeValue);
            tier2.MaxCount = 1;

            OnUpgradeCounted = () => // Doing the final sync during HandleUpgrades may be unorthodox, but it somehow doesn't want to work any other way.
            {
                if (manager == null)
                {
                    manager = MCUServices.Find.AuxCyclopsManager <CyNukeManager>(cyclops);
                }

                OnUpgradeCounted = null; // This method only needs to be called once
            };

            OnFinishedUpgrades = EnhanceCyNukeReactors;
        }
        private void GetMCUHandler()
        {
            ParentCyclops = ParentCyclops ?? GetComponentInParent <SubRoot>();

            if (ParentCyclops == null)
            {
                QuickLogger.Debug("Could not find Cyclops during Start. Attempting external synchronize.");
                CyNukeManager.SyncReactors();
            }
            else if (Manager == null)
            {
                QuickLogger.Debug("Looking for CyNukeChargeManager.");
                Manager = MCUServices.Find.AuxCyclopsManager <CyNukeManager>(ParentCyclops);
            }

            if (Manager != null)
            {
                CancelInvoke(nameof(GetMCUHandler));
            }
        }
        public void ConnectToCyclops(SubRoot cyclops, CyNukeManager manager = null)
        {
            if (cyclops == null)
            {
                return;
            }

            ParentCyclops = cyclops;
            this.transform.SetParent(cyclops.transform);

            Manager = manager ?? MCUServices.Find.AuxCyclopsManager <CyNukeManager>(cyclops);

            if (Manager == null)
            {
                QuickLogger.Debug("CyNukeChargeManager still missing");
                return;
            }

            Manager.AddReactor(this);
            UpdateUpgradeLevel(Manager.UpgradeLevel);
            QuickLogger.Debug("Cyclops Nuclear Reactor has been connected", true);
        }