Ejemplo n.º 1
0
        public void Start(TaskCompletionSource <bool> ResultOfInitSink)
        {
            if (!Assembly.GetCallingAssembly().GetName().FullName.StartsWith("ACE.Server,"))
            {
                log.Fatal("Invalid startup method.  This is an ACEmulator plugin.");
                return;
            }
            TransferConfigManager.Initialize();
            TransferManager.Initialize();

            ResultOfInitSink.SetResult(true); // report success
        }
        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");
        }