Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Trollheim v0.1.3
plugins/SilverTrolls/Fred.SilverTrolls.dll
Decompiled 15 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Fred.SilverTrolls")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.3.0")] [assembly: AssemblyInformationalVersion("0.1.3")] [assembly: AssemblyProduct("Fred.SilverTrolls")] [assembly: AssemblyTitle("Fred.SilverTrolls")] [assembly: AssemblyVersion("0.1.3.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Fred.SilverTrolls { [HarmonyPatch(typeof(ZoneSystem), "SetupLocations")] internal static class CampPlacement { private const string PlacedKey = "dlc_silver_troll_locations_v4"; private static readonly string[] CampIds = new string[3] { "DLC_SilverTrollPlainsStockade", "DLC_SilverTrollMistStonehold", "DLC_SilverTrollGiantsPlateau" }; private static readonly MethodInfo GenerateLocation = AccessTools.Method(typeof(ZoneSystem), "GenerateLocationsTimeSliced", new Type[3] { typeof(ZoneLocation), typeof(Stopwatch), typeof(ZPackage) }, (Type[])null); private static readonly Action<ZoneSystem, long> SendLocationIcons = AccessTools.MethodDelegate<Action<ZoneSystem, long>>(AccessTools.Method(typeof(ZoneSystem), "SendLocationIcons", (Type[])null, (Type[])null), (object)null, true); [HarmonyPriority(0)] private static void Postfix(ZoneSystem __instance) { if (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer()) { ((MonoBehaviour)__instance).StartCoroutine(PlaceInExistingWorld(__instance)); } } private static IEnumerator PlaceInExistingWorld(ZoneSystem zones) { yield return null; while (!zones.LocationsGenerated || (int)ZNet.GetConnectionStatus() != 2) { yield return null; } if (zones.GetGlobalKey("dlc_silver_troll_locations_v4")) { yield break; } ZoneLocation[] array = zones.m_locations.Where((ZoneLocation location) => CampIds.Contains(location.m_prefabName)).ToArray(); if (array.Length != CampIds.Length || GenerateLocation == null) { yield break; } ZoneLocation[] array2 = array; foreach (ZoneLocation camp in array2) { int num2 = zones.m_locationInstances.Values.Count((LocationInstance entry) => entry.m_location.m_prefabName == camp.m_prefabName); int num3 = ((!(camp.m_prefabName == "DLC_SilverTrollGiantsPlateau")) ? 1 : 10); if (num2 < num3) { yield return (IEnumerator)GenerateLocation.Invoke(zones, new object[3] { camp, Stopwatch.StartNew(), (object)new ZPackage() }); if (camp.m_prefabName == "DLC_SilverTrollGiantsPlateau") { SendLocationIcons(zones, 0L); } } } zones.SetGlobalKey("dlc_silver_troll_locations_v4"); } } internal static class PlateauHarbor { private const int Rows = 42; private const int CrestColumns = 7; private const int Columns = 11; private const float Seabed = -99f; private static readonly float[] Across = new float[7] { -1f, -0.75f, -0.4f, 0f, 0.43f, 0.74f, 1f }; private static readonly float[] Crown = new float[7] { -0.86f, -0.15f, 0.06f, 0f, 0.1f, -0.06f, -0.98f }; internal static void Build(Transform parent, PrefabManager prefabs, Material soil, Material rock, Vector3[] shoreProfile, Vector3[] shoreNormals) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_002d: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) Vector3 val = PlateauTerrain.RoutePoint(-0.65f); Vector3 val2 = PlateauTerrain.RoutePoint(-0.53f) - val; val2.y = 0f; Transform transform = new GameObject("Troll Harbor").transform; transform.SetParent(parent, false); transform.SetLocalPositionAndRotation(val, Quaternion.LookRotation(val2)); Vector3[] array = (Vector3[])(object)new Vector3[7]; Vector3[] array2 = (Vector3[])(object)new Vector3[7]; for (int i = 0; i < 7; i++) { array[i] = Quaternion.Inverse(transform.localRotation) * (shoreProfile[i] - val); array2[i] = Quaternion.Inverse(transform.localRotation) * shoreNormals[i]; } BuildEmbankment(transform, soil, rock, array, array2); GameObject source = Strongholds.Require(prefabs, "rock4_coast"); GameObject prefab = Beacon(prefabs); Vector3 center = default(Vector3); for (int j = -1; j <= 1; j += 2) { PlateauStonework.Rock(source, "Bonfire foundation", transform, new Vector3(7.9f * (float)j, -3.9f, -2.1f), Quaternion.Euler(1f, (float)j * 18f, (float)j * 2f), new Vector3(6.9f, 9.7f, 6.6f), collision: true); Strongholds.Place(prefab, transform, new Vector3(7.9f * (float)j, 0.53f, -2.1f), (float)j * 15f); for (int k = 0; k < 3; k++) { ((Vector3)(ref center))..ctor((float)j * (8.17f + 0.78f * (float)k), -1.48f - 0.5f * (float)k, -14.4f + (float)k * 3.5f); PlateauStonework.Rock(source, "Waterworn harbor stone", transform, center, Quaternion.Euler(8f * (float)k, (float)j * (33f + 27f * (float)k), (float)j * (5f + 7f * (float)k)), new Vector3(4f + 0.81f * (float)k, 3.7f + 0.35f * (float)k, 4.2f + 0.35f * (float)k), collision: true); } } } private static void BuildEmbankment(Transform harbor, Material soil, Material rock, Vector3[] seam, Vector3[] seamNormals) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Expected O, but got Unknown //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Earthen harbor embankment"); val.transform.SetParent(harbor, false); Vector3[] vertices = (Vector3[])(object)new Vector3[475]; Vector2[] uv = (Vector2[])(object)new Vector2[vertices.Length]; List<int> list = new List<int>(); List<int> banks = new List<int>(); Vector3 val2 = default(Vector3); for (int i = 0; i <= 42; i++) { float num = Mathf.Lerp(-29.7f, 0f, (float)i / 42f); float num2 = Mathf.InverseLerp(-29.7f, -13.1f, num); float num3 = Mathf.Lerp(-7.4f, -0.03f, num2 * num2 * (2f - num2)); float num4 = Mathf.SmoothStep(4.55f, 10.4f, Mathf.InverseLerp(-29.7f, -11.4f, num)) + 0.31f * Mathf.Sin(num * 0.47f) + 0.19f * Mathf.Cos(num * 1.16f); float num5 = 0.55f * Mathf.Sin(num * 0.37f); float num6 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(-5.2f, 0f, num)); int num7 = i * 11; for (int j = 0; j < 7; j++) { float num8 = Across[j]; float num9 = 0.14f * Mathf.Sin(num * 0.64f + (float)j * 1.3f) + 0.064f * Mathf.Cos(num * 1.28f - (float)j); ((Vector3)(ref val2))..ctor(num5 + num8 * num4, num3 + Crown[j] + num9, num); Vertex(num7 + j, Vector3.Lerp(val2, seam[j] + Vector3.forward * num, num6)); } Vector3 val3 = vertices[num7]; Vector3 val4 = vertices[num7 + 7 - 1]; float num10 = 0.65f * Mathf.Sin(num * 0.43f); Vertex(num7 + 7, val4 + new Vector3(2.15f + num10, -6.6f, 0.42f)); Vertex(num7 + 8, new Vector3(val4.x + 3.25f + num10, -99f, val4.z)); Vertex(num7 + 9, new Vector3(val3.x - 3.55f - num10, -99f, val3.z)); Vertex(num7 + 10, val3 + new Vector3(-2.12f - num10, -6.1f, -0.33f)); if (i != 42) { for (int k = 0; k < 11; k++) { int num11 = num7 + k; int num12 = num7 + (k + 1) % 11; List<int> obj = ((k >= 1 && k <= 4) ? list : banks); obj.Add(num11); obj.Add(num11 + 11); obj.Add(num12); obj.Add(num12); obj.Add(num11 + 11); obj.Add(num12 + 11); } } } Close(0, vertices.Length - 2, seaward: true); Close(462, vertices.Length - 1, seaward: false); Mesh val5 = new Mesh { name = "Sealed earthen harbor", vertices = vertices, uv = uv, subMeshCount = 2 }; val5.SetTriangles(list, 0); val5.SetTriangles(banks, 1); val5.RecalculateNormals(); Vector3[] normals = val5.normals; for (int l = 39; l <= 42; l++) { float num13 = Mathf.SmoothStep(0f, 1f, (float)(l - 42 + 4) / 4f); for (int m = 0; m < 7; m++) { int num14 = l * 11 + m; Vector3 val6 = Vector3.Slerp(normals[num14], seamNormals[m], num13); normals[num14] = ((Vector3)(ref val6)).normalized; } } val5.normals = normals; val5.RecalculateTangents(); val5.RecalculateBounds(); val.AddComponent<MeshFilter>().sharedMesh = val5; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterials = (Material[])(object)new Material[2] { soil, rock }; val.AddComponent<MeshCollider>().sharedMesh = val5; void Close(int start, int center, bool seaward) { //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_0029: Unknown result type (might be due to invalid IL or missing references) Vector3 val7 = vertices[start + 3]; val7.y = (val7.y + -99f) * 0.5f; Vertex(center, val7); for (int n = 0; n < 11; n++) { int num15 = start + n; int num16 = start + (n + 1) % 11; banks.Add(center); banks.Add(seaward ? num15 : num16); banks.Add(seaward ? num16 : num15); } } void Vertex(int index, Vector3 point) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //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_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) vertices[index] = point; uv[index] = PlateauTerrain.SurfaceUv(harbor.localPosition + harbor.localRotation * point); } } private static GameObject Beacon(PrefabManager prefabs) { GameObject val = prefabs.CreateClonedPrefab("DLC_SilverTrollHarborBonfire", Strongholds.Require(prefabs, "bonfire")); Fireplace component = val.GetComponent<Fireplace>(); component.m_startFuel = component.m_maxFuel; component.m_infiniteFuel = true; component.m_canRefill = false; component.m_playerBaseObject = null; WearNTear component2 = val.GetComponent<WearNTear>(); component2.m_noSupportWear = false; component2.m_noRoofWear = false; Strongholds.ShelterFromCreatures(val); val.AddComponent<StrongholdAddition>(); prefabs.AddPrefab(val); return val; } } internal static class PlateauLocation { internal const string Id = "DLC_SilverTrollGiantsPlateau"; internal const string MapName = "Troll Tower"; internal const string SummitCache = "DLC_SilverTrollSummitCache"; internal const float SummitHeight = 131.8f; internal const int TowerLimit = 10; internal const float Clearance = 250f; internal static void Register(PrefabManager prefabs, TrollArt art, IReadOnlyDictionary<string, GameObject> sentries) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_0164: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown ZoneManager instance = ZoneManager.Instance; GameObject val = instance.CreateLocationContainer("DLC_SilverTrollGiantsPlateau"); Location val2 = val.AddComponent<Location>(); val2.m_biome = (Biome)256; val2.m_exteriorRadius = 31f; val2.m_discoverLabel = "Troll Tower"; val2.m_clearArea = false; val2.m_noBuild = true; Material val3 = Cache.GetPrefab<Material>("rock_mistlands"); Material prefab = Cache.GetPrefab<Material>("stonewall"); Material val4 = Cache.GetPrefab<Material>("mudfloor"); if (!Object.op_Implicit((Object)(object)prefab) || !Object.op_Implicit((Object)(object)prefab.mainTexture)) { throw new InvalidOperationException("Missing the vanilla stone material for Giants' Plateau."); } if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val3.mainTexture)) { val3 = prefab; } if (!Object.op_Implicit((Object)(object)val4) || !Object.op_Implicit((Object)(object)val4.mainTexture)) { val4 = Cache.GetPrefab<Material>("rock_heath"); } if (!Object.op_Implicit((Object)(object)val4) || !Object.op_Implicit((Object)(object)val4.mainTexture)) { val4 = val3; } BuildCliff(val.transform, val3, val4); (Vector3[], Vector3[]) tuple = PlateauTerrain.Build(val.transform, val4, val3, new PlateauStonework(prefabs), sentries); PlateauHarbor.Build(val.transform, prefabs, val4, val3, tuple.Item1, tuple.Item2); BuildSummit(val.transform, prefabs, art, sentries); if (!instance.AddCustomLocation(new CustomLocation(val, false, new LocationConfig { Biome = (Biome)256, BiomeArea = (BiomeArea)3, Quantity = 10, Group = "DLC_SilverTrollGiantsPlateau", MaxTerrainDelta = float.MaxValue, MinDistanceFromSimilar = 250f, ExteriorRadius = val2.m_exteriorRadius, ClearArea = false, SnapToWater = true, RandomRotation = true, IconAlways = true }))) { throw new InvalidOperationException("Could not add Giants' Plateau to world generation."); } } private static void BuildCliff(Transform parent, Material material, Material soil) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_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_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Expected O, but got Unknown //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_0141: 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_014a: 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_0153: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0191: 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_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: 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_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) Vector2[] array = PlateauTerrain.CliffOutline(); List<Vector3> vertices = new List<Vector3>(); List<Vector2> uvs = new List<Vector2>(); List<int> triangles = new List<int>(); List<int> list = new List<int>(); Vector3[] top = (Vector3[])(object)new Vector3[array.Length]; for (int i = 0; i < array.Length; i++) { top[i] = new Vector3(array[i].x, 131.8f, array[i].y); } Vector3 val5 = default(Vector3); for (int j = 0; j < top.Length; j++) { int num = (j + 1) % top.Length; Vector3 val = top[j]; Vector3 val2 = top[num]; Vector3 a = RingPoint(j, 0); Vector3 d = RingPoint(num, 0); for (int k = 1; k <= 4; k++) { Vector3 val3 = RingPoint(j, k); Vector3 val4 = RingPoint(num, k); Face(a, val3, val4, d); a = val3; d = val4; } int count = vertices.Count; ((Vector3)(ref val5))..ctor(0f, 131.8f, 0f); vertices.AddRange((IEnumerable<Vector3>)(object)new Vector3[3] { val5, val2, val }); uvs.AddRange((IEnumerable<Vector2>)(object)new Vector2[3] { Vector2.zero, new Vector2(val2.x, val2.z) / 9.6f, new Vector2(val.x, val.z) / 9.6f }); list.AddRange(new int[3] { count, count + 1, count + 2 }); } Mesh val6 = new Mesh { name = "Giants Plateau rock formation" }; val6.SetVertices(vertices); val6.SetUVs(0, uvs); val6.subMeshCount = 2; val6.SetTriangles(triangles, 0); val6.SetTriangles(list, 1); val6.RecalculateNormals(); val6.RecalculateBounds(); GameObject val7 = new GameObject("Sheer cliff"); val7.transform.SetParent(parent, false); val7.AddComponent<MeshFilter>().sharedMesh = val6; ((Renderer)val7.AddComponent<MeshRenderer>()).sharedMaterials = (Material[])(object)new Material[2] { material, soil }; val7.AddComponent<MeshCollider>().sharedMesh = val6; BoxCollider obj = val7.AddComponent<BoxCollider>(); obj.center = Vector3.up * 130.76001f; obj.size = new Vector3(54f, 2f, 54f); void Face(Vector3 val8, Vector3 b, Vector3 c, Vector3 val9) { //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_002a: 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_0032: 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_003b: 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_0061: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a8: 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_00bc: 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) int count2 = vertices.Count; float num2 = Vector3.Distance(val8, val9) / 14f; vertices.AddRange((IEnumerable<Vector3>)(object)new Vector3[4] { val8, b, c, val9 }); uvs.AddRange((IEnumerable<Vector2>)(object)new Vector2[4] { new Vector2(0f, val8.y / 14f), new Vector2(0f, b.y / 14f), new Vector2(num2, c.y / 14f), new Vector2(num2, val9.y / 14f) }); triangles.AddRange(new int[6] { count2, count2 + 1, count2 + 2, count2, count2 + 2, count2 + 3 }); } Vector3 RingPoint(int index, int ring) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0081: 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_00a1: 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) Vector3 val8 = top[index]; switch (ring) { case 0: return new Vector3(val8.x * 1.14f, -99f, val8.z * 1.14f); case 4: return val8; default: { float num2 = 0.64f * Mathf.Sin((float)index * 0.92f + (float)ring * 2.32f) + 0.36f * Mathf.Cos((float)index * 2.12f - (float)ring); float num3 = 1f - 0.058f * (1f + num2); return new Vector3(val8.x * num3, 31f * (float)ring + 5.5f * num2, val8.z * num3); } } } } private static void BuildSummit(Transform parent, PrefabManager prefabs, TrollArt art, IReadOnlyDictionary<string, GameObject> sentries) { //IL_000d: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00d9: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Expected O, but got Unknown //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) Transform transform = new GameObject("Summit fort").transform; transform.SetParent(parent, false); transform.localPosition = Vector3.up * 131.8f; Vector3[] array = (Vector3[])(object)new Vector3[9] { new Vector3(-7f, 0f, 24f), new Vector3(18f, 0f, 24f), new Vector3(24f, 0f, 18f), new Vector3(24f, 0f, -25f), new Vector3(-21f, 0f, -25f), new Vector3(-26f, 0f, -19f), new Vector3(-26f, 0f, 17f), new Vector3(-19f, 0f, 24f), new Vector3(-16f, 0f, 24f) }; for (int i = 1; i < array.Length; i++) { Strongholds.AddWall(transform, art, array[i - 1], array[i], 7.2f); } GameObject val = art.MeshObject("arch", transform, new Vector3(-11.5f, 3.4f, 24f), Quaternion.Euler(0f, 180f, 0f), new Vector3(11f, 8.7f, 3.5f)); float[] array2 = new float[2] { -0.415f, 0.415f }; foreach (float num in array2) { BoxCollider obj = val.AddComponent<BoxCollider>(); obj.center = new Vector3(num, -0.075f, 0f); obj.size = new Vector3(0.15f, 0.85f, 0.82f); } BoxCollider obj2 = val.AddComponent<BoxCollider>(); obj2.center = new Vector3(0f, 0.42f, 0f); obj2.size = new Vector3(0.91f, 0.16f, 0.85f); Strongholds.Place(StrongholdBreach.SummitGate, transform, new Vector3(-11.5f, -0.1f, 24f), 180f); GameObject val2 = prefabs.CreateClonedPrefab("DLC_SilverTrollSummitCache", Strongholds.Require(prefabs, "TreasureChest_plains_stone")); Container component = val2.GetComponent<Container>(); component.m_name = "Giants' Summit Treasure"; component.m_width = 8; component.m_height = 4; component.m_autoDestroyEmpty = false; component.m_checkGuardStone = false; component.m_defaultItems = new DropTable { m_dropMin = 10, m_dropMax = 10, m_dropChance = 1f, m_oneOfEach = true, m_drops = new List<DropData> { Treasure("Coins", 475, 650), Treasure("Ruby", 12, 19), Treasure("AmberPearl", 13, 22), Treasure("Silver", 11, 17), Treasure("BlackMetalScrap", 11, 18), Treasure("Softtissue", 8, 15), Treasure("Carapace", 7, 12), Treasure("Sap", 5, 9), Treasure("Eitr", 3, 6), Treasure("YggdrasilWood", 10, 17) } }; Strongholds.ShelterFromCreatures(val2); prefabs.AddPrefab(val2); for (int k = 0; k < 4; k++) { float num2 = ((float)k - 1.5f) * 4.7f; Strongholds.Place(val2, transform, new Vector3(num2, 0.12f, -17.1f)); } StrongholdBreach.BuildTreasureHouse(prefabs, transform, -17.1f, 20f, summit: true); PlateauTerrain.PopulateWatch(parent, sentries, new Vector3(0f, 131.8f, 1f), Vector3.forward, 6, 0, summit: true); DropData Treasure(string id, int min, int max) { //IL_0002: 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) return new DropData { m_item = Strongholds.Require(prefabs, id), m_stackMin = min, m_stackMax = max, m_weight = 1f, m_dontScale = true }; } } } [HarmonyPatch(typeof(CreatureSpawner), "Spawn")] internal static class PlateauSentrySpawnFloor { private static readonly int SolidFloor = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" }); private static bool Prefix(CreatureSpawner __instance) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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) if (!((Object)__instance).name.StartsWith("DLC_SilverTroll", StringComparison.Ordinal) || !Utils.GetPrefabName(((Component)__instance).gameObject).EndsWith("PlateauSpawner", StringComparison.Ordinal)) { return true; } RaycastHit val = default(RaycastHit); if (!Physics.Raycast(((Component)__instance).transform.position + Vector3.up, Vector3.down, ref val, 4f, SolidFloor, (QueryTriggerInteraction)1)) { return false; } Location componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Location>(); if (!Object.op_Implicit((Object)(object)componentInParent) || !((Object)componentInParent).name.StartsWith("DLC_SilverTrollGiantsPlateau", StringComparison.Ordinal)) { return false; } if (((Object)__instance.m_creaturePrefab).name != "DLC_SilverTrollBoss" && PlateauTerrain.IsWarlordWatch(((Component)componentInParent).transform.InverseTransformPoint(((Component)__instance).transform.position))) { __instance.m_creaturePrefab = ZNetScene.instance.GetPrefab("DLC_SilverTrollBoss"); Strongholds.SetWarlordLevels(__instance); } return true; } } [HarmonyPatch(typeof(BaseAI), "MoveTowards")] internal static class PlateauSentryFooting { private static readonly int SolidFloor = LayerMask.GetMask(new string[4] { "Default", "static_solid", "piece", "terrain" }); private static bool Prefix(BaseAI __instance, Vector3 dir, Character ___m_character) { //IL_005a: 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_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_007c: 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_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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)___m_character) || ___m_character.m_group != "DLC_SilverTrolls" || !___m_character.IsOnGround()) { return true; } Collider lastGroundCollider = ___m_character.GetLastGroundCollider(); Location val = (Object.op_Implicit((Object)(object)lastGroundCollider) ? ((Component)lastGroundCollider).GetComponentInParent<Location>() : null); if (!Object.op_Implicit((Object)(object)val) || !((Object)val).name.StartsWith("DLC_SilverTrollGiantsPlateau", StringComparison.Ordinal)) { return true; } Vector3 val2 = Vector3.ProjectOnPlane(dir, Vector3.up); if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { return true; } RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(((Component)___m_character).transform.position + ((Vector3)(ref val2)).normalized * 2.1f + Vector3.up * 1.25f, Vector3.down, ref val3, 3.35f, SolidFloor, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val3)).normal.y >= 0.58f) { return true; } __instance.LookTowards(dir); __instance.StopMoving(); return false; } } [HarmonyPatch(typeof(Character), "RPC_Damage")] internal static class PlateauRampKnockback { private static readonly int SolidFloor = LayerMask.GetMask(new string[4] { "Default", "static_solid", "piece", "terrain" }); private static void Prefix(Character __instance, HitData hit) { //IL_0082: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_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_00a7: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_0137: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_0174: Unknown result type (might be due to invalid IL or missing references) if (!__instance.IsPlayer() || hit.m_pushForce <= 0f) { return; } Collider lastGroundCollider = __instance.GetLastGroundCollider(); if (!Object.op_Implicit((Object)(object)lastGroundCollider) || ((Object)lastGroundCollider).name != "Earthen ascent") { return; } Location componentInParent = ((Component)lastGroundCollider).GetComponentInParent<Location>(); Character attacker = hit.GetAttacker(); if (!Object.op_Implicit((Object)(object)componentInParent) || !((Object)componentInParent).name.StartsWith("DLC_SilverTrollGiantsPlateau", StringComparison.Ordinal) || !Object.op_Implicit((Object)(object)attacker) || attacker.m_group != "DLC_SilverTrolls") { return; } Vector3 position = ((Component)__instance).transform.position; Vector3 val = Vector3.ProjectOnPlane(position - ((Component)componentInParent).transform.position, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; val = Vector3.ProjectOnPlane(hit.m_dir, Vector3.up); Vector3 normalized2 = ((Vector3)(ref val)).normalized; float num = Vector3.Dot(normalized, normalized2); float num2 = Mathf.InverseLerp(0.25f, 1f, num); hit.m_pushForce *= Mathf.Lerp(1f, 0.42f, num2); Rigidbody val2 = default(Rigidbody); if (num < -0.1f || normalized2 == Vector3.zero || !((Component)__instance).TryGetComponent<Rigidbody>(ref val2)) { return; } RaycastHit val3 = default(RaycastHit); for (int i = 1; i <= 3; i++) { float num3 = (float)i * 1.4f; if (!Physics.Raycast(position + normalized2 * num3 + Vector3.up * 1.1f, Vector3.down, ref val3, 2.75f, SolidFloor, (QueryTriggerInteraction)1) || !(((RaycastHit)(ref val3)).normal.y >= 0.55f) || !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<Location>() == (Object)(object)componentInParent)) { float num4 = Mathf.Max(0.15f, Mathf.Clamp01(1f + __instance.GetEquipmentMovementModifier())); float num5 = (num3 - 0.95f) * val2.mass * 2f / num4; hit.m_pushForce = Mathf.Min(hit.m_pushForce, num5); break; } } } } internal sealed class PlateauStonework { private readonly GameObject coastRock; private readonly GameObject forestRock; internal PlateauStonework(PrefabManager prefabs) { forestRock = Strongholds.Require(prefabs, "rock4_forest"); coastRock = prefabs.GetPrefab("rock4_coast"); if (!Object.op_Implicit((Object)(object)coastRock)) { coastRock = forestRock; } } internal void LedgeOutcrop(Transform parent, Vector3 ledge, Vector3 outward, int index) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //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_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_0044: 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_0052: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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) //IL_009c: 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_00b4: 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) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00da: 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_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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross(Vector3.up, outward); float num = ((index % 2 == 0) ? 1f : (-1f)); Quaternion val2 = Quaternion.LookRotation(outward) * Quaternion.Euler(9f, (float)index * 21f, num * 13f); Rock(coastRock, "Weathered ledge", parent, ledge + outward * 5.25f + val * 3.75f * num - Vector3.up * 1.6f, val2, new Vector3(5.2f, 4.3f, 5f), collision: true); Rock(forestRock, "Eroded rock spur", parent, ledge + outward * 4.5f - val * 5f * num - Vector3.up * 5.8f, val2 * Quaternion.Euler(5f, 37f, 14f), new Vector3(6.2f, 11.5f, 8.2f)); } internal void SlopeOutcrop(Transform parent, Vector3 path, Vector3 outward, int index) { //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0053: 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_006a: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) Quaternion rotation = Quaternion.LookRotation(outward) * Quaternion.Euler(7f + (float)(index % 4) * 5f, (float)index * 43f, (float)(index % 3 - 1) * 12f); Rock((index % 3 == 0) ? forestRock : coastRock, "Cliff outcrop", parent, path + outward * (6.1f + 0.4f * (float)(index % 3)) - Vector3.up * (3.6f + 1.1f * (float)(index % 4)), rotation, new Vector3(4.3f + (float)(index % 4), 6.2f + (float)(index % 3) * 1.1f, 5.8f)); } internal void ShoreOutcrop(Transform parent, Vector3 path, Vector3 outward, int index) { //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_0032: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) float num = ((index % 2 == 0) ? 1f : (-1f)); Quaternion rotation = Quaternion.LookRotation(outward) * Quaternion.Euler((float)index * 4f, (float)index * 51f, num * 4f); Rock(coastRock, "Harbor rock shelf", parent, path + outward * (5.9f * num) - Vector3.up * 4.65f, rotation, new Vector3(12.8f, 8.4f + (float)index * 0.6f, 6.4f)); } internal static void Rock(GameObject source, string name, Transform parent, Vector3 center, Quaternion rotation, Vector3 dimensions, bool collision = false) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_011e: 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_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_0126: 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_0140: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0194: 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_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00bb: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00eb: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) Transform val = Strongholds.PlaceVisual(source, name, parent, center, rotation, 1f, collision); Vector3 val2 = Vector3.one * float.PositiveInfinity; Vector3 val3 = Vector3.one * float.NegativeInfinity; MeshFilter[] componentsInChildren = ((Component)val).GetComponentsInChildren<MeshFilter>(true); Vector3 val5 = default(Vector3); foreach (MeshFilter val4 in componentsInChildren) { Bounds bounds = val4.sharedMesh.bounds; for (int j = 0; j < 8; j++) { ((Vector3)(ref val5))..ctor(((j & 1) == 0) ? (0f - ((Bounds)(ref bounds)).extents.x) : ((Bounds)(ref bounds)).extents.x, ((j & 2) == 0) ? (0f - ((Bounds)(ref bounds)).extents.y) : ((Bounds)(ref bounds)).extents.y, ((j & 4) == 0) ? (0f - ((Bounds)(ref bounds)).extents.z) : ((Bounds)(ref bounds)).extents.z); Vector3 val6 = val.InverseTransformPoint(((Component)val4).transform.TransformPoint(((Bounds)(ref bounds)).center + val5)); val2 = Vector3.Min(val2, val6); val3 = Vector3.Max(val3, val6); } } Vector3 val7 = val3 - val2; if (!(val7.x > 0.01f) || !(val7.y > 0.01f) || !(val7.z > 0.01f) || !(((Vector3)(ref val7)).sqrMagnitude < float.PositiveInfinity)) { throw new InvalidOperationException("Vanilla rock prefab " + ((Object)source).name + " has no usable visual mesh."); } Vector3 val8 = default(Vector3); ((Vector3)(ref val8))..ctor(dimensions.x / val7.x, dimensions.y / val7.y, dimensions.z / val7.z); val.localScale = val8; val.localPosition = center - rotation * Vector3.Scale((val2 + val3) * 0.5f, val8); } } internal static class PlateauTerrain { internal const int SummitTurn = 20; private const float EntryHeight = 2.8f; internal const float Entry = -0.65f; private const int Rows = 640; private const int Columns = 8; private const int ShoreColumns = 4; private static readonly int[] GuardsPerLedge = new int[10] { 1, 1, 2, 2, 2, 2, 2, 2, 2, 2 }; private static readonly int[] WarlordLedges = new int[3] { 3, 6, 9 }; internal static Vector2[] CliffOutline() { //IL_001b: 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_002e: 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_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) Vector2[] array = (Vector2[])(object)new Vector2[96]; for (int i = 0; i < array.Length; i++) { float turn = (float)i * 8f / (float)array.Length; Vector3 val = Radial(turn) * Radius(turn); array[i] = new Vector2(val.x, val.z); } return array; } private static Vector3 Radial(float turn) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) float num = (22.5f + 45f * turn) * (MathF.PI / 180f); return new Vector3(Mathf.Sin(num), 0f, 0f - Mathf.Cos(num)); } private static float Radius(float turn) { float num = (Mathf.Repeat(turn, 1f) - 0.5f) * 45f * (MathF.PI / 180f); float num2 = 44.5f / Mathf.Cos(num); return Mathf.Lerp(46.6f, num2, 0.6f) + 0.62f * Mathf.Sin(turn * MathF.PI * 0.75f) + 0.48f * Mathf.Cos(turn * MathF.PI * 1.5f); } private static float Ledge(float turn) { float num = Mathf.Round(turn * 0.5f) * 2f; if (num >= 20f || turn < 0f) { return 0f; } return Mathf.SmoothStep(1f, 0f, Mathf.Clamp01(Mathf.Abs(turn - num) / 0.42f)); } internal static Vector3 RoutePoint(float turn) { //IL_00a6: 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_00b1: 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_00bc: Unknown result type (might be due to invalid IL or missing references) float num = Radius(turn) + 5.2f; float num3; if (turn < 0f) { float num2 = Mathf.InverseLerp(-0.65f, 0f, turn); num += Mathf.SmoothStep(21f, 0f, num2); num3 = Mathf.SmoothStep(2.35f, 2.8f, num2); } else { float num4 = 6.45f; num3 = 2.8f + num4 * (turn - 0.86f * Mathf.Sin(MathF.PI * turn) / MathF.PI); if (turn > 19.78f) { num -= Mathf.SmoothStep(0f, 12.5f, Mathf.InverseLerp(19.78f, 20f, turn)); num3 = 131.83f; } } return Radial(turn) * num + Vector3.up * num3; } internal static (Vector3[] Crest, Vector3[] Normals) Build(Transform parent, Material soil, Material rock, PlateauStonework decoration, IReadOnlyDictionary<string, GameObject> sentries) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_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_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Expected O, but got Unknown //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) Transform transform = new GameObject("Earthen ascent").transform; transform.SetParent(parent, false); int shoreRows = Mathf.CeilToInt(Mathf.InverseLerp(-0.65f, 20f, -0.09f) * 640f) + 1; int shoreStart = 5128; Vector3[] vertices = (Vector3[])(object)new Vector3[shoreStart + shoreRows * 4]; Vector2[] texture = (Vector2[])(object)new Vector2[vertices.Length]; List<int> list = new List<int>(); List<int> bank = new List<int>(); for (int i = 0; i <= 640; i++) { float num = Mathf.Lerp(-0.65f, 20f, (float)i / 640f); Vector3 location = RoutePoint(num); Vector3 outward = Radial(num); float num2 = Ledge(num); float num3 = 0.54f * Mathf.Sin(num * 16.3f) + 0.38f * Mathf.Cos(num * 9.7f); float num4 = 5.65f + num2 * 6.4f + num3; float distance = ((num < 0f) ? (-5.3f - 1.6f * (1f - Mathf.InverseLerp(-0.65f, 0f, num))) : (-5.3f)); float num5 = 10.1f + 3.7f * num2 + 2.3f * Mathf.Cos(num * 6.9f); if (num < -0.22f) { num5 += 8f * Mathf.InverseLerp(-0.22f, -0.65f, num); } float num6 = 0.09f * Mathf.Sin(num * 30f); int num7 = i * 8; Vertex(num7, -8.6f, 0.7f); Vertex(num7 + 1, distance, 0.22f + num6); Vertex(num7 + 2, -2.6f, 0.05f * Mathf.Sin(num * 21.7f)); Vertex(num7 + 3, 0.05f, 0f); Vertex(num7 + 4, num4 * 0.62f, 0.07f * Mathf.Sin(num * 17.8f) - 0.04f); Vertex(num7 + 5, num4, -0.22f + num6); Vertex(num7 + 6, num4 + 1.8f + num3, -0.45f * num5); Vertex(num7 + 7, -8.8f - 0.8f * Mathf.Sin(num * 5.6f), 0f - num5); if (i != 640) { for (int j = 0; j < 7; j++) { int num8 = num7 + j; ((j >= 1 && j <= 4) ? list : bank).AddRange(new int[6] { num8, num8 + 8, num8 + 1, num8 + 1, num8 + 8, num8 + 8 + 1 }); } } void Vertex(int index, float num9, float elevation) { //IL_0002: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0044: Unknown result type (might be due to invalid IL or missing references) Vector3 val4 = location + outward * num9 + Vector3.up * elevation; vertices[index] = val4; texture[index] = SurfaceUv(val4); } } AddShoreFooting(); Mesh val = new Mesh { name = "Sculpted cliff ascent", vertices = vertices, uv = texture, subMeshCount = 2 }; val.SetTriangles(list, 0); val.SetTriangles(bank, 1); val.RecalculateNormals(); val.RecalculateTangents(); val.RecalculateBounds(); ((Component)transform).gameObject.AddComponent<MeshFilter>().sharedMesh = val; ((Renderer)((Component)transform).gameObject.AddComponent<MeshRenderer>()).sharedMaterials = (Material[])(object)new Material[2] { soil, rock }; ((Component)transform).gameObject.AddComponent<MeshCollider>().sharedMesh = val; for (int k = 0; k < 4; k++) { float turn = -0.57f + (float)k * 0.145f; decoration.ShoreOutcrop(transform, RoutePoint(turn), Radial(turn), k); } for (int l = 0; l < GuardsPerLedge.Length; l++) { float turn2 = (float)l * 2f; Vector3 val2 = Radial(turn2); Vector3 val3 = RoutePoint(turn2) + val2 * 4.7f; Transform transform2 = new GameObject($"Troll ledge {l + 1:00}").transform; transform2.SetParent(transform, false); transform2.SetLocalPositionAndRotation(val3, Quaternion.LookRotation(val2)); decoration.LedgeOutcrop(transform, val3, val2, l); PopulateWatch(parent, sentries, val3, val2, GuardsPerLedge[l], l); } for (int m = 0; m < 12; m++) { float turn3 = 0.75f + (float)m * 1.56f + 0.16f * Mathf.Sin((float)m * 3.1f); Vector3 outward2 = Radial(turn3); decoration.SlopeOutcrop(transform, RoutePoint(turn3), outward2, m); } Vector3[] array = (Vector3[])(object)new Vector3[7]; Vector3[] array2 = (Vector3[])(object)new Vector3[7]; Array.Copy(vertices, array, array.Length); Array.Copy(val.normals, array2, array2.Length); return (Crest: array, Normals: array2); void Add(int index, Vector3 point) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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) vertices[index] = point; texture[index] = SurfaceUv(point); } void AddShoreFooting() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00ca: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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) for (int n = 0; n < shoreRows; n++) { int num9 = n * 8; int num10 = shoreStart + n * 4; Vector3 val4 = Radial(Mathf.Lerp(-0.65f, 20f, (float)n / 640f)) * 41f; Vector3 val5 = Vector3.Lerp(val4, vertices[num9], 0.56f + 0.064f * Mathf.Sin((float)n * 0.54f)); Add(num10, val4 + Vector3.up * (0.85f + 0.36f * Mathf.Sin((float)n * 0.31f))); Add(num10 + 1, new Vector3(val5.x, 1.18f + 0.48f * Mathf.Sin((float)n * 0.43f + 1.4f), val5.z)); Add(num10 + 2, new Vector3(vertices[num9 + 7].x, -43f, vertices[num9 + 7].z)); Add(num10 + 3, val4 - Vector3.up * 43f); if (n < shoreRows - 1) { Strip(num10, num10 + 1, num10 + 4, num10 + 4 + 1); Strip(num10 + 1, num9, num10 + 4 + 1, num9 + 8); Strip(num9 + 7, num10 + 2, num9 + 8 + 7, num10 + 4 + 2); Strip(num10 + 2, num10 + 3, num10 + 4 + 2, num10 + 4 + 3); Strip(num10 + 3, num10, num10 + 4 + 3, num10 + 4); } } CloseEdge(0, shoreStart, seaward: true); CloseEdge((shoreRows - 1) * 8, shoreStart + (shoreRows - 1) * 4, seaward: false); } void CloseEdge(int ramp, int first, bool seaward) { int[] array3 = new int[6] { first, first + 1, ramp, ramp + 7, first + 2, first + 3 }; for (int n = 1; n < array3.Length - 1; n++) { bank.Add(array3[0]); bank.Add(array3[seaward ? n : (n + 1)]); bank.Add(array3[seaward ? (n + 1) : n]); } } void Strip(int a, int b, int nextA, int nextB) { bank.AddRange(new int[6] { a, nextA, b, b, nextA, nextB }); } } internal static Vector2 SurfaceUv(Vector3 towerPoint) { //IL_0000: 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_0019: 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_0030: Unknown result type (might be due to invalid IL or missing references) return new Vector2(towerPoint.x + towerPoint.y * 0.37f, towerPoint.z + towerPoint.y * 0.57f) / 9.6f; } internal static void PopulateWatch(Transform parent, IReadOnlyDictionary<string, GameObject> sentries, Vector3 landing, Vector3 outward, int count, int firstRole, bool summit = false) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_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) string[] array = new string[3] { "DLC_SilverTrollBrawler", "DLC_SilverTrollBreacher", "DLC_SilverTrollHurler" }; for (int i = 0; i < count; i++) { string key = ((i == count - 1 && (summit || Array.IndexOf(WarlordLedges, firstRole) >= 0)) ? "DLC_SilverTrollBoss" : array[(i + firstRole) % array.Length]); Strongholds.Place(sentries[key], parent, landing + WatchOffset(outward, count, i)); } } internal static bool IsWarlordWatch(Vector3 localPosition) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0032: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) int[] warlordLedges = WarlordLedges; foreach (int num in warlordLedges) { float turn = (float)num * 2f; Vector3 val = Radial(turn); Vector3 val2 = RoutePoint(turn) + val * 4.7f + WatchOffset(val, GuardsPerLedge[num], GuardsPerLedge[num] - 1) - localPosition; if (((Vector3)(ref val2)).sqrMagnitude < 0.16f) { return true; } } return false; } private static Vector3 WatchOffset(Vector3 outward, int count, int slot) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0053: 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_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) float num = ((float)(slot % 3) - (float)(Mathf.Min(count, 3) - 1) * 0.5f) * 4.25f; float num2 = ((count <= 3) ? 0f : ((slot < 3) ? (-4.8f) : 4.8f)); return Vector3.Cross(Vector3.up, outward) * num + Vector3.up * 0.36f + outward * num2; } } [HarmonyPatch] internal static class PlateauWaterPlacement { private static MethodBase TargetMethod() { return AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(ZoneSystem), "GenerateLocationsTimeSliced", new Type[3] { typeof(ZoneLocation), typeof(Stopwatch), typeof(ZPackage) }, (Type[])null)); } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase original) { FieldInfo location = AccessTools.Field(original.DeclaringType, "location"); MethodInfo terrainDelta = AccessTools.Method(typeof(WorldGenerator), "GetTerrainDelta", (Type[])null, (Type[])null); MethodInfo check = AccessTools.Method(typeof(PlateauWaterPlacement), "CheckTerrain", (Type[])null, (Type[])null); foreach (CodeInstruction instruction in instructions) { if (!CodeInstructionExtensions.Calls(instruction, terrainDelta)) { yield return instruction; continue; } yield return CodeInstructionExtensions.MoveBlocksFrom(CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Ldarg_0, (object)null), instruction), instruction); yield return new CodeInstruction(OpCodes.Ldfld, (object)location); yield return new CodeInstruction(OpCodes.Call, (object)check); } } private static void CheckTerrain(WorldGenerator world, Vector3 point, float radius, out float delta, out Vector3 slope, ZoneLocation location) { //IL_0045: 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_0022: 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_003e: Unknown result type (might be due to invalid IL or missing references) if (location.m_prefabName == "DLC_SilverTrollGiantsPlateau") { delta = ((Utils.LengthXZ(point) <= 10436f && HasOpenWater(world, point)) ? 0f : float.PositiveInfinity); slope = Vector3.zero; } else { world.GetTerrainDelta(point, radius, ref delta, ref slope); } } private static bool HasOpenWater(WorldGenerator world, Vector3 center) { //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_0021: 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_0044: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Invalid comparison between Unknown and I4 //IL_011b: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Invalid comparison between Unknown and I4 //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Invalid comparison between Unknown and I4 float num = 250f; int num2 = AltBiomeWorldData.WorldSpaceToMapSpace(center.x - num); int num3 = AltBiomeWorldData.WorldSpaceToMapSpace(center.x + num); int num4 = AltBiomeWorldData.WorldSpaceToMapSpace(center.z - num); int num5 = AltBiomeWorldData.WorldSpaceToMapSpace(center.z + num); Vector2 val = default(Vector2); for (int i = num2; i <= num3; i++) { float num6 = Mathf.Clamp(center.x, AltBiomeWorldData.MapSpaceToWorldSpace((float)i), AltBiomeWorldData.MapSpaceToWorldSpace((float)(i + 1))); for (int j = num4; j <= num5; j++) { float num7 = Mathf.Clamp(center.z, AltBiomeWorldData.MapSpaceToWorldSpace((float)j), AltBiomeWorldData.MapSpaceToWorldSpace((float)(j + 1))); ((Vector2)(ref val))..ctor(num6 - center.x, num7 - center.z); if (((Vector2)(ref val)).sqrMagnitude < num * num && (int)world.GetBiomeSector(i, j, false).Biome != 256) { return false; } } } int num8 = Mathf.FloorToInt(num / 3f) * 3; for (int k = -num8; k <= num8; k += 3) { float num9 = Mathf.Sqrt(num * num - (float)(k * k)); for (int l = -Mathf.FloorToInt(num9 / 3f) * 3; (float)l <= num9; l += 3) { if ((int)world.GetBiome(center.x + (float)k, center.z + (float)l, 0.02f, false) != 256) { return false; } } } int num10 = Mathf.CeilToInt(MathF.PI * 2f * num / 3f); for (int m = 0; m < num10; m++) { float num11 = (float)m * (MathF.PI * 2f / (float)num10); if ((int)world.GetBiome(center.x + num * Mathf.Cos(num11), center.z + num * Mathf.Sin(num11), 0.02f, false) != 256) { return false; } } return true; } } [HarmonyPatch(typeof(ZoneSystem), "HaveLocationInRange")] internal static class PlateauTowerSeparation { private static bool Prefix(ZoneSystem __instance, string group, Vector3 p, float radius, ref bool __result) { //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) if (group != "DLC_SilverTrollGiantsPlateau") { return true; } __result = __instance.m_locationInstances.Values.Any((LocationInstance entry) => entry.m_location.m_prefabName == "DLC_SilverTrollGiantsPlateau" && Utils.DistanceXZ(entry.m_position, p) < radius); return false; } } [HarmonyPatch(typeof(Character), "Awake")] internal static class SilverTrollHealthUpgrade { private static readonly int WarlordRankSet = StringExtensionMethods.GetStableHashCode("DLC_SilverTrollWarlordRankSet"); private static void Postfix(Character __instance) { if (__instance.m_group != "DLC_SilverTrolls") { return; } ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if (!component.IsValid() || !component.IsOwner()) { return; } string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject); if (prefabName == "DLC_SilverTrollBoss") { ZDO zDO = component.GetZDO(); if (!zDO.GetBool(WarlordRankSet, false) && __instance.GetLevel() == 1 && __instance.GetHealth() > 0f) { float num = __instance.GetHealth() / __instance.GetMaxHealth(); __instance.SetLevel(2); if (num < 1f) { __instance.SetHealth(num * __instance.GetMaxHealth()); } } zDO.Set(WarlordRankSet, true); } float num2 = prefabName switch { "DLC_SilverTrollHurler" => 840f, "DLC_SilverTrollBrawler" => 950f, "DLC_SilverTrollBreacher" => 1080f, "DLC_SilverTrollBoss" => 1760f, _ => 0f, }; float maxHealth = __instance.GetMaxHealth(); float health = __instance.GetHealth(); float num3 = __instance.GetMaxHealthBase() / __instance.m_health * (float)__instance.GetLevel(); if (!(health <= 0f) && !(num2 <= 0f) && Mathf.Approximately(maxHealth, num2 * num3)) { float num4 = __instance.m_health * num3; __instance.SetMaxHealth(num4); __instance.SetHealth(num4 * (health / maxHealth)); } } } [BepInPlugin("com.darklightcreations.silvertrolls", "Trollheim", "0.1.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class SilverTrollsPlugin : BaseUnityPlugin { public const string PluginId = "com.darklightcreations.silvertrolls"; public const string Version = "0.1.3"; internal const string TrollFactionGroup = "DLC_SilverTrolls"; internal const string Hurler = "DLC_SilverTrollHurler"; internal const string Brawler = "DLC_SilverTrollBrawler"; internal const string Breacher = "DLC_SilverTrollBreacher"; internal const string Boss = "DLC_SilverTrollBoss"; internal const string Boulder = "DLC_SilverTrollAttackBoulder"; internal const string Slam = "DLC_SilverTrollAttackSlam"; internal const string BrawlerPunch = "DLC_SilverTrollBrawlerPunch"; internal const string BrawlerSlam = "DLC_SilverTrollBrawlerSlam"; internal const string BrawlerBoulder = "DLC_SilverTrollBrawlerBoulder"; internal const string ClubSweep = "DLC_SilverTrollClubSweep"; internal const string ClubOverhead = "DLC_SilverTrollClubOverhead"; internal const string Rage = "DLC_SilverTrollRage"; private readonly Dictionary<string, GameObject> trolls = new Dictionary<string, GameObject>(StringComparer.Ordinal); private TrollArt art; private EffectList deathEffects; private Harmony harmony; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown harmony = new Harmony("com.darklightcreations.silvertrolls"); harmony.CreateClassProcessor(typeof(HurlerAttackSelection)).Patch(); harmony.CreateClassProcessor(typeof(TrollBossAttackSelection)).Patch(); harmony.CreateClassProcessor(typeof(TrollBossRageStart)).Patch(); harmony.CreateClassProcessor(typeof(CampPlacement)).Patch(); harmony.CreateClassProcessor(typeof(CampFurnitureDamage)).Patch(); harmony.CreateClassProcessor(typeof(TrollTreasureDiscovery)).Patch(); harmony.CreateClassProcessor(typeof(PlateauWaterPlacement)).Patch(); harmony.CreateClassProcessor(typeof(PlateauTowerSeparation)).Patch(); harmony.CreateClassProcessor(typeof(PlateauSentrySpawnFloor)).Patch(); harmony.CreateClassProcessor(typeof(PlateauSentryFooting)).Patch(); harmony.CreateClassProcessor(typeof(PlateauRampKnockback)).Patch(); harmony.CreateClassProcessor(typeof(SilverTrollHealthUpgrade)).Patch(); harmony.CreateClassProcessor(typeof(TrollTowerIcon)).Patch(); harmony.CreateClassProcessor(typeof(TrollTowerMapLabels)).Patch(); harmony.CreateClassProcessor(typeof(StrongholdNewLocation)).Patch(); harmony.CreateClassProcessor(typeof(StrongholdSavedLocation)).Patch(); PrefabManager.OnVanillaPrefabsAvailable += Register; } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= Register; Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } private void Register() { PrefabManager instance = PrefabManager.Instance; GameObject prefab = instance.GetPrefab("Troll"); if (!Object.op_Implicit((Object)(object)prefab)) { return; } Humanoid component = prefab.GetComponent<Humanoid>(); Dictionary<string, GameObject> dictionary = component.m_randomSets.SelectMany((ItemSet set) => set.m_items).Distinct().ToDictionary<GameObject, string>((GameObject item) => ((Object)item).name, StringComparer.Ordinal); art = new TrollArt(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "art")); try { deathEffects = CreateDeathEffects(instance, ((Character)component).m_deathEffects); GameObject val = CloneAttack(instance, dictionary["troll_throw"], "DLC_SilverTrollAttackBoulder", 120f, 5.25f, 25f); GameObject val2 = CloneAttack(instance, dictionary["troll_groundslam"], "DLC_SilverTrollAttackSlam", 135f, 5f, 5.65f); AddTroll(instance, prefab, "DLC_SilverTrollHurler", "Silver Boulder Hurler", 1750f, val, val2); GameObject val3 = CloneAttack(instance, dictionary["troll_punch"], "DLC_SilverTrollBrawlerPunch", 125f); GameObject val4 = CloneAttack(instance, dictionary["troll_groundslam"], "DLC_SilverTrollBrawlerSlam", 135f); GameObject val5 = CloneAttack(instance, dictionary["troll_throw"], "DLC_SilverTrollBrawlerBoulder", 120f); AddTroll(instance, prefab, "DLC_SilverTrollBrawler", "Silver Troll Brawler", 1800f, val3, val4, val5); TrollClubArt trollClubArt = new TrollClubArt(Strongholds.Require(instance, "Club").transform.Find("attach/model")); GameObject source = dictionary["troll_log_swing_h"]; TrollClubArt club = trollClubArt; GameObject val6 = CloneAttack(instance, source, "DLC_SilverTrollClubSweep", 130f, null, null, club); GameObject source2 = dictionary["troll_log_swing_v"]; club = trollClubArt; GameObject val7 = CloneAttack(instance, source2, "DLC_SilverTrollClubOverhead", 140f, null, null, club); AddTroll(instance, prefab, "DLC_SilverTrollBreacher", "Silver Troll Breacher", 1850f, val6, val7); GameObject val8 = CloneRageAttack(instance, trollClubArt); AddTroll(instance, prefab, "DLC_SilverTrollBoss", "Silver Troll Warlord", 2500f, val, val6, val7, val2, val8); Strongholds.Register(instance, trolls, art); PrefabManager.OnVanillaPrefabsAvailable -= Register; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered three Silver Troll variants and the Silver Troll Warlord."); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Silver Trolls registration failed: {arg}"); throw; } } private EffectList CreateDeathEffects(PrefabManager prefabs, EffectList source) { //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_003e: Expected O, but got Unknown EffectData[] effectPrefabs = ((IEnumerable<EffectData>)source.m_effectPrefabs).Select((Func<EffectData, EffectData>)delegate(EffectData effect) { //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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown Ragdoll val = default(Ragdoll); if (Object.op_Implicit((Object)(object)effect.m_prefab) && effect.m_prefab.TryGetComponent<Ragdoll>(ref val)) { GameObject val2 = prefabs.CreateClonedPrefab("DLC_SilverTrollRagdoll", effect.m_prefab); art.SetCharcoalSkin(val2); prefabs.AddPrefab(val2); return new EffectData { m_prefab = val2, m_enabled = effect.m_enabled, m_variant = effect.m_variant, m_attach = effect.m_attach, m_follow = effect.m_follow, m_inheritParentRotation = effect.m_inheritParentRotation, m_inheritParentScale = effect.m_inheritParentScale, m_multiplyParentVisualScale = effect.m_multiplyParentVisualScale, m_randomRotation = effect.m_randomRotation, m_scale = effect.m_scale, m_childTransform = effect.m_childTransform }; } return effect; }).ToArray(); return new EffectList { m_effectPrefabs = effectPrefabs }; } private static GameObject CloneAttack(PrefabManager prefabs, GameObject source, string id, float blunt, float? interval = null, float? range = null, TrollClubArt club = null) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown GameObject val = prefabs.CreateClonedPrefab(id, source); ItemDrop component = val.GetComponent<ItemDrop>(); component.m_itemData.m_dropPrefab = val; SharedData shared = component.m_itemData.m_shared; if (shared == source.GetComponent<ItemDrop>().m_itemData.m_shared) { throw new InvalidOperationException("Attack " + id + " shares its settings with the vanilla troll."); } if (interval.HasValue) { shared.m_aiAttackInterval = interval.Value; } if (range.HasValue) { shared.m_aiAttackRange = range.Value; shared.m_aiAttackRangeMin = 0f; } shared.m_damages.m_blunt = blunt; if (club != null) { Transform val2 = val.transform.Find("attach"); Object.DestroyImmediate((Object)(object)((Component)val2.Find("log")).gameObject); club.Mount(val2); } if (!ItemManager.Instance.AddItem(new CustomItem(val, false))) { throw new InvalidOperationException("Could not register creature attack " + id + "."); } return val; } private static GameObject CloneRageAttack(PrefabManager prefabs, TrollClubArt club) { //IL_0037: 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_00fe: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown GameObject val = Strongholds.Require(prefabs, "GoblinBrute_RageAttack"); GameObject val2 = prefabs.CreateClonedPrefab("DLC_SilverTrollRage", val); Transform val3 = val2.transform.Find("attach"); if (!Object.op_Implicit((Object)(object)val3)) { val3 = new GameObject("attach").transform; val3.SetParent(val2.transform, false); } club.Mount(val3); ItemData itemData = val2.GetComponent<ItemDrop>().m_itemData; itemData.m_dropPrefab = val2; if (itemData.m_shared == val.GetComponent<ItemDrop>().m_itemData.m_shared) { throw new InvalidOperationException("The Troll Tower boss shares its attack settings with the vanilla Fuling Berserker."); } itemData.m_shared.m_attack = itemData.m_shared.m_attack.Clone(); itemData.m_shared.m_attack.m_attackAnimation = "swing_logv"; itemData.m_shared.m_attack.m_attackRange = 8.2f; itemData.m_shared.m_aiAttackRange = 7.6f; itemData.m_shared.m_aiAttackInterval = 0.3f; SharedData shared = itemData.m_shared; EffectList val4 = new EffectList(); val4.m_effectPrefabs = (EffectData[])(object)new EffectData[2] { new EffectData { m_prefab = Strongholds.Require(prefabs, "fx_goblinbrute_groundslam") }, new EffectData { m_prefab = Strongholds.Require(prefabs, "sfx_goblinbrute_clubhit") } }; shared.m_triggerEffect = val4; if (!ItemManager.Instance.AddItem(new CustomItem(val2, false))) { throw new InvalidOperationException("Could not register the Troll Tower boss's berserker attack."); } return val2; } private void AddTroll(PrefabManager prefabs, GameObject source, string id, string displayName, float health, params GameObject[] attacks) { //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) GameObject val = prefabs.CreateClonedPrefab(id, source); Humanoid component = val.GetComponent<Humanoid>(); ((Character)component).m_name = displayName; ((Character)component).m_group = "DLC_SilverTrolls"; ((Character)component).m_health = health; ((Character)component).m_deathEffects = deathEffects; component.m_defaultItems = attacks; component.m_randomSets = Array.Empty<ItemSet>(); MonsterAI component2 = val.GetComponent<MonsterAI>(); component2.m_maxChaseDistance = 55f; ((BaseAI)component2).m_randomMoveRange = 6f; ((BaseAI)component2).m_mistVision = true; if (id == "DLC_SilverTrollHurler") { ((BaseAI)component2).m_viewRange = 34f; component2.m_alertRange = 28f; val.AddComponent<HurlerMarker>(); } if (id == "DLC_SilverTrollBoss") { ((Character)component).m_boss = false; ((BaseAI)component2).m_viewRange = 34f; component2.m_alertRange = 28f; component2.m_minAttackInterval = 0.3f; GameObject val2 = prefabs.CreateClonedPrefab("DLC_SilverTrollWarCry", Strongholds.Require(prefabs, "sfx_goblinbrute_taunt")); ZSFX[] componentsInChildren = val2.GetComponentsInChildren<ZSFX>(true); foreach (ZSFX val3 in componentsInChildren) { val3.m_minVol = Mathf.Min(1f, val3.m_minVol * 1.5f); val3.m_maxVol = Mathf.Min(1f, val3.m_maxVol * 1.5f); } AudioSource[] componentsInChildren2 = val2.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource obj in componentsInChildren2) { obj.minDistance *= 1.65f; obj.maxDistance *= 1.3f; } val.AddComponent<TrollBossAttackState>().RageCall = val2; } art.SetCharcoalSkin(val); art.Armor(val); if (id == "DLC_SilverTrollBoss") { Transform transform = val.transform; transform.localScale *= 1.15f; } prefabs.AddPrefab(val); trolls.Add(id, val); } } internal sealed class HurlerMarker : MonoBehaviour { } [HarmonyPatch(typeof(MonsterAI), "SelectBestAttack")] internal static class HurlerAttackSelection { private const float CloseRange = 5.25f; private static bool Prefix(MonsterAI __instance, Humanoid humanoid, Character ___m_targetCreature, StaticTarget ___m_targetStatic, ref ItemData __result) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown r