using System; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using ExitGames.Client.Photon; using HarmonyLib; using ImGuiNET; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Peak.Network; using Photon.Pun; using Photon.Realtime; using PhotonCustomPropsUtils; using Sirenix.Serialization; using Steamworks; using TerrainCustomiserCN.Managers; using TerrainCustomiserCN.Map; using TerrainCustomiserCN.Map.Serialization; using TerrainCustomiserCN.Session; using TerrainCustomiserCN.TerrainGeneration; using TerrainCustomiserCN.UI; using TerrainCustomiserCN.UI.Modals; using TerrainCustomiserCN.UI.Windows; using TerrainCustomiserCN.Utils; using UBImGui; using Unity.Burst; using Unity.Collections; using Unity.Jobs; using Unity.Mathematics; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RegisterFormatter(typeof(GameObjectFormatter), 10)] [assembly: RegisterFormatter(typeof(MaterialFormatter), 10)] [assembly: RegisterFormatter(typeof(TransformFormatter), 10)] [assembly: AssemblyCompany("TerrainCustomiserCN")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("TerrainCustomiserCN")] [assembly: AssemblyTitle("TerrainCustomiserCN")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public sealed class GameObjectFormatter : MinimalBaseFormatter { protected override void Read(ref GameObject value, IDataReader reader) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown string text = default(string); string kv = default(string); while ((int)reader.PeekEntry(ref text) != 8) { reader.ReadString(ref kv); if (text == "name") { GameObject val = TerrainCustomiserCN.Map.ResourceManager.GameObjectResources.Find((GameObject x) => ((Object)x).name == kv); value = val; } else if (text == "targetId") { GameObject val2 = new GameObject(kv); val2.SetActive(false); value = val2; MapSerializer.testgos.Add(val2); } else { reader.SkipEntry(); } } } protected override void Write(ref GameObject value, IDataWriter writer) { GameObject go = value.gameObject; KeyValuePair keyValuePair = MapSerializer.GameObjectReferences.FirstOrDefault((KeyValuePair x) => (Object)(object)x.Value == (Object)(object)go); if ((Object)(object)keyValuePair.Value == (Object)null) { writer.WriteString("name", ((Object)value).name); } else { writer.WriteString("targetId", keyValuePair.Key); } } } public sealed class MaterialFormatter : MinimalBaseFormatter { protected override void Read(ref Material value, IDataReader reader) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 string text = default(string); string kv = default(string); while ((int)reader.PeekEntry(ref text) != 8) { reader.ReadString(ref kv); if (text == "name") { Material val = TerrainCustomiserCN.Map.ResourceManager.MaterialResources.Find((Material x) => (Object)(object)x != (Object)null && ((Object)x).name == kv); value = val; } else { reader.SkipEntry(); } } } protected override void Write(ref Material value, IDataWriter writer) { writer.WriteString("name", ((Object)value).name); } } public sealed class TransformFormatter : MinimalBaseFormatter { protected override void Read(ref Transform value, IDataReader reader) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown string text = default(string); string text2 = default(string); while ((int)reader.PeekEntry(ref text) != 8) { reader.ReadString(ref text2); if (text == "refid") { GameObject val = new GameObject(text2); val.SetActive(false); value = val.transform; MapSerializer.testgos.Add(val); } else if (text == "refpath") { GameObject val2 = GameObject.Find(text2); if ((Object)(object)val2 != (Object)null) { value = val2.transform; } else { value = null; } } else { reader.SkipEntry(); } } } protected override void Write(ref Transform value, IDataWriter writer) { GameObject go = ((Component)value).gameObject; KeyValuePair keyValuePair = MapSerializer.GameObjectReferences.FirstOrDefault((KeyValuePair x) => (Object)(object)x.Value == (Object)(object)go); if ((Object)(object)keyValuePair.Value == (Object)null) { string pathFromGameObject = MapSerializer.GetPathFromGameObject(go); writer.WriteString("refpath", pathFromGameObject); } else { writer.WriteString("refid", keyValuePair.Key); } } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace TerrainCustomiserCN { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInIncompatibility("com.snosz.terraincustomiser")] [BepInPlugin("com.wuyachiyu.terraincustomisercn", "TerrainCustomiserCN", "0.1.0")] public class Plugin : BaseUnityPlugin { public static Plugin Instance; private static Harmony _harmony; private void Awake() { Instance = this; ConfigManager.Setup(); BundleManager.Setup(); PlayerInfoManager.Setup(); _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); WindowsManager.Setup(); } private void OnDestroy() { _harmony.UnpatchSelf(); BundleManager.UnloadAll(); Object.Destroy((Object)(object)Singleton.Instance); } public void LoadWilIsland() { AirportCheckInKiosk val = Object.FindFirstObjectByType(); if ((Object)(object)val == (Object)null) { Debug.LogError((object)"[TCCN] 未找到机场登机台"); return; } int ascentIndex = GUIManager.instance.boardingPass.ascentIndex; ((MonoBehaviourPun)val).photonView.RPC("BeginIslandLoadRPC", (RpcTarget)0, new object[3] { "WilIsland", ascentIndex, RunSettings.GetSerializedRunSettings() }); } } [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")] [DebuggerNonUserCode] [CompilerGenerated] internal class Resource1 { private static System.Resources.ResourceManager resourceMan; private static CultureInfo resourceCulture; [EditorBrowsable(EditorBrowsableState.Advanced)] internal static System.Resources.ResourceManager ResourceManager { get { if (resourceMan == null) { resourceMan = new System.Resources.ResourceManager("TerrainCustomiserCN.Resource1", typeof(Resource1).Assembly); } return resourceMan; } } [EditorBrowsable(EditorBrowsableState.Advanced)] internal static CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } internal static byte[] selectionoverlay => (byte[])ResourceManager.GetObject("selectionoverlay", resourceCulture); internal static byte[] visibilitycompute => (byte[])ResourceManager.GetObject("visibilitycompute", resourceCulture); internal Resource1() { } } } namespace TerrainCustomiserCN.Utils { internal static class TerrainCustomiserSerialization { public static SerializationContext CreateSerializationContext() { //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_0011: Expected O, but got Unknown return new SerializationContext { Binder = (TwoWaySerializationBinder)(object)TerrainCustomiserCompatibilityBinder.Instance }; } public static DeserializationContext CreateDeserializationContext() { //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_0011: Expected O, but got Unknown return new DeserializationContext { Binder = (TwoWaySerializationBinder)(object)TerrainCustomiserCompatibilityBinder.Instance }; } } internal sealed class TerrainCustomiserCompatibilityBinder : TwoWaySerializationBinder { public static readonly TerrainCustomiserCompatibilityBinder Instance = new TerrainCustomiserCompatibilityBinder(); private static readonly string[,] TypeNameMappings = new string[8, 2] { { typeof(PlayerInfo).FullName + ", TerrainCustomiserCN", "TerrainCustomiser.Managers.PlayerInfo, TerrainCustomiser" }, { typeof(MapSerializer.ObjectData).FullName + ", TerrainCustomiserCN", "TerrainCustomiser.Map.Serialization.MapSerializer+ObjectData, TerrainCustomiser" }, { typeof(MapSerializer.TransformData).FullName + ", TerrainCustomiserCN", "TerrainCustomiser.Map.Serialization.MapSerializer+TransformData, TerrainCustomiser" }, { typeof(MapSerializer.ComponentData).FullName + ", TerrainCustomiserCN", "TerrainCustomiser.Map.Serialization.MapSerializer+ComponentData, TerrainCustomiser" }, { typeof(MapSerializer.FieldData).FullName + ", TerrainCustomiserCN", "TerrainCustomiser.Map.Serialization.MapSerializer+FieldData, TerrainCustomiser" }, { typeof(MapSerializer.MapSaveData).FullName + ", TerrainCustomiserCN", "TerrainCustomiser.Map.Serialization.MapSerializer+MapSaveData, TerrainCustomiser" }, { typeof(MapSerializer.MapSyncData).FullName + ", TerrainCustomiserCN", "TerrainCustomiser.Map.Serialization.MapSerializer+MapSyncData, TerrainCustomiser" }, { typeof(MapSerializer.SegmentSaveData).FullName + ", TerrainCustomiserCN", "TerrainCustomiser.Map.Serialization.MapSerializer+SegmentSaveData, TerrainCustomiser" } }; private TerrainCustomiserCompatibilityBinder() { } public override string BindToName(Type type, DebugContext debugContext = null) { return ReplaceTypeNames(TwoWaySerializationBinder.Default.BindToName(type, debugContext), useOriginalNames: true); } public override Type BindToType(string typeName, DebugContext debugContext = null) { string text = ReplaceTypeNames(typeName, useOriginalNames: false); if (!string.Equals(text, typeName, StringComparison.Ordinal)) { Type type = TwoWaySerializationBinder.Default.BindToType(text, debugContext); if (type != null) { return type; } } return TwoWaySerializationBinder.Default.BindToType(typeName, debugContext); } public override bool ContainsType(string typeName) { string text = ReplaceTypeNames(typeName, useOriginalNames: false); if (!TwoWaySerializationBinder.Default.ContainsType(typeName)) { return TwoWaySerializationBinder.Default.ContainsType(text); } return true; } private static string ReplaceTypeNames(string typeName, bool useOriginalNames) { string text = typeName; for (int i = 0; i < TypeNameMappings.GetLength(0); i++) { string text2 = TypeNameMappings[i, 0]; string text3 = TypeNameMappings[i, 1]; text = text.Replace(useOriginalNames ? text2 : text3, useOriginalNames ? text3 : text2); } return text; } } public class DebugVisualiser : MonoBehaviour { private abstract class Shape { public Color color; public float duration; public float startTime; private int startFrame; public bool alwaysOnTop; public bool Expired { get { if (!(duration <= 0f)) { return Time.time - startTime > duration; } return Time.frameCount > startFrame; } } protected Shape(Color color, float duration, bool alwaysOnTop) { //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) this.color = color; this.duration = duration; this.alwaysOnTop = alwaysOnTop; startTime = Time.time; startFrame = Time.frameCount; } public abstract void Draw(); } private class MeshShape : Shape { private Mesh mesh; private Transform transform; public MeshShape(Mesh mesh, Transform transform, Color color, float duration, bool alwaysOnTop) : base(color, duration, alwaysOnTop) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) this.mesh = mesh; this.transform = transform; } public override void Draw() { //IL_005b: 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_0065: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)mesh == (Object)null) && !((Object)(object)transform == (Object)null)) { Vector3[] vertices = mesh.vertices; int[] triangles = mesh.triangles; for (int i = 0; i < triangles.Length; i += 3) { int num = triangles[i]; int num2 = triangles[i + 1]; int num3 = triangles[i + 2]; Vector3 val = transform.TransformPoint(vertices[num]); Vector3 val2 = transform.TransformPoint(vertices[num2]); Vector3 val3 = transform.TransformPoint(vertices[num3]); GL.Color(color); GL.Vertex(val); GL.Vertex(val2); GL.Vertex(val2); GL.Vertex(val3); GL.Vertex(val3); GL.Vertex(val); } } } } private class BoxShape : Shape { private Vector3 center; private Vector3 size; private Quaternion rotation; public BoxShape(Vector3 center, Vector3 size, Quaternion rotation, Color color, float duration, bool alwaysOnTop) : base(color, duration, alwaysOnTop) { //IL_0001: 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_000e: 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_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) this.center = center; this.size = size; this.rotation = rotation; } public override void Draw() { //IL_0001: 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_0010: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_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_003a: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //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_0067: 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_0072: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00a6: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) Vector3 val = size * 0.5f; Vector3[] array = (Vector3[])(object)new Vector3[8] { new Vector3(0f - val.x, 0f - val.y, 0f - val.z), new Vector3(val.x, 0f - val.y, 0f - val.z), new Vector3(val.x, 0f - val.y, val.z), new Vector3(0f - val.x, 0f - val.y, val.z), new Vector3(0f - val.x, val.y, 0f - val.z), new Vector3(val.x, val.y, 0f - val.z), new Vector3(val.x, val.y, val.z), new Vector3(0f - val.x, val.y, val.z) }; for (int i = 0; i < array.Length; i++) { array[i] = center + rotation * array[i]; } int[,] array2 = new int[12, 2] { { 0, 1 }, { 1, 2 }, { 2, 3 }, { 3, 0 }, { 4, 5 }, { 5, 6 }, { 6, 7 }, { 7, 4 }, { 0, 4 }, { 1, 5 }, { 2, 6 }, { 3, 7 } }; GL.Color(color); for (int j = 0; j < array2.GetLength(0); j++) { GL.Vertex(array[array2[j, 0]]); GL.Vertex(array[array2[j, 1]]); } } } private class RayShape : Shape { private Vector3 from; private Vector3 dir; public RayShape(Vector3 from, Vector3 dir, Color color, float duration, bool alwaysOnTop) : base(color, duration, alwaysOnTop) { //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_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) this.from = from; this.dir = dir; } public override void Draw() { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) GL.Color(color); GL.Vertex(from); GL.Vertex(from + dir); } } private class LineShape : Shape { private Vector3 from; private Vector3 to; public LineShape(Vector3 from, Vector3 to, Color color, float duration, bool alwaysOnTop) : base(color, duration, alwaysOnTop) { //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_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) this.from = from; this.to = to; } public override void Draw() { //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_0017: Unknown result type (might be due to invalid IL or missing references) GL.Color(color); GL.Vertex(from); GL.Vertex(to); } } private class SphereShape : Shape { private Vector3 pos; private float radius; public SphereShape(Vector3 pos, float radius, Color color, float duration, bool alwaysOnTop) : base(color, duration, alwaysOnTop) { //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_000d: Unknown result type (might be due to invalid IL or missing references) this.pos = pos; this.radius = radius; } public override void Draw() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) int num = 24; for (int i = 0; i < num; i++) { float num2 = (float)i / (float)num * MathF.PI * 2f; float num3 = (float)(i + 1) / (float)num * MathF.PI * 2f; Vector3 val = pos + new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * radius; Vector3 val2 = pos + new Vector3(Mathf.Cos(num3), 0f, Mathf.Sin(num3)) * radius; GL.Color(color); GL.Vertex(val); GL.Vertex(val2); Vector3 val3 = pos + new Vector3(0f, Mathf.Cos(num2), Mathf.Sin(num2)) * radius; Vector3 val4 = pos + new Vector3(0f, Mathf.Cos(num3), Mathf.Sin(num3)) * radius; GL.Vertex(val3); GL.Vertex(val4); Vector3 val5 = pos + new Vector3(Mathf.Cos(num2), Mathf.Sin(num2), 0f) * radius; Vector3 val6 = pos + new Vector3(Mathf.Cos(num3), Mathf.Sin(num3), 0f) * radius; GL.Vertex(val5); GL.Vertex(val6); } } } private static DebugVisualiser _instance; private List _shapes = new List(); private Material lineMaterialNormal; private Material lineMaterialOverlay; private void Awake() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { _instance = this; } else { Object.Destroy((Object)(object)((Component)this).gameObject); } lineMaterialNormal = new Material(Shader.Find("Hidden/Internal-Colored")); lineMaterialOverlay = new Material(Shader.Find("Hidden/Internal-Colored")); lineMaterialOverlay.SetInt("_ZTest", 8); RenderPipelineManager.endCameraRendering += OnEndCameraRendering; } private void OnDisable() { RenderPipelineManager.endCameraRendering -= OnEndCameraRendering; } private void OnEndCameraRendering(ScriptableRenderContext ctx, Camera cam) { if (_shapes.Count != 0) { DrawShapes(overlay: false, lineMaterialNormal); DrawShapes(overlay: true, lineMaterialOverlay); } } public static void DrawRay(Vector3 from, Vector3 dir, Color color, float duration = 0f, bool alwaysOnTop = false) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_instance == (Object)null) { CreateInstance(); } _instance._shapes.Add(new RayShape(from, dir, color, duration, alwaysOnTop)); } public static void DrawSphere(Vector3 pos, float radius, Color color, float duration = 0f, bool alwaysOnTop = false) { //IL_001c: 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) if ((Object)(object)_instance == (Object)null) { CreateInstance(); } _instance._shapes.Add(new SphereShape(pos, radius, color, duration, alwaysOnTop)); } public static void DrawLine(Vector3 from, Vector3 to, Color color, float duration = 0f, bool alwaysOnTop = false) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_instance == (Object)null) { CreateInstance(); } _instance._shapes.Add(new LineShape(from, to, color, duration, alwaysOnTop)); } public static void DrawBox(Vector3 center, Vector3 size, Color color, float duration = 0f, bool alwaysOnTop = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) DrawBox(center, size, Quaternion.identity, color, duration, alwaysOnTop); } public static void DrawBox(Vector3 center, Vector3 size, Quaternion rotation, Color color, float duration = 0f, bool alwaysOnTop = false) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //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) if ((Object)(object)_instance == (Object)null) { CreateInstance(); } _instance._shapes.Add(new BoxShape(center, size, rotation, color, duration, alwaysOnTop)); } public static void DrawMeshCollider(MeshCollider collider, Color color, float duration = 0f, bool alwaysOnTop = false) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)collider == (Object)null) && !((Object)(object)collider.sharedMesh == (Object)null)) { if ((Object)(object)_instance == (Object)null) { CreateInstance(); } _instance._shapes.Add(new MeshShape(collider.sharedMesh, ((Component)collider).transform, color, duration, alwaysOnTop)); } } private static void CreateInstance() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) _instance = new GameObject("TCCN_DebugVisualiser") { hideFlags = (HideFlags)61 }.AddComponent(); } private void DrawShapes(bool overlay, Material mat) { mat.SetPass(0); GL.Begin(1); for (int num = _shapes.Count - 1; num >= 0; num--) { if (_shapes[num].Expired) { _shapes.RemoveAt(num); } else if (_shapes[num].alwaysOnTop == overlay) { _shapes[num].Draw(); } } GL.End(); } } public static class GizmoUtils { public class RendererMaterialCache { public Renderer Renderer; public Material[] OriginalMaterials; public Material OverlayMaterial; } internal static Shader SelectionOverlayShader; public static void TryDrawGizmos(Transform target, Component component) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0048: 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_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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) if (component is PropSpawner) { PropSpawner val = (PropSpawner)component; DrawPropSpawnerGizmos(component.transform, val.area, val.rayLength, val.rayNearCutoff); } else if (component is PropSpawner_Line) { PropSpawner_Line val2 = (PropSpawner_Line)component; Vector3 to = ((Component)val2).transform.position + val2.height * 0.5f * ((Component)val2).transform.up; DebugVisualiser.DrawLine(((Component)val2).transform.position - val2.height * 0.5f * ((Component)val2).transform.up, to, Color.white); } else if (component is PropSpawner_Sphere) { PropSpawner_Sphere val3 = (PropSpawner_Sphere)component; DebugVisualiser.DrawSphere(((Component)val3).transform.position, val3.rayLength, Color.white); } else if (component is SpecialDayZone) { SpecialDayZone val4 = (SpecialDayZone)component; DebugVisualiser.DrawBox(((Component)val4).transform.position, ((Bounds)(ref val4.bounds)).size, Color.white); } } public static void TryDrawOverlays(Transform target) { } public static void TryRestoreMaterials() { } public static void DrawPropSpawnerGizmos(Transform target, Vector2 area, float rayLength, float rayNearCutoff) { //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_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) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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_0040: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_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_007b: 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_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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_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_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: 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_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: 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_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: 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_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) Vector3 val = target.position + area.y * 0.5f * target.up; Vector3 val2 = target.position - area.y * 0.5f * target.up; Vector3 val3 = target.position - area.x * 0.5f * target.right; Vector3 val4 = target.position + area.x * 0.5f * target.right; DebugVisualiser.DrawLine(val2, val, Color.white); DebugVisualiser.DrawLine(val3, val4, Color.white); DebugVisualiser.DrawLine(val2, val2 + target.forward * rayLength + target.forward * rayNearCutoff, Color.green); DebugVisualiser.DrawLine(val, val + target.forward * rayLength + target.forward * rayNearCutoff, Color.green); DebugVisualiser.DrawLine(val3, val3 + target.forward * rayLength + target.forward * rayNearCutoff, Color.green); DebugVisualiser.DrawLine(val4, val4 + target.forward * rayLength + target.forward * rayNearCutoff, Color.green); DebugVisualiser.DrawBox(target.position + target.forward * rayLength / 2f, Vector3.one, target.rotation, Color.green); DebugVisualiser.DrawLine(val2, val2 + target.forward * rayNearCutoff, Color.red); DebugVisualiser.DrawLine(val3, val3 + target.forward * rayNearCutoff, Color.red); DebugVisualiser.DrawLine(val, val + target.forward * rayNearCutoff, Color.red); DebugVisualiser.DrawLine(val4, val4 + target.forward * rayNearCutoff, Color.red); } public static List GetRenderersFromObject(GameObject target) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) List list = new List(); LODGroup[] componentsInChildren = target.GetComponentsInChildren(true); if (componentsInChildren != null && componentsInChildren.Length != 0) { LODGroup[] array = componentsInChildren; for (int i = 0; i < array.Length; i++) { LOD[] lODs = array[i].GetLODs(); for (int j = 0; j < lODs.Length; j++) { Renderer[] renderers = lODs[j].renderers; foreach (Renderer val in renderers) { if (!((Object)(object)val == (Object)null)) { list.Add(val); } } } } return list; } return target.GetComponentsInChildren(true).ToList(); } public static List ApplyOverlayToRenderers(List renderers) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown List list = new List(); foreach (Renderer renderer in renderers) { Material[] sharedMaterials = renderer.sharedMaterials; Material val = new Material(SelectionOverlayShader); list.Add(new RendererMaterialCache { Renderer = renderer, OriginalMaterials = sharedMaterials, OverlayMaterial = val }); Material[] array = (Material[])(object)new Material[sharedMaterials.Length + 1]; Array.Copy(sharedMaterials, array, sharedMaterials.Length); array[^1] = val; renderer.sharedMaterials = array; } return list; } public static List ApplyOverlayToRenderers(Renderer[] renderers) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown List list = new List(); foreach (Renderer val in renderers) { Material[] sharedMaterials = val.sharedMaterials; Material val2 = new Material(SelectionOverlayShader); list.Add(new RendererMaterialCache { Renderer = val, OriginalMaterials = sharedMaterials, OverlayMaterial = val2 }); Material[] array = (Material[])(object)new Material[sharedMaterials.Length + 1]; Array.Copy(sharedMaterials, array, sharedMaterials.Length); array[^1] = val2; val.sharedMaterials = array; } return list; } public static void RestoreRendererMaterials(List rendererCache) { foreach (RendererMaterialCache item in rendererCache) { if (!((Object)(object)item.Renderer == (Object)null)) { item.Renderer.sharedMaterials = item.OriginalMaterials; if ((Object)(object)item.OverlayMaterial != (Object)null) { Object.Destroy((Object)(object)item.OverlayMaterial); } } } rendererCache.Clear(); } } public static class NetworkUtils { public static byte[] CompressBrotli(byte[] data) { using MemoryStream memoryStream = new MemoryStream(); using (BrotliStream brotliStream = new BrotliStream(memoryStream, CompressionLevel.Optimal)) { brotliStream.Write(data, 0, data.Length); } return memoryStream.ToArray(); } public static byte[] DecompressBrotli(byte[] compressed) { using MemoryStream stream = new MemoryStream(compressed); using BrotliStream brotliStream = new BrotliStream(stream, CompressionMode.Decompress); using MemoryStream memoryStream = new MemoryStream(); brotliStream.CopyTo(memoryStream); return memoryStream.ToArray(); } public static byte[] SerializeMapSyncData(MapSerializer.MapSyncData data) { string s = JsonConvert.SerializeObject((object)data); return Encoding.UTF8.GetBytes(s); } public static MapSerializer.MapSyncData DeserializeMapSyncData(byte[] bytes) { return JsonConvert.DeserializeObject(Encoding.UTF8.GetString(bytes)); } public static byte[] CompressMapSyncData(MapSerializer.MapSyncData data) { return CompressBrotli(SerializeMapSyncData(data)); } public static MapSerializer.MapSyncData DecompressMapSyncData(byte[] compressed) { return DeserializeMapSyncData(DecompressBrotli(compressed)); } public static void SetMapDataRoomProperty(MapSerializer.MapSyncData mapSyncData) { byte[] array = CompressMapSyncData(mapSyncData); double num = (double)array.Length / 1048576.0; Debug.Log((object)$"Compressed MapSyncData Size: {num:F2} MB"); NetworkManager.SetRoomProperty("mapData", array); } } } namespace TerrainCustomiserCN.UI { public static class ContextMenu { private static Type[] types; public static void GetTypes(Type type) { types = GetConcreteDerivedTypes(type); } public static void CreateMenu(IList list, Type type) { if (!ImGui.BeginPopupContextItem("WidgetContextMenu")) { return; } for (int i = 0; i < types.Length; i++) { Type type2 = types[i]; if (ImGui.Selectable(DisplayNameTranslator.TypeName(type2, "ContextMenu") + "##" + type2.FullName)) { object value = Activator.CreateInstance(type2); list.Add(value); types = null; break; } } ImGui.EndPopup(); } private static Type[] GetConcreteDerivedTypes(Type baseType) { return (from t in AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly a) => a.GetTypes()) where baseType.IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface select t).ToArray(); } } public enum TranslationKind { Ui, Field, Type, Enum, Dynamic } public readonly struct MissingTranslation { public TranslationKind Kind { get; } public string Key { get; } public string Source { get; } public MissingTranslation(TranslationKind kind, string key, string source) { Kind = kind; Key = key; Source = source ?? string.Empty; } } public static class DisplayNameTranslator { private static readonly Dictionary UiNames = new Dictionary(StringComparer.Ordinal) { { "Editor", "编辑器" }, { "Inspector", "检查器" }, { "Resource", "资源" }, { "GodCam Settings", "自由相机设置" }, { "Generate", "生成" }, { "Save", "保存" }, { "Load", "加载" }, { "Cam", "相机" }, { "Gizmo", "辅助线" }, { "Name", "名称" }, { "Value", "值" }, { "Type", "类型" }, { "Buttons", "按钮" }, { "Swap", "切换" }, { "Create", "创建" }, { "Delete", "删除" }, { "Remove", "移除" }, { "Add", "添加" }, { "Change", "更改" }, { "None", "无" }, { "No custom variant.", "没有自定义变体。" }, { "Create Spawner", "创建生成器" }, { "Create Grouper", "创建分组器" }, { "Duplicate", "复制" }, { "Rename", "重命名" }, { "Cancel", "取消" }, { "Apply", "应用" }, { "Select", "选择" }, { "Filter", "筛选" } }; private static readonly Dictionary FieldNames = new Dictionary(StringComparer.Ordinal) { { "area", "范围" }, { "rayDirectionOffset", "射线偏移" }, { "rayLength", "射线长度" }, { "rayNearCutoff", "近裁" }, { "raycastPosition", "射线位置" }, { "rayCastSpawn", "射线生成" }, { "nrOfSpawns", "数量" }, { "randomSpawns", "随机" }, { "minSpawnCount", "最少" }, { "chanceToUseSpawner", "概率" }, { "spawnChance", "概率" }, { "currentSpawns", "当前" }, { "props", "物件" }, { "syncTransforms", "同步" }, { "layerType", "层类型" }, { "LayerType", "层类型" }, { "modifiers", "修改器" }, { "constraints", "条件" }, { "postConstraints", "后置条件" }, { "postSpawnBehaviors", "生成后行为" }, { "height", "高度" }, { "timing", "时机" }, { "parents", "父级" }, { "mat", "材质" }, { "bounds", "范围" }, { "outerBounds", "外范围" }, { "blendSize", "混合" }, { "inBounds", "范围内" }, { "overrideSun", "覆盖日光" }, { "daylLightIntensity", "日间光强" }, { "nightLightIntensity", "夜间光强" }, { "specialSunColor", "日光色" }, { "useCustomSun", "自定义光源" }, { "specialLight", "光源" }, { "useCustomColorVals", "自定义颜色" }, { "specialTopColor", "顶色" }, { "specialMidColor", "中色" }, { "specialBottomColor", "底色" }, { "globalShaderVals", "着色值" }, { "overrideFog", "改雾" }, { "fogDensity", "雾密度" }, { "treePlatformParent", "树平台" }, { "localStart", "起点" }, { "localEnd", "终点" }, { "bannedMaterial", "禁材质" }, { "circleSize", "圆尺寸" }, { "inverted", "反转" }, { "invert", "反转" }, { "RaycastDistance", "射线距离" }, { "DesiredResult", "期望" }, { "maxHeight", "最高" }, { "minHeight", "最低" }, { "radius", "半径" }, { "objects", "对象" }, { "minAngle", "最小角" }, { "maxAngle", "最大角" }, { "perlinSize", "噪声尺寸" }, { "perlinOffset", "噪声偏移" }, { "minMax", "最小最大" }, { "RequiredMaterial", "需材质" }, { "minDistance", "最小距离" }, { "findAllSpawners", "全生成器" }, { "axisMultipliers", "轴倍率" }, { "effectedLayers", "影响层" }, { "whitelistedTagWords", "白名单词" }, { "blacklistedTagWords", "黑名单词" }, { "onePerPlayer", "每人一个" }, { "destroyAllIfLessThan", "少于销毁" }, { "customColor", "自定义颜色" }, { "color", "颜色" }, { "customIntensity", "自强度" }, { "intensity", "强度" }, { "offset", "偏移" }, { "minEffect", "最小效果" }, { "maxEffect", "最大效果" }, { "randomPow", "随机幂" }, { "minOffset", "最小偏" }, { "maxOffset", "最大偏" }, { "xMult", "X倍" }, { "yMult", "Y倍" }, { "zMult", "Z倍" }, { "maxScaleMult", "最大缩" }, { "minScaleMult", "最小缩" }, { "minRotation", "最小旋" }, { "maxRotation", "最大旋" }, { "snapToIncrement", "吸附步" }, { "increment", "步长" }, { "replaceThis", "替换项" }, { "withThis", "替换为" }, { "childName", "子名" }, { "edits", "编辑" }, { "mats", "材质组" }, { "flipNormal", "翻法线" }, { "objToSpawn", "生成物" }, { "addRotation", "加旋转" }, { "eulerAngles", "欧拉角" }, { "random", "随机" }, { "eulerAnglesRandom", "随机角" }, { "blend", "混合" }, { "minUpLerp", "最小上插" }, { "maxUpLerp", "最大上插" }, { "spawnerTransform", "生成器变换" }, { "pos", "位置" }, { "normal", "法线" }, { "rayDir", "射线方向" }, { "hit", "命中" }, { "placement", "放置" }, { "spawnCount", "生成数" }, { "_deferredSteps", "延迟步骤" }, { "_hm", "高度图" }, { "_madeDummyData", "已创建虚拟数据" }, { "_propSpawnData", "物件生成数据" }, { "_timing", "时机" }, { "k__BackingField", "已生成物件" }, { "k__BackingField", "验证状态" }, { "baseFog", "基础雾效" }, { "blockerObjects", "阻挡对象" }, { "blurIterations", "模糊迭代次数" }, { "blurRadius", "模糊半径" }, { "cellSize", "单元格尺寸" }, { "center", "中心" }, { "clampHeights", "限制高度" }, { "Deadzone", "死区" }, { "drawRayGizmos", "绘制射线辅助线" }, { "drawSamplePoints", "绘制采样点" }, { "enterenceObjects", "入口对象" }, { "enterences", "入口" }, { "heightOffset", "高度偏移" }, { "inside", "内部" }, { "layerMask", "层遮罩" }, { "maxRaycastLength", "最大射线长度" }, { "minBadEffects", "最少负面效果" }, { "minGoodEffects", "最少正面效果" }, { "minMaxSpawn", "最小最大生成数" }, { "mushroomEffects", "蘑菇效果" }, { "mushroomStamAmt", "蘑菇耐力量" }, { "mute", "静音" }, { "outVal", "输出值" }, { "overallSpawnChance", "总生成概率" }, { "perlinAmount", "噪声强度" }, { "perlinScale", "噪声缩放" }, { "postPerlinAmount", "后置噪声强度" }, { "postPerlinScale", "后置噪声缩放" }, { "requiredParents", "所需父级" }, { "resolution", "分辨率" }, { "returnVal", "返回值" }, { "scaleMinMax", "最小最大缩放" }, { "Segment", "区段" }, { "spawnedObjects", "已生成对象" }, { "spawnPoints", "生成点" }, { "triggerInteraction", "触发器交互" }, { "ValidateAfterwards", "随后验证" }, { "validationConstraints", "验证条件" } }; private static readonly Dictionary TypeNames = new Dictionary(StringComparer.Ordinal) { { "Transform", "变换" }, { "PropSpawner", "生成器" }, { "PropSpawner_Line", "线性生成器" }, { "PropSpawner_Sphere", "球形生成器" }, { "PropGrouper", "分组器" }, { "RockMaterialSwapper", "岩石材质替换器" }, { "SpecialDayZone", "特殊区域" }, { "PropSpawnerMod", "生成修改" }, { "PropSpawnerConstraint", "生成条件" }, { "PropSpawnerConstraintPost", "后置条件" }, { "PostSpawnBehavior", "生成后行为" }, { "PSB_ChildSpawners", "子生成器" }, { "PSC_BannedMaterial", "禁材质" }, { "PSC_CircleMask", "圆遮罩" }, { "PSC_Embedded", "嵌入检测" }, { "PSC_Height", "高度条件" }, { "PSC_LineCheck", "射线检测" }, { "PSC_NearObject", "近对象" }, { "PSC_Normal", "法线条件" }, { "PSC_Perlin", "噪声条件" }, { "PSC_RequiredMaterial", "需材质" }, { "PSC_SameTypeDistance", "同类距离" }, { "PSC_SurfaceRestrictions", "表面限制" }, { "PSC_VolumeLight", "体积光" }, { "PSM_AddPlayerCountBasedDespawner", "人数销毁" }, { "PSM_BakedVolumeLightModiferIntensity", "烘焙光强" }, { "PSM_BlastVine", "爆炸藤" }, { "PSM_ChildSpawners", "子生成器" }, { "PSM_LocalOffset", "本地偏移" }, { "PSM_NormalOffset", "法线偏移" }, { "PSM_PitonNormal", "岩钉法线" }, { "PSM_PlacementOffset", "放置偏移" }, { "PSM_RandomOffset", "随机偏移" }, { "PSM_RandomRotation", "随机旋转" }, { "PSM_RandomScale", "随机缩放" }, { "PSM_RayDirectionOffset", "射向偏移" }, { "PSM_ReplaceMaterial", "替换材质" }, { "PSM_ReplaceMaterialWithRayTargetMaterial", "用命中材质替换" }, { "PSM_SetForwardRotationToNormal", "前向对法线" }, { "PSM_SetMaterial", "设材质" }, { "PSM_SetMaterialOnChild", "设子材质" }, { "PSM_SetMaterialsOnChild", "设子材质组" }, { "PSM_SetRandomMaterial", "随机材质" }, { "PSM_SetSpawnerPlayerCountRequirement", "人数需求" }, { "PSM_SetUpRotationToNormal", "上向对法线" }, { "PSM_SingleItemSpawner", "单物品生成" }, { "PSM_SpecificRotation", "指定旋转" }, { "PSM_UpLerp", "上向插值" }, { "Campfire_Set_Segment", "营火区段设置" }, { "DecorSpawner", "装饰生成器" }, { "DesertRockSpawner", "沙漠岩石生成器" }, { "MushroomManager", "蘑菇管理器" }, { "PropDeleter", "物件删除器" }, { "PSCP_ConnectTreePlatforms", "连接树平台" }, { "PSCP_Custom", "自定义后置条件" }, { "PSCP_LineCheck", "后置射线检测" }, { "SwampMeshGen", "沼泽网格生成器" } }; private static readonly Dictionary EnumNames = new Dictionary(StringComparer.Ordinal) { { "HelperFunctions+LayerType.AllPhysical", "全实体" }, { "HelperFunctions+LayerType.TerrainMap", "地形图" }, { "HelperFunctions+LayerType.Terrain", "地形" }, { "HelperFunctions+LayerType.Map", "地图" }, { "HelperFunctions+LayerType.Default", "默认" }, { "HelperFunctions+LayerType.AllPhysicalExceptCharacter", "全实体非角色" }, { "HelperFunctions+LayerType.CharacterAndDefault", "角色+默认" }, { "HelperFunctions+LayerType.AllPhysicalExceptDefault", "全实体非默认" }, { "PropGrouper+PropGrouperTiming.Early", "早" }, { "PropGrouper+PropGrouperTiming.Late", "晚" }, { "TerrainCustomiserCN.UI.WidgetFactory+WidgetMode.Default", "默认" }, { "TerrainCustomiserCN.UI.WidgetFactory+WidgetMode.Disabled", "禁用" }, { "TerrainCustomiserCN.UI.WidgetFactory+WidgetMode.Hidden", "隐藏" }, { "TerrainCustomiserCN.UI.WidgetFactory+FieldLayout.Inline", "行内" }, { "TerrainCustomiserCN.UI.WidgetFactory+FieldLayout.Full", "完整" }, { "DeferredStepTiming.None", "无" }, { "DeferredStepTiming.AfterCurrentStep", "当前步骤后" }, { "DeferredStepTiming.AfterCurrentGroupTiming", "当前分组时机后" }, { "DeferredStepTiming.AfterDone", "完成后" }, { "Peak.ProcGen.ValidationState.Unknown", "未知" }, { "Peak.ProcGen.ValidationState.Passed", "通过" }, { "Peak.ProcGen.ValidationState.Failed", "失败" }, { "Segment.Alpine", "雪山" }, { "Segment.Beach", "海滩" }, { "Segment.Caldera", "火山" }, { "Segment.Peak", "顶峰" }, { "Segment.TheKiln", "熔炉" }, { "Segment.Tropics", "雨林" }, { "UnityEngine.QueryTriggerInteraction.UseGlobal", "使用全局设置" }, { "UnityEngine.QueryTriggerInteraction.Ignore", "忽略触发器" }, { "UnityEngine.QueryTriggerInteraction.Collide", "碰撞触发器" } }; private static readonly Dictionary DynamicNames = new Dictionary(StringComparer.Ordinal) { { "Alpine", "雪山" }, { "Beach", "海滩" }, { "Tropics", "雨林" }, { "Volcano", "火山" }, { "Mesa", "方山" }, { "Roots", "森蕈" }, { "Caldera", "火山" }, { "Peak", "顶峰" }, { "The Kiln", "熔炉" }, { "CULLER", "剔除器" }, { "Edges", "边缘" }, { "Eggs", "蛋" }, { "Mid", "中" }, { "Middle", "中间" }, { "Airplane Food", "飞机餐" }, { "AloeVera", "芦荟" }, { "AncientIdol", "古老玩偶" }, { "Antidote", "解毒剂" }, { "Anti-Rope Spool", "反重绳索" }, { "Apple Berry Green", "绿脆莓" }, { "Apple Berry Red", "红脆莓" }, { "Apple Berry Yellow", "黄脆莓" }, { "Backpack", "背包" }, { "Balloon", "气球" }, { "BalloonBunch", "一束气球" }, { "Bandages", "绷带" }, { "Basketball", "篮球" }, { "Beehive", "蜂巢" }, { "Berrynana Blue", "蓝莓蕉" }, { "Berrynana Brown", "棕莓蕉" }, { "Berrynana Peel Blue Variant", "莓蕉皮" }, { "Berrynana Peel Brown Variant", "莓蕉皮" }, { "Berrynana Peel Pink Variant", "莓蕉皮" }, { "Berrynana Peel Yellow", "莓蕉皮" }, { "Berrynana Pink", "粉莓蕉" }, { "Berrynana Yellow", "黄莓蕉" }, { "BingBong", "宾邦" }, { "BingBong_Prop Variant", "宾邦" }, { "Binoculars", "望远镜" }, { "Binoculars_Prop", "望远镜" }, { "BookOfBones", "骸骨之书" }, { "BounceShroom", "弹力菇" }, { "Bugfix", "蜱虫" }, { "Bugle", "喇叭" }, { "Bugle_Magic", "友谊喇叭" }, { "Bugle_Prop Variant", "喇叭" }, { "Bugle_Scoutmaster Variant", "童军领队的喇叭" }, { "C_Bishop B", "主教" }, { "C_Bishop W", "主教" }, { "C_Bishop_f", "青荔莓" }, { "C_Bishop_f Variant", "主教" }, { "C_Bishop_m", "青荔莓" }, { "C_Bishop_m Variant", "青荔莓" }, { "C_King", "青荔莓" }, { "C_King B", "国王" }, { "C_King Variant", "国王" }, { "C_King W", "国王" }, { "C_Knight", "青荔莓" }, { "C_Knight B", "骑士" }, { "C_Knight Variant", "骑士" }, { "C_Knight W", "骑士" }, { "C_Pawn B", "兵卒" }, { "C_Pawn W", "兵卒" }, { "C_Pawn_f", "青荔莓" }, { "C_Pawn_f Variant", "青荔莓" }, { "C_Pawn_m", "青荔莓" }, { "C_Pawn_m Variant", "兵卒" }, { "C_Queen", "青荔莓" }, { "C_Queen B", "皇后" }, { "C_Queen Variant", "皇后" }, { "C_Queen W", "皇后" }, { "C_Rook B", "战车" }, { "C_Rook W", "战车" }, { "C_Rook_f", "青荔莓" }, { "C_Rook_f Variant", "青荔莓" }, { "C_Rook_m", "青荔莓" }, { "C_Rook_m Variant", "战车" }, { "CactusBall", "仙人球" }, { "ChainShootable", "锁链" }, { "ChainShooter", "锁链发射器" }, { "ClimbingSpike", "岩钉" }, { "ClimbingSpikeHammered", "岩钉" }, { "CloudFungus", "云雾菇" }, { "Clusterberry Black", "黑葚莓" }, { "Clusterberry Red", "红葚莓" }, { "Clusterberry Yellow", "黄葚莓" }, { "Clusterberry_UNUSED", "青葚莓" }, { "Compass", "罗盘" }, { "Cure-All", "万灵药" }, { "Cursed Skull", "诅咒头骨" }, { "Dynamite", "炸药" }, { "Egg", "煎蛋" }, { "EggTurkey", "“鸟”" }, { "Energy Drink", "能量饮料" }, { "FireWood", "棍子" }, { "FirstAidKit", "急救箱" }, { "Flag_Plantable_Checkpoint", "检查点旗标" }, { "Flare", "照明棒" }, { "FortifiedMilk", "奶白金" }, { "FortifiedMilk_TEMP", "青荔莓" }, { "Frisbee", "飞盘" }, { "Glizzy", "热狗肠" }, { "Granola Bar", "燕麦棒" }, { "Guidebook", "旅行指南" }, { "GuidebookPage", "撕下的书页" }, { "GuidebookPage_0_Intro", "撕下的书页" }, { "GuidebookPage_1_Mushrooms", "撕下的书页" }, { "GuidebookPage_2_Campfire", "撕下的书页" }, { "GuidebookPage_3_Revival", "撕下的书页" }, { "GuidebookPage_4_BodyHeat Variant", "撕下的书页" }, { "GuidebookPage_5_Sleepy Variant", "撕下的书页" }, { "GuidebookPage_6_Awake Variant", "撕下的书页" }, { "GuidebookPage_7_Crashout Variant", "撕下的书页" }, { "GuidebookPage_8_FirstTeams", "撕下的书页" }, { "GuidebookPageScroll Variant", "卷轴" }, { "HealingDart Variant", "吹箭筒" }, { "HealingPuffShroom", "灵药菇" }, { "Heat Pack", "暖宝宝" }, { "Item_Coconut", "椰子" }, { "Item_Coconut_half", "半边椰子" }, { "Item_Honeycomb", "蜂巢蜜" }, { "Kingberry Green", "青荔莓" }, { "Kingberry Purple", "紫荔莓" }, { "Kingberry Yellow", "黄荔莓" }, { "Lantern", "提灯" }, { "Lantern_Faerie", "仙子提灯" }, { "Lollipop", "大棒棒糖" }, { "Lollipop_Prop", "大棒棒糖" }, { "MagicBean", "魔豆" }, { "Mandrake", "曼德拉草" }, { "Mandrake_Hidden", "药用根茎" }, { "Marshmallow", "棉花糖" }, { "MedicinalRoot", "药用根茎" }, { "Megaphone", "扩音器" }, { "Mushroom Chubby", "梨鲍菇" }, { "Mushroom Cluster", "银针菇" }, { "Mushroom Cluster Poison", "银针菇" }, { "Mushroom Glow", "诡异菇" }, { "Mushroom Lace", "喇叭菇" }, { "Mushroom Lace Poison", "喇叭菇" }, { "Mushroom Normie", "馒头菇" }, { "Mushroom Normie Poison", "馒头菇" }, { "Napberry", "晚安莓" }, { "NestEgg", "好大蛋" }, { "PandorasBox", "潘多拉餐盒" }, { "Parasol", "太阳伞" }, { "Parasol_Roots Variant", "太阳伞" }, { "Passport", "护照" }, { "Pepper Berry", "火烧莓" }, { "Pirate Compass", "海盗罗盘" }, { "PortableStovetop_Placed", "便携火炉" }, { "PortableStovetopItem", "便携火炉" }, { "Prickleberry_Gold", "金刺莓" }, { "Prickleberry_Red", "红刺莓" }, { "RemoteRopeSegment Variant", "绳索" }, { "RemoteRopeSegmentAntiRope", "反重绳索" }, { "RescueHook", "救援抓钩" }, { "RescueHook_Infinite", "救援抓钩" }, { "RopeSegment", "绳索" }, { "RopeSegmentInverted", "反重绳索" }, { "RopeShooter", "绳索炮" }, { "RopeShooterAnti", "反重绳索炮" }, { "RopeSpool", "绳索" }, { "Scorpion", "蝎子" }, { "ScoutCannonItem", "童子军大炮" }, { "ScoutCookies", "童军饼干" }, { "ScoutCookies_Vanilla", "童军饼干" }, { "ScoutEffigy", "童军雕像" }, { "ShelfShroom", "踏板菇" }, { "Shell Big", "海螺" }, { "Shroomberry_Blue", "蓝菇莓" }, { "Shroomberry_Green", "绿菇莓" }, { "Shroomberry_Purple", "紫菇莓" }, { "Shroomberry_Red", "红菇莓" }, { "Shroomberry_Yellow", "黄菇莓" }, { "Snowball", "雪球" }, { "Sports Drink", "运动饮料" }, { "Stone", "石头" }, { "Strange Gem", "奇怪水晶" }, { "Sunscreen", "防晒喷雾" }, { "Torch", "火炬" }, { "TrailMix", "混合坚果" }, { "Warp Compass", "曲迁罗盘" }, { "Winterberry Orange", "橙雪莓" }, { "Winterberry Yellow", "黄雪莓" }, { "Biome_1", "生物群系 1" }, { "Biome_2", "生物群系 2" }, { "Biome_3", "生物群系 3" }, { "Biome_4", "生物群系 4" }, { "Beach_Segment", "海滩区段" }, { "Caldera_Segment", "火山口区段" }, { "Desert_Segment", "沙漠区段" }, { "Jungle_Segment", "丛林区段" }, { "Roots Segment", "根系区段" }, { "Snow_Segment", "雪地区段" }, { "Volcano_Segment", "火山区段" }, { "Custom", "自定义" }, { "Default", "默认" }, { "Spiky", "尖刺" }, { "NoVariant", "无变体" }, { "BlackSand", "黑沙" }, { "BlueBeach", "蓝色海滩" }, { "Bombs", "炸弹" }, { "CactusForest", "仙人掌森林" }, { "CacusHell", "仙人掌地狱" }, { "DynamiteHell", "炸药地狱" }, { "GeyserHell", "间歇泉地狱" }, { "Ivy", "藤蔓" }, { "JellyHell", "水母地狱" }, { "Lava", "熔岩" }, { "Pillars", "石柱" }, { "RedBeach", "红色海滩" }, { "ScorpionsHell", "蝎子地狱" }, { "SkyJungle", "天空丛林" }, { "SnakeBeach", "蛇海滩" }, { "Thorny", "荆棘" }, { "TornadoHell", "龙卷风地狱" }, { "TumblerHell", "翻滚草地狱" }, { "- Bomb Beetle Variant", "炸弹甲虫变体" }, { "- Cave Mania Variant", "洞穴狂热变体" }, { "- Deep Water variant", "深水变体" }, { "- Redwood Clearcut Variant", "红木清伐变体" }, { "- Redwoods Default Variant", "红木默认变体" }, { "- redwoods deep woods Variant", "红木深林变体" } }; private static readonly Dictionary DynamicNameTokens = new Dictionary(StringComparer.OrdinalIgnoreCase) { { "Aid", "急救" }, { "Airplane", "飞机" }, { "Aleo", "芦荟" }, { "All", "全部" }, { "Aloe", "芦荟" }, { "Anchor", "锚点" }, { "Ancient", "远古" }, { "Ant", "蚂蚁" }, { "Anti", "反向" }, { "Antidote", "解毒剂" }, { "Antigrav", "反重力" }, { "Antlion", "蚁狮" }, { "Apple", "苹果" }, { "Awake", "清醒" }, { "Axe", "斧" }, { "B", "黑" }, { "Backpack", "背包" }, { "Badge", "徽章" }, { "Badges", "徽章" }, { "Ball", "球" }, { "Balloon", "气球" }, { "Balls", "球" }, { "Banana", "香蕉" }, { "Bandages", "绷带" }, { "Bar", "棒" }, { "Basalt", "玄武岩" }, { "Bassalt", "玄武岩" }, { "Base", "基础" }, { "Basic", "基础" }, { "Basketball", "篮球" }, { "Beach", "海滩" }, { "Bean", "豆" }, { "Bee", "蜜蜂" }, { "Beehive", "蜂巢" }, { "Beetle", "甲虫" }, { "Beetles", "甲虫" }, { "Behive", "蜂巢" }, { "Berries", "浆果" }, { "Berry", "浆果" }, { "berrybush", "浆果灌木" }, { "Berrynana", "莓蕉" }, { "Big", "大型" }, { "Bing", "宾" }, { "Binoc", "双筒镜" }, { "Binoculars", "双筒望远镜" }, { "Bishop", "主教" }, { "Black", "黑色" }, { "Bl", "黑" }, { "Blind", "致盲" }, { "Blue", "蓝色" }, { "Body", "体温" }, { "Bones", "骨头" }, { "Bong", "邦" }, { "Book", "书" }, { "Bot", "机器人" }, { "Bounce", "弹跳" }, { "Box", "盒子" }, { "Bridge", "桥" }, { "Bridges", "桥" }, { "Brown", "棕色" }, { "Bugfix", "修复" }, { "Bugle", "号角" }, { "Bunch", "束" }, { "Bush", "灌木" }, { "Bushes", "灌木" }, { "C", "棋子" }, { "Cactus", "仙人掌" }, { "Campfire", "营火" }, { "Cannon", "炮" }, { "Canyon", "峡谷" }, { "Cave", "洞穴" }, { "Caves", "洞穴" }, { "Cell", "单元格" }, { "Chain", "链条" }, { "Chalk", "粉笔" }, { "Character", "角色" }, { "Cheat", "作弊" }, { "Checkpoint", "检查点" }, { "Chest", "箱子" }, { "Chubby", "胖" }, { "Cliff", "峭壁" }, { "Climbing", "攀爬" }, { "Cloud", "云" }, { "Cluster", "簇" }, { "Clusterberry", "簇生莓" }, { "Clusters", "簇" }, { "Coconut", "椰子" }, { "Cold", "寒冷" }, { "Collection", "集合" }, { "Column", "柱" }, { "Compass", "指南针" }, { "Conclusion", "结语" }, { "Connecting", "连接" }, { "Console", "控制台" }, { "Cookies", "饼干" }, { "Crashout", "崩溃" }, { "Crook", "弯曲" }, { "Cure", "治疗" }, { "Cursed", "诅咒" }, { "Custom", "自定义" }, { "Dart", "飞镖" }, { "Dead", "枯死" }, { "Dedication", "题献" }, { "Deep", "深" }, { "Default", "默认" }, { "Desert", "沙漠" }, { "Destroyer", "销毁器" }, { "Dolo", "多洛" }, { "Dome", "圆顶" }, { "Driftwood", "浮木" }, { "Drink", "饮料" }, { "DROPDOWN", "下拉框" }, { "Dropper", "投放器" }, { "Dry", "干枯" }, { "Dynamic", "动态" }, { "Dynamite", "炸药" }, { "E", "东" }, { "Edge", "边缘" }, { "Effigy", "雕像" }, { "Egg", "蛋" }, { "Elixir", "药剂" }, { "End", "末端" }, { "Energy", "能量" }, { "ENUM", "枚举" }, { "Epic", "史诗" }, { "Erik", "埃里克" }, { "Eruption", "喷发" }, { "Evil", "邪恶" }, { "Explo", "爆炸" }, { "Explosion", "爆炸" }, { "f", "女" }, { "Fae", "仙灵" }, { "Faerie", "仙灵" }, { "Fake", "假" }, { "Fern", "蕨类" }, { "Ferns", "蕨类" }, { "Final", "最终" }, { "Fire", "火" }, { "First", "初级" }, { "Fixed", "固定" }, { "Flag", "旗帜" }, { "Flare", "信号弹" }, { "Flash", "闪光" }, { "Flat", "平坦" }, { "FLOAT", "浮点数" }, { "flower", "花" }, { "Food", "食物" }, { "Foot", "脚部" }, { "For", "用于" }, { "Forest", "森林" }, { "Fortified", "强化" }, { "Foundation", "基础" }, { "Friend", "队友" }, { "Frisbee", "飞盘" }, { "Fungus", "真菌" }, { "Funky", "奇异" }, { "Gem", "宝石" }, { "Geyser", "间歇泉" }, { "Geysers", "间歇泉" }, { "Giant", "巨型" }, { "Glizzy", "热狗" }, { "Glow", "发光" }, { "Gold", "金色" }, { "Granola", "格兰诺拉" }, { "Grass", "草" }, { "Green", "绿色" }, { "Guidebook", "指南书" }, { "Half", "半个" }, { "Hammered", "已敲入" }, { "Hand", "手" }, { "Hang", "悬挂" }, { "Hanging", "悬挂" }, { "Healing", "治疗" }, { "Heat", "热量" }, { "Helicopter", "直升机" }, { "Helping", "帮助" }, { "Hidden", "隐藏" }, { "High", "高" }, { "Hold", "抓点" }, { "Holow", "中空" }, { "Honeycomb", "蜂巢蜜" }, { "Hook", "钩" }, { "Horsetail", "木贼草" }, { "Hot", "热" }, { "Ice", "冰" }, { "Icicle", "冰锥" }, { "Identity", "标识" }, { "Idol", "神像" }, { "Impact", "冲击" }, { "Infinite", "无限" }, { "Injury", "伤害" }, { "Inner", "内部" }, { "INPUT", "输入" }, { "Inside", "内部" }, { "Internal", "内部" }, { "Intro", "介绍" }, { "Inverted", "反转" }, { "Item", "物品" }, { "Ivy", "藤蔓" }, { "Jellies", "水母" }, { "Jelly", "水母" }, { "Jellyfish", "水母" }, { "Jungle", "丛林" }, { "Kiln", "窑炉" }, { "King", "国王" }, { "Kingberry", "王莓" }, { "Kit", "套件" }, { "Knight", "骑士" }, { "Knockback", "击退" }, { "L", "左" }, { "Lace", "蕾丝" }, { "Lantern", "灯笼" }, { "Lava", "熔岩" }, { "Light", "光源" }, { "Lights", "光源" }, { "Lil", "小" }, { "Lion", "狮" }, { "List", "列表" }, { "Loading", "加载" }, { "Lollipop", "棒棒糖" }, { "Long", "长" }, { "Looker", "观察者" }, { "Low", "低" }, { "Luggage", "行李" }, { "m", "男" }, { "Magic", "魔法" }, { "Magma", "岩浆" }, { "Manager", "管理器" }, { "Mandrake", "曼德拉草" }, { "Marshmallow", "棉花糖" }, { "Massive", "巨大" }, { "Medicinal", "药用" }, { "Medium", "中型" }, { "Mega", "巨型" }, { "Megaphone", "扩音器" }, { "Milk", "牛奶" }, { "mineshaft", "矿井" }, { "Mineshafts", "矿井" }, { "Mini", "迷你" }, { "Mirage", "海市蜃楼" }, { "Mirrage", "海市蜃楼" }, { "Mix", "混合" }, { "Monstera", "龟背竹" }, { "Monsteras", "龟背竹" }, { "Moss", "苔藓" }, { "Movement", "移动" }, { "Mush", "蘑菇" }, { "Mushroom", "蘑菇" }, { "Mushrooms", "蘑菇" }, { "Nap", "睡眠" }, { "Napberry", "睡眠莓" }, { "Nest", "巢" }, { "Nice", "良性" }, { "No", "无" }, { "Normie", "普通" }, { "Oasis", "绿洲" }, { "Of", "的" }, { "Old", "旧" }, { "Only", "仅" }, { "Onsen", "温泉" }, { "Option", "选项" }, { "Orange", "橙色" }, { "Orb", "球体" }, { "Out", "外部" }, { "Outside", "外部" }, { "Overhang", "悬垂" }, { "Pack", "包" }, { "Page", "页面" }, { "Palm", "棕榈" }, { "Palms", "棕榈" }, { "Pandora", "潘多拉" }, { "Pandoras", "潘多拉" }, { "Parasol", "遮阳伞" }, { "Passed", "已通过" }, { "Passport", "护照" }, { "patch", "片" }, { "Pawn", "兵" }, { "Peel", "果皮" }, { "Pepper", "辣椒" }, { "Pick", "镐" }, { "Pile", "堆" }, { "Pillar", "石柱" }, { "Pine", "松树" }, { "Ping", "标记" }, { "Pink", "粉色" }, { "Pip", "状态点" }, { "Pirate", "海盗" }, { "Piton", "岩钉" }, { "Placed", "已放置" }, { "Plane", "飞机" }, { "Plant", "植物" }, { "Plantable", "可插旗" }, { "Planted", "已插旗" }, { "Plartform", "平台" }, { "Plat", "平台" }, { "Plateau", "高原" }, { "Platform", "平台" }, { "Platforms", "平台" }, { "Platteau", "高原" }, { "Player", "玩家" }, { "Point", "点" }, { "Poison", "毒" }, { "Pop", "爆开" }, { "Pops", "弹出物" }, { "Portable", "便携" }, { "Pre", "预置" }, { "Preface", "前言" }, { "Preview", "预览" }, { "Prickleberry", "刺莓" }, { "Prop", "物件" }, { "Props", "物件" }, { "Proxy", "代理" }, { "Puff", "喷雾" }, { "Purple", "紫色" }, { "Queen", "王后" }, { "R", "右" }, { "Red", "红色" }, { "Redwood", "红木" }, { "redwoods", "红木" }, { "Remote", "远程" }, { "Rescue", "救援" }, { "Respawn", "重生" }, { "Revival", "复活" }, { "Revived", "已复活" }, { "Ring", "环" }, { "Rings", "环" }, { "River", "河流" }, { "Rivers", "河流" }, { "Rock", "岩石" }, { "Rocks", "岩石" }, { "Rook", "车" }, { "Root", "根" }, { "Roots", "根系" }, { "Rope", "绳索" }, { "Ropes", "绳索" }, { "Round", "圆形" }, { "Rule", "规则" }, { "Safe", "安全" }, { "Scorpion", "蝎子" }, { "Scorpions", "蝎子" }, { "Scorps", "蝎子" }, { "Scout", "童子军" }, { "Scoutmaster", "童子军队长" }, { "Scream", "尖叫" }, { "Screen", "屏幕" }, { "Scroll", "卷轴" }, { "Sea", "海" }, { "Segment", "区段" }, { "Settings", "设置" }, { "SFX", "音效" }, { "Shaky", "摇晃" }, { "Shape", "形状" }, { "Sharp", "尖锐" }, { "Shelf", "架状" }, { "Shell", "贝壳" }, { "Shells", "贝壳" }, { "Shitty", "劣质" }, { "Shootable", "可射击" }, { "Shooter", "发射器" }, { "Short", "矮" }, { "Shroom", "蘑菇" }, { "Shroomberry", "蘑菇莓" }, { "Shrooms", "蘑菇" }, { "Shrub", "灌木" }, { "Side", "侧面" }, { "Simple", "简单" }, { "Single", "单个" }, { "Skull", "头骨" }, { "Sleepy", "困倦" }, { "Slippery", "湿滑" }, { "Small", "小型" }, { "Smoke", "烟雾" }, { "Snake", "蛇" }, { "Snow", "雪" }, { "Snowball", "雪球" }, { "Some", "部分" }, { "Sound", "声音" }, { "Spawn", "生成" }, { "Spawner", "生成器" }, { "Spawners", "生成器" }, { "Spawns", "生成点" }, { "Spider", "蜘蛛" }, { "Spiders", "蜘蛛" }, { "Spike", "尖刺" }, { "Spire", "尖塔" }, { "Spline", "样条" }, { "Spool", "线轴" }, { "Spore", "孢子" }, { "spores", "孢子" }, { "Sports", "运动" }, { "Stamina", "耐力" }, { "Start", "起点" }, { "Step", "步骤" }, { "Stone", "石头" }, { "Stovetop", "炉具" }, { "Strange", "奇异" }, { "Stumps", "树桩" }, { "Sunscreen", "防晒霜" }, { "Swarm", "蜂群" }, { "Tall", "高" }, { "TCCN", "TCCN" }, { "Teams", "队伍" }, { "TEMP", "临时" }, { "Thick", "粗" }, { "Thin", "细" }, { "Thorns", "荆棘" }, { "Timple", "神庙" }, { "Tiny", "微型" }, { "Title", "标题" }, { "Toggle", "切换" }, { "Torch", "火把" }, { "Tower", "塔" }, { "Tracking", "追踪" }, { "Trail", "混合包" }, { "Transform", "变换" }, { "Tree", "树" }, { "Trees", "树" }, { "Trunk", "树干" }, { "Tumble", "翻滚草" }, { "Tumblers", "翻滚草" }, { "tumbleweed", "翻滚草" }, { "Tunnels", "隧道" }, { "Turkey", "火鸡" }, { "UI", "界面" }, { "UNUSED", "未使用" }, { "Urch", "海胆" }, { "Urchins", "海胆" }, { "Use", "使用" }, { "Vanilla", "原味" }, { "Variant", "变体" }, { "Vera", "芦荟" }, { "VFX", "特效" }, { "Vine", "藤蔓" }, { "Vines", "藤蔓" }, { "W", "白" }, { "Wall", "墙面" }, { "Warp", "传送" }, { "Water", "水" }, { "Waterfall", "瀑布" }, { "Waterfalls", "瀑布" }, { "Web", "蛛网" }, { "Weed", "杂草" }, { "Wildflower", "野花" }, { "Willow", "柳树" }, { "Windows", "窗口" }, { "Winterberry", "冬莓" }, { "With", "带" }, { "Wonderberry", "奇异莓" }, { "Wood", "木头" }, { "Yellow", "黄色" }, { "Zombie", "僵尸" }, { "Atlas", "图集" }, { "Binggrae", "宾格瑞" }, { "Blink", "眨眼" }, { "Blowgun", "吹箭筒" }, { "Board", "面板" }, { "Boarding", "登机" }, { "Bold", "粗体" }, { "Check", "检查" }, { "Clouds", "云" }, { "Columns", "柱" }, { "Costume", "服装" }, { "CRAZK", "CRAZK" }, { "Crown", "王冠" }, { "Dark", "暗" }, { "Daruma", "达摩" }, { "Dear", "Dear" }, { "Decal", "贴花" }, { "Departure", "出发" }, { "Depth", "深度" }, { "Drop", "投放" }, { "Droplet", "水滴" }, { "Drowsy", "困倦" }, { "Extra", "特粗" }, { "Eye", "眼睛" }, { "Fade", "淡出" }, { "Feature", "特性" }, { "Fog", "雾" }, { "Font", "字体" }, { "Glass", "玻璃" }, { "Gothic", "哥特体" }, { "Graphs", "图" }, { "Gui", "界面" }, { "Heli", "直升机" }, { "Im", "Im" }, { "In", "内" }, { "Info", "信息" }, { "Jug", "壶" }, { "Kiosk", "自助终端" }, { "Liberation", "Liberation" }, { "Lit", "受光" }, { "Mask", "遮罩" }, { "Material", "材质" }, { "Member", "成员" }, { "Mesh", "网格" }, { "Mirror", "镜子" }, { "Montserrat", "蒙特塞拉特" }, { "Mountains", "群山" }, { "Nick", "昵称" }, { "Now", "当前" }, { "One", "一" }, { "Outline", "描边" }, { "Pangolin", "穿山甲" }, { "Particle", "粒子" }, { "Particles", "粒子" }, { "Photobooth", "照相亭" }, { "Players", "玩家" }, { "Post", "后处理" }, { "Pro", "Pro" }, { "Rain", "雨" }, { "Regular", "常规" }, { "Rotors", "旋翼" }, { "Sand", "沙" }, { "Sans", "无衬线" }, { "SC", "简中" }, { "Scan", "扫描" }, { "SDF", "SDF" }, { "Semi", "半" }, { "Set", "套装" }, { "Shader", "着色器" }, { "Shadow", "阴影" }, { "Sign", "标志" }, { "Skybox", "天空盒" }, { "Snowflake", "雪花" }, { "Soft", "柔和" }, { "softy", "柔和" }, { "Space", "太空" }, { "Sprite", "精灵" }, { "Sprites", "精灵" }, { "Steam", "蒸汽" }, { "Sun", "太阳" }, { "Tetsubin", "铁瓶" }, { "Text", "文本" }, { "TMP", "TMP" }, { "Tomb", "墓穴" }, { "Unlit", "无光照" }, { "Visor", "面罩" }, { "Volume", "体积" }, { "White", "白色" }, { "Wildflowers", "野花" } }; private static readonly Dictionary GeneratedDynamicNames = new Dictionary(StringComparer.Ordinal); private static readonly HashSet MissingKeys = new HashSet(StringComparer.Ordinal); private static readonly Regex EnglishRegex = new Regex("[A-Za-z]", RegexOptions.Compiled); private static readonly Regex DynamicNameBoundaryRegex = new Regex("(?<=[a-z])(?=[A-Z])|(?<=[A-Za-z])(?=\\d)|(?<=\\d)(?=[A-Za-z])", RegexOptions.Compiled); private static readonly Regex DynamicNameTokenRegex = new Regex("[A-Za-z]+|\\d+", RegexOptions.Compiled); public static event Action MissingTranslationFound; public static string Ui(string value, string source = null) { return Translate(TranslationKind.Ui, value, UiNames, source); } public static string Field(string value, string source = null) { return Translate(TranslationKind.Field, value, FieldNames, source); } public static string TypeName(Type type, string source = null) { if (type == null) { return string.Empty; } return TypeName(type.Name, source ?? type.FullName); } public static string TypeName(string value, string source = null) { return Translate(TranslationKind.Type, value, TypeNames, source); } public static string EnumName(Type enumType, string value, string source = null) { if (enumType == null) { return Translate(TranslationKind.Enum, value, EnumNames, source); } string text = enumType.FullName + "." + value; if (EnumNames.TryGetValue(text, out var value2)) { return value2; } ReportMissing(TranslationKind.Enum, text, source ?? enumType.FullName); return value; } public static string Dynamic(string value, string source = null) { if (string.IsNullOrEmpty(value)) { return value; } if (DynamicNames.TryGetValue(value, out var value2)) { return value2; } if (GeneratedDynamicNames.TryGetValue(value, out value2)) { return value2; } value2 = TryTranslateDynamicName(value); if (value2 != null) { GeneratedDynamicNames[value] = value2; return value2; } ReportMissing(TranslationKind.Dynamic, value, source); return value; } public static string Context(string value, string source = null) { if (string.IsNullOrEmpty(value)) { return value; } if (UiNames.TryGetValue(value, out var value2)) { return value2; } if (TypeNames.TryGetValue(value, out var value3)) { return value3; } ReportMissing(TranslationKind.Ui, value, source); return value; } public static bool HasTranslation(TranslationKind kind, string value, Type enumType = null) { if (string.IsNullOrEmpty(value)) { return true; } switch (kind) { case TranslationKind.Ui: return UiNames.ContainsKey(value); case TranslationKind.Field: return FieldNames.ContainsKey(value); case TranslationKind.Type: return TypeNames.ContainsKey(value); case TranslationKind.Enum: if (!(enumType != null) || !EnumNames.ContainsKey(enumType.FullName + "." + value)) { return EnumNames.ContainsKey(value); } return true; case TranslationKind.Dynamic: if (!DynamicNames.ContainsKey(value) && !GeneratedDynamicNames.ContainsKey(value)) { return TryTranslateDynamicName(value) != null; } return true; default: return false; } } private static string Translate(TranslationKind kind, string value, Dictionary table, string source) { if (string.IsNullOrEmpty(value)) { return value; } if (table.TryGetValue(value, out var value2)) { return value2; } ReportMissing(kind, value, source); return value; } private static void ReportMissing(TranslationKind kind, string value, string source) { string item = kind.ToString() + ":" + value; if (!MissingKeys.Contains(item)) { if (!ShouldReport(value)) { MissingKeys.Add(item); } else if (MissingKeys.Add(item)) { DisplayNameTranslator.MissingTranslationFound?.Invoke(new MissingTranslation(kind, value, source)); } } } private static bool ShouldReport(string value) { if (string.IsNullOrWhiteSpace(value)) { return false; } if (value.StartsWith("##", StringComparison.Ordinal)) { return false; } return EnglishRegex.IsMatch(value); } private static string TryTranslateDynamicName(string value) { string text = DynamicNameBoundaryRegex.Replace(value, " "); MatchCollection matchCollection = DynamicNameTokenRegex.Matches(text); if (matchCollection.Count == 0) { return null; } StringBuilder stringBuilder = new StringBuilder(); int num = 0; bool flag = false; foreach (Match item in matchCollection) { if (item.Index > num) { stringBuilder.Append(NormaliseDynamicSeparator(text.Substring(num, item.Index - num))); } string value2 = item.Value; if (DynamicNameTokens.TryGetValue(value2, out var value3)) { stringBuilder.Append(value3); flag = true; } else { stringBuilder.Append(value2); } num = item.Index + item.Length; } if (num < text.Length) { stringBuilder.Append(NormaliseDynamicSeparator(text.Substring(num))); } if (!flag) { return null; } string text2 = CollapseSpaces(stringBuilder.ToString()).Trim(); if (text2.Length != 0) { return text2; } return null; } private static string NormaliseDynamicSeparator(string separator) { if (string.IsNullOrEmpty(separator)) { return string.Empty; } return separator.Replace('_', ' ').Replace('-', ' ').Replace('.', ' '); } private static string CollapseSpaces(string value) { while (value.IndexOf(" ", StringComparison.Ordinal) >= 0) { value = value.Replace(" ", " "); } return value; } } public static class EditorGizmos { public static bool IsEnabled = false; private static List rendererMaterialCache = new List(); private static Transform Target; public static void ToggleGizmos() { IsEnabled = !IsEnabled; if (!IsEnabled) { GizmoUtils.RestoreRendererMaterials(rendererMaterialCache); } else { RefreshGizmos(); } } public static void OnSelectionChanged(Transform selected) { Target = selected; if (IsEnabled) { GizmoUtils.RestoreRendererMaterials(rendererMaterialCache); LevelGenStep component = ((Component)Target).gameObject.GetComponent(); GizmoUtils.TryDrawGizmos(Target, (Component)(object)component); if ((Object)(object)component != (Object)null) { rendererMaterialCache = GizmoUtils.ApplyOverlayToRenderers(((Component)Target).gameObject.GetComponentsInChildren(true)); } } } public static void RefreshGizmos() { if (!IsEnabled) { return; } GizmoUtils.RestoreRendererMaterials(rendererMaterialCache); if (!((Object)(object)Target == (Object)null)) { LevelGenStep component = ((Component)Target).gameObject.GetComponent(); GizmoUtils.TryDrawGizmos(Target, (Component)(object)component); if ((Object)(object)component != (Object)null) { rendererMaterialCache = GizmoUtils.ApplyOverlayToRenderers(((Component)Target).gameObject.GetComponentsInChildren(true)); } } } } public class HierarchyView { public class ContextNode { public string Name; public List Children = new List(); public Action Action; public Func CanUseNode; public string DisplayName => DisplayNameTranslator.Context(Name, "HierarchyContext") + "##" + Name; public void AddContextItem(string label, Action action, Func canUseNode) { Children.Add(new ContextNode { Name = label, Action = action, CanUseNode = canUseNode }); } } public Action OnSelectionChanged; public Func ShouldDrawNode; public List ContextNodes = new List(); public Transform Selected { get; private set; } public void DrawNode(Transform t) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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) if ((Object)(object)t == (Object)null || (ShouldDrawNode != null && !ShouldDrawNode(t))) { return; } ImGuiTreeNodeFlags val = (ImGuiTreeNodeFlags)4288; if ((Object)(object)Selected == (Object)(object)t) { val = (ImGuiTreeNodeFlags)(val | 1); } ImGui.PushID(((Object)t).GetInstanceID()); if (t.childCount == 0) { val = (ImGuiTreeNodeFlags)(val | 0x100); } bool num = ImGui.TreeNodeEx("", val, DisplayNameTranslator.Dynamic(((Object)t).name, "HierarchyNode")); if (ImGui.IsItemClicked() || ImGui.IsItemClicked((ImGuiMouseButton)1)) { SetSelected(t); } if (ImGui.IsItemClicked((ImGuiMouseButton)1)) { ImGui.OpenPopup("HierarchyItemContextMenuPopup"); } if (ImGui.BeginPopup("HierarchyItemContextMenuPopup")) { DrawContextNodes(t); ImGui.EndPopup(); } if (num) { for (int i = 0; i < t.childCount; i++) { DrawNode(t.GetChild(i)); } ImGui.TreePop(); } ImGui.PopID(); } public void SetSelected(Transform t) { if (!((Object)(object)Selected == (Object)(object)t)) { Selected = t; OnSelectionChanged?.Invoke(t); } } public ContextNode AddContextMenu(string label, Func canUseNode) { ContextNode contextNode = new ContextNode { Name = label, CanUseNode = canUseNode }; ContextNodes.Add(contextNode); return contextNode; } public void AddContextItem(string label, Action action, Func canUseNode) { ContextNodes.Add(new ContextNode { Name = label, Action = action, CanUseNode = canUseNode }); } public void DrawContextNodes(Transform t) { foreach (ContextNode contextNode in ContextNodes) { bool flag = true; if (contextNode.CanUseNode != null) { flag = contextNode.CanUseNode(t); } if (!flag) { ImGui.BeginDisabled(); } DrawContextNode(contextNode, t); if (!flag) { ImGui.EndDisabled(); } } } private void DrawContextNode(ContextNode node, Transform t) { if (node.Children.Count > 0) { DrawMenuNode(node, t); } else { DrawMenuItemNode(node, t); } } private void DrawMenuItemNode(ContextNode node, Transform t) { if (ImGui.MenuItem(node.DisplayName)) { node.Action?.Invoke(t); } } private void DrawMenuNode(ContextNode node, Transform t) { if (!ImGui.BeginMenu(node.DisplayName)) { return; } foreach (ContextNode child in node.Children) { DrawContextNode(child, t); } ImGui.EndMenu(); } } public static class ImGuiHelpers { public static void DrawPropertiesTable(string tableName, WidgetFactory.FieldWidgetData[] fieldWidgets) { if (!ImGui.BeginTable("Table_" + tableName, 2)) { return; } ImGui.TableSetupColumn(DisplayNameTranslator.Ui("Name"), (ImGuiTableColumnFlags)16, 100f); ImGui.TableSetupColumn(DisplayNameTranslator.Ui("Value"), (ImGuiTableColumnFlags)8); foreach (WidgetFactory.FieldWidgetData fieldWidgetData in fieldWidgets) { if (!fieldWidgetData.IsHidden) { if (fieldWidgetData.IsDisabled) { ImGui.BeginDisabled(); } ImGui.TableNextColumn(); ImGui.TextUnformatted(DisplayNameTranslator.Field(fieldWidgetData.Name, tableName)); ImGui.TableNextColumn(); ImGui.SetNextItemWidth(-1f); fieldWidgetData.Draw(); ImGui.TableNextRow(); if (fieldWidgetData.IsDisabled) { ImGui.EndDisabled(); } } } ImGui.EndTable(); } public static void DrawFullLayoutField(WidgetFactory.FieldWidgetData fieldWidget) { if (!fieldWidget.IsHidden) { ImGui.SetNextItemWidth(-1f); if (fieldWidget.IsDisabled) { ImGui.BeginDisabled(); } WidgetFactory.DrawField(fieldWidget); if (fieldWidget.IsDisabled) { ImGui.EndDisabled(); } } } public static void DrawButton(string label, Action onClick, bool enabled = true) { if (!enabled) { ImGui.BeginDisabled(); } if (ImGui.Button(label)) { onClick(); } if (!enabled) { ImGui.EndDisabled(); } } public static void DrawSmallButton(string label, Action onClick, bool enabled = true) { if (!enabled) { ImGui.BeginDisabled(); } if (ImGui.SmallButton(label)) { onClick(); } if (!enabled) { ImGui.EndDisabled(); } } } public static class WidgetFactory { public class FieldWidgetData { public string Name; public Type Type; public Func Get; public Action Set; public RangeAttribute RangeAttribute; public bool IsHidden; public bool IsDisabled; public FieldWidgetData(Type type, Func get, Action set, string name, RangeAttribute rangeAttribute = null, bool isHidden = false, bool isDisabled = false) { Type = type; Get = get; Set = set; Name = name; RangeAttribute = rangeAttribute; IsHidden = isHidden; IsDisabled = isDisabled; } public FieldWidgetData() { } public FieldWidgetData(FieldData fieldData, object ownerObject) { Type = fieldData.fieldInfo.FieldType; Get = () => fieldData.fieldInfo.GetValue(ownerObject); Set = delegate(object v) { fieldData.fieldInfo.SetValue(ownerObject, v); }; Name = fieldData.name; RangeAttribute = fieldData.rangeAttribute; IsHidden = fieldData.widgetMode == WidgetMode.Hidden; IsDisabled = fieldData.widgetMode == WidgetMode.Disabled; } public virtual void Draw() { DrawField(Type, Get, Set, Name, RangeAttribute); } } public class ComboWidgetData : FieldWidgetData { public Func GetIndex; public Action SetIndex; public Func GetOptions; public ComboWidgetData(string name, Func getIndex, Action setIndex, Func getOptions) { Name = name; GetIndex = getIndex; SetIndex = setIndex; GetOptions = getOptions; } public override void Draw() { int num = GetIndex(); string[] array = GetOptions(); if (array != null && array.Length != 0) { if (num < 0 || num >= array.Length) { num = 0; } ImGui.PushID(Name); string[] array2 = array.Select((string option) => DisplayNameTranslator.Dynamic(option, Name)).ToArray(); if (ImGui.Combo("##v", ref num, array2, array2.Length)) { SetIndex(num); } ImGui.PopID(); } } } public class FieldData { public string name; public FieldInfo fieldInfo; public RangeAttribute rangeAttribute; public FieldLayout layout; public WidgetMode widgetMode; } public enum WidgetMode { Default, Disabled, Hidden } public enum FieldLayout { Inline, Full } private static string[] spawnerHideFieldData = new string[5] { "_deferredSteps", "validationConstraints", "_propSpawnData", "_madeDummyData", "k__BackingField" }; public static Dictionary TypeFieldDataDictionary = new Dictionary(); public static void DrawField(object obj, FieldData fieldData) { FieldInfo f = fieldData.fieldInfo; DrawField(f.FieldType, () => f.GetValue(obj), delegate(object v) { f.SetValue(obj, v); }, f.Name, fieldData.rangeAttribute); } public static void DrawField(FieldWidgetData fieldWidgetData) { DrawField(fieldWidgetData.Type, fieldWidgetData.Get, fieldWidgetData.Set, fieldWidgetData.Name, fieldWidgetData.RangeAttribute); } public static void DrawField(Type t, Func get, Action set, string id, RangeAttribute rangeAttribute = null) { ImGui.PushID(id); if (t == typeof(int)) { DrawInt(() => (int)get(), delegate(int v) { set(v); }); } else if (t == typeof(float)) { if (rangeAttribute != null) { DrawSliderFloat(() => (float)get(), delegate(float v) { set(v); }, rangeAttribute.min, rangeAttribute.max); } else { DrawFloat(() => (float)get(), delegate(float v) { set(v); }); } } else if (t == typeof(string)) { DrawString(() => (string)get(), delegate(string v) { set(v); }); } else if (t == typeof(Vector2)) { DrawVector2(() => (Vector2)get(), delegate(Vector2 v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) set(v); }); } else if (t == typeof(Vector2Int)) { DrawVector2Int(() => (Vector2Int)get(), delegate(Vector2Int v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) set(v); }); } else if (t == typeof(Vector3)) { DrawVector3(() => (Vector3)get(), delegate(Vector3 v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) set(v); }); } else if (t == typeof(Vector3Int)) { DrawVector3Int(() => (Vector3Int)get(), delegate(Vector3Int v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) set(v); }); } else if (t == typeof(Vector4)) { DrawVector4(() => (Vector4)get(), delegate(Vector4 v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) set(v); }); } else if (t == typeof(Bounds)) { DrawBounds(() => (Bounds)get(), delegate(Bounds v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) set(v); }); } else if (t == typeof(bool)) { DrawBool(() => (bool)get(), delegate(bool v) { set(v); }); } else if (t.IsEnum) { DrawEnum(() => (Enum)get(), delegate(Enum v) { set(v); }); } else if (t == typeof(Color)) { DrawColor(() => (Color)get(), delegate(Color v) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) set(v); }); } else if (t == typeof(GameObject)) { DrawGameObject(() => (GameObject)get(), delegate(GameObject v) { set(v); }); } else if (t == typeof(Material)) { DrawMaterial(() => (Material)get(), delegate(Material v) { set(v); }); } else if (t == typeof(Transform)) { DrawTransform(() => (Transform)get(), delegate(Transform v) { set(v); }); } else if (t.IsArray) { DrawArray(t.GetElementType(), () => (Array)get(), delegate(Array a) { set(a); }, id); } else if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(List<>)) { DrawList(t.GetGenericArguments()[0], () => (IList)get(), id); } else if (t.IsClass && !typeof(Object).IsAssignableFrom(t)) { DrawClass(get, set, t); } else { ImGui.TextDisabled(t.ToString() + " 未实现"); } ImGui.PopID(); } private static void DrawClass(Func get, Action set, Type classType) { object obj = get(); if (obj == null) { if (ImGui.SmallButton("创建")) { obj = Activator.CreateInstance(classType); set(obj); } return; } Type type = obj.GetType(); Type type2 = obj.GetType(); if (ImGui.TreeNode(DisplayNameTranslator.TypeName(type2, "WidgetFactory.DrawClass") + "##" + type2.FullName)) { List list = new List(); FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); for (int i = 0; i < fields.Length; i++) { FieldWidgetData item = new FieldWidgetData(GetFieldData(fields[i]), obj); list.Add(item); } ImGuiHelpers.DrawPropertiesTable(obj.GetType().Name, list.ToArray()); ImGui.TreePop(); } } private static void DrawInt(Func get, Action set) { int obj = get(); if (ImGui.InputInt("##v", ref obj)) { set(obj); } } private static void DrawFloat(Func get, Action set) { float obj = get(); if (ImGui.InputFloat("##v", ref obj)) { set(obj); } } private static void DrawString(Func get, Action set) { string text = get(); if (text == null) { text = ""; } if (ImGui.InputText("##v", ref text, 32u)) { set(text); } } private static void DrawSliderFloat(Func get, Action set, float min, float max) { float obj = get(); if (ImGui.SliderFloat("##v", ref obj, min, max)) { set(obj); } } private static void DrawVector2(Func get, Action set) { //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_0016: Unknown result type (might be due to invalid IL or missing references) Vector2 obj = get(); if (ImGui.InputFloat2("##v", ref obj)) { set(obj); } } private static void DrawVector2Int(Func get, Action set) { //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_003c: Unknown result type (might be due to invalid IL or missing references) Vector2Int val = get(); int[] array = new int[2] { ((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y }; if (ImGui.InputInt2("##v", ref array[0])) { set(new Vector2Int(array[0], array[1])); } } public static void DrawVector3(Func get, Action set) { //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_0016: Unknown result type (might be due to invalid IL or missing references) Vector3 obj = get(); if (ImGui.InputFloat3("##v", ref obj)) { set(obj); } } private static void DrawVector3Int(Func get, Action set) { //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_0049: Unknown result type (might be due to invalid IL or missing references) Vector3Int val = get(); int[] array = new int[3] { ((Vector3Int)(ref val)).x, ((Vector3Int)(ref val)).y, ((Vector3Int)(ref val)).z }; if (ImGui.InputInt3("##v", ref array[0])) { set(new Vector3Int(array[0], array[1], array[2])); } } public static void DrawVector4(Func get, Action set) { //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_0016: Unknown result type (might be due to invalid IL or missing references) Vector4 obj = get(); if (ImGui.InputFloat4("##v", ref obj)) { set(obj); } } public static void DrawBounds(Func get, Action set) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_007d: Unknown result type (might be due to invalid IL or missing references) Bounds obj = get(); Vector3 center = ((Bounds)(ref obj)).center; Vector3 extents = ((Bounds)(ref obj)).extents; ImGui.TextUnformatted("中心"); ImGui.SameLine(); ImGui.SetNextItemWidth(-1f); if (ImGui.InputFloat3("##vc", ref center)) { ((Bounds)(ref obj)).center = center; set(obj); } ImGui.TextUnformatted("范围"); ImGui.SameLine(); ImGui.SetNextItemWidth(-1f); if (ImGui.InputFloat3("##ve", ref extents)) { ((Bounds)(ref obj)).extents = extents; set(obj); } } private static void DrawBool(Func get, Action set) { bool obj = get(); if (ImGui.Checkbox("##v", ref obj)) { set(obj); } } private static void DrawEnum(Func get, Action set) { Enum @enum = get(); int value = Convert.ToInt32(@enum); Type type = @enum.GetType(); string[] array = (from name in Enum.GetNames(type) select DisplayNameTranslator.EnumName(type, name)).ToArray(); if (ImGui.Combo("##v", ref value, array, array.Length)) { set((Enum)Enum.ToObject(type, value)); } } public static void DrawCombo(int selectedIndex, Func get, Action set) { string[] array = (from option in get() select DisplayNameTranslator.Dynamic(option, "Combo")).ToArray(); if (ImGui.Combo("##v", ref selectedIndex, array, array.Length)) { set(selectedIndex); } } private static void DrawColor(Func get, Action set) { //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_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) Vector4 val = Color.op_Implicit(get()); if (ImGui.ColorEdit4("##v", ref val)) { set(Color.op_Implicit(val)); } } private static void DrawGameObject(Func get, Action set) { GameObject val = get(); ImGui.TextUnformatted(((Object)(object)val != (Object)null) ? ((Object)val).name : "无"); ImGui.SameLine(); if (ImGui.SmallButton("更改")) { ResourceWindow.Show(get, set); WindowsManager.Get().Open(); } } public static void DrawMaterial(Func get, Action set) { Material val = get(); ImGui.TextUnformatted(((Object)(object)val != (Object)null) ? ((Object)val).name : "无"); ImGui.SameLine(); if (ImGui.SmallButton("更改")) { ResourceWindow.Show(get, set); WindowsManager.Get().Open(); } } private static void DrawTransform(Func get, Action set) { Transform val = get(); string obj = (((Object)(object)val != (Object)null) ? ((Object)val).name : "无"); ImGui.SetNextItemAllowOverlap(); ImGui.Selectable(obj); ImGui.SameLine(); if (ImGui.SmallButton("更改")) { ResourceWindow.Show(get, set); WindowsManager.Get().Open(); } } private static void DrawArray(Type elementType, Func get, Action set, string name) { Array array = get(); if (array == null) { ImGui.TextUnformatted(DisplayNameTranslator.Field(name, "Array")); ImGui.SameLine(); if (ImGui.SmallButton(DisplayNameTranslator.Ui("Create"))) { array = Array.CreateInstance(elementType, 0); set(array); } return; } int num = -1; if (ImGui.TreeNode("Array_" + name, string.Format("{0} [{1}]", DisplayNameTranslator.Field(name, "Array"), array.Length))) { for (int i = 0; i < array.Length; i++) { ImGui.PushID(i); int index = i; DrawField(elementType, () => array.GetValue(index), delegate(object v) { array.SetValue(v, index); }, index.ToString()); ImGui.SameLine(); ImGui.PushID("Remove"); if (ImGui.SmallButton(DisplayNameTranslator.Ui("Remove"))) { num = index; } ImGui.PopID(); ImGui.PopID(); } if (ImGui.SmallButton(DisplayNameTranslator.Ui("Add"))) { AddElement(array, set); } ImGui.TreePop(); } if (num >= 0) { RemoveAt(array, set, num); } } private static void DrawList(Type elementType, Func get, string name) { IList list = get(); if (list == null) { ImGui.TextUnformatted(DisplayNameTranslator.Field(name, "List")); ImGui.SameLine(); if (ImGui.SmallButton(DisplayNameTranslator.Ui("Create"))) { Type type = typeof(List<>).MakeGenericType(elementType); list = (IList)Activator.CreateInstance(type); } return; } int num = -1; if (ImGui.TreeNode("List_" + name, string.Format("{0} [{1}]", DisplayNameTranslator.Field(name, "List"), list.Count))) { for (int i = 0; i < list.Count; i++) { ImGui.PushID(i); int index = i; DrawField(elementType, () => list[index], delegate(object v) { list[index] = v; }, index.ToString()); ImGui.SameLine(); ImGui.PushID("Remove"); if (ImGui.SmallButton(DisplayNameTranslator.Ui("Remove"))) { num = index; } ImGui.PopID(); ImGui.PopID(); } ContextMenu.CreateMenu(list, elementType); if (ImGui.SmallButton(DisplayNameTranslator.Ui("Add"))) { if (elementType.IsAbstract) { ContextMenu.GetTypes(elementType); ImGui.OpenPopup("WidgetContextMenu"); } else { object value = Activator.CreateInstance(elementType); list.Add(value); } } ImGui.TreePop(); } if (num >= 0) { list.RemoveAt(num); } } private static void RemoveAt(Array array, Action set, int index) { int length = array.Length; Array array2 = Array.CreateInstance(array.GetType().GetElementType(), length - 1); if (index > 0) { Array.Copy(array, 0, array2, 0, index); } if (index < length - 1) { Array.Copy(array, index + 1, array2, index, length - index - 1); } set(array2); } private static void AddElement(Array array, Action set) { int length = array.Length; Array array2 = Array.CreateInstance(array.GetType().GetElementType(), length + 1); Array.Copy(array, array2, length); set(array2); } public static FieldData[] GetSpecialFieldData(Type t) { FieldData[] fieldDataFromType = GetFieldDataFromType(t); if (t == typeof(PropSpawner)) { fieldDataFromType.Where((FieldData d) => d.name == "currentSpawns").FirstOrDefault().widgetMode = WidgetMode.Disabled; FieldData[] array = fieldDataFromType; foreach (FieldData fieldData in array) { if (spawnerHideFieldData.Contains(fieldData.name)) { fieldData.widgetMode = WidgetMode.Hidden; } } } return fieldDataFromType; } public static FieldData[] GetFieldDataFromType(Type t) { FieldInfo[] fields = t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldData[] array = new FieldData[fields.Length]; for (int i = 0; i < fields.Length; i++) { FieldInfo fieldInfo = fields[i]; RangeAttribute customAttribute = ((MemberInfo)fieldInfo).GetCustomAttribute(); array[i] = new FieldData { name = fieldInfo.Name, fieldInfo = fieldInfo, rangeAttribute = customAttribute, widgetMode = WidgetMode.Default, layout = ((fieldInfo.FieldType.IsArray || (fieldInfo.FieldType.IsGenericType && fieldInfo.FieldType.GetGenericTypeDefinition() == typeof(List<>)) || (fieldInfo.FieldType.IsClass && !typeof(Object).IsAssignableFrom(fieldInfo.FieldType))) ? FieldLayout.Full : FieldLayout.Inline) }; } return array; } public static FieldData GetFieldData(FieldInfo fieldInfo) { RangeAttribute customAttribute = ((MemberInfo)fieldInfo).GetCustomAttribute(); return new FieldData { name = fieldInfo.Name, fieldInfo = fieldInfo, rangeAttribute = customAttribute, widgetMode = WidgetMode.Default, layout = ((fieldInfo.FieldType.IsArray || (fieldInfo.FieldType.IsGenericType && fieldInfo.FieldType.GetGenericTypeDefinition() == typeof(List<>)) || (fieldInfo.FieldType.IsClass && !typeof(Object).IsAssignableFrom(fieldInfo.FieldType))) ? FieldLayout.Full : FieldLayout.Inline) }; } private static FieldInfo[] GetTypeFields(Type t) { return t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } } } namespace TerrainCustomiserCN.UI.Windows { public class AirportWindow : ImGuiWindowBase { private int selectedSaveIndex; private bool useRandomSeed; private int seedValue; private bool bakeLightMap; public override string WindowName => "地形编辑菜单"; public override ImGuiWindowFlags WindowFlags => (ImGuiWindowFlags)64; public override void OnCreate() { base.OnCreate(); bakeLightMap = PlayerInfoManager.LobbyCanBake && ConfigManager.EnableLightMapBaking.Value && ConfigManager.BakeLightMap.Value; useRandomSeed = ConfigManager.UseRandomSeed.Value; seedValue = ConfigManager.SeedToUse.Value; } protected override void DrawContent() { if (SessionState.Is(SessionState.State.InAirport) || SessionState.Is(SessionState.State.SelectingSave)) { DrawOptionSelectionMenu(); } else if (SessionState.Is(SessionState.State.ConfiguringCustomMap) || SessionState.Is(SessionState.State.WaitingToStartCustomMap)) { DrawPlayConfigMenu(); } } private void DrawOptionSelectionMenu() { if (ImGui.Button("开始")) { SaveSelectionModal.Open(OnSaveSelected); SessionState.Set(SessionState.State.SelectingSave); } SaveSelectionModal.Draw(); ImGui.SameLine(); ImGuiHelpers.DrawButton("编辑器", OnEditorButtonClicked, PhotonNetwork.OfflineMode); } private void DrawPlayConfigMenu() { WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[3] { new WidgetFactory.FieldWidgetData(typeof(bool), () => useRandomSeed, delegate(object v) { SetUseRandomSeedValue((bool)v); }, "随机种子"), new WidgetFactory.FieldWidgetData(typeof(int), () => seedValue, delegate { SetSeedValue(seedValue); }, "种子", null, isHidden: false, useRandomSeed), new WidgetFactory.FieldWidgetData(typeof(bool), () => bakeLightMap && PlayerInfoManager.LobbyCanBake, delegate(object v) { SetBakeLightMapValue((bool)v); }, "烘焙光照贴图", null, isHidden: false, !PlayerInfoManager.LobbyCanBake) }; ImGuiHelpers.DrawPropertiesTable("PlayConfigTable", fieldWidgets); if (ImGui.BeginListBox("##players")) { Player[] array = ((CachedPlayerList)(ref PlayerHandler.Instance._playerList)).Get(); foreach (Player val in array) { ImGui.TextUnformatted(val.NickName); if (PlayerInfoManager.PlayersInfo.TryGetValue(val, out var value)) { ImGui.SameLine(); ImGui.TextUnformatted(value.canBake ? "可烘焙" : "不可烘焙"); if (SessionState.Is(SessionState.State.LoadingCustomMap)) { ImGui.SameLine(); ImGui.TextUnformatted(value.hasMapData ? "已就绪" : "未就绪"); } } } ImGui.EndListBox(); } ImGuiHelpers.DrawButton("开始", OnPlayClicked, SessionState.Is(SessionState.State.ConfiguringCustomMap)); ImGui.SameLine(); if (ImGui.Button("取消")) { OnCancelLoadClicked(); } } private void SetUseRandomSeedValue(bool newValue) { useRandomSeed = newValue; ConfigManager.UseRandomSeed.Value = newValue; } private void SetSeedValue(int newValue) { seedValue = newValue; ConfigManager.SeedToUse.Value = newValue; } private void SetBakeLightMapValue(bool newValue) { bakeLightMap = newValue; ConfigManager.BakeLightMap.Value = newValue; } private void OnSaveSelected(int saveIndex) { selectedSaveIndex = saveIndex; SessionState.Set(SessionState.State.ConfiguringCustomMap); } private void OnEditorButtonClicked() { SessionState.Set(SessionState.State.LoadingEditor); Plugin.Instance.LoadWilIsland(); } private void OnPlayClicked() { SessionState.Set(SessionState.State.WaitingToStartCustomMap); byte[] save = MapSerializer.GetSave(selectedSaveIndex); if (useRandomSeed) { seedValue = Random.Range(0, 999999999); } NetworkUtils.SetMapDataRoomProperty(new MapSerializer.MapSyncData { bakeLightMap = bakeLightMap, seed = seedValue, mapSaveData = save }); } private void OnCancelLoadClicked() { NetworkManager.SetRoomProperty("mapData", null); SessionState.Set(SessionState.State.InAirport); } } public class EditorWindow : ImGuiWindowBase { public HierarchyView hierarchy = new HierarchyView(); private int selectedSegmentNodeInstanceId; private MapData.BiomeSegment hierarchyTargetSegment; public override string WindowName => "编辑器"; public override ImGuiWindowFlags WindowFlags => (ImGuiWindowFlags)64; public override void OnCreate() { base.OnCreate(); IsOpen = true; Singleton.Instance.SetCurrentSegment(MapData.biomeSections[0].activeBiome.segments[0]); SetupHierarchy(); } private void SetupHierarchy() { HierarchyView hierarchyView = hierarchy; hierarchyView.OnSelectionChanged = (Action)Delegate.Combine(hierarchyView.OnSelectionChanged, (Action)delegate(Transform t) { WindowsManager.Get().SetTarget(t); }); hierarchy.ShouldDrawNode = (Transform t) => (Object)(object)((Component)t).GetComponent() != (Object)null || (Object)(object)((Component)t).GetComponent() != (Object)null || (((Component)t).GetComponents().Length == 1 && (Object)(object)((Component)t.parent).GetComponent() != (Object)null); HierarchyView.ContextNode contextNode = hierarchy.AddContextMenu("创建生成器", (Transform t) => (Object)(object)t == (Object)null || (Object)(object)((Component)t).GetComponent() == (Object)null); foreach (Type item in Singleton.Instance.levelGenStepTypes) { contextNode.AddContextItem(item.Name, delegate(Transform t) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Singleton.Instance.CreateObjectWithComponent(item.Name, t, item, ((Component)Camera.main).transform.position, ((Component)Camera.main).transform.rotation); }, null); } hierarchy.AddContextItem("创建分组器", delegate(Transform t) { //IL_001f: 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) Singleton.Instance.CreateObjectWithComponent("PropGrouper", t, typeof(PropGrouper), ((Component)Camera.main).transform.position, ((Component)Camera.main).transform.rotation); }, (Transform t) => (Object)(object)t == (Object)null || (Object)(object)((Component)t).GetComponent() == (Object)null); hierarchy.AddContextItem("复制", delegate(Transform t) { Singleton.Instance.DuplicateObject(t); }, (Transform t) => (Object)(object)t != (Object)null); hierarchy.AddContextItem("重命名", delegate(Transform t) { RenameModal.RequestOpen(t); }, (Transform t) => (Object)(object)t != (Object)null); hierarchy.AddContextItem("删除", delegate(Transform t) { Singleton.Instance.DestroyObject(((Component)t).gameObject); }, (Transform t) => (Object)(object)t != (Object)null); } protected override void DrawContent() { DrawControlsList(); DrawBiomeTable(); ImGui.Separator(); DrawHierarchy(); } private void DrawControlsList() { ImGuiHelpers.DrawSmallButton("生成", Singleton.Instance.GenerateCurrentSegment); ImGui.SameLine(); ImGuiHelpers.DrawSmallButton("保存", SaveModal.Open); ImGui.SameLine(); ImGuiHelpers.DrawSmallButton("加载", LoadModal.Open); ImGui.SameLine(); ImGuiHelpers.DrawSmallButton("相机", WindowsManager.Get().ToggleOpen); ImGui.SameLine(); ImGuiHelpers.DrawSmallButton("辅助线", EditorGizmos.ToggleGizmos); SaveModal.Draw(); LoadModal.Draw(); } private void SetSelectedSegment(MapData.BiomeSegment biomeSegment) { selectedSegmentNodeInstanceId = ((Object)biomeSegment.transform).GetInstanceID(); hierarchyTargetSegment = biomeSegment; Singleton.Instance.SetCurrentSegment(biomeSegment); } private void DrawBiomeTable() { if (!ImGui.BeginTable("Table_Biomes", 3)) { return; } ImGui.TableSetupColumn("名称", (ImGuiTableColumnFlags)16, 100f); ImGui.TableSetupColumn("类型", (ImGuiTableColumnFlags)16, 60f); ImGui.TableSetupColumn("按钮", (ImGuiTableColumnFlags)16, 50f); foreach (MapData.BiomeSection biomeSection in MapData.biomeSections) { DrawBiomeNode(biomeSection); } ImGui.EndTable(); } private void DrawBiomeNode(MapData.BiomeSection biomeSection) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) ImGui.TableNextRow(); ImGui.TableNextColumn(); int instanceID = ((Object)biomeSection.activeBiome.transform).GetInstanceID(); ImGui.PushID(instanceID); ImGui.SetNextItemAllowOverlap(); ImGuiTreeNodeFlags val = (ImGuiTreeNodeFlags)16674; ImGui.PushStyleColor((ImGuiCol)24, Color.op_Implicit(Color.black)); ImGui.PushStyleColor((ImGuiCol)25, Color.op_Implicit(Color.black)); bool num = ImGui.TreeNodeEx(DisplayNameTranslator.Dynamic(biomeSection.activeBiome.name, "Biome") + "##" + instanceID, val); ImGui.PopStyleColor(2); ImGui.TableNextColumn(); ImGui.TextUnformatted(DisplayNameTranslator.Dynamic(biomeSection.name, "BiomeSection")); ImGui.TableNextColumn(); if (ImGui.SmallButton("切换")) { SwapBiomeModal.Open(biomeSection); } SwapBiomeModal.Draw(); if (num) { foreach (MapData.BiomeSegment segment in biomeSection.activeBiome.segments) { DrawSegmentNode(segment); } ImGui.TreePop(); } ImGui.PopID(); } private void DrawSegmentNode(MapData.BiomeSegment biomeSegment) { //IL_0039: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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) ImGui.TableNextRow(); ImGui.TableNextColumn(); int instanceID = ((Object)biomeSegment.transform).GetInstanceID(); ImGui.PushID(instanceID); ImGui.SetNextItemAllowOverlap(); ImGuiTreeNodeFlags val = (ImGuiTreeNodeFlags)17160; if (instanceID == selectedSegmentNodeInstanceId) { val = (ImGuiTreeNodeFlags)(val | 1); } ImGui.TreeNodeEx(DisplayNameTranslator.Dynamic(biomeSegment.name, "BiomeSegment") + "##" + instanceID, val); if (ImGui.IsItemClicked()) { SetSelectedSegment(biomeSegment); } ImGui.TableNextColumn(); ImGui.TextUnformatted((biomeSegment.activeVariant != null) ? DisplayNameTranslator.Dynamic(biomeSegment.activeVariant.name, "SegmentVariant") : "无"); ImGui.TableNextColumn(); MapData.SegmentVariant customVariant = biomeSegment.customVariant; ImGuiHelpers.DrawSmallButton("建", delegate { CreateVariantModal.Open(biomeSegment); }, customVariant == null); if (customVariant != null) { ImGui.SameLine(); if (ImGui.SmallButton("删")) { DeleteSegmentModal.Open(customVariant); } } CreateVariantModal.Draw(); DeleteSegmentModal.Draw(); ImGui.PopID(); } private void DrawHierarchy() { //IL_0005: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown if (!ImGui.BeginChild("Hierarchy", new Vector2(ImGui.GetContentRegionAvail().x, 220f))) { return; } if (hierarchyTargetSegment == null || hierarchyTargetSegment.customVariant == null) { ImGui.TextUnformatted("没有自定义变体。"); ImGui.EndChild(); return; } foreach (Transform item in hierarchyTargetSegment.customVariant.transform) { Transform t = item; hierarchy.DrawNode(t); } if (RenameModal.OpenRequested) { RenameModal.Open(); } RenameModal.Draw(); if (ImGui.BeginPopupContextWindow("HierarchyWindowContextMenuPopup", (ImGuiPopupFlags)385)) { hierarchy.DrawContextNodes(null); ImGui.EndPopup(); } ImGui.EndChild(); } } public class FreeCamWindow : ImGuiWindowBase { public override string WindowName => "自由相机设置"; public override ImGuiWindowFlags WindowFlags => (ImGuiWindowFlags)2; public override Vector2 InitialWindowSize => new Vector2(275f, 150f); private GodCam godCam { get { MainCameraMovement instance = Singleton.Instance; if (!((Object)(object)instance != (Object)null)) { return null; } return instance.godcam; } } protected override void DrawContent() { if (godCam != null) { WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[4] { new WidgetFactory.FieldWidgetData(typeof(float), () => godCam.lookSens, delegate(object v) { godCam.lookSens = (float)v; }, "视角灵敏度"), new WidgetFactory.FieldWidgetData(typeof(float), () => godCam.lookDrag, delegate(object v) { godCam.lookDrag = (float)v; }, "视角阻尼"), new WidgetFactory.FieldWidgetData(typeof(float), () => godCam.force, delegate(object v) { godCam.force = (float)v; }, "移动力度"), new WidgetFactory.FieldWidgetData(typeof(float), () => godCam.drag, delegate(object v) { godCam.drag = (float)v; }, "移动阻尼") }; ImGuiHelpers.DrawPropertiesTable("godCamTable", fieldWidgets); } } } public abstract class ImGuiWindowBase { public bool IsOpen; public virtual string WindowName => "窗口"; public virtual Vector2 InitialWindowSize => Vector2.zero; public virtual ImGuiWindowFlags WindowFlags => (ImGuiWindowFlags)0; public virtual void OnCreate() { } public virtual void OnDestroy() { } public void ToggleOpen() { IsOpen = !IsOpen; } public void Close() { IsOpen = false; } public void Open() { IsOpen = true; } public void DrawWindow() { //IL_000c: 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) if (IsOpen) { ImGui.SetNextWindowSize(InitialWindowSize, (ImGuiCond)2); if (ImGui.Begin(WindowName, WindowFlags)) { DrawContent(); ImGui.End(); } } } protected abstract void DrawContent(); } public class InspectorWindow : ImGuiWindowBase { private GameObject targetGO; public static List allowedTypes = new List { typeof(PropGrouper), typeof(Transform), typeof(RockMaterialSwapper), typeof(SpecialDayZone) }; public override string WindowName => "检查器"; public override Vector2 InitialWindowSize => new Vector2(300f, 600f); public override void OnCreate() { base.OnCreate(); IsOpen = true; foreach (Type levelGenStepType in Singleton.Instance.levelGenStepTypes) { allowedTypes.Add(levelGenStepType); } } public void SetTarget(Transform targetTransform) { if ((Object)(object)targetTransform == (Object)null) { targetGO = null; return; } targetGO = ((Component)targetTransform).gameObject; Component[] components = targetGO.GetComponents(); for (int i = 0; i < components.Length; i++) { Type type = ((object)components[i]).GetType(); if (allowedTypes.Contains(type) && !WidgetFactory.TypeFieldDataDictionary.ContainsKey(type)) { WidgetFactory.FieldData[] specialFieldData = WidgetFactory.GetSpecialFieldData(type); WidgetFactory.TypeFieldDataDictionary.Add(type, specialFieldData); } } } private void DrawTransformComponent(Transform targetTransform) { if (ImGui.TreeNodeEx("变换", (ImGuiTreeNodeFlags)34)) { WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[2] { new WidgetFactory.FieldWidgetData(typeof(Vector3), () => targetTransform.position, delegate(object v) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) targetTransform.position = (Vector3)v; }, "位置"), new WidgetFactory.FieldWidgetData(typeof(Vector3), () => targetTransform.eulerAngles, delegate(object v) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) targetTransform.eulerAngles = (Vector3)v; }, "旋转") }; ImGuiHelpers.DrawPropertiesTable("transformTable", fieldWidgets); ImGui.TreePop(); } } protected override void DrawContent() { if ((Object)(object)targetGO == (Object)null) { return; } Component[] components = targetGO.GetComponents(); foreach (Component component in components) { Type type = ((object)component).GetType(); if (!allowedTypes.Contains(type)) { continue; } if (type == typeof(Transform)) { DrawTransformComponent(targetGO.transform); continue; } WidgetFactory.FieldData[] array = WidgetFactory.TypeFieldDataDictionary[type]; if (array == null || !ImGui.TreeNodeEx(DisplayNameTranslator.TypeName(type, "Inspector") + "##" + type.FullName, (ImGuiTreeNodeFlags)34)) { continue; } IEnumerable enumerable = array.Where((WidgetFactory.FieldData f) => f.layout == WidgetFactory.FieldLayout.Inline); IEnumerable enumerable2 = array.Where((WidgetFactory.FieldData f) => f.layout == WidgetFactory.FieldLayout.Full); List list = new List(); foreach (WidgetFactory.FieldData tableField in enumerable) { WidgetFactory.FieldWidgetData item = new WidgetFactory.FieldWidgetData(tableField.fieldInfo.FieldType, () => tableField.fieldInfo.GetValue(component), delegate(object v) { tableField.fieldInfo.SetValue(component, v); }, tableField.name, tableField.rangeAttribute, tableField.widgetMode == WidgetFactory.WidgetMode.Hidden, tableField.widgetMode == WidgetFactory.WidgetMode.Disabled); list.Add(item); } ImGuiHelpers.DrawPropertiesTable(((Object)component).name, list.ToArray()); foreach (WidgetFactory.FieldData data in enumerable2) { ImGuiHelpers.DrawFullLayoutField(new WidgetFactory.FieldWidgetData(data.fieldInfo.FieldType, () => data.fieldInfo.GetValue(component), delegate(object v) { data.fieldInfo.SetValue(component, v); }, data.name, data.rangeAttribute, data.widgetMode == WidgetFactory.WidgetMode.Hidden, data.widgetMode == WidgetFactory.WidgetMode.Disabled)); } ImGui.TreePop(); } } } public class ResourceWindow : ImGuiWindowBase { private static int _selectedIndex = -1; private static readonly List _items = new List(); private static string filterBuffer = string.Empty; private static Func _get; private static Action _set; public override string WindowName => "资源"; public override ImGuiWindowFlags WindowFlags => (ImGuiWindowFlags)64; public static void Show(Func get, Action set) where T : Object { _get = () => (Object)(object)get(); _set = delegate(Object o) { set((T)(object)o); }; RebuildList(); T val = get(); _selectedIndex = (((Object)(object)val != (Object)null) ? _items.IndexOf((Object)(object)val) : (-1)); } private static void RebuildList() where T : Object { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) _items.Clear(); T[] array = Resources.FindObjectsOfTypeAll(); if (typeof(T) == typeof(GameObject)) { foreach (GameObject item in array.Cast()) { if (!((Object)(object)item == (Object)null) && (Object)(object)item.transform.parent == (Object)null) { Scene scene = item.scene; if (!((Scene)(ref scene)).IsValid()) { _items.Add((Object)(object)item); } } } } else if (typeof(T) == typeof(Transform)) { GetTransformsFromRoot(GameObject.Find("Custom").transform); } else { T[] array2 = array; foreach (T val in array2) { if (!((Object)(object)val == (Object)null)) { _items.Add((Object)(object)val); } } } _items.Sort((Object a, Object b) => string.Compare(a.name, b.name, StringComparison.OrdinalIgnoreCase)); } private static void GetTransformsFromRoot(Transform t) { _items.Add((Object)(object)t); for (int i = 0; i < t.childCount; i++) { GetTransformsFromRoot(t.GetChild(i)); } } protected override void DrawContent() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[1] { new WidgetFactory.FieldWidgetData(typeof(string), () => filterBuffer, delegate(object v) { filterBuffer = (string)v; }, "筛选") }; ImGuiHelpers.DrawPropertiesTable("ResourceWindowTable", fieldWidgets); if (ImGui.BeginListBox("##resource_list", new Vector2(300f, 200f))) { for (int i = 0; i < _items.Count; i++) { Object val = _items[i]; string text = ((val != (Object)null) ? val.name : string.Empty); string displayName = ((val != (Object)null) ? DisplayNameTranslator.Dynamic(text, "Resource") : "<空>"); if (!MatchesFilter(text, displayName, filterBuffer)) { continue; } bool flag = _selectedIndex == i; if (ImGui.Selectable(BuildSelectableLabel(displayName, text, i), flag, (ImGuiSelectableFlags)4)) { _selectedIndex = i; if (ImGui.IsMouseDoubleClicked((ImGuiMouseButton)0)) { if (val != (Object)null && _set != null) { _set(val); } _get = null; _set = null; IsOpen = false; } } if (flag) { ImGui.SetItemDefaultFocus(); } } ImGui.EndListBox(); } if (ImGui.Button("取消")) { IsOpen = false; } } private static bool MatchesFilter(string rawName, string displayName, string filter) { if (string.IsNullOrEmpty(filter)) { return true; } if (!ContainsText(rawName, filter)) { return ContainsText(displayName, filter); } return true; } private static bool ContainsText(string value, string filter) { if (!string.IsNullOrEmpty(value)) { return value.IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0; } return false; } private static string BuildSelectableLabel(string displayName, string rawName, int index) { if (string.IsNullOrEmpty(displayName)) { displayName = "<空>"; } return displayName + "##resource_" + index + "_" + rawName; } } } namespace TerrainCustomiserCN.UI.Modals { public static class ConfirmationModal { private static Action ConfirmAction; private static string Message = string.Empty; public static void Open(string message, Action confirmAction) { Message = message; ConfirmAction = confirmAction; ImGui.OpenPopup("确认操作"); } public static void Draw() { if (ImGui.BeginPopupModal("确认操作", (ImGuiWindowFlags)64)) { ImGui.TextUnformatted(Message); if (ImGui.Button("确认")) { ConfirmAction(); ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("取消")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } } } public static class CreateVariantModal { private static Vector2 ModalSize = new Vector2(275f, 100f); private static MapData.BiomeSegment TargetSegment; private static string[] VariantOptionNames; private static int SelectedVariantIndex = 0; private static bool HasOptions = false; public static void Open(MapData.BiomeSegment biomeSegment) { TargetSegment = biomeSegment; if (biomeSegment.variantSelectionType == MapData.VariantSelectionType.BiomeVariant) { VariantOptionNames = biomeSegment.variants.Select((MapData.SegmentVariant x) => x.name).ToArray(); SelectedVariantIndex = biomeSegment.variants.FindIndex((MapData.SegmentVariant x) => x.isActive); } else { VariantOptionNames = biomeSegment.variantObjects.Select((MapData.SegmentVariant x) => x.name).ToArray(); SelectedVariantIndex = biomeSegment.variantObjects.FindIndex((MapData.SegmentVariant x) => x.isActive); } HasOptions = VariantOptionNames.Length != 0; ImGui.OpenPopup("创建变体"); } public static void Draw() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (ImGui.BeginPopupModal("创建变体", (ImGuiWindowFlags)2)) { ImGui.SetWindowSize(ModalSize); WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[1] { new WidgetFactory.ComboWidgetData("变体模板", () => SelectedVariantIndex, delegate(int v) { SelectedVariantIndex = v; }, () => VariantOptionNames) }; if (!HasOptions) { ImGui.BeginDisabled(); } ImGuiHelpers.DrawPropertiesTable("CreateVariantModalTable", fieldWidgets); if (!HasOptions) { ImGui.EndDisabled(); } if (ImGui.Button("创建")) { MapManager.CreateVariant(TargetSegment, HasOptions ? SelectedVariantIndex : (-1)); ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("取消")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } } } public static class DeleteSegmentModal { private static MapData.SegmentVariant TargetSegment; public static void Open(MapData.SegmentVariant targetSegment) { TargetSegment = targetSegment; ImGui.OpenPopup("删除分段"); } public static void Draw() { if (!ImGui.BeginPopupModal("删除分段", (ImGuiWindowFlags)64)) { return; } ImGui.TextUnformatted("删除你的自定义分段?"); if (ImGui.Button("是")) { if (TargetSegment != null) { MapManager.DeleteSegmentVariant(TargetSegment); } ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("否")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } } public static class LoadModal { private static Vector2 ModalSize = new Vector2(275f, 200f); private static int selectedSaveIndex = 0; public static void Open() { MapSerializer.RefreshSaveList(); ImGui.OpenPopup("加载存档"); } public static void Draw() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!ImGui.BeginPopupModal("加载存档", (ImGuiWindowFlags)2)) { return; } ImGui.SetWindowSize(ModalSize); ImGui.SetNextItemWidth(-1f); if (ImGui.BeginListBox("##saves")) { for (int i = 0; i < MapSerializer.SaveFiles.Count; i++) { bool flag = i == selectedSaveIndex; string text = MapSerializer.SaveFiles[i]; if (ImGui.Selectable(DisplayNameTranslator.Dynamic(text, "SaveFile") + "##" + text, flag)) { selectedSaveIndex = i; } } ImGui.EndListBox(); } if (ImGui.Button("加载")) { MapLoader.ApplySave(MapSerializer.LoadSave(selectedSaveIndex)); ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("取消")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } } public static class RenameModal { private static Vector2 ModalSize = new Vector2(275f, 150f); private static string RenameBuffer = string.Empty; private static Transform Selected; public static bool OpenRequested = false; private static Transform TransformRequested; public static void RequestOpen(Transform t) { OpenRequested = true; TransformRequested = t; } public static void Open() { if ((Object)(object)TransformRequested == (Object)null) { OpenRequested = false; return; } Selected = TransformRequested; RenameBuffer = ((Object)Selected).name; OpenRequested = false; ImGui.OpenPopup("重命名对象"); } public static void Draw() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (ImGui.BeginPopupModal("重命名对象", (ImGuiWindowFlags)2)) { ImGui.SetWindowSize(ModalSize); WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[1] { new WidgetFactory.FieldWidgetData(typeof(string), () => RenameBuffer, delegate(object v) { RenameBuffer = (string)v; }, "名称") }; ImGuiHelpers.DrawPropertiesTable("RenameModalTable", fieldWidgets); if (ImGui.Button("应用")) { ((Object)Selected).name = RenameBuffer; ImGui.CloseCurrentPopup(); RenameBuffer = string.Empty; } ImGui.SameLine(); if (ImGui.Button("取消")) { ImGui.CloseCurrentPopup(); RenameBuffer = string.Empty; } ImGui.EndPopup(); } } } public static class SaveModal { private static string saveName = "新存档"; public static void Open() { ImGui.OpenPopup("保存地图"); } public static void Draw() { if (ImGui.BeginPopupModal("保存地图")) { WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[1] { new WidgetFactory.FieldWidgetData(typeof(string), () => saveName, delegate(object v) { saveName = (string)v; }, "存档名") }; ImGuiHelpers.DrawPropertiesTable("saveModalTable", fieldWidgets); if (ImGui.Button("保存")) { MapSaver.SaveTerrain(saveName); ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("取消")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } } } public static class SaveSelectionModal { private static Vector2 ModalSize = new Vector2(275f, 225f); private static int SelectedSaveIndex = 0; private static Action OnSelectAction; private static string FilterInput = string.Empty; public static void Open(Action onSelectAction) { MapSerializer.RefreshSaveList(); OnSelectAction = onSelectAction; ImGui.OpenPopup("选择存档"); } public static void Draw() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!ImGui.BeginPopupModal("选择存档", (ImGuiWindowFlags)2)) { return; } ImGui.SetWindowSize(ModalSize); WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[1] { new WidgetFactory.FieldWidgetData(typeof(string), () => FilterInput, delegate(object v) { FilterInput = (string)v; }, "筛选") }; ImGuiHelpers.DrawPropertiesTable("SaveSelectionModalTable", fieldWidgets); ImGui.SetNextItemWidth(-1f); if (ImGui.BeginListBox("##saves")) { for (int i = 0; i < MapSerializer.SaveFiles.Count; i++) { if (string.IsNullOrEmpty(FilterInput) || MapSerializer.SaveFiles[i].IndexOf(FilterInput, StringComparison.OrdinalIgnoreCase) >= 0) { bool flag = i == SelectedSaveIndex; string text = MapSerializer.SaveFiles[i]; if (ImGui.Selectable(DisplayNameTranslator.Dynamic(text, "SaveFile") + "##" + text, flag)) { SelectedSaveIndex = i; } } } ImGui.EndListBox(); } if (ImGui.Button("选择")) { OnSelectAction(SelectedSaveIndex); ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("取消")) { ImGui.CloseCurrentPopup(); SessionState.Set(SessionState.State.InAirport); } ImGui.EndPopup(); } } public static class SwapBiomeModal { private static Vector2 ModalSize = new Vector2(275f, 100f); private static MapData.BiomeSection TargetSection; private static string[] BiomeOptionNames; private static int SelectedBiomeIndex = 0; private static bool OverrideConfirmed = false; public static void Open(MapData.BiomeSection biomeSection) { TargetSection = biomeSection; BiomeOptionNames = biomeSection.biomes.Select((MapData.BiomeOption x) => x.name).ToArray(); SelectedBiomeIndex = biomeSection.biomes.FindIndex((MapData.BiomeOption x) => x.isActive); ImGui.OpenPopup("切换生物群系"); } public static void Draw() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (!ImGui.BeginPopupModal("切换生物群系", (ImGuiWindowFlags)2)) { return; } ImGui.SetWindowSize(ModalSize); WidgetFactory.FieldWidgetData[] fieldWidgets = new WidgetFactory.FieldWidgetData[1] { new WidgetFactory.ComboWidgetData("生物群系", () => SelectedBiomeIndex, delegate(int v) { SelectedBiomeIndex = v; }, () => BiomeOptionNames) }; ImGuiHelpers.DrawPropertiesTable("SwapBiomeModalTable", fieldWidgets); if (ImGui.Button("应用")) { if (TargetSection.activeBiome.segmentHasCustomVariant) { ConfirmationModal.Open("该生物群系的自定义变体将被删除。是否继续?", delegate { OverrideConfirmed = true; }); } else { Singleton.Instance.ChangeBiome(TargetSection, TargetSection.biomes[SelectedBiomeIndex]); ImGui.CloseCurrentPopup(); } } ConfirmationModal.Draw(); if (OverrideConfirmed) { Singleton.Instance.ChangeBiome(TargetSection, TargetSection.biomes[SelectedBiomeIndex]); OverrideConfirmed = false; ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("取消")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } } } namespace TerrainCustomiserCN.TerrainGeneration { public static class AreaVoxeliser { [BurstCompile] private struct BuildOverlapCommandsJob : IJobParallelFor { [WriteOnly] public NativeArray commands; public int3 gridRes; public float spacing; public float3 offset; public float3 halfExtents; public QueryParameters query; public void Execute(int index) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00a4: 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) //IL_00b1: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) int num = index % gridRes.x; int num2 = index / gridRes.x % gridRes.y; int num3 = index / (gridRes.x * gridRes.y); float3 val = default(float3); ((float3)(ref val))..ctor(((float)num + 0.5f) * spacing, ((float)num2 + 0.5f) * spacing, ((float)num3 + 0.5f) * spacing); val -= new float3(gridRes) * spacing * 0.5f; val += offset; commands[index] = new OverlapBoxCommand(float3.op_Implicit(val), float3.op_Implicit(halfExtents), quaternion.op_Implicit(quaternion.identity), query); } } [BurstCompile] private struct ProcessOverlapResultsJob : IJobParallelFor { [ReadOnly] public NativeArray results; [WriteOnly] public NativeArray occupancy; public void Execute(int index) { //IL_000e: 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) ref NativeArray reference = ref occupancy; ColliderHit val = results[index]; reference[index] = ((((ColliderHit)(ref val)).instanceID != 0) ? 1u : 0u); } } private static NativeArray commands; private static NativeArray results; public static NativeArray occupancyNative; public static NativeArray BuildOccupancyGrid(LayerMask occluderMask) { //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_0031: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) LightVolume obj = LightVolume.Instance(); Vector3Int gridRes = obj.gridRes; float raySpacing = obj.raySpacing; int num = ((Vector3Int)(ref gridRes)).x * ((Vector3Int)(ref gridRes)).y * ((Vector3Int)(ref gridRes)).z; CreateArrays(num); float3 offset = float3.op_Implicit(obj.gridOffset); float3 halfExtents = default(float3); ((float3)(ref halfExtents))..ctor(raySpacing * 0.5f); BuildOverlapCommandsJob buildOverlapCommandsJob = default(BuildOverlapCommandsJob); buildOverlapCommandsJob.commands = commands; buildOverlapCommandsJob.gridRes = new int3(((Vector3Int)(ref gridRes)).x, ((Vector3Int)(ref gridRes)).y, ((Vector3Int)(ref gridRes)).z); buildOverlapCommandsJob.spacing = raySpacing; buildOverlapCommandsJob.offset = offset; buildOverlapCommandsJob.halfExtents = halfExtents; QueryParameters query = default(QueryParameters); query.layerMask = LayerMask.op_Implicit(occluderMask); query.hitTriggers = (QueryTriggerInteraction)1; buildOverlapCommandsJob.query = query; BuildOverlapCommandsJob buildOverlapCommandsJob2 = buildOverlapCommandsJob; JobHandle val = default(JobHandle); JobHandle val2 = IJobParallelForExtensions.Schedule(buildOverlapCommandsJob2, num, 128, val); JobHandle val3 = OverlapBoxCommand.ScheduleBatch(commands, results, 128, 1, val2); ProcessOverlapResultsJob processOverlapResultsJob = default(ProcessOverlapResultsJob); processOverlapResultsJob.results = results; processOverlapResultsJob.occupancy = occupancyNative; val = IJobParallelForExtensions.Schedule(processOverlapResultsJob, num, 128, val3); ((JobHandle)(ref val)).Complete(); return occupancyNative; } private static void CreateArrays(int voxelCount) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) DisposeArrays(); commands = new NativeArray(voxelCount, (Allocator)3, (NativeArrayOptions)1); results = new NativeArray(voxelCount, (Allocator)3, (NativeArrayOptions)1); occupancyNative = new NativeArray(voxelCount, (Allocator)3, (NativeArrayOptions)1); } public static void DisposeArrays() { if (commands.IsCreated) { commands.Dispose(); } if (results.IsCreated) { results.Dispose(); } if (occupancyNative.IsCreated) { occupancyNative.Dispose(); } } } public static class GenerationPatches { [HarmonyPatch] public static class RemoveDebugLogsPatch { [HarmonyTranspiler] [HarmonyPatch(typeof(JungleVine), "Awake")] [HarmonyPatch(typeof(JungleVine), "PickTreePlatforms")] [HarmonyPatch(typeof(SpawnConnectingBridge), "CheckCondition")] private static IEnumerable Transpiler(IEnumerable instructions) { return instructions; } } [HarmonyPatch(typeof(Looker), "ToggleLookers")] internal static class ToggleLookersPatch { public static bool Prefix(Looker __instance) { Looker[] componentsInChildren = ((Component)((Component)__instance).transform.parent).GetComponentsInChildren(); int num = Random.Range(0, componentsInChildren.Length); if (Random.value < 0.95f) { num = -1; } Looker[] array = componentsInChildren; foreach (Looker val in array) { if ((Object)(object)val.view == (Object)null) { val.view = ((Component)val).GetComponent(); } if (((Component)val).transform.GetSiblingIndex() != num) { val.view.RPC("RPCA_DisableLooker", (RpcTarget)3, Array.Empty()); } } return false; } } [HarmonyPatch(typeof(PropGrouper), "RunAll")] public static class PropGrouperRunAllPatch { public static Dictionary> deferredSteps = new Dictionary>(); private static void AddToStepList(DeferredStepTiming key, IDeferredStep stepToAdd) { //IL_0005: 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_0015: Unknown result type (might be due to invalid IL or missing references) if (!deferredSteps.ContainsKey(key)) { deferredSteps.Add(key, new List()); } deferredSteps[key].Add(stepToAdd); } private static void ExecuteAndClearDeferredStepsFor(DeferredStepTiming key) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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) if (!deferredSteps.ContainsKey(key)) { return; } foreach (IDeferredStep item in deferredSteps[key]) { item.DeferredGo(); } deferredSteps[key].Clear(); } public static bool Prefix(PropGrouper __instance, bool updateLightmap = true) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Invalid comparison between Unknown and I4 //IL_009d: Unknown result type (might be due to invalid IL or missing references) if (!SessionState.CanGenerate) { return true; } deferredSteps.Clear(); __instance.ClearAll(); LevelGenStep[] componentsInChildren = ((Component)__instance).GetComponentsInChildren(); List list = new List(); List list2 = new List(); for (int i = 0; i < componentsInChildren.Length; i++) { PropGrouperTiming timing = ((Component)componentsInChildren[i]).GetComponentInParent().timing; if ((int)timing == 0) { list.Add(componentsInChildren[i]); } else if ((int)timing == 1) { list2.Add(componentsInChildren[i]); } } foreach (LevelGenStep item in list) { item.Execute(); if ((int)item.DeferredTiming > 0) { AddToStepList(item.DeferredTiming, item.ConstructDeferred((IMayHaveDeferredStep)(object)item)); } } ((PhotonPeer)PhotonNetwork.NetworkingClient.LoadBalancingPeer).SendOutgoingCommands(); if (ConfigManager.EnableLightMapBaking.Value && updateLightmap) { LightMapBaker.RunBake(); } ((PhotonPeer)PhotonNetwork.NetworkingClient.LoadBalancingPeer).SendOutgoingCommands(); ExecuteAndClearDeferredStepsFor((DeferredStepTiming)2); foreach (LevelGenStep item2 in list2) { item2.Execute(); } return false; } } [HarmonyPatch(typeof(PropSpawner_Sphere), "SpawnNew")] public static class PropSpawnerSphereAddPatch { private static Ray[] rays = (Ray[])(object)new Ray[0]; private static bool Prefix(PropSpawner_Sphere __instance, bool executeDeferredImmediately) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00aa: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Invalid comparison between Unknown and I4 //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown if (!SessionState.CanGenerate) { return true; } if (__instance.spawnChance < Random.value) { return false; } if (!CanBatch(((Object)((Component)__instance).gameObject).name, __instance.rayCastSpawn, __instance.syncTransforms)) { return true; } int num = __instance.nrOfSpawns; if (__instance.randomSpawns) { num = Random.Range(__instance.minSpawnCount, __instance.nrOfSpawns); } int num2 = 50000; int num3 = 0; int num4 = 256; if (rays.Length < num4) { rays = (Ray[])(object)new Ray[num4]; } LayerMask mask = HelperFunctions.GetMask(__instance.layerType); QueryParameters @default = QueryParameters.Default; @default.layerMask = ((LayerMask)(ref mask)).value; @default.hitTriggers = (QueryTriggerInteraction)1; NativeArray results = default(NativeArray); results..ctor(num4, (Allocator)3, (NativeArrayOptions)1); NativeArray commands = default(NativeArray); commands..ctor(num4, (Allocator)3, (NativeArrayOptions)1); while (num3 < num && num2 > 0) { rays = PropSpawnerHelpers.BuildRays_Sphere(__instance, rays, num4); ExecuteJob(commands, results, rays, @default, num4, __instance.rayLength); num2 -= num4; int num5 = 0; for (int i = 0; i < num4; i++) { if (num3 >= num) { break; } RaycastHit hit = results[i]; if (!Object.op_Implicit((Object)(object)((RaycastHit)(ref hit)).transform)) { continue; } SpawnData val = new SpawnData { pos = ((RaycastHit)(ref hit)).point, normal = ((RaycastHit)(ref hit)).normal, rayDir = ((Ray)(ref rays[i])).direction, hit = hit, spawnerTransform = ((Component)__instance).transform }; bool flag = true; for (int j = 0; j < __instance.constraints.Count; j++) { if (!__instance.constraints[j].CheckConstraint(val)) { flag = false; break; } } if (flag) { GameObject val2 = Spawn(__instance, val); if ((Object)(object)val2 != (Object)null) { __instance.spawnedProps.Add(val2); num3++; num5++; } } } if (num <= 10 && num5 == 0) { break; } } commands.Dispose(); results.Dispose(); foreach (PostSpawnBehavior postSpawnBehavior in __instance.postSpawnBehaviors) { if (!postSpawnBehavior.mute) { if (executeDeferredImmediately || (int)postSpawnBehavior.DeferredTiming != 2) { postSpawnBehavior.RunBehavior((IEnumerable)__instance.spawnedProps); } else { __instance._deferredSteps.Add(postSpawnBehavior.ConstructDeferred((IMayHaveDeferredStep)(object)__instance)); } } } return false; } private static GameObject Spawn(PropSpawner_Sphere spawner, SpawnData spawnData) { //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_0020: Unknown result type (might be due to invalid IL or missing references) GameObject val = HelperFunctions.SpawnPrefab(spawner.props[Random.Range(0, spawner.props.Length)], spawnData.pos, HelperFunctions.GetRandomRotationWithUp(Vector3.up), ((Component)spawner).transform); if ((Object)(object)val == (Object)null) { return null; } for (int i = 0; i < spawner.modifiers.Count; i++) { spawner.modifiers[i].ModifyObject(val, spawnData); } for (int j = 0; j < spawner.postConstraints.Count; j++) { if (!spawner.postConstraints[j].CheckConstraint(val, spawnData)) { Object.DestroyImmediate((Object)(object)val); return null; } } return val; } } [HarmonyPatch(typeof(PropSpawner), "SpawnNew")] public static class PropSpawnerSpawnNewPatch { private static Ray[] rays = (Ray[])(object)new Ray[0]; private static bool Prefix(PropSpawner __instance, bool executeDeferredImmediately) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) if (!SessionState.CanGenerate) { return true; } if (__instance.chanceToUseSpawner < 0.999f && Random.value > __instance.chanceToUseSpawner) { return false; } if (!CanBatch(((Object)((Component)__instance).gameObject).name, __instance.raycastPosition, __instance.syncTransforms)) { return true; } int num = __instance.nrOfSpawns; if (__instance.randomSpawns) { num = Random.Range(__instance.minSpawnCount, __instance.nrOfSpawns); } int num2 = 25000; int i = 0; int num3 = 256; LayerMask mask = HelperFunctions.GetMask(__instance.layerType); if (rays.Length < num3) { rays = (Ray[])(object)new Ray[num3]; } Vector3 val = ((Component)__instance).transform.forward + __instance.rayDirectionOffset; Vector3 normalized = ((Vector3)(ref val)).normalized; QueryParameters @default = QueryParameters.Default; @default.layerMask = ((LayerMask)(ref mask)).value; @default.hitTriggers = (QueryTriggerInteraction)1; NativeArray results = default(NativeArray); results..ctor(num3, (Allocator)3, (NativeArrayOptions)1); NativeArray commands = default(NativeArray); commands..ctor(num3, (Allocator)3, (NativeArrayOptions)1); int num4; for (; i < num; i += num4) { if (num2 <= 0) { break; } rays = PropSpawnerHelpers.BuildRays(__instance, rays, num3, normalized); ExecuteJob(commands, results, rays, @default, num3, __instance.rayLength); num2 -= num3; num4 = ProcessResults(results, rays, __instance, i, num); } commands.Dispose(); results.Dispose(); Physics.SyncTransforms(); __instance.currentSpawns = ((Component)__instance).transform.childCount; __instance.SpawnDecor(); HandlePostSpawnBehaviors(__instance, executeDeferredImmediately); return false; } private static void HandlePostSpawnBehaviors(PropSpawner __instance, bool executeDeferredImmediately) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 foreach (PostSpawnBehavior postSpawnBehavior in __instance.postSpawnBehaviors) { if (!postSpawnBehavior.mute) { if (executeDeferredImmediately || (int)postSpawnBehavior.DeferredTiming != 2) { postSpawnBehavior.RunBehavior(__instance.SpawnedProps); } else { __instance._deferredSteps.Add(postSpawnBehavior.ConstructDeferred((IMayHaveDeferredStep)(object)__instance)); } } } } } [HarmonyPatch(typeof(PropSpawner), "Execute")] public static class PropSpawnerExecutePatch { private static bool Prefix(PropSpawner __instance) { if (__instance.props == null || __instance.props.Length == 0) { Debug.LogError((object)("[TCCN] PropSpawner " + ((Object)__instance).name + " has null or empty props array.")); return false; } return true; } } [HarmonyPatch(typeof(PropSpawner_Sphere), "Execute")] public static class PropSpawner_SphereExecutePatch { private static bool Prefix(PropSpawner_Sphere __instance) { if (__instance.props == null || __instance.props.Length == 0) { Debug.LogError((object)("[TCCN] PropSpawner_Sphere " + ((Object)__instance).name + " has null or empty props array.")); return false; } return true; } } [HarmonyPatch(typeof(PropSpawner_Line), "Execute")] public static class PropSpawner_LineExecutePatch { private static bool Prefix(PropSpawner_Line __instance) { if (__instance.props == null || __instance.props.Length == 0) { Debug.LogError((object)("[TCCN] PropSpawner_Line " + ((Object)__instance).name + " has null or empty props array.")); return false; } return true; } } [HarmonyPatch] public static class LevelGenStepSpawnPatch { private static IEnumerable TargetMethods() { return from type in typeof(LevelGenStep).Assembly.GetTypes() where typeof(LevelGenStep).IsAssignableFrom(type) && !type.IsAbstract let method = AccessTools.Method(type, "Spawn", new Type[1] { typeof(SpawnData) }, (Type[])null) where method != null && method.ReturnType == typeof(GameObject) select method; } private static bool Prefix(LevelGenStep __instance, MethodBase __originalMethod, SpawnData spawnData, ref GameObject __result) { if (!SessionState.CanGenerate) { return true; } Type type = ((object)__instance).GetType(); FieldInfo field = type.GetField("props", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); GameObject[] array = ((field != null) ? field.GetValue(__instance) : null) as GameObject[]; FieldInfo field2 = type.GetField("modifiers", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); IList list = ((field2 != null) ? field2.GetValue(__instance) : null) as IList; FieldInfo field3 = type.GetField("postConstraints", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); IList list2 = ((field3 != null) ? field3.GetValue(__instance) : null) as IList; if (array == null) { return true; } List modifiers = ((list != null) ? new List(list.Cast()) : new List()); List postConstraints = ((list2 != null) ? new List(list2.Cast()) : new List()); return PropSpawnerHelpers.TrySpawn(spawnData, ref __result, array, modifiers, postConstraints, ((Component)__instance).transform, ((Component)__instance).gameObject); } } [HarmonyPatch(typeof(MapHandler), "InitializeMap")] private static class MapHandlerInitializeMapPatch { private static bool Prefix() { if (SessionState.Is(SessionState.State.WaitingForMapData)) { return false; } if (SessionState.Is(SessionState.State.LoadingEditor) || SessionState.Is(SessionState.State.WaitingToStartCustomMap)) { MapData.BuildMapData(); TerrainCustomiserCN.Map.ResourceManager.GetAllResources(); } if (!SessionState.Is(SessionState.State.WaitingToStartCustomMap)) { return true; } LoadCustomMap(); return true; } private static void LoadCustomMap() { SessionState.Set(SessionState.State.LoadingCustomMap); AddGroupersToSegments(); MapSerializer.MapSaveData save = MapSerializer.LoadFromBytes(PlayerInfoManager.currentMapSyncData.mapSaveData); Random.InitState(PlayerInfoManager.currentMapSyncData.seed); MapLoader.ApplySave(save); PropGrouper component = ((Component)Singleton.Instance).GetComponent(); bool flag = PlayerInfoManager.LocalPlayerInfo.canBake && PlayerInfoManager.currentMapSyncData.bakeLightMap; component.RunAll(flag); HandleRemainingPhotonViews(); FakeItemManager.Instance.RefreshList(); } private static void AddGroupersToSegments() { List list = Singleton.Instance.segments.ToList(); list.AddRange(Singleton.Instance.variantSegments); foreach (MapSegment item in list) { if ((Object)(object)item.segmentParent.GetComponent() == (Object)null) { item.segmentParent.gameObject.AddComponent(); } } } private static void HandleRemainingPhotonViews() { foreach (PhotonView allUnassignedView in GetAllUnassignedViews()) { ViewSyncManager.AddPendingView(allUnassignedView); } ViewSyncManager.HandlePendingViews(); } public static List GetAllUnassignedViews() { PhotonView[] componentsInChildren = ((Component)Singleton.Instance).gameObject.GetComponentsInChildren(true); List list = new List(); for (int i = 0; i < componentsInChildren.Length; i++) { if (componentsInChildren[i].ViewID == 0) { list.Add(componentsInChildren[i]); } } return list; } } public static bool CanBatch(string spawnerName, bool raycastPosition, bool syncTransforms) { if (!raycastPosition) { return false; } return (syncTransforms && !PropSpawnerHelpers.SafeToBatchPropNames.Contains(spawnerName)) || true; } public static bool PassedConstraints(PropSpawner spawner, SpawnData sd) { for (int i = 0; i < spawner.constraints.Count; i++) { if (!spawner.constraints[i].CheckConstraint(sd)) { return false; } } return true; } public static void ExecuteJob(NativeArray commands, NativeArray results, Ray[] rays, QueryParameters queryParams, int batchCount, float rayLength) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_003a: 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_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) for (int i = 0; i < batchCount; i++) { commands[i] = new RaycastCommand(((Ray)(ref rays[i])).origin, ((Ray)(ref rays[i])).direction, queryParams, rayLength); } NativeArray val = commands; JobHandle val2 = default(JobHandle); val2 = RaycastCommand.ScheduleBatch(val, results, 4, val2); ((JobHandle)(ref val2)).Complete(); } public static int ProcessResults(NativeArray results, Ray[] rays, PropSpawner spawner, int successes, int nrOfSpawns) { //IL_000b: 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_0027: 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) int num = 0; int num2 = 0; for (int i = 0; i < results.Length; i++) { if (successes >= nrOfSpawns) { break; } RaycastHit hit = results[i]; if ((Object)(object)((RaycastHit)(ref hit)).collider == (Object)null) { continue; } num++; SpawnData val = PropSpawnerHelpers.BuildSpawnData(spawner, rays[i], hit, hasHit: true, successes); if (PassedConstraints(spawner, val)) { GameObject val2 = spawner.Spawn(val); if ((Object)(object)val2 != (Object)null) { successes++; num2++; spawner.AllSpawnData[val2] = val; } } } return num2; } } public static class LightMapBaker { public struct GpuLightData { public Vector3 Position; public float ConeSize; public Vector3 Direction; public float Radius; public Vector3 Color; public float Falloff; public float ConeFalloff; } public static ComputeShader computeShader; public static int rayCount = 128; public static int maxSteps = 64; public static void RunBake() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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) LightVolume val = LightVolume.Instance(); val.lightMap = null; Shader.SetGlobalTexture("_LightMap", (Texture)null); Stopwatch stopwatch = Stopwatch.StartNew(); NativeArray occupancy = AreaVoxeliser.BuildOccupancyGrid(val.occluderMask); stopwatch.Stop(); Debug.Log((object)("[TerrainCustomiserCN] Occupancy took: " + stopwatch.ElapsedMilliseconds)); stopwatch = Stopwatch.StartNew(); RenderTexture val2 = DispatchAndCreateRenderTexture(computeShader, occupancy, val.gridRes, rayCount, maxSteps, val.skyColor); AreaVoxeliser.DisposeArrays(); RenderTexture val3 = val.RunBlur(val2); ((Object)val3).name = "LightVolumeRenderTexture"; val.SetShaderVars(); val.SaveTex(val3, (Action)null); stopwatch.Stop(); Debug.Log((object)("[TerrainCustomiserCN] Visibility took: " + stopwatch.ElapsedMilliseconds)); } private static RenderTexture DispatchAndCreateRenderTexture(ComputeShader cs, NativeArray occupancy, Vector3Int gridRes, int rayCount, int maxSteps, Color skyColor) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_005b: 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_0067: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) int num = cs.FindKernel("SkyVisibilityDDA"); ComputeBuffer val = new ComputeBuffer(((Vector3Int)(ref gridRes)).x * ((Vector3Int)(ref gridRes)).y * ((Vector3Int)(ref gridRes)).z, 4); val.SetData(occupancy); List list = BuildLights(); ComputeBuffer val2 = new ComputeBuffer(list.Count, 52); val2.SetData(list); RenderTexture val3 = new RenderTexture(((Vector3Int)(ref gridRes)).x, ((Vector3Int)(ref gridRes)).y, 0) { enableRandomWrite = true, format = (RenderTextureFormat)2, dimension = (TextureDimension)3, volumeDepth = ((Vector3Int)(ref gridRes)).z, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; val3.Create(); LightVolume val4 = LightVolume.Instance(); cs.SetInts("_GridRes", new int[3] { ((Vector3Int)(ref gridRes)).x, ((Vector3Int)(ref gridRes)).y, ((Vector3Int)(ref gridRes)).z }); cs.SetVector("_GridOffset", Vector4.op_Implicit(val4.gridOffset)); cs.SetFloat("_RaySpacing", val4.raySpacing); cs.SetBuffer(num, "_Occupancy", val); cs.SetTexture(num, "_LightMap", (Texture)(object)val3); cs.SetInt("_RayCount", rayCount); cs.SetInt("_MaxSteps", maxSteps); cs.SetVector("_SkyColor", Color.op_Implicit(skyColor)); cs.SetBuffer(num, "_LightBuffer", val2); cs.SetInt("_LightBufferLength", list.Count); int num2 = (((Vector3Int)(ref gridRes)).x + 3) / 4; int num3 = (((Vector3Int)(ref gridRes)).y + 3) / 4; int num4 = (((Vector3Int)(ref gridRes)).z + 3) / 4; cs.Dispatch(num, num2, num3, num4); val.Release(); val2.Release(); return val3; } public static List BuildLights() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 //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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) LightVolume val = LightVolume.Instance(); List list = new List(); BakedVolumeLight[] componentsInChildren = (((Object)(object)val.sceneParent == (Object)null) ? ((Component)val).gameObject : val.sceneParent).GetComponentsInChildren(); Vector3 val3 = default(Vector3); foreach (BakedVolumeLight val2 in componentsInChildren) { ((Vector3)(ref val3))..ctor(val2.color.r, val2.color.g, val2.color.b); LightModes mode = val2.mode; float num; if ((int)mode == 0) { num = 0f; } else { if ((int)mode != 1) { throw new Exception(); } num = val2.coneSize * (MathF.PI / 180f); } float coneSize = num; list.Add(new GpuLightData { Position = ((Component)val2).transform.position, ConeSize = coneSize, Direction = ((Component)val2).transform.forward, Radius = val2.GetRadius(), Color = val3 * val2.intensity, Falloff = val2.falloff, ConeFalloff = val2.coneFalloff }); } if (list.Count == 0) { list.Add(default(GpuLightData)); } return list; } } public static class PropGrouperHelpers { public static Dictionary> deferredSteps = new Dictionary>(); private static void AddToStepList(DeferredStepTiming key, IDeferredStep stepToAdd) { //IL_0005: 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_0015: Unknown result type (might be due to invalid IL or missing references) if (!deferredSteps.ContainsKey(key)) { deferredSteps.Add(key, new List()); } deferredSteps[key].Add(stepToAdd); } private static void ExecuteAndClearDeferredStepsFor(DeferredStepTiming key) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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) if (!deferredSteps.ContainsKey(key)) { return; } foreach (IDeferredStep item in deferredSteps[key]) { item.DeferredGo(); } deferredSteps[key].Clear(); } public static void RunRootPropGrouper(PropGrouper rootGrouper) { //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_0036: 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_0048: Invalid comparison between Unknown and I4 //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Invalid comparison between Unknown and I4 //IL_0085: Unknown result type (might be due to invalid IL or missing references) deferredSteps.Clear(); rootGrouper.ClearAll(); LevelGenStep[] componentsInChildren = ((Component)rootGrouper).GetComponentsInChildren(); List list = new List(); List list2 = new List(); for (int i = 0; i < componentsInChildren.Length; i++) { PropGrouperTiming timing = ((Component)componentsInChildren[i]).GetComponentInParent().timing; if ((int)timing == 0) { list.Add(componentsInChildren[i]); } else if ((int)timing == 1) { list2.Add(componentsInChildren[i]); } } foreach (LevelGenStep item in list) { item.Execute(); if ((int)item.DeferredTiming > 0) { AddToStepList(item.DeferredTiming, item.ConstructDeferred((IMayHaveDeferredStep)(object)item)); } } ((PhotonPeer)PhotonNetwork.NetworkingClient.LoadBalancingPeer).SendOutgoingCommands(); if (ConfigManager.EnableLightMapBaking.Value) { LightMapBaker.RunBake(); } ((PhotonPeer)PhotonNetwork.NetworkingClient.LoadBalancingPeer).SendOutgoingCommands(); ExecuteAndClearDeferredStepsFor((DeferredStepTiming)2); foreach (LevelGenStep item2 in list2) { item2.Execute(); } } } public static class PropSpawnerHelpers { public static readonly HashSet SafeToBatchPropNames = new HashSet { "LuggageSpawner", "Ivy", "Geysers", "Weed", "ExploShrooms", "PoisonShrooms", "Vines", "BeachGrass", "Driftwood", "Behive", "ShittyPiton", "Monsteras", "FlashPlant", "Shrub", "Pine", "Bushes", "Trees", "DeadTree", "Ice_DeadTree", "Palms", "Luggage", "Cacti", "Dynamite", "Ferns", "Zombie Spawner", "Exploding Shrooms", "Glow Mushrooms", "Spiders", "Bounce Shrooms", "Shroom Spawners", "Root Spawner", "Evil Shroom" }; public static bool TrySpawn(SpawnData spawnData, ref GameObject __result, GameObject[] props, List modifiers, List postConstraints, Transform parent, GameObject fallback) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0047: Unknown result type (might be due to invalid IL or missing references) if (props == null) { __result = null; return false; } GameObject val = props[Random.Range(0, props.Length)]; PhotonView val2 = default(PhotonView); if ((Object)(object)val != (Object)null && val.TryGetComponent(ref val2)) { Quaternion randomRotationWithUp = GetRandomRotationWithUp(Vector3.up); GameObject val3 = Object.Instantiate(val, spawnData.pos, randomRotationWithUp, parent); if ((Object)(object)val3 == (Object)null) { Debug.LogError((object)("Failed to instantiate prop " + ((Object)val).name)); __result = null; return false; } RemoveSpineIfLuggage(val3); ApplyModifiers(val3, spawnData, modifiers); if (!CheckAndHandlePostConstraints(val3, spawnData, postConstraints)) { __result = null; return false; } if ((Object)(object)val3 == (Object)null) { __result = null; return false; } HandleIfBridge(val3); PhotonView component = val3.GetComponent(); if (PhotonNetwork.OfflineMode) { PhotonNetwork.AllocateViewID(component); } else { ViewSyncManager.AddPendingView(component); } __result = val3; return false; } return true; } public static Quaternion GetRandomRotationWithUp(Vector3 normal) { //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_0012: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vector3 onUnitSphere = Random.onUnitSphere; onUnitSphere.y = 0f; onUnitSphere = Vector3.Cross(normal, Vector3.Cross(normal, onUnitSphere)); return Quaternion.LookRotation(onUnitSphere, normal); } public static bool CheckAndHandlePostConstraints(GameObject go, SpawnData spawnData, List postConstraints) { foreach (PropSpawnerConstraintPost postConstraint in postConstraints) { if (!postConstraint.mute && !postConstraint.CheckConstraint(go, spawnData)) { Object.DestroyImmediate((Object)(object)go); return false; } } return true; } public static void ApplyModifiers(GameObject go, SpawnData spawnData, List modifiers) { foreach (PropSpawnerMod modifier in modifiers) { if (!modifier.mute) { modifier.ModifyObject(go, spawnData); } } } public static void RemoveSpineIfLuggage(GameObject go) { Luggage val = default(Luggage); if (go.TryGetComponent(ref val)) { SpineCheck component = go.GetComponent(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } } } public static void HandleIfBridge(GameObject go) { BreakableBridge @object = default(BreakableBridge); if (go.TryGetComponent(ref @object)) { CollisionModifier[] componentsInChildren = go.GetComponentsInChildren(); foreach (CollisionModifier obj in componentsInChildren) { obj.applyEffects = false; obj.onCollide = (Action)Delegate.Combine(obj.onCollide, new Action(@object.OnBridgeCollision)); } } } public static bool CheckIfBridge(GameObject go) { BreakableBridge val = default(BreakableBridge); return go.TryGetComponent(ref val); } public static Ray[] BuildRays_Sphere(PropSpawner_Sphere spawner, Ray[] outRays, int count) { //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_0010: 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_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_001a: 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) Vector3 position = ((Component)spawner).transform.position; for (int i = 0; i < count; i++) { Vector3 onUnitSphere = Random.onUnitSphere; outRays[i] = new Ray(position, onUnitSphere); } return outRays; } public static Ray[] BuildRays(PropSpawner spawner, Ray[] outRays, int count, Vector3 rayDir) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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) for (int i = 0; i < count; i++) { outRays[i] = GetSpawnRay(spawner.area, ((Component)spawner).transform, rayDir); } return outRays; } public static Ray GetSpawnRay(Vector2 area, Transform t, Vector3 rayDir) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_003b: 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_0051: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_008a: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(Random.value, Random.value); return new Ray(t.position + t.right * Mathf.Lerp((0f - area.x) * 0.5f, area.x * 0.5f, val.x) + t.up * Mathf.Lerp((0f - area.y) * 0.5f, area.y * 0.5f, val.y), rayDir); } public static SpawnData BuildSpawnData(PropSpawner spawner, Ray ray, RaycastHit hit, bool hasHit, int count) { //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_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_0023: 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) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown Vector2 placement = default(Vector2); ((Vector2)(ref placement))..ctor(Random.value, Random.value); return new SpawnData { pos = ((RaycastHit)(ref hit)).point, normal = ((RaycastHit)(ref hit)).normal, rayDir = ((Component)spawner).transform.forward, hit = hit, spawnerTransform = ((Component)spawner).transform, placement = placement, spawnCount = count }; } } } namespace TerrainCustomiserCN.Session { internal static class SessionActions { internal static void OnQuitToMainMenu() { if (SessionState.Is(SessionState.State.InEditor) && (Object)(object)Singleton.Instance != (Object)null) { Singleton.Instance.EndSession(); } } internal static void OnLobbyEnter() { string lobbyData = NetworkManager.GetLobbyData("TC_inCustomMap"); if (!string.IsNullOrEmpty(lobbyData) && lobbyData == "true") { SessionState.Set(SessionState.State.WaitingForMapData); } } internal static void OnAirportEnter() { SessionState.Set(SessionState.State.InAirport); if (PhotonNetwork.IsMasterClient) { NetworkManager.SetRoomProperty("mapData", null); NetworkManager.SetLobbyData("TC_inCustomMap", "false"); } } internal static void OnStartRun() { if (SessionState.Is(SessionState.State.LoadingEditor)) { EditorManager.Setup(); } else if (SessionState.Is(SessionState.State.LoadingCustomMap)) { SessionState.Set(SessionState.State.InCustomMap); if (PhotonNetwork.IsMasterClient) { NetworkManager.SetLobbyData("TC_inCustomMap", "true"); } } } } internal static class SessionState { public enum State { InMainMenu, InAirport, SelectingSave, ConfiguringCustomMap, WaitingToStartCustomMap, LoadingCustomMap, WaitingForMapData, LoadingEditor, InCustomMap, InEditor } public static State Current { get; private set; } public static bool CanGenerate { get { if (Current != State.LoadingCustomMap && Current != State.LoadingEditor) { return Current == State.InEditor; } return true; } } public static void Set(State state) { Current = state; } public static bool Is(State state) { return Current == state; } } } namespace TerrainCustomiserCN.Patches { internal class AirportPatches { [HarmonyPatch(typeof(GameUtils), "OnEnable")] private class GameUtilsOnEnablePatch { private static void Postfix(GameUtils __instance) { if (__instance.m_inAirport) { SessionActions.OnAirportEnter(); } } } [HarmonyPatch(typeof(BoardingPass), "Initialize")] private class BoardingPassInitializePatch { private static void Postfix(BoardingPass __instance) { WindowsManager.Register(); } } [HarmonyPatch(typeof(BoardingPass), "OnOpen")] private class BoardingPassOnOpenPatch { private static void Postfix() { if (PhotonNetwork.IsMasterClient) { WindowsManager.Get().Open(); } } } [HarmonyPatch(typeof(BoardingPass), "OnClose")] private class BoardingPassOnClosePatch { private static void Postfix() { if (PhotonNetwork.IsMasterClient) { WindowsManager.Get().Close(); } } } [HarmonyPatch(typeof(AirportCheckInKiosk), "BeginIslandLoadRPC")] private class BeginIslandLoadRPCPatch { private static void Postfix() { WindowsManager.Unregister(); } } } internal class ImGuiPatches { [HarmonyPatch(typeof(ImGuiTextures), "BuildFontAtlas")] private class BuildFontAtlasPatch { private static void Prefix(ImGuiIOPtr io, ref ImGuiFontAsset fontAsset) { fontAsset = ChineseFontManager.AppendChineseFont(fontAsset); } } } internal class NetworkPatches { [HarmonyPatch(typeof(GameHandler), "Awake")] private class GameHandlerAwakePatch { private static void Postfix(GameHandler __instance) { NetworkManager.Setup(); } } [HarmonyPatch(typeof(GameUtils), "OnPlayerLeftRoom")] private class OnPlayerLeftRoomPatch { private static void Postfix(Player newPlayer) { PlayerInfoManager.RemovePlayerInfo(newPlayer); } } } internal class SessionPatches { [HarmonyPatch(typeof(MainMenu), "Start")] private class MainMenuStartPatch { private static void Postfix(MainMenu __instance) { SessionState.Set(SessionState.State.InMainMenu); } } [HarmonyPatch(typeof(RunManager), "StartRun")] public class RunManagerStartRunPatch { private static void Postfix() { SessionActions.OnStartRun(); } } [HarmonyPatch(typeof(PauseMenuMainPage), "Quit")] private class PauseMenQuitPatch { private static void Postfix() { SessionActions.OnQuitToMainMenu(); } } [HarmonyPatch(typeof(SteamLobbyHandler), "OnLobbyEnter")] private static class OnLobbyEnterPatch { private static void Postfix(SteamLobbyHandler __instance, LobbyEnter_t param) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (param.m_EChatRoomEnterResponse == 1) { SessionActions.OnLobbyEnter(); } } } } } namespace TerrainCustomiserCN.Map { public static class MapData { public enum VariantSelectionType { BiomeVariant, VariantObject } public class BiomeSection { public string name; public Transform transform; public List biomes = new List(); public BiomeOption activeBiome => biomes.Find((BiomeOption x) => x.isActive); } public class BiomeOption { public string name; public Transform transform; public BiomeType biomeType; public BiomeSection section; public List segments = new List(); public bool isActive => ((Component)transform).gameObject.activeSelf; public bool segmentHasCustomVariant => segments.Find((BiomeSegment x) => x.customVariant != null) != null; } public class BiomeSegment { public string name; public Transform transform; public BiomeOption biome; public VariantSelectionType variantSelectionType = VariantSelectionType.VariantObject; public List variants = new List(); public List variantObjects = new List(); public SegmentVariant initialVariant; public SegmentVariant customVariant => variants.Find((SegmentVariant x) => x.isCustom); public SegmentVariant activeVariant => variants.Find((SegmentVariant x) => x.isActive); } public class SegmentVariant { public string name; public Transform transform; public BiomeSegment segment; public bool isCustom; public bool isInitial; public bool isActive => ((Component)transform).gameObject.activeSelf; } public static List biomeSections = new List(); public static void BuildMapData() { biomeSections.Clear(); GetBiomeSections(Singleton.Instance); } private static void GetBiomeSections(MapHandler mapHandler) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown foreach (Transform item in ((Component)mapHandler).transform) { Transform val = item; if ((Object)(object)((Component)val).GetComponent() != (Object)null) { BiomeSection biomeSection = new BiomeSection { name = ((Object)val).name, transform = val }; GetBiomeOptions(biomeSection); biomeSections.Add(biomeSection); } } } private static void GetBiomeOptions(BiomeSection biomeSection) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) Biome val2 = default(Biome); foreach (Transform item in biomeSection.transform) { Transform val = item; if (((Component)val).TryGetComponent(ref val2)) { BiomeOption biomeOption = new BiomeOption { name = ((Object)val).name, transform = val, biomeType = val2.biomeType, section = biomeSection }; GetBiomeSegments(biomeOption); biomeSection.biomes.Add(biomeOption); } } } private static void GetBiomeSegments(BiomeOption biomeOption) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown foreach (Transform item in biomeOption.transform) { Transform val = item; if (((Object)val).name.Contains("Segment")) { BiomeSegment biomeSegment = new BiomeSegment { name = ((Object)val).name, transform = val, biome = biomeOption }; VariationSwapper componentInChildren = ((Component)biomeSegment.transform).GetComponentInChildren(true); biomeSegment.variantSelectionType = ((!((Object)(object)componentInChildren != (Object)null)) ? VariantSelectionType.VariantObject : VariantSelectionType.BiomeVariant); GetSegmentVariants(biomeSegment); biomeOption.segments.Add(biomeSegment); } } } private static void GetSegmentVariants(BiomeSegment biomeSegment) { if (biomeSegment.variantSelectionType == VariantSelectionType.BiomeVariant) { Variation[] variations = ((Component)biomeSegment.transform).GetComponentInChildren(true).Variations; foreach (Variation val in variations) { SegmentVariant segmentVariant = new SegmentVariant { name = ((Object)val.parent).name, transform = val.parent.transform, segment = biomeSegment, isInitial = val.parent.activeSelf }; if (segmentVariant.isInitial) { biomeSegment.initialVariant = segmentVariant; } biomeSegment.variants.Add(segmentVariant); } } else { MapManager.PrepareDefaultVariant(biomeSegment); VariantObject[] componentsInChildren = ((Component)biomeSegment.transform).GetComponentsInChildren(true); foreach (VariantObject val2 in componentsInChildren) { SegmentVariant item = new SegmentVariant { name = ((Object)val2).name, transform = ((Component)val2).transform, segment = biomeSegment }; biomeSegment.variantObjects.Add(item); } } } } public static class MapLoader { public static void ApplySave(MapSerializer.MapSaveData save) { //IL_0250: Unknown result type (might be due to invalid IL or missing references) ((Component)Singleton.Instance).GetComponent().ClearAll(); foreach (MapData.BiomeSection biomeSection2 in MapData.biomeSections) { foreach (MapData.BiomeOption biome in biomeSection2.biomes) { if (!biome.segmentHasCustomVariant) { continue; } foreach (MapData.BiomeSegment segment in biome.segments) { if (segment.customVariant != null) { MapManager.DeleteSegmentVariant(segment.customVariant); } } } } foreach (MapSerializer.SegmentSaveData seg in save.Segments) { if (seg.SectionIndex < 0) { continue; } MapData.BiomeSection biomeSection = MapData.biomeSections[seg.SectionIndex]; MapData.BiomeOption biomeOption = biomeSection.biomes.FirstOrDefault((MapData.BiomeOption b) => b.biomeType == seg.BiomeType); if (biomeOption == null) { continue; } MapManager.ChangeBiome(biomeSection, biomeOption); MapData.BiomeSegment biomeSegment = biomeOption.segments[seg.SegmentIndex]; if (biomeSegment.customVariant != null) { MapManager.DeleteSegmentVariant(biomeSegment.customVariant); } ((Component)biomeSegment.activeVariant.transform).gameObject.SetActive(false); GameObject val = RebuildObjectData(seg.CustomVariant); ((Object)val).name = "Custom"; val.transform.SetParent(biomeSegment.transform, false); MapData.SegmentVariant segmentVariant = new MapData.SegmentVariant { name = "Custom", isCustom = true, transform = val.transform, segment = biomeSegment }; biomeSegment.variants.Add(segmentVariant); ((Component)segmentVariant.transform).gameObject.SetActive(true); if ((Object)(object)val.GetComponent() == (Object)null) { val.AddComponent(); } if ((Object)(object)val.GetComponent() == (Object)null) { val.AddComponent(); } foreach (Transform item in val.transform) { EnableCustomObject(((Component)item).gameObject); } } MapSerializer.GameObjectReferences.Clear(); MapSerializer.testgos.Clear(); } private static void EnableCustomObject(GameObject go) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) go.SetActive(true); foreach (Transform item in go.transform) { EnableCustomObject(((Component)item).gameObject); } } public static GameObject RebuildObjectData(MapSerializer.ObjectData data) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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) GameObject val = MapSerializer.testgos.Find((GameObject x) => ((Object)x).name == data.Id); GameObject val2; if ((Object)(object)val != (Object)null) { val2 = val; ((Object)val2).name = data.Name; } else { val2 = new GameObject(data.Name); val2.SetActive(false); } MapSerializer.GameObjectReferences[data.Id] = val2; val2.transform.localPosition = data.Transform.Position; val2.transform.localEulerAngles = data.Transform.Rotation; val2.transform.localScale = data.Transform.Scale; foreach (MapSerializer.ComponentData component in data.Components) { if (component.Type == typeof(Transform)) { continue; } Component obj = val2.AddComponent(component.Type); foreach (MapSerializer.FieldData field2 in component.Fields) { FieldInfo field = component.Type.GetField(field2.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(field == null)) { object value = field2.Value; try { field.SetValue(obj, value); } catch { } } } } foreach (MapSerializer.ObjectData child in data.Children) { RebuildObjectData(child).transform.SetParent(val2.transform, false); } return val2; } } public static class MapManager { public static void ChangeBiome(MapData.BiomeSection biomeSection, MapData.BiomeOption targetBiome) { //IL_006d: 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) if (biomeSection.activeBiome.segmentHasCustomVariant) { foreach (MapData.BiomeSegment segment in biomeSection.activeBiome.segments) { MapData.SegmentVariant customVariant = segment.customVariant; if (customVariant != null) { DeleteSegmentVariant(customVariant); } } } if (biomeSection.activeBiome != targetBiome) { int index = Singleton.Instance.biomes.IndexOf(biomeSection.activeBiome.biomeType); Singleton.Instance.biomes[index] = targetBiome.biomeType; ((Component)biomeSection.activeBiome.transform).gameObject.SetActive(false); ((Component)targetBiome.transform).gameObject.SetActive(true); } } public static void DeleteSegmentVariant(MapData.SegmentVariant targetVariant) { MapData.BiomeSegment segment = targetVariant.segment; segment.variants.Remove(targetVariant); Object.Destroy((Object)(object)((Component)targetVariant.transform).gameObject); targetVariant = null; ((Component)segment.initialVariant.transform).gameObject.SetActive(true); } public static void AssignNewPhotonIds(PhotonView[] views) { foreach (PhotonView obj in views) { obj.ViewID = 0; PhotonNetwork.AllocateViewID(obj); } } public static void CreateVariant(MapData.BiomeSegment biomeSegment, int variantIndex) { ((Component)biomeSegment.transform).GetComponentInParent().ClearAll(); ((Component)biomeSegment.activeVariant.transform).gameObject.SetActive(false); if (biomeSegment.variantSelectionType == MapData.VariantSelectionType.BiomeVariant) { Transform val = Object.Instantiate(biomeSegment.variants[variantIndex].transform); ((Component)val).transform.SetParent(biomeSegment.transform, false); ((Object)val).name = "Custom"; MapData.SegmentVariant segmentVariant = new MapData.SegmentVariant { name = "Custom", isCustom = true, transform = val, segment = biomeSegment }; biomeSegment.variants.Add(segmentVariant); AssignNewPhotonIds(((Component)val).GetComponentsInChildren(true)); ((Component)segmentVariant.transform).gameObject.SetActive(true); return; } Transform val2 = Object.Instantiate(biomeSegment.initialVariant.transform); ((Component)val2).transform.SetParent(biomeSegment.transform, false); ((Object)val2).name = "Custom"; MapData.SegmentVariant segmentVariant2 = new MapData.SegmentVariant { name = "Custom", isCustom = true, transform = val2, segment = biomeSegment }; biomeSegment.variants.Add(segmentVariant2); VariantObject[] componentsInChildren = ((Component)val2).GetComponentsInChildren(true); if (variantIndex != -1) { MapData.SegmentVariant segmentVariant3 = biomeSegment.variantObjects[variantIndex]; for (int i = 0; i < componentsInChildren.Length; i++) { if (((Object)componentsInChildren[i]).name != segmentVariant3.name) { Object.Destroy((Object)(object)((Component)componentsInChildren[i]).gameObject); } else { ((Component)componentsInChildren[i]).gameObject.SetActive(true); } } } List list = new List(); GetAllInactiveSelfGameObjects(segmentVariant2.transform, list); foreach (GameObject item in list) { Object.Destroy((Object)(object)item); } DesertRockSpawner componentInChildren = ((Component)val2).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { Object.Destroy((Object)(object)componentInChildren); } AssignNewPhotonIds(((Component)val2).GetComponentsInChildren(true)); ((Component)segmentVariant2.transform).gameObject.SetActive(true); } private static void GetAllInactiveSelfGameObjects(Transform target, List results) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown foreach (Transform item in target) { Transform val = item; if (!Object.op_Implicit((Object)(object)((Component)val).GetComponent())) { if (!((Component)val).gameObject.activeSelf) { results.Add(((Component)val).gameObject); } else { GetAllInactiveSelfGameObjects(val, results); } } } } public static void PrepareDefaultVariant(MapData.BiomeSegment biomeSegment) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown if (biomeSegment.variantSelectionType != MapData.VariantSelectionType.VariantObject) { return; } GameObject val = new GameObject("Default"); val.transform.SetParent(biomeSegment.transform); List list = new List(); foreach (Transform item in biomeSegment.transform) { Transform val2 = item; if ((Object)(object)((Component)val2).gameObject.GetComponent() != (Object)null) { list.Add(val2); } } foreach (Transform item2 in list) { item2.SetParent(val.transform); } val.gameObject.AddComponent(); val.gameObject.AddComponent(); MapData.SegmentVariant segmentVariant = new MapData.SegmentVariant { name = "Default", isCustom = false, transform = val.transform, segment = biomeSegment, isInitial = true }; biomeSegment.variants.Add(segmentVariant); biomeSegment.initialVariant = segmentVariant; } public static void DisableInactiveSegments() { MapSegment[] variantSegments = Singleton.Instance.variantSegments; foreach (MapSegment val in variantSegments) { val.segmentParent.SetActive(false); if ((Object)(object)val.segmentCampfire != (Object)null) { val.segmentCampfire.SetActive(false); } } } } public static class MapSaver { public static void SaveTerrain(string saveName) { //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) ((Component)Singleton.Instance).GetComponent().ClearAll(); MapSerializer.MapSaveData mapSaveData = new MapSerializer.MapSaveData { MapName = saveName }; for (int i = 0; i < MapData.biomeSections.Count; i++) { MapData.BiomeOption activeBiome = MapData.biomeSections[i].activeBiome; if (!activeBiome.segmentHasCustomVariant) { continue; } for (int j = 0; j < activeBiome.segments.Count; j++) { if (activeBiome.segments[j].customVariant != null) { MapSerializer.SegmentSaveData item = new MapSerializer.SegmentSaveData { SectionIndex = i, SegmentIndex = j, BiomeType = activeBiome.biomeType, CustomVariant = MapSerializer.BuildObjectData(activeBiome.segments[j].customVariant.transform) }; mapSaveData.Segments.Add(item); } } } Directory.CreateDirectory(MapSerializer.SavePath); string path = Path.Combine(MapSerializer.SavePath, saveName + ".json"); using MemoryStream memoryStream = new MemoryStream(); JsonDataWriter val = new JsonDataWriter((Stream)memoryStream, TerrainCustomiserSerialization.CreateSerializationContext(), false); SerializationUtility.SerializeValue(mapSaveData, (IDataWriter)(object)val); File.WriteAllBytes(path, memoryStream.ToArray()); } } public static class ResourceManager { public static List GameObjectResources = new List(); public static List MaterialResources = new List(); public static void GetAllResources() { GetAllGameObjectResources(); GetAllMaterialResources(); } private static void GetAllGameObjectResources() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) GameObjectResources.Clear(); GameObject[] array = Resources.FindObjectsOfTypeAll(); foreach (GameObject val in array) { if (!((Object)(object)val == (Object)null) && (Object)(object)val.transform.parent == (Object)null) { Scene scene = val.scene; if (!((Scene)(ref scene)).IsValid()) { GameObjectResources.Add(val); } } } } private static void GetAllMaterialResources() { MaterialResources.Clear(); Material[] array = Resources.FindObjectsOfTypeAll(); foreach (Material val in array) { if (!((Object)(object)val == (Object)null)) { MaterialResources.Add(val); } } } } } namespace TerrainCustomiserCN.Map.Serialization { public static class MapSerializer { public class ObjectData { public string Id; public string Name; public TransformData Transform; public List Components = new List(); public List Children = new List(); } public class TransformData { public Vector3 Position; public Vector3 Rotation; public Vector3 Scale; } public class ComponentData { public Type Type; public List Fields = new List(); } public class FieldData { public string Name; public Type Type; public object Value; } public class MapSaveData { public string MapName; public List Segments = new List(); } public class MapSyncData { public int seed; public bool bakeLightMap; public byte[] mapSaveData; } public class SegmentSaveData { public int SectionIndex; public int SegmentIndex; public BiomeType BiomeType; public ObjectData CustomVariant; } internal static readonly string SavePath = ResolveSavePath(); internal static List SaveFiles = new List(); public static Dictionary GameObjectReferences = new Dictionary(); public static List testgos = new List(); public static string GetIdFromGameObject(GameObject go) { KeyValuePair keyValuePair = GameObjectReferences.FirstOrDefault((KeyValuePair x) => (Object)(object)x.Value == (Object)(object)go); if ((Object)(object)keyValuePair.Value == (Object)null) { string text = Guid.NewGuid().ToString("N"); GameObjectReferences.Add(text, go); return text; } return keyValuePair.Key; } public static string GetPathFromGameObject(GameObject go) { Transform val = go.transform; if ((Object)(object)val == (Object)null) { return null; } StringBuilder stringBuilder = new StringBuilder(((Object)val).name); while ((Object)(object)val.parent != (Object)null) { val = val.parent; stringBuilder.Insert(0, ((Object)val).name + "/"); } return stringBuilder.ToString(); } private static string ResolveSavePath() { string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty; string[] array = new string[3] { Path.Combine(path, "..", "Snosz-TerrainCustomiser", "Map Saves"), Path.Combine(path, "Map Saves"), Path.Combine(path, "..", "Snosz-TerrainCustomiserCN", "Map Saves") }; string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string fullPath = Path.GetFullPath(array2[i]); if (Directory.Exists(fullPath)) { return fullPath; } } return Path.GetFullPath(array[0]); } public static void RefreshSaveList() { if (Directory.Exists(SavePath)) { SaveFiles.Clear(); IEnumerable enumerable = Directory.GetFiles(SavePath, "*.json").Select(Path.GetFileName); if (enumerable != null) { SaveFiles.AddRange(enumerable); } } } public static byte[] GetSave(int selectedSaveIndex) { string path = Path.Combine(SavePath, SaveFiles[selectedSaveIndex]); if (!File.Exists(path)) { return null; } return File.ReadAllBytes(path); } public static MapSaveData LoadSave(int selectedSaveIndex) { return SerializationUtility.DeserializeValue(GetSave(selectedSaveIndex), (DataFormat)1, TerrainCustomiserSerialization.CreateDeserializationContext()); } public static MapSaveData LoadFromBytes(byte[] bytes) { return SerializationUtility.DeserializeValue(bytes, (DataFormat)1, TerrainCustomiserSerialization.CreateDeserializationContext()); } public static void SaveTerrain() { } public static ObjectData BuildObjectData(Transform t) { //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_003b: 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_0047: 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_0086: 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) ObjectData objectData = new ObjectData { Id = GetIdFromGameObject(((Component)t).gameObject), Name = ((Object)((Component)t).gameObject).name, Transform = new TransformData { Position = t.localPosition, Rotation = t.localEulerAngles, Scale = t.localScale } }; Component[] components = ((Component)t).GetComponents(); foreach (Component val in components) { if (!((Object)(object)val == (Object)null) && !(val is Transform)) { if (val is PhotonView) { PhotonView val2 = (PhotonView)val; val2.ViewID = 0; val2.sceneViewId = 0; } objectData.Components.Add(SerializeComponent(val)); } } for (int j = 0; j < t.childCount; j++) { objectData.Children.Add(BuildObjectData(t.GetChild(j))); } return objectData; } private static ComponentData SerializeComponent(Component comp) { Type type = ((object)comp).GetType(); ComponentData componentData = new ComponentData { Type = type }; FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (!fieldInfo.IsStatic && !fieldInfo.IsNotSerialized && (fieldInfo.IsPublic || ((MemberInfo)fieldInfo).GetCustomAttribute() != null)) { object value = fieldInfo.GetValue(comp); componentData.Fields.Add(new FieldData { Name = fieldInfo.Name, Type = fieldInfo.FieldType, Value = value }); } } return componentData; } } } namespace TerrainCustomiserCN.Managers { internal static class BundleManager { internal static AssetBundle DebugShaderBundle; internal static AssetBundle VisibilityComputeBundle; internal static void Setup() { DebugShaderBundle = AssetBundle.LoadFromMemory(Resource1.selectionoverlay); GizmoUtils.SelectionOverlayShader = DebugShaderBundle.LoadAsset("SelectionOverlay.shader"); VisibilityComputeBundle = AssetBundle.LoadFromMemory(Resource1.visibilitycompute); LightMapBaker.computeShader = VisibilityComputeBundle.LoadAsset("SkyVisibilityDDA"); } internal static void UnloadAll() { DebugShaderBundle.Unload(true); VisibilityComputeBundle.Unload(true); } } internal static class ChineseFontManager { private const int FontSizeInPixels = 16; private static readonly string[] FontFileNames = new string[4] { "simhei.ttf", "NotoSansSC-VF.ttf", "msyh.ttc", "simsun.ttc" }; private static ImGuiFontAsset _fontAsset; private static bool _loggedMissingFont; internal static ImGuiFontAsset AppendChineseFont(ImGuiFontAsset originalFontAsset) { //IL_003c: 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) string text = FindFontPath(); if (text == null) { if (!_loggedMissingFont) { Debug.LogWarning((object)"[TCCN] 找不到可用的中文字体,ImGui 中文界面可能无法正确显示。"); _loggedMissingFont = true; } return originalFontAsset; } if (Object.op_Implicit((Object)(object)_fontAsset)) { return _fontAsset; } List list = new List { new FontSettings { fontPath = text, sizeInPixels = 16, glyphRanges = (ScriptGlyphRanges)129 } }; if (Object.op_Implicit((Object)(object)originalFontAsset) && originalFontAsset.fontSettings != null) { list.AddRange(originalFontAsset.fontSettings); } _fontAsset = ScriptableObject.CreateInstance(); _fontAsset.fontSettings = list.ToArray(); return _fontAsset; } private static string FindFontPath() { string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Fonts"); string[] fontFileNames = FontFileNames; foreach (string path2 in fontFileNames) { string text = Path.Combine(path, path2); if (File.Exists(text)) { return text; } } return null; } } internal static class ConfigManager { public static ConfigFile ConfigFile; public static ConfigEntry EnableLightMapBaking; public static ConfigEntry BakeLightMap; public static ConfigEntry UseRandomSeed; public static ConfigEntry SeedToUse; internal static void Setup() { ConfigFile = ((BaseUnityPlugin)Plugin.Instance).Config; ConfigFile.SaveOnConfigSet = true; EnableLightMapBaking = ConfigFile.Bind("General", "EnableLightMapBaking", true, "生成用于部分游戏机制的光照贴图。若游戏崩溃,请关闭此项。"); BakeLightMap = ConfigFile.Bind("UI", "BakeLightMap", false, "保存机场界面中“烘焙光照贴图”复选框的上次状态。"); UseRandomSeed = ConfigFile.Bind("UI", "UseRandomSeed", true, "保存机场界面中“随机种子”复选框的上次状态。"); SeedToUse = ConfigFile.Bind("UI", "SeedToUse", 42, "保存机场界面中“种子”输入框的上次状态。"); if (!EnableLightMapBaking.Value) { BakeLightMap.Value = false; } } } public class EditorManager : Singleton { public List levelGenStepTypes; private MenuWindow menuWindow; public int currentSegmentIndex; public MapData.BiomeSegment currentSegment; private EditorWindow editorWindow; public static InputAction action_pause; internal static void Setup() { SessionState.Set(SessionState.State.InEditor); ((Component)Plugin.Instance).gameObject.AddComponent(); } public GameObject CreateObject(string name, Transform parent, Vector3 position, Quaternion rotation) { //IL_0001: 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_002d: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown GameObject val = new GameObject(name); if ((Object)(object)parent == (Object)null) { parent = currentSegment.customVariant.transform; } val.transform.SetParent(parent); val.transform.position = position; val.transform.rotation = rotation; return val; } public GameObject CreateObjectWithComponent(string name, Transform parent, Type type, Vector3 position, Quaternion rotation) { //IL_0003: 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) GameObject obj = CreateObject(name, parent, position, rotation); obj.AddComponent(type); return obj; } private void InitializeNullCollections(Component component) { FieldInfo[] fields = ((object)component).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { Type fieldType = fieldInfo.FieldType; if (fieldInfo.GetValue(component) == null) { if (fieldType.IsArray) { Array value = Array.CreateInstance(fieldType.GetElementType(), 0); fieldInfo.SetValue(component, value); } else if (fieldType.IsGenericType && fieldType.GetGenericTypeDefinition() == typeof(List<>)) { object value2 = Activator.CreateInstance(fieldType); fieldInfo.SetValue(component, value2); } } } } public GameObject DuplicateObject(Transform target) { Transform val = Object.Instantiate(target); if ((Object)(object)target.parent != (Object)null) { val.SetParent(target.parent); } return ((Component)val).gameObject; } public void DestroyObject(GameObject go) { Object.Destroy((Object)(object)go); } private void SetupCamera() { CameraOverride val = ((Component)Camera.main).gameObject.AddComponent(); val.fov = Camera.main.fieldOfView; if ((Object)(object)((Component)Camera.main).GetComponent() != (Object)null) { ((Component)Camera.main).GetComponent().SetCameraOverride(val); GodCam godcam = Singleton.Instance.godcam; godcam.drag = 10f; godcam.force = 100f; godcam.lookDrag = 10f; godcam.lookSens = 100f; } } private void Update() { HandleInput(); TryDrawGizmos(); } private void TryDrawGizmos() { if (EditorGizmos.IsEnabled && (Object)(object)editorWindow.hierarchy.Selected != (Object)null) { LevelGenStep component = ((Component)editorWindow.hierarchy.Selected).gameObject.GetComponent(); GizmoUtils.TryDrawGizmos(editorWindow.hierarchy.Selected, (Component)(object)component); GizmoUtils.TryDrawOverlays(editorWindow.hierarchy.Selected); } } private void HandleInput() { if (UnityInput.Current.GetMouseButtonDown(1)) { SetGodCamActive(active: true); menuWindow.Hide(); } if (UnityInput.Current.GetMouseButtonUp(1)) { SetGodCamActive(active: false); menuWindow.Show(); } if (action_pause.WasPressedThisFrame()) { GUIManager.instance.pauseMenu.SetActive(!GUIManager.instance.pauseMenu.activeSelf); } } private void SetGodCamActive(bool active) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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) Singleton.Instance.isGodCam = active; GodCam godcam = Singleton.Instance.godcam; if (!active) { godcam.lookVel = Vector2.zero; godcam.vel = Vector3.zero; godcam.targetFov = Singleton.Instance.currentFov; } } public void SetCurrentSegment(MapData.BiomeSegment biomeSegment) { //IL_0073: 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_008c: Unknown result type (might be due to invalid IL or missing references) currentSegment = biomeSegment; MapSegment[] segments = Singleton.Instance.segments; foreach (MapSegment val in segments) { if ((Object)(object)val.segmentParent.transform == (Object)(object)biomeSegment.transform) { val.segmentParent.SetActive(true); if ((Object)(object)val.segmentCampfire != (Object)null) { val.segmentCampfire.SetActive(true); } ((Component)Camera.main).transform.position = ((Component)val.reconnectSpawnPos).transform.position + new Vector3(0f, 25f, 0f); if ((Object)(object)val.wallNext != (Object)null) { ((Component)Camera.main).transform.LookAt(val.wallNext.transform); } } else { val.segmentParent.SetActive(false); if ((Object)(object)val.segmentCampfire != (Object)null) { val.segmentCampfire.SetActive(false); } } } } public void GenerateCurrentSegment() { ((Component)currentSegment.transform).GetComponentInParent().RunAll(false); EditorGizmos.RefreshGizmos(); } public void ChangeBiome(MapData.BiomeSection biomeSection, MapData.BiomeOption targetBiome) { MapManager.ChangeBiome(biomeSection, targetBiome); SetCurrentSegment(targetBiome.segments.FirstOrDefault()); } protected override void Awake() { base.Awake(); } private void Start() { PrepareEditorMode(); } public override void OnDestroy() { base.OnDestroy(); WindowsManager.UnregisterAll(); } public void EndSession() { menuWindow.Close(); Object.Destroy((Object)(object)this); } public void LoadSave() { } private void PrepareEditorMode() { //IL_0052: 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) action_pause = InputSystem.actions.FindAction("Pause", false); DisableFog(); DisableScoutmaster(); DisableCharacter(); DisableGameUI(); GetAllLevelGenStepTypes(); MapManager.DisableInactiveSegments(); ((Component)Singleton.Instance.globalParent).GetComponent().ClearAll(); GameObject val = new GameObject("MenuWindow"); val.transform.parent = ((Component)this).gameObject.transform; menuWindow = val.AddComponent(); WindowsManager.Register(); WindowsManager.Register(); WindowsManager.Register(); WindowsManager.Register(); if ((Object)(object)menuWindow != (Object)null) { menuWindow.Show(); } editorWindow = WindowsManager.Get(); HierarchyView hierarchy = editorWindow.hierarchy; hierarchy.OnSelectionChanged = (Action)Delegate.Combine(hierarchy.OnSelectionChanged, new Action(EditorGizmos.OnSelectionChanged)); } private void DisableFog() { GameObject val = GameObject.Find("Misc/Post Fog"); if ((Object)(object)val != (Object)null) { val.SetActive(false); } GameObject val2 = GameObject.Find("FogSphereSystem"); if ((Object)(object)val2 != (Object)null) { val2.SetActive(false); } } private void DisableScoutmaster() { Scoutmaster val = default(Scoutmaster); if (Scoutmaster.GetPrimaryScoutmaster(ref val)) { ((Component)val).gameObject.SetActive(false); } } private void DisableCharacter() { if ((Object)(object)Character.localCharacter != (Object)null) { ((Component)Character.localCharacter).gameObject.SetActive(false); Character.localCharacter = null; } } private void DisableGameUI() { if ((Object)(object)GUIManager.instance != (Object)null && (Object)(object)GUIManager.instance.hudCanvas != (Object)null) { ((Component)GUIManager.instance.hudCanvas).gameObject.SetActive(false); } if ((Object)(object)GamefeelHandler.instance != (Object)null) { PerlinShake componentInChildren = ((Component)GamefeelHandler.instance).gameObject.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { ((Component)componentInChildren).gameObject.SetActive(false); } } } private void GetAllLevelGenStepTypes() { Type baseType = typeof(LevelGenStep); levelGenStepTypes = (from t in baseType.Assembly.GetTypes() where baseType.IsAssignableFrom(t) && !t.IsAbstract select t).ToList(); } } internal static class NetworkManager { public static class PropertyKeys { public const string MapData = "mapData"; public const string PropViews = "propViews"; public const string PlayerInfo = "playerInfo"; public const string InCustomMap = "TC_inCustomMap"; } private static PhotonScopedManager _manager; private static SteamLobbyHandler _steamLobbyHandler; internal static void Setup() { _manager = PhotonCustomPropsUtilsPlugin.GetManager("com.snosz.terraincustomiser"); _steamLobbyHandler = GameHandler.GetService(); RegisterEvents(); } public static void SetRoomProperty(string propertyKey, object value) { _manager.SetRoomProperty(propertyKey, value); } public static void SetPlayerProperty(string propertyKey, object value) { _manager.SetPlayerProperty(propertyKey, value); } internal static void SetLobbyData(string propertyKey, string value) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (_steamLobbyHandler != null) { SteamMatchmaking.SetLobbyData(_steamLobbyHandler.LobbySteamId, propertyKey, value); } } internal static string GetLobbyData(string propertyKey) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (_steamLobbyHandler != null) { return SteamMatchmaking.GetLobbyData(_steamLobbyHandler.LobbySteamId, propertyKey); } return null; } private static void RegisterEvents() { _manager.RegisterRoomProperty("mapData", (RoomEventType)2, (Action)delegate(byte[] val) { OnMapDataChanged(val); }); _manager.RegisterRoomProperty("propViews", (RoomEventType)2, (Action)delegate(int[] val) { OnPropViewsChanged(val); }); _manager.RegisterOnJoinedRoom((Action)delegate { OnLocalPlayerJoinedRoom(); }); _manager.RegisterPlayerProperty("playerInfo", (PlayerEventType)2, (Action)delegate(Player targetPlayer, byte[] value) { OnPlayerInfoChanged(targetPlayer, value); }); } private static void OnMapDataChanged(byte[] val) { if (val == null) { PlayerInfoManager.currentMapSyncData = null; PlayerInfoManager.LocalPlayerInfo.hasMapData = false; } else { PlayerInfoManager.currentMapSyncData = NetworkUtils.DecompressMapSyncData(val); PlayerInfoManager.LocalPlayerInfo.hasMapData = true; if (SessionState.Is(SessionState.State.WaitingForMapData)) { SessionState.Set(SessionState.State.WaitingToStartCustomMap); MapHandler.InitializeMap(); } else { SessionState.Set(SessionState.State.WaitingToStartCustomMap); } } PlayerInfoManager.SendLocalPlayerInfo(); } private static void OnPropViewsChanged(int[] val) { if (!PhotonNetwork.IsMasterClient) { ViewSyncManager.ReceivePendingIds(val); } } private static void OnLocalPlayerJoinedRoom() { byte[] value = SerializationUtility.SerializeValue(PlayerInfoManager.LocalPlayerInfo, (DataFormat)1, TerrainCustomiserSerialization.CreateSerializationContext()); SetPlayerProperty("playerInfo", value); } private static void OnPlayerInfoChanged(Player targetPlayer, byte[] val) { PlayerInfoManager.HandlePlayerInfoChanged(targetPlayer, val); if (PhotonNetwork.IsMasterClient && SessionState.Is(SessionState.State.WaitingToStartCustomMap) && PlayerInfoManager.LobbyHasMapData) { Plugin.Instance.LoadWilIsland(); } } } public class PlayerInfo { public bool canBake; public bool hasMapData; } internal static class PlayerInfoManager { public static Dictionary PlayersInfo = new Dictionary(); public static PlayerInfo LocalPlayerInfo; internal static MapSerializer.MapSyncData currentMapSyncData; public static bool LobbyCanBake = false; public static bool LobbyHasMapData = false; internal static void Setup() { LocalPlayerInfo = new PlayerInfo { canBake = ConfigManager.EnableLightMapBaking.Value }; } public static void HandlePlayerInfoChanged(Player targetPlayer, byte[] data) { PlayerInfo playerInfo = SerializationUtility.DeserializeValue(data, (DataFormat)1, TerrainCustomiserSerialization.CreateDeserializationContext()); if (PlayersInfo.TryGetValue(targetPlayer, out var _)) { UpdatePlayerInfo(targetPlayer, playerInfo); } else { AddPlayerInfo(targetPlayer, playerInfo); } } public static void SendLocalPlayerInfo() { byte[] value = SerializationUtility.SerializeValue(LocalPlayerInfo, (DataFormat)1, TerrainCustomiserSerialization.CreateSerializationContext()); NetworkManager.SetPlayerProperty("playerInfo", value); } public static void AddPlayerInfo(Player targetPlayer, PlayerInfo playerInfo) { PlayersInfo.Add(targetPlayer, playerInfo); if (PhotonNetwork.IsMasterClient) { LobbyCanBake = PlayersInfo.All((KeyValuePair x) => x.Value.canBake); LobbyHasMapData = PlayersInfo.All((KeyValuePair x) => x.Value.hasMapData); } } public static void RemovePlayerInfo(Player targetPlayer) { if (PlayersInfo.Remove(targetPlayer) && PhotonNetwork.IsMasterClient) { LobbyCanBake = PlayersInfo.All((KeyValuePair x) => x.Value.canBake); LobbyHasMapData = PlayersInfo.All((KeyValuePair x) => x.Value.hasMapData); } } public static void UpdatePlayerInfo(Player targetPlayer, PlayerInfo playerInfo) { PlayersInfo[targetPlayer] = playerInfo; if (PhotonNetwork.IsMasterClient) { LobbyCanBake = PlayersInfo.All((KeyValuePair x) => x.Value.canBake); LobbyHasMapData = PlayersInfo.All((KeyValuePair x) => x.Value.hasMapData); } } } internal static class ViewSyncManager { private static List pendingViews = new List(); private static int[] pendingIds; internal static void AddPendingView(PhotonView view) { if (!pendingViews.Contains(view)) { pendingViews.Add(view); } } internal static void ReceivePendingIds(int[] ids) { pendingIds = ids; HandlePendingViews(); } private static void ClearPending() { pendingViews.Clear(); pendingIds = null; } internal static void HandlePendingViews() { if (PhotonNetwork.IsMasterClient) { int[] value = AssignPendingViews(); NetworkManager.SetRoomProperty("propViews", value); ClearPending(); } else if (pendingIds != null && pendingIds.Length != 0) { ApplyPendingIds(); ClearPending(); } } private static int[] AssignPendingViews() { int[] array = new int[pendingViews.Count]; for (int i = 0; i < pendingViews.Count; i++) { int num = PhotonNetwork.AllocateViewID(false); pendingViews[i].ViewID = num; array[i] = num; } return array; } private static void ApplyPendingIds() { if (pendingIds.Length != pendingViews.Count) { Debug.LogError((object)$"[TCCN] ID Count mismatch! Map will be out of sync! Views: {pendingViews.Count}, Ids: {pendingIds.Length}."); return; } for (int i = 0; i < pendingIds.Length; i++) { if ((Object)(object)pendingViews[i] != (Object)null && (Object)(object)((Component)pendingViews[i]).gameObject != (Object)null) { pendingViews[i].ViewID = pendingIds[i]; } } } } public class WindowsManager : MonoBehaviour { private static WindowsManager _instance; private static List windows = new List(); internal static void Setup() { //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) if (!((Object)(object)_instance != (Object)null)) { _instance = new GameObject("TCCN_WindowsManager") { hideFlags = (HideFlags)61 }.AddComponent(); } } public static T Get() where T : ImGuiWindowBase { return (T)windows.Find((ImGuiWindowBase w) => w is T); } public static T Register() where T : ImGuiWindowBase, new() { T val = new T(); if (!windows.Contains(val)) { windows.Add(val); val.OnCreate(); } return val; } public static void Unregister() where T : ImGuiWindowBase { T val = (T)windows.Find((ImGuiWindowBase w) => w is T); if (val != null) { val.OnDestroy(); windows.Remove(val); } } public static void UnregisterAll() { foreach (ImGuiWindowBase window in windows) { window.OnDestroy(); } windows.Clear(); } private void OnEnable() { ImGui.Layout += OnLayout; } private void OnDisable() { ImGui.Layout -= OnLayout; } private void OnLayout() { DrawAll(); } private void DrawAll() { for (int i = 0; i < windows.Count; i++) { windows[i].DrawWindow(); } } } }