internal void InitializeSolar(float charge, float capacity)
        {
            var go     = new GameObject("DD_SolarBattery");
            var solarB = go.AddComponent <Battery>();

            go.AddComponent <PrefabIdentifier>();
            solarB._capacity = capacity;
            solarB._charge   = charge;

            Battery = solarB.GetComponent <IBattery>();

            if (Battery == null)
            {
                QuickLogger.Error("Solar Battery is null");
            }

            QuickLogger.Debug("Created Solar Battery for Deep Driller");
        }
Esempio n. 2
0
        private static void HandleReadMeFile()
        {
            if (!File.Exists(FileLocations.HowToFile))
            {
                File.WriteAllLines(FileLocations.HowToFile, ReadMeFileLines());
                QuickLogger.Debug($"{FileLocations.HowToFile} file not found. File created.");
            }
            else
            {
                string[] readmeLines = File.ReadAllLines(FileLocations.HowToFile);

                if (readmeLines.Length < 1 || readmeLines[0] != ReadMeVersionLine)
                {
                    File.WriteAllLines(FileLocations.HowToFile, ReadMeFileLines());
                    QuickLogger.Info($"{FileLocations.HowToFile} out of date. Regenerated with new version.");
                }
            }
        }
Esempio n. 3
0
        private void RestoreItemsFromSaveData()
        {
            if (!isLoadingSaveData || SaveData is null)
            {
                return;
            }

            foreach (BioEnergy material in SaveData.GetMaterialsInProcessing())
            {
                InventoryItem inventoryItem = BioReactor.container.AddItem(material.Pickupable);
                MaterialsProcessing.Add(material);
                material.Size = inventoryItem.width * inventoryItem.height;
            }

            QuickLogger.Debug("Original items restored");

            isLoadingSaveData = false;
        }
        internal static void Patch(Harmony harmony)
        {
            QuickLogger.Debug($"{nameof(EnergyMixinPatcher)} Applying Harmony Patches");

            MethodInfo energyMixinNotifyHasBattery   = AccessTools.Method(typeof(EnergyMixin), nameof(EnergyMixin.NotifyHasBattery));
            MethodInfo notifyHasBatteryPostfixMethod = AccessTools.Method(typeof(EnergyMixinPatcher), nameof(EnergyMixinPatcher.NotifyHasBatteryPostfix));

            var harmonyNotifyPostfix = new HarmonyMethod(notifyHasBatteryPostfixMethod);

            harmony.Patch(energyMixinNotifyHasBattery, postfix: harmonyNotifyPostfix); // Patches the EnergyMixin NotifyHasBattery method

            MethodInfo energyMixStartMethod = AccessTools.Method(typeof(EnergyMixin), nameof(EnergyMixin.Awake));
            MethodInfo startPrefixMethod    = AccessTools.Method(typeof(EnergyMixinPatcher), nameof(EnergyMixinPatcher.AwakePrefix));

            var harmonyStartPrefix = new HarmonyMethod(startPrefixMethod);

            harmony.Patch(energyMixStartMethod, prefix: harmonyStartPrefix); // Patches the EnergyMixin Start method
        }
        private void Start()
        {
            SubRoot cyclops = base.GetComponentInParent <SubRoot>();

            if (cyclops == null)
            {
                QuickLogger.Debug("CyUpgradeConsoleMono: Could not find Cyclops during Start. Attempting external syncronize.");
                for (int i = 0; i < CyclopsManager.Managers.Count; i++)
                {
                    CyclopsManager.Managers[i].Upgrade.SyncBuildables();
                }
            }
            else
            {
                QuickLogger.Debug("CyUpgradeConsoleMono: Parent cyclops found!");
                ConnectToCyclops(cyclops);
            }
        }
        private void OnRepaired()
        {
            QuickLogger.Debug("OnRepaired", true);

            AnimationHandler.SetBoolHash(BitDamageState, false);

            if (PowerManager.GetPowerState() == FCSPowerStates.Tripped)
            {
                return;
            }

            UpdateSystemLights(PowerManager.GetPowerState());

            if (!isActiveAndEnabled)
            {
                _runStartUpOnEnable = true;
            }
        }
        private bool FindObjectDataMatch(TechType item, out ObjectData objectData)
        {
            bool objectDataMatch = false;

            objectData = null;
            QuickLogger.Debug($"Trying to add item to container {item}", true);
            foreach (ObjectData data in FCSFilteredStorage.Items)
            {
                if (data.TechType == item)
                {
                    objectData      = data;
                    objectDataMatch = true;
                    break;
                }
            }

            return(objectDataMatch);
        }
Esempio n. 8
0
        protected override RecipeData GetBlueprintRecipe()
        {
            QuickLogger.Debug($"Creating recipe...");

            // Create and associate recipe to the new TechType
            var customFabRecipe = new RecipeData()
            {
                craftAmount = 1,
                Ingredients = new List <Ingredient>()
                {
                    new Ingredient(Mod.ExStorageKitClassID.ToTechType(), 1)
                }
            };

            QuickLogger.Debug($"Created Ingredients");

            return(customFabRecipe);
        }
        public void OpenStorage()
        {
            if (_mono.IsInvalidPlacement())
            {
                return;
            }


            if (_container == null)
            {
                QuickLogger.Debug("The container returned null", true);
                return;
            }
            var pda = Player.main.GetPDA();

            Inventory.main.SetUsedStorage(_container);
            pda.Open(PDATab.Inventory, _mono.transform, null, 10f);
        }
        protected override RecipeData GetBlueprintRecipe()
        {
            QuickLogger.Debug($"Creating recipe...");
            // Create and associate recipe to the new TechType
            var customFabRecipe = new RecipeData()
            {
                craftAmount = 1,
                Ingredients = new List <Ingredient>()
                {
                    new Ingredient(TechType.SeaTreaderPoop, 2),
                    new Ingredient(TechType.Tank, 1),
                    new Ingredient(TechType.HydrochloricAcid, 1),
                    new Ingredient(TechType.BigFilteredWater, 2)
                }
            };

            return(customFabRecipe);
        }
Esempio n. 11
0
        public static void Patch()
        {
            QuickLogger.Info("Started patching. Version: " + QuickLogger.GetAssemblyVersion());

#if DEBUG
            QuickLogger.DebugLogsEnabled = true;
            QuickLogger.Debug("Debug logs enabled");
#endif

            ModConfiguration.Initialize();

            CubeGeneratorBuildable.PatchSMLHelper();

            var harmony = new Harmony("com.ioncubegenerator.psmod");
            harmony.PatchAll(Assembly.GetExecutingAssembly());

            QuickLogger.Info("Finished patching");
        }
        protected override TechData GetBlueprintRecipe()
        {
            QuickLogger.Debug($"Creating recipe...");

            // Create and associate recipe to the new TechType
            var customFabRecipe = new TechData()
            {
                craftAmount = 1,
                Ingredients = new List <Ingredient>()
                {
                    new Ingredient(TechType.Silicone, 1)
                }
            };

            QuickLogger.Debug($"Created Ingredients");

            return(customFabRecipe);
        }
Esempio n. 13
0
        public bool IsAllowedToAdd(Pickupable pickupable)
        {
            bool flag = false;

            if (pickupable != null)
            {
                TechType techType = pickupable.GetTechType();

                QuickLogger.Debug(techType.ToString());

                if (pickupable.GetComponent <Eatable>() != null)
                {
                    flag = true;
                }
            }

            return(flag);
        }
Esempio n. 14
0
 protected override TechData GetBlueprintRecipe()
 {
     QuickLogger.Debug($"Creating recipe...");
     // Create and associate recipe to the new TechType
     var customFabRecipe = new TechData()
     {
         craftAmount = 1,
         Ingredients = new List <Ingredient>()
         {
             new Ingredient(TechType.TitaniumIngot, 1),
             new Ingredient(TechType.CopperWire, 1),
             new Ingredient(TechType.ComputerChip, 1),
             new Ingredient(TechType.AdvancedWiringKit, 1),
             new Ingredient(TechType.Glass, 1),
             new Ingredient(TechType.FiberMesh, 2),
             new Ingredient(TechType.Lubricant, 2),
         }
     };
        internal void ExposeInventoryData()
        {
            if (InventoryItem != null)
            {
                TechType = InventoryItem.item.GetTechType();
                PrefabId = InventoryItem.item.gameObject.GetComponent <PrefabIdentifier>()?.Id;
                var battery = InventoryItem.item.gameObject.GetComponent <Battery>();
                var food    = InventoryItem.item.gameObject.GetComponent <Eatable>();
                var fuel    = InventoryItem.item.gameObject.GetComponent <FireExtinguisher>();

                if (fuel != null)
                {
                    FuelData = new FuelData {
                        Fuel = fuel.fuel
                    };
                    QuickLogger.Debug($"Saved {TechType} fire extinguisher");
                    Type = ItemType.Fuel;
                    return;
                }

                if (battery != null)
                {
                    BatteryData = new BatteryData {
                        Capacity = battery._capacity, Charge = battery._charge
                    };
                    QuickLogger.Debug($"Saved {TechType} battery");
                    Type = ItemType.Battery;
                    return;
                }

                if (InventoryItem.item.gameObject.GetComponent <Eatable>() != null)
                {
                    FoodData = new FoodData {
                        FoodValue = food.GetFoodValue(), WaterValue = food.GetWaterValue()
                    };
                    QuickLogger.Debug($"Saved {TechType} Food");
                    Type = ItemType.Food;
                }
            }
            else
            {
                QuickLogger.Error($"InventoryItem was null when trying to set in the {nameof(ItemData)}");
            }
        }
Esempio n. 16
0
        private static void PatchToolTipFactory(Harmony harmony)
        {
            var toolTipFactoryType = Type.GetType("TooltipFactory, Assembly-CSharp");

            if (toolTipFactoryType != null)
            {
                QuickLogger.Debug("Got TooltipFactory Type");

                var inventoryItemViewMethodInfo = toolTipFactoryType.GetMethod("InventoryItem");

                if (inventoryItemViewMethodInfo != null)
                {
                    QuickLogger.Info("Got Inventory Item View Method Info");
                    var postfix = typeof(TooltipFactory_Patch).GetMethod("GetToolTip");
                    harmony.Patch(inventoryItemViewMethodInfo, null, new HarmonyMethod(postfix));
                }
            }


            //if (easyCraftClosestItemContainersType != null)
            //{
            //    QuickLogger.Debug("Got EasyCraft Type");
            //    var destroyItemMethodInfo = easyCraftClosestItemContainersType.GetMethod("DestroyItem");
            //    var getPickupCountMethodInfo = easyCraftClosestItemContainersType.GetMethod("GetPickupCount");

            //    if (destroyItemMethodInfo != null)
            //    {
            //        QuickLogger.Debug("Got EasyCraft DestroyItem Method");
            //        var postfix = typeof(EasyCraft_Patch).GetMethod("DestroyItem");
            //        harmony.Patch(destroyItemMethodInfo, null, new HarmonyMethod(postfix));
            //    }

            //    if (getPickupCountMethodInfo != null)
            //    {
            //        QuickLogger.Debug("Got EasyCraft GetPickupCount Method");
            //        var postfix = typeof(EasyCraft_Patch).GetMethod("GetPickupCount");
            //        harmony.Patch(getPickupCountMethodInfo, null, new HarmonyMethod(postfix));
            //    }
            //}
            //else
            //{
            //    QuickLogger.Error("Failed to get EasyCraft Type");
            //}
        }
Esempio n. 17
0
        public void OnEnable()
        {
            if (_isSelected)
            {
                return;
            }
            if (string.IsNullOrEmpty(BtnName))
            {
                return;
            }

            Disabled = false;

            UpdateTextComponent(IsTextMode());
            QuickLogger.Debug($"Button Name:{BtnName} || Button Mode {ButtonMode}", true);

            switch (this.ButtonMode)
            {
            case InterfaceButtonMode.TextScale:
                this.TextComponent.fontSize = this.TextComponent.fontSize;
                break;

            case InterfaceButtonMode.TextColor:
                this.TextComponent.color = this.STARTING_COLOR;
                break;

            case InterfaceButtonMode.Background:
                if (GetComponent <Image>() != null)
                {
                    GetComponent <Image>().color = this.STARTING_COLOR;
                }
                break;

            case InterfaceButtonMode.BackgroundScale:
                if (this.gameObject != null)
                {
                    this.gameObject.transform.localScale = this.gameObject.transform.localScale;
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Esempio n. 18
0
        private void OnLoadCategoryGrid(DisplayData data)
        {
            if (_isBeingDestroyed)
            {
                return;
            }

            _trackedButtons.Clear();
            _categoryGrid.ClearPage();

            var grouped = new List <Filter>();

            foreach (var filter in _filters)
            {
                if (filter.IsCategory())
                {
                    grouped.Add(filter);
                }
            }

            if (data.EndPosition > grouped.Count)
            {
                data.EndPosition = grouped.Count;
            }

            for (int i = data.StartPosition; i < data.EndPosition; i++)
            {
                GameObject buttonPrefab = Instantiate(data.ItemsPrefab);

                if (buttonPrefab == null || data.ItemsGrid == null)
                {
                    if (buttonPrefab != null)
                    {
                        QuickLogger.Debug("Destroying Tab", true);
                        Destroy(buttonPrefab);
                    }
                    return;
                }

                CreateFilterButton(data, buttonPrefab, grouped, i);
            }
            _categoryGrid.UpdaterPaginator(grouped.Count);
            UpdateCheckMarks();
        }
        public void OnConstructedChanged(bool constructed)
        {
            QuickLogger.Debug($"Constructed - {constructed}");

            if (IsBeingDeleted)
            {
                return;
            }

            if (constructed)
            {
                _seaBase = gameObject?.transform?.parent?.gameObject;

                if (isActiveAndEnabled)
                {
                    if (IsOperational())
                    {
                        if (!IsInitialized)
                        {
                            Initialize();
                        }

                        if (_display != null)
                        {
                            _display.Setup(this);
                            _runStartUpOnEnable = false;
                        }

                        _currentBiome = BiomeManager.GetBiome();
                        RotateToMag();
                        SetCurrentRotation();
                        QuickLogger.Debug($"Turbine Constructed Rotation Set {_rotor.transform.rotation.ToString()} ", true);
                    }
                    else
                    {
                        QuickLogger.Message(DisplayLanguagePatching.NotOperational(), true);
                    }
                }
                else
                {
                    _runStartUpOnEnable = true;
                }
            }
        }
Esempio n. 20
0
        public static bool GetPrefabs()
        {
            try
            {
                if (!_initialized)
                {
                    QuickLogger.Debug($"AssetBundle Set");

                    QuickLogger.Debug("GetPrefabs");
                    _assetBundle = AssetHelper.Asset(Mod.ModFolderName, Mod.BundleName);

                    Bundle = _assetBundle;

                    //We have found the asset bundle and now we are going to continue by looking for the model.
                    GameObject prefab = _assetBundle.LoadAsset <GameObject>(Mod.ModPrefabName);


                    //If the prefab isn't null lets add the shader to the materials
                    if (prefab != null)
                    {
                        //Lets apply the material shader
                        ApplyShaders(prefab, _assetBundle);

                        Prefab = prefab;
                        QuickLogger.Debug($"{Mod.ModFriendlyName} Prefab Found!");
                    }
                    else
                    {
                        QuickLogger.Error($"{Mod.ModFriendlyName} Gen Prefab Not Found!");
                        return(false);
                    }


                    _initialized = true;
                }

                return(true);
            }
            catch (Exception e)
            {
                QuickLogger.Error(e.Message);
                return(false);
            }
        }
Esempio n. 21
0
        public void RefreshVehicles(List <Vehicle> vehicles)
        {
            if (_isBeingDestroyed)
            {
                return;
            }

            QuickLogger.Debug("Refreshing Vehicles");

            if (!vehicles.Contains(_currentVehicle))
            {
                _currentVehicle = null;
                _vehicleGrid.DrawPage();
                if (_mono.AnimationManager.GetIntHash(_page) != (int)TerminalPages.Home)
                {
                    GoToPage(TerminalPages.VehiclesPage);
                }
            }
        }
        private static VehicleUpgrader CreateNewUpgrader <T>(T vehicle) where T : Vehicle
        {
            var upgrader = new VehicleUpgrader
            {
                InstanceID = vehicle.GetInstanceID()
            };

            if (upgrader.Initialize(vehicle))
            {
                Upgraders.Add(upgrader);
                QuickLogger.Debug("CreateNewUpgrader: Initialize successful");
                return(upgrader);
            }
            else
            {
                QuickLogger.Debug("CreateNewUpgrader: Initialize failed");
                return(null);
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Saves all the bases settings
        /// </summary>
        internal static void SaveBases()
        {
            QuickLogger.Debug("Save Bases");
            var saveDirectory = Information.GetSaveFileDirectory();
            var SaveFile      = Path.Combine(saveDirectory, "Bases.json");

            QuickLogger.Debug($"SD {saveDirectory} || SF {SaveFile}");

            if (!Directory.Exists(saveDirectory))
            {
                Directory.CreateDirectory(saveDirectory);
            }


            var output = JsonConvert.SerializeObject(Managers, Formatting.Indented);

            File.WriteAllText(SaveFile, output);
            LoadData.CleanOldSaveData();
        }
Esempio n. 24
0
        public void ConnectToCyclops(SubRoot parentCyclops, CyclopsManager manager = null)
        {
            if (ParentCyclops != null)
            {
                return;
            }

            ParentCyclops = parentCyclops;
            this.transform.SetParent(parentCyclops.transform);
            Manager = manager ?? CyclopsManager.GetAllManagers(parentCyclops);

            if (!Manager.ChargeManager.CyBioReactors.Contains(this))
            {
                Manager.ChargeManager.CyBioReactors.Add(this);
            }

            UpdateBoosterCount(Manager.ChargeManager.BioBoosters.Count);
            QuickLogger.Debug("Bioreactor has been connected to Cyclops", true);
        }
        public static void Patch()
        {
            try
            {
                QuickLogger.Info("Started patching - " + QuickLogger.GetAssemblyVersion());

                //Handle Config Options
                var configOptions = new UpgradeOptions();
                configOptions.Initialize();

                QuickLogger.DebugLogsEnabled = configOptions.DebugLogsEnabled;
                QuickLogger.Debug("Debug logs enabled");

                CrossModUpdates();

                CraftTreeHandler.AddTabNode(CraftTree.Type.Workbench, WorkBenchTab, "Armor Modules", SpriteManager.Get(TechType.VehicleArmorPlating));

                //Handle SpeedBooster
                var speedModule = new SpeedBooster();
                speedModule.Patch();

                //Handle HullArmorUpgrades
                var hullArmorMk2Module = new HullArmorMk2();
                hullArmorMk2Module.Patch();

                var hullArmorMk3Module = new HullArmorMk3(hullArmorMk2Module.TechType);
                hullArmorMk3Module.Patch();

                var hullArmorMk4Module = new HullArmorMk4(hullArmorMk3Module.TechType);
                hullArmorMk4Module.Patch();

                VehicleUpgrader.SetBonusSpeedMultipliers(configOptions);

                var harmony = HarmonyInstance.Create("com.upgradedvehicles.psmod");
                harmony.PatchAll(Assembly.GetExecutingAssembly());

                QuickLogger.Info("Finished patching");
            }
            catch (Exception ex)
            {
                QuickLogger.Error(ex);
            }
        }
Esempio n. 26
0
        internal void KillCooking()
        {
            QuickLogger.Debug("Kill Cooking");

            if (_cookall != null)
            {
                StopCoroutine(_cookall);
            }

            if (_cook != null)
            {
                StopCoroutine(_cook);
            }

            _mono.UpdateIsRunning(false);
            _mono.DisplayManager.ToggleProcessDisplay(false);
            _mono.DisplayManager.ResetProgressBar();
            Reset();
        }
Esempio n. 27
0
        private void OnLoadDisplay(DisplayData data)
        {
            QuickLogger.Debug("Loading SeaBreeze Display");

            _sbList.Clear();

            var items = _mono.SeaBreezes.Keys;


            if (data.EndPosition > items.Count)
            {
                data.EndPosition = items.Count;
            }

            _seaBreezeGrid.ClearPage();

            for (int i = data.StartPosition; i < data.EndPosition; i++)
            {
                var unit = _mono.SeaBreezes.Values.ElementAt(i);
                var unitNameController = unit;
                var unitName           = unitNameController.GetName();
                unitNameController.SubscribeToNameChange(OnLabelChanged);

                GameObject itemDisplay = Instantiate(data.ItemsPrefab);

                itemDisplay.transform.SetParent(data.ItemsGrid.transform, false);
                var text = itemDisplay.transform.Find("Text").GetComponent <Text>();
                text.text = unitName;

                var itemButton = itemDisplay.AddComponent <CustomToggle>();
                itemButton.ButtonMode     = InterfaceButtonMode.TextColor;
                itemButton.Tag            = unit;
                itemButton.TextComponent  = text;
                itemButton.OnButtonClick += OnButtonClick;
                itemButton.BtnName        = "SeaBreeze";
                unitNameController.SetNameControllerTag(itemButton);
                _sbList.Add(itemButton);
                UpdateCheckedSB();
                QuickLogger.Debug($"Added Unit {unitName}");
            }

            _seaBreezeGrid.UpdaterPaginator(items.Count);
        }
        internal static void ApplyColorMaskShader(string materialName, string maskTexture, Color color, Color color2, Color color3, GameObject gameObject, AssetBundle assetBundle)
        {
            QuickLogger.Debug($"[ApplyColorMaskShader] In Apply Color Mask");

            var shader = Shader.Find("MarmosetUBER");

            Renderer[] renderers = gameObject.GetComponentsInChildren <Renderer>(true);

            QuickLogger.Debug($"[ApplyColorMaskShader] Renderer Count: {renderers.Length}");


            foreach (Renderer renderer in renderers)
            {
                foreach (Material material in renderer.materials)
                {
                    QuickLogger.Debug($"[ApplyColorMaskShader] Material Name: {material.name} || Compare to: {materialName} || Result: {material.name.ToLower().StartsWith(materialName.ToLower())} || Render:{renderer.name}");


                    if (material.name.StartsWith(materialName, StringComparison.OrdinalIgnoreCase))
                    {
                        material.shader = shader;
                        QuickLogger.Debug("Setting Color Mask Shader", true);

                        material.EnableKeyword("UWE_3COLOR");
                        QuickLogger.Debug("Setting Color Mask UWE_3COLOR", true);

                        material.SetFloat("_Enable3Color", 1);

                        material.SetTexture("_MultiColorMask", FindTexture2D(maskTexture, assetBundle));
                        QuickLogger.Debug("Setting Color Mask _MultiColorMask", true);

                        material.SetColor("_Color", color);
                        QuickLogger.Debug("Setting Color Mask _Color", true);

                        material.SetColor("_Color2", color2);
                        QuickLogger.Debug("Setting Color Mask _Color2", true);

                        material.SetColor("_Color3", color3);
                        QuickLogger.Debug("Setting Color Mask _Color3", true);
                    }
                }
            }
        }
        private void Start()
        {
            this.Animator = this.transform.GetComponentInChildren <Animator>();

            _drillState = Animator.StringToHash("DrillingState");

            if (this.Animator == null)
            {
                QuickLogger.Error("Animator component not found on the GameObject.");
            }

            if (this.Animator != null && this.Animator.enabled == false)
            {
                QuickLogger.Debug("Animator was disabled and now has been enabled");
                this.Animator.enabled = true;
            }

            //_audioHandler = new AudioHandler(transform);
        }
        internal void ChangeTakeO2State(ButtonStates state)
        {
            QuickLogger.Debug($"Changing Button State for {nameof(ChangeTakeO2State)}");
            switch (state)
            {
            case ButtonStates.Enabled:
                _buttonLbl.text = OxStationBuildable.TakeOxygen();
                _giveOIntBtn.OnEnable();
                break;

            case ButtonStates.Disabled:
                _buttonLbl.text = OxStationBuildable.Damaged();
                _giveOIntBtn.OnDisable();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(state), state, null);
            }
        }