Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Infinity Hammer v1.91.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.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using Data; using HarmonyLib; using InfinityHammer; using Microsoft.CodeAnalysis; using ServerDevcommands; using Service; using SoftReferenceableAssets; using Splatform; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.Rendering; using UnityEngine.UI; using WorldEditCommands; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("InfinityHammer")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a8212de58b9ccf9decae725badcc7be3a7aab6a9")] [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] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 static readonly HashSet<string> Truthies = new HashSet<string> { "1", "t", "true", "yes", "on" }; private static readonly HashSet<string> Falsies = new HashSet<string> { "0", "f", "false", "no", "off" }; public ConfigWrapper(string command, ConfigFile configFile) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_004f: Expected O, but got Unknown //IL_004a: 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, 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) return BindCommand(() => command, group, name, value, description, mode); } public ConfigEntry<KeyboardShortcut> BindCommand(Func<string> command, string group, string name, KeyboardShortcut value, string description, string mode) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) return BindCommand(command, group, name, value, description, "", mode); } public ConfigEntry<KeyboardShortcut> BindCommand(Func<string> command, string group, string name, KeyboardShortcut value, string description, string offCommand, 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) string text = ToKey(name); string text2 = "_bind_" + text; Helper.Command(text2, description, (ConsoleEvent)delegate(ConsoleEventArgs args) { string text3 = command(); if (args.Length == 1) { args.Context.TryRunCommand(text3, false, false); } else { string args2 = HammerHelper.GetArgs(args[0], args); args.Context.TryRunCommand(text3 + " " + args2, false, false); } }); ConfigEntry<KeyboardShortcut> val = Create<KeyboardShortcut>(group, name, value, description); RegisterCommand(val, text2, offCommand, 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) return BindWheelCommand(() => command, 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) string text = ToKey(name); string text2 = "_bind_" + text; Helper.Command(text2, description, (ConsoleEvent)delegate(ConsoleEventArgs args) { string text3 = command(); if (args.Length == 1) { args.Context.TryRunCommand(text3, false, false); } else { string args2 = HammerHelper.GetArgs(args[0], args); args.Context.TryRunCommand(text3 + " " + args2, false, false); } }); ConfigEntry<KeyboardShortcut> val = Create<KeyboardShortcut>(group, name, value, description); RegisterWheelCommand(val, text2, "", mode); return val; } public ConfigEntry<T> Bind<T>(string group, string name, T value, string description) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return Bind(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())); } private static void AddMessage(Terminal context, string message) { context.AddString(message); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, message, 0, (Sprite)null, false); } } public void Bind() { foreach (Action binder in Binders) { binder(); } } private void Register(ConfigEntry<bool> setting) { string name = ((ConfigEntryBase)setting).Definition.Key; string key = ToKey(name); SettingHandlers.Add(key, delegate(Terminal terminal, string value) { Toggle(terminal, setting, 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"; } string text = ((object)((KeyboardShortcut)(ref key)).MainKey/*cast due to .constrained prefix*/).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 offCommand, string mode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) BindManager.SetTemporaryBind(GetKeys(key), mode, command, offCommand); } private string ToKey(string name) { return name.ToLower().Replace(' ', '_').Replace("(", "") .Replace(")", ""); } private void RegisterCommand(ConfigEntry<KeyboardShortcut> setting, string command, string offCommand, string mode) { string name = ((ConfigEntryBase)setting).Definition.Key; string key = ToKey(name); setting.SettingChanged += delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) UpdateKey(setting.Value, command, offCommand, mode); }; Binders.Add(delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) UpdateKey(setting.Value, command, offCommand, mode); }); SettingHandlers.Add(key, delegate(Terminal terminal, string value) { SetKey(terminal, setting, name, value); }); } private void UpdateWheelKey(KeyboardShortcut key, string command, string offCommand, string mode) { //IL_0008: 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) List<string> list = new List<string>(); if ((int)((KeyboardShortcut)(ref key)).MainKey != 0 || mode == "command") { list.Add("wheel"); list.Add(GetKeys(key)); } BindManager.SetTemporaryBind(string.Join(",", list), mode, command, offCommand); } private void RegisterWheelCommand(ConfigEntry<KeyboardShortcut> setting, string command, string offCommand, string mode) { string name = ((ConfigEntryBase)setting).Definition.Key; string key = ToKey(name); setting.SettingChanged += delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) UpdateWheelKey(setting.Value, command, offCommand, mode); }; Binders.Add(delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) UpdateWheelKey(setting.Value, command, offCommand, mode); }); SettingHandlers.Add(key, delegate(Terminal terminal, string value) { SetKey(terminal, setting, name, value); }); } private void Register(ConfigEntry<KeyboardShortcut> setting) { string name = ((ConfigEntryBase)setting).Definition.Key; string key = ToKey(name); SettingHandlers.Add(key, delegate(Terminal terminal, string value) { SetKey(terminal, setting, name, value); }); } private void RegisterList(ConfigEntry<string> setting) { string name = ((ConfigEntryBase)setting).Definition.Key; string key = ToKey(name); SettingHandlers.Add(key, delegate(Terminal terminal, string value) { ToggleFlag(terminal, setting, name, value); }); } private void Register<T>(ConfigEntry<T> setting) { string name = ((ConfigEntryBase)setting).Definition.Key; string key = ToKey(name); SettingHandlers.Add(key, delegate(Terminal terminal, string value) { SetValue<T>(terminal, setting, name, value); }); } private static string State(bool value) { if (!value) { return "disabled"; } return "enabled"; } private static string Flag(bool value) { if (!value) { return "Added"; } return "Removed"; } private static bool IsTruthy(string value) { return Truthies.Contains(value); } private static bool IsFalsy(string value) { return Falsies.Contains(value); } private static void Toggle(Terminal context, ConfigEntry<bool> setting, string name, string value) { if (value == "") { setting.Value = !setting.Value; } else if (IsTruthy(value)) { setting.Value = true; } else if (IsFalsy(value)) { setting.Value = false; } AddMessage(context, name + " " + State(setting.Value) + "."); } private static void SetKey(Terminal context, ConfigEntry<KeyboardShortcut> setting, string name, string value) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) if (value == "") { AddMessage(context, $"{name}: {setting.Value}."); return; } if (!Enum.TryParse<KeyCode>(value, ignoreCase: true, out KeyCode result)) { throw new InvalidOperationException("'" + value + "' is not a valid UnityEngine.KeyCode."); } setting.Value = new KeyboardShortcut(result, Array.Empty<KeyCode>()); AddMessage(context, name + " set to " + value + "."); } public static int TryParseInt(string value, int defaultValue) { if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return result; } return defaultValue; } public static int TryParseInt(ConfigEntry<string> setting) { if (int.TryParse(setting.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return result; } return TryParseInt((string)((ConfigEntryBase)setting).DefaultValue, 0); } private static float TryParseFloat(string value, float defaultValue) { if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return result; } return defaultValue; } public static float TryParseFloat(ConfigEntry<string> setting) { if (float.TryParse(setting.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return result; } return TryParseFloat((string)((ConfigEntryBase)setting).DefaultValue, 0f); } private static HashSet<string> ParseList(string value) { return (from s in value.Split(new char[1] { ',' }) select s.Trim().ToLower()).ToHashSet(); } private static void ToggleFlag(Terminal context, ConfigEntry<string> setting, string name, string value) { if (value == "") { AddMessage(context, name + ": " + setting.Value + "\"."); return; } HashSet<string> hashSet = ParseList(setting.Value); foreach (string item in ParseList(value)) { bool flag = hashSet.Contains(item); if (flag) { hashSet.Remove(item); } else { hashSet.Add(item); } setting.Value = string.Join(",", hashSet); AddMessage(context, name + ": " + Flag(flag) + " \"" + item + "\"."); } } private static void SetValue<T>(Terminal context, ConfigEntry<T> setting, string name, string value) { if (value == "") { AddMessage(context, $"{name}: {setting.Value}."); return; } if (value.Contains("/")) { string[] array = value.Split(new char[1] { '/' }); value = array[0]; for (int i = 0; i < array.Length - 1; i++) { T value2 = setting.Value; if (string.Equals((value2 != null) ? value2.ToString() : null, array[i], StringComparison.OrdinalIgnoreCase)) { value = array[i + 1]; break; } } } setting.Value = (T)(object)value; AddMessage(context, name + " set to " + value + "."); } } public abstract class TerrainChannelData<TValue> where TValue : struct { public Vector3 CenterPosition; public Quaternion CenterRotation = Quaternion.identity; public float DistanceBetweenNodes = 1f; public float Smooth; public int Width; public int Height; public float GetRadius() { return GetRequiredRadius(); } public float GetSmoothWeight(Vector3 nodePos, Vector3 placementPos, Quaternion relativeRotation, float smooth) { //IL_0018: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) //IL_002a: Unknown result type (might be due to invalid IL or missing references) smooth = Mathf.Clamp01(smooth); if (smooth <= 0f) { return 1f; } Vector3 val = Quaternion.Inverse(relativeRotation) * (nodePos - placementPos); float num = val.x - CenterPosition.x; float num2 = val.z - CenterPosition.z; float requiredRadius = GetRequiredRadius(); if (requiredRadius <= 0f) { return 1f; } float num3 = Mathf.Sqrt(num * num + num2 * num2); float num4 = requiredRadius * (1f - smooth); if (num3 <= num4) { return 1f; } if (num3 >= requiredRadius) { return 0f; } float num5 = Mathf.Max(0.001f, requiredRadius - num4); return Mathf.Clamp01(1f - (num3 - num4) / num5); } protected void InitializeReference(int width, int height, Vector3 centerPos) { //IL_000f: 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) Width = width; Height = height; CenterPosition = centerPos; } private float GetRequiredRadius() { //IL_004e: 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_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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if (Width <= 0 || Height <= 0) { return 0f; } float num = Mathf.Max(0.001f, DistanceBetweenNodes); float num2 = (float)(Width - 1) * num * 0.5f; float num3 = (float)(Height - 1) * num * 0.5f; Vector3 val = CenterPosition - new Vector3(num2, 0f, num3); float num4 = 0f; for (int i = 0; i < Width; i++) { for (int j = 0; j < Height; j++) { if (Get(i, j).HasValue) { Vector3 val2 = val + new Vector3((float)i * num, 0f, (float)j * num); num4 = Mathf.Max(num4, Utils.LengthXZ(val2)); } } } return num4; } public void SetReference(Vector3 center, Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) CenterPosition -= center; CenterRotation = GetYawRotation(rotation); OnSetReference(center); } protected static Quaternion GetYawRotation(Quaternion rotation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0026: Unknown result type (might be due to invalid IL or missing references) Vector3 val = rotation * Vector3.forward; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude <= 0.0001f) { return Quaternion.identity; } return Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); } protected virtual void OnSetReference(Vector3 center) { } protected Vector3 GetFirstNodeAnchor() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0.001f, DistanceBetweenNodes); float num2 = (float)(Width - 1) * num * 0.5f; float num3 = (float)(Height - 1) * num * 0.5f; return new Vector3(CenterPosition.x - num2, CenterPosition.y, CenterPosition.z - num3); } protected static bool TryGetGridCoordinates(Vector3 nodePos, Vector3 placementPos, Quaternion relativeRotation, Vector3 firstNodeAnchor, float distanceBetweenNodes, out int gridX, out int gridZ) { //IL_000d: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0036: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0.001f, distanceBetweenNodes); Vector3 val = nodePos - placementPos; Vector3 val2 = Quaternion.Inverse(relativeRotation) * val; float x = val2.x; float z = val2.z; float num2 = x - firstNodeAnchor.x; float num3 = z - firstNodeAnchor.z; gridX = Mathf.RoundToInt(num2 / num); gridZ = Mathf.RoundToInt(num3 / num); return true; } public abstract TValue? Get(int x, int z); public abstract void Set(int x, int z, TValue value); public abstract TValue? FindNearest(Vector3 nodePos, Vector3 placementPos, Quaternion relativeRotation); } public class TerrainHeight : TerrainChannelData<float> { public float?[,] Heights = new float?[0, 0]; public void InitializeGrid(int width, int height, Vector3 centerPosition) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) InitializeReference(width, height, centerPosition); Heights = new float?[width, height]; } public override float? Get(int x, int z) { if (x >= 0 && x < Width && z >= 0 && z < Height) { return Heights[x, z]; } return null; } public override void Set(int x, int z, float value) { if (x >= 0 && x < Width && z >= 0 && z < Height) { Heights[x, z] = value; } } public override float? FindNearest(Vector3 nodePos, Vector3 placementPos, Quaternion relativeRotation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) if (!TerrainChannelData<float>.TryGetGridCoordinates(nodePos, placementPos, relativeRotation, GetFirstNodeAnchor(), DistanceBetweenNodes, out var gridX, out var gridZ)) { return null; } if (gridX < 0 || gridX >= Width || gridZ < 0 || gridZ >= Height) { return null; } return Get(gridX, gridZ); } protected override void OnSetReference(Vector3 center) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < Width; i++) { for (int j = 0; j < Height; j++) { if (Heights[i, j].HasValue) { Heights[i, j] -= center.y; } } } } public TerrainHeight Clone() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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) TerrainHeight terrainHeight = new TerrainHeight { CenterPosition = CenterPosition, CenterRotation = CenterRotation, DistanceBetweenNodes = DistanceBetweenNodes, Smooth = Smooth, Width = Width, Height = Height, Heights = new float?[Width, Height] }; for (int i = 0; i < Width; i++) { for (int j = 0; j < Height; j++) { terrainHeight.Heights[i, j] = Heights[i, j]; } } return terrainHeight; } } public class TerrainPaint : TerrainChannelData<Color> { public Color?[,] Paints = new Color?[0, 0]; public void InitializeGrid(int width, int height, Vector3 centerPosition) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) InitializeReference(width, height, centerPosition); Paints = new Color?[width, height]; } public override Color? Get(int x, int z) { if (x >= 0 && x < Width && z >= 0 && z < Height) { return Paints[x, z]; } return null; } public override void Set(int x, int z, Color value) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (x >= 0 && x < Width && z >= 0 && z < Height) { Paints[x, z] = value; } } public override Color? FindNearest(Vector3 nodePos, Vector3 placementPos, Quaternion relativeRotation) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) if (!TerrainChannelData<Color>.TryGetGridCoordinates(nodePos, placementPos, relativeRotation, GetFirstNodeAnchor(), DistanceBetweenNodes, out var gridX, out var gridZ)) { return null; } if (gridX < 0 || gridX >= Width || gridZ < 0 || gridZ >= Height) { return null; } return Get(gridX, gridZ); } public TerrainPaint Clone() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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) TerrainPaint terrainPaint = new TerrainPaint { CenterPosition = CenterPosition, CenterRotation = CenterRotation, DistanceBetweenNodes = DistanceBetweenNodes, Smooth = Smooth, Width = Width, Height = Height, Paints = new Color?[Width, Height] }; for (int i = 0; i < Width; i++) { for (int j = 0; j < Height; j++) { terrainPaint.Paints[i, j] = Paints[i, j]; } } return terrainPaint; } } public class TerrainInfo { public static float ResolveRadius(TerrainHeight? height, TerrainPaint? paint) { float num = Mathf.Max(height?.GetRadius() ?? 0f, paint?.GetRadius() ?? 0f); float num2 = Mathf.Max(new float[3] { 1f, height?.DistanceBetweenNodes ?? 0f, paint?.DistanceBetweenNodes ?? 0f }); return num + num2; } private static Vector3 VertexToWorld(Heightmap hmap, int x, int z) { //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_0046: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)hmap).transform.position; position.x += (float)(x - hmap.m_width / 2) * hmap.m_scale; position.z += (float)(z - hmap.m_width / 2) * hmap.m_scale; return position; } private static float GetX(float x, float z, float angle) { return Mathf.Cos(angle) * x - Mathf.Sin(angle) * z; } private static float GetZ(float x, float z, float angle) { return Mathf.Sin(angle) * x + Mathf.Cos(angle) * z; } public static TerrainHeight CollectTerrainHeightInRadius(Vector3 centerPos, Quaternion centerRot, Vector3 searchPos, Range<float> radius, float nodeSpacingOverride = 0f) { //IL_0000: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) TerrainHeight terrainHeight = MergeHeightmapsWithCircle(Terrain.GetCompilers(searchPos, new Range<float>(radius.Max)).ToList(), searchPos, radius, nodeSpacingOverride); terrainHeight.SetReference(centerPos, centerRot); return terrainHeight; } public static TerrainPaint CollectTerrainPaintInRadius(Vector3 centerPos, Quaternion centerRot, Vector3 searchPos, Range<float> radius, float nodeSpacingOverride = 0f) { //IL_0000: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) TerrainPaint terrainPaint = MergePaintmapsWithCircle(Terrain.GetCompilers(searchPos, new Range<float>(radius.Max)).ToList(), searchPos, radius, nodeSpacingOverride); terrainPaint.SetReference(centerPos, centerRot); return terrainPaint; } public static TerrainHeight CollectTerrainHeightInRect(Vector3 centerPos, Quaternion centerRot, Vector3 searchPos, Range<float> width, Range<float> depth, float angle, float nodeSpacingOverride = 0f) { //IL_0000: 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) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) TerrainHeight terrainHeight = MergeHeightmapsWithRect(Terrain.GetCompilers(searchPos, width, depth, angle).ToList(), searchPos, width, depth, angle, nodeSpacingOverride); terrainHeight.SetReference(centerPos, centerRot); return terrainHeight; } public static TerrainPaint CollectTerrainPaintInRect(Vector3 centerPos, Quaternion centerRot, Vector3 searchPos, Range<float> width, Range<float> depth, float angle, float nodeSpacingOverride = 0f) { //IL_0000: 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) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) TerrainPaint terrainPaint = MergePaintmapsWithRect(Terrain.GetCompilers(searchPos, width, depth, angle).ToList(), searchPos, width, depth, angle, nodeSpacingOverride); terrainPaint.SetReference(centerPos, centerRot); return terrainPaint; } private static float ResolveNodeSpacing(List<TerrainComp> compilers, float nodeSpacingOverride) { if (nodeSpacingOverride > 0f) { return Mathf.Max(0.001f, nodeSpacingOverride); } if (compilers.Count == 0) { return 1f; } return Mathf.Max(0.001f, compilers[0].m_hmap.m_scale); } private static TerrainHeight MergeHeightmapsWithCircle(List<TerrainComp> compilers, Vector3 centerPos, Range<float> radius, float nodeSpacingOverride) { //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) TerrainHeight terrainHeight = new TerrainHeight(); if (compilers.Count == 0) { return terrainHeight; } float num = ResolveNodeSpacing(compilers, nodeSpacingOverride); float num2 = float.MaxValue; float num3 = float.MinValue; float num4 = float.MaxValue; float num5 = float.MinValue; bool flag = false; foreach (TerrainComp compiler in compilers) { int num6 = compiler.m_width + 1; for (int i = 0; i < num6; i++) { for (int j = 0; j < num6; j++) { Vector3 val = VertexToWorld(compiler.m_hmap, i, j); float num7 = Utils.DistanceXZ(centerPos, val); if (Helper.Within(radius, num7)) { flag = true; num2 = Math.Min(num2, val.x); num3 = Math.Max(num3, val.x); num4 = Math.Min(num4, val.z); num5 = Math.Max(num5, val.z); } } } } if (!flag) { return terrainHeight; } int num8 = Mathf.RoundToInt((num3 - num2) / num) + 1; int num9 = Mathf.RoundToInt((num5 - num4) / num) + 1; terrainHeight.InitializeGrid(num8, num9, new Vector3(num2 + (float)(num8 - 1) * num * 0.5f, 0f, num4 + (float)(num9 - 1) * num * 0.5f)); terrainHeight.DistanceBetweenNodes = num; foreach (TerrainComp compiler2 in compilers) { int num10 = compiler2.m_width + 1; for (int k = 0; k < num10; k++) { for (int l = 0; l < num10; l++) { Vector3 val2 = VertexToWorld(compiler2.m_hmap, k, l); float num11 = Utils.DistanceXZ(centerPos, val2); if (!Helper.Within(radius, num11)) { continue; } int num12 = l * num10 + k; if (num12 < compiler2.m_hmap.m_heights.Count) { int x = Mathf.RoundToInt((val2.x - num2) / num); int z = Mathf.RoundToInt((val2.z - num4) / num); if (!terrainHeight.Get(x, z).HasValue) { terrainHeight.Set(x, z, compiler2.m_hmap.m_heights[num12]); } } } } } return terrainHeight; } private static TerrainPaint MergePaintmapsWithCircle(List<TerrainComp> compilers, Vector3 centerPos, Range<float> radius, float nodeSpacingOverride) { //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019e: 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_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) TerrainPaint terrainPaint = new TerrainPaint(); if (compilers.Count == 0) { return terrainPaint; } float num = ResolveNodeSpacing(compilers, nodeSpacingOverride); float num2 = float.MaxValue; float num3 = float.MinValue; float num4 = float.MaxValue; float num5 = float.MinValue; bool flag = false; foreach (TerrainComp compiler in compilers) { int num6 = compiler.m_width + 1; for (int i = 0; i < num6; i++) { for (int j = 0; j < num6; j++) { Vector3 val = VertexToWorld(compiler.m_hmap, i, j); float num7 = Utils.DistanceXZ(centerPos, val); if (Helper.Within(radius, num7)) { flag = true; num2 = Math.Min(num2, val.x); num3 = Math.Max(num3, val.x); num4 = Math.Min(num4, val.z); num5 = Math.Max(num5, val.z); } } } } if (!flag) { return terrainPaint; } int num8 = Mathf.RoundToInt((num3 - num2) / num) + 1; int num9 = Mathf.RoundToInt((num5 - num4) / num) + 1; terrainPaint.InitializeGrid(num8, num9, new Vector3(num2 + (float)(num8 - 1) * num * 0.5f, 0f, num4 + (float)(num9 - 1) * num * 0.5f)); terrainPaint.DistanceBetweenNodes = num; foreach (TerrainComp compiler2 in compilers) { int num10 = compiler2.m_width + 1; for (int k = 0; k < num10; k++) { for (int l = 0; l < num10; l++) { Vector3 val2 = VertexToWorld(compiler2.m_hmap, k, l); float num11 = Utils.DistanceXZ(centerPos, val2); if (Helper.Within(radius, num11)) { int x = Mathf.RoundToInt((val2.x - num2) / num); int z = Mathf.RoundToInt((val2.z - num4) / num); if (!terrainPaint.Get(x, z).HasValue) { terrainPaint.Set(x, z, compiler2.m_hmap.GetPaintMask(k, l)); } } } } } return terrainPaint; } private static TerrainHeight MergeHeightmapsWithRect(List<TerrainComp> compilers, Vector3 centerPos, Range<float> width, Range<float> depth, float angle, float nodeSpacingOverride) { //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) TerrainHeight terrainHeight = new TerrainHeight(); if (compilers.Count == 0) { return terrainHeight; } float num = ResolveNodeSpacing(compilers, nodeSpacingOverride); float num2 = float.MaxValue; float num3 = float.MinValue; float num4 = float.MaxValue; float num5 = float.MinValue; bool flag = false; foreach (TerrainComp compiler in compilers) { int num6 = compiler.m_width + 1; for (int i = 0; i < num6; i++) { for (int j = 0; j < num6; j++) { Vector3 val = VertexToWorld(compiler.m_hmap, i, j); float x = val.x - centerPos.x; float z = val.z - centerPos.z; float x2 = GetX(x, z, angle); float z2 = GetZ(x, z, angle); if (Helper.Within(width, depth, Mathf.Abs(x2), Mathf.Abs(z2))) { flag = true; num2 = Math.Min(num2, val.x); num3 = Math.Max(num3, val.x); num4 = Math.Min(num4, val.z); num5 = Math.Max(num5, val.z); } } } } if (!flag) { return terrainHeight; } int num7 = Mathf.RoundToInt((num3 - num2) / num) + 1; int num8 = Mathf.RoundToInt((num5 - num4) / num) + 1; terrainHeight.InitializeGrid(num7, num8, new Vector3(num2 + (float)(num7 - 1) * num * 0.5f, 0f, num4 + (float)(num8 - 1) * num * 0.5f)); terrainHeight.DistanceBetweenNodes = num; foreach (TerrainComp compiler2 in compilers) { int num9 = compiler2.m_width + 1; for (int k = 0; k < num9; k++) { for (int l = 0; l < num9; l++) { Vector3 val2 = VertexToWorld(compiler2.m_hmap, k, l); float x3 = val2.x - centerPos.x; float z3 = val2.z - centerPos.z; float x4 = GetX(x3, z3, angle); float z4 = GetZ(x3, z3, angle); if (!Helper.Within(width, depth, Mathf.Abs(x4), Mathf.Abs(z4))) { continue; } int num10 = l * num9 + k; if (num10 < compiler2.m_hmap.m_heights.Count) { int x5 = Mathf.RoundToInt((val2.x - num2) / num); int z5 = Mathf.RoundToInt((val2.z - num4) / num); if (!terrainHeight.Get(x5, z5).HasValue) { terrainHeight.Set(x5, z5, compiler2.m_hmap.m_heights[num10]); } } } } } return terrainHeight; } private static TerrainPaint MergePaintmapsWithRect(List<TerrainComp> compilers, Vector3 centerPos, Range<float> width, Range<float> depth, float angle, float nodeSpacingOverride) { //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) TerrainPaint terrainPaint = new TerrainPaint(); if (compilers.Count == 0) { return terrainPaint; } float num = ResolveNodeSpacing(compilers, nodeSpacingOverride); float num2 = float.MaxValue; float num3 = float.MinValue; float num4 = float.MaxValue; float num5 = float.MinValue; bool flag = false; foreach (TerrainComp compiler in compilers) { int num6 = compiler.m_width + 1; for (int i = 0; i < num6; i++) { for (int j = 0; j < num6; j++) { Vector3 val = VertexToWorld(compiler.m_hmap, i, j); float x = val.x - centerPos.x; float z = val.z - centerPos.z; float x2 = GetX(x, z, angle); float z2 = GetZ(x, z, angle); if (Helper.Within(width, depth, Mathf.Abs(x2), Mathf.Abs(z2))) { flag = true; num2 = Math.Min(num2, val.x); num3 = Math.Max(num3, val.x); num4 = Math.Min(num4, val.z); num5 = Math.Max(num5, val.z); } } } } if (!flag) { return terrainPaint; } int num7 = Mathf.RoundToInt((num3 - num2) / num) + 1; int num8 = Mathf.RoundToInt((num5 - num4) / num) + 1; terrainPaint.InitializeGrid(num7, num8, new Vector3(num2 + (float)(num7 - 1) * num * 0.5f, 0f, num4 + (float)(num8 - 1) * num * 0.5f)); terrainPaint.DistanceBetweenNodes = num; foreach (TerrainComp compiler2 in compilers) { int num9 = compiler2.m_width + 1; for (int k = 0; k < num9; k++) { for (int l = 0; l < num9; l++) { Vector3 val2 = VertexToWorld(compiler2.m_hmap, k, l); float x3 = val2.x - centerPos.x; float z3 = val2.z - centerPos.z; float x4 = GetX(x3, z3, angle); float z4 = GetZ(x3, z3, angle); if (Helper.Within(width, depth, Mathf.Abs(x4), Mathf.Abs(z4))) { int x5 = Mathf.RoundToInt((val2.x - num2) / num); int z5 = Mathf.RoundToInt((val2.z - num4) / num); if (!terrainPaint.Get(x5, z5).HasValue) { terrainPaint.Set(x5, z5, compiler2.m_hmap.GetPaintMask(k, l)); } } } } } return terrainPaint; } } } 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 { public static float SetHealth(ZNetView obj, bool isRepair) { ZDO zDO = obj.GetZDO(); if (Configuration.Invulnerability == "Off" && Configuration.OverwriteHealth == 0f) { return SetDefaultHealth(obj, zDO, isRepair); } if (Configuration.Invulnerability == "Off" || Configuration.Invulnerability == "Legacy") { return SetCustomHealth(obj, zDO); } return SetInfiniteHealth(obj, zDO); } private static float SetDefaultHealth(ZNetView obj, ZDO zdo, bool isRepair) { if (!isRepair) { return 0f; } float num = 0f; Character character = default(Character); if (((Component)obj).TryGetComponent<Character>(ref character)) { num += SetDefaultHealth(zdo, character); } Destructible destructible = default(Destructible); if (((Component)obj).TryGetComponent<Destructible>(ref destructible)) { num += SetDefaultHealth(zdo, destructible); } TreeBase treeBase = default(TreeBase); if (((Component)obj).TryGetComponent<TreeBase>(ref treeBase)) { num += SetDefaultHealth(zdo, treeBase); } TreeLog treeLog = default(TreeLog); if (((Component)obj).TryGetComponent<TreeLog>(ref treeLog)) { num += SetDefaultHealth(zdo, treeLog); } MineRock mineRock = default(MineRock); if (((Component)obj).TryGetComponent<MineRock>(ref mineRock)) { num += SetDefaultHealth(zdo, mineRock); } MineRock5 mineRock2 = default(MineRock5); if (((Component)obj).TryGetComponent<MineRock5>(ref mineRock2)) { num += SetDefaultHealth(zdo, mineRock2); } WearNTear wear = default(WearNTear); if (((Component)obj).TryGetComponent<WearNTear>(ref wear)) { num += SetDefaultHealth(zdo, wear); } return num; } private static float SetDefaultHealth(ZDO zdo, Destructible destructible) { float num = zdo.GetFloat(ZDOVars.s_health, destructible.m_health); zdo.RemoveFloat(ZDOVars.s_health); if (RemoveToolTier(destructible, zdo)) { return float.NegativeInfinity; } return destructible.m_health - num; } private static float SetDefaultHealth(ZDO zdo, TreeBase treeBase) { float num = zdo.GetFloat(ZDOVars.s_health, treeBase.m_health); zdo.RemoveFloat(ZDOVars.s_health); if (RemoveToolTier(treeBase, zdo)) { return float.NegativeInfinity; } return treeBase.m_health - num; } private static float SetDefaultHealth(ZDO zdo, TreeLog treeLog) { float num = zdo.GetFloat(ZDOVars.s_health, treeLog.m_health); zdo.RemoveFloat(ZDOVars.s_health); if (RemoveToolTier(treeLog, zdo)) { return float.NegativeInfinity; } return treeLog.m_health - num; } private static float SetDefaultHealth(ZDO zdo, MineRock mineRock) { MineRock component = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<MineRock>(); if (!Object.op_Implicit((Object)(object)component)) { return 0f; } float num = component.m_health - mineRock.m_health; mineRock.m_health = component.m_health; zdo.RemoveFloat(Hashes.HealthMineRock); float result = RemoveCurrentHealth(mineRock, zdo); if (RemoveToolTier(mineRock, zdo)) { return float.NegativeInfinity; } if (num == 0f) { return result; } return num; } private static float SetDefaultHealth(ZDO zdo, MineRock5 mineRock) { float num = 0f; foreach (HitArea hitArea in mineRock.m_hitAreas) { if (!(hitArea.m_health <= 0f)) { num += mineRock.m_health - hitArea.m_health; hitArea.m_health = mineRock.m_health; } } mineRock.SaveHealth(); if (RemoveToolTier(mineRock, zdo)) { return float.NegativeInfinity; } return num; } private static float SetDefaultHealth(ZDO zdo, WearNTear wear) { float num = zdo.GetFloat(ZDOVars.s_health, wear.m_health); zdo.RemoveFloat(ZDOVars.s_health); float num2 = zdo.GetFloat(Hashes.MaxHealth, 0f); if (num2 != 0f) { wear.m_health = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<WearNTear>().m_health; zdo.RemoveFloat(Hashes.MaxHealth); } UpdateVisual(zdo, wear); if (!(num2 < 0f)) { return wear.m_health - num; } return float.NegativeInfinity; } private static float SetDefaultHealth(ZDO zdo, Character character) { float num = zdo.GetFloat(ZDOVars.s_health, zdo.GetFloat(ZDOVars.s_maxHealth, character.m_health)); zdo.RemoveFloat(ZDOVars.s_health); character.SetupMaxHealth(); return zdo.GetFloat(ZDOVars.s_maxHealth, 0f) - num; } private static float SetCustomHealth(ZNetView obj, ZDO zdo) { float num = 0f; float num2 = ((Configuration.Invulnerability == "Legacy") ? 1E+30f : Configuration.OverwriteHealth); if (num2 <= 0f) { return 0f; } Character character = default(Character); if (((Component)obj).TryGetComponent<Character>(ref character)) { num += SetCustomHealth(zdo, character, num2); } Destructible destructible = default(Destructible); if (((Component)obj).TryGetComponent<Destructible>(ref destructible)) { num += SetCustomHealth(zdo, destructible, num2); } TreeBase treeBase = default(TreeBase); if (((Component)obj).TryGetComponent<TreeBase>(ref treeBase)) { num += SetCustomHealth(zdo, treeBase, num2); } TreeLog treeLog = default(TreeLog); if (((Component)obj).TryGetComponent<TreeLog>(ref treeLog)) { num += SetCustomHealth(zdo, treeLog, num2); } MineRock mineRock = default(MineRock); if (((Component)obj).TryGetComponent<MineRock>(ref mineRock)) { num += SetCustomHealth(zdo, mineRock, num2); } MineRock5 mineRock2 = default(MineRock5); if (((Component)obj).TryGetComponent<MineRock5>(ref mineRock2)) { num += SetCustomHealth(zdo, mineRock2, num2); } WearNTear wear = default(WearNTear); if (((Component)obj).TryGetComponent<WearNTear>(ref wear)) { num += SetCustomHealth(zdo, wear, num2); } return num; } private static float SetCustomHealth(ZDO zdo, Destructible destructible, float health) { float num = zdo.GetFloat(ZDOVars.s_health, destructible.m_health); zdo.Set(ZDOVars.s_health, health); if (RemoveToolTier(destructible, zdo)) { return float.NegativeInfinity; } return health - num; } private static float SetCustomHealth(ZDO zdo, TreeBase treeBase, float health) { float num = zdo.GetFloat(ZDOVars.s_health, treeBase.m_health); zdo.Set(ZDOVars.s_health, health); if (RemoveToolTier(treeBase, zdo)) { return float.NegativeInfinity; } return health - num; } private static float SetCustomHealth(ZDO zdo, TreeLog treeLog, float health) { float num = zdo.GetFloat(ZDOVars.s_health, treeLog.m_health); zdo.Set(ZDOVars.s_health, health); if (RemoveToolTier(treeLog, zdo)) { return float.NegativeInfinity; } return health - num; } private static float SetCustomHealth(ZDO zdo, MineRock mineRock, float health) { zdo.Set(Hashes.HasFields, true); zdo.Set(Hashes.HashFieldsMineRock, true); zdo.Set(Hashes.HealthMineRock, health); float num = health - mineRock.m_health; mineRock.m_health = health; float result = RemoveCurrentHealth(mineRock, zdo); if (RemoveToolTier(mineRock, zdo)) { return float.NegativeInfinity; } if (num == 0f) { return result; } return num; } private static float SetCustomHealth(ZDO zdo, MineRock5 mineRock, float health) { float num = 0f; foreach (HitArea hitArea in mineRock.m_hitAreas) { if (!(hitArea.m_health <= 0f)) { num += health - hitArea.m_health; hitArea.m_health = health; } } mineRock.SaveHealth(); if (RemoveToolTier(mineRock, zdo)) { return float.NegativeInfinity; } return num; } private static float SetCustomHealth(ZDO zdo, WearNTear wear, float health) { float num = zdo.GetFloat(ZDOVars.s_health, wear.m_health); zdo.Set(ZDOVars.s_health, health); float num2 = zdo.GetFloat(Hashes.MaxHealth, 0f); if (num2 != 0f) { wear.m_health = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<WearNTear>().m_health; zdo.RemoveFloat(Hashes.MaxHealth); } zdo.RemoveFloat(Hashes.BuildingSkillLevel); UpdateVisual(zdo, wear); if (!(num2 < 0f)) { return health - num; } return float.NegativeInfinity; } private static float SetCustomHealth(ZDO zdo, Character character, float health) { float num = zdo.GetFloat(ZDOVars.s_health, zdo.GetFloat(ZDOVars.s_maxHealth, character.m_health)); zdo.Set(ZDOVars.s_maxHealth, health); zdo.Set(ZDOVars.s_health, health * 1.000001f); return health - num; } private static float SetInfiniteHealth(ZNetView obj, ZDO zdo) { bool flag = false; Character character = default(Character); if (((Component)obj).TryGetComponent<Character>(ref character)) { flag |= SetInfiniteHealth(zdo, character); } Destructible destructible = default(Destructible); if (((Component)obj).TryGetComponent<Destructible>(ref destructible)) { flag |= SetInfiniteHealth(zdo, destructible); } TreeBase treeBase = default(TreeBase); if (((Component)obj).TryGetComponent<TreeBase>(ref treeBase)) { flag |= SetInfiniteHealth(zdo, treeBase); } TreeLog treeLog = default(TreeLog); if (((Component)obj).TryGetComponent<TreeLog>(ref treeLog)) { flag |= SetInfiniteHealth(zdo, treeLog); } MineRock mineRock = default(MineRock); if (((Component)obj).TryGetComponent<MineRock>(ref mineRock)) { flag |= SetInfiniteHealth(zdo, mineRock); } MineRock5 mineRock2 = default(MineRock5); if (((Component)obj).TryGetComponent<MineRock5>(ref mineRock2)) { flag |= SetInfiniteHealth(zdo, mineRock2); } WearNTear wear = default(WearNTear); if (((Component)obj).TryGetComponent<WearNTear>(ref wear)) { flag |= SetInfiniteHealth(zdo, wear); } if (!flag) { return 0f; } return float.PositiveInfinity; } private static bool SetInfiniteHealth(ZDO zdo, Destructible destructible) { bool result = zdo.GetInt(Hashes.ToolTierDestructible, 0) != 1073741823; zdo.RemoveFloat(ZDOVars.s_health); zdo.Set(Hashes.HasFields, true); zdo.Set(Hashes.HashFieldsDestructible, true); zdo.Set(Hashes.ToolTierDestructible, 1073741823, false); destructible.m_minToolTier = 1073741823; return result; } private static bool SetInfiniteHealth(ZDO zdo, TreeBase treeBase) { bool result = zdo.GetInt(Hashes.ToolTierTreeBase, 0) != 1073741823; zdo.RemoveFloat(ZDOVars.s_health); zdo.Set(Hashes.HasFields, true); zdo.Set(Hashes.HashFieldsTreeBase, true); zdo.Set(Hashes.ToolTierTreeBase, 1073741823, false); treeBase.m_minToolTier = 1073741823; return result; } private static bool SetInfiniteHealth(ZDO zdo, TreeLog treeLog) { bool result = zdo.GetInt(Hashes.ToolTierTreeLog, 0) != 1073741823; zdo.RemoveFloat(ZDOVars.s_health); zdo.Set(Hashes.HasFields, true); zdo.Set(Hashes.HashFieldsTreeLog, true); zdo.Set(Hashes.ToolTierTreeLog, 1073741823, false); treeLog.m_minToolTier = 1073741823; return result; } private static bool SetInfiniteHealth(ZDO zdo, MineRock mineRock) { bool num = zdo.GetInt(Hashes.ToolTierMineRock, 0) != 1073741823; float num2 = RemoveCurrentHealth(mineRock, zdo); mineRock.m_minToolTier = 1073741823; zdo.Set(Hashes.HasFields, true); zdo.Set(Hashes.HashFieldsMineRock, true); zdo.Set(Hashes.ToolTierMineRock, 1073741823, false); if (!num) { return num2 != 0f; } return true; } private static bool SetInfiniteHealth(ZDO zdo, MineRock5 mineRock) { bool result = zdo.GetInt(Hashes.ToolTierMineRock5, 0) != 1073741823; zdo.Set(Hashes.HasFields, true); zdo.Set(Hashes.HashFieldsMineRock5, true); zdo.Set(Hashes.ToolTierMineRock5, 1073741823, false); mineRock.m_minToolTier = 1073741823; foreach (HitArea hitArea in mineRock.m_hitAreas) { if (!(hitArea.m_health <= 0f)) { hitArea.m_health = 1.0737418E+09f; } } mineRock.SaveHealth(); return result; } private static bool SetInfiniteHealth(ZDO zdo, WearNTear wear) { float num = zdo.GetFloat(Hashes.MaxHealth, 0f); zdo.Set(ZDOVars.s_health, -1f); float num2 = -1f; if (Configuration.Invulnerability == "Worn") { num2 = -2f; } if (Configuration.Invulnerability == "Damaged") { num2 = -4f; } if (Configuration.PreserveWear && Configuration.Invulnerability != "Off") { if (num < 0f) { num2 = num; } else if (wear.GetHealthPercentage() <= 0.25f) { num2 = -4f; } else if (wear.GetHealthPercentage() <= 0.75f) { num2 = -2f; } } bool result = num != num2; zdo.Set(Hashes.HasFields, true); zdo.Set(Hashes.HashFieldsWearNTear, true); zdo.Set(Hashes.MaxHealth, num2); zdo.RemoveFloat(Hashes.BuildingSkillLevel); wear.m_health = num2; UpdateVisual(zdo, wear); return result; } private static bool SetInfiniteHealth(ZDO zdo, Character character) { bool result = zdo.GetFloat(ZDOVars.s_maxHealth, 0f) != 1E+30f; zdo.Set(ZDOVars.s_health, 1.000001E+30f); zdo.Set(ZDOVars.s_maxHealth, 1E+30f); return result; } private static void UpdateVisual(ZDO zdo, WearNTear wear) { wear.m_healthPercentage = zdo.GetFloat(ZDOVars.s_health, wear.m_health) / wear.m_health; wear.SetHealthVisual(wear.m_healthPercentage, false); } private static float RemoveCurrentHealth(MineRock mineRock, ZDO zdo) { if (mineRock.m_hitAreas == null) { return 0f; } float num = 0f; for (int i = 0; i < mineRock.m_hitAreas.Length; i++) { string text = "Health" + i; float num2 = zdo.GetFloat(text, 0f); if (!(num2 <= 0f)) { num += mineRock.m_health - num2; zdo.RemoveFloat(text); } } return num; } private static bool RemoveToolTier(MineRock5 obj, ZDO zdo) { if (zdo.GetInt(Hashes.ToolTierMineRock5, -1) < 0) { return false; } zdo.RemoveInt(Hashes.ToolTierMineRock5); obj.m_minToolTier = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<MineRock5>()?.m_minToolTier ?? 0; return true; } private static bool RemoveToolTier(MineRock obj, ZDO zdo) { if (zdo.GetInt(Hashes.ToolTierMineRock, -1) < 0) { return false; } zdo.RemoveInt(Hashes.ToolTierMineRock); obj.m_minToolTier = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<MineRock>()?.m_minToolTier ?? 0; return true; } private static bool RemoveToolTier(TreeBase obj, ZDO zdo) { if (zdo.GetInt(Hashes.ToolTierTreeBase, -1) < 0) { return false; } zdo.RemoveInt(Hashes.ToolTierTreeBase); obj.m_minToolTier = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<TreeBase>()?.m_minToolTier ?? 0; return true; } private static bool RemoveToolTier(TreeLog obj, ZDO zdo) { if (zdo.GetInt(Hashes.ToolTierTreeLog, -1) < 0) { return false; } zdo.RemoveInt(Hashes.ToolTierTreeLog); obj.m_minToolTier = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<TreeLog>()?.m_minToolTier ?? 0; return true; } private static bool RemoveToolTier(Destructible obj, ZDO zdo) { if (zdo.GetInt(Hashes.ToolTierDestructible, -1) < 0) { return false; } zdo.RemoveInt(Hashes.ToolTierDestructible); obj.m_minToolTier = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponent<Destructible>()?.m_minToolTier ?? 0; return true; } } [HarmonyPatch] public static class DungeonRooms { private static readonly List<DungeonGenerator> Dgs = new List<DungeonGenerator>(); public static void AddRoom(ZNetView obj, int hash, Vector3 pos, Quaternion rot) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) ZDO zDO = obj.GetZDO(); int num = zDO.GetInt(ZDOVars.s_rooms, 0); byte[] byteArray = zDO.GetByteArray(ZDOVars.s_roomData, (byte[])null); if (num > 0) { AddRoom(zDO, num, hash, pos, rot); } else if (byteArray != null) { AddRoom(zDO, byteArray, hash, pos, rot); } } private static void AddRoom(ZDO zdo, int rooms, int hash, Vector3 pos, Quaternion rot) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) zdo.Set(ZDOVars.s_rooms, rooms + 1, false); zdo.Set(StringExtensionMethods.GetStableHashCode("room" + rooms), hash, false); zdo.Set(StringExtensionMethods.GetStableHashCode("room" + rooms + "_pos"), pos); zdo.Set(StringExtensionMethods.GetStableHashCode("room" + rooms + "_rot"), rot); } private static void AddRoom(ZDO zdo, byte[] data, int hash, Vector3 pos, Quaternion rot) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) DungeonGenerator.saveStream.SetLength(0L); BinaryReader binaryReader = new BinaryReader(new MemoryStream(data)); int num = binaryReader.ReadInt32(); DungeonGenerator.saveWriter.Write(num + 1); for (int i = 0; i < num; i++) { DungeonGenerator.saveWriter.Write(binaryReader.ReadInt32()); Utils.Write(DungeonGenerator.saveWriter, Utils.ReadVector3(binaryReader)); Utils.Write(DungeonGenerator.saveWriter, Utils.ReadQuaternion(binaryReader)); } DungeonGenerator.saveWriter.Write(hash); Utils.Write(DungeonGenerator.saveWriter, pos); Utils.Write(DungeonGenerator.saveWriter, rot); zdo.Set(ZDOVars.s_roomData, DungeonGenerator.saveStream.ToArray()); } public static void RemoveRoom(ZNetView obj, int index) { ZDO zDO = obj.GetZDO(); int num = zDO.GetInt(ZDOVars.s_rooms, 0); if (num > 0) { Remove(zDO, num, index); } byte[] byteArray = zDO.GetByteArray(ZDOVars.s_roomData, (byte[])null); if (byteArray != null) { Remove(zDO, byteArray, index); } if (((Component)obj).transform.childCount >= 1) { Transform child = ((Component)obj).transform.GetChild(index); if (Object.op_Implicit((Object)(object)child)) { child.parent = null; Object.Destroy((Object)(object)((Component)child).gameObject); } } } private static void Remove(ZDO zdo, int rooms, int index) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) for (int i = index + 1; i < rooms; i++) { int stableHashCode = StringExtensionMethods.GetStableHashCode("room" + i); int stableHashCode2 = StringExtensionMethods.GetStableHashCode("room" + (i - 1)); zdo.Set(stableHashCode2, zdo.GetInt(stableHashCode, 0), false); stableHashCode = StringExtensionMethods.GetStableHashCode("room" + i + "_pos"); stableHashCode2 = StringExtensionMethods.GetStableHashCode("room" + (i - 1) + "_pos"); zdo.Set(stableHashCode2, zdo.GetVec3(stableHashCode, Vector3.zero)); stableHashCode = StringExtensionMethods.GetStableHashCode("room" + i + "_rot"); stableHashCode2 = StringExtensionMethods.GetStableHashCode("room" + (i - 1) + "_rot"); zdo.Set(stableHashCode2, zdo.GetQuaternion(stableHashCode, Quaternion.identity)); } zdo.Set(ZDOVars.s_rooms, rooms - 1, false); zdo.RemoveInt(StringExtensionMethods.GetStableHashCode("room" + rooms)); zdo.RemoveVec3(StringExtensionMethods.GetStableHashCode("room" + rooms + "_pos")); zdo.RemoveQuaternion(StringExtensionMethods.GetStableHashCode("room" + rooms + "_rot")); } private static void Remove(ZDO zdo, byte[] data, int index) { //IL_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_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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) DungeonGenerator.saveStream.SetLength(0L); BinaryReader binaryReader = new BinaryReader(new MemoryStream(data)); int num = binaryReader.ReadInt32(); DungeonGenerator.saveWriter.Write(num - 1); for (int i = 0; i < num; i++) { int value = binaryReader.ReadInt32(); Vector3 val = Utils.ReadVector3(binaryReader); Quaternion val2 = Utils.ReadQuaternion(binaryReader); if (i != index) { DungeonGenerator.saveWriter.Write(value); Utils.Write(DungeonGenerator.saveWriter, val); Utils.Write(DungeonGenerator.saveWriter, val2); } } zdo.Set(ZDOVars.s_roomData, DungeonGenerator.saveStream.ToArray()); } public static void Reposition(ZDO zdo, Transform target) { GameObject prefab = ZNetScene.instance.GetPrefab(zdo.GetPrefab()); if (Object.op_Implicit((Object)(object)prefab) && Object.op_Implicit((Object)(object)prefab.GetComponent<DungeonGenerator>())) { List<Transform> trs = (from r in ((Component)target).GetComponentsInChildren<Room>() select ((Component)r).transform).ToList(); byte[] byteArray = zdo.GetByteArray(ZDOVars.s_roomData, (byte[])null); int num = zdo.GetInt(ZDOVars.s_rooms, 0); if (num > 0) { Reposition(zdo, num, trs); } else if (byteArray != null) { Reposition(zdo, byteArray, trs); } } } private static void Reposition(ZDO zdo, int rooms, List<Transform> trs) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < rooms; i++) { int stableHashCode = StringExtensionMethods.GetStableHashCode("room" + i + "_pos"); int stableHashCode2 = StringExtensionMethods.GetStableHashCode("room" + i + "_rot"); if (trs.Count <= i) { zdo.Set(stableHashCode, zdo.GetPosition()); zdo.Set(stableHashCode2, zdo.GetRotation()); } else { zdo.Set(stableHashCode, trs[i].position); zdo.Set(stableHashCode2, trs[i].rotation); } } } private static void Reposition(ZDO zdo, byte[] data, List<Transform> trs) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) DungeonGenerator.saveStream.SetLength(0L); BinaryReader binaryReader = new BinaryReader(new MemoryStream(data)); int num = binaryReader.ReadInt32(); DungeonGenerator.saveWriter.Write(num); for (int i = 0; i < num; i++) { DungeonGenerator.saveWriter.Write(binaryReader.ReadInt32()); if (trs.Count <= i) { Utils.Write(DungeonGenerator.saveWriter, zdo.GetPosition()); Utils.Write(DungeonGenerator.saveWriter, zdo.GetRotation()); } else { Utils.Write(DungeonGenerator.saveWriter, trs[i].position); Utils.Write(DungeonGenerator.saveWriter, trs[i].rotation); } } zdo.Set(ZDOVars.s_roomData, DungeonGenerator.saveStream.ToArray()); } public static DungeonGenerator? FindClosestDg(Vector3 pos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return Dgs.OrderBy(delegate(DungeonGenerator dg) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Distance(pos, ((Component)dg).transform.position); Room val = default(Room); foreach (Transform item in ((Component)dg).transform) { if (((Component)item).TryGetComponent<Room>(ref val)) { RoomConnection[] connections = val.GetConnections(); foreach (RoomConnection val2 in connections) { float num2 = Vector3.Distance(pos, ((Component)val2).transform.position); if (num2 < num) { num = num2; } } } } return num; }).FirstOrDefault(); } [HarmonyPatch(typeof(DungeonGenerator), "Awake")] [HarmonyPostfix] private static void DungeonGeneratorAwake(DungeonGenerator __instance) { Dgs.Add(__instance); } [HarmonyPatch(typeof(DungeonGenerator), "OnDestroy")] [HarmonyPostfix] private static void DungeonGeneratorDestroy(DungeonGenerator __instance) { Dgs.Remove(__instance); } [HarmonyPatch(typeof(Piece), "GetSnapPoints", new Type[] { typeof(Vector3), typeof(float), typeof(List<Transform>), typeof(List<Piece>) })] [HarmonyPrefix] private static void GetSnapPointsRadius(ref float radius) { float snapMultiplier = Selection.Get().SnapMultiplier; radius *= snapMultiplier; } [HarmonyPatch(typeof(Piece), "GetSnapPoints", new Type[] { typeof(Vector3), typeof(float), typeof(List<Transform>), typeof(List<Piece>) })] [HarmonyPostfix] private static void GetSnapPoints(Vector3 point, float radius, List<Transform> points) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) float dungeonRoomSnapMultiplier = Selection.Get().DungeonRoomSnapMultiplier; Room val = default(Room); foreach (DungeonGenerator dg in Dgs) { foreach (Transform item in ((Component)dg).transform) { if (!((Component)item).TryGetComponent<Room>(ref val)) { continue; } RoomConnection[] connections = val.GetConnections(); foreach (RoomConnection val2 in connections) { if (Vector3.Distance(point, ((Component)val2).transform.position) <= radius * dungeonRoomSnapMultiplier) { points.Add(((Component)val2).transform); } } } } } } [HarmonyPatch] public static class Manipulation { private static Vector3 CurrentNormal = Vector3.up; [HarmonyPatch(typeof(Player), "FindClosestSnapPoints")] [HarmonyPrefix] private static bool DisableSnapsWhenFrozen() { return !Position.Override.HasValue; } [HarmonyPatch(typeof(Player), "PieceRayTest")] [HarmonyPostfix] private static void FreezePlacementMarker(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")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> OverridePlacementGhost(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(); } [HarmonyPatch(typeof(Humanoid), "UnequipItem")] [HarmonyPrefix] private static void UnfreezeOnUnequip(Humanoid __instance, ItemData item) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && item != null && Configuration.UnfreezeOnUnequip) { Position.Unfreeze(); } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] [HarmonyPrefix] private static void DisableSnapCycleWhenTypingPrefix(Player __instance, ref int __state) { __state = __instance.m_manualSnapPoint; } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] [HarmonyPostfix] private static void DisableSnapCycleWhenTypingPostfix(Player __instance, int __state) { if (!((Character)__instance).TakeInput()) { __instance.m_manualSnapPoint = __state; } } } 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) { //IL_00a7: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) ZDO zDO = view.GetZDO(); if (Configuration.NoCreator) { zDO.RemoveLong(ZDOVars.s_creator); zDO.RemoveInt(ZDOVars.s_creatorIndex); piece.m_creator = 0L; piece.m_creatorPlatformUserIDIndex = -1; ZDOHelper.Remove<string>(ZDOExtraData.s_strings, zDO.m_uid, ZDOVars.s_creatorName); ZDOHelper.Remove<string>(ZDOExtraData.s_strings, zDO.m_uid, Hashes.XRaySteamName); ZDOHelper.Remove<string>(ZDOExtraData.s_strings, zDO.m_uid, Hashes.XRaySteamID); zDO.RemoveLong(Hashes.XRayCreatedID); } else { piece.m_creator = 0L; piece.SetCreator(Game.instance.GetPlayerProfile().GetPlayerID(), ((IUser)PlatformManager.DistributionPlatform.LocalUser).PlatformUserID); } if (Configuration.NoTarget && (((StaticTarget)piece).m_primaryTarget || ((StaticTarget)piece).m_randomTarget)) { zDO.Set(Hashes.HasFields, true); zDO.Set(Hashes.HasFieldsStaticTarget, true); if (((StaticTarget)piece).m_primaryTarget) { ((StaticTarget)piece).m_primaryTarget = false; zDO.Set(Hashes.StaticTargetPrimaryTarget, false); } if (((StaticTarget)piece).m_randomTarget) { ((StaticTarget)piece).m_randomTarget = false; zDO.Set(Hashes.StaticTargetRandomTarget, false); } view.LoadFields(); } StaticPhysics val = default(StaticPhysics); if (Configuration.NoPhysics && ((Component)piece).TryGetComponent<StaticPhysics>(ref val) && (val.m_fall || val.m_pushUp)) { zDO.Set(Hashes.HasFields, true); zDO.Set(Hashes.HasFieldsStaticPhysics, true); if (val.m_fall) { val.m_fall = false; zDO.Set(Hashes.StaticPhysicsFall, false);