private void OnEnable()
        {
            if (!_runStartUpOnEnable)
            {
                return;
            }

            if (!_initialized)
            {
                Initialize();
            }

            if (_fromSave)
            {
                QuickLogger.Debug("In OnProtoDeserialize");
                var prefabIdentifier = GetComponent <PrefabIdentifier>() ?? GetComponentInParent <PrefabIdentifier>();
                var id   = prefabIdentifier?.Id ?? string.Empty;
                var data = Mod.GetExStorageDepotSaveData(id);
                NameController.SetCurrentName(data.UnitName);

                if (data.StorageItems != null)
                {
                    Storage.LoadFromSave(data.StorageItems);
                }

                BulkMultiplier = data.Multiplier;
                FCSConnectableDevice.IsVisible = data.IsVisible;
                Display.UpdateMultiplier();
            }

            _runStartUpOnEnable = false;
        }
        private void OnEnable()
        {
            if (_runStartUpOnEnable)
            {
                if (!IsInitialized)
                {
                    Initialize();
                }

                if (DisplayManager != null)
                {
                    var numberOfItems = FridgeComponent.NumberOfItems;
                    DisplayManager.OnContainerUpdate(numberOfItems, QPatch.Configuration.StorageLimit);
                    DisplayManager.UpdateScreenLabel(NameController.GetCurrentName(), NameController);
                }

                if (_fromSave)
                {
                    if (_savedData == null)
                    {
                        ReadySaveData();
                    }

                    PowerManager.LoadSave(_savedData.PowercellData);
                    FridgeComponent.LoadSave(_savedData.FridgeContainer);
                    NameController.SetCurrentName(_savedData.UnitName);
                    ColorManager.SetColorFromSave(_savedData.BodyColor.Vector4ToColor());
                    QuickLogger.Info($"Loaded {Mod.FriendlyName}");
                }

                _runStartUpOnEnable = false;
            }
        }
示例#3
0
        private void OnEnable()
        {
            if (!_runStartUpOnEnable)
            {
                return;
            }

            if (!IsInitialized)
            {
                Initialize();
            }

            if (_data == null)
            {
                ReadySaveData();
            }

            if (_fromSave)
            {
                NameController.SetCurrentName(_data.UnitName);
                SetIsGlobal(_data.IsGlobal);
                ColorManager.SetColorFromSave(_data.BodyColor.Vector4ToColor());
                DisplayManager.SetTab(_data.SelectedTab);
                QuickLogger.Info($"Loaded {Mod.FriendlyName}");
                _fromSave = false;
            }
        }
        private void Initialize(SubRoot habitat)
        {
            ReadySaveData();
            FCSConnectableAwake_Patcher.AddEventHandlerIfMissing(AlertedNewFCSConnectablePlaced);
            FCSConnectableDestroy_Patcher.AddEventHandlerIfMissing(AlertedFCSConnectableDestroyed);

            GetFCSConnectables();


            if (NameController == null)
            {
                NameController = new NameController();
                NameController.Initialize(AuxPatchers.Submit(), Mod.AntennaFriendlyName);
                NameController.OnLabelChanged += OnLabelChangedMethod;

                if (string.IsNullOrEmpty(_savedData?.InstanceID))
                {
                    NameController.SetCurrentName(GetDefaultName());
                }
                else
                {
                    NameController.SetCurrentName(_savedData?.BaseName);
                }
            }

            if (DumpContainer == null)
            {
                DumpContainer = habitat.gameObject.AddComponent <DumpContainer>();
                DumpContainer.Initialize(habitat.transform, AuxPatchers.BaseDumpReceptacle(), AuxPatchers.NotAllowed(),
                                         AuxPatchers.CannotBeStored(), this);
            }

            if (DockingManager == null)
            {
                DockingManager = habitat.gameObject.AddComponent <DSSVehicleDockingManager>();
                DockingManager.Initialize(habitat, this);
                DockingManager.ToggleIsEnabled(_savedData?.AllowDocking ?? false);
            }

            _hasBreakerTripped = _savedData?.HasBreakerTripped ?? false;
        }
        public override void Initialize()
        {
            PageStateHash = Animator.StringToHash("PageState");

            QPatch.Configuration.OnModModeChanged += OnModModeChanged;

            if (PrefabId == null)
            {
                PrefabId = GetComponentInParent <PrefabIdentifier>() ?? GetComponent <PrefabIdentifier>();
            }

            if (PowerManager == null)
            {
                PowerManager = gameObject.AddComponent <ARSolutionsSeaBreezePowerManager>();
                PowerManager.Initialize(this);
                PowerManager.OnBreakerTripped += OnBreakerTripped;
                PowerManager.OnBreakerReset   += OnBreakerReset;
                PowerManager.OnPowerResume    += OnPowerResume;
                PowerManager.OnPowerOutage    += OnPowerOutage;
            }

            if (FridgeComponent == null)
            {
                FridgeComponent = gameObject.AddComponent <Fridge>();
                FridgeComponent.Initialize(this, QPatch.Configuration.StorageLimit);
                FridgeComponent.OnContainerUpdate += OnContainerUpdate;
                FridgeComponent.SetModMode(QPatch.Configuration.ModMode);
            }

            if (ColorManager == null)
            {
                ColorManager = gameObject.AddComponent <ColorManager>();
                ColorManager.Initialize(gameObject, ARSSeaBreezeFCS32Buildable.BodyMaterial);
            }

            if (FridgeDumpContainer == null)
            {
                FridgeDumpContainer = gameObject.AddComponent <DumpContainer>();
                FridgeDumpContainer.Initialize(gameObject.transform, ARSSeaBreezeFCS32Buildable.StorageLabel(),
                                               ARSSeaBreezeFCS32Buildable.ItemNotAllowed(),
                                               ARSSeaBreezeFCS32Buildable.SeaBreezeFull(),
                                               FridgeComponent, _dumpStorageSizeXY, _dumpStorageSizeXY);
            }

            if (NameController == null)
            {
                NameController = gameObject.EnsureComponent <NameController>();
                NameController.Initialize(ARSSeaBreezeFCS32Buildable.Submit(), Mod.FriendlyName);
                NameController.SetCurrentName(Mod.GetNewSeabreezeName());
                NameController.OnLabelChanged += OnLabelChangedMethod;
            }

            if (AnimationManager == null)
            {
                AnimationManager = gameObject.AddComponent <AnimationManager>();
            }

            if (DisplayManager == null)
            {
                DisplayManager = gameObject.AddComponent <ARSolutionsSeaBreezeDisplay>();
                DisplayManager.Setup(this);
            }

            if (FCSConnectableDevice == null)
            {
                FCSConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>();
                FCSConnectableDevice.Initialize(this, FridgeComponent);
            }

            IsInitialized = true;
        }
示例#6
0
        public override void Initialize()
        {
            _prefabIdentifier = GetComponent <PrefabIdentifier>().Id ?? GetComponentInParent <PrefabIdentifier>().Id;
            _spinTitle        = Animator.StringToHash("SpinTitle");

            var target = gameObject.FindChild("targetPos");

            if (target == null)
            {
                QuickLogger.Error("Cant find trigger targetPos");
                return;
            }

            if (_buildable == null)
            {
                _buildable = GetComponentInParent <Constructable>() ?? GetComponent <Constructable>();
            }

            if (ColorManager == null)
            {
                ColorManager = new ColorManager();
            }

            ColorManager.Initialize(gameObject, QuantumTeleporterBuildable.BodyMaterial);

            TeleportManager.Initialize();

            if (NameController == null)
            {
                NameController = gameObject.EnsureComponent <NameController>();
            }


            if (AnimationManager == null)
            {
                AnimationManager = gameObject.GetComponent <AnimationManager>();
            }

            if (DisplayManager == null)
            {
                DisplayManager = gameObject.GetComponent <QTDisplayManager>();
            }

            if (SubRoot == null)
            {
                SubRoot = GetComponentInParent <SubRoot>();
            }

            if (Manager == null)
            {
                Manager = BaseManager.FindManager(SubRoot);
            }

            if (AudioManager == null)
            {
                AudioManager = new AudioManager(gameObject.GetComponent <FMOD_CustomLoopingEmitter>());
            }

            AudioManager.LoadFModAssets("/env/use_teleporter_use_loop", "use_teleporter_use_loop");

            if (PowerManager == null)
            {
                PowerManager = new QTPowerManager(this);
            }

            //var pingInstance = gameObject.GetComponent<PingInstance>() ??
            //                   gameObject.GetComponentInChildren<PingInstance>();

            //if (QTPingManager == null)
            //    QTPingManager = new QTPingManager();

            //QTPingManager.Initialize(pingInstance);

            DisplayManager.Setup(this);

            NameController.Initialize(QuantumTeleporterBuildable.Submit(), Mod.FriendlyName);
            NameController.SetCurrentName(GetNewName(), DisplayManager.GetNameTextBox());
            NameController.OnLabelChanged += OnLabelChanged;
            Manager.OnBaseUnitsChanged    += OnBaseUnitsChanged;
            AddToManager();

            AnimationManager.SetBoolHash(_spinTitle, true);

            if (QTDoorManager == null)
            {
                QTDoorManager = gameObject.FindChild("model").FindChild("anims").FindChild("door").AddComponent <QTDoorManager>();
            }
            QTDoorManager.Initalize(this);

            var trigger = target.AddComponent <QTTriggerBoxManager>();

            trigger.OnPlayerExit += QTDoorManager.OnPlayerExit;
            _target = target.transform;

            IsInitialized = true;
        }