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 EmeraudeMontures v1.0.0
plugins/EmeraudeMontures.dll
Decompiled a day agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("EmeraudeMontures")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EmeraudeMontures")] [assembly: AssemblyTitle("EmeraudeMontures")] [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 EmeraudeMontures { [HarmonyPatch(typeof(GameCamera), "GetOffsetedEyePos")] internal static class EyePosPatch { private static void Postfix(ref Vector3 __result) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (Riding.TryGetMount(localPlayer, out var mount)) { __result += Riding.Seat(localPlayer, mount) - ((Component)localPlayer).transform.position; } } } [HarmonyPatch(typeof(GameCamera), "ApplyCameraTilt")] internal static class CameraTiltPatch { private static bool Prefix(Player player, ref Quaternion rot, ref Vector3 ___m_smoothedCameraUp) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!Riding.TryGetMount(player, out var _)) { return true; } ___m_smoothedCameraUp = Vector3.up; rot = Quaternion.LookRotation(((Character)player).m_eye.forward, Vector3.up); return false; } } internal static class Riding { private static Character s_mount; private static Vector3 s_seat; private static Vector3 s_seatVelocity; internal static bool TryGetMount(Player player, out Character mount) { object obj; if ((Object)(object)player != (Object)null && ((Character)player).IsAttached()) { IDoodadController doodadController = player.GetDoodadController(); Sadle val = (Sadle)(object)((doodadController is Sadle) ? doodadController : null); if (val != null) { obj = val.GetCharacter(); goto IL_002a; } } obj = null; goto IL_002a; IL_002a: mount = (Character)obj; return (Object)(object)mount != (Object)null; } internal static Vector3 Seat(Player player, Character mount) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)mount).transform.InverseTransformPoint(((Component)player).transform.position); if ((Object)(object)mount != (Object)(object)s_mount) { s_mount = mount; s_seat = val; s_seatVelocity = Vector3.zero; } s_seat = Vector3.SmoothDamp(s_seat, val, ref s_seatVelocity, Plugin.CameraSmoothing.Value, 999f, Time.deltaTime); return ((Component)mount).transform.TransformPoint(s_seat); } } [HarmonyPatch(typeof(Sadle), "FixedUpdate")] internal static class SadleFixedUpdatePatch { private static void Postfix(Character ___m_character, ZNetView ___m_nview) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && ___m_nview.IsValid() && ___m_nview.IsOwner()) { long num = ___m_nview.GetZDO().GetLong(ZDOVars.s_user, 0L); ZDOID zDOID = ((Character)localPlayer).GetZDOID(); if (num == ((ZDOID)(ref zDOID)).UserID && Health.IsMount(___m_character)) { Health.MatchRider(___m_character, localPlayer); } } } } [HarmonyPatch(typeof(Character), "SetupMaxHealth")] internal static class SetupMaxHealthPatch { private static void Postfix(Character __instance) { if (Health.IsMount(__instance)) { float num = ((Component)__instance).GetComponent<ZNetView>().GetZDO().GetFloat(Health.MaxHealthKey, 0f); if (num > __instance.GetMaxHealth()) { __instance.SetMaxHealth(num); } } } } internal static class Health { internal static readonly int MaxHealthKey = StringExtensionMethods.GetStableHashCode("emeraude_mount_maxhealth"); internal static bool IsMount(Character character) { if ((Object)(object)character != (Object)null && character.IsTamed()) { return Mounts.IsRideable(((Component)character).gameObject); } return false; } internal static void MatchRider(Character mount, Player rider) { float num = Mathf.Max(mount.GetMaxHealthBase() * (float)mount.GetLevel(), ((Character)rider).GetMaxHealth()); float maxHealth = mount.GetMaxHealth(); if (!(Mathf.Abs(maxHealth - num) < 1f)) { float num2 = mount.GetHealth() / maxHealth; mount.SetMaxHealth(num); mount.SetHealth(num * num2); ((Component)mount).GetComponent<ZNetView>().GetZDO().Set(MaxHealthKey, num); } } } [HarmonyPatch(typeof(Tameable), "UseItem")] internal static class UseSaddlePatch { private static bool Prefix(Tameable __instance, Humanoid user, ItemData item, ref bool __result) { ItemDrop saddleItem = __instance.m_saddleItem; if ((Object)(object)saddleItem == (Object)null || item.m_shared.m_name != saddleItem.m_itemData.m_shared.m_name) { return true; } if (Mounts.IsRideable(((Component)__instance).gameObject)) { return true; } ((Character)user).Message((MessageType)2, "Seuls le loup et le sanglier peuvent être montés", 0, (Sprite)null, false); __result = true; return false; } } [HarmonyPatch(typeof(Sadle), "Interact")] internal static class RidePatch { private static bool Prefix(Sadle __instance, Humanoid character, bool repeat, bool alt, ref bool __result) { if (repeat || alt || Mounts.IsRideable(((Component)__instance.GetCharacter()).gameObject)) { return true; } ((Character)character).Message((MessageType)2, "Seuls le loup et le sanglier peuvent être montés", 0, (Sprite)null, false); __result = false; return false; } } internal static class Mounts { internal const string Refused = "Seuls le loup et le sanglier peuvent être montés"; internal static bool IsRideable(GameObject creature) { string prefabName = Utils.GetPrefabName(creature); if (!(prefabName == "Wolf")) { return prefabName == "Boar"; } return true; } } [BepInPlugin("emeraude.montures", "Emeraude Montures", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "emeraude.montures"; public const string Name = "Emeraude Montures"; public const string Version = "1.0.0"; internal static ConfigEntry<float> CameraSmoothing; private void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) CameraSmoothing = ((BaseUnityPlugin)this).Config.Bind<float>("Camera", "CameraSmoothing", 1f, new ConfigDescription("While riding, how long the camera takes to follow the rider's bobbing on the mount, in seconds. Higher is steadier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())); new Harmony("emeraude.montures").PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Emeraude Montures 1.0.0 loaded"); } } }