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 MountTweaks v1.0.1
plugins/MountTweaks.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; 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("MountTweaks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("MountTweaks")] [assembly: AssemblyTitle("MountTweaks")] [assembly: AssemblyVersion("1.0.1.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 MountTweaks { public class LoxPack : MonoBehaviour { private static readonly Color Leather = new Color(0.58f, 0.38f, 0.2f); private static readonly Color Strap = new Color(0.18f, 0.11f, 0.06f); private static readonly Color Buckle = new Color(0.78f, 0.8f, 0.84f); private ZNetView m_nview; private Character m_character; private Container m_container; private readonly List<Collider> m_colliders = new List<Collider>(); private readonly List<Renderer> m_renderers = new List<Renderer>(); private bool m_shown = true; private static readonly MethodInfo s_dropAll = AccessTools.Method(typeof(Container), "DropAllItems", Type.EmptyTypes, (Type[])null); public bool IsAvailable { get { if (m_shown) { return Object.op_Implicit((Object)(object)m_container); } return false; } } internal static void Attach(Tameable tameable) { ZNetView component = ((Component)tameable).GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)component) && component.GetZDO() != null && !Object.op_Implicit((Object)(object)((Component)tameable).GetComponent<LoxPack>())) { ((Component)tameable).gameObject.AddComponent<LoxPack>().Build(component); } } private void Build(ZNetView nview) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Expected O, but got Unknown //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) m_nview = nview; m_character = ((Component)this).GetComponent<Character>(); Transform val = null; Transform val2 = null; Transform val3 = null; Material fallback = null; Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); foreach (Transform val4 in componentsInChildren) { if (((Object)val4).name == "Hip") { val = val4; } else if (((Object)val4).name == "Spine2") { val2 = val4; } else if (((Object)val4).name == "attachpoint") { val3 = val4; } } SkinnedMeshRenderer componentInChildren = ((Component)this).GetComponentInChildren<SkinnedMeshRenderer>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { fallback = ((Renderer)componentInChildren).sharedMaterial; } Transform transform = ((Component)this).transform; float num = ((Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2)) ? Mathf.Max(0.5f, Vector3.Distance(val.position, val2.position)) : 1.5f); Vector3 val5 = (Object.op_Implicit((Object)(object)val3) ? val3.position : (transform.position + transform.up * 2.5f)); GameObject val6 = new GameObject("MountTweaks_Pack"); val6.SetActive(false); val6.layer = ((Component)this).gameObject.layer; val6.transform.SetParent(transform, false); val6.transform.position = val5 - transform.forward * 0.5f - transform.up * 0.7f; val6.transform.rotation = transform.rotation; float num2 = 0.38f * num + 0.3f; float[] array = new float[2] { -1f, 1f }; foreach (float num3 in array) { GameObject val7 = new GameObject("Saddlebag"); val7.layer = val6.layer; val7.transform.SetParent(val6.transform, false); val7.transform.localPosition = new Vector3(num3 * num2, 0f, 0f); BoxCollider val8 = val7.AddComponent<BoxCollider>(); val8.size = new Vector3(0.5f, 0.7f, 0.9f); m_colliders.Add((Collider)(object)val8); Visual(val7.transform, Vector3.zero, new Vector3(0.5f, 0.7f, 0.9f), Leather, fallback); Visual(val7.transform, new Vector3(0f, 0.38f, 0f), new Vector3(0.54f, 0.08f, 0.94f), Strap, fallback); float[] array2 = new float[2] { -0.25f, 0.25f }; foreach (float num4 in array2) { Visual(val7.transform, new Vector3(0f, 0f, num4), new Vector3(0.53f, 0.72f, 0.07f), Strap, fallback); Visual(val7.transform, new Vector3(num3 * 0.27f, 0.1f, num4), new Vector3(0.03f, 0.08f, 0.08f), Buckle, fallback); } } m_container = val6.AddComponent<Container>(); m_container.m_name = Plugin.PackName.Value; m_container.m_width = Plugin.PackWidth.Value; m_container.m_height = Plugin.PackHeight.Value; m_container.m_privacy = (PrivacySetting)2; m_container.m_rootObjectOverride = nview; GameObject val9 = (Object.op_Implicit((Object)(object)ZNetScene.instance) ? ZNetScene.instance.GetPrefab("Cart") : null); Container val10 = (Object.op_Implicit((Object)(object)val9) ? val9.GetComponentInChildren<Container>(true) : null); if (Object.op_Implicit((Object)(object)val10)) { m_container.m_bkg = val10.m_bkg; m_container.m_openEffects = val10.m_openEffects; m_container.m_closeEffects = val10.m_closeEffects; } val6.SetActive(true); if (Object.op_Implicit((Object)(object)m_character)) { Character character = m_character; character.m_onDeath = (Action)Delegate.Combine(character.m_onDeath, new Action(DropContents)); } ((MonoBehaviour)this).InvokeRepeating("UpdateVisibility", 0f, 1f); } private void Visual(Transform parent, Vector3 localPos, Vector3 size, Color color, Material fallback) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>()); obj.layer = ((Component)parent).gameObject.layer; obj.transform.SetParent(parent, false); obj.transform.localPosition = localPos; obj.transform.localScale = size; Renderer component = obj.GetComponent<Renderer>(); component.sharedMaterial = RobotSkin.MakeMaterial(color, glow: false, fallback); m_renderers.Add(component); } private void UpdateVisibility() { bool flag = Plugin.PackEnabled.Value && Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid() && Object.op_Implicit((Object)(object)m_character) && m_character.IsTamed() && m_nview.GetZDO().GetBool(ZDOVars.s_haveSaddleHash, false); if (flag == m_shown) { return; } m_shown = flag; foreach (Collider collider in m_colliders) { if (Object.op_Implicit((Object)(object)collider)) { collider.enabled = flag; } } foreach (Renderer renderer in m_renderers) { if (Object.op_Implicit((Object)(object)renderer)) { renderer.enabled = flag; } } } public void Open(Player player) { m_container.Interact((Humanoid)(object)player, false, false); } private void DropContents() { if (Object.op_Implicit((Object)(object)m_container) && Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid() && m_nview.IsOwner()) { Inventory inventory = m_container.GetInventory(); if (inventory != null && inventory.NrOfItems() > 0) { s_dropAll?.Invoke(m_container, null); } } } } [BepInPlugin("nicodiansk.MountTweaks", "MountTweaks", "1.0.1")] public class Plugin : BaseUnityPlugin { public const string Guid = "nicodiansk.MountTweaks"; public const string Name = "MountTweaks"; public const string Version = "1.0.1"; internal static ConfigEntry<float> MaxStamina; internal static ConfigEntry<float> StaminaRegen; internal static ConfigEntry<float> RunStaminaDrain; internal static ConfigEntry<float> SwimStaminaDrain; internal static ConfigEntry<float> WalkSpeed; internal static ConfigEntry<float> RunSpeed; internal static ManualLogSource Log; internal static ConfigEntry<float> RobotSpeed; internal static ConfigEntry<KeyboardShortcut> TransformKey; internal static ConfigEntry<KeyboardShortcut> SpawnKey; internal static ConfigEntry<bool> SpawnAsRobot; internal static ConfigEntry<bool> EasyMountEnabled; internal static ConfigEntry<bool> PackEnabled; internal static ConfigEntry<int> PackWidth; internal static ConfigEntry<int> PackHeight; internal static ConfigEntry<string> PackName; internal static ConfigEntry<KeyboardShortcut> OpenPackKey; private void Awake() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Expected O, but got Unknown //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Expected O, but got Unknown //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) AcceptableValueRange<float> val = new AcceptableValueRange<float>(0f, 10f); MaxStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "MaxStaminaMultiplier", 2f, new ConfigDescription("Multiplier for the mount's max stamina.", (AcceptableValueBase)(object)val, Array.Empty<object>())); StaminaRegen = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "RegenMultiplier", 1.5f, new ConfigDescription("Multiplier for the mount's stamina regeneration (fed and hungry).", (AcceptableValueBase)(object)val, Array.Empty<object>())); RunStaminaDrain = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "RunDrainMultiplier", 0.5f, new ConfigDescription("Multiplier for stamina used while running. 0 = infinite sprint.", (AcceptableValueBase)(object)val, Array.Empty<object>())); SwimStaminaDrain = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "SwimDrainMultiplier", 0.5f, new ConfigDescription("Multiplier for stamina used while swimming. 0 = never drowns.", (AcceptableValueBase)(object)val, Array.Empty<object>())); WalkSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Speed", "WalkSpeedMultiplier", 1.25f, new ConfigDescription("Multiplier for walk/trot speed while ridden.", (AcceptableValueBase)(object)val, Array.Empty<object>())); RunSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Speed", "RunSpeedMultiplier", 1.5f, new ConfigDescription("Multiplier for run speed while ridden.", (AcceptableValueBase)(object)val, Array.Empty<object>())); RobotSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Extras", "BonusSpeedMultiplier", 1.2f, new ConfigDescription("Extra speed multiplier for a Lox in its special form.", (AcceptableValueBase)(object)val, Array.Empty<object>())); TransformKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Extras", "SpecialKey", new KeyboardShortcut((KeyCode)290, Array.Empty<KeyCode>()), "Toggles the special form of the Lox you ride, or the nearest tamed Lox."); SpawnKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Extras", "SpawnKey", new KeyboardShortcut((KeyCode)290, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), "Spawn a tamed, saddled Lox in front of you. Only works for the host/single player or server admins."); SpawnAsRobot = ((BaseUnityPlugin)this).Config.Bind<bool>("Extras", "SpawnSpecial", false, "Spawned Lox start in their special form."); EasyMountEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EasyMount", true, "E anywhere on a saddled mount rides it, instead of petting it. Shift+E still renames."); PackEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Saddlebags", "Enabled", true, "Tamed, saddled Lox carry saddlebags with a cart-like inventory."); PackWidth = ((BaseUnityPlugin)this).Config.Bind<int>("Saddlebags", "Width", 6, new ConfigDescription("Inventory columns (cart is 6).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>())); PackHeight = ((BaseUnityPlugin)this).Config.Bind<int>("Saddlebags", "Height", 3, new ConfigDescription("Inventory rows (cart is 3).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 6), Array.Empty<object>())); PackName = ((BaseUnityPlugin)this).Config.Bind<string>("Saddlebags", "Name", "Saddlebags", "Name shown on hover and in the inventory panel."); OpenPackKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Saddlebags", "OpenKey", new KeyboardShortcut((KeyCode)103, Array.Empty<KeyCode>()), "Open the saddlebags of the Lox you ride, or the nearest one. E on the bags works too."); Log = ((BaseUnityPlugin)this).Logger; new Harmony("nicodiansk.MountTweaks").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"MountTweaks 1.0.1 loaded"); } private void Update() { //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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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) Player localPlayer = Player.m_localPlayer; if (!Object.op_Implicit((Object)(object)localPlayer) || ((Character)localPlayer).IsDead() || IsTyping()) { return; } KeyboardShortcut value = SpawnKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { SpawnLox(localPlayer); return; } value = TransformKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { RobotSkin robotSkin = FindTargetLox(localPlayer); if (Object.op_Implicit((Object)(object)robotSkin)) { robotSkin.Toggle(); } else { ((Character)localPlayer).Message((MessageType)2, "No tamed Lox nearby", 0, (Sprite)null, false); } return; } value = OpenPackKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { RobotSkin robotSkin2 = FindTargetLox(localPlayer); LoxPack loxPack = (Object.op_Implicit((Object)(object)robotSkin2) ? ((Component)robotSkin2).GetComponent<LoxPack>() : null); if (Object.op_Implicit((Object)(object)loxPack) && loxPack.IsAvailable) { loxPack.Open(localPlayer); } else { ((Character)localPlayer).Message((MessageType)2, "No saddled Lox nearby", 0, (Sprite)null, false); } } } private static bool IsTyping() { if ((!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus()) && !Console.IsVisible() && !TextInput.IsVisible() && !Menu.IsVisible()) { return InventoryGui.IsVisible(); } return true; } private static RobotSkin FindTargetLox(Player player) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) IDoodadController doodadController = player.GetDoodadController(); Sadle val = (Sadle)(object)((doodadController is Sadle) ? doodadController : null); if (val != null) { RobotSkin component = ((Component)val.GetCharacter()).GetComponent<RobotSkin>(); if (Object.op_Implicit((Object)(object)component)) { return component; } } RobotSkin result = null; float num = 8f; foreach (Character allCharacter in Character.GetAllCharacters()) { if (!allCharacter.IsTamed()) { continue; } RobotSkin component2 = ((Component)allCharacter).GetComponent<RobotSkin>(); if (Object.op_Implicit((Object)(object)component2)) { float num2 = Vector3.Distance(((Component)allCharacter).transform.position, ((Component)player).transform.position); if (num2 < num) { num = num2; result = component2; } } } return result; } private static void SpawnLox(Player player) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.LocalPlayerIsAdminOrHost()) { ((Character)player).Message((MessageType)2, "Lox spawn: only host or admins", 0, (Sprite)null, false); return; } GameObject val = (Object.op_Implicit((Object)(object)ZNetScene.instance) ? ZNetScene.instance.GetPrefab("Lox") : null); if (Object.op_Implicit((Object)(object)val)) { Vector3 forward = ((Component)player).transform.forward; GameObject obj = Object.Instantiate<GameObject>(val, ((Component)player).transform.position + forward * 5f + Vector3.up, Quaternion.LookRotation(-forward)); ZNetView component = obj.GetComponent<ZNetView>(); obj.GetComponent<MonsterAI>().MakeTame(); component.GetZDO().Set(ZDOVars.s_haveSaddleHash, true); component.InvokeRPC(ZNetView.Everybody, "SetSaddle", new object[1] { true }); if (SpawnAsRobot.Value) { RobotSkin.MarkRobot(component); } ((Character)player).Message((MessageType)2, "Tamed Lox ready - press E to ride", 0, (Sprite)null, false); } } } internal static class EasyMount { internal static bool Applies(Tameable t) { if (Plugin.EasyMountEnabled.Value && Object.op_Implicit((Object)(object)t.m_saddle) && ((Component)t.m_saddle).gameObject.activeInHierarchy) { return t.IsTamed(); } return false; } } [HarmonyPatch(typeof(Tameable), "Interact")] internal static class EasyMountInteractPatch { private static bool Prefix(Tameable __instance, Humanoid user, bool hold, bool alt, ref bool __result) { if (hold || alt || !EasyMount.Applies(__instance)) { return true; } __result = __instance.m_saddle.Interact(user, false, false); return false; } } [HarmonyPatch(typeof(Tameable), "GetHoverText")] internal static class EasyMountHoverPatch { private static void Postfix(Tameable __instance, ref string __result) { if (EasyMount.Applies(__instance)) { __result = __result.Replace(Localization.instance.Localize("$hud_pet"), "Ride"); } } } [HarmonyPatch(typeof(Tameable), "Awake")] internal static class AddRobotSkinPatch { private static void Postfix(Tameable __instance) { if (Object.op_Implicit((Object)(object)__instance.m_saddle) && ((Object)((Component)__instance).gameObject).name.StartsWith("Lox")) { if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<RobotSkin>())) { ((Component)__instance).gameObject.AddComponent<RobotSkin>(); } LoxPack.Attach(__instance); } } } [HarmonyPatch(typeof(Sadle), "GetMaxStamina")] internal static class MaxStaminaPatch { private static void Postfix(ref float __result) { __result *= Plugin.MaxStamina.Value; } } [HarmonyPatch(typeof(Sadle), "UpdateRiding")] internal static class StaminaDrainPatch { internal struct Saved { public float Run; public float Swim; } private static void Prefix(Sadle __instance, out Saved __state) { __state = new Saved { Run = __instance.m_runStaminaDrain, Swim = __instance.m_swimStaminaDrain }; __instance.m_runStaminaDrain *= Plugin.RunStaminaDrain.Value; __instance.m_swimStaminaDrain *= Plugin.SwimStaminaDrain.Value; } private static void Finalizer(Sadle __instance, Saved __state) { __instance.m_runStaminaDrain = __state.Run; __instance.m_swimStaminaDrain = __state.Swim; } } [HarmonyPatch(typeof(Sadle), "UpdateStamina")] internal static class StaminaRegenPatch { internal struct Saved { public float Fed; public float Hungry; } private static void Prefix(Sadle __instance, out Saved __state) { __state = new Saved { Fed = __instance.m_staminaRegen, Hungry = __instance.m_staminaRegenHungry }; __instance.m_staminaRegen *= Plugin.StaminaRegen.Value; __instance.m_staminaRegenHungry *= Plugin.StaminaRegen.Value; } private static void Finalizer(Sadle __instance, Saved __state) { __instance.m_staminaRegen = __state.Fed; __instance.m_staminaRegenHungry = __state.Hungry; } } [HarmonyPatch(typeof(Character), "UpdateWalking")] internal static class RideSpeedPatch { internal struct Saved { public bool Active; public float Jog; public float Walk; public float Run; } private static void Prefix(Character __instance, out Saved __state) { __state = default(Saved); if (!__instance.IsPlayer() && __instance.HaveRider()) { __state = new Saved { Active = true, Jog = __instance.m_speed, Walk = __instance.m_walkSpeed, Run = __instance.m_runSpeed }; RobotSkin component = ((Component)__instance).GetComponent<RobotSkin>(); float num = ((Object.op_Implicit((Object)(object)component) && component.IsRobot) ? Plugin.RobotSpeed.Value : 1f); __instance.m_speed *= Plugin.WalkSpeed.Value * num; __instance.m_walkSpeed *= Plugin.WalkSpeed.Value * num; __instance.m_runSpeed *= Plugin.RunSpeed.Value * num; } } private static void Finalizer(Character __instance, Saved __state) { if (__state.Active) { __instance.m_speed = __state.Jog; __instance.m_walkSpeed = __state.Walk; __instance.m_runSpeed = __state.Run; } } } public class RobotSkin : MonoBehaviour { private const string ZdoKey = "MountTweaks_Robot"; private const string RpcName = "MountTweaks_SetRobot"; private static readonly Color Red = new Color(0.88f, 0.1f, 0.1f); private static readonly Color Blue = new Color(0.12f, 0.3f, 0.8f); private static readonly Color Silver = new Color(0.78f, 0.8f, 0.84f); private static readonly Color Dark = new Color(0.1f, 0.1f, 0.12f); private static readonly Color Glass = new Color(0.45f, 0.75f, 1f); private static readonly Color Lamp = new Color(1f, 0.85f, 0.3f); private static readonly Color Eye = new Color(0.3f, 0.9f, 1f); private static Shader s_shader; private static Shader s_glowShader; private static bool s_shaderSearched; private ZNetView m_nview; private Character m_character; private Tameable m_tameable; private readonly List<GameObject> m_parts = new List<GameObject>(); private readonly List<Renderer> m_hidden = new List<Renderer>(); private bool m_active; private bool m_synced; private Material m_fallbackBase; private int m_layer; private static readonly Dictionary<(Color, bool), Material> s_materials = new Dictionary<(Color, bool), Material>(); public bool IsRobot => m_active; private bool WantsRobot { get { if ((Object)(object)m_nview != (Object)null && m_nview.IsValid()) { return m_nview.GetZDO().GetBool("MountTweaks_Robot", false); } return false; } } private void Awake() { m_nview = ((Component)this).GetComponent<ZNetView>(); m_character = ((Component)this).GetComponent<Character>(); m_tameable = ((Component)this).GetComponent<Tameable>(); if (!((Object)(object)m_nview == (Object)null) && m_nview.IsValid()) { m_nview.Register<bool>("MountTweaks_SetRobot", (Action<long, bool>)RPC_SetRobot); ((MonoBehaviour)this).InvokeRepeating("Sync", 0.5f, 0.5f); } } public void RequestSet(bool on) { if (!((Object)(object)m_nview == (Object)null) && m_nview.IsValid()) { if (m_nview.IsOwner()) { m_nview.GetZDO().Set("MountTweaks_Robot", on); return; } m_nview.InvokeRPC("MountTweaks_SetRobot", new object[1] { on }); } } public void Toggle() { RequestSet(!WantsRobot); } public static void MarkRobot(ZNetView nview) { nview.GetZDO().Set("MountTweaks_Robot", true); } private void RPC_SetRobot(long sender, bool on) { if (m_nview.IsOwner()) { m_nview.GetZDO().Set("MountTweaks_Robot", on); } } private void Sync() { bool wantsRobot = WantsRobot; if (wantsRobot && !m_active) { Build(); if (m_synced) { PlayTransformFx(on: true); } } else if (!wantsRobot && m_active) { Teardown(); if (m_synced) { PlayTransformFx(on: false); } } else if (m_active) { foreach (Renderer item in m_hidden) { if (Object.op_Implicit((Object)(object)item)) { item.enabled = false; } } } m_synced = true; } private void OnDestroy() { Teardown(); } private void PlayTransformFx(bool on) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0063: Unknown result type (might be due to invalid IL or missing references) string[] array = new string[3] { "fx_GP_Activation", "vfx_spawn", "sfx_spawn" }; foreach (string text in array) { GameObject val = (Object.op_Implicit((Object)(object)ZNetScene.instance) ? ZNetScene.instance.GetPrefab(text) : null); if (Object.op_Implicit((Object)(object)val)) { Object.Instantiate<GameObject>(val, ((Component)this).transform.position + Vector3.up, Quaternion.identity); } } Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer) && Vector3.Distance(((Component)localPlayer).transform.position, ((Component)this).transform.position) < 20f) { ((Character)localPlayer).Message((MessageType)2, on ? "IRONHAULER: TRANSFORM!" : "Ironhauler: back to Lox", 0, (Sprite)null, false); } } private void Teardown() { foreach (GameObject part in m_parts) { if (Object.op_Implicit((Object)(object)part)) { Object.Destroy((Object)(object)part); } } m_parts.Clear(); foreach (Renderer item in m_hidden) { if (Object.op_Implicit((Object)(object)item)) { item.enabled = true; } } m_hidden.Clear(); m_active = false; } private void Build() { //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_0537: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_05db: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_066b: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_067a: Unknown result type (might be due to invalid IL or missing references) //IL_067f: Unknown result type (might be due to invalid IL or missing references) //IL_0684: Unknown result type (might be due to invalid IL or missing references) //IL_0689: Unknown result type (might be due to invalid IL or missing references) //IL_068b: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_06aa: Unknown result type (might be due to invalid IL or missing references) //IL_06b8: Unknown result type (might be due to invalid IL or missing references) //IL_06ba: Unknown result type (might be due to invalid IL or missing references) //IL_06c4: Unknown result type (might be due to invalid IL or missing references) //IL_06c9: Unknown result type (might be due to invalid IL or missing references) //IL_06ce: Unknown result type (might be due to invalid IL or missing references) //IL_06d8: Unknown result type (might be due to invalid IL or missing references) //IL_06dd: Unknown result type (might be due to invalid IL or missing references) //IL_06e2: Unknown result type (might be due to invalid IL or missing references) //IL_06fc: Unknown result type (might be due to invalid IL or missing references) //IL_0701: Unknown result type (might be due to invalid IL or missing references) //IL_070f: Unknown result type (might be due to invalid IL or missing references) //IL_0711: Unknown result type (might be due to invalid IL or missing references) //IL_071b: Unknown result type (might be due to invalid IL or missing references) //IL_0720: Unknown result type (might be due to invalid IL or missing references) //IL_0725: Unknown result type (might be due to invalid IL or missing references) //IL_073f: Unknown result type (might be due to invalid IL or missing references) //IL_0744: Unknown result type (might be due to invalid IL or missing references) //IL_064b: Unknown result type (might be due to invalid IL or missing references) //IL_0652: Unknown result type (might be due to invalid IL or missing references) //IL_065f: Unknown result type (might be due to invalid IL or missing references) //IL_0779: Unknown result type (might be due to invalid IL or missing references) //IL_077b: Unknown result type (might be due to invalid IL or missing references) //IL_0785: Unknown result type (might be due to invalid IL or missing references) //IL_078a: Unknown result type (might be due to invalid IL or missing references) //IL_078f: Unknown result type (might be due to invalid IL or missing references) //IL_0799: Unknown result type (might be due to invalid IL or missing references) //IL_079e: Unknown result type (might be due to invalid IL or missing references) //IL_07a3: Unknown result type (might be due to invalid IL or missing references) //IL_07b0: Unknown result type (might be due to invalid IL or missing references) //IL_07b5: Unknown result type (might be due to invalid IL or missing references) //IL_07ba: Unknown result type (might be due to invalid IL or missing references) //IL_07d4: Unknown result type (might be due to invalid IL or missing references) //IL_07d9: Unknown result type (might be due to invalid IL or missing references) //IL_07e7: Unknown result type (might be due to invalid IL or missing references) //IL_07e9: Unknown result type (might be due to invalid IL or missing references) //IL_07f6: Unknown result type (might be due to invalid IL or missing references) //IL_07fb: Unknown result type (might be due to invalid IL or missing references) //IL_0800: Unknown result type (might be due to invalid IL or missing references) //IL_080a: Unknown result type (might be due to invalid IL or missing references) //IL_080f: Unknown result type (might be due to invalid IL or missing references) //IL_0814: Unknown result type (might be due to invalid IL or missing references) //IL_082e: Unknown result type (might be due to invalid IL or missing references) //IL_0833: Unknown result type (might be due to invalid IL or missing references) Teardown(); Dictionary<string, Transform> bones = new Dictionary<string, Transform>(); Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (!bones.ContainsKey(((Object)val).name)) { bones[((Object)val).name] = val; } } Transform val2 = B("Hip"); Transform val3 = B("spine1"); Transform val4 = B("Spine2"); Transform val5 = B("Neck"); Transform val6 = B("Head"); Transform val7 = B("attachpoint"); if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val4) || !Object.op_Implicit((Object)(object)val6)) { Plugin.Log.LogWarning((object)"Ironhauler: Lox skeleton not recognised, skipping robot skin"); return; } Transform val8 = ((Object.op_Implicit((Object)(object)m_tameable) && Object.op_Implicit((Object)(object)m_tameable.m_saddle)) ? ((Component)m_tameable.m_saddle).transform : null); SkinnedMeshRenderer[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val9 in componentsInChildren2) { bool flag = Object.op_Implicit((Object)(object)val8) && ((Component)val9).transform.IsChildOf(val8); if (!Object.op_Implicit((Object)(object)m_fallbackBase) && !flag) { m_fallbackBase = ((Renderer)val9).sharedMaterial; m_layer = ((Component)val9).gameObject.layer; } ((Renderer)val9).enabled = false; m_hidden.Add((Renderer)(object)val9); } Transform transform = ((Component)this).transform; Vector3 up = transform.up; _ = transform.forward; _ = transform.right; float num = Mathf.Max(0.5f, Vector3.Distance(val2.position, val4.position)); Vector3 val10 = (val2.position + val4.position) * 0.5f; float num2 = (Object.op_Implicit((Object)(object)val7) ? (val7.position.y - 0.05f) : (val10.y + 0.35f * num)); float num3 = val10.y - 0.3f * num; float num4 = Mathf.Max(0.4f * num, num2 - num3); float num5 = 0.7f * num; float num6 = 1.35f * num; Vector3 val11 = default(Vector3); ((Vector3)(ref val11))..ctor(val10.x, (num2 + num3) * 0.5f, val10.z); Quaternion val12 = Quaternion.LookRotation(Vector3.ProjectOnPlane(val4.position - val2.position, up), up); Vector3 val13 = val12 * Vector3.forward; Vector3 val14 = val12 * Vector3.right; Box(val3, val11, val12, new Vector3(num5, num4, num6), Red); Box(val3, val11 - up * (num4 * 0.42f), val12, new Vector3(num5 * 1.04f, num4 * 0.18f, num6 * 1.03f), Blue); Vector3 val15 = val11 + val13 * (num6 * 0.5f + 0.02f); Box(val3, val15 + up * (num4 * 0.25f), val12, new Vector3(num5 * 0.85f, num4 * 0.25f, 0.05f), Glass, glow: true); Box(val3, val15 - up * (num4 * 0.12f), val12, new Vector3(num5 * 0.75f, num4 * 0.38f, 0.06f), Silver); for (int j = -1; j <= 1; j++) { Box(val3, val15 + val13 * 0.03f + up * ((0f - num4) * 0.12f + (float)j * num4 * 0.1f), val12, new Vector3(num5 * 0.7f, num4 * 0.03f, 0.04f), Dark); } float[] array = new float[2] { -1f, 1f }; foreach (float num7 in array) { Box(val3, val15 + val14 * (num7 * num5 * 0.4f) - up * (num4 * 0.3f), val12, new Vector3(num5 * 0.12f, num4 * 0.08f, 0.06f), Lamp, glow: true); Cyl(val3, val11 + val14 * (num7 * num5 * 0.45f) - val13 * (num6 * 0.05f) + up * (num4 * 0.5f + 0.3f * num), val12, new Vector3(0.09f * num, 0.3f * num, 0.09f * num), Silver); Box(val3, val11 + val14 * (num7 * (num5 * 0.5f + 0.01f)) + up * (num4 * 0.05f), val12, new Vector3(0.03f, num4 * 0.12f, num6 * 0.9f), Blue); } string[] array2 = new string[2] { "l", "r" }; foreach (string text in array2) { Leg(B("Frontupperleg." + text), B("Frontlowerleg." + text), B("Frontfoot." + text), val3, val12, num, num5); Leg(B("Backupperleg." + text), B("Backlowerleg." + text), B("Backfoot." + text), val2, val12, num, num5); } if (Object.op_Implicit((Object)(object)val5)) { Segment(val5, val5.position, val6.position, 0.2f * num, Silver); } Vector3 val16 = val6.position + up * (0.05f * num); Box(val6, val16, val12, new Vector3(0.36f * num, 0.38f * num, 0.36f * num), Blue); Box(val6, val16 + val13 * (0.18f * num) - up * (0.06f * num), val12, new Vector3(0.26f * num, 0.18f * num, 0.04f * num), Silver); Box(val6, val16 + up * (0.21f * num), val12, new Vector3(0.06f * num, 0.06f * num, 0.3f * num), Silver); array = new float[2] { -1f, 1f }; foreach (float num8 in array) { Box(val6, val16 + val13 * (0.185f * num) + up * (0.07f * num) + val14 * (num8 * 0.08f * num), val12, new Vector3(0.09f * num, 0.04f * num, 0.03f * num), Eye, glow: true); Box(val6, val16 + val14 * (num8 * 0.2f * num) + up * (0.2f * num), val12, new Vector3(0.04f * num, 0.24f * num, 0.08f * num), Blue); } m_active = true; Transform B(string n) { if (!bones.TryGetValue(n, out var value)) { return null; } return value; } } private void Leg(Transform upper, Transform lower, Transform foot, Transform body, Quaternion bodyRot, float L, float bodyW) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)upper) && Object.op_Implicit((Object)(object)lower)) { Segment(upper, upper.position, lower.position, 0.22f * L, Blue); if (Object.op_Implicit((Object)(object)foot)) { Segment(lower, lower.position, foot.position, 0.18f * L, Blue); Box(foot, foot.position - ((Component)this).transform.up * (0.04f * L), ((Component)this).transform.rotation, new Vector3(0.26f * L, 0.1f * L, 0.34f * L), Dark); } Vector3 val = bodyRot * Vector3.right; float num = ((Vector3.Dot(upper.position - body.position, val) < 0f) ? (-1f) : 1f); Vector3 val2 = body.position + Vector3.Project(upper.position - body.position, bodyRot * Vector3.forward); val2.y = upper.position.y; Vector3 val3 = val2 + val * (num * (bodyW * 0.5f + 0.08f * L)); Quaternion rot = bodyRot * Quaternion.Euler(0f, 0f, 90f); Cyl(body, val3, rot, new Vector3(0.5f * L, 0.07f * L, 0.5f * L), Dark); Cyl(body, val3 + val * (num * 0.08f * L), rot, new Vector3(0.22f * L, 0.02f * L, 0.22f * L), Silver); } } private void Segment(Transform parent, Vector3 a, Vector3 b, float thickness, Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) Vector3 val = b - a; if (!(((Vector3)(ref val)).sqrMagnitude < 1E-06f)) { Quaternion rot = Quaternion.LookRotation(val, ((Component)this).transform.up); Box(parent, (a + b) * 0.5f, rot, new Vector3(thickness, thickness, ((Vector3)(ref val)).magnitude + thickness * 0.3f), color); } } private void Box(Transform parent, Vector3 pos, Quaternion rot, Vector3 size, Color color, bool glow = false) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) Part((PrimitiveType)3, parent, pos, rot, size, color, glow); } private void Cyl(Transform parent, Vector3 pos, Quaternion rot, Vector3 size, Color color) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) Part((PrimitiveType)2, parent, pos, rot, size, color, glow: false); } private void Part(PrimitiveType type, Transform parent, Vector3 pos, Quaternion rot, Vector3 size, Color color, bool glow) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive(type); ((Object)val).name = "Ironhauler_part"; Object.DestroyImmediate((Object)(object)val.GetComponent<Collider>()); val.layer = m_layer; val.transform.SetPositionAndRotation(pos, rot); val.transform.localScale = size; val.transform.SetParent(parent, true); val.GetComponent<Renderer>().sharedMaterial = MakeMaterial(color, glow, m_fallbackBase); m_parts.Add(val); } internal static Material MakeMaterial(Color color, bool glow, Material fallbackBase) { //IL_0005: 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) //IL_0142: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) if (s_materials.TryGetValue((color, glow), out var value) && Object.op_Implicit((Object)(object)value)) { return value; } if (!s_shaderSearched) { s_shaderSearched = true; string[] array = new string[3] { "Standard", "Legacy Shaders/Diffuse", "Unlit/Color" }; for (int i = 0; i < array.Length; i++) { s_shader = Shader.Find(array[i]); if (Object.op_Implicit((Object)(object)s_shader)) { break; } } array = new string[2] { "Unlit/Color", "Legacy Shaders/Self-Illumin/Diffuse" }; for (int i = 0; i < array.Length; i++) { s_glowShader = Shader.Find(array[i]); if (Object.op_Implicit((Object)(object)s_glowShader)) { break; } } Plugin.Log.LogInfo((object)("Ironhauler shader: " + (Object.op_Implicit((Object)(object)s_shader) ? ((Object)s_shader).name : "fallback to Lox material") + ", glow: " + (Object.op_Implicit((Object)(object)s_glowShader) ? ((Object)s_glowShader).name : "none"))); } Material val; if (glow && Object.op_Implicit((Object)(object)s_glowShader)) { val = new Material(s_glowShader); } else if (Object.op_Implicit((Object)(object)s_shader)) { val = new Material(s_shader); } else { val = new Material(fallbackBase); val.mainTexture = (Texture)(object)Texture2D.whiteTexture; } val.color = color; if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.55f); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0.35f); } if (glow && val.HasProperty("_EmissionColor")) { val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", color * 1.5f); } s_materials[(color, glow)] = val; return val; } } }