Decompiled source of KushNoFishingXPPenalty v1.0.0

plugins/KushNoFishingXPPenalty.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("KushNoFishingXPPenalty")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("KushNoFishingXPPenalty")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f3169265-81f4-463b-9c57-0757cbeb172f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace KushNoFishingXPPenalty;

[BepInPlugin("KushNoFishingXPPenalty", "kushzei", "1.0.0")]
public class KushNoFishingXPPenalty : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Skills), "LowerAllSkills")]
	public static class SkillsLowerAllSkills
	{
		public static bool Prefix(ref float factor, Skills __instance)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			foreach (KeyValuePair<SkillType, Skill> item in __instance.getField<Dictionary<SkillType, Skill>>("m_skillData"))
			{
				if ((int)item.Key != 104)
				{
					float num = item.Value.m_level * factor;
					Skill value = item.Value;
					value.m_level -= num;
					item.Value.m_accumulator = 0f;
				}
			}
			((Character)__instance.getField<Player>("m_player")).Message((MessageType)1, "$msg_skills_lowered", 0, (Sprite)null);
			return false;
		}
	}

	public const string creator = "kushzei";

	public const string version = "1.0.0";

	public const string guid = "KushNoFishingXPPenalty";

	private Harmony _hi = null;

	private static KushNoFishingXPPenalty inst;

	public ConfigEntry<string> PrefabsToMakeIntoCraftingStation { get; set; }

	public static KushNoFishingXPPenalty Get()
	{
		return inst;
	}

	private KushNoFishingXPPenalty()
	{
		Debug.Log((object)"KushNoFishingXPPenalty() KushNoFishingXPPenalty");
		inst = this;
	}

	public void Start()
	{
		Debug.Log((object)"Starting mod KushNoFishingXPPenalty");
	}

	private void Awake()
	{
		Debug.Log((object)"Loading mod KushNoFishingXPPenalty");
		_hi = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
	}

	private void OnDestroy()
	{
		if (_hi != null)
		{
			_hi.UnpatchSelf();
		}
	}
}
public static class Util
{
	public static T getField<T>(this object obj, string field, bool isStatic = false)
	{
		BindingFlags bindingAttr = ((!isStatic) ? (BindingFlags.Instance | BindingFlags.NonPublic) : (BindingFlags.Static | BindingFlags.NonPublic));
		try
		{
			return (T)obj.GetType().GetField(field, bindingAttr).GetValue(obj);
		}
		catch (Exception ex)
		{
			Debug.Log((object)("Error13: " + ex?.ToString() + " obj " + ((obj == null) ? "null" : obj.GetType().Name) + " method " + field));
		}
		return default(T);
	}
}