Decompiled source of Infinity Hammer v1.63.0
InfinityHammer.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Data; using HarmonyLib; using InfinityHammer; using InfinityTools; using Microsoft.CodeAnalysis; using ServerDevcommands; using Service; using SoftReferenceableAssets; using TMPro; using UnityEngine; using WorldEditCommands; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("InfinityHammer")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+278ce99f01f6deaf570b6f5f021133c22c49e4c5")] [assembly: AssemblyProduct("InfinityHammer")] [assembly: AssemblyTitle("InfinityHammer")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 Service { public class ConfigWrapper { private readonly ConfigFile ConfigFile; private readonly Dictionary<string, Action<Terminal, string>> SettingHandlers = new Dictionary<string, Action<Terminal, string>>(); private readonly List<Action> Binders = new List<Action>(); private bool BindsDone; private static readonly HashSet<string> Truthies = new HashSet<string> { "1", "t", "true", "yes", "on" }; private static readonly HashSet<string> Falsies = new HashSet<string> { "0", "f", "false", "no", "off" }; public ConfigWrapper(string command, ConfigFile configFile) { //IL_0030: 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: Expected O, but got Unknown //IL_004e: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) ConfigFile = configFile; new ConsoleCommand(command, "[key] [value] - Toggles or sets a config value.", (ConsoleEvent)delegate(ConsoleEventArgs args) { if (args.Length >= 2 && SettingHandlers.TryGetValue(args[1].ToLower(), out Action<Terminal, string> value)) { if (args.Length == 2) { value(args.Context, ""); } else { value(args.Context, string.Join(" ", args.Args, 2, args.Length - 2)); } } }, false, false, false, false, false, (ConsoleOptionsFetcher)(() => SettingHandlers.Keys.ToList()), false, false, false); } private ConfigEntry<T> Create<T>(string group, string name, T value, ConfigDescription description) { return ConfigFile.Bind<T>(group, name, value, description); } private ConfigEntry<T> Create<T>(string group, string name, T value, string description) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return Create(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); } public ConfigEntry<T> Bind<T>(string group, string name, T value, ConfigDescription description) { ConfigEntry<T> val = Create(group, name, value, description); if (val is ConfigEntry<bool> setting) { Register(setting); } else if (val is ConfigEntry<KeyboardShortcut> setting2) { Register(setting2); } else { Register<T>(val); } return val; } public ConfigEntry<string> BindList(string group, string name, string value, string description) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return Bind(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); } public ConfigEntry<string> BindList(string group, string name, string value, ConfigDescription description) { ConfigEntry<string> val = Create(group, name, value, description); RegisterList(val); return val; } public ConfigEntry<KeyboardShortcut> BindCommand(string command, string group, string name, KeyboardShortcut value, string description, string mode = "") { //IL_001c: Unknown result type (might be due to invalid IL or missing references) string command2 = command; return BindCommand(() => command2, group, name, value, description, mode); } public ConfigEntry<KeyboardShortcut> BindCommand(Func<string> command, string group, string name, KeyboardShortcut value, string description, string mode = "") { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) Func<string> command2 = command; string text = ToKey(name); string text2 = "_bind_" + text; Helper.Command(text2, description, (ConsoleEvent)delegate(ConsoleEventArgs args) { string text3 = command2(); if (args.Length == 1) { args.Context.TryRunCommand(text3, false, false); } else { string args2 = HammerHelper.GetArgs(args[0], args); args.Context.TryRunCommand(text3 + " " + args2, false, false); } }); ConfigEntry<KeyboardShortcut> val = Create<KeyboardShortcut>(group, name, value, description); RegisterCommand(val, text2, mode); return val; } public ConfigEntry<KeyboardShortcut> BindWheelCommand(string command, string group, string name, KeyboardShortcut value, string description, string mode = "") { //IL_001c: Unknown result type (might be due to invalid IL or missing references) string command2 = command; return BindWheelCommand(() => command2, group, name, value, description, mode); } public ConfigEntry<KeyboardShortcut> BindWheelCommand(Func<string> command, string group, string name, KeyboardShortcut value, string description, string mode = "") { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) Func<string> command2 = command; string text = ToKey(name); string text2 = "_bind_" + text; Helper.Command(text2, description, (ConsoleEvent)delegate(ConsoleEventArgs args) { string text3 = command2(); if (args.Length == 1) { args.Context.TryRunCommand(text3, false, false); } else { string args2 = HammerHelper.GetArgs(args[0], args); args.Context.TryRunCommand(text3 + " " + args2, false, false); } }); ConfigEntry<KeyboardShortcut> val = Create<KeyboardShortcut>(group, name, value, description); RegisterWheelCommand(val, text2, mode); return val; } public ConfigEntry<T> Bind<T>(string group, string name, T value, string description) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return Bind(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); } private static void AddMessage(Terminal context, string message) { context.AddString(message); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, message, 0, (Sprite)null); } } public void Bind() { if (BindsDone) { return; } BindsDone = true; foreach (Action binder in Binders) { binder(); } } private void Register(ConfigEntry<bool> setting) { ConfigEntry<bool> setting2 = setting; string name = ((ConfigEntryBase)setting2).Definition.Key; string key = ToKey(name); SettingHandlers.Add(key, delegate(Terminal terminal, string value) { Toggle(terminal, setting2, name, value); }); } public static string GetKeys(KeyboardShortcut key) { //IL_0002: 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) if ((int)((KeyboardShortcut)(ref key)).MainKey == 0) { return "unbound"; } KeyCode mainKey = ((KeyboardShortcut)(ref key)).MainKey; string text = ((object)(KeyCode)(ref mainKey)).ToString().ToLower(); if (((KeyboardShortcut)(ref key)).Modifiers.Count() > 0) { text = text + "," + string.Join(",", ((KeyboardShortcut)(ref key)).Modifiers); } return text; } private void UpdateKey(KeyboardShortcut key, string command, string mode = "") { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)Chat.instance)) { BindsDone = false; return; } string text = GetKeys(key); if (mode != "") { text = text + "," + mode; } string text2 = "rebind " + text + " " + command; ((Terminal)Console.instance).TryRunCommand(text2, false, false); } private string ToKey(string name) { return name.ToLower().Replace(' ', '_').Replace("(", "") .Replace(")", ""); } private void RegisterCommand(ConfigEntry<KeyboardShortcut> setting, string command, string mode = "") { ConfigEntry<KeyboardShortcut> setting2 = setting; string command2 = command; string mode2 = mode; string name = ((ConfigEntryBase)setting2).Definition.Key; string key = ToKey(name); setting2.SettingChanged += delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) UpdateKey(setting2.Value, command2, mode2); }; Binders.Add(delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) UpdateKey(setting2.Value, command2, mode2); }); SettingHandlers.Add(key, delegate(Terminal terminal, string value) { SetKey(terminal, setting2, name, value); }); } private void UpdateWheelKey(KeyboardShortcut key, string command, string mode = "") { //IL_0028: 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) if (!Object.op_Implicit((Object)(object)Chat.instance)) { BindsDone = false; return; } List<string> list = new List<string>(1) { "wheel" }; if ((int)((KeyboardShortcut)(ref key)).MainKey != 0 || mode != "command") { list.Add(GetKeys(key)); } if (mode != "") { list.Add(mode.ToLower()); } string text = "rebind " + string.Join(",", list) + " " + command; ((Terminal)Console.instance).TryRunCommand(text, false, false); } private void RegisterWheelCommand(ConfigEntry<KeyboardShortcut> setting, string command, string mode = "") { ConfigEntry<KeyboardShortcut> setting2 = setting; string command2 = command; string mode2 = mode; string name = ((ConfigEntryBase)setting2).Definition.Key; string key = ToKey(name); setting2.SettingChanged += delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) UpdateWheelKey(setting2.Value, command2, mode2); }; Binders.Add(delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) UpdateWheelKey(setting2.Value, command2, mode2); }); SettingHandlers.Add(key, delegate(Terminal terminal, string value) { SetKey(terminal, setting2, name, value); }); } private void Register(ConfigEntry<KeyboardShortcut> setting) { ConfigEntry<KeyboardShortcut> setting2 = setting; string name = ((ConfigEntryBase)setting2).Definition.Key; string key = ToKey(name); SettingHandlers.Add(key, delegate(Terminal terminal, string value) { SetKey(terminal, setting2, name, value); }); } private void RegisterList(ConfigEntry<string> setting) { ConfigEntry<string> setting2 = setting; string name = ((ConfigEntryBase)setting2).Definition.Key; string key = ToKey(name); SettingHandlers.Add(key, delegate(Terminal terminal, string value) { ToggleFlag(terminal, setting2, name, value); }); } private void Register<T>(ConfigEntry<T> setting) { ConfigEntry<T> setting2 = setting; string name = ((ConfigEntryBase)setting2).Definition.Key; string key = ToKey(name); SettingHandlers.Add(key, delegate(Terminal terminal, string value) { SetValue<T>(terminal, setting2, name, value); }); } private static string State(bool value) { if (!value) { return "disabled"; } return "enabled"; } private static string Flag(bool value) { if (!value) { return "Added"; } return "Removed"; } private static bool IsTruthy(string value) { return Truthies.Contains(value); } private static bool IsFalsy(string value) { return Falsies.Contains(value); } private static void Toggle(Terminal context, ConfigEntry<bool> setting, string name, string value) { if (value == "") { setting.Value = !setting.Value; } else if (IsTruthy(value)) { setting.Value = true; } else if (IsFalsy(value)) { setting.Value = false; } AddMessage(context, name + " " + State(setting.Value) + "."); } private static void SetKey(Terminal context, ConfigEntry<KeyboardShortcut> setting, string name, string value) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (value == "") { AddMessage(context, $"{name}: {setting.Value}."); return; } if (!Enum.TryParse<KeyCode>(value, ignoreCase: true, out KeyCode result)) { throw new InvalidOperationException("'" + value + "' is not a valid UnityEngine.KeyCode."); } setting.Value = new KeyboardShortcut(result, Array.Empty<KeyCode>()); AddMessage(context, name + " set to " + value + "."); } public static int TryParseInt(string value, int defaultValue) { if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return result; } return defaultValue; } public static int TryParseInt(ConfigEntry<string> setting) { if (int.TryParse(setting.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return result; } return TryParseInt((string)((ConfigEntryBase)setting).DefaultValue, 0); } private static float TryParseFloat(string value, float defaultValue) { if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return result; } return defaultValue; } public static float TryParseFloat(ConfigEntry<string> setting) { if (float.TryParse(setting.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return result; } return TryParseFloat((string)((ConfigEntryBase)setting).DefaultValue, 0f); } private static HashSet<string> ParseList(string value) { return (from s in value.Split(new char[1] { ',' }) select s.Trim().ToLower()).ToHashSet(); } private static void ToggleFlag(Terminal context, ConfigEntry<string> setting, string name, string value) { if (value == "") { AddMessage(context, name + ": " + setting.Value + "\"."); return; } HashSet<string> hashSet = ParseList(setting.Value); foreach (string item in ParseList(value)) { bool flag = hashSet.Contains(item); if (flag) { hashSet.Remove(item); } else { hashSet.Add(item); } setting.Value = string.Join(",", hashSet); AddMessage(context, name + ": " + Flag(flag) + " \"" + item + "\"."); } } private static void SetValue<T>(Terminal context, ConfigEntry<T> setting, string name, string value) { if (value == "") { AddMessage(context, $"{name}: {setting.Value}."); return; } if (value.Contains("/")) { string[] array = value.Split(new char[1] { '/' }); value = array[0]; for (int i = 0; i < array.Length - 1; i++) { T value2 = setting.Value; if (string.Equals((value2 != null) ? value2.ToString() : null, array[i], StringComparison.OrdinalIgnoreCase)) { value = array[i + 1]; break; } } } setting.Value = (T)(object)value; AddMessage(context, name + " set to " + value + "."); } } public class Log { private static ManualLogSource Logger; public static void Init(ManualLogSource logger) { Logger = logger; } public static void Error(string message) { Logger.LogError((object)message); } public static void Warning(string message) { Logger.LogWarning((object)message); } public static void Info(string message) { Logger.LogInfo((object)message); } public static void Debug(string message) { Logger.LogDebug((object)message); } } } namespace InfinityHammer { public static class CoverCheck { public const float CoverRayCastLength = 30f; public const float CoverRaycastStart = 0.5f; public const float CoverBedLimit = 0.8f; public const float CoverCraftingStationLimit = 0.7f; public const float CoverFermenterLimit = 0.7f; public const float CoverFireplaceLimit = 0.7f; public const string FORMAT = "0.##"; public static string CurrentCover = ""; public static Vector3 GetCoverPoint(CraftingStation obj) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return obj.m_roofCheckPoint.position; } public static Vector3 GetCoverPoint(Fermenter obj) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return obj.m_roofCheckPoint.position; } public static Vector3 GetCoverPoint(Beehive obj) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return obj.m_coverPoint.position; } public static Vector3 GetCoverPoint(Fireplace obj) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_001b: Unknown result type (might be due to invalid IL or missing references) return ((Component)obj).transform.position + Vector3.up * obj.m_coverCheckOffset; } public static Vector3 GetCoverPoint(Bed obj) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return obj.GetSpawnPoint(); } public static Vector3 GetCoverPoint(Windmill obj) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return ((Component)obj.m_propeller).transform.position; } public static bool ChecksCover(Fireplace obj) { if ((Object)(object)obj.m_enabledObjectLow != (Object)null) { return (Object)(object)obj.m_enabledObjectHigh != (Object)null; } return false; } public static string String(string value, string color = "white") { return "<color=" + color + ">" + value + "</color>"; } public static string Percent(double value, string color = "white") { return String(value.ToString("P0"), color); } public static string JoinLines(IEnumerable<string> lines) { return string.Join(". ", lines.Where((string line) => line != "")); } public static void CheckCover(GameObject obj) { CurrentCover = ""; GetCover(obj.GetComponent<Beehive>()); GetCover(obj.GetComponent<Fermenter>()); GetCover(obj.GetComponent<Fireplace>()); GetCover(obj.GetComponent<Bed>()); GetCover(obj.GetComponent<CraftingStation>()); GetCover(obj.GetComponent<Windmill>()); } public static void GetCover(Beehive obj) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)obj)) { GetCover(GetCoverPoint(obj), obj.m_maxCover, checkRoof: false, minLimit: false); } } public static void GetCover(Fermenter obj) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)obj)) { GetCover(GetCoverPoint(obj), 0.7f); } } public static void GetCover(Fireplace obj) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)obj)) { GetCover(GetCoverPoint(obj), 0.7f, checkRoof: false); } } public static void GetCover(Bed obj) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)obj)) { GetCover(GetCoverPoint(obj), 0.8f); } } public static void GetCover(CraftingStation obj) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)obj)) { GetCover(GetCoverPoint(obj), 0.7f); } } public static void GetCover(Windmill obj) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)obj)) { GetCover(GetCoverPoint(obj), 0f, checkRoof: false); } } public static void GetCover(Vector3 position, float limit, bool checkRoof = true, bool minLimit = true) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string>(); float num = default(float); bool flag = default(bool); Cover.GetCoverForPoint(position, ref num, ref flag, 0.5f); string text = Percent(num) + " cover"; if (limit > 0f) { bool flag2 = (minLimit ? (num < limit) : (num > limit)); text = text + " (" + Percent(limit, flag2 ? "yellow" : "white") + ")"; } list.Add(text); if (checkRoof && !flag) { list.Add(String("Missing roof", "yellow")); } CurrentCover = JoinLines(list); } } public class CustomHealth { private static readonly int HashFields = StringExtensionMethods.GetStableHashCode("HasFields"); private static readonly int HashFieldsDestructible = StringExtensionMethods.GetStableHashCode("HasFieldsDestructible"); private static readonly int HashFieldsMineRock5 = StringExtensionMethods.GetStableHashCode("HasFieldsMineRock5"); private static readonly int HashFieldsTreeBase = StringExtensionMethods.GetStableHashCode("HasFieldsTreeBase"); private static readonly int HashFieldsTreeLog = StringExtensionMethods.GetStableHashCode("HasFieldsTreeLog"); private static readonly int HashToolTierDestructible = StringExtensionMethods.GetStableHashCode("Destructible.m_minToolTier"); private static readonly int HashToolTierMineRock5 = StringExtensionMethods.GetStableHashCode("MineRock5.m_minToolTier"); private static readonly int HashToolTierTreeBase = StringExtensionMethods.GetStableHashCode("TreeBase.m_minToolTier"); private static readonly int HashToolTierTreeLog = StringExtensionMethods.GetStableHashCode("TreeLog.m_minToolTier"); private static readonly int HashFieldsWearNTear = StringExtensionMethods.GetStableHashCode("HasFieldsWearNTear"); public static readonly int HashMaxHealth = StringExtensionMethods.GetStableHashCode("WearNTear.m_health"); public static float SetHealth(ZNetView obj, bool isRepair) { ZDO zDO = obj.GetZDO(); if (Configuration.Invulnerability == "Off" && Configuration.OverwriteHealth == 0f) { return SetDefaultHealth(obj, zDO, isRepair); } if (Configuration.Invulnerability == "Off" || Configuration.Invulnerability == "Legacy") { return SetCustomHealth(obj, zDO); } return SetInfiniteHealth(obj, zDO); } private static float SetDefaultHealth(ZNetView obj, ZDO zdo, bool isRepair) { if (!isRepair) { return 0f; } float num = 0f; Character character = default(Character); if (((Component)obj).TryGetComponent<Character>(ref character)) { num += SetDefaultHealth(zdo, character); } Destructible destructible = default(Destructible); if (((Component)obj).TryGetComponent<Destructible>(ref destructible)) { num += SetDefaultHealth(zdo, destructible); } TreeBase treeBase = default(TreeBase); if (((Component)obj).TryGetComponent<TreeBase>(ref treeBase)) { num += SetDefaultHealth(zdo, treeBase); } TreeLog treeLog = default(TreeLog); if (((Component)obj).TryGetComponent<TreeLog>(ref treeLog)) { num += SetDefaultHealth(zdo, treeLog); } MineRock5 mineRock = default(MineRock5); if (((Component)obj).TryGetComponent<MineRock5>(ref mineRock)) { num += SetDefaultHealth(zdo, mineRock); } WearNTear wear = default(WearNTear); if (((Component)obj).TryGetComponent<WearNTear>(ref wear)) { num += SetDefaultHealth(zdo, wear); } return num; } private static float SetDefaultHealth(ZDO zdo, Destructible destructible) { float @float = zdo.GetFloat(ZDOVars.s_health, destructible.m_health); zdo.RemoveFloat(ZDOVars.s_health); if (zdo.GetInt(HashToolTierDestructible, -1) > -1) { zdo.RemoveInt(HashToolTierDestructible); destructible.m_minToolTier = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<Destructible>()?.m_minToolTier ?? 0; return float.NegativeInfinity; } return destructible.m_health - @float; } private static float SetDefaultHealth(ZDO zdo, TreeBase treeBase) { float @float = zdo.GetFloat(ZDOVars.s_health, treeBase.m_health); zdo.RemoveFloat(ZDOVars.s_health); if (zdo.GetInt(HashToolTierTreeBase, -1) > -1) { zdo.RemoveInt(HashToolTierTreeBase); treeBase.m_minToolTier = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<TreeBase>()?.m_minToolTier ?? 0; return float.NegativeInfinity; } return treeBase.m_health - @float; } private static float SetDefaultHealth(ZDO zdo, TreeLog treeLog) { float @float = zdo.GetFloat(ZDOVars.s_health, treeLog.m_health); zdo.RemoveFloat(ZDOVars.s_health); if (zdo.GetInt(HashToolTierTreeLog, -1) > -1) { zdo.RemoveInt(HashToolTierTreeLog); treeLog.m_minToolTier = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<TreeLog>()?.m_minToolTier ?? 0; return float.NegativeInfinity; } return treeLog.m_health - @float; } private static float SetDefaultHealth(ZDO zdo, MineRock5 mineRock) { float num = 0f; foreach (HitArea hitArea in mineRock.m_hitAreas) { num += mineRock.m_health - hitArea.m_health; hitArea.m_health = mineRock.m_health; } mineRock.SaveHealth(); if (zdo.GetInt(HashToolTierMineRock5, -1) > -1) { zdo.RemoveInt(HashToolTierMineRock5); mineRock.m_minToolTier = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<MineRock5>()?.m_minToolTier ?? 0; return float.NegativeInfinity; } return num; } private static float SetDefaultHealth(ZDO zdo, WearNTear wear) { float @float = zdo.GetFloat(ZDOVars.s_health, wear.m_health); zdo.RemoveFloat(ZDOVars.s_health); float float2 = zdo.GetFloat(HashMaxHealth, 0f); if (float2 != 0f) { wear.m_health = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<WearNTear>().m_health; zdo.RemoveFloat(HashMaxHealth); } UpdateVisual(zdo, wear); if (!(float2 < 0f)) { return wear.m_health - @float; } return float.NegativeInfinity; } private static float SetDefaultHealth(ZDO zdo, Character character) { float @float = zdo.GetFloat(ZDOVars.s_health, zdo.GetFloat(ZDOVars.s_maxHealth, character.m_health)); zdo.RemoveFloat(ZDOVars.s_health); character.SetupMaxHealth(); return zdo.GetFloat(ZDOVars.s_maxHealth, 0f) - @float; } private static float SetCustomHealth(ZNetView obj, ZDO zdo) { float num = 0f; float num2 = ((Configuration.Invulnerability == "Legacy") ? 1E+30f : Configuration.OverwriteHealth); if (num2 <= 0f) { return 0f; } Character character = default(Character); if (((Component)obj).TryGetComponent<Character>(ref character)) { num += SetCustomHealth(zdo, character, num2); } Destructible destructible = default(Destructible); if (((Component)obj).TryGetComponent<Destructible>(ref destructible)) { num += SetCustomHealth(zdo, destructible, num2); } TreeBase treeBase = default(TreeBase); if (((Component)obj).TryGetComponent<TreeBase>(ref treeBase)) { num += SetCustomHealth(zdo, treeBase, num2); } TreeLog treeLog = default(TreeLog); if (((Component)obj).TryGetComponent<TreeLog>(ref treeLog)) { num += SetCustomHealth(zdo, treeLog, num2); } MineRock5 mineRock = default(MineRock5); if (((Component)obj).TryGetComponent<MineRock5>(ref mineRock)) { num += SetCustomHealth(zdo, mineRock, num2); } WearNTear wear = default(WearNTear); if (((Component)obj).TryGetComponent<WearNTear>(ref wear)) { num += SetCustomHealth(zdo, wear, num2); } return num; } private static float SetCustomHealth(ZDO zdo, Destructible destructible, float health) { float @float = zdo.GetFloat(ZDOVars.s_health, destructible.m_health); zdo.Set(ZDOVars.s_health, health); if (zdo.GetInt(HashToolTierDestructible, -1) > -1) { zdo.RemoveInt(HashToolTierDestructible); destructible.m_minToolTier = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<Destructible>()?.m_minToolTier ?? 0; return float.NegativeInfinity; } return health - @float; } private static float SetCustomHealth(ZDO zdo, TreeBase treeBase, float health) { float @float = zdo.GetFloat(ZDOVars.s_health, treeBase.m_health); zdo.Set(ZDOVars.s_health, health); if (zdo.GetInt(HashToolTierTreeBase, -1) > -1) { zdo.RemoveInt(HashToolTierTreeBase); treeBase.m_minToolTier = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<TreeBase>()?.m_minToolTier ?? 0; return float.NegativeInfinity; } return health - @float; } private static float SetCustomHealth(ZDO zdo, TreeLog treeLog, float health) { float @float = zdo.GetFloat(ZDOVars.s_health, treeLog.m_health); zdo.Set(ZDOVars.s_health, health); if (zdo.GetInt(HashToolTierTreeLog, -1) > -1) { zdo.RemoveInt(HashToolTierTreeLog); treeLog.m_minToolTier = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<TreeLog>()?.m_minToolTier ?? 0; return float.NegativeInfinity; } return health - @float; } private static float SetCustomHealth(ZDO zdo, MineRock5 mineRock, float health) { float num = 0f; foreach (HitArea hitArea in mineRock.m_hitAreas) { num += health - hitArea.m_health; hitArea.m_health = health; } mineRock.SaveHealth(); if (zdo.GetInt(HashToolTierMineRock5, -1) > -1) { zdo.RemoveInt(HashToolTierMineRock5); mineRock.m_minToolTier = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<MineRock5>()?.m_minToolTier ?? 0; return float.NegativeInfinity; } return num; } private static float SetCustomHealth(ZDO zdo, WearNTear wear, float health) { float @float = zdo.GetFloat(ZDOVars.s_health, wear.m_health); zdo.Set(ZDOVars.s_health, health); float float2 = zdo.GetFloat(HashMaxHealth, 0f); if (float2 != 0f) { wear.m_health = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<WearNTear>().m_health; zdo.RemoveFloat(HashMaxHealth); } zdo.RemoveFloat(Hash.BuildingSkillLevel); UpdateVisual(zdo, wear); if (!(float2 < 0f)) { return health - @float; } return float.NegativeInfinity; } private static float SetCustomHealth(ZDO zdo, Character character, float health) { float @float = zdo.GetFloat(ZDOVars.s_health, zdo.GetFloat(ZDOVars.s_maxHealth, character.m_health)); zdo.Set(ZDOVars.s_maxHealth, health); zdo.Set(ZDOVars.s_health, health * 1.000001f); return health - @float; } private static float SetInfiniteHealth(ZNetView obj, ZDO zdo) { bool flag = false; Character character = default(Character); if (((Component)obj).TryGetComponent<Character>(ref character)) { flag |= SetInfiniteHealth(zdo, character); } Destructible destructible = default(Destructible); if (((Component)obj).TryGetComponent<Destructible>(ref destructible)) { flag |= SetInfiniteHealth(zdo, destructible); } TreeBase treeBase = default(TreeBase); if (((Component)obj).TryGetComponent<TreeBase>(ref treeBase)) { flag |= SetInfiniteHealth(zdo, treeBase); } TreeLog treeLog = default(TreeLog); if (((Component)obj).TryGetComponent<TreeLog>(ref treeLog)) { flag |= SetInfiniteHealth(zdo, treeLog); } MineRock5 mineRock = default(MineRock5); if (((Component)obj).TryGetComponent<MineRock5>(ref mineRock)) { flag |= SetInfiniteHealth(zdo, mineRock); } WearNTear wear = default(WearNTear); if (((Component)obj).TryGetComponent<WearNTear>(ref wear)) { flag |= SetInfiniteHealth(zdo, wear); } if (!flag) { return 0f; } return float.PositiveInfinity; } private static bool SetInfiniteHealth(ZDO zdo, Destructible destructible) { bool result = zdo.GetInt(HashToolTierDestructible, 0) != 1073741823; zdo.RemoveFloat(ZDOVars.s_health); zdo.Set(HashFields, true); zdo.Set(HashFieldsDestructible, true); zdo.Set(HashToolTierDestructible, 1073741823, false); destructible.m_minToolTier = 1073741823; return result; } private static bool SetInfiniteHealth(ZDO zdo, TreeBase treeBase) { bool result = zdo.GetInt(HashToolTierTreeBase, 0) != 1073741823; zdo.RemoveFloat(ZDOVars.s_health); zdo.Set(HashFields, true); zdo.Set(HashFieldsTreeBase, true); zdo.Set(HashToolTierTreeBase, 1073741823, false); treeBase.m_minToolTier = 1073741823; return result; } private static bool SetInfiniteHealth(ZDO zdo, TreeLog treeLog) { bool result = zdo.GetInt(HashToolTierTreeLog, 0) != 1073741823; zdo.RemoveFloat(ZDOVars.s_health); zdo.Set(HashFields, true); zdo.Set(HashFieldsTreeLog, true); zdo.Set(HashToolTierTreeLog, 1073741823, false); treeLog.m_minToolTier = 1073741823; return result; } private static bool SetInfiniteHealth(ZDO zdo, MineRock5 mineRock) { bool result = zdo.GetInt(HashToolTierMineRock5, 0) != 1073741823; zdo.Set(HashFields, true); zdo.Set(HashFieldsMineRock5, true); zdo.Set(HashToolTierMineRock5, 1073741823, false); foreach (HitArea hitArea in mineRock.m_hitAreas) { hitArea.m_health = mineRock.m_health; } mineRock.SaveHealth(); return result; } private static bool SetInfiniteHealth(ZDO zdo, WearNTear wear) { zdo.Set(ZDOVars.s_health, -1f); float num = -1f; if (Configuration.Invulnerability == "Worn") { num = -2f; } if (Configuration.Invulnerability == "Damaged") { num = -4f; } bool result = zdo.GetFloat(HashMaxHealth, 0f) != num; zdo.Set(HashFields, true); zdo.Set(HashFieldsWearNTear, true); zdo.Set(HashMaxHealth, num); zdo.RemoveFloat(Hash.BuildingSkillLevel); wear.m_health = num; UpdateVisual(zdo, wear); return result; } private static bool SetInfiniteHealth(ZDO zdo, Character character) { bool result = zdo.GetFloat(ZDOVars.s_maxHealth, 0f) != 1E+30f; zdo.Set(ZDOVars.s_health, 1.000001E+30f); zdo.Set(ZDOVars.s_maxHealth, 1E+30f); return result; } private static void UpdateVisual(ZDO zdo, WearNTear wear) { wear.m_healthPercentage = zdo.GetFloat(ZDOVars.s_health, wear.m_health) / wear.m_health; wear.SetHealthVisual(wear.m_healthPercentage, false); } } [HarmonyPatch] public static class DungeonRooms { private static readonly List<DungeonGenerator> Dgs = new List<DungeonGenerator>(); public static void AddRoom(ZNetView obj, int hash, Vector3 pos, Quaternion rot) { //IL_0028: 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_0036: 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) ZDO zDO = obj.GetZDO(); int @int = zDO.GetInt(ZDOVars.s_rooms, 0); byte[] byteArray = zDO.GetByteArray(ZDOVars.s_roomData, (byte[])null); if (@int > 0) { AddRoom(zDO, @int, hash, pos, rot); } else if (byteArray != null) { AddRoom(zDO, byteArray, hash, pos, rot); } } private static void AddRoom(ZDO zdo, int rooms, int hash, Vector3 pos, Quaternion rot) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) zdo.Set(ZDOVars.s_rooms, rooms + 1, false); zdo.Set(StringExtensionMethods.GetStableHashCode("room" + rooms), hash, false); zdo.Set(StringExtensionMethods.GetStableHashCode("room" + rooms + "_pos"), pos); zdo.Set(StringExtensionMethods.GetStableHashCode("room" + rooms + "_rot"), rot); } private static void AddRoom(ZDO zdo, byte[] data, int hash, Vector3 pos, Quaternion rot) { //IL_0046: 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) //IL_0078: 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) DungeonGenerator.saveStream.SetLength(0L); BinaryReader binaryReader = new BinaryReader(new MemoryStream(data)); int num = binaryReader.ReadInt32(); DungeonGenerator.saveWriter.Write(num + 1); for (int i = 0; i < num; i++) { DungeonGenerator.saveWriter.Write(binaryReader.ReadInt32()); Utils.Write(DungeonGenerator.saveWriter, Utils.ReadVector3(binaryReader)); Utils.Write(DungeonGenerator.saveWriter, Utils.ReadQuaternion(binaryReader)); } DungeonGenerator.saveWriter.Write(hash); Utils.Write(DungeonGenerator.saveWriter, pos); Utils.Write(DungeonGenerator.saveWriter, rot); zdo.Set(ZDOVars.s_roomData, DungeonGenerator.saveStream.ToArray()); } public static void RemoveRoom(ZNetView obj, int index) { ZDO zDO = obj.GetZDO(); int @int = zDO.GetInt(ZDOVars.s_rooms, 0); if (@int > 0) { Remove(zDO, @int, index); } byte[] byteArray = zDO.GetByteArray(ZDOVars.s_roomData, (byte[])null); if (byteArray != null) { Remove(zDO, byteArray, index); } if (((Component)obj).transform.childCount >= 1) { Transform child = ((Component)obj).transform.GetChild(index); if (Object.op_Implicit((Object)(object)child)) { child.parent = null; Object.Destroy((Object)(object)((Component)child).gameObject); } } } private static void Remove(ZDO zdo, int rooms, int index) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) for (int i = index + 1; i < rooms; i++) { int stableHashCode = StringExtensionMethods.GetStableHashCode("room" + i); int stableHashCode2 = StringExtensionMethods.GetStableHashCode("room" + (i - 1)); zdo.Set(stableHashCode2, zdo.GetInt(stableHashCode, 0), false); stableHashCode = StringExtensionMethods.GetStableHashCode("room" + i + "_pos"); stableHashCode2 = StringExtensionMethods.GetStableHashCode("room" + (i - 1) + "_pos"); zdo.Set(stableHashCode2, zdo.GetVec3(stableHashCode, Vector3.zero)); stableHashCode = StringExtensionMethods.GetStableHashCode("room" + i + "_rot"); stableHashCode2 = StringExtensionMethods.GetStableHashCode("room" + (i - 1) + "_rot"); zdo.Set(stableHashCode2, zdo.GetQuaternion(stableHashCode, Quaternion.identity)); } zdo.Set(ZDOVars.s_rooms, rooms - 1, false); zdo.RemoveInt(StringExtensionMethods.GetStableHashCode("room" + rooms)); zdo.RemoveVec3(StringExtensionMethods.GetStableHashCode("room" + rooms + "_pos")); zdo.RemoveQuaternion(StringExtensionMethods.GetStableHashCode("room" + rooms + "_rot")); } private static void Remove(ZDO zdo, byte[] data, int index) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) DungeonGenerator.saveStream.SetLength(0L); BinaryReader binaryReader = new BinaryReader(new MemoryStream(data)); int num = binaryReader.ReadInt32(); DungeonGenerator.saveWriter.Write(num - 1); for (int i = 0; i < num; i++) { if (i != index) { DungeonGenerator.saveWriter.Write(binaryReader.ReadInt32()); Utils.Write(DungeonGenerator.saveWriter, Utils.ReadVector3(binaryReader)); Utils.Write(DungeonGenerator.saveWriter, Utils.ReadQuaternion(binaryReader)); } } zdo.Set(ZDOVars.s_roomData, DungeonGenerator.saveStream.ToArray()); } public static void Reposition(ZDO zdo, Transform target) { GameObject prefab = ZNetScene.instance.GetPrefab(zdo.GetPrefab()); if (Object.op_Implicit((Object)(object)prefab) && Object.op_Implicit((Object)(object)prefab.GetComponent<DungeonGenerator>())) { List<Transform> trs = (from r in ((Component)target).GetComponentsInChildren<Room>() select ((Component)r).transform).ToList(); byte[] byteArray = zdo.GetByteArray(ZDOVars.s_roomData, (byte[])null); int @int = zdo.GetInt(ZDOVars.s_rooms, 0); if (@int > 0) { Reposition(zdo, @int, trs); } else if (byteArray != null) { Reposition(zdo, byteArray, trs); } } } private static void Reposition(ZDO zdo, int rooms, List<Transform> trs) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < rooms; i++) { int stableHashCode = StringExtensionMethods.GetStableHashCode("room" + i + "_pos"); int stableHashCode2 = StringExtensionMethods.GetStableHashCode("room" + i + "_rot"); if (trs.Count <= i) { zdo.Set(stableHashCode, zdo.GetPosition()); zdo.Set(stableHashCode2, zdo.GetRotation()); } else { zdo.Set(stableHashCode, trs[i].position); zdo.Set(stableHashCode2, trs[i].rotation); } } } private static void Reposition(ZDO zdo, byte[] data, List<Transform> trs) { //IL_0075: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) DungeonGenerator.saveStream.SetLength(0L); BinaryReader binaryReader = new BinaryReader(new MemoryStream(data)); int num = binaryReader.ReadInt32(); DungeonGenerator.saveWriter.Write(num); for (int i = 0; i < num; i++) { DungeonGenerator.saveWriter.Write(binaryReader.ReadInt32()); if (trs.Count <= i) { Utils.Write(DungeonGenerator.saveWriter, zdo.GetPosition()); Utils.Write(DungeonGenerator.saveWriter, zdo.GetRotation()); } else { Utils.Write(DungeonGenerator.saveWriter, trs[i].position); Utils.Write(DungeonGenerator.saveWriter, trs[i].rotation); } } zdo.Set(ZDOVars.s_roomData, DungeonGenerator.saveStream.ToArray()); } public static DungeonGenerator? FindClosestDg(Vector3 pos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return Dgs.OrderBy(delegate(DungeonGenerator dg) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Distance(pos, ((Component)dg).transform.position); Room val = default(Room); foreach (Transform item in ((Component)dg).transform) { if (((Component)item).TryGetComponent<Room>(ref val)) { RoomConnection[] connections = val.GetConnections(); foreach (RoomConnection val2 in connections) { float num2 = Vector3.Distance(pos, ((Component)val2).transform.position); if (num2 < num) { num = num2; } } } } return num; }).FirstOrDefault(); } [HarmonyPatch(typeof(DungeonGenerator), "Awake")] [HarmonyPostfix] private static void DungeonGeneratorAwake(DungeonGenerator __instance) { Dgs.Add(__instance); } [HarmonyPatch(typeof(DungeonGenerator), "OnDestroy")] [HarmonyPostfix] private static void DungeonGeneratorDestroy(DungeonGenerator __instance) { Dgs.Remove(__instance); } [HarmonyPatch(typeof(Piece), "GetSnapPoints", new Type[] { typeof(Vector3), typeof(float), typeof(List<Transform>), typeof(List<Piece>) })] [HarmonyPrefix] private static void GetSnapPointsRadius(ref float radius) { float snapMultiplier = Selection.Get().SnapMultiplier; radius *= snapMultiplier; } [HarmonyPatch(typeof(Piece), "GetSnapPoints", new Type[] { typeof(Vector3), typeof(float), typeof(List<Transform>), typeof(List<Piece>) })] [HarmonyPostfix] private static void GetSnapPoints(Vector3 point, float radius, List<Transform> points) { //IL_0035: 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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) float dungeonRoomSnapMultiplier = Selection.Get().DungeonRoomSnapMultiplier; Room val = default(Room); foreach (DungeonGenerator dg in Dgs) { foreach (Transform item in ((Component)dg).transform) { if (!((Component)item).TryGetComponent<Room>(ref val)) { continue; } RoomConnection[] connections = val.GetConnections(); foreach (RoomConnection val2 in connections) { if (Vector3.Distance(point, ((Component)val2).transform.position) <= radius * dungeonRoomSnapMultiplier) { points.Add(((Component)val2).transform); } } } } } } [HarmonyPatch(typeof(Player), "FindClosestSnapPoints")] public class DisableSnapsWhenFrozen { private static bool Prefix() { return !Position.Override.HasValue; } } [HarmonyPatch(typeof(Player), "PieceRayTest")] public class FreezePlacementMarker { private static Vector3 CurrentNormal = Vector3.up; private static void Postfix(ref Vector3 point, ref Vector3 normal, ref Piece piece, ref Heightmap heightmap, ref Collider waterSurface, ref bool __result) { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_0014: 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_0023: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0096: Unknown result type (might be due to invalid IL or missing references) if (__result && Grid.Enabled) { point = Grid.Apply(point, Object.op_Implicit((Object)(object)heightmap) ? Vector3.up : normal); if (Object.op_Implicit((Object)(object)heightmap)) { point.y = ZoneSystem.instance.GetGroundHeight(point) + 2f; RaycastHit val = default(RaycastHit); if (Physics.Raycast(point, Vector3.down, ref val, 50f, Player.m_localPlayer.m_placeRayMask)) { point = ((RaycastHit)(ref val)).point; normal = ((RaycastHit)(ref val)).normal; } } } if (Position.Override.HasValue) { point = Position.Override.Value; normal = CurrentNormal; __result = true; piece = null; heightmap = null; waterSurface = null; } else { CurrentNormal = normal; } } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] public class OverridePlacementGhost { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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) //IL_0037: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Location), "IsInsideNoBuildLocation", (Type[])null, (Type[])null), (string)null) }).Advance(-2).Insert((CodeInstruction[])(object)new CodeInstruction[3] { new CodeInstruction(OpCodes.Call, Transpilers.EmitDelegate<Action<GameObject>>((Action<GameObject>)Position.Apply).operand), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(Player), "m_placementGhost")) }) .InstructionEnumeration(); } } public static class Grid { private static float Precision; private static Vector3 Center; private static Vector3 PreciseCenter; public static bool Enabled { get { if (Precision == 0f) { return Selection.Get().TerrainGrid; } return true; } } public static Vector3 Apply(Vector3 point, Vector3 normal) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0041: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_007e: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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) float num = Precision; Vector3 val = Center; if (num == 0f && Selection.Get().TerrainGrid) { num = 1f; val = PreciseCenter; } if (num == 0f) { return point; } Quaternion val2 = Quaternion.FromToRotation(Vector3.up, normal); point = val2 * point; Vector3 val3 = val2 * val; point.x = val3.x + Mathf.Round((point.x - val3.x) / num) * num; point.z = val3.z + Mathf.Round((point.z - val3.z) / num) * num; return Quaternion.Inverse(val2) * point; } public static void Toggle(float precision, Vector3 center) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (Precision == precision) { Precision = 0f; return; } Center = center; Precision = precision; } public static void SetPreciseMode(Vector3 center) { //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) PreciseCenter = center; } } public static class Position { public static Vector3? Override = null; public static Vector3 Offset = Vector3.zero; public static void ToggleFreeze() { if (Override.HasValue) { Unfreeze(); } else { Freeze(); } } public static void Freeze(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) Override = position; } public static void Freeze() { //IL_0028: 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) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Player player = Helper.GetPlayer(); GameObject placementGhost = player.m_placementGhost; Override = (Object.op_Implicit((Object)(object)placementGhost) ? Deapply(placementGhost.transform.position, placementGhost.transform.rotation) : ((Component)player).transform.position); } public static void Unfreeze() { //IL_0012: 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) Override = null; if (Configuration.ResetOffsetOnUnfreeze) { Offset = Vector3.zero; } } public static void Apply(GameObject ghost) { //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_001e: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (Selection.Get().PlayerHeight) { Player player = Helper.GetPlayer(); ghost.transform.position = new Vector3(ghost.transform.position.x, ((Component)player).transform.position.y, ghost.transform.position.z); } ghost.transform.position = Apply(ghost.transform.position, ghost.transform.rotation); } public static Vector3 Apply(Vector3 point, Quaternion rotation) { //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_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_0032: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) //IL_004f: 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_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_006d: 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_0070: 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) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_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) if (Override.HasValue) { point = Override.Value; } if (Selection.Get().TerrainGrid) { rotation = Quaternion.identity; } point += rotation * Vector3.right * Offset.x; point += rotation * Vector3.up * Offset.y; point += rotation * Vector3.forward * Offset.z; return point; } public static Vector3 Deapply(Vector3 point, Quaternion rotation) { //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_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_0032: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) //IL_004f: 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_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_006d: 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_0070: 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) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_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) if (Override.HasValue) { point = Override.Value; } if (Selection.Get().TerrainGrid) { rotation = Quaternion.identity; } point -= rotation * Vector3.right * Offset.x; point -= rotation * Vector3.up * Offset.y; point -= rotation * Vector3.forward * Offset.z; return point; } public static void SetX(float value) { Offset.x = value; } public static void SetY(float value) { Offset.y = value; } public static void SetZ(float value) { Offset.z = value; } public static void MoveLeft(float value) { if (Selection.Get().TerrainGrid) { value = Mathf.Max(value, 1f); } Offset.x = Helper.Round(Offset.x - value); } public static void MoveRight(float value) { if (Selection.Get().TerrainGrid) { value = Mathf.Max(value, 1f); } Offset.x = Helper.Round(Offset.x + value); } public static void MoveDown(float value) { Offset.y = Helper.Round(Offset.y - value); } public static void MoveUp(float value) { Offset.y = Helper.Round(Offset.y + value); } public static void MoveBackward(float value) { if (Selection.Get().TerrainGrid) { value = Mathf.Max(value, 1f); } Offset.z = Helper.Round(Offset.z - value); } public static void MoveForward(float value) { if (Selection.Get().TerrainGrid) { value = Mathf.Max(value, 1f); } Offset.z = Helper.Round(Offset.z + value); } public static void Set(Vector3 value) { //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) Offset = value; } public static void Move(Vector3 value) { //IL_0000: 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_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Offset += value; } public static void Print(Terminal terminal) { if (!Configuration.DisableOffsetMessages) { HammerHelper.Message(terminal, "Offset set to forward: " + Offset.z.ToString("F1", CultureInfo.InvariantCulture) + ", up: " + Offset.y.ToString("F1", CultureInfo.InvariantCulture) + ", right: " + Offset.x.ToString("F1", CultureInfo.InvariantCulture) + "."); } } } public class NoCreator { private static readonly int XRaySteamName = StringExtensionMethods.GetStableHashCode("steamName"); private static readonly int XRaySteamID = StringExtensionMethods.GetStableHashCode("steamID"); private static readonly int XRayCreatedID = StringExtensionMethods.GetStableHashCode("xray_created"); public static void Set(ZNetView view, Piece piece) { if (!((StaticTarget)piece).m_randomTarget && !((StaticTarget)piece).m_primaryTarget) { return; } ZDO zDO = view.GetZDO(); if (Configuration.NoCreator) { zDO.Set(ZDOVars.s_creator, 0L); if (zDO.GetString(ZDOVars.s_creatorName, "") != "") { zDO.Set(ZDOVars.s_creatorName, ""); } piece.m_creator = 0L; zDO.Set(XRaySteamName, ""); zDO.Set(XRaySteamID, ""); zDO.Set(XRayCreatedID, 0L); } else { piece.SetCreator(Game.instance.GetPlayerProfile().GetPlayerID()); } if (Configuration.NoPrimaryTarget && ((StaticTarget)piece).m_primaryTarget) { ((StaticTarget)piece).m_primaryTarget = false; zDO.Set("HasFields", true); zDO.Set("HasFieldsStaticTarget", true); zDO.Set("StaticTarget.m_primaryTarget", false); view.LoadFields(); } if (Configuration.NoSecondaryTarget && ((StaticTarget)piece).m_randomTarget) { ((StaticTarget)piece).m_randomTarget = false; zDO.Set("HasFields", true); zDO.Set("HasFieldsStaticTarget", true); zDO.Set("StaticTarget.m_randomTarget", false); view.LoadFields(); } } } [HarmonyPatch(typeof(Player), "PlacePiece")] public class PlacePiece { private static void Prefix() { HideEffects.Active = true; } private static void Finalizer() { HideEffects.Active = false; DataHelper.CleanUp(); if (Selection.Get().SingleUse) { Hammer.Clear(); } } private static GameObject GetPrefab(GameObject obj) { if (!Configuration.Enabled) { return obj; } return Selection.Get().GetPrefab(obj); } private static void Postprocess(GameObject obj) { if (Configuration.Enabled) { Selection.Get().AfterPlace(obj); } } private static void OnPlaced(Piece piece) { if (Object.op_Implicit((Object)(object)piece)) { piece.OnPlaced(); } } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null) }).Advance(1).Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, Transpilers.EmitDelegate<Func<GameObject, GameObject>>((Func<GameObject, GameObject>)GetPrefab).operand) }) .MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Piece), "OnPlaced", (Type[])null, (Type[])null), (string)null) }) .Set(OpCodes.Call, Transpilers.EmitDelegate<Action<Piece>>((Action<Piece>)OnPlaced).operand) .MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ret, (object)null, (string)null) }) .Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldloc_0, (object)null), new CodeInstruction(OpCodes.Call, Transpilers.EmitDelegate<Action<GameObject>>((Action<GameObject>)Postprocess).operand) }) .InstructionEnumeration(); } } [HarmonyPatch(typeof(Player), "UpdatePlacement")] public class HoldUse { public static bool Selecting; private static void Prefix(Player __instance, ref ItemData __state) { __state = ((Humanoid)__instance).GetRightItem(); Hammer.RemoveToolCosts(__state); } private static void Postfix(Player __instance) { if (Selection.Get().Continuous && __instance.m_placePressedTime == -9999f) { if (!ZInput.GetButton("Attack") && !ZInput.GetButton("JoyPlace")) { __instance.m_placePressedTime = -9998f; } else if (!(Time.time - __instance.m_lastToolUseTime < __instance.m_placeDelay / 4f)) { __instance.m_placePressedTime = Time.time; __instance.m_lastToolUseTime = 0f; } } } private static void Finalizer(ItemData __state) { Hammer.RestoreToolCosts(__state); } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] public class UnlockBuildDistance { public static void Prefix(Player __instance, ref float __state) { __state = __instance.m_maxPlaceDistance; BaseSelection baseSelection = Selection.Get(); if (baseSelection != null) { __instance.m_maxPlaceDistance = baseSelection.MaxPlaceDistance(__instance.m_maxPlaceDistance); } } public static void Postfix(Player __instance, float __state) { __instance.m_maxPlaceDistance = __state; } } [HarmonyPatch(typeof(ZoneSystem), "SpawnLocation")] public class CustomizeSpawnLocation { public static bool? RandomDamage; public static bool AllViews; private static void Customize(ZNetView[] views) { if (RandomDamage.HasValue) { WearNTear.m_randomInitialDamage = RandomDamage.Value; } if (AllViews) { for (int i = 0; i < views.Length; i++) { ((Component)views[i]).gameObject.SetActive(true); } } } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_0035: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Stsfld, (object)AccessTools.Field(typeof(WearNTear), "m_randomInitialDamage"), (string)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldloc_0, (object)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, Transpilers.EmitDelegate<Action<ZNetView[]>>((Action<ZNetView[]>)Customize).operand) }) .InstructionEnumeration(); } } [HarmonyPatch(typeof(Player), "RemovePiece")] public class UnlockRemoveDistance { public static void Prefix(Player __instance, ref float __state) { __state = __instance.m_maxPlaceDistance; if (Configuration.Range > 0f) { __instance.m_maxPlaceDistance = Configuration.Range; } } public static void Postfix(Player __instance, float __state) { __instance.m_maxPlaceDistance = __state; } } [HarmonyPatch(typeof(Player), "RemovePiece")] public class RemovePiece { public static bool Prefix(Player __instance, ref bool __result) { UndoHelper.BeginAction(); HideEffects.Active = true; PreventPieceDrops.Active = Configuration.DisableLoot; PreventCreaturerops.Active = Configuration.DisableLoot; if (Configuration.RemoveAnything) { __result = RemoveAnything(__instance); return false; } return true; } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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) //IL_0037: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(ZNetScene), "get_instance", (Type[])null, (Type[])null), (string)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldloc_1, (object)null) }).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RemovePiece), "HandleRemoved", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } private static void Finalizer() { UndoHelper.EndAction(); HideEffects.Active = false; PreventPieceDrops.Active = false; PreventCreaturerops.Active = false; } private static void HandleRemoved(Piece piece) { //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_001f: 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_002a: 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) ZDO zDO = piece.m_nview.GetZDO(); Vector3 position = ((Component)piece).transform.position; int prefab = zDO.m_prefab; ZDOID uid = zDO.m_uid; UndoHelper.AddRemoveAction(zDO); RemoveInArea(uid, prefab, position, Configuration.RemoveArea); } private static bool RemoveAnything(Player obj) { //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) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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) Hovered hovered = Selector.GetHovered(obj, obj.m_maxPlaceDistance, Array.Empty<string>(), Configuration.RemoveIds, false); if (hovered == null) { return false; } obj.m_removeEffects.Create(((Component)hovered.Obj).transform.position, Quaternion.identity, (Transform)null, 1f, -1); Vector3 position = ((Component)hovered.Obj).transform.position; int prefab = hovered.Obj.GetZDO().m_prefab; ZDOID uid = hovered.Obj.GetZDO().m_uid; if (Remove(hovered)) { RemoveInArea(uid, prefab, position, Configuration.RemoveArea); } ItemData rightItem = ((Humanoid)obj).GetRightItem(); if (rightItem != null) { obj.FaceLookDirection(); ((Character)obj).m_zanim.SetTrigger(rightItem.m_shared.m_attack.m_attackAnimation); } return true; } private static bool Remove(Hovered hovered) { ZNetView obj = hovered.Obj; if (Object.op_Implicit((Object)(object)((Component)obj).GetComponent<DungeonGenerator>()) && hovered.Index > -1) { if (((Component)obj).transform.childCount > 1) { UndoHelper.AddEditAction(obj.GetZDO()); } else { UndoHelper.AddRemoveAction(obj.GetZDO()); } DungeonRooms.RemoveRoom(obj, hovered.Index); if (((Component)obj).transform.childCount == 0) { HammerHelper.RemoveZDO(obj.GetZDO()); return true; } return false; } Remove(obj); return true; } private static void Remove(ZNetView obj) { CharacterDrop component = ((Component)obj).GetComponent<CharacterDrop>(); if (component != null) { component.OnDeath(); } Piece component2 = ((Component)obj).GetComponent<Piece>(); if (component2 != null) { component2.DropResources((HitData)null); } UndoHelper.AddRemoveAction(obj.GetZDO()); HammerHelper.RemoveZDO(obj.GetZDO()); } private static void RemoveInArea(ZDOID id, int prefab, Vector3 position, float radius) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (radius != 0f) { ZNetView[] array = ZNetScene.instance.m_instances.Values.Where((ZNetView view) => Object.op_Implicit((Object)(object)view) && view.IsValid() && view.GetZDO().m_prefab == prefab && Vector3.Distance(position, view.GetZDO().m_position) < radius && view.GetZDO().m_uid != id).ToArray(); for (int i = 0; i < array.Length; i++) { Remove(array[i]); } } } } [HarmonyPatch(typeof(Piece), "DropResources")] public class PreventPieceDrops { public static bool Active; private static bool Prefix() { return !Active; } } [HarmonyPatch(typeof(CharacterDrop), "OnDeath")] public class PreventCreaturerops { public static bool Active; private static bool Prefix() { return !Active; } } [HarmonyPatch(typeof(Player), "Repair")] public class Repair { private static void Prefix(Player __instance, ItemData toolItem) { HideEffects.Active = true; Hammer.RemoveToolCosts(toolItem); UndoHelper.BeginAction(); if (Configuration.RepairAnything && ((Character)__instance).InPlaceMode() && !Object.op_Implicit((Object)(object)__instance.GetHoveringPiece())) { RepairAnything(__instance); } } private static void Finalizer(ItemData toolItem) { UndoHelper.EndAction(); HideEffects.Active = false; Hammer.RestoreToolCosts(toolItem); } private static bool RepairPlayer(ZNetView obj) { Player component = ((Component)obj).GetComponent<Player>(); if (!Object.op_Implicit((Object)(object)component)) { return false; } float num = ((Character)component).GetMaxHealth() - ((Character)component).GetHealth(); if (num == 0f) { return false; } ((Character)component).Heal(num, true); return true; } public static bool RepairStructure(ZNetView obj) { WearNTear component = ((Component)obj).GetComponent<WearNTear>(); if (!Object.op_Implicit((Object)(object)component) || Time.time - component.m_lastRepair < 1f) { return false; } bool flag = RepairShared(obj); if (flag) { component.m_lastRepair = Time.time; obj.InvokeRPC(ZNetView.Everybody, "RPC_HealthChanged", new object[1] { obj.GetZDO().GetFloat(ZDOVars.s_health, component.m_health) }); } return flag; } private static bool RepairMineRock(ZNetView obj, MineRock5 mineRock, int index) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) HitArea hitArea = mineRock.GetHitArea(index); obj.ClaimOwnership(); obj.GetZDO(); float num = ((Configuration.OverwriteHealth > 0f) ? Configuration.OverwriteHealth : mineRock.m_health); float num2 = num - hitArea.m_health; Bounds bounds; if (num2 != 0f) { hitArea.m_health = num; mineRock.SaveHealth(); DamageText instance = DamageText.instance; int num3 = ((num2 > 0f) ? 4 : 2); bounds = hitArea.m_collider.bounds; instance.ShowText((TextType)num3, ((Bounds)(ref bounds)).center, Mathf.Abs(num2), false); return true; } HitArea val = mineRock.m_hitAreas.Find((HitArea area) => area.m_health <= 0f); if (val != null) { val.m_health = num; mineRock.SaveHealth(); mineRock.UpdateMesh(); DamageText instance2 = DamageText.instance; bounds = val.m_collider.bounds; instance2.ShowText((TextType)4, ((Bounds)(ref bounds)).center, num, false); return true; } return false; } private static bool RepairShared(ZNetView obj) { //IL_0034: 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) obj.ClaimOwnership(); float num = CustomHealth.SetHealth(obj, isRepair: true); if (num == 0f) { return false; } if (num == float.PositiveInfinity || num == float.NegativeInfinity) { DamageText.instance.ShowText((TextType)4, ((Component)obj).transform.position, num, false); } else { DamageText.instance.ShowText((TextType)((num > 0f) ? 4 : 2), ((Component)obj).transform.position, Mathf.Abs(num), false); } return true; } private static bool RepairInArea(ZDO zdo, float radius) { //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) if (radius == 0f) { return false; } Vector3 position = zdo.m_position; int prefab = zdo.m_prefab; ZNetView[] array = ZNetScene.instance.m_instances.Values.Where((ZNetView view) => Object.op_Implicit((Object)(object)view) && view.IsValid() && view.GetZDO().m_prefab == prefab && Vector3.Distance(position, view.GetZDO().m_position) < radius).ToArray(); bool flag = false; ZNetView[] array2 = array; foreach (ZNetView obj in array2) { flag |= RepairObject(obj, 0); } return flag; } private static bool RepairObject(ZNetView obj, int index) { if (Object.op_Implicit((Object)(object)((Component)obj).GetComponent<Player>())) { return RepairPlayer(obj); } MineRock5 mineRock = default(MineRock5); if (Configuration.Invulnerability == "Off" && ((Component)obj).TryGetComponent<MineRock5>(ref mineRock)) { return RepairMineRock(obj, mineRock, index); } return RepairShared(obj); } private static bool RepairAnything(Player player) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) float num = ((Configuration.Range > 0f) ? Configuration.Range : player.m_maxPlaceDistance); Hovered hovered = Selector.GetHovered(player, num, Array.Empty<string>(), Array.Empty<string>(), true); if (hovered == null) { return false; } ZNetView obj = hovered.Obj; UndoHelper.AddEditAction(obj.GetZDO()); if (!RepairObject(obj, hovered.Index)) { return false; } Piece component = ((Component)obj).GetComponent<Piece>(); string text = (Object.op_Implicit((Object)(object)component) ? component.m_name : Utils.GetPrefabName(((Component)obj).gameObject)); if (component != null) { component.m_placeEffect.Create(((Component)obj).transform.position, ((Component)obj).transform.rotation, (Transform)null, 1f, -1); } ((Character)player).Message((MessageType)1, Localization.instance.Localize("$msg_repaired", new string[1] { text }), 0, (Sprite)null); ItemData rightItem = ((Humanoid)player).GetRightItem(); if (rightItem != null) { player.FaceLookDirection(); ((Character)player).m_zanim.SetTrigger(rightItem.m_shared.m_attack.m_attackAnimation); ((Character)player).UseStamina(rightItem.m_shared.m_attack.m_attackStamina); ((Character)player).UseEitr(rightItem.m_shared.m_attack.m_attackEitr); if (rightItem.m_shared.m_useDurability) { rightItem.m_durability -= rightItem.m_shared.m_useDurabilityDrain; } } return true; } } [HarmonyPatch(typeof(Player), "UpdateWearNTearHover")] public class UnlockRepairDistance { private static void Prefix(Player __instance, ref float __state) { __state = __instance.m_maxPlaceDistance; if (Configuration.Range > 0f) { __instance.m_maxPlaceDistance = Configuration.Range; } } private static void Postfix(Player __instance, float __state) { __instance.m_maxPlaceDistance = __state; } } [HarmonyPatch(typeof(WearNTear), "Repair")] public class AdvancedRepair { public static bool Prefix(WearNTear __instance, ref bool __result) { if (!Configuration.Enabled || !Object.op_Implicit((Object)(object)__instance.m_nview)) { return true; } ZDO zDO = __instance.m_nview.GetZDO(); bool num = Configuration.OverwriteHealth > 0f || Configuration.Invulnerability != "Off"; bool flag = zDO.GetFloat(CustomHealth.HashMaxHealth, 0f) != 0f; if (!num && !flag) { return true; } __result = Repair.RepairStructure(__instance.m_nview); return false; } } [HarmonyPatch(typeof(Player), "HaveRequirements", new Type[] { typeof(Piece), typeof(RequirementMode) })] public class HaveRequirements { public static bool Prefix(ref bool __result) { if (Configuration.NoCost) { __result = true; return false; } return true; } } [HarmonyPatch(typeof(Player), "ConsumeResources")] public class ConsumeResources { private static bool Prefix() { return !Configuration.NoCost; } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] public class UnlockPlacement { public static void Prefix(Player __instance) { if (Object.op_Implicit((Object)(object)__instance.m_placementGhost)) { Piece component = __instance.m_placementGhost.GetComponent<Piece>(); if (Configuration.AllowInDungeons) { component.m_allowedInDungeons = true; } } } public static void Finalizer(Player __instance) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0025: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Invalid comparison between Unknown and I4 //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)__instance.m_placementGhost) && __instance.m_placementGhost.activeSelf) { PlacementStatus placementStatus = __instance.m_placementStatus; if ((int)placementStatus != 3 && (int)placementStatus != 11 && (int)placementStatus != 4 && Configuration.IgnoreOtherRestrictions) { __instance.m_placementStatus = (PlacementStatus)0; __instance.SetPlacementGhostValid(true); } } } } [HarmonyPatch(typeof(Location), "IsInsideNoBuildLocation")] [HarmonyPriority(0)] public class IsInsideNoBuildLocation { private static bool Postfix(bool result) { if (Configuration.IgnoreNoBuild) { return false; } return result; } } [HarmonyPatch(typeof(PrivateArea), "CheckAccess")] [HarmonyPriority(0)] public class CheckAccess { private static bool Prefix(ref bool __result) { if (Configuration.IgnoreWards) { __result = true; } return !Configuration.IgnoreWards; } } [HarmonyPatch(typeof(Player), "CheckCanRemovePiece")] [HarmonyPriority(0)] public class CheckCanRemovePiece { private static bool Prefix(ref bool __result) { if (Configuration.NoCost) { __result = true; } return !Configuration.NoCost; } } public class Scaling { private static readonly ScalingData PieceScaling = new ScalingData(sanityY: true, minXZ: false, printChanges: true, Vector3.one); private static readonly ScalingData ToolScaling = new ScalingData(sanityY: false, minXZ: true, printChanges: false, new Vector3(10f, 0f, 10f)); public static Vector3 Value => Get().Vec3; public static void Set(Vector3 value) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Get().SetScale(value); } public static void Set(GameObject value) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) Get().SetScale(value.transform.localScale); } public static void Print(Terminal terminal) { Get().Print(terminal); } public static ScalingData Get() { if (!Selection.Get().IsTool) { return PieceScaling; } return ToolScaling; } public static ScalingData Get(bool tool) { if (!tool) { return PieceScaling; } return ToolScaling; } } public class ScalingData { private readonly bool OnlyPositiveHeight; private readonly bool MinXZ; private Vector3 Value; private readonly bool PrintChanges; public Vector3 Vec3 => Value; public float X { get { if (!MinXZ) { return Value.x; } return Mathf.Max(0.25f, Value.x); } } public float Y => Value.y; public float Z { get { if (!MinXZ) { return Value.z; } return Mathf.Max(0.25f, Value.z); } } public ScalingData(bool sanityY, bool minXZ, bool printChanges, Vector3 value) { //IL_000f: 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) OnlyPositiveHeight = sanityY; MinXZ = minXZ; Value = value; PrintChanges = printChanges; base..ctor(); } public void Print(Terminal terminal) { if (PrintChanges && !Configuration.DisableScaleMessages) { if (X != Y || X != Z) { HammerHelper.Message(terminal, $"Scale set to X: {X:P0}, Z: {Z:P0}, Y: {Y:P0}."); } else { HammerHelper.Message(terminal, $"Scale set to {Y:P0}."); } } } private void Sanity() { Value.x = Mathf.Max(0f, Value.x); if (OnlyPositiveHeight) { Value.y = Mathf.Max(0f, Value.y); } Value.z = Mathf.Max(0f, Value.z); Value.x = Helper.Round(Value.x); Value.y = Helper.Round(Value.y); Value.z = Helper.Round(Value.z); } public void SetPrecisionXZ(float min, float precision) { Value.x = min + precision * Mathf.Floor((Value.x - min) / precision); Value.z = min + precision * Mathf.Floor((Value.z - min) / precision); AfterScaling(); } public void Zoom(float amount, float percentage) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0049: 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) //IL_0023: 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_0034: Unknown result type (might be due to invalid IL or missing references) Value += new Vector3(amount, amount, amount); if (percentage < 0f) { Value /= 1f - percentage; } else { Value *= 1f + percentage; } Sanity(); AfterScaling(); } public void ZoomX(float amount, float percentage) { Value.x += amount; if (percentage < 0f) { Value.x /= 1f - percentage; } else { Value.x *= 1f + percentage; } Sanity(); AfterScaling(); } public void ZoomY(float amount, float percentage) { Value.y += amount; if (percentage < 0f) { Value.y /= 1f - percentage; } else { Value.y *= 1f + percentage; } Sanity(); AfterScaling(); } public void ZoomZ(float amount, float percentage) { Value.z += amount; if (percentage < 0f) { Value.z /= 1f - percentage; } else { Value.z *= 1f + percentage; } Sanity(); AfterScaling(); } public void SetScale(float value) { //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_000c: Unknown result type (might be due to invalid IL or missing references) Value = value * Vector3.one; Sanity(); AfterScaling(); } public void SetScaleX(float value) { Value.x = value; Sanity(); AfterScaling(); } public void SetScaleY(float value) { Value.y = value; Sanity(); AfterScaling(); } public void SetScaleZ(float value) { Value.z = value; Sanity(); AfterScaling(); } public void SetScale(Vector3 value) { //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) Value = value; Sanity(); AfterScaling(); } private void AfterScaling() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) Player player = Helper.GetPlayer(); if (Object.op_Implicit((Object)(object)player.m_placementGhost)) { player.m_placementGhost.transform.localScale = Value; } } } [HarmonyPatch(typeof(BaseAI), "Awake")] public class BaseAIAwake { private static bool Prefix() { return !ZNetView.m_forceDisableInit; } } [HarmonyPatch(typeof(DungeonGenerator), "Awake")] public class DungeonGeneratorAwake { private static bool Prefix() { return !ZNetView.m_forceDisableInit; } } [HarmonyPatch(typeof(TreeBase), "Awake")] public class TreeBaseAwake { private static bool Prefix() { return !ZNetView.m_forceDisableInit; } } [HarmonyPatch(typeof(TreeLog), "Awake")] public class TreeLogAwake { private static bool Prefix() { return !ZNetView.m_forceDisableInit; } } [HarmonyPatch(typeof(MonsterAI), "Awake")] public class MonsterAIAwake { private static bool Prefix() { return !ZNetView.m_forceDisableInit; } } [HarmonyPatch(typeof(TombStone), "Awake")] public class TombStoneAwake { private static bool Prefix() { return !ZNetView.m_forceDisableInit; } } [HarmonyPatch(typeof(LocationProxy), "Awake")] public class LocationProxyAwake { private static bool Prefix() { return !ZNetView.m_forceDisableInit; } } [HarmonyPatch(typeof(Character), "Awake")] public class CharacterAwake { private static void Postfix(Character __instance) { if (ZNetView.m_forceDisableInit) { Character.s_characters.Remove(__instance); } } } [HarmonyPatch(typeof(MineRock5), "Awake")] public class MineRock5_NameFix { private static void Prefix(MineRock5 __instance, ref string __state) { __state = ((Object)__instance).name; } private static void Postfix(MineRock5 __instance, string __state) { ((Object)__instance).name = __state; } } public class SelectedObject { public int Prefab; public DataEntry? Data; public bool Scalable; public SelectedObject(int prefab, bool scalable, DataEntry? data) { Prefab = prefab; Data = data; Scalable = scalable; base..ctor(); } } public static class Selection { public static BaseSelection BaseSelection = new BaseSelection(); public static Dictionary<string, BaseSelection> Selections = new Dictionary<string, BaseSelection>(); public static BaseSelection Get() { if (!Selections.TryGetValue(HammerHelper.GetTool(), out BaseSelection value)) { return BaseSelection; } return value; } public static void Clear() { if (Configuration.UnfreezeOnSelect) { Position.Unfreeze(); } if (Selections.TryGetValue(HammerHelper.GetTool(), out BaseSelection value)) { value.Deactivate(); value.Destroy(); Selections.Remove(HammerHelper.GetTool()); } } public static void Destroy() { foreach (BaseSelection value in Selections.Values) { value.Deactivate(); value.Destroy(); } Selections.Clear(); } public static GameObject CreateGhost(BaseSelection selection) { Clear(); selection.Activate(); Selections[HammerHelper.GetTool()] = selection; Player player = Helper.GetPlayer(); player.SetupPlacementGhost(); return player.m_placementGhost; } } [HarmonyPatch(typeof(VisEquipment), "SetItem")] public class SetItemHack { public static bool Hack; private static void SetItem(VisEquipment obj, VisSlot slot, string name, int variant) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected I4, but got Unknown switch ((int)slot) { case 0: obj.m_leftItem = name; obj.m_leftItemVariant = variant; break; case 1: obj.m_rightItem = name; break; case 2: obj.m_leftBackItem = name; obj.m_leftBackItemVariant = variant; break; case 3: obj.m_rightBackItem = name; break; case 4: obj.m_chestItem = name; break; case 5: obj.m_legItem = name; break; case 6: obj.m_helmetItem = name; break; case 7: obj.m_shoulderItem = name; obj.m_shoulderItemVariant = variant; break; case 8: obj.m_utilityItem = name; break; case 9: obj.m_beardItem = name; break; case 10: obj.m_hairItem = name; break; } } private static bool Prefix(VisEquipment __instance, VisSlot slot, string name, int variant) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (Hack) { SetItem(__instance, slot, name, variant); } return !Hack; } } [HarmonyPatch(typeof(PieceTable), "SetSelected")] public class PieceTableSetSelected { private static void Prefix() { Selection.Clear(); } private static void Postfix(PieceTable __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) Vector2Int selectedIndex = __instance.GetSelectedIndex(); Piece piece = __instance.GetPiece(__instance.GetSelectedCategory(), selectedIndex); if (Object.op_Implicit((Object)(object)piece) && Object.op_Implicit((Object)(object)((Component)piece).GetComponent<ZNetView>())) { Selection.CreateGhost(new ObjectSelection(piece, singleUse: false)); } } } [HarmonyPatch(typeof(PieceTable), "SetCategory")] public class PieceTableSetCategory { private static void Prefix() { Se