コード例 #1
0
        public static void Init(string directory, string settingsJSON)
        {
            Logger = HBS.Logging.Logger.GetLogger("CustomFilters", LogLevel.Debug);

            try
            {
                try
                {
                    Settings = new CustomFiltersSettings();
                    JSONSerializationUtility.FromJSON(Settings, settingsJSON);
                    HBS.Logging.Logger.SetLoggerLevel(Logger.Name, Settings.LogLevel);
                }
                catch (Exception)
                {
                    Settings = new CustomFiltersSettings();
                }

                Settings.Complete();
                SetupLogging(directory);

                var harmony = HarmonyInstance.Create("io.github.denadan.CustomFilters");
                harmony.PatchAll(Assembly.GetExecutingAssembly());

                Logger.Log("Loaded CustomFilters v0.1 for bt 1.6.2");

                CustomComponents.Registry.RegisterSimpleCustomComponents(Assembly.GetExecutingAssembly());

                Logger.LogDebug("done");
                Logger.LogDebug(JSONSerializationUtility.ToJSON(Settings));
            }
            catch (Exception e)
            {
                Logger.LogError(e);
            }
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: CptMoore/DynModLib
 public void SaveSettings <T>(T settings) where T : ModSettings
 {
     using (var writer = new StreamWriter(SettingsPath))
     {
         var json = JSONSerializationUtility.ToJSON(settings);
         writer.Write(json);
     }
 }
コード例 #3
0
        private void init(string directory, string settingsJSON)
        {
            try
            {
                Logger = HBS.Logging.Logger.GetLogger(ModName, LogLevel.Debug);
                try
                {
                    Settings = new Settings();
                    JSONSerializationUtility.FromJSON(Settings, settingsJSON);
                    HBS.Logging.Logger.SetLoggerLevel(Logger.Name, LogLevel.Debug);
                }
                catch (Exception)
                {
                    Settings = new Settings();
                }

                if (!Settings.AddLogPrefix)
                {
                    LogPrefix = "";
                }

                SetupLogging(directory);

                var harmony = HarmonyInstance.Create($"{ModName}");
                harmony.PatchAll(Assembly.GetExecutingAssembly());
                Logger.Log("=========================================================");
                Logger.Log($"Loaded {ModName} v0.5 for bt 1.9");
                Logger.Log("=========================================================");

                if (Settings.ShowSettingsOnLoad)
                {
                    Logger.LogDebug(JSONSerializationUtility.ToJSON(Settings));
                }
                CustomComponents.Registry.RegisterSimpleCustomComponents(Assembly.GetExecutingAssembly());

                if (Settings.FixMechPartCost)
                {
                    CustomComponents.AutoFixer.Shared.RegisterMechFixer(Extentions.FixVehicleCost, Settings.FakeVehicleTag);
                }
                if (Settings.FixUIName)
                {
                    CustomComponents.AutoFixer.Shared.RegisterMechFixer(Extentions.FixVehicleUIName, Settings.FakeVehicleTag);
                }
                if (Settings.AddWeaponToDescription)
                {
                    CustomComponents.AutoFixer.Shared.RegisterMechFixer(Extentions.FixDescription, Settings.FakeVehicleTag);
                }

                Logger.LogDebug("done");
            }
            catch (Exception e)
            {
                Logger.LogError(e);
            }
        }
コード例 #4
0
 public override string GenerateJSONTemplate()
 {
     return(JSONSerializationUtility.ToJSON <LanceSpawnedMessage>(new LanceSpawnedMessage(string.Empty, string.Empty)));
 }
コード例 #5
0
 public override string ToJSON()
 {
     return(JSONSerializationUtility.ToJSON <LanceSpawnedMessage>(this));
 }
コード例 #6
0
 public string GenerateJSONTemplate()
 {
     return(JSONSerializationUtility.ToJSON(new ModEntry("")));
 }
コード例 #7
0
 public override string ToJSON()
 {
     return(JSONSerializationUtility.ToJSON <SwapPlacementGameLogic>(this));
 }
コード例 #8
0
 public override string ToJSON()
 {
     return(JSONSerializationUtility.ToJSON(this));
 }
コード例 #9
0
 public override string GenerateJSONTemplate()
 {
     return(JSONSerializationUtility.ToJSON <SetChunkStateAtRandomActivator>(new SetChunkStateAtRandomActivator()));
 }
コード例 #10
0
        public static void Init(string directory, string settingsJSON)
        {
            Logger = HBS.Logging.Logger.GetLogger("CustomComponents", LogLevel.Debug);
            SetupLogging(directory);

            try
            {
                try
                {
                    Settings = new CustomComponentSettings();
                    JSONSerializationUtility.FromJSON(Settings, settingsJSON);
                    HBS.Logging.Logger.SetLoggerLevel(Logger.Name, Settings.LogLevel);
                }
                catch (Exception e)
                {
                    Logger.LogError("Couldn't load settings", e);
                    Settings = new CustomComponentSettings();
                }
                Logger.LogError($"{Settings.TestEnableAllTags}");


                Settings.Complete();

                LogDebug(DType.ShowConfig, JSONSerializationUtility.ToJSON(Settings));


                var harmony = HarmonyInstance.Create("io.github.denadan.CustomComponents");
                harmony.PatchAll(Assembly.GetExecutingAssembly());

                Registry.RegisterSimpleCustomComponents(Assembly.GetExecutingAssembly());
                Validator.RegisterMechValidator(CategoryController.Shared.ValidateMech, CategoryController.Shared.ValidateMechCanBeFielded);

                Logger.Log("Loaded CustomComponents v0.9.7.1 for bt 1.5.1");

                Validator.RegisterMechValidator(TagRestrictionsHandler.Shared.ValidateMech, TagRestrictionsHandler.Shared.ValidateMechCanBeFielded);
                Validator.RegisterDropValidator(pre: TagRestrictionsHandler.Shared.ValidateDrop);

                if (Settings.RunAutofixer)
                {
                    if (Settings.FixDeletedComponents)
                    {
                        AutoFixer.Shared.RegisterMechFixer(AutoFixer.Shared.RemoveEmptyRefs);
                    }

                    if (Settings.FixSaveGameMech)
                    {
                        AutoFixer.Shared.RegisterSaveMechFixer(AutoFixer.Shared.ReAddFixed);
                        AutoFixer.Shared.RegisterSaveMechFixer(CategoryController.Shared.RemoveExcessDefaults);
                    }

                    if (Settings.FixDefaults)
                    {
                        AutoFixer.Shared.RegisterMechFixer(DefaultFixer.Shared.FixMechs);
                    }
                }
                Logger.LogDebug("done");
            }
            catch (Exception e)
            {
                Logger.LogError(e);
            }
        }
コード例 #11
0
        public static void Init(string directory, string settingsJSON)
        {
            Logger = HBS.Logging.Logger.GetLogger(ModName, LogLevel.Debug);

            try
            {
                try
                {
                    Settings = new CustomShopsSettings();
                    JSONSerializationUtility.FromJSON(Settings, settingsJSON);
                    HBS.Logging.Logger.SetLoggerLevel(Logger.Name, Settings.LogLevel);
                }
                catch (Exception)
                {
                    Settings = new CustomShopsSettings();
                }

                if (!Settings.AddLogPrefix)
                {
                    LogPrefix = "";
                }

                SetupLogging(directory);


                var harmony = HarmonyInstance.Create($"{ModName}");
                harmony.PatchAll(Assembly.GetExecutingAssembly());
                Logger.Log("=========================================================");
                Logger.Log($"Loaded {ModName} v0.3.1 for bt 1.9");
                Logger.Log("=========================================================");
                Logger.LogDebug("done");
                Logger.LogDebug(JSONSerializationUtility.ToJSON(Settings));

                State         = new GameState();
                RefreshEvents = new Dictionary <string, List <IShopDescriptor> >();


                RegisterRefreshEvent("Daily");
                RegisterRefreshEvent("SystemChange");
                RegisterRefreshEvent("MonthEnd");
                RegisterRefreshEvent("ContractComplete");
                RegisterRefreshEvent("OwnerChange");

                if (Settings.SystemShop)
                {
                    RegisterShop(new SystemShop(), new List <string>()
                    {
                        "systemchange", "monthend"
                    });
                }
                if (Settings.FactionShop)
                {
                    RegisterShop(new FactionShop(), new List <string>()
                    {
                        "systemchange", "monthend"
                    });
                }
                if (Settings.BlackMarketShop)
                {
                    RegisterShop(new BlackMarketShop(), new List <string>()
                    {
                        "systemchange", "monthend"
                    });
                }
                if (Settings.BuyBackShop)
                {
                    BuyBack = new BuyBackShop();
                    RegisterShop(BuyBack, new List <string>()
                    {
                        "systemchange"
                    });
                }
            }
            catch (Exception e)
            {
                Logger.LogError(e);
            }
        }
コード例 #12
0
 public override string ToJSON()
 {
     return(JSONSerializationUtility.ToJSON <DialogueActivator>(this));
 }
コード例 #13
0
 public override string GenerateJSONTemplate()
 {
     return(JSONSerializationUtility.ToJSON <DialogueActivator>(new DialogueActivator()));
 }
コード例 #14
0
 public override string ToJSON()
 {
     return(JSONSerializationUtility.ToJSON <SwapTeamFactionGameLogic>(this));
 }
コード例 #15
0
 public override string GenerateJSONTemplate()
 {
     return(JSONSerializationUtility.ToJSON <SwapTeamFactionGameLogic>(new SwapTeamFactionGameLogic()));
 }
コード例 #16
0
 public override string GenerateJSONTemplate()
 {
     return(JSONSerializationUtility.ToJSON <DisablePilotDeathGameLogic>(new DisablePilotDeathGameLogic()));
 }
コード例 #17
0
 public override string ToJSON()
 {
     return(JSONSerializationUtility.ToJSON <DisablePilotDeathGameLogic>(this));
 }
コード例 #18
0
 public override string ToJSON()
 {
     return(JSONSerializationUtility.ToJSON <CustomPlayerLanceSpawnerGameLogic>(this));
 }
コード例 #19
0
 public override string ToJSON()
 {
     return(JSONSerializationUtility.ToJSON <SetChunkStateAtRandomActivator>(this));
 }
コード例 #20
0
 public override string GenerateJSONTemplate()
 {
     return(JSONSerializationUtility.ToJSON <CustomPlayerLanceSpawnerGameLogic>(new CustomPlayerLanceSpawnerGameLogic()));
 }
コード例 #21
0
 public override string GenerateJSONTemplate()
 {
     return(JSONSerializationUtility.ToJSON(new SystemModDef()));
 }
コード例 #22
0
        public static void Init(string directory, string settingsJSON)
        {
            Logger = HBS.Logging.Logger.GetLogger("CustomSalvage", LogLevel.Debug);

            try
            {
                try
                {
                    Settings = new CustomSalvageSettings();
                    JSONSerializationUtility.FromJSON(Settings, settingsJSON);
                    HBS.Logging.Logger.SetLoggerLevel(Logger.Name, Settings.LogLevel);
                }
                catch (Exception)
                {
                    Settings = new CustomSalvageSettings();
                }

                Settings.Complete();
                SetupLogging(directory);

                var harmony = HarmonyInstance.Create("io.github.denadan.CustomSalvage");
                harmony.PatchAll(Assembly.GetExecutingAssembly());

#if USE_CC
                Logger.Log("Loaded CustomSalvageCC v0.4.2 for bt 1.8");
#else
                Logger.Log("Loaded CustomSalvageNonCC v0.4.2 for bt 1.8");
#endif

                switch (Settings.RecoveryType)
                {
                case RecoveryCalculationType.AlwaysRecover:
                    NeedRecovery = (result, contract) => true;
                    break;

                case RecoveryCalculationType.NeverRecover:
                    NeedRecovery = (result, contract) => false;
                    break;

                case RecoveryCalculationType.PartDestroyed:
                    NeedRecovery = RecoveryDelegates.PartDestroyed;
                    break;

                default:
                    NeedRecovery = RecoveryDelegates.VanilaRecovery;
                    break;
                }


                switch (Settings.LostMechAction)
                {
                case LostMechActionType.ReturnItemsAndPartsToPlayer:
                    LostUnitAction = LostUnitActions.ReturnItemsAndParts;
                    break;

                case LostMechActionType.MoveItemsToSalvage:
                    LostUnitAction = LostUnitActions.SalvageItems;
                    break;

                case LostMechActionType.MoveItemsAndPartsToSalvage:
                    LostUnitAction = LostUnitActions.SalvageItemsAndParts;
                    break;

                default:
                    LostUnitAction = LostUnitActions.ReturnItems;
                    break;
                }

                switch (Settings.PartCountType)
                {
                case PartCalculationType.VanilaAdjusted:
                    GetNumParts = PartsNumCalculations.VanilaAdjusted;
                    break;

                case PartCalculationType.PartDestroyed:
                    GetNumParts = PartsNumCalculations.PartDestroyed;
                    break;

                case PartCalculationType.PartDestroyedIgnoreCT:
                    GetNumParts = PartsNumCalculations.PartDestroyedNoCT;
                    break;

                default:
                    GetNumParts = PartsNumCalculations.Vanila;
                    break;
                }
#if USE_CC
                CustomComponents.Registry.RegisterSimpleCustomComponents(Assembly.GetExecutingAssembly());
#endif

                Logger.LogDebug("done");
                Logger.LogDebug(JSONSerializationUtility.ToJSON(Settings));
            }
            catch (Exception e)
            {
                Logger.LogError(e);
            }
        }