Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SimpleCombatSettings v1.0.0
SimpleCombatSettings.dll
Decompiled 2 days agousing System; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("SimpleCombatSettings")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SimpleCombatSettings")] [assembly: AssemblyTitle("SimpleCombatSettings")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SimpleCombatSettings { [BepInPlugin("Iteravio.SimpleCombatSettings", "SimpleCombatSettings", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [SynchronizationMode(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "Iteravio.SimpleCombatSettings"; public const string PluginName = "SimpleCombatSettings"; public const string PluginVersion = "1.0.0"; private const string Section = "Combat Settings"; private const int MinPercent = 25; private const int MaxPercent = 300; private const int PercentStep = 5; internal static ManualLogSource Log; internal static CombatSetting[] Settings; private static string lastLoggedSummary; private void Awake() { //IL_0177: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Settings = new CombatSetting[4] { Bind("Player damage", "PlayerDamage", 8, "Damage creatures take, from any source. Vanilla: 100% on Normal (Very Easy 125%, Easy 110%, Hard 85%, Very Hard 70%).", () => Game.m_playerDamageRate, delegate(float v) { Game.m_playerDamageRate = v; }), Bind("Enemy damage", "EnemyDamage", 6, "Damage creatures deal, to players and tames alike. Vanilla: 100% on Normal (Very Easy 50%, Easy 75%, Hard 150%, Very Hard 200%).", () => Game.m_enemyDamageRate, delegate(float v) { Game.m_enemyDamageRate = v; }), Bind("Enemy speed and size", "EnemySpeedAndSize", 4, "Creature speed and size outside dungeons. Size changes on creatures loaded after the change. Vanilla: 100% on Normal (Very Easy 90%, Easy 90%, Hard 110%, Very Hard 120%).", () => Game.m_enemySpeedSize, delegate(float v) { Game.m_enemySpeedSize = v; }), Bind("Enemy level up rate", "EnemyLevelUpRate", 2, "Chance for creatures to spawn with stars. Vanilla: 100% on Normal (Hard 120%, Very Hard 140%).", () => Game.m_enemyLevelUpRate, delegate(float v) { Game.m_enemyLevelUpRate = v; }) }; new Harmony("Iteravio.SimpleCombatSettings").PatchAll(); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new StatusCommand()); } private CombatSetting Bind(string label, string key, int order, string percentDescription, Func<float> get, Action<float> set) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("Combat Settings", "Override" + key, false, new ConfigDescription("Use Percent" + key + " instead of the world's Combat setting. [Synced with Server]", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = order } })); ConfigEntry<int> percentEntry = ((BaseUnityPlugin)this).Config.Bind<int>("Combat Settings", "Percent" + key, 100, new ConfigDescription(percentDescription + " [Synced with Server]", (AcceptableValueBase)(object)new AcceptableValueRange<int>(25, 300), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = order - 1 } })); SnapToStep(percentEntry); percentEntry.SettingChanged += delegate { if (!SnapToStep(percentEntry)) { ApplyAll(); } }; val.SettingChanged += delegate { ApplyAll(); }; return new CombatSetting(label, val, percentEntry, get, set); } private static bool SnapToStep(ConfigEntry<int> entry) { int num = Mathf.Clamp(Mathf.RoundToInt((float)entry.Value / 5f) * 5, 25, 300); if (num == entry.Value) { return false; } entry.Value = num; return true; } internal static void ApplyAll() { if (Settings != null) { CombatSetting[] settings = Settings; for (int i = 0; i < settings.Length; i++) { settings[i].Apply(); } string text = string.Join(", ", Settings.Select((CombatSetting s) => s.Describe()).ToArray()); if (!(text == lastLoggedSummary)) { lastLoggedSummary = text; Log.LogInfo((object)("In effect: " + text)); } } } internal static string GetSettingsSource() { ZNet instance = ZNet.instance; if ((Object)(object)instance == (Object)null) { return "local config"; } if (!instance.IsServer()) { return "synced from host"; } return "this machine (host/solo)"; } } internal class CombatSetting { private readonly string label; private readonly ConfigEntry<bool> overrideEntry; private readonly ConfigEntry<int> percentEntry; private readonly Func<float> get; private readonly Action<float> set; private float worldRate = 1f; public CombatSetting(string label, ConfigEntry<bool> overrideEntry, ConfigEntry<int> percentEntry, Func<float> get, Action<float> set) { this.label = label; this.overrideEntry = overrideEntry; this.percentEntry = percentEntry; this.get = get; this.set = set; } public void CaptureWorldRate() { worldRate = get(); } public void Apply() { set(overrideEntry.Value ? ((float)percentEntry.Value / 100f) : worldRate); } public string Describe() { string text = Mathf.RoundToInt(worldRate * 100f) + "%"; if (!overrideEntry.Value) { return label + " " + text + " (world)"; } return $"{label} {percentEntry.Value}% (override, world {text})"; } } [HarmonyPatch(typeof(Game), "UpdateWorldRates")] internal static class UpdateWorldRatesPatch { private static void Postfix() { CombatSetting[] settings = Plugin.Settings; for (int i = 0; i < settings.Length; i++) { settings[i].CaptureWorldRate(); } Plugin.ApplyAll(); } } internal static class RagdollScale { [HarmonyPatch(typeof(Character), "OnDeath")] private static class OnDeathPatch { private static void Prefix(Character __instance) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) dyingScale = 1f; if (!__instance.IsPlayer() && !((Object)(object)ZNetScene.instance == (Object)null)) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); GameObject val = ((Object.op_Implicit((Object)(object)component) && component.IsValid()) ? ZNetScene.instance.GetPrefab(component.GetZDO().GetPrefab()) : null); if (!((Object)(object)val == (Object)null) && val.transform.localScale.x != 0f) { dyingScale = ((Component)__instance).transform.localScale.x / val.transform.localScale.x; } } } private static void Finalizer() { dyingScale = 1f; } } [HarmonyPatch(typeof(Ragdoll), "Setup")] private static class SetupPatch { private static void Postfix(Ragdoll __instance) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (!Mathf.Approximately(dyingScale, 1f)) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { component.GetZDO().Set(ScaleKey, dyingScale); Transform transform = ((Component)__instance).transform; transform.localScale *= dyingScale; } } } } [HarmonyPatch(typeof(Ragdoll), "Awake")] private static class AwakePatch { private static void Postfix(Ragdoll __instance) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { float num = component.GetZDO().GetFloat(ScaleKey, 1f); if (!Mathf.Approximately(num, 1f)) { Transform transform = ((Component)__instance).transform; transform.localScale *= num; } } } } private static readonly int ScaleKey = StringExtensionMethods.GetStableHashCode("Iteravio.SimpleCombatSettings.RagdollScale"); private static float dyingScale = 1f; } internal class StatusCommand : ConsoleCommand { public override string Name => "simplecombatsettings"; public override string Help => "Show the combat rates SimpleCombatSettings has in effect"; public override void Run(string[] args, Terminal context) { if (!((Object)(object)context == (Object)null)) { context.AddString("SimpleCombatSettings 1.0.0, settings from " + Plugin.GetSettingsSource() + ":"); CombatSetting[] settings = Plugin.Settings; foreach (CombatSetting combatSetting in settings) { context.AddString(" " + combatSetting.Describe()); } } } } }