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() { 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); } ExtendStateHash = Animator.StringToHash("LegState"); ShaftStateHash = Animator.StringToHash("ShaftState"); ScreenStateHash = Animator.StringToHash("ScreenState"); BitSpinState = Animator.StringToHash("BitSpinState"); BitDamageState = Animator.StringToHash("BitDamageState"); SolarStateHash = Animator.StringToHash("SolarState"); _prefabId = GetComponentInParent <PrefabIdentifier>() ?? GetComponent <PrefabIdentifier>(); 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 <OreGenerator>(); OreGenerator.Initialize(this); OreGenerator.OnAddCreated += OreGeneratorOnAddCreated; if (PowerManager == null) { PowerManager = gameObject.AddComponent <FCSDeepDrillerPowerHandler>(); PowerManager.Initialize(this); PowerManager.OnPowerUpdate += OnPowerUpdate; 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>()); HealthManager = gameObject.AddComponent <FCSDeepDrillerHealthHandler>(); HealthManager.Initialize(this); HealthManager.SetHealth(100); HealthManager.OnDamaged += OnDamaged; HealthManager.OnRepaired += OnRepaired; 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 (UpgradeManager == null) { UpgradeManager = gameObject.AddComponent <UpgradeManager>(); UpgradeManager.Initialize(this); } UpdateSystemLights(PowerManager.GetPowerState()); OnGenerate(); IsInitialized = true; QuickLogger.Debug($"Initializing Completed"); }