Decompiled source of Infinity Hammer v1.53.0
InfinityHammer.dll
Decompiled 2 weeks 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.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 HarmonyLib; using Microsoft.CodeAnalysis; using ServerDevcommands; using Service; using TMPro; using UnityEngine; [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")] [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", "true", "yes", "on" }; private static readonly HashSet<string> Falsies = new HashSet<string> { "0", "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) { args.Context.TryRunCommand(command2() + " " + string.Join(" ", args.Args, 1, args.Length - 1), 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) { args.Context.TryRunCommand(command2() + " " + string.Join(" ", args.Args, 1, args.Length - 1), 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_0027: 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) if (!Object.op_Implicit((Object)(object)Chat.instance)) { BindsDone = false; return; } List<string> list = new List<string> { "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; } setting.Value = (T)(object)value; AddMessage(context, name + " set to " + value + "."); } } public static class Hash { public static int BuildingSkillLevel = StringExtensionMethods.GetStableHashCode("BuildingSkill Level"); public static int OverrideItems = StringExtensionMethods.GetStableHashCode("override_items"); public static int Wear = StringExtensionMethods.GetStableHashCode("override_wear"); public static int Fall = StringExtensionMethods.GetStableHashCode("override_fall"); public static int Growth = StringExtensionMethods.GetStableHashCode("override_growth"); public static int Interact = StringExtensionMethods.GetStableHashCode("override_interact"); public static int Restrict = StringExtensionMethods.GetStableHashCode("override_restrict"); public static int Render = StringExtensionMethods.GetStableHashCode("override_render"); public static int Collision = StringExtensionMethods.GetStableHashCode("override_collision"); public static int Portal = StringExtensionMethods.GetStableHashCode("portal_wood"); } 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); } } public static class Parse2 { private static readonly HashSet<string> Truthies = new HashSet<string> { "1", "true", "yes", "on" }; private static readonly HashSet<string> Falsies = new HashSet<string> { "0", "false", "no", "off" }; private static Range<string> TryRange(string arg) { List<string> list = arg.Split(new char[1] { '-' }).ToList(); if (list.Count > 1 && list[0] == "") { list[0] = "-" + list[1]; list.RemoveAt(1); } if (list.Count > 2 && list[1] == "") { list[1] = "-" + list[2]; list.RemoveAt(2); } if (list.Count == 1) { return new Range<string>(list[0]); } return new Range<string>(list[0], list[1]); } public static int TryInt(string arg, int defaultValue = 0) { if (!int.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return defaultValue; } return result; } public static int TryInt(string[] args, int index, int defaultValue = 0) { if (args.Length <= index) { return defaultValue; } return TryInt(args[index], defaultValue); } public static Range<int> TryIntRange(string arg, int defaultValue = 0) { Range<string> val = TryRange(arg); return new Range<int>(TryInt(val.Min, defaultValue), TryInt(val.Max, defaultValue)); } public static Range<int> TryIntRange(string[] args, int index, int defaultValue = 0) { if (args.Length <= index) { return new Range<int>(defaultValue); } return TryIntRange(args[index], defaultValue); } public static uint TryUInt(string arg, uint defaultValue = 0u) { if (!uint.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return defaultValue; } return result; } public static uint TryUInt(string[] args, int index, uint defaultValue = 0u) { if (args.Length <= index) { return defaultValue; } return TryUInt(args[index], defaultValue); } public static Range<uint> TryUIntRange(string arg, uint defaultValue = 0u) { Range<string> val = TryRange(arg); return new Range<uint>(TryUInt(val.Min, defaultValue), TryUInt(val.Max, defaultValue)); } public static Range<uint> TryUIntRange(string[] args, int index, uint defaultValue = 0u) { if (args.Length <= index) { return new Range<uint>(defaultValue); } return TryUIntRange(args[index], defaultValue); } public static long TryLong(string arg, long defaultValue = 1L) { if (!long.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return defaultValue; } return result; } public static long TryLong(string[] args, int index, long defaultValue = 1L) { if (args.Length <= index) { return defaultValue; } return TryLong(args[index], defaultValue); } public static Range<long> TryLongRange(string arg, long defaultValue = 1L) { Range<string> val = TryRange(arg); return new Range<long>(TryLong(val.Min, defaultValue), TryLong(val.Max, defaultValue)); } public static Range<long> TryLongRange(string[] args, int index, long defaultValue = 1L) { if (args.Length <= index) { return new Range<long>(defaultValue); } return TryLongRange(args[index], defaultValue); } public static float TryFloat(string arg, float defaultValue = 1f) { if (!float.TryParse(arg, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return defaultValue; } return result; } public static float? TryFloatNull(string arg) { if (!float.TryParse(arg, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return null; } return result; } public static float TryFloat(string[] args, int index, float defaultValue = 1f) { if (args.Length <= index) { return defaultValue; } return TryFloat(args[index], defaultValue); } public static Range<float> TryFloatRange(string arg, float defaultValue = 1f) { Range<string> val = TryRange(arg); return new Range<float>(TryFloat(val.Min, defaultValue), TryFloat(val.Max, defaultValue)); } public static Range<float?> TryFloatNullRange(string arg) { Range<string> val = TryRange(arg); return new Range<float?>(TryFloatNull(val.Min), TryFloatNull(val.Max)); } public static Range<float> TryFloatRange(string[] args, int index, float defaultValue = 1f) { if (args.Length <= index) { return new Range<float>(defaultValue); } return TryFloatRange(args[index], defaultValue); } public static string String(string arg) { return arg; } public static string TryString(string[] args, int index, string defaultValue = "") { if (args.Length <= index) { return defaultValue; } return args[index]; } private static bool IsTruthy(string value) { return Truthies.Contains(value); } private static bool IsFalsy(string value) { return Falsies.Contains(value); } public static bool? Boolean(string arg) { if (IsTruthy(arg)) { return true; } if (IsFalsy(arg)) { return false; } return null; } public static Quaternion TryAngleYXZ(string arg) { //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) return TryAngleYXZ(arg, Quaternion.identity); } public static Quaternion TryAngleYXZ(string arg, Quaternion defaultValue) { //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) //IL_0015: 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_0049: 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) //IL_005e: Unknown result type (might be due to invalid IL or missing references) string[] args = Split(arg); Vector3 zero = Vector3.zero; zero.y = TryFloat(args, 0, ((Quaternion)(ref defaultValue)).eulerAngles.y); zero.x = TryFloat(args, 1, ((Quaternion)(ref defaultValue)).eulerAngles.x); zero.z = TryFloat(args, 2, ((Quaternion)(ref defaultValue)).eulerAngles.z); return Quaternion.Euler(zero); } public static Range<Quaternion> TryAngleYXZRange(string arg) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return TryAngleYXZRange(arg, Quaternion.identity); } public static Range<Quaternion> TryAngleYXZRange(string arg, Quaternion defaultValue) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) string[] args = Split(arg); Range<float> y = TryFloatRange(args, 0, defaultValue.y); Range<float> x = TryFloatRange(args, 1, defaultValue.x); Range<float> z = TryFloatRange(args, 2, defaultValue.z); return ToAngleRange(x, y, z); } private static Range<Quaternion> ToAngleRange(Range<float> x, Range<float> y, Range<float> z) { //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) //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.Euler(new Vector3(x.Min, y.Min, z.Min)); Quaternion val2 = Quaternion.Euler(new Vector3(x.Max, y.Max, z.Max)); return new Range<Quaternion>(val, val2); } public static Vector3 TryVectorXZY(string[] args) { //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) return TryVectorXZY(args, 0, Vector3.zero); } public static Vector3 TryVectorXZY(string[] args, Vector3 defaultValue) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return TryVectorXZY(args, 0, defaultValue); } public static Vector3 TryVectorXZY(string[] args, int index) { //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) return TryVectorXZY(args, index, Vector3.zero); } public static Vector3 TryVectorXZY(string[] args, int index, Vector3 defaultValue) { //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0046: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; zero.x = TryFloat(args, index, defaultValue.x); zero.y = TryFloat(args, index + 2, defaultValue.y); zero.z = TryFloat(args, index + 1, defaultValue.z); return zero; } public static Range<Vector3> TryVectorXZYRange(string arg, Vector3 defaultValue) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) string[] args = Split(arg); Range<float> x = TryFloatRange(args, 0, defaultValue.x); Range<float> y = TryFloatRange(args, 2, defaultValue.y); Range<float> z = TryFloatRange(args, 1, defaultValue.z); return ToVectorRange(x, y, z); } public static Vector3 TryVectorZXY(string[] args) { //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) return TryVectorZXY(args, 0, Vector3.zero); } public static Vector3 TryVectorZXY(string[] args, Vector3 defaultValue) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return TryVectorZXY(args, 0, defaultValue); } public static Vector3 TryVectorZXY(string[] args, int index) { //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) return TryVectorZXY(args, index, Vector3.zero); } public static Vector3 TryVectorZXY(string[] args, int index, Vector3 defaultValue) { //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_000c: 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_0036: 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) Vector3 zero = Vector3.zero; zero.x = TryFloat(args, index + 1, defaultValue.x); zero.y = TryFloat(args, index + 2, defaultValue.y); zero.z = TryFloat(args, index, defaultValue.z); return zero; } public static Range<Vector3> TryVectorZXYRange(string arg, Vector3 defaultValue) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) string[] args = Split(arg); Range<float> x = TryFloatRange(args, 1, defaultValue.x); Range<float> y = TryFloatRange(args, 2, defaultValue.y); Range<float> z = TryFloatRange(args, 0, defaultValue.z); return ToVectorRange(x, y, z); } private static Range<Vector3> ToVectorRange(Range<float> x, Range<float> y, Range<float> z) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Vector3 val = new Vector3(x.Min, y.Min, z.Min); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(x.Max, y.Max, z.Max); return new Range<Vector3>(val, val2); } public static Vector3 TryVectorYXZ(string[] args) { //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) return TryVectorYXZ(args, 0, Vector3.zero); } public static Vector3 TryVectorYXZ(string[] args, Vector3 defaultValue) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return TryVectorYXZ(args, 0, defaultValue); } public static Vector3 TryVectorYXZ(string[] args, int index) { //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) return TryVectorYXZ(args, index, Vector3.zero); } public static Vector3 TryVectorYXZ(string[] args, int index, Vector3 defaultValue) { //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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0046: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; zero.y = TryFloat(args, index, defaultValue.y); zero.x = TryFloat(args, index + 1, defaultValue.x); zero.z = TryFloat(args, index + 2, defaultValue.z); return zero; } public static Range<Vector3> TryVectorYXZRange(string arg, Vector3 defaultValue) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) string[] args = Split(arg); Range<float> x = TryFloatRange(args, 1, defaultValue.x); Range<float> y = TryFloatRange(args, 0, defaultValue.y); Range<float> z = TryFloatRange(args, 2, defaultValue.z); return ToVectorRange(x, y, z); } public static Vector3 TryScale(string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return TryScale(args, 0); } public static Vector3 TryScale(string[] args, int index) { //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) return SanityCheck(TryVectorXZY(args, index)); } private static Vector3 SanityCheck(Vector3 scale) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) if (scale.x == 0f) { scale.x = 1f; } if (scale.y == 0f) { scale.y = scale.x; } if (scale.z == 0f) { scale.z = scale.x; } return scale; } public static Range<Vector3> TryScaleRange(string arg) { //IL_0038: 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_0042: 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_0053: Unknown result type (might be due to invalid IL or missing references) string[] args = Split(arg); Range<float> x = TryFloatRange(args, 0, 0f); Range<float> y = TryFloatRange(args, 1, 0f); Range<float> z = TryFloatRange(args, 2, 0f); Range<Vector3> obj = ToVectorRange(x, y, z); obj.Min = SanityCheck(obj.Min); obj.Max = SanityCheck(obj.Max); return obj; } public static string[] Split(string arg, char separator = ',') { return (from s in arg.Split(new char[1] { separator }) select s.Trim()).ToArray(); } public static string[] TrySplit(string[] args, int index, char separator) { if (args.Length <= index) { return new string[0]; } return Split(args[index], separator); } public static float Direction(string value) { if (TryFloat(value) > 0f) { return 1f; } return -1f; } public static Vector3Int ParseXYZInt(string 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_0058: Unknown result type (might be due to invalid IL or missing references) Vector3Int zero = Vector3Int.zero; string[] array = value.Split(new char[1] { ',' }); if (array.Length != 0) { ((Vector3Int)(ref zero)).x = TryInt(array[0]); } if (array.Length > 1) { ((Vector3Int)(ref zero)).y = TryInt(array[1]); } if (array.Length > 2) { ((Vector3Int)(ref zero)).z = TryInt(array[2]); } return zero; } } public class FakeZDO { private readonly ZDOData Data = new ZDOData(zdo); public readonly ZDO Source = zdo.Clone(); public int Prefab => Source.m_prefab; public Vector3 Position => Source.m_position; public FakeZDO(ZDO zdo) { } public ZDO Create() { //IL_0006: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) ZDO val = ZDOMan.instance.CreateNewZDO(Position, Prefab); val.m_prefab = Source.m_prefab; val.m_position = Source.m_position; val.m_rotation = Source.m_rotation; val.Type = Source.Type; val.Distant = Source.Distant; val.Persistent = Source.Persistent; Data.Copy(val); val.DataRevision = 0u; val.IncreaseDataRevision(); return val; } } public class ZDOData { public Dictionary<int, string> Strings = new Dictionary<int, string>(); public Dictionary<int, float> Floats = new Dictionary<int, float>(); public Dictionary<int, int> Ints = new Dictionary<int, int>(); public Dictionary<int, long> Longs = new Dictionary<int, long>(); public Dictionary<int, Vector3> Vecs = new Dictionary<int, Vector3>(); public Dictionary<int, Quaternion> Quats = new Dictionary<int, Quaternion>(); public Dictionary<int, byte[]> ByteArrays = new Dictionary<int, byte[]>(); public ConnectionType ConnectionType; public int ConnectionHash; public ZDOData() { } public ZDOData(ZDO zdo) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = zdo.m_uid; Floats = (ZDOExtraData.s_floats.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, float>>)ZDOExtraData.s_floats[uid]).ToDictionary((KeyValuePair<int, float> kvp) => kvp.Key, (KeyValuePair<int, float> kvp) => kvp.Value) : new Dictionary<int, float>()); Ints = (ZDOExtraData.s_ints.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, int>>)ZDOExtraData.s_ints[uid]).ToDictionary((KeyValuePair<int, int> kvp) => kvp.Key, (KeyValuePair<int, int> kvp) => kvp.Value) : new Dictionary<int, int>()); Longs = (ZDOExtraData.s_longs.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, long>>)ZDOExtraData.s_longs[uid]).ToDictionary((KeyValuePair<int, long> kvp) => kvp.Key, (KeyValuePair<int, long> kvp) => kvp.Value) : new Dictionary<int, long>()); Strings = (ZDOExtraData.s_strings.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, string>>)ZDOExtraData.s_strings[uid]).ToDictionary((KeyValuePair<int, string> kvp) => kvp.Key, (KeyValuePair<int, string> kvp) => kvp.Value) : new Dictionary<int, string>()); Vecs = (ZDOExtraData.s_vec3.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, Vector3>>)ZDOExtraData.s_vec3[uid]).ToDictionary((KeyValuePair<int, Vector3> kvp) => kvp.Key, (KeyValuePair<int, Vector3> kvp) => kvp.Value) : new Dictionary<int, Vector3>()); Quats = (ZDOExtraData.s_quats.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, Quaternion>>)ZDOExtraData.s_quats[uid]).ToDictionary((KeyValuePair<int, Quaternion> kvp) => kvp.Key, (KeyValuePair<int, Quaternion> kvp) => kvp.Value) : new Dictionary<int, Quaternion>()); ByteArrays = (ZDOExtraData.s_byteArrays.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, byte[]>>)ZDOExtraData.s_byteArrays[uid]).ToDictionary((KeyValuePair<int, byte[]> kvp) => kvp.Key, (KeyValuePair<int, byte[]> kvp) => kvp.Value) : new Dictionary<int, byte[]>()); if (ZDOExtraData.s_connectionsHashData.TryGetValue(uid, out var value)) { ConnectionType = value.m_type; ConnectionHash = value.m_hash; } } public ZDOData(ZPackage? pkg) { if (pkg != null) { Load(pkg); } } public void Add(ZDOData data) { //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<int, float> @float in data.Floats) { Floats[@float.Key] = @float.Value; } foreach (KeyValuePair<int, int> @int in data.Ints) { Ints[@int.Key] = @int.Value; } foreach (KeyValuePair<int, long> @long in data.Longs) { Longs[@long.Key] = @long.Value; } foreach (KeyValuePair<int, string> @string in data.Strings) { Strings[@string.Key] = @string.Value; } foreach (KeyValuePair<int, Vector3> vec in data.Vecs) { Vecs[vec.Key] = vec.Value; } foreach (KeyValuePair<int, Quaternion> quat in data.Quats) { Quats[quat.Key] = quat.Value; } foreach (KeyValuePair<int, byte[]> byteArray in data.ByteArrays) { ByteArrays[byteArray.Key] = byteArray.Value; } if ((int)data.ConnectionType != 0 && data.ConnectionHash != 0) { ConnectionType = data.ConnectionType; ConnectionHash = data.ConnectionHash; } } public bool HasData() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (Floats.Count <= 0 && Ints.Count <= 0 && Longs.Count <= 0 && Strings.Count <= 0 && Vecs.Count <= 0 && Quats.Count <= 0 && ByteArrays.Count <= 0) { if ((int)ConnectionType != 0) { return ConnectionHash != 0; } return false; } return true; } public void Copy(ZDO zdo) { //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_001a: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = zdo.m_uid; if (Floats.Count > 0) { ZDOHelper.Release<float>(ZDOExtraData.s_floats, uid); foreach (KeyValuePair<int, float> @float in Floats) { ZDOExtraData.Set(uid, @float.Key, @float.Value); } } if (Ints.Count > 0) { ZDOHelper.Release<int>(ZDOExtraData.s_ints, uid); foreach (KeyValuePair<int, int> @int in Ints) { ZDOExtraData.Set(uid, @int.Key, @int.Value); } } if (Longs.Count > 0) { ZDOHelper.Release<long>(ZDOExtraData.s_longs, uid); foreach (KeyValuePair<int, long> @long in Longs) { ZDOExtraData.Set(uid, @long.Key, @long.Value); } } if (Strings.Count > 0) { ZDOHelper.Release<string>(ZDOExtraData.s_strings, uid); foreach (KeyValuePair<int, string> @string in Strings) { ZDOExtraData.Set(uid, @string.Key, @string.Value); } } if (Vecs.Count > 0) { ZDOHelper.Release<Vector3>(ZDOExtraData.s_vec3, uid); foreach (KeyValuePair<int, Vector3> vec in Vecs) { ZDOExtraData.Set(uid, vec.Key, vec.Value); } } if (Quats.Count > 0) { ZDOHelper.Release<Quaternion>(ZDOExtraData.s_quats, uid); foreach (KeyValuePair<int, Quaternion> quat in Quats) { ZDOExtraData.Set(uid, quat.Key, quat.Value); } } if (ByteArrays.Count > 0) { ZDOHelper.Release<byte[]>(ZDOExtraData.s_byteArrays, uid); foreach (KeyValuePair<int, byte[]> byteArray in ByteArrays) { ZDOExtraData.Set(uid, byteArray.Key, byteArray.Value); } } if ((int)ConnectionType != 0 && ConnectionHash != 0) { ZDOExtraData.SetConnectionData(uid, ConnectionType, ConnectionHash); } } public string GetString(int hash, string defautlValue = "") { if (!Strings.TryGetValue(hash, out string value)) { return defautlValue; } return value; } public string GetString(string key, string defautlValue = "") { return GetString(StringExtensionMethods.GetStableHashCode(key), defautlValue); } public void Set(int hash, string value) { Strings[hash] = value; } public void Set(string key, string value) { Set(StringExtensionMethods.GetStableHashCode(key), value); } public float GetFloat(int hash, float defautlValue = 0f) { if (!Floats.TryGetValue(hash, out var value)) { return defautlValue; } return value; } public void Set(int hash, float value) { Floats[hash] = value; } public int GetInt(int hash, int defautlValue = 0) { if (!Ints.TryGetValue(hash, out var value)) { return defautlValue; } return value; } public int GetInt(string key, int defautlValue = 0) { return GetInt(StringExtensionMethods.GetStableHashCode(key), defautlValue); } public void Set(int hash, int value) { Ints[hash] = value; } public void Set(string key, int value) { Set(StringExtensionMethods.GetStableHashCode(key), value); } public void Set(int hash, bool value) { Ints[hash] = (value ? 1 : 0); } public long GetLong(int hash, long defautlValue = 0L) { if (!Longs.TryGetValue(hash, out var value)) { return defautlValue; } return value; } public ZDOID GetZDOID(KeyValuePair<int, int> hashPair) { //IL_0027: 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) long @long = GetLong(hashPair.Key, 0L); uint num = (uint)GetLong(hashPair.Value, 0L); if (@long == 0L || num == 0) { return ZDOID.None; } return new ZDOID(@long, num); } public void Set(int hash, long value) { Longs[hash] = value; } public void Set(KeyValuePair<int, int> hashPair, ZDOID id) { Set(hashPair.Key, ((ZDOID)(ref id)).UserID); Set(hashPair.Value, (long)((ZDOID)(ref id)).ID); } public Vector3 GetVector(int hash, Vector3 defautlValue) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!Vecs.TryGetValue(hash, out var value)) { return defautlValue; } return value; } public void Set(int hash, Vector3 value) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Vecs[hash] = value; } public Quaternion GetQuaternion(int hash, Quaternion defautlValue) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!Quats.TryGetValue(hash, out var value)) { return defautlValue; } return value; } public void Set(int hash, Quaternion value) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Quats[hash] = value; } public byte[] GetByteArray(int hash, byte[] defautlValue) { if (!ByteArrays.TryGetValue(hash, out byte[] value)) { return defautlValue; } return value; } public void Set(int hash, byte[] value) { ByteArrays[hash] = value; } public ZPackage Save() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Expected I4, but got Unknown ZPackage val = new ZPackage(); Vecs.Remove(ZDOVars.s_scaleHash); Vecs.Remove(ZDOVars.s_spawnPoint); if (Strings.ContainsKey(Hash.OverrideItems)) { Ints.Remove(ZDOVars.s_addedDefaultItems); Strings.Remove(ZDOVars.s_items); } int num = 0; if (Floats.Count > 0) { num |= 1; } if (Vecs.Count > 0) { num |= 2; } if (Quats.Count > 0) { num |= 4; } if (Ints.Count > 0) { num |= 8; } if (Strings.Count > 0) { num |= 0x10; } if (Longs.Count > 0) { num |= 0x40; } if (ByteArrays.Count > 0) { num |= 0x80; } if ((int)ConnectionType != 0 && ConnectionHash != 0) { num |= 0x100; } val.Write(num); if (Floats.Count > 0) { val.Write((byte)Floats.Count); foreach (KeyValuePair<int, float> @float in Floats) { val.Write(@float.Key); val.Write(@float.Value); } } if (Vecs.Count > 0) { val.Write((byte)Vecs.Count); foreach (KeyValuePair<int, Vector3> vec in Vecs) { val.Write(vec.Key); val.Write(vec.Value); } } if (Quats.Count > 0) { val.Write((byte)Quats.Count); foreach (KeyValuePair<int, Quaternion> quat in Quats) { val.Write(quat.Key); val.Write(quat.Value); } } if (Ints.Count > 0) { val.Write((byte)Ints.Count); foreach (KeyValuePair<int, int> @int in Ints) { val.Write(@int.Key); val.Write(@int.Value); } } if (Longs.Count > 0) { val.Write((byte)Longs.Count); foreach (KeyValuePair<int, long> @long in Longs) { val.Write(@long.Key); val.Write(@long.Value); } } if (Strings.Count > 0) { val.Write((byte)Strings.Count); foreach (KeyValuePair<int, string> @string in Strings) { val.Write(@string.Key); val.Write(@string.Value); } } if (ByteArrays.Count > 0) { val.Write((byte)ByteArrays.Count); foreach (KeyValuePair<int, byte[]> byteArray in ByteArrays) { val.Write(byteArray.Key); val.Write(byteArray.Value); } } if (((uint)num & 0x100u) != 0) { val.Write((byte)(int)ConnectionType); val.Write(ConnectionHash); } return val; } public void Load(ZPackage pkg) { //IL_005b: 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_018f: Unknown result type (might be due to invalid IL or missing references) pkg.SetPos(0); int num = pkg.ReadInt(); if (((uint)num & (true ? 1u : 0u)) != 0) { byte b = pkg.ReadByte(); for (int i = 0; i < b; i++) { Floats[pkg.ReadInt()] = pkg.ReadSingle(); } } if (((uint)num & 2u) != 0) { byte b2 = pkg.ReadByte(); for (int j = 0; j < b2; j++) { Vecs[pkg.ReadInt()] = pkg.ReadVector3(); } } if (((uint)num & 4u) != 0) { byte b3 = pkg.ReadByte(); for (int k = 0; k < b3; k++) { Quats[pkg.ReadInt()] = pkg.ReadQuaternion(); } } if (((uint)num & 8u) != 0) { byte b4 = pkg.ReadByte(); for (int l = 0; l < b4; l++) { Ints[pkg.ReadInt()] = pkg.ReadInt(); } } if (((uint)num & 0x40u) != 0) { byte b5 = pkg.ReadByte(); for (int m = 0; m < b5; m++) { Longs[pkg.ReadInt()] = pkg.ReadLong(); } } if (((uint)num & 0x10u) != 0) { byte b6 = pkg.ReadByte(); for (int n = 0; n < b6; n++) { Strings[pkg.ReadInt()] = pkg.ReadString(); } } if (((uint)num & 0x80u) != 0) { byte b7 = pkg.ReadByte(); for (int num2 = 0; num2 < b7; num2++) { ByteArrays[pkg.ReadInt()] = pkg.ReadByteArray(); } } if (((uint)num & 0x100u) != 0) { ConnectionType = (ConnectionType)pkg.ReadByte(); ConnectionHash = pkg.ReadInt(); } } } } 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"); private static readonly int HashMaxHealth = StringExtensionMethods.GetStableHashCode("WearNTear.m_health"); public static bool SetHealth(ZNetView obj) { ZDO zDO = obj.GetZDO(); if (Configuration.Invulnerability == "Off" || Configuration.Invulnerability == "Legacy") { return SetCustomHealth(obj, zDO); } return SetInfiniteHealth(obj, zDO); } private static bool SetCustomHealth(ZNetView obj, ZDO zdo) { bool flag = false; float num = ((Configuration.Invulnerability == "Legacy") ? 1E+30f : Configuration.OverwriteHealth); if (num <= 0f) { return false; } if (Object.op_Implicit((Object)(object)((Component)obj).GetComponent<Character>())) { flag |= zdo.GetFloat(ZDOVars.s_maxHealth, 0f) != num; zdo.Set(ZDOVars.s_maxHealth, num); zdo.Set(ZDOVars.s_health, num * 1.000001f); } if (Object.op_Implicit((Object)(object)((Component)obj).GetComponent<Destructible>()) || Object.op_Implicit((Object)(object)((Component)obj).GetComponent<TreeBase>()) || Object.op_Implicit((Object)(object)((Component)obj).GetComponent<TreeLog>())) { flag |= zdo.GetFloat(ZDOVars.s_health, 0f) != num; zdo.Set(ZDOVars.s_health, num); } MineRock5 val = default(MineRock5); if (((Component)obj).TryGetComponent<MineRock5>(ref val)) { foreach (HitArea hitArea in val.m_hitAreas) { flag |= hitArea.m_health != num; hitArea.m_health = num; } val.SaveHealth(); } WearNTear val2 = default(WearNTear); if (((Component)obj).TryGetComponent<WearNTear>(ref val2)) { flag |= zdo.GetFloat(ZDOVars.s_health, 0f) != num; zdo.Set(ZDOVars.s_health, num); zdo.RemoveFloat(Hash.BuildingSkillLevel); val2.m_healthPercentage = num / val2.m_health; val2.SetHealthVisual(val2.m_healthPercentage, false); } return flag; } private static bool SetInfiniteHealth(ZNetView obj, ZDO zdo) { bool flag = false; if (Object.op_Implicit((Object)(object)((Component)obj).GetComponent<Destructible>())) { flag |= zdo.GetInt(HashToolTierDestructible, 0) != 1073741823; zdo.Set(HashFields, true); zdo.Set(HashFieldsDestructible, true); zdo.Set(HashToolTierDestructible, 1073741823, false); obj.LoadFields(); } if (Object.op_Implicit((Object)(object)((Component)obj).GetComponent<MineRock5>())) { flag |= zdo.GetInt(HashToolTierMineRock5, 0) != 1073741823; zdo.Set(HashFields, true); zdo.Set(HashFieldsMineRock5, true); zdo.Set(HashToolTierMineRock5, 1073741823, false); obj.LoadFields(); } if (Object.op_Implicit((Object)(object)((Component)obj).GetComponent<TreeBase>())) { flag |= zdo.GetInt(HashToolTierTreeBase, 0) != 1073741823; zdo.Set(HashFields, true); zdo.Set(HashFieldsTreeBase, true); zdo.Set(HashToolTierTreeBase, 1073741823, false); obj.LoadFields(); } if (Object.op_Implicit((Object)(object)((Component)obj).GetComponent<TreeLog>())) { flag |= zdo.GetInt(HashToolTierTreeLog, 0) != 1073741823; zdo.Set(HashFields, true); zdo.Set(HashFieldsTreeLog, true); zdo.Set(HashToolTierTreeLog, 1073741823, false); obj.LoadFields(); } WearNTear val = default(WearNTear); if (((Component)obj).TryGetComponent<WearNTear>(ref val)) { zdo.Set(ZDOVars.s_health, -1f); float num = -1f; if (Configuration.Invulnerability == "Worn") { num = -2f; } if (Configuration.Invulnerability == "Damaged") { num = -4f; } flag |= zdo.GetFloat(HashMaxHealth, 0f) != num; zdo.Set(HashFields, true); zdo.Set(HashFieldsWearNTear, true); zdo.Set(HashMaxHealth, num); zdo.RemoveFloat(Hash.BuildingSkillLevel); obj.LoadFields(); val.m_healthPercentage = -1f / num; val.SetHealthVisual(val.m_healthPercentage, false); } if (Object.op_Implicit((Object)(object)((Component)obj).GetComponent<Character>())) { flag |= zdo.GetFloat(ZDOVars.s_maxHealth, 0f) != 1E+30f; zdo.Set(ZDOVars.s_health, 1.000001E+30f); zdo.Set(ZDOVars.s_maxHealth, 1E+30f); } return flag; } } public class DataHelper { public static void Init(string name, Transform tr, ZDOData data) { Init(StringExtensionMethods.GetStableHashCode(name), tr, data); } public static void Init(int hash, Transform tr, ZDOData data) { //IL_0002: 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) //IL_000e: Unknown result type (might be due to invalid IL or missing references) Init(hash, tr.position, tr.rotation, tr.lossyScale, data); } public static void Init(int hash, Vector3 pos, Quaternion rot, Vector3 scale, ZDOData data) { //IL_0049: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_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) Clear(); ZNetView val = default(ZNetView); if (ZNetScene.instance.m_namedPrefabs.TryGetValue(hash, out var value) && value.TryGetComponent<ZNetView>(ref val) && (data.HasData() || (val.m_syncInitialScale && !(scale == Vector3.one)))) { ZNetView.m_initZDO = ZDOMan.instance.CreateNewZDO(pos, hash); data.Copy(ZNetView.m_initZDO); ZNetView.m_initZDO.m_rotation = ((Quaternion)(ref rot)).eulerAngles; ZNetView.m_initZDO.Type = val.m_type; ZNetView.m_initZDO.Distant = val.m_distant; ZNetView.m_initZDO.Persistent = val.m_persistent; ZNetView.m_initZDO.m_prefab = hash; if (val.m_syncInitialScale) { ZNetView.m_initZDO.Set(ZDOVars.s_scaleHash, scale); } ZNetView.m_initZDO.DataRevision = 0u; ZNetView.m_initZDO.IncreaseDataRevision(); } } public static void Clear() { ZNetView.m_initZDO = null; } } [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 { 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; } 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(bool __result) { HideEffects.Active = false; DataHelper.Clear(); if (__result && 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 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldloc_2, (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[2] { new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ret, (object)null, (string)null) }) .Advance(-1) .Insert((CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldloc_3, (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 = true; private static void CheckHold() { if (!ZInput.GetButton("Attack") && !ZInput.GetButton("JoyPlace")) { Selecting = false; } if (!Selecting && Selection.Get().Continuous) { Player localPlayer = Player.m_localPlayer; if (ZInput.GetButton("Attack") || ZInput.GetButton("JoyPlace")) { localPlayer.m_placePressedTime = Time.time; } if (Time.time - localPlayer.m_lastToolUseTime > localPlayer.m_placeDelay / 4f) { localPlayer.m_lastToolUseTime = 0f; } } } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"Attack", (string)null) }).SetAndAdvance(OpCodes.Call, Transpilers.EmitDelegate<Action>((Action)CheckHold).operand).Insert((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldstr, (object)"Attack") }) .InstructionEnumeration(); } } [HarmonyPatch(typeof(Player), "PlacePiece")] public class PostProcessToolOnPlace { private static void Postfix(Player __instance, ref bool __result) { if (__result) { Hammer.PostProcessTool(__instance); } } } [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 Removing = false; public static List<FakeZDO> RemovedObjects = new List<FakeZDO>(); public static void SetRemovedObject(ZNetView obj) { RemovedObjects = new List<FakeZDO> { new FakeZDO(obj.GetZDO()) }; } public static void AddRemovedObject(ZNetView obj) { RemovedObjects.Add(new FakeZDO(obj.GetZDO())); } private static bool RemoveAnything(Player obj) { //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) Hovered hovered = Selector.GetHovered(obj, obj.m_maxPlaceDistance, new string[0], Configuration.RemoveIds, false); if (hovered == null) { return false; } obj.m_removeEffects.Create(((Component)hovered.Obj).transform.position, Quaternion.identity, (Transform)null, 1f, -1); SetRemovedObject(hovered.Obj); Remove(hovered.Obj); 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 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(); } HammerHelper.RemoveZDO(obj.GetZDO()); } private static void RemoveInArea(FakeZDO zdo, float radius) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) FakeZDO zdo2 = zdo; if (radius != 0f) { Vector3 position = zdo2.Position; int prefab = zdo2.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 && view.GetZDO() != zdo2.Source).ToArray(); foreach (ZNetView obj in array) { AddRemovedObject(obj); Remove(obj); } } } public static bool Prefix(Player __instance, ref bool __result) { HideEffects.Active = true; Removing = true; PreventPieceDrops.Active = Configuration.DisableLoot; PreventCreaturerops.Active = Configuration.DisableLoot; if (Configuration.RemoveAnything) { __result = RemoveAnything(__instance); return false; } return true; } private static void Finalizer() { if (RemovedObjects.Count > 0) { RemoveInArea(RemovedObjects[0], Configuration.RemoveArea); Undo.AddRemoveStep(RemovedObjects); } RemovedObjects.Clear(); HideEffects.Active = false; PreventPieceDrops.Active = false; PreventCreaturerops.Active = false; Removing = false; } } [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), "RemovePiece")] public class PostProcessToolOnRemove { public static void Postfix(Player __instance, ref bool __result) { if (__result) { Hammer.PostProcessTool(__instance); } } } [HarmonyPatch(typeof(Piece), "CanBeRemoved")] public class AccessTargetedObject { public static void Prefix(Piece __instance) { if (RemovePiece.Removing && Selector.IsValid(__instance.m_nview)) { RemovePiece.SetRemovedObject(__instance.m_nview); } } } [HarmonyPatch(typeof(Player), "Repair")] public class Repair { public static bool IsRepairing; public static bool Repaired; private static bool RepairCharacter(ZNetView obj) { Character component = ((Component)obj).GetComponent<Character>(); if (!Object.op_Implicit((Object)(object)component)) { return false; } return RepairShared(obj, component.GetMaxHealth()); } 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, component.m_health); if (flag) { component.m_lastRepair = Time.time; obj.InvokeRPC(ZNetView.Everybody, "WNTHealthChanged", new object[1] { obj.GetZDO().GetFloat("health", component.m_health) }); } return flag; } private static bool RepairDestructible(ZNetView obj) { Destructible component = ((Component)obj).GetComponent<Destructible>(); if (!Object.op_Implicit((Object)(object)component)) { return false; } return RepairShared(obj, component.m_health); } private static bool RepairTreeBase(ZNetView obj) { TreeBase component = ((Component)obj).GetComponent<TreeBase>(); if (!Object.op_Implicit((Object)(object)component)) { return false; } return RepairShared(obj, component.m_health); } private static bool RepairTreeLog(ZNetView obj) { TreeLog component = ((Component)obj).GetComponent<TreeLog>(); if (!Object.op_Implicit((Object)(object)component)) { return false; } return RepairShared(obj, component.m_health); } private static bool RepairMineRock(ZNetView obj, int index) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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) MineRock5 component = ((Component)obj).GetComponent<MineRock5>(); if (!Object.op_Implicit((Object)(object)component)) { return false; } HitArea hitArea = component.GetHitArea(index); obj.ClaimOwnership(); obj.GetZDO(); float num = ((Configuration.OverwriteHealth > 0f) ? Configuration.OverwriteHealth : component.m_health); float num2 = num - hitArea.m_health; Bounds bounds; if (num2 != 0f) { hitArea.m_health = num; component.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 = component.m_hitAreas.Find((HitArea area) => area.m_health <= 0f); if (val != null) { val.m_health = num; component.SaveHealth(); component.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, float maxHealth) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) obj.ClaimOwnership(); if (!CustomHealth.SetHealth(obj)) { return false; } float num = float.PositiveInfinity; if (Configuration.Invulnerability == "Off") { num = Configuration.OverwriteHealth - obj.GetZDO().GetFloat(ZDOVars.s_health,