Decompiled source of RUS Better Vanilla Valheim v2.1.3

BepInEx/plugins/aopk-Battlestance/Battlestance.dll

Decompiled 5 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
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("战斗姿态")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("战斗姿态")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8067902b-4faf-47c8-a601-753d8d8527ce")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace 战斗姿态;

[BepInPlugin("AOPK.battlestance", "战斗姿态", "0.1.0")]
public class Main : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Player), "FixedUpdate")]
	private static class LookDir_patch
	{
		private static void Postfix(Player __instance, ZSyncAnimation ___m_zanim, bool ___m_walk, bool ___m_run)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			if (!Input.GetKey(flButton) && (AccessTools.Method(typeof(Humanoid), "GetRightItem", (Type[])null, (Type[])null).Invoke(__instance, null) != null || AccessTools.Method(typeof(Humanoid), "GetLeftItem", (Type[])null, (Type[])null).Invoke(__instance, null) != null) && !((Character)__instance).InDodge() && !((Character)__instance).IsStaggering() && !((Character)__instance).IsSitting() && !((Character)__instance).InEmote())
			{
				float num = (((Character)__instance).InAttack() ? attackFactor.Value : baseFactor.Value);
				Quaternion rotation = ((Component)__instance).transform.rotation;
				Quaternion lookYaw = ((Character)__instance).GetLookYaw();
				((Component)__instance).transform.rotation = Quaternion.Lerp(rotation, lookYaw, num);
			}
		}
	}

	internal const string GUID = "AOPK.battlestance";

	internal const string NAME = "战斗姿态";

	internal const string VERSION = "0.1.0";

	public Harmony harmony = new Harmony("AOPK.battlestance");

	public readonly string modFolder;

	private static ConfigEntry<float> baseFactor;

	private static ConfigEntry<float> attackFactor;

	private static ConfigEntry<string> freeLookButton;

	private static KeyCode flButton;

	public void Awake()
	{
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Expected O, but got Unknown
		baseFactor = ((BaseUnityPlugin)this).Config.Bind<float>("主要", "基本转弯速度", 0.15f, "不攻击时转动速度。 此处不建议低于 0.1,因为转弯太弱而无法抵消游戏的步行转弯。 1.0 = 完全控制。");
		attackFactor = ((BaseUnityPlugin)this).Config.Bind<float>("主要", "攻击转弯速度", 0.1f, "攻击时的转身速度");
		freeLookButton = ((BaseUnityPlugin)this).Config.Bind<string>("主要", "自由查看按钮", "LeftAlt", "按下时停止转动。 按钮名称供参考: https://docs.unity3d.com/ScriptReference/KeyCode.html");
		flButton = (KeyCode)Enum.Parse(typeof(KeyCode), freeLookButton.Value);
		harmony = new Harmony("AOPK.battlestance");
		harmony.PatchAll();
		Debug.Log((object)"加载战斗姿态...");
	}
}

BepInEx/plugins/cjayride-CustomLoadingScreens/CustomLoadingScreens.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.8.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyVersion("0.8.0.0")]
namespace CustomLoadingScreens;

[BepInPlugin("cjayride.CustomLoadingScreens", "Custom Loading Screens", "0.8.0")]
public class BepInExPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(FejdStartup), "LoadMainScene")]
	public static class LoadMainScene_Patch
	{
		public static void Prefix(FejdStartup __instance)
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			loadingSprite = GetRandomLoadingScreen();
			if (differentSpawnScreen.Value)
			{
				loadingSprite2 = GetRandomLoadingScreen();
			}
			if (loadingTips.Any())
			{
				loadingTip = loadingTips[Random.Range(0, loadingTips.Length)];
				if (differentSpawnTip.Value)
				{
					loadingTip2 = loadingTips[Random.Range(0, loadingTips.Length)];
				}
			}
			Image val = Object.Instantiate<Image>(((Component)__instance.m_loading.transform.Find("Bkg")).GetComponent<Image>(), __instance.m_loading.transform);
			if (!((Object)(object)val == (Object)null))
			{
				val.sprite = loadingSprite;
				((Graphic)val).color = loadingColorMask.Value;
				val.type = (Type)0;
				val.preserveAspect = true;
			}
		}
	}

	[HarmonyPriority(800)]
	[HarmonyPatch(typeof(ZNet), "RPC_ClientHandshake")]
	public static class ZNet_RPC_ClientHandshake_Patch
	{
		public static bool Prefix(ZNet __instance, ZRpc rpc, bool needPassword)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.IsServer())
			{
				Image val = Object.Instantiate<Image>(((Component)((Component)Hud.instance).transform.Find("LoadingBlack").Find("Bkg")).GetComponent<Image>(), ((Component)((Component)Hud.instance).transform.Find("LoadingBlack")).transform);
				if ((Object)(object)val == (Object)null)
				{
					return true;
				}
				val.sprite = loadingSprite;
				((Graphic)val).color = loadingColorMask.Value;
				val.type = (Type)0;
				val.preserveAspect = true;
				if (loadingTips.Any())
				{
					Object.Instantiate<Transform>(Hud.instance.m_loadingTip.transform.parent.Find("panel_separator"), ((Component)((Component)Hud.instance).transform.Find("LoadingBlack")).transform);
					TMP_Text component = Object.Instantiate<GameObject>(((Component)Hud.instance.m_loadingTip).gameObject, ((Component)((Component)Hud.instance).transform.Find("LoadingBlack")).transform).GetComponent<TMP_Text>();
					if ((Object)(object)component != (Object)null)
					{
						component.text = loadingTip;
						((Graphic)component).color = tipTextColor.Value;
					}
				}
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Hud), "UpdateBlackScreen")]
	public static class UpdateBlackScreen_Patch
	{
		public static void Prefix(Hud __instance, bool ___m_haveSetupLoadScreen, ref bool __state)
		{
			__state = !___m_haveSetupLoadScreen;
		}

		public static void Postfix(Hud __instance, bool ___m_haveSetupLoadScreen, ref bool __state)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if (__state && ___m_haveSetupLoadScreen)
			{
				__instance.m_loadingImage.sprite = (differentSpawnScreen.Value ? loadingSprite2 : loadingSprite);
				((Graphic)__instance.m_loadingImage).color = spawnColorMask.Value;
				if (loadingTips.Any())
				{
					__instance.m_loadingTip.text = (differentSpawnTip.Value ? loadingTip2 : loadingTip);
				}
				((Graphic)__instance.m_loadingTip).color = tipTextColor.Value;
				if (removeVignette.Value)
				{
					((Component)__instance.m_loadingProgress.transform.Find("TopFade")).gameObject.SetActive(false);
					((Component)__instance.m_loadingProgress.transform.Find("BottomFade")).gameObject.SetActive(false);
					((Component)__instance.m_loadingProgress.transform.Find("text_darken")).gameObject.SetActive(false);
				}
			}
		}
	}

	private static readonly bool isDebug = true;

	private static BepInExPlugin context;

	public static ConfigEntry<bool> modEnabled;

	public static ConfigEntry<string> loadingText;

	public static ConfigEntry<bool> differentSpawnScreen;

	public static ConfigEntry<bool> differentSpawnTip;

	public static ConfigEntry<bool> showTipsOnLoadingScreen;

	public static ConfigEntry<bool> removeVignette;

	public static ConfigEntry<Color> spawnColorMask;

	public static ConfigEntry<Color> loadingColorMask;

	public static ConfigEntry<Color> loadingTextColor;

	public static ConfigEntry<Color> tipTextColor;

	public static List<string> loadingScreens = new List<string>();

	public static Dictionary<string, string> loadingScreens2 = new Dictionary<string, string>();

	public static Dictionary<string, DateTime> fileWriteTimes = new Dictionary<string, DateTime>();

	public static List<string> screensToLoad = new List<string>();

	public static string[] loadingTips = new string[0];

	public static Dictionary<string, Texture2D> cachedScreens = new Dictionary<string, Texture2D>();

	private static Sprite loadingSprite;

	private static Sprite loadingSprite2;

	private static string loadingTip;

	private static string loadingTip2;

	public static ConfigEntry<string> imagePath;

	public static ConfigEntry<string> tipsPath;

	private void Awake()
	{
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		context = this;
		modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable this mod");
		differentSpawnScreen = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DifferentSpawnScreen", true, "Use a different screen for the spawn part");
		differentSpawnTip = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DifferentSpawnTip", true, "Use a different tip for the spawn part");
		spawnColorMask = ((BaseUnityPlugin)this).Config.Bind<Color>("General", "SpawnColorMask", new Color(0.532f, 0.588f, 0.853f, 1f), "Change the color mask of the spawn screen (set last number to 0 to disable)");
		loadingColorMask = ((BaseUnityPlugin)this).Config.Bind<Color>("General", "LoadingColorMask", Color.white, "Change the color mask of the initial loading screen (set to white to disable)");
		removeVignette = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RemoveMask", true, "Remove dark edges for the spawn part");
		loadingText = ((BaseUnityPlugin)this).Config.Bind<string>("General", "LoadingText", "Loading...", "Custom Loading... text");
		loadingTextColor = ((BaseUnityPlugin)this).Config.Bind<Color>("General", "LoadingTextColor", new Color(1f, 0.641f, 0f, 1f), "Custom Loading... text color");
		tipTextColor = ((BaseUnityPlugin)this).Config.Bind<Color>("General", "TipTextColor", Color.white, "Custom tip text color");
		imagePath = ((BaseUnityPlugin)this).Config.Bind<string>("General", "PathToImagesFolder", "plugins\\cjayride-CustomLoadingScreens\\CustomLoadingScreens", "Path to image files. Example: config\\CustomLoadingScreens or plugins\\cjayride-CustomLoadingScreens\\CustomLoadingScreens");
		tipsPath = ((BaseUnityPlugin)this).Config.Bind<string>("General", "PathToTipsFolder", "plugins\\cjayride-CustomLoadingScreens\\CustomLoadingScreens", "Path to tips file. Example: config\\CustomLoadingScreens or plugins\\cjayride-CustomLoadingScreens\\CustomLoadingScreens");
		if (modEnabled.Value)
		{
			LoadCustomLoadingScreens();
			LoadTips();
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}
	}

	private void LoadTips()
	{
		string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		string directoryName2 = Path.GetDirectoryName(directoryName);
		string directoryName3 = Path.GetDirectoryName(directoryName2);
		string path = Path.Combine(directoryName3, tipsPath.Value, "tips.txt");
		if (!File.Exists(path))
		{
			File.Create(path);
		}
		else
		{
			loadingTips = File.ReadAllLines(path);
		}
	}

	private static void LoadCustomLoadingScreens()
	{
		loadingScreens.Clear();
		string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		string directoryName2 = Path.GetDirectoryName(directoryName);
		string directoryName3 = Path.GetDirectoryName(directoryName2);
		string path = Path.Combine(directoryName3, imagePath.Value);
		if (!Directory.Exists(path))
		{
			Directory.CreateDirectory(path);
			return;
		}
		string[] files = Directory.GetFiles(path, "*.png", SearchOption.AllDirectories);
		foreach (string item in files)
		{
			loadingScreens.Add(item);
		}
	}

	private static Sprite GetRandomLoadingScreen()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Expected O, but got Unknown
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		if (!loadingScreens.Any())
		{
			return null;
		}
		Texture2D val = new Texture2D(2, 2);
		byte[] array = File.ReadAllBytes(loadingScreens[Random.Range(0, loadingScreens.Count)]);
		ImageConversion.LoadImage(val, array);
		return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero, 1f);
	}
}