Пример #1
0
        private bool IsAllowedToAdd(Pickupable pickupable, bool verbose)
        {
            if (pickupable.gameObject.GetComponent <FCSTechFabricatorTag>() != null)
            {
                if (pickupable.GetTechType() == TechTypeHelper.BatteryAttachmentTechType() || pickupable.GetTechType() == TechTypeHelper.SolarAttachmentTechType())
                {
                    if (_powerModuleAttached)
                    {
                        QuickLogger.Message(FCSDeepDrillerBuildable.OnePowerAttachmentAllowed(), true);
                        return(false);
                    }
                }
                else if (pickupable.GetTechType() == TechTypeHelper.DrillerMK1TechType() ||
                         pickupable.GetTechType() == TechTypeHelper.DrillerMK2TechType() ||
                         pickupable.GetTechType() == TechTypeHelper.DrillerMK3TechType())
                {
                    if (_upgradeAttached)
                    {
                        QuickLogger.Message(FCSDeepDrillerBuildable.OneUpgradeAllowed(), true);
                        return(false);
                    }
                }

                return(true);
            }

            QuickLogger.Message(FCSDeepDrillerBuildable.DDAttachmentsOnly(), true);
            return(false);
        }
Пример #2
0
        internal static void TeleportPlayer(QuantumTeleporterController fromUnit, QuantumTeleporterController toUnit, QTTeleportTypes type)
        {
            if (_initialized)
            {
                _fromUnit = fromUnit;
                _toUnit   = toUnit;

                if (!fromUnit.PowerManager.HasEnoughPower(type))
                {
                    QuickLogger.Message(QuantumTeleporterBuildable.BaseNotEnoughPower(), true);
                    return;
                }

                if (!_toUnit.PowerManager.HasEnoughPower(type))
                {
                    QuickLogger.Message(QuantumTeleporterBuildable.ToBaseNotEnoughPower(), true);
                    return;
                }

                InitializeTeleport(_toUnit, type);

                InitializeTeleport(_fromUnit, type);

                Player.main.playerController.SetEnabled(false);

                var target = _toUnit.GetTarget();

                if (target != null)
                {
                    _target = target;
                    SetIsTeleporting(true);
                }
            }
        }
        internal void Initialize()
        {
            try
            {
                LoadFromFile();
            }
            catch (Exception ex)
            {
                QuickLogger.Error($"EXCEPTION LOADING {ConfigKey}: " + ex.ToString());
                WriteConfigFile();
            }
            finally
            {
                Initialized = true;

                if (this.Value)
                {
                    QuickLogger.Message("ForceUnlockAtStart was enabled. New items will start unlocked.");
                }
                else
                {
                    QuickLogger.Message("New items set to normal unlock requirements.");
                }
            }
        }
        internal bool SendItems(ItemsContainer items, AlterraShippingTarget target)
        {
            QuickLogger.Debug($"Starting Transfer to {target.GetInstanceID()}", true);
            QuickLogger.Debug($"Target Found: {target.Name}", true);
            QuickLogger.Debug($"Target IsReceivingTransfer: {target.IsReceivingTransfer}", true);

            if (_mono == null)
            {
                _mono = gameObject.GetComponent <AlterraShippingTarget>();
            }

            if (!target.IsReceivingTransfer)
            {
                QuickLogger.Debug($"Starting Transfer to {target.Name}", true);
                _target = target;
                _items  = items;
                _done   = false;
                _target.IsReceivingTransfer = true;
                _currentTime = GetTime(_target);
                _target.OnReceivingTransfer?.Invoke();
            }
            else
            {
                QuickLogger.Message(string.Format(AlterraShippingBuildable.TargetIsShipping(), _target.Name), true);
            }

            return(true);
        }
        private bool GetFunctionName(string functionString, out string result)
        {
            var methodName = string.Empty;

            result = string.Empty;
            //Spit by "."
            var parts = functionString.Split('.');

            if (parts.Length <= 0)
            {
                return(false);
            }

            for (int i = 0; i < parts.Length; i++)
            {
                var item = parts[i].Trim();
                if (item.EndsWith(";") && item.Contains("(") && item.Contains(")"))
                {
                    methodName = item.GetUntilOrEmpty();

                    if (_classes.Any(x => x.FunctionName == methodName))
                    {
                        QuickLogger.Debug($"Method Name = {methodName}", true);
                        result = methodName;
                        return(true);
                    }
                }
            }

            QuickLogger.Message(string.Format(FCSDeepDrillerBuildable.InvalidFunctionFormat(), methodName), true);

            return(false);
        }
        public bool IsAllowedToAdd(Pickupable pickupable, bool verbose)
        {
            var dna = pickupable.GetComponent <FCSDNA>();

            if (dna == null)
            {
                return(false);
            }

            if (IsFull)
            {
                QuickLogger.Message(HydroponicHarvestersBuildable.StorageFull(), true);
                return(false);
            }

            dna.GetDnaData();

            if (_currentEnvironment != dna.Environment)
            {
                QuickLogger.Message(HydroponicHarvestersBuildable.IncorrectEnvironment(), true);
                return(false);
            }

            var result = CanBeStored(_mono.DumpContainer.GetCount() + 1, pickupable.GetTechType());

            if (!result)
            {
                QuickLogger.Message(HydroponicHarvestersBuildable.StorageFull(), true);
            }

            return(result);
        }
Пример #7
0
        internal static bool IsValid(string[] paraResults, out int amountPerDay)
        {
            amountPerDay = 0;
            try
            {
                if (paraResults.Length != 1)
                {
                    //TODO Show Message Box with error of incorrect parameters
                    QuickLogger.Message(string.Format(FCSDeepDrillerBuildable.IncorrectAmountOfParameterFormat(), "1", paraResults.Length), true);
                    return(false);
                }

                if (int.TryParse(paraResults[0], out var result))
                {
                    amountPerDay = Convert.ToInt32(result);
                }
                else
                {
                    QuickLogger.Message(string.Format(FCSDeepDrillerBuildable.IncorrectParameterFormat(), "INT", "OS.OresPerDay(10);"), true);
                    return(false);
                }
            }
            catch (Exception e)
            {
                //TODO Show Message Box with error of incorrect parameters
                QuickLogger.Error(e.Message);
                QuickLogger.Error(e.StackTrace);
                return(false);
            }

            return(true);
        }
Пример #8
0
        public static void Patch()
        {
            try
            {
                QuickLogger.Message("Started patching - " + QuickLogger.GetAssemblyVersion());

                if (TechTypeHandler.TryGetModdedTechType("SeamothHullModule4", out TechType vehicleHullModule4) &&
                    TechTypeHandler.TryGetModdedTechType("SeamothHullModule5", out TechType vehicleHullModule5))
                {
                    VehicleUpgrader.SetModdedDepthModules(vehicleHullModule4, vehicleHullModule5);
                }

                SpeedBooster speedModule = SpeedBooster.Main;
                speedModule.Patch();

                VehicleUpgrader.SetSpeedBooster(speedModule);

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

                QuickLogger.Message("Finished patching");
            }
            catch (Exception ex)
            {
                QuickLogger.Error("EXCEPTION on Patch: " + ex.ToString());
            }
        }
Пример #9
0
        bool IFCSStorage.IsAllowedToAdd(Pickupable pickupable, bool verbose)
        {
            var eatable = pickupable.gameObject.GetComponent <Eatable>();

            if (eatable != null)
            {
                if (eatable.decomposes && pickupable.GetTechType() != TechType.CreepvinePiece)
                {
                    QuickLogger.Message(ExStorageDepotBuildable.FoodNotAllowed(), true);
                    return(false);
                }
            }

            if (_mono.DumpContainer == null)
            {
                QuickLogger.Error("DumpContainer returned null");
                return(false);
            }

            if (!CanBeStored(_mono.DumpContainer.GetCount() + 1, pickupable.GetTechType()))
            {
                QuickLogger.Info(ExStorageDepotBuildable.NoMoreSpace(), true);
                return(false);
            }

            return(true);
        }
        private void LoadFromFile()
        {
            if (!File.Exists(ConfigFile))
            {
                QuickLogger.Message("Config file for VModFabricator not found. Writing default file.");
                SetDefaults();
                WriteConfigFile();
                return;
            }

            string text = File.ReadAllText(ConfigFile, Encoding.UTF8);

            if (!text.TrimStart('#').Trim().StartsWith(ConfigTopLine))
            {
                QuickLogger.Message("Config file for VModFabricator was outdated. Overwriting with default file.");
                SetDefaults();
                WriteConfigFile();
                return;
            }

            bool readCorrectly = FromString(text);

            if (!readCorrectly)
            {
                QuickLogger.Message("Config file for VModFabricator contained errors. Overwriting with default file.");
                SetDefaults();
                WriteConfigFile();
                return;
            }
        }
        private bool IsAllowedToAdd(Pickupable pickupable, bool verbose)
        {
            bool flag = false;

            if (_fridge.IsFull)
            {
                QuickLogger.Message(_storageIsFullMessage, true);
                return(false);
            }

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

                QuickLogger.Debug(techType.ToString());

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

            QuickLogger.Debug($"Adding Item {flag} || {verbose}");

            if (!flag && verbose)
            {
                QuickLogger.Message(_itemNotAllowedMessage, true);
                flag = false;
            }

            return(flag);
        }
        public bool IsAllowedToAdd(Pickupable pickupable, bool verbose)
        {
            bool flag = false;

            if (IsFull)
            {
                QuickLogger.Message(LanguageHelpers.GetLanguage("InventoryFull"), true);
                return(false);
            }

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

                QuickLogger.Debug(techType.ToString());

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

            QuickLogger.Debug($"Adding Item {flag} || {verbose}");

            if (!flag && verbose)
            {
                QuickLogger.Message(LanguageHelpers.GetLanguage("TimeCapsuleItemNotAllowed"), true);
                flag = false;
            }

            return(flag);
        }
        public void RemoveItem(TechType techType, EatableType eatableType)
        {
            var pickupable = techType.ToPickupable();

            if (Inventory.main.HasRoomFor(pickupable))
            {
                EatableEntities match = FindMatch(techType, eatableType);

                if (match != null)
                {
                    var go      = GameObject.Instantiate(CraftData.GetPrefabForTechType(techType));
                    var eatable = go.GetComponent <Eatable>();
                    var pickup  = go.GetComponent <Pickupable>();

                    match.UnpauseDecay();
                    eatable.timeDecayStart = match.TimeDecayStart;

                    if (Inventory.main.Pickup(pickup))
                    {
                        QuickLogger.Debug($"Removed Match Before || Fridge Count {FridgeItems.Count}");
                        FridgeItems.Remove(match);
                        QuickLogger.Debug($"Removed Match || Fridge Count {FridgeItems.Count}");
                    }
                    else
                    {
                        QuickLogger.Message(LanguageHelpers.GetLanguage("InventoryFull"), true);
                    }
                    GameObject.Destroy(pickupable);
                    OnContainerUpdate?.Invoke(NumberOfItems, _itemLimit);
                }
            }
        }
        internal static void SetModdedDepthModules(TechType seamothDepth4, TechType seamothDepth5)
        {
            QuickLogger.Message("Additional Seamoth Depth Modules from MoreSeamothUpgrades registered");

            CommonUpgradeModules.Add(SeamothHullModule4 = seamothDepth4);
            CommonUpgradeModules.Add(SeamothHullModule5 = seamothDepth5);
            HasModdedDepthModules = true;
        }
        internal void OnButtonClick(string btnName, object additionalObject)
        {
            switch (btnName)
            {
            case "SentPackages":

                if (!_mono.HasItems())
                {
                    QuickLogger.Info($"There are no items to ship canceling shipment", true);
                    return;
                }

                TargetScreen();
                break;

            case "OpenContainer":
                _mono.OpenStorage();
                _animatorController.OpenDoors();
                break;

            case "CancelBTN":
                MainScreen();
                break;

            case "ColorItem":
                var color = (Color)additionalObject;
                ColorHandler.ChangeBodyColor("AlterraShipping_BaseColor", color, _mono.gameObject);
                QuickLogger.Debug($"{_mono.gameObject.name} Color Changed to {color.ToString()}");
                _mono.SetCurrentBodyColor(color);
                break;

            case "ColorPickerBTN":
                ColorPickerScreen();
                break;

            case "ColorCancelBTN":
                MainScreen();
                break;

            case "ShippingContainer":
                var target = additionalObject as AlterraShippingTarget;

                if (target == null)
                {
                    QuickLogger.Error <AlterraShippingDisplay>("The target shipping container returned null");
                    return;
                }

                if (target.IsReceivingTransfer || target.IsFull())
                {
                    QuickLogger.Message($"Target Inventory doesn't have enough free slots or is receiving a shipment", true);
                    return;
                }

                ShippingScreen(target);
                break;
            }
        }
Пример #16
0
 // Token: 0x06000089 RID: 137 RVA: 0x00003A04 File Offset: 0x00001C04
 private static void Postfix(Beacon __instance)
 {
     OxStationController[] array = UnityEngine.Object.FindObjectsOfType <OxStationController>();
     if (array.Any(t => t.TryAttachBeacon(__instance)))
     {
         QuickLogger.Message("Beacon attached", true);
         return;
     }
 }
        internal bool HasVehicles(bool verbose = false)
        {
            var value = DockingBays.Count > 0 && Vehicles.Count > 0;

            if (!value && verbose)
            {
                QuickLogger.Message(AuxPatchers.NoVehiclesDocked(), true);
            }

            return(value);
        }
        public bool AddItemToContainer(InventoryItem item)
        {
            var food = item.item.GetComponentInChildren <Eatable>();

            if (food != null)
            {
                bool successful = false;
                if ((!food.decomposes || item.item.GetTechType() == TechType.CreepvinePiece) && CanBeStored(DumpContainer.GetCount() + 1, item.item.GetTechType()))
                {
                    var rackController = FindValidRack(item.item.GetTechType(), 1, out var slot);
                    if (rackController == null)
                    {
                        return(false);
                    }
                    rackController.AddItemToAServer(item, slot);
                    successful = true;
                }
                else
                {
                    foreach (KeyValuePair <string, FCSConnectableDevice> fcsConnectable in FCSConnectables)
                    {
                        if (fcsConnectable.Value.CanBeStored(1, item.item.GetTechType()) && fcsConnectable.Value.GetTechType() == Mod.GetSeaBreezeTechType())
                        {
                            var result = fcsConnectable.Value.AddItemToContainer(new InventoryItem(item.item), out string reason);
                            successful = true;

                            if (!result)
                            {
                                QuickLogger.Error(reason);
                            }
                            break;
                        }
                    }
                }

                if (!successful)
                {
                    QuickLogger.Message(string.Format(AuxPatchers.NoEmptySeaBreezeFormat(), item.item.GetTechType()), true);
                    return(false);
                }
            }
            else
            {
                var rackController = FindValidRack(item.item.GetTechType(), 1, out var slot);
                if (rackController == null)
                {
                    return(false);
                }
                rackController.AddItemToAServer(item, slot);
            }

            return(true);
        }
        public bool IsAllowedToAdd(Pickupable pickupable, bool verbose)
        {
            var successful = false;
            var food       = pickupable.GetComponentInChildren <Eatable>();

            if (food != null)
            {
#if DEBUG
                QuickLogger.Debug($"Food Check {CanBeStored(DumpContainer.GetCount() + 1, pickupable.GetTechType())}", true);
#endif

                if ((!food.decomposes || AllowedFoodItems.Contains(pickupable.GetTechType())) && CanBeStored(DumpContainer.GetCount() + 1, pickupable.GetTechType()))
                {
                    successful = true;
                }
                else
                {
                    foreach (KeyValuePair <string, FCSConnectableDevice> seaBreeze in FCSConnectables)
                    {
                        if (seaBreeze.Value.GetTechType() != Mod.GetSeaBreezeTechType())
                        {
                            continue;
                        }
                        if (!seaBreeze.Value.CanBeStored(1, pickupable.GetTechType()))
                        {
                            continue;
                        }
                        successful = true;
                    }
                }

                if (!successful)
                {
                    QuickLogger.Message(AuxPatchers.NoFoodItems(), true);
                }


                QuickLogger.Debug($"Food Allowed Result: {successful}", true);
                return(successful);
            }
#if DEBUG
            QuickLogger.Debug($"{DumpContainer.GetCount() + 1}", true);
#endif

            if (!CanBeStored(DumpContainer.GetCount() + 1, pickupable.GetTechType()))
            {
                QuickLogger.Message(AuxPatchers.CannotBeStored(), true);
                return(false);
            }

            return(true);
        }
Пример #20
0
        private bool IsAllowedToRemove(Pickupable pickupable, bool verbose)
        {
            if (pickupable.GetTechType() == TechTypeHelper.BatteryAttachmentTechType())
            {
                if (_mono.BatteryController.GetController().HasBatteries())
                {
                    QuickLogger.Message(FCSDeepDrillerBuildable.BatteryAttachmentHasBatteries(), true);
                    return(false);
                }
            }

            return(true);
        }
        private bool ValidateClassType(string functionString)
        {
            //Spit by "."
            var parts = functionString.Split('.');

            //If the command has more than zero parts and contains os as the first item the class is valid
            var result = parts.Length > 0 && parts.Select(t => t.Trim()).Any(item => item.ToLower().Equals("os"));

            if (!result)
            {
                QuickLogger.Message(string.Format(FCSDeepDrillerBuildable.InvalidClassFormat(), parts.Length > 0 ? parts[0] : "N/A"), true);
            }

            return(result);
        }
Пример #22
0
        public static void Patch()
        {
            try
            {
                QuickLogger.Message("Start patching. Version: " + QuickLogger.GetAssemblyVersion());
                var vmodFabricator = new VModFabricatorModule();

                vmodFabricator.Patch();
                QuickLogger.Message("Finished patching");
            }
            catch (Exception ex)
            {
                QuickLogger.Error("EXCEPTION on Patch: " + ex.ToString());
            }
        }
        /// <summary>
        /// A method that takes the tank from holder and gives it to the player.
        /// </summary>
        private void TakeTank()
        {
            var size = CraftData.GetItemSize(TechType.FireExtinguisher);

            if (!Inventory.main.HasRoomFor(size.x, size.y))
            {
                QuickLogger.Message(Language.main.Get("InventoryFull"));
                return;
            }

            CraftData.AddToInventory(TechType.FireExtinguisher, 1, false, false);

            _hasTank = false;
            _tankMesh.SetActive(false);
            gameObject.GetComponent <FireExtinguisher>().fuel = _fuel;
        }
        public bool IsAllowedToAdd(Pickupable pickupable, bool verbose)
        {
            if (pickupable.GetTechType() != TechType.Lubricant)
            {
                QuickLogger.Message(FCSDeepDrillerBuildable.ItemNotAllowed(), true);
                return(false);
            }

            if (!CanBeStored(_mono.OilDumpContainer.GetCount(), TechType.Lubricant))
            {
                QuickLogger.Message(string.Format(FCSDeepDrillerBuildable.OilTankNotEmpty(), TimeTilRefuel()), true);
                return(false);
            }

            return(true);
        }
Пример #25
0
        internal void CookAllFood(ItemsContainer container)
        {
            if (_mono.PowerManager.GetPowerState() == FCSPowerStates.Unpowered)
            {
                QuickLogger.Message(SeaCookerBuildable.NoPowerAvailable(), true);
            }

            if (_mono.PowerManager.GetPowerState() == FCSPowerStates.Unpowered || !_mono.StorageManager.HasRoomForAll())
            {
                KillCooking();
                return;
            }

            _cookall = StartCoroutine(CookAll(container));
            QuickLogger.Debug("Cooking All Food", true);
        }
 internal void Initialize()
 {
     try
     {
         LoadFromFile();
     }
     catch
     {
         QuickLogger.Message("Error loading Config file for VModFabricator. Overwriting with default file.");
         SetDefaults();
         WriteConfigFile();
     }
     finally
     {
         IsInitialized = true;
     }
 }
        internal static bool IsValid(string[] paraResults, out Tuple <TechType, int> data)
        {
            data = null;
            try
            {
                if (paraResults.Length != 2)
                {
                    //TODO Show Message Box with error of incorrect parameters
                    QuickLogger.Message(string.Format(FCSDeepDrillerBuildable.IncorrectAmountOfParameterFormat(), "2", paraResults.Length), true);
                    return(false);
                }

                int amount;
                if (int.TryParse(paraResults[1], out var result))
                {
                    amount = Convert.ToInt32(result);
                }
                else
                {
                    QuickLogger.Message(string.Format(FCSDeepDrillerBuildable.IncorrectParameterFormat(), "TechType,INT", "OS.MaxOreCount(Silver,10);"), true);
                    return(false);
                }

                TechType techType;
                if (BiomeManager.IsApproved(paraResults[0].ToTechType()))
                {
                    techType = paraResults[0].ToTechType();
                }
                else
                {
                    QuickLogger.Message(string.Format(FCSDeepDrillerBuildable.NotOreErrorFormat(), paraResults[0]), true);
                    return(false);
                }

                data = new Tuple <TechType, int>(techType, amount);
            }
            catch (Exception e)
            {
                //TODO Show Message Box with error of incorrect parameters
                QuickLogger.Error(e.Message);
                QuickLogger.Error(e.StackTrace);
                return(false);
            }

            return(true);
        }
Пример #28
0
        public static void Patch()
        {
            try
            {
                QuickLogger.Message("Started patching " + QuickLogger.GetAssemblyVersion());

                OtherMods.VehicleUpgradesInCyclops = Directory.Exists(@"./QMods/VehicleUpgradesInCyclops");

                if (OtherMods.VehicleUpgradesInCyclops)
                {
                    QuickLogger.Message("VehicleUpgradesInCyclops detected. Correcting placement of craft nodes in Cyclops Fabricator.");
                }

                var modConfig = new EmModPatchConfig();
                modConfig.Initialize();

                QuickLogger.Message("Patching new upgrade modules");
                CyclopsModule.PatchAllModules(modConfig.EnableNewUpgradeModules);

                if (!modConfig.EnableNewUpgradeModules)
                {
                    QuickLogger.Message("New upgrade modules disabled by config settings");
                }

                QuickLogger.Message("Patching Auxiliary Upgrade Console");

                var auxConsole = new AuxCyUpgradeConsole();

                auxConsole.Patch(modConfig.EnableAuxiliaryUpgradeConsoles);

                if (!modConfig.EnableAuxiliaryUpgradeConsoles)
                {
                    QuickLogger.Message("Auxiliary Upgrade Console disabled by config settings");
                }

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

                QuickLogger.Message("Finished Patching");
            }
            catch (Exception ex)
            {
                QuickLogger.Error(ex);
            }
        }
Пример #29
0
        public static void Patch()
        {
            QuickLogger.Message("Start patching. Version: " + QuickLogger.GetAssemblyVersion());

            try
            {
                DeepBatteryCellBase.PatchAll();

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

                QuickLogger.Message("Finished patching");
            }
            catch (Exception ex)
            {
                QuickLogger.Error(ex);
            }
        }
        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;
                }
            }
        }