public static void Postfix(FCSConnectableDevice __instance)
 {
     if (onSeaBreezeAdded != null && __instance.GetTechType() == Mod.SeabeezeTechType())
     {
         onSeaBreezeAdded.Invoke(__instance);
     }
 }
 public static void Postfix(FCSConnectableDevice __instance)
 {
     if (onSeaBreezeDestroyed != null)
     {
         onSeaBreezeDestroyed.Invoke(__instance);
     }
 }
示例#3
0
 private void ResetData()
 {
     _fromCurrentSearchString = _itemCurrentSearchString = _toCurrentSearchString = string.Empty;
     _fromDevice    = _toDevice = null;
     _itemTechType  = TechType.None;
     _craftTechType = TechType.None;
 }
 private void AlertedNewFCSConnectablePlaced(FCSConnectableDevice obj)
 {
     if (obj != null)
     {
         QuickLogger.Debug("OBJ Not NULL", true);
         TrackNewFCSConnectable(obj);
     }
 }
示例#5
0
 private void AlertedNewSeaBreezePlaced(FCSConnectableDevice obj)
 {
     if (obj != null)
     {
         QuickLogger.Debug("OBJ Not NULL", true);
         StartCoroutine(TrackNewSeabreezeCoroutine(obj));
     }
 }
        public override void Initialize()
        {
            if (NameController == null)
            {
                NameController = new ExStorageDepotNameManager();
                NameController.Initialize(this);
            }

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

            if (Storage == null)
            {
                Storage = gameObject.AddComponent <ExStorageDepotStorageManager>();
                Storage.Initialize(this);
            }

            if (DumpContainer == null)
            {
                DumpContainer = gameObject.AddComponent <DumpContainer>();
                DumpContainer.Initialize(transform, ExStorageDepotBuildable.DumpContainerLabel(), ExStorageDepotBuildable.FoodNotAllowed(), ExStorageDepotBuildable.ContainerFullMessage(), Storage);
                DumpContainer.OnDumpContainerClosed += Storage.OnDumpContainerClosed;
            }

            if (Display == null)
            {
                Display = gameObject.AddComponent <ExStorageDepotDisplayManager>();
                Display.Initialize(this);
            }

            var locker = GameObjectHelpers.FindGameObject(gameObject, "Locker", SearchOption.StartsWith);
            var sRoot  = GameObjectHelpers.FindGameObject(gameObject, "StorageRoot");

            if (locker != null)
            {
                Destroy(locker);
            }

            if (sRoot != null)
            {
                Destroy(sRoot);
            }

            if (FCSConnectableDevice == null)
            {
                FCSConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>();
                FCSConnectableDevice.Initialize(this, Storage, new ExStoragePowerManager(), true);
                FCSTechFabricator.FcTechFabricatorService.PublicAPI.RegisterDevice(FCSConnectableDevice, GetPrefabID(), Mod.ExStorageTabID);
            }

            _initialized = true;
        }
        private void AlertedFCSConnectableDestroyed(FCSConnectableDevice obj)
        {
            if (obj == null || obj.GetPrefabIDString() == null)
            {
                return;
            }

            QuickLogger.Debug("OBJ Not NULL", true);
            FCSConnectables.Remove(obj.GetPrefabIDString());
            QuickLogger.Debug("Removed FCSConnectable");
        }
示例#8
0
        private void AlertedSeaBreezeDestroyed(FCSConnectableDevice obj)
        {
            if (obj == null || obj.GetPrefabIDString() == null)
            {
                return;
            }

            QuickLogger.Debug("OBJ Not NULL", true);
            SeaBreezes.Remove(obj.GetPrefabIDString());
            QuickLogger.Debug("Removed Seabreeze");
            DisplayManager.UpdateSeaBreezes();
        }
示例#9
0
 private void OnFCSDeviceAwake(FCSConnectableDevice obj)
 {
     QuickLogger.Debug($"New Connectable Device: TechType to check {Mod.ExStorageTechType()} || Object TechType == {obj.GetTechType()}", true);
     if (_storagesList.Contains(obj) || obj.GetTechType() != Mod.ExStorageTechType())
     {
         return;
     }
     if (!CheckIfInRange(obj))
     {
         return;
     }
     QuickLogger.Debug("New Connectable Device in range", true);
     _storagesList.Add(obj);
 }
示例#10
0
 public void RegisterDevice(FCSConnectableDevice device, string prefabID, string tabID)
 {
     if (!knownDevices.ContainsKey(prefabID))
     {
         var id = $"{tabID}{knownDevices.Count:D3}";
         device.UnitID = id;
         knownDevices.Add(prefabID, id);
         Mod.SaveDevices(knownDevices);
     }
     else
     {
         device.UnitID = knownDevices[prefabID];
     }
 }
示例#11
0
        private bool CheckIfInRange(FCSConnectableDevice device)
        {
            if (_mono == null || _mono.PowerManager == null || !_mono.IsConstructed || _mono.PowerManager.IsTripped())
            {
                return(false);
            }
            float distance = Vector3.Distance(_mono.gameObject.transform.position, device.gameObject.transform.position);

            QuickLogger.Debug($"Object Distance {distance}", true);

            if (distance <= QPatch.Configuration.DrillExStorageRange)
            {
                QuickLogger.Debug("Adding to Connectable device");
                return(true);
            }
            return(false);
        }
        private void TrackNewFCSConnectable(FCSConnectableDevice obj)
        {
            GameObject newSeaBase         = obj?.gameObject?.transform?.parent?.gameObject;
            var        fcsConnectableBase = BaseManager.FindManager(newSeaBase?.GetComponentInChildren <PrefabIdentifier>().Id);

            QuickLogger.Debug($"SeaBase Base Found in Track {newSeaBase?.name}");
            QuickLogger.Debug($"Terminal Base Found in Track {Habitat?.name}");

            if (newSeaBase != null && fcsConnectableBase?.Habitat == Habitat)
            {
                QuickLogger.Debug("Subscribing to OnContainerUpdate");
                obj.GetStorage().OnContainerUpdate += OnFCSConnectableContainerUpdate;
                QuickLogger.Debug("Adding FCSConnectable");
                FCSConnectables.Add(obj.GetPrefabIDString(), obj);
                QuickLogger.Debug("Added FCSConnectable");
            }
        }
示例#13
0
        private IEnumerator TrackNewSeabreezeCoroutine(FCSConnectableDevice obj)
        {
            yield return(new WaitForEndOfFrame());

            GameObject newSeaBase = obj?.gameObject?.transform?.parent?.gameObject;

            QuickLogger.Debug($"SeaBase Base Found in Track {newSeaBase?.name}");
            QuickLogger.Debug($"Cooker Base Found in Track {_habitat?.name}");

            if (newSeaBase != null && newSeaBase == _habitat)
            {
                QuickLogger.Debug("Adding Seabreeze");
                SeaBreezes.Add(obj.GetPrefabIDString(), obj);
                DisplayManager.UpdateSeaBreezes();
                QuickLogger.Debug("Added Seabreeze");
            }
        }
        private void TrackNewFCSConnectable(FCSConnectableDevice obj)
        {
            QuickLogger.Info("===========================================");

            QuickLogger.Info("1");
            if (obj == null)
            {
                return;
            }
            QuickLogger.Info("2");

            SubRoot newSeaBase = obj.GetComponentInParent <SubRoot>(); //obj?.gameObject?.transform?.parent?.gameObject;

            QuickLogger.Info("3");

            var fcsConnectableBase = FindManager(newSeaBase?.GetComponentInChildren <PrefabIdentifier>().Id);

            QuickLogger.Info("4");

#if DEBUG
            QuickLogger.Debug($"FCSConnectable Base Found: {newSeaBase?.name}", true);
            QuickLogger.Debug($"FCSConnectable found in base: {Habitat?.name}", true);
#endif

            if (fcsConnectableBase == null || Habitat)
            {
                return;
            }

            if (fcsConnectableBase.Habitat == Habitat)
            {
                QuickLogger.Debug("Subscribing to OnContainerUpdate");
                obj.GetStorage().OnContainerUpdate += OnFCSConnectableContainerUpdate;
                QuickLogger.Info("5");
                QuickLogger.Debug("Adding FCSConnectable");
                FCSConnectables.Add(obj.GetPrefabIDString(), obj);
                QuickLogger.Debug("Added FCSConnectable");
                QuickLogger.Info("6");
            }

            QuickLogger.Info("===========================================");
        }
示例#15
0
        public override void Initialize()
        {
            if (PowerManager == null)
            {
                PowerManager = gameObject.AddComponent <AlterraGenPowerManager>();
            }

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

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

            if (DumpContainer == null)
            {
                DumpContainer = gameObject.AddComponent <DumpContainer>();
                DumpContainer.Initialize(transform, "AlterraGen Receptacle", AlterraGenBuildable.NotAllowedItem(), AlterraGenBuildable.StorageFullMessage(), PowerManager, 3, 3);
            }

            if (_fcsConnectableDevice == null)
            {
                _fcsConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>();
                _fcsConnectableDevice.Initialize(this, PowerManager, PowerManager);
                FCSTechFabricator.FcTechFabricatorService.PublicAPI.RegisterDevice(_fcsConnectableDevice, GetPrefabID(), Mod.ModTabID);
            }


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

            _xBubbles = GameObjectHelpers.FindGameObject(gameObject, "xBubbles");

            IsInitialized = true;
        }
示例#16
0
        public override void Initialize()
        {
            if (PowerManager == null)
            {
                PowerManager = gameObject.AddComponent <AlterraGenPowerManager>();
            }

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

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

            if (DumpContainer == null)
            {
                DumpContainer = gameObject.AddComponent <DumpContainer>();
                DumpContainer.Initialize(transform, "AlterraGen Receptacle", "", AlterraGenBuildable.NotAllowedItem(), PowerManager);
            }

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


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

            _xBubbles = GameObjectHelpers.FindGameObject(gameObject, "xBubbles");

            IsInitialized = true;
        }
        public override void Initialize()
        {
            if (NameController == null)
            {
                NameController = new ExStorageDepotNameManager();
                NameController.Initialize(this);
            }

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

            if (Storage == null)
            {
                Storage = gameObject.AddComponent <ExStorageDepotStorageManager>();
                Storage.Initialize(this);
            }

            if (DumpContainer == null)
            {
                DumpContainer = gameObject.AddComponent <DumpContainer>();
                DumpContainer.Initialize(transform, ExStorageDepotBuildable.DumpContainerLabel(), ExStorageDepotBuildable.FoodNotAllowed(), ExStorageDepotBuildable.ContainerFullMessage(), Storage);
                DumpContainer.OnDumpContainerClosed += Storage.OnDumpContainerClosed;
            }

            if (Display == null)
            {
                Display = gameObject.AddComponent <ExStorageDepotDisplayManager>();
                Display.Initialize(this);
            }

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

            _initialized = true;
        }
示例#18
0
 public static void Postfix(FCSConnectableDevice __instance)
 {
     onFCSConnectableAdded?.Invoke(__instance);
 }
示例#19
0
 private void OnFCSDeviceDestroy(FCSConnectableDevice obj)
 {
     _storagesList.Remove(obj);
 }
示例#20
0
 public void SetCurrentSeaBreeze(FCSConnectableDevice sb)
 {
     SelectedSeaBreeze   = sb;
     SelectedSeaBreezeID = sb.GetPrefabIDString();
 }
示例#21
0
        public override void OnButtonClick(string btnName, object tag)
        {
            switch (btnName)
            {
            case "ConnectionsBTN":
                GoToPage(OperatorPages.Operations);
                _mono.Manager.LoadOperationSaveData();
                break;

            case "AutoCraftBTN":
                GoToPage(OperatorPages.AutoCraft);
                break;

            case "HomeBTN":
                GoToPage(OperatorPages.Home);
                break;

            case "AddBTN":
                GoToPage(OperatorPages.From);
                _fromGrid?.DrawPage();
                break;

            case "ItemsNextButton":
                GoToPage(OperatorPages.To);
                break;

            case "ToFinishButton":
                GoToPage(OperatorPages.Operations);
                break;

            case "VisibilityBTN":
                GoToPage(OperatorPages.Visibility);
                _visibilityGrid?.DrawPage();
                break;

            case "OperatorDisplayBTN":
                var operatorData = (OperatorButtonData)tag;
                if (GetCurrentPage() == OperatorPages.From)
                {
                    _fromDevice = operatorData.Button.IsChecked() ? operatorData.Connectable : null;
                }
                else if (GetCurrentPage() == OperatorPages.To)
                {
                    _toDevice = operatorData.Button.IsChecked() ? operatorData.Connectable : null;
                }

                RefreshOperatorButtons(((OperatorButtonData)tag).Button);
                break;

            case "ItemTechBTN":
                var operatorItemData = (OperatorButtonData)tag;
                _itemTechType = operatorItemData.Button.IsChecked() ? operatorItemData.TechType : TechType.None;
                RefreshOperatorButtons(((OperatorButtonData)tag).Button);
                break;

            case "VisibilityItemBTN":
                var visibilityData = (OperatorButtonData)tag;
                visibilityData.Connectable.IsVisible = visibilityData.Button.IsChecked();
                Mod.OnBaseUpdate?.Invoke();
                break;

            case "AddCraftBTN":
                GoToPage(OperatorPages.CraftingItems);
                _autocraftItemTechTypeGrid?.DrawPage();
                break;

            case "AutoCraftItemTechBTN":
                var autocraftItemData = (OperatorButtonData)tag;
                _craftTechType = autocraftItemData.Button.IsChecked() ? autocraftItemData.TechType : TechType.None;
                RefreshOperatorButtons(((OperatorButtonData)tag).Button);
                break;
            }
        }
        public override void Initialize()
        {
            QuickLogger.Debug($"Initializing");

            var listSolar = new List <GameObject>
            {
                GameObjectHelpers.FindGameObject(gameObject, "Cube_2_2"),
                GameObjectHelpers.FindGameObject(gameObject, "Cube_1_2"),
                GameObjectHelpers.FindGameObject(gameObject, "Cube_1"),
                GameObjectHelpers.FindGameObject(gameObject, "Cube_2"),
                GameObjectHelpers.FindGameObject(gameObject, "Cube_2_3"),
                GameObjectHelpers.FindGameObject(gameObject, "Cube_1_4"),
                GameObjectHelpers.FindGameObject(gameObject, "Cube_2_4")
            };

            foreach (GameObject solarObj in listSolar)
            {
                var sController = solarObj.AddComponent <FCSDeepDrillerSolarController>();
                sController.Setup(this);
            }

            SolarStateHash = Animator.StringToHash("SolarState");

            InvokeRepeating(nameof(UpdateDrillShaftSate), 1, 1);

            if (OilHandler == null)
            {
                OilHandler = gameObject.AddComponent <FCSDeepDrillerOilHandler>();
                OilHandler.Initialize(this);
            }

            if (_prefabId == null)
            {
                QuickLogger.Error("Prefab Identifier Component was not found");
            }

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

            OreGenerator = gameObject.AddComponent <FCSDeepDrillerOreGenerator>();
            OreGenerator.Initialize(this);
            OreGenerator.OnAddCreated += OreGeneratorOnAddCreated;

            if (PowerManager == null)
            {
                PowerManager = gameObject.AddComponent <FCSDeepDrillerPowerHandler>();
                PowerManager.Initialize(this);
                var powerRelay = gameObject.AddComponent <PowerRelay>();
                PowerManager.SetPowerRelay(powerRelay);
            }

            if (LaserManager == null)
            {
                LaserManager = new LaserManager();
                LaserManager.Setup(this);
            }

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

            AudioManager = new AudioManager(gameObject.GetComponent <FMOD_CustomLoopingEmitter>());

            DeepDrillerContainer = new FCSDeepDrillerContainer();
            DeepDrillerContainer.Setup(this);


            AnimationHandler = gameObject.AddComponent <FCSDeepDrillerAnimationHandler>();
            AnimationHandler.Initialize(this);

            LavaPitHandler = gameObject.AddComponent <FCSDeepDrillerLavaPitHandler>();
            LavaPitHandler.Initialize(this);

            if (OilDumpContainer == null)
            {
                OilDumpContainer = gameObject.AddComponent <DumpContainer>();
                OilDumpContainer.Initialize(transform,
                                            FCSDeepDrillerBuildable.OilDropContainerTitle(),
                                            FCSDeepDrillerBuildable.NotAllowedItem(),
                                            FCSDeepDrillerBuildable.StorageFull(),
                                            OilHandler, 4, 4);
            }

            if (PowercellDumpContainer == null)
            {
                PowercellDumpContainer = gameObject.AddComponent <DumpContainer>();
                PowercellDumpContainer.Initialize(transform,
                                                  FCSDeepDrillerBuildable.PowercellDumpContainerTitle(),
                                                  FCSDeepDrillerBuildable.NotAllowedItem(),
                                                  FCSDeepDrillerBuildable.StorageFull(),
                                                  PowerManager, 1, 1);
            }

            if (TransferManager == null)
            {
                TransferManager = gameObject.AddComponent <FCSDeepDrillerTransferManager>();
                TransferManager.Initialize(this);
            }

            if (UpgradeManager == null)
            {
                UpgradeManager = gameObject.AddComponent <FCSDeepDrillerUpgradeManager>();
                UpgradeManager.Initialize(this);
            }

            _line = gameObject.GetComponent <LineRenderer>();
            _line.SetVertexCount(Segments + 1);
            _line.useWorldSpace = false;

            if (FCSConnectableDevice == null)
            {
                FCSConnectableDevice = gameObject.AddComponent <FCSConnectableDevice>();
                FCSConnectableDevice.Initialize(this, DeepDrillerContainer, PowerManager);
                FCSTechFabricator.FcTechFabricatorService.PublicAPI.RegisterDevice(FCSConnectableDevice, GetPrefabID(), Mod.DeepDrillerTabID);
            }

            OnGenerate();

            IsInitialized = true;

            QuickLogger.Debug($"Initializing Completed");
        }
        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;
        }