Please disclose if your mod was created primarily 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 ILoxYou v1.0.8
ILoxYou.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; 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 Microsoft.CodeAnalysis; using Splatform; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ILoxYou")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Azumatt")] [assembly: AssemblyProduct("ILoxYou")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("4358610B-F3F4-4843-B7AF-98B7BC60DCDE")] [assembly: AssemblyFileVersion("1.0.8")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.8.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace ILoxYou { [BepInPlugin("Azumatt.ILoxYou", "ILoxYou", "1.0.8")] public class ILoxYouPlugin : BaseUnityPlugin { internal const string ModName = "ILoxYou"; internal const string ModVersion = "1.0.8"; internal const string Author = "Azumatt"; private const string ModGUID = "Azumatt.ILoxYou"; private readonly Harmony _harmony = new Harmony("Azumatt.ILoxYou"); public static readonly ManualLogSource ILoxYouLogger = Logger.CreateLogSource("ILoxYou"); public static Sprite? LoxSprite = null; public const string Fab = "TrophyLox"; public void Awake() { Assembly executingAssembly = Assembly.GetExecutingAssembly(); _harmony.PatchAll(executingAssembly); } public static void LogIfDebug(string message) { } } [HarmonyPatch(typeof(ObjectDB), "Awake")] internal static class ObjectDBAwakePatch { private static void Postfix(ObjectDB __instance) { if (!((Object)(object)__instance.GetItemPrefab("TrophyLox") == (Object)null)) { ILoxYouPlugin.LoxSprite = __instance.GetItemPrefab("TrophyLox").GetComponent<ItemDrop>().m_itemData.m_shared.m_icons[0]; } } } [HarmonyPatch(typeof(Minimap), "UpdateEventPin")] public static class UpdateEventPinPatch { public static void Postfix(Minimap __instance) { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Invalid comparison between Unknown and I4 //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) Minimap __instance2 = __instance; if (((ZDOID)(ref PlayerStartDoodadControlPatch.LastHumanoidZDOID)).IsNone()) { return; } List<Character> source = (from hud in EnemyHud.instance.m_huds.Values where (Object)(object)hud.m_character != (Object)null && hud.m_character.IsTamed() && hud.m_character.GetZDOID() == PlayerStartDoodadControlPatch.LastHumanoidZDOID select hud.m_character).ToList(); foreach (Character item in from character in source where !(character is Player) let flag = __instance2.m_pins.Any((PinData pin) => pin.m_name.Equals($"$hud_tame {character.GetHoverName()} [Health: {character.GetHealth()}]")) where !flag select character) { PinData val = __instance2.AddPin(item.GetCenterPoint(), (PinType)8, $"$hud_tame {item.GetHoverName()} [Health: {item.GetHealth()}]", false, false, 0L, default(PlatformUserID)); if ((Object)(object)ILoxYouPlugin.LoxSprite != (Object)null) { val.m_icon = ILoxYouPlugin.LoxSprite; } Sadle val2 = null; EnemyHud.instance.UpdateHuds(Player.m_localPlayer, val2, Time.deltaTime); } List<PinData> list = new List<PinData>(); foreach (PinData pin2 in __instance2.m_pins) { if ((int)pin2.m_type != 8) { continue; } bool flag = false; using (IEnumerator<Character> enumerator = source.Where((Character character) => pin2.m_name.Equals($"$hud_tame {character.GetHoverName()} [Health: {character.GetHealth()}]")).GetEnumerator()) { if (enumerator.MoveNext()) { Character current2 = enumerator.Current; pin2.m_pos.x = current2.GetCenterPoint().x; pin2.m_pos.y = current2.GetCenterPoint().y; pin2.m_pos.z = current2.GetCenterPoint().z; flag = true; } } if (!flag && ((object)pin2.m_icon).Equals((object?)ILoxYouPlugin.LoxSprite)) { ILoxYouPlugin.ILoxYouLogger.LogDebug((object)("pin to remove: " + pin2.m_name + "::" + ((object)pin2.m_icon)?.ToString() + "::" + (object)pin2.m_iconElement)); list.Add(pin2); } } if (list.Count > 0) { ILoxYouPlugin.ILoxYouLogger.LogDebug((object)("number of pins to remove: " + list.Count)); } foreach (PinData item2 in list) { __instance2.RemovePin(item2); ILoxYouPlugin.ILoxYouLogger.LogDebug((object)("removing pin for " + item2.m_name)); } } } [HarmonyPatch(typeof(Player), "StartDoodadControl")] internal static class PlayerStartDoodadControlPatch { public static bool RidingLox; public static Humanoid RidingHumanoid; public static ZDOID LastHumanoidZDOID; private static void Postfix(Player __instance, IDoodadController shipControl) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) ILoxYouPlugin.LogIfDebug("PlayerIsRidingPatch: They are on " + Utils.GetPrefabName(((Object)__instance.m_doodadController.GetControlledComponent().gameObject).name)); if (Utils.GetPrefabName(((Object)shipControl.GetControlledComponent().gameObject).name) == "Lox") { RidingLox = true; RidingHumanoid = ((Component)shipControl.GetControlledComponent().transform).GetComponentInParent<Humanoid>(); LastHumanoidZDOID = ((Character)RidingHumanoid).GetZDOID(); ILoxYouPlugin.LogIfDebug($"Player is riding a Lox. Humanoid ZDOID: {LastHumanoidZDOID}"); } } } [HarmonyPatch(typeof(Player), "StopDoodadControl")] internal static class PlayerStopDoodadControlPatch { private static bool Prefix(Player __instance) { ILoxYouPlugin.LogIfDebug("PlayerStopDoodadControlPatch: Attempting to stop doodad control."); if (__instance.m_doodadController == null || !__instance.m_doodadController.IsValid()) { ILoxYouPlugin.LogIfDebug("PlayerStopDoodadControlPatch: Doodad controller is invalid or null."); PlayerStartDoodadControlPatch.RidingLox = false; PlayerStartDoodadControlPatch.RidingHumanoid = null; return true; } if (PlayerStartDoodadControlPatch.RidingLox) { return false; } ILoxYouPlugin.LogIfDebug("PlayerStopDoodadControlPatch: Player is not riding a Lox."); return true; } } [HarmonyPatch(typeof(Humanoid), "StartAttack")] internal static class HumanoidStartAttackPatch { private static bool Prefix(Humanoid __instance) { ILoxYouPlugin.LogIfDebug("HumanoidStartAttackPatch: Humanoid " + ((Character)__instance).GetHoverName() + " attempting to start attack."); if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return true; } ILoxYouPlugin.LogIfDebug($"HumanoidStartAttackPatch: Player is {((Character)Player.m_localPlayer).GetHoverName()} and riding Lox: {PlayerStartDoodadControlPatch.RidingLox}"); if (PlayerStartDoodadControlPatch.RidingLox) { return Player.m_localPlayer.m_doodadController == null; } return true; } } [HarmonyPatch(typeof(Player), "AttachStop")] internal static class PlayerAttachStopPatch { private static bool Prefix(Player __instance) { ILoxYouPlugin.LogIfDebug($"PlayerAttachStopPatch: Player is attempting to attach stop. Riding Lox: {PlayerStartDoodadControlPatch.RidingLox}"); return !PlayerStartDoodadControlPatch.RidingLox; } } [HarmonyPatch(typeof(Player), "UpdateDoodadControls")] internal static class PlayerUpdateDoodadControlsPatch { private static void Postfix(Player __instance) { if (__instance.m_doodadController == null || !__instance.m_doodadController.IsValid() || !PlayerStartDoodadControlPatch.RidingLox) { return; } Humanoid ridingHumanoid = PlayerStartDoodadControlPatch.RidingHumanoid; if (ridingHumanoid != null && ((Character)ridingHumanoid).GetHealth() <= 0f) { ILoxYouPlugin.LogIfDebug("PlayerUpdateDoodadControlsPatch: Mount is dead, stopping control."); __instance.CustomAttachStop(); return; } if (!ZInput.GetButton("Jump") && !ZInput.GetButtonDown("JoyJump")) { if ((ZInput.GetButtonDown("Use") || ZInput.GetButtonDown("JoyUse")) && !Hud.InRadial()) { GameObject hovering = __instance.m_hovering; if ((Object)(object)((hovering != null) ? hovering.GetComponent<Sadle>() : null) == (Object)null) { goto IL_009c; } } __instance.HandleInput(); return; } goto IL_009c; IL_009c: ILoxYouPlugin.LogIfDebug("PlayerUpdateDoodadControlsPatch: Jump button pressed, stopping control."); __instance.CustomAttachStop(); } } public static class PlayerExtensions { public static void CustomAttachStop(this Player p) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (p.m_sleeping || !p.m_attached) { return; } if ((Object)(object)p.m_attachPoint != (Object)null) { ((Component)p).transform.position = p.m_attachPoint.TransformPoint(p.m_detachOffset); } if (p.m_attachColliders != null) { Collider[] attachColliders = p.m_attachColliders; foreach (Collider val in attachColliders) { if (Object.op_Implicit((Object)(object)val)) { Physics.IgnoreCollision((Collider)(object)((Character)p).m_collider, val, false); } } p.m_attachColliders = null; } ((Character)p).m_body.useGravity = true; p.m_attached = false; p.m_attachPoint = null; p.m_attachPointCamera = null; ((Character)p).m_zanim.SetBool(p.m_attachAnimation, false); ((Character)p).m_nview.GetZDO().Set(ZDOVars.s_inBed, false); ((Character)p).ResetCloth(); PlayerStartDoodadControlPatch.RidingLox = false; p.StopDoodadControl(); PlayerStartDoodadControlPatch.RidingHumanoid = null; } public static void HandleInput(this Player player) { Player player2 = player; ProcessInput((KeyCode)323, 0, "JoyAttack"); ProcessInput((KeyCode)324, 1, "JoyBlock"); ProcessInput((KeyCode)325, 2, "JoySecondaryAttack"); void ProcessInput(KeyCode key, int weaponIndex, string controllerButton = "") { //IL_0009: Unknown result type (might be due to invalid IL or missing references) bool flag = false; flag = (ZInput.IsGamepadActive() ? ZInput.GetButtonDown(controllerButton) : Input.GetKeyDown(key)); if (Object.op_Implicit((Object)(object)PlayerStartDoodadControlPatch.RidingHumanoid) && flag && !Menu.IsVisible() && ((Character)player2).TakeInput() && !((Character)PlayerStartDoodadControlPatch.RidingHumanoid).InAttack()) { List<ItemData> list = (from i in PlayerStartDoodadControlPatch.RidingHumanoid.m_inventory.GetAllItems() where i.IsWeapon() select i).ToList(); if (list.Count > weaponIndex) { ItemData val = list[weaponIndex]; PlayerStartDoodadControlPatch.RidingHumanoid.EquipItem(val, true); float num = val.m_shared.m_attack.m_attackStamina; IDoodadController doodadController = player2.GetDoodadController(); Sadle val2 = (Sadle)(object)((doodadController is Sadle) ? doodadController : null); if (!((Object)(object)val2 == (Object)null)) { if (val.m_shared.m_attack.m_attackStamina <= 0f) { num = val2.GetMaxStamina() * 0.05f; } if (val2.HaveStamina(num)) { val2.UseStamina(num); ((Character)PlayerStartDoodadControlPatch.RidingHumanoid).StartAttack((Character)null, false); } } } } } } } }