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;
        }
Example #3
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;
        }