internal void Save(DeepDrillerSaveData saveDataList)
        {
            var prefabIdentifier = GetComponent <PrefabIdentifier>();
            var id = prefabIdentifier.Id;

            if (_saveData == null)
            {
                _saveData = new DeepDrillerSaveDataEntry();
            }

            _saveData.Id            = id;
            _saveData.BodyColor     = ColorManager.GetMaskColor().ColorToVector4();
            _saveData.PowerState    = PowerManager.GetPowerState();
            _saveData.PullFromRelay = PowerManager.GetPullFromPowerRelay();
            _saveData.Items         = DeepDrillerContainer.SaveData();

            if (QPatch.Configuration.AllowDamage)
            {
                _saveData.Health = HealthManager.GetHealth();
            }

            _saveData.PowerData     = PowerManager.SaveData();
            _saveData.FocusOres     = OreGenerator.GetFocuses();
            _saveData.IsFocused     = OreGenerator.GetIsFocused();
            _saveData.Biome         = CurrentBiome;
            _saveData.OilTimeLeft   = OilHandler.GetOilTimeLeft();
            _saveData.SolarExtended = PowerManager.IsSolarExtended();
            _saveData.Upgrades      = UpgradeManager.Save();
            saveDataList.Entries.Add(_saveData);
        }
        internal void Save(DeepDrillerSaveData saveDataList)
        {
            var prefabIdentifier = GetComponent <PrefabIdentifier>();
            var id = prefabIdentifier.Id;

            if (_saveData == null)
            {
                _saveData = new DeepDrillerSaveDataEntry();
            }

            _saveData.Id              = id;
            _saveData.BodyColor       = ColorManager.GetMaskColor().ColorToVector4();
            _saveData.PowerState      = PowerManager.GetPowerState();
            _saveData.PullFromRelay   = PowerManager.GetPullFromPowerRelay();
            _saveData.Items           = DeepDrillerContainer.SaveData();
            _saveData.PowerData       = PowerManager.SaveData();
            _saveData.FocusOres       = OreGenerator.GetFocuses();
            _saveData.IsFocused       = OreGenerator.GetIsFocused();
            _saveData.IsBlackListMode = OreGenerator.GetInBlackListMode();
            _saveData.Biome           = CurrentBiome;
            _saveData.OilTimeLeft     = OilHandler.GetOilTimeLeft();
            _saveData.SolarExtended   = PowerManager.IsSolarExtended();
            _saveData.Upgrades        = UpgradeManager.Save();
            _saveData.IsRangeVisible  = _isRangeVisible;
            _saveData.AllowedToExport = TransferManager.IsAllowedToExport();
            saveDataList.Entries.Add(_saveData);
        }
Example #3
0
 private void MineStart()
 {
     playerGO                 = GameObject.FindGameObjectWithTag("Player");
     generateLevel            = FindObjectOfType <GenerateLevel>();
     _gridBehavior            = FindObjectOfType <GridBehavior>();
     oreGenerator             = FindObjectOfType <OreGenerator>();
     _nextLevelLoadController = FindObjectOfType <NextLevelLoadController>();
     progressBar              = FindObjectOfType <ProgressBar>();
     _chancesGenerator        = FindObjectOfType <ChancesGenerator>();
 }
Example #4
0
    private void Awake()
    {
        if (onDescending == null)
        {
            new UnityEvent();
        }

        _player         = GameObject.FindGameObjectWithTag("Player");
        _gridBehavior   = FindObjectOfType <GridBehavior>();
        _csGlobal       = FindObjectOfType <CsGlobal>();
        oreGenerator    = FindObjectOfType <OreGenerator>();
        generateLevel   = FindObjectOfType <GenerateLevel>();
        progressBar     = FindObjectOfType <ProgressBar>();
        _canvas         = FindObjectOfType <Canvas>();
        _dataController = FindObjectOfType <DataController>();
    }
        private void OnEnable()
        {
            if (IsBeingDeleted)
            {
                return;
            }

            if (_runStartUpOnEnable)
            {
                if (!IsInitialized)
                {
                    Initialize();
                }

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

                if (_fromSave && _data != null)
                {
                    if (QPatch.Configuration.AllowDamage)
                    {
                        StartCoroutine(SetHeath());
                    }

                    PowerManager.LoadData(_data);
                    DeepDrillerContainer.LoadData(_data.Items);
                    if (_data.IsFocused)
                    {
                        OreGenerator.SetIsFocus(_data.IsFocused);
                        OreGenerator.Load(_data.FocusOres);
                    }

                    ColorManager.SetMaskColorFromSave(_data.BodyColor.Vector4ToColor());
                    CurrentBiome = _data.Biome;
                    OilHandler.SetOilTimeLeft(_data.OilTimeLeft);
                    UpgradeManager.Load(_data?.Upgrades);

                    _fromSave = false;
                }

                StartCoroutine(TryGetLoot());
                _runStartUpOnEnable = false;
            }
        }
        private void OnEnable()
        {
            if (IsBeingDeleted)
            {
                return;
            }

            if (_runStartUpOnEnable)
            {
                if (!IsInitialized)
                {
                    Initialize();
                }

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

                if (IsFromSave && _saveData != null)
                {
                    PowerManager.LoadData(_saveData);

                    DeepDrillerContainer.LoadData(_saveData.Items);
                    if (_saveData.IsFocused)
                    {
                        OreGenerator.SetIsFocus(_saveData.IsFocused);
                        OreGenerator.Load(_saveData.FocusOres);
                    }

                    ColorManager.SetMaskColorFromSave(_saveData.BodyColor.Vector4ToColor());
                    CurrentBiome = _saveData.Biome;
                    OilHandler.SetOilTimeLeft(_saveData.OilTimeLeft);
                    UpgradeManager.Load(_saveData?.Upgrades);
                    OreGenerator.SetBlackListMode(_saveData.IsBlackListMode);
                    _isRangeVisible = _saveData.IsRangeVisible;
                }

                StartCoroutine(TryGetLoot());
                _runStartUpOnEnable = false;
            }
        }
Example #7
0
    private void Awake()
    {
        boosterTypes = Enum.GetValues(typeof(BoostersController.BoosterTypes))
                       .Cast <BoostersController.BoosterTypes>();

        _gridBehavior        = FindObjectOfType <GridBehavior>();
        _oreGenerator        = FindObjectOfType <OreGenerator>();
        progressBar          = FindObjectOfType <ProgressBar>();
        extractedOresCounter = FindObjectOfType <SingleExtractedOresCounter>();
        animatorController   = FindObjectOfType <CharacterAnimatorController>();

        maxDurability     = oreStats.durability;
        currentDurability = maxDurability;
        armour            = oreStats.armor - AwakeningUpgradeSingleton.armourPiercing;
        if (armour < 0)
        {
            armour = 0;
        }
        index                  = oreStats.index;
        _sprites               = Resources.LoadAll <Sprite>("OresSprites/" + (index + 1));
        _sprite                = _sprites[Random.Range(0, _sprites.Length)];
        _spriteRenderer        = gameObject.GetComponent <SpriteRenderer>();
        _spriteRenderer.sprite = _sprite;
    }
        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");
        }
Example #9
0
 public OresData(OreGenerator oreGenerator)
 {
     indexer     = oreGenerator.currentLevel;
     randNumbers = oreGenerator.randNumbers;
 }
Example #10
0
 private void Awake()
 {
     instance = this;
 }
Example #11
0
 private void Awake()
 {
     _oreGenerator  = FindObjectOfType <OreGenerator>();
     _adsController = FindObjectOfType <AdsController>();
 }
 internal HashSet <TechType> GetFocusedOres()
 {
     return(OreGenerator.GetFocusedOres());
 }
 internal bool GetFocusedState()
 {
     return(OreGenerator.GetIsFocused());
 }
 internal void SetOreFocus(TechType techType)
 {
     OreGenerator.AddFocus(techType);
 }
        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");
        }