using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("JCQuintas.Outward.OutwardWaterSkins")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JCQuintas.Outward.OutwardWaterSkins")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[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 JCQuintas.Outward.OutwardWaterSkins;
[BepInPlugin("JCQuintas.Outward.OutwardWaterSkins", "Outward Water Skins", "1.0.0")]
public class OutwardWaterSkinsPlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(UIUtilities), "GetWaterTypeIcon")]
public class UIUtilities_Patch
{
[HarmonyPrefix]
public static bool UIUtilities_GetWaterTypeIcon(WaterType _type, ref Sprite __result)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
__result = WaterIcons[_type].Sprite;
return false;
}
}
public const string GUID = "JCQuintas.Outward.OutwardWaterSkins";
public const string NAME = "Outward Water Skins";
public const string VERSION = "1.0.0";
public const string FOLDER = "JCQuintas-Outward_Water_Skins";
internal static ManualLogSource Log;
internal static Harmony _harmony;
internal static readonly Dictionary<WaterType, (Sprite Sprite, string Filename)> WaterIcons = new Dictionary<WaterType, (Sprite, string)>();
internal static readonly (WaterType WaterType, string ID, string Filename)[] WaterInfo = new(WaterType, string, string)[7]
{
((WaterType)0, "5600000", "WaterSkin_Clean.png"),
((WaterType)1, "5600001", "WaterSkin_River.png"),
((WaterType)2, "5600002", "WaterSkin_Salt.png"),
((WaterType)3, "5600003", "WaterSkin_Rancid.png"),
((WaterType)4, "5600004", "WaterSkin_Mana.png"),
((WaterType)5, "5600005", "WaterSkin_Pure.png"),
((WaterType)6, "5600006", "WaterSkin_Healing.png")
};
internal void Awake()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
Log = Logger.CreateLogSource("Outward Water Skins".Replace("Outward ", "").Replace(" ", ""));
Log.LogInfo((object)"Initializing Outward Water Skins v1.0.0");
LoadWaterIcons();
_harmony = new Harmony("JCQuintas.Outward.OutwardWaterSkins");
_harmony.PatchAll();
}
private static void LoadWaterIcons()
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
Log.LogInfo((object)"Loading water icons...");
(WaterType, string, string)[] waterInfo = WaterInfo;
for (int i = 0; i < waterInfo.Length; i++)
{
(WaterType, string, string) tuple = waterInfo[i];
string iconFilePath = GetIconFilePath(tuple.Item3);
if (iconFilePath == null)
{
Log.LogError((object)$"Icon path for water item {tuple.Item1} is null. Skipping icon load.");
break;
}
Texture2D val = new Texture2D(128, 84, (TextureFormat)12, false);
ImageConversion.LoadImage(val, File.ReadAllBytes(iconFilePath));
((Object)val).hideFlags = (HideFlags)0;
((Texture)val).anisoLevel = 1;
((Texture)val).filterMode = (FilterMode)1;
((Texture)val).wrapMode = (TextureWrapMode)0;
string name = (((Object)val).name = $"tex_men_iconItem_WaterSkin{tuple.Item1}_v_icn");
val.Apply();
Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, 84f, 128f), new Vector2(42f, 64f), 25f, 0u, (SpriteMeshType)0);
((Object)val2).name = name;
WaterIcons.Add(tuple.Item1, (val2, iconFilePath));
Log.LogInfo((object)$"Loaded texture for water item {tuple.Item1}");
}
}
private static string GetIconFilePath(string filename)
{
string path = Path.Combine(Paths.PluginPath, "JCQuintas-Outward_Water_Skins", "icons");
if (File.Exists(Path.Combine(path, filename)))
{
return Path.Combine(path, filename);
}
return null;
}
internal void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}