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 MinecraftMoon v1.0.0
MinecraftMoon.dll
Decompiled a day 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.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using DunGen.Graph; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using MinecraftMoon.Items; using MinecraftMoon.World; using Unity.AI.Navigation; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.SceneManagement; [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("MinecraftMoon")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MinecraftMoon")] [assembly: AssemblyTitle("MinecraftMoon")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MinecraftMoon { internal class AutoTestDriver : MonoBehaviour { internal static bool Active; private string shotDir; private bool immortal; private int damageTaken; private readonly List<string> errors = new List<string>(); private static readonly FieldInfo CameraUp = typeof(PlayerControllerB).GetField("cameraUp", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); internal static string ShotDir => Path.Combine(Paths.ConfigPath, "MinecraftMoon", "autotest"); internal static void Log(string s) { Plugin.Log.LogInfo((object)("[AutoTest] " + s)); } private void OnEnable() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Application.logMessageReceived += new LogCallback(OnLog); } private void OnDisable() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Application.logMessageReceived -= new LogCallback(OnLog); } private void OnLog(string message, string stack, LogType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: Unknown result type (might be due to invalid IL or missing references) if ((int)type == 4 || (int)type == 0) { errors.Add(message.Split('\n')[0] + " @ " + (stack ?? "").Split('\n')[0]); } } private IEnumerator Start() { Active = true; shotDir = ShotDir; Directory.CreateDirectory(shotDir); string[] files = Directory.GetFiles(shotDir); for (int i = 0; i < files.Length; i++) { File.Delete(files[i]); } Log("Démarrage du test automatique."); yield return WaitFor(() => (Object)(object)Object.FindObjectOfType<PreInitSceneScript>() != (Object)null || (Object)(object)MainMenu() != (Object)null, 90f); PreInitSceneScript pre = Object.FindObjectOfType<PreInitSceneScript>(); if ((Object)(object)pre != (Object)null) { yield return (object)new WaitForSeconds(2f); pre.ChooseLaunchOption(false); } MenuManager menu = null; yield return WaitFor(() => (Object)(object)(menu = MainMenu()) != (Object)null, 120f); if ((Object)(object)menu == (Object)null) { Fail("menu principal introuvable"); yield break; } yield return (object)new WaitForSeconds(3f); GameNetworkManager.Instance.currentSaveFileName = "LCMinecraftAutoTest"; menu.ClickHostButton(); yield return (object)new WaitForSeconds(1f); menu.lobbyNameInputField.text = "MinecraftAutoTest"; menu.ConfirmHostButton(); yield return WaitFor(() => (Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.localPlayerController != (Object)null && StartOfRound.Instance.inShipPhase && StartOfRound.Instance.fullyLoadedPlayers.Count > 0, 120f); if ((Object)(object)StartOfRound.Instance == (Object)null) { Fail("vaisseau non chargé"); yield break; } yield return (object)new WaitForSeconds(4f); StartOfRound sor = StartOfRound.Instance; int num = Plugin.AutoTestLevel.Value; if (num < 0) { num = MoonRegistry.LevelIndex; } if (num >= 0 && num < sor.levels.Length && sor.currentLevelID != num) { sor.ChangeLevel(num); sor.ArriveAtLevel(); yield return (object)new WaitForSeconds(2f); } Log($"Lune : {sor.currentLevel.PlanetName} ({sor.currentLevel.sceneName}), météo {sor.currentLevel.currentWeather}."); if (Plugin.AutoTestClearWeather.Value) { sor.currentLevel.currentWeather = (LevelWeatherType)(-1); } StartMatchLever obj = Object.FindObjectOfType<StartMatchLever>(); obj.singlePlayerEnabled = true; obj.leverHasBeenPulled = true; obj.StartGame(); yield return WaitFor(() => sor.shipHasLanded && RoundManager.Instance.dungeonCompletedGenerating, 240f); if (!sor.shipHasLanded) { Fail("le vaisseau n'a pas atterri"); yield break; } Log("Atterri."); yield return (object)new WaitForSeconds(3f); Scene sceneByName = SceneManager.GetSceneByName(sor.currentLevel.sceneName); if (Plugin.DumpScene.Value) { Recon.DumpScene(sceneByName, Path.Combine(shotDir, "scene_" + sor.currentLevel.sceneName + ".txt")); } PlayerControllerB me = sor.localPlayerController; RoundManager instance = RoundManager.Instance; instance.GetOutsideAINodes(false); Log($"Nœuds IA extérieurs : {instance.outsideAINodes?.Length}, intérieurs : {instance.insideAINodes?.Length}."); EntranceTeleport[] entrances = Object.FindObjectsOfType<EntranceTeleport>(); EntranceTeleport[] array = entrances; foreach (EntranceTeleport val in array) { object[] obj2 = new object[4] { val.entranceId, val.isEntranceToBuilding, ((Component)val).transform.position, null }; Transform entrancePoint = val.entrancePoint; obj2[3] = ((entrancePoint != null) ? new Vector3?(entrancePoint.position) : ((Vector3?)null)); Log(string.Format("Entrée id={0} versBâtiment={1} pos={2} point={3}", obj2)); } if (MoonBuilder.Built && MoonBuilder.World != null) { Dictionary<string, Vector3> W = MoonBuilder.World.Points; Vector3 shipLook = sor.shipLandingPosition.position + Vector3.up * 2f; TimeOfDay tod = TimeOfDay.Instance; if (!Plugin.AutoTestQuick.Value) { float[] array2 = new float[3] { 0f, 1.5f, 3f }; foreach (float num3 in array2) { SkyController.ExposureOverride = num3; yield return Shot(me, $"00_ciel_ev{num3:0.0}", G(-14f, -6f), G(-60f, 30f, 6f)); } SkyController.ExposureOverride = null; yield return Shot(me, "01_vaisseau", G(-34f, 6f), shipLook); yield return Shot(me, "02_vers_montagne", G(-16f, -4f), G(-80f, 50f, 10f)); yield return Shot(me, "03_vers_lac", G(20f, 4f), G(74f, 40f, 0f)); yield return Shot(me, "04_mine", W["mine_mouth"], W["mine_mouth_look"]); yield return Shot(me, "05_portail", W["portal_view"], W["portal_look"]); yield return Shot(me, "06_village", W["village_view"], W["village_look"]); yield return Shot(me, "07_village_centre", W["village"], W["village_look"]); yield return Shot(me, "08_pyramide", W["pyramid_view"], W["pyramid_look"]); yield return Shot(me, "09_pyramide_salle", W["pyramid_inside"], W["pyramid_inside_look"]); yield return Shot(me, "10_grotte", W["cave"], W["cave_look"]); yield return Shot(me, "11_grotte_entree", W["cave_mouth"] + Vector3.back * 3f, W["cave_look"]); yield return Shot(me, "12_foret", G(40f, 90f), G(40f, 120f, 4f)); yield return Shot(me, "13_sommet", G(-98f, 60f, 0.5f), shipLook); tod.globalTime = tod.totalTime * 0.7f; yield return (object)new WaitForSeconds(2f); yield return Shot(me, "14_coucher", G(-14f, -6f), G(-60f, 30f, 6f)); tod.globalTime = tod.totalTime * 0.93f; yield return (object)new WaitForSeconds(2f); yield return Shot(me, "15_nuit_village", W["village_view"], W["village_look"]); yield return Shot(me, "16_nuit_mine", W["mine_mouth"], W["mine_mouth_look"]); tod.globalTime = tod.totalTime * 0.2f; yield return (object)new WaitForSeconds(1f); } G(-20f, -2f); List<NetworkObjectReference> list = new List<NetworkObjectReference>(); List<int> list2 = new List<int>(); for (int num4 = 0; num4 < McItems.All.Count; num4++) { McItems.Def def = McItems.All[num4]; Vector3 val2 = G(-22f, -8f + (float)num4 * 0.9f, def.Item.verticalOffset); GameObject val3 = Object.Instantiate<GameObject>(def.Item.spawnPrefab, val2, Quaternion.Euler(def.Item.restingRotation)); val3.GetComponent<GrabbableObject>().fallTime = 0f; val3.GetComponent<NetworkObject>().Spawn(false); val3.GetComponent<GrabbableObject>().SetScrapValue(def.Max); list.Add(NetworkObjectReference.op_Implicit(val3.GetComponent<NetworkObject>())); list2.Add(def.Max); } RoundManager.Instance.SyncScrapValuesClientRpc(list.ToArray(), list2.ToArray()); MusicDisc disc = null; NetworkObject val4 = default(NetworkObject); foreach (NetworkObjectReference item4 in list) { NetworkObjectReference current = item4; if (((NetworkObjectReference)(ref current)).TryGet(ref val4, (NetworkManager)null) && (Object)(object)((Component)val4).GetComponent<MusicDisc>() != (Object)null) { disc = ((Component)val4).GetComponent<MusicDisc>(); } } if ((Object)(object)disc != (Object)null) { ((GrabbableObject)disc).ItemActivate(true, true); yield return (object)new WaitForSeconds(0.5f); object arg = ((Component)disc).GetComponent<AudioSource>().isPlaying; AudioClip clip = ((Component)disc).GetComponent<AudioSource>().clip; Log($"Disque de musique : lecture={arg} ({((clip != null) ? new float?(clip.length) : ((float?)null)):0} s)"); } yield return Shot(me, "17_objets", G(-19.5f, -2.5f), G(-22f, -2.5f, 0f)); VoxelWorld world = MoonBuilder.World; bool found = false; NavMeshHit val6 = default(NavMeshHit); NavMeshHit val7 = default(NavMeshHit); for (int num5 = VoxelWorld.BX(-40f); num5 < VoxelWorld.BX(-10f); num5++) { if (found) { break; } for (int num6 = VoxelWorld.BZ(0f); num6 < VoxelWorld.BZ(30f); num6++) { if (found) { break; } int num7 = world.TopSolid(num5, num6); int num8 = world.TopSolid(num5 + 1, num6); if (num8 == num7 + 1 && world.Get(num5, num7 + 1, num6) == B.Air && world.Get(num5 + 1, num8 + 1, num6) == B.Air && world.Get(num5 - 1, num7, num6) != B.Air) { found = true; me.TeleportPlayer(VoxelWorld.StandOn(num5 - 1, num7, num6) + Vector3.up * 0.05f, false, 0f, false, true); (Vector3, Vector3, string)[] array3 = new(Vector3, Vector3, string)[2] { (VoxelWorld.StandOn(num5 - 1, num7, num6), VoxelWorld.StandOn(num5 + 2, num8, num6), "marche"), (VoxelWorld.StandOn(num5 - 1, num7, num6), VoxelWorld.StandOn(num5 - 1, num7, num6) + Vector3.forward * 0f + Vector3.left * 4f, "plat") }; for (int i = 0; i < array3.Length; i++) { (Vector3, Vector3, string) tuple = array3[i]; Vector3 item = tuple.Item1; Vector3 item2 = tuple.Item2; string item3 = tuple.Item3; NavMeshPath val5 = new NavMeshPath(); NavMesh.SamplePosition(item, ref val6, 2f, -1); NavMesh.SamplePosition(item2, ref val7, 2f, -1); NavMesh.CalculatePath(((NavMeshHit)(ref val6)).position, ((NavMeshHit)(ref val7)).position, -1, val5); Log($"Chemin {item3} : {item} -> {item2} : {((NavMeshHit)(ref val6)).position}/{((NavMeshHit)(ref val7)).position} {val5.status} {val5.corners.Length} coins"); } } } } yield return (object)new WaitForSeconds(0.5f); float y0 = ((Component)me).transform.position.y; me.thisPlayerBody.rotation = Quaternion.LookRotation(Vector3.right); float x0 = ((Component)me).transform.position.x; AutoStep.TestDirection = Vector3.right; for (int num2 = 0; num2 < 60; num2++) { me.thisController.Move(Vector3.right * 4f * Time.deltaTime + Vector3.down * 0.02f); yield return null; } AutoStep.TestDirection = null; Log($" x {x0:0.00} -> {((Component)me).transform.position.x:0.00}"); Log($"Marche d'un bloc : trouvée={found}, hauteur {y0:0.00} -> {((Component)me).transform.position.y:0.00} (stepOffset {me.thisController.stepOffset:0.00})"); Vector3 val8 = G(-30f, 12f, 0.1f); NetworkObjectReference nref = RoundManager.Instance.SpawnEnemyGameObject(val8, 0f, -1, Plugin.CreeperType); yield return (object)new WaitForSeconds(0.5f); NetworkObject val9 = default(NetworkObject); CreeperAI creeper = (((NetworkObjectReference)(ref nref)).TryGet(ref val9, (NetworkManager)null) ? ((Component)val9).GetComponent<CreeperAI>() : null); Log(string.Format("Creeper de test : objet={0} ai={1} actifs={2}", ((Object)(object)val9 != (Object)null) ? ((Object)val9).name : "null", (Object)(object)creeper != (Object)null, RoundManager.Instance.SpawnedEnemies.Count((EnemyAI e) => e is CreeperAI))); if ((Object)(object)creeper == (Object)null) { Log("ÉCHEC : creeper non apparu"); } else { immortal = true; me.TeleportPlayer(G(-30f, 4f, 0.1f), false, 0f, false, true); yield return (object)new WaitForSeconds(0.2f); for (int num2 = 0; num2 < 4; num2++) { Look(me, ((Component)creeper).transform.position + Vector3.up * 1f); yield return (object)new WaitForSeconds(0.25f); } yield return Capture("18_creeper"); string seen = ""; x0 = Time.time; while (Time.time - x0 < 20f && (Object)(object)creeper != (Object)null && ((EnemyAI)creeper).currentBehaviourStateIndex != 1) { yield return (object)new WaitForSeconds(0.2f); if ((Object)(object)creeper != (Object)null) { Look(me, ((Component)creeper).transform.position + Vector3.up); } } if ((Object)(object)creeper != (Object)null) { seen += CreeperAI.StateNames[((EnemyAI)creeper).currentBehaviourStateIndex]; } yield return (object)new WaitForSeconds(0.6f); yield return Capture("19_creeper_mèche"); Vector3 position = ((Component)me).transform.position; Vector3 val10 = ((Component)me).transform.position - ((Component)creeper).transform.position; me.TeleportPlayer(position + ((Vector3)(ref val10)).normalized * 10f, false, 0f, false, true); yield return (object)new WaitForSeconds(1.5f); if ((Object)(object)creeper != (Object)null) { seen = seen + " -> " + CreeperAI.StateNames[((EnemyAI)creeper).currentBehaviourStateIndex]; } x0 = Time.time; _ = me.health; found = false; while (Time.time - x0 < 25f && (Object)(object)creeper != (Object)null && !((EnemyAI)creeper).isEnemyDead) { if (!found && ((EnemyAI)creeper).currentBehaviourStateIndex == 1) { found = true; Vector3 position2 = ((Component)creeper).transform.position; val10 = ((Component)me).transform.position - ((Component)creeper).transform.position; me.TeleportPlayer(position2 + ((Vector3)(ref val10)).normalized * 4.5f, false, 0f, false, true); } yield return (object)new WaitForSeconds(0.1f); } seen += (((Object)(object)creeper == (Object)null || ((EnemyAI)creeper).isEnemyDead) ? " -> Boom" : " -> (pas d'explosion)"); Log($"Creeper : {seen}, dégâts subis : {damageTaken}"); immortal = false; } nref = default(NetworkObjectReference); } else { Log("ÉCHEC : le monde Minecraft n'a pas été construit !"); } EntranceTeleport main = ((IEnumerable<EntranceTeleport>)entrances).FirstOrDefault((Func<EntranceTeleport, bool>)((EntranceTeleport e) => e.entranceId == 0 && e.isEntranceToBuilding)); if ((Object)(object)main != (Object)null) { me.TeleportPlayer(main.entrancePoint.position, false, 0f, false, true); yield return (object)new WaitForSeconds(1f); Look(me, ((Component)main).transform.position); yield return Capture("20_devant_entree"); main.TeleportPlayer(); yield return (object)new WaitForSeconds(2f); Log($"Dans l'installation : {me.isInsideFactory} pos={((Component)me).transform.position}"); yield return Capture("21_interieur"); EntranceTeleport val11 = ((IEnumerable<EntranceTeleport>)entrances).FirstOrDefault((Func<EntranceTeleport, bool>)((EntranceTeleport e) => e.entranceId == 0 && !e.isEntranceToBuilding)); if ((Object)(object)val11 != (Object)null) { val11.TeleportPlayer(); yield return (object)new WaitForSeconds(2f); Log($"Ressorti : dehors={!me.isInsideFactory} pos={((Component)me).transform.position}"); yield return Capture("22_ressorti"); } EntranceTeleport val12 = ((IEnumerable<EntranceTeleport>)entrances).FirstOrDefault((Func<EntranceTeleport, bool>)((EntranceTeleport e) => e.entranceId == 1 && e.isEntranceToBuilding)); if ((Object)(object)val12 != (Object)null) { val12.TeleportPlayer(); yield return (object)new WaitForSeconds(2f); Log($"Par le portail : dedans={me.isInsideFactory} pos={((Component)me).transform.position}"); yield return Capture("23_portail_interieur"); } } else { Log("Pas d'entrée principale !"); } Summary(); yield return (object)new WaitForSeconds(2f); Application.Quit(); static Vector3 G(float num9, float z, float up = 0.2f) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return new Vector3(num9, MoonBuilder.GroundY(num9, z) + up, z); } } private void LateUpdate() { PlayerControllerB val = StartOfRound.Instance?.localPlayerController; if (immortal && !((Object)(object)val == (Object)null) && val.health < 100) { damageTaken += 100 - val.health; val.health = 100; } } private IEnumerator Shot(PlayerControllerB me, string name, Vector3 pos, Vector3? lookAt) { //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) me.TeleportPlayer(pos, false, 0f, false, true); yield return (object)new WaitForSeconds(0.3f); if (lookAt.HasValue) { Look(me, lookAt.Value); } yield return (object)new WaitForSeconds(1.2f); if (lookAt.HasValue) { Look(me, lookAt.Value); } yield return Capture(name); } private static void Look(PlayerControllerB me, Vector3 target) { //IL_0000: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) Vector3 val = target - ((Component)me.gameplayCamera).transform.position; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(val.x, 0f, val.z); if (!(((Vector3)(ref val2)).sqrMagnitude < 0.01f)) { me.thisPlayerBody.rotation = Quaternion.LookRotation(val2); float num = (0f - Mathf.Atan2(val.y, ((Vector3)(ref val2)).magnitude)) * 57.29578f; CameraUp?.SetValue(me, num); ((Component)me.gameplayCamera).transform.localEulerAngles = new Vector3(num, 0f, 0f); } } private IEnumerator Capture(string name) { yield return (object)new WaitForEndOfFrame(); ScreenCapture.CaptureScreenshot(Path.Combine(shotDir, name + ".png")); Log("Capture : " + name + ".png"); yield return (object)new WaitForSeconds(0.4f); } private static MenuManager MainMenu() { return ((IEnumerable<MenuManager>)Object.FindObjectsOfType<MenuManager>()).FirstOrDefault((Func<MenuManager, bool>)((MenuManager m) => !m.isInitScene && (Object)(object)m.lobbyNameInputField != (Object)null)); } private static IEnumerator WaitFor(Func<bool> cond, float timeout) { float t = 0f; while (t < timeout) { bool flag = false; try { flag = cond(); } catch { } if (flag) { break; } t += 0.5f; yield return (object)new WaitForSeconds(0.5f); } } private void Fail(string why) { Log("ÉCHEC : " + why); Summary(); Application.Quit(); } private void Summary() { Log("===== RÉSUMÉ ====="); Log((errors.Count == 0) ? "Aucune erreur." : string.Format("{0} erreur(s) : {1}", errors.Count, string.Join(" | ", errors.Distinct().Take(15)))); } } internal class CreeperAI : EnemyAI { public const int Roam = 0; public const int Fuse = 1; public const int Boom = 2; public static readonly string[] StateNames = new string[3] { "Roam", "Fuse", "Boom" }; private Transform model; private Transform head; private Transform legFL; private Transform legFR; private Transform legBL; private Transform legBR; private Renderer[] renderers; private MaterialPropertyBlock mpb; private AISearchRoutine roam; private float stateTimer; private float walkPhase; private float dbgTimer; private int lastState = -1; private bool exploded; private Vector3 lastPos; private static Mesh headMesh; private static Mesh bodyMesh; private static Mesh legMesh; private static Material creeperMat; private static Mesh faceMesh; private static Material CreeperMat => creeperMat ?? (creeperMat = MatLib.Lit("MC_Creeper", (Texture)(object)Textures.Atlas, alphaClip: false, doubleSided: false, transparent: false, 0.01f)); private static Mesh FaceMesh { get { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0058: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)faceMesh != (Object)null) { return faceMesh; } MeshBuffer meshBuffer = new MeshBuffer(); meshBuffer.Quad(uv: Textures.Uv(T.CreeperFace), a: new Vector3(0.25f, -0.25f, 0f), b: new Vector3(0.25f, 0.25f, 0f), c: new Vector3(-0.25f, 0.25f, 0f), d: new Vector3(-0.25f, -0.25f, 0f), n: Vector3.forward); faceMesh = Keep(meshBuffer.ToMesh("CreeperFace", render: true)); return faceMesh; } } public override void Start() { //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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //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_004e: Unknown result type (might be due to invalid IL or missing references) try { BuildModel(); } catch (Exception ex) { Plugin.Log.LogError((object)("Creeper : modèle impossible : " + ex)); } ((EnemyAI)this).Start(); if (Plugin.DebugLogs.Value) { Plugin.Log.LogInfo((object)$"Creeper prêt en {((Component)this).transform.position}, dehors={base.isOutside}, nœuds={base.allAINodes?.Length}"); } roam = new AISearchRoutine { searchWidth = 80f, loopSearch = true }; lastPos = ((Component)this).transform.position; } private void BuildModel() { //IL_0016: 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_0054: 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_00b5: 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_0116: 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_012f: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_019a: 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_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Expected O, but got Unknown //IL_0085: 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) if (headMesh == null) { headMesh = Keep(Decorations.Box(new Vector3(0.5f, 0.5f, 0.5f), T.CreeperSkin, T.CreeperSkin, T.CreeperSkin, Vector3.zero)); } if (bodyMesh == null) { bodyMesh = Keep(Decorations.Box(new Vector3(0.5f, 0.75f, 0.25f), T.CreeperSkin, Vector3.zero)); } if (legMesh == null) { legMesh = Keep(Decorations.Box(new Vector3(0.25f, 0.375f, 0.25f), T.CreeperSkin, new Vector3(0f, -0.1875f, 0f))); } model = new GameObject("CreeperModel").transform; model.SetParent(((Component)this).transform, false); Part("Body", bodyMesh, new Vector3(0f, 0.75f, 0f)); head = Part("Head", headMesh, new Vector3(0f, 1.375f, 0f)); GameObject val = new GameObject("Face"); val.transform.SetParent(head, false); val.transform.localPosition = new Vector3(0f, 0f, 0.252f); val.AddComponent<MeshFilter>().sharedMesh = FaceMesh; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = CreeperMat; legFL = Part("LegFL", legMesh, new Vector3(-0.125f, 0.375f, 0.25f)); legFR = Part("LegFR", legMesh, new Vector3(0.125f, 0.375f, 0.25f)); legBL = Part("LegBL", legMesh, new Vector3(-0.125f, 0.375f, -0.25f)); legBR = Part("LegBR", legMesh, new Vector3(0.125f, 0.375f, -0.25f)); renderers = ((Component)model).GetComponentsInChildren<Renderer>(); mpb = new MaterialPropertyBlock(); Transform Part(string n, Mesh m, Vector3 pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) GameObject val2 = new GameObject(n); val2.transform.SetParent(model, false); val2.transform.localPosition = pos; val2.AddComponent<MeshFilter>().sharedMesh = m; ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = CreeperMat; return val2.transform; } } private static Mesh Keep(Mesh m) { MatLib.Keep((Object)(object)m); return m; } public override void DoAIInterval() { //IL_0167: 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_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0091: 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_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0360: 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_01db: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_0296: 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_0109: 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) ((EnemyAI)this).DoAIInterval(); if (base.isEnemyDead || exploded) { return; } StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayersDead) { return; } if (Plugin.DebugLogs.Value && (dbgTimer -= base.AIIntervalTime) < 0f) { dbgTimer = 2f; string text = ""; if ((Object)(object)base.targetPlayer != (Object)null) { NavMeshPath val = new NavMeshPath(); NavMeshHit val2 = default(NavMeshHit); bool flag = NavMesh.SamplePosition(((Component)base.targetPlayer).transform.position, ref val2, 3f, -1); NavMesh.CalculatePath(((Component)this).transform.position, flag ? ((NavMeshHit)(ref val2)).position : ((Component)base.targetPlayer).transform.position, -1, val); text = $" joueurSurNavmesh={flag}({(flag ? Vector3.Distance(((NavMeshHit)(ref val2)).position, ((Component)base.targetPlayer).transform.position) : (-1f)):0.0}) calcul={val.status}/{val.corners.Length}"; } ManualLogSource log = Plugin.Log; object[] obj = new object[8] { text, base.currentBehaviourStateIndex, ((Component)this).transform.position, base.agent.isOnNavMesh, base.agent.pathStatus, base.agent.destination, ((Object)(object)base.targetPlayer != (Object)null) ? base.targetPlayer.playerUsername : "-", null }; Vector3 velocity = base.agent.velocity; obj[7] = ((Vector3)(ref velocity)).magnitude; log.LogInfo((object)string.Format("Creeper{0} {1} pos={2} navmesh={3} chemin={4} dest={5} cible={6} vitesse={7:0.0}", obj)); } switch (base.currentBehaviourStateIndex) { case 0: { base.agent.speed = Plugin.CreeperSpeed.Value; PlayerControllerB val3 = base.targetPlayer; if ((Object)(object)val3 == (Object)null || !((EnemyAI)this).PlayerIsTargetable(val3, false, false, true) || Vector3.Distance(((Component)val3).transform.position, ((Component)this).transform.position) > 40f) { val3 = (base.targetPlayer = ClosestVisiblePlayer(28f)); } if ((Object)(object)val3 == (Object)null) { if (!roam.inProgress) { ((EnemyAI)this).StartSearch(((Component)this).transform.position, roam); } break; } if (roam.inProgress) { ((EnemyAI)this).StopSearch(roam, true); } ((EnemyAI)this).SetDestinationToPosition(((Component)val3).transform.position, false); if (Vector3.Distance(((Component)val3).transform.position, ((Component)this).transform.position) < 2.6f && HasLineOfSight(val3)) { stateTimer = 0f; ((EnemyAI)this).SwitchToBehaviourState(1); } break; } case 1: base.agent.speed = 0f; if ((Object)(object)base.targetPlayer == (Object)null || !((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true) || Vector3.Distance(((Component)base.targetPlayer).transform.position, ((Component)this).transform.position) > 6.5f) { ((EnemyAI)this).SwitchToBehaviourState(0); } else if (stateTimer >= 1.5f) { ((EnemyAI)this).SwitchToBehaviourState(2); } break; } } private PlayerControllerB ClosestVisiblePlayer(float range) { //IL_002c: 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) PlayerControllerB result = null; float num = range; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (((EnemyAI)this).PlayerIsTargetable(val, false, false, true)) { float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position); if (num2 < num && (num2 < 8f || HasLineOfSight(val))) { result = val; num = num2; } } } return result; } private bool HasLineOfSight(PlayerControllerB p) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) return !Physics.Linecast(((Component)this).transform.position + Vector3.up * 1.4f, ((Component)p.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1); } public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { ((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID); if (base.isEnemyDead || exploded) { return; } stateTimer = Mathf.Max(0f, stateTimer - 0.4f); if (((NetworkBehaviour)this).IsOwner) { base.enemyHP -= force; if (base.enemyHP <= 0) { ((EnemyAI)this).KillEnemyOnOwnerClient(false); } else if ((Object)(object)playerWhoHit != (Object)null && base.currentBehaviourStateIndex == 0) { base.targetPlayer = playerWhoHit; } } } public override void KillEnemy(bool destroy = false) { ((EnemyAI)this).KillEnemy(destroy); if (!exploded) { Poof(); } if ((Object)(object)model != (Object)null) { ((Component)model).gameObject.SetActive(false); } } public override void Update() { //IL_00f9: 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_0104: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0136: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0199: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_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_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0257: 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_0203: 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) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_030d: 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) ((EnemyAI)this).Update(); if ((Object)(object)model == (Object)null) { return; } float deltaTime = Time.deltaTime; stateTimer += deltaTime; int currentBehaviourStateIndex = base.currentBehaviourStateIndex; if (currentBehaviourStateIndex != lastState) { if (currentBehaviourStateIndex == 1) { stateTimer = 0f; base.creatureVoice.PlayOneShot(Music.Hiss, 1f); WalkieTalkie.TransmitOneShotAudio(base.creatureVoice, Music.Hiss, 0.8f); PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController != (Object)null && Vector3.Distance(((Component)localPlayerController).transform.position, ((Component)this).transform.position) < 10f) { localPlayerController.JumpToFearLevel(0.9f, true); } } else if (lastState == 1) { base.creatureVoice.Stop(); } if (currentBehaviourStateIndex == 2) { Explode(); } lastState = currentBehaviourStateIndex; } if (!base.isEnemyDead && !exploded) { Vector3 val = (((Component)this).transform.position - lastPos) / Mathf.Max(deltaTime, 0.0001f); lastPos = ((Component)this).transform.position; Vector3 val2 = new Vector3(val.x, 0f, val.z); float magnitude = ((Vector3)(ref val2)).magnitude; walkPhase += deltaTime * magnitude * 4f; float num = Mathf.Sin(walkPhase) * Mathf.Clamp01(magnitude / 2f) * 35f; Transform obj = legFL; Quaternion localRotation = (legBR.localRotation = Quaternion.Euler(num, 0f, 0f)); obj.localRotation = localRotation; Transform obj2 = legFR; localRotation = (legBL.localRotation = Quaternion.Euler(0f - num, 0f, 0f)); obj2.localRotation = localRotation; if ((Object)(object)base.targetPlayer != (Object)null) { Quaternion val5 = Quaternion.LookRotation(((Component)base.targetPlayer.gameplayCamera).transform.position - head.position); head.rotation = Quaternion.Slerp(head.rotation, val5, deltaTime * 6f); } else { head.localRotation = Quaternion.Slerp(head.localRotation, Quaternion.identity, deltaTime * 4f); } float num2 = ((currentBehaviourStateIndex == 1) ? Mathf.Clamp01(stateTimer / 1.5f) : 0f); model.localScale = Vector3.one * (1f + num2 * 0.18f + ((num2 > 0f) ? (Mathf.Sin(stateTimer * 30f) * 0.02f) : 0f)); float num3 = ((num2 > 0f && Mathf.Sin(stateTimer * (10f + num2 * 20f)) > 0f) ? 1f : 0f); mpb.SetColor("_EmissiveColor", Color.white * (num3 * 4f + 0.01f)); Renderer[] array = renderers; for (int i = 0; i < array.Length; i++) { array[i].SetPropertyBlock(mpb); } } } private void Explode() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (!exploded) { exploded = true; ((Component)model).gameObject.SetActive(false); Landmine.SpawnExplosion(((Component)this).transform.position + Vector3.up * 0.8f, true, Plugin.CreeperKillRange.Value, Plugin.CreeperKillRange.Value * 2.2f, 60, 6f, (GameObject)null, false); Poof(); if (((NetworkBehaviour)this).IsOwner) { ((MonoBehaviour)this).Invoke("Despawn", 0.6f); } } } private void Despawn() { if (!base.isEnemyDead) { ((EnemyAI)this).KillEnemyOnOwnerClient(true); } } private void Poof() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //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_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_0045: 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_0066: 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_0092: 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_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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("CreeperPoof"); val.transform.position = ((Component)this).transform.position + Vector3.up * 0.8f; ParticleSystem val2 = val.AddComponent<ParticleSystem>(); val2.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = val2.main; ((MainModule)(ref main)).duration = 0.5f; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(1.2f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.5f, 2.5f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.15f, 0.35f); ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.85f, 0.85f, 0.85f), new Color(0.6f, 0.6f, 0.6f)); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.1f); EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1] { new Burst(0f, (short)25) }); ShapeModule shape = val2.shape; ((ShapeModule)(ref shape)).radius = 0.5f; ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>(); component.renderMode = (ParticleSystemRenderMode)4; component.mesh = Resources.GetBuiltinResource<Mesh>("Cube.fbx"); ((Renderer)component).sharedMaterial = MatLib.Cloud; val2.Play(); Object.Destroy((Object)(object)val, 3f); } public static EnemyType Create() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: 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_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) EnemyType val = ScriptableObject.CreateInstance<EnemyType>(); ((Object)val).name = "Creeper"; val.enemyName = "Creeper"; val.probabilityCurve = AnimationCurve.Constant(0f, 1f, 1f); val.numberSpawnedFalloff = AnimationCurve.Constant(0f, 1f, 1f); val.MaxCount = Mathf.Max(1, Plugin.CreeperMaxCount.Value); val.PowerLevel = 1f; val.isOutsideEnemy = true; val.isDaytimeEnemy = false; val.canDie = true; val.destroyOnDeath = true; val.canBeStunned = true; val.stunTimeMultiplier = 1f; val.canSeeThroughFog = false; val.loudnessMultiplier = 1f; ((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x20); int layer = LayerMask.NameToLayer("Enemies"); GameObject val2 = NetworkPrefabs.CreateNetworkPrefab("MinecraftCreeper"); val2.layer = layer; NavMeshAgent obj = val2.AddComponent<NavMeshAgent>(); obj.speed = 3.8f; obj.angularSpeed = 300f; obj.acceleration = 10f; obj.radius = 0.35f; obj.height = 1.65f; obj.stoppingDistance = 0.5f; CreeperAI creeperAI = val2.AddComponent<CreeperAI>(); ((EnemyAI)creeperAI).enemyType = val; ((EnemyAI)creeperAI).enemyHP = 3; ((EnemyAI)creeperAI).AIIntervalTime = 0.2f; ((EnemyAI)creeperAI).enemyBehaviourStates = Array.ConvertAll(StateNames, (Converter<string, EnemyBehaviourState>)((string n) => new EnemyBehaviourState { name = n })); Transform transform = new GameObject("Eye").transform; transform.SetParent(val2.transform, false); transform.localPosition = new Vector3(0f, 1.4f, 0.25f); ((EnemyAI)creeperAI).eye = transform; ((EnemyAI)creeperAI).creatureSFX = Audio(val2.transform, "CreeperSFX", 20f); ((EnemyAI)creeperAI).creatureVoice = Audio(val2.transform, "CreeperVoice", 28f); GameObject val3 = new GameObject("CreeperCollision") { layer = layer, tag = "Enemy" }; val3.transform.SetParent(val2.transform, false); BoxCollider obj2 = val3.AddComponent<BoxCollider>(); ((Collider)obj2).isTrigger = true; obj2.center = new Vector3(0f, 0.82f, 0f); obj2.size = new Vector3(0.6f, 1.65f, 0.7f); Rigidbody obj3 = val3.AddComponent<Rigidbody>(); obj3.isKinematic = true; obj3.useGravity = false; val3.AddComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)creeperAI; GameObject val4 = new GameObject("ScanNode") { layer = LayerMask.NameToLayer("ScanNode") }; val4.transform.SetParent(val2.transform, false); val4.transform.localPosition = new Vector3(0f, 1.2f, 0f); ((Collider)val4.AddComponent<BoxCollider>()).isTrigger = true; ScanNodeProperties obj4 = val4.AddComponent<ScanNodeProperties>(); obj4.headerText = "Creeper"; obj4.subText = "Ssssss..."; obj4.nodeType = 1; obj4.minRange = 1; obj4.maxRange = 30; obj4.creatureScanID = -1; val.enemyPrefab = val2; TerminalNode val5 = ScriptableObject.CreateInstance<TerminalNode>(); ((Object)val5).name = "CreeperFile"; val5.creatureName = "Creepers"; val5.clearPreviousText = true; val5.maxCharactersToType = 35; val5.displayText = "CREEPERS\n\nSigurd's danger level: 60%\n\nGreen, blocky, legless-looking quadrupeds native to 64 Overworld. They make no sound while walking, which is the problem.\n\nWhen one gets close, it hisses for about a second and a half and then detonates. Running away while it hisses makes it lose interest. Three hits with a shovel will also do.\n\nThey are mostly seen at night. They do not seem to enjoy being looked at, but they do not care either.\n\n"; TerminalKeyword val6 = ScriptableObject.CreateInstance<TerminalKeyword>(); ((Object)val6).name = "CreeperKeyword"; val6.word = "creepers"; Enemies.RegisterEnemy(val, 0, (LevelTypes)1, (SpawnType)2, val5, val6); return val; } private static AudioSource Audio(Transform parent, string name, float max) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = Vector3.up * 1.2f; AudioSource obj = val.AddComponent<AudioSource>(); obj.playOnAwake = false; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = 2f; obj.maxDistance = max; obj.dopplerLevel = 0f; return obj; } } internal static class MoonBuilder { internal static VoxelWorld World; private static List<ChunkMeshes> chunks; private static readonly List<(Vector3 origin, Mesh opaque, Mesh cutout, Mesh emissive, Mesh water, Mesh[] colliders)> meshCache = new List<(Vector3, Mesh, Mesh, Mesh, Mesh, Mesh[])>(); private static NavMeshData navCache; internal static bool Built; internal static GameObject Root; private static readonly string[] SurfaceTags = new string[5] { "Grass", "Rock", "Wood", "Gravel", "Snow" }; private static readonly string[] KeepRoots = new string[9] { "ItemShipAnimContainer", "Teleports", "LevelGeneration", "OutOfBounds", "NavMeshColliders", "Sun", "DustStorm", "ScanNodes", "SyncedMapObjects" }; public static bool IsOurLevel { get { if ((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)MoonRegistry.Level != (Object)null) { return (Object)(object)StartOfRound.Instance.currentLevel == (Object)(object)MoonRegistry.Level; } return false; } } public static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (!IsOurLevel || ((Scene)(ref scene)).name != MoonRegistry.Level.sceneName) { return; } try { Build(scene); } catch (Exception ex) { Plugin.Log.LogError((object)("Construction du monde Minecraft impossible : " + ex)); } } public static void OnSceneUnloaded(Scene scene) { if ((Object)(object)MoonRegistry.Level != (Object)null && ((Scene)(ref scene)).name == MoonRegistry.Level.sceneName) { Built = false; Root = null; } } private static void EnsureWorld() { //IL_0085: 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_00c6: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) if (World != null && meshCache.Count > 0) { return; } Stopwatch stopwatch = Stopwatch.StartNew(); World = Generator.Generate(Plugin.WorldSeed.Value); chunks = Mesher.Build(World); meshCache.Clear(); foreach (ChunkMeshes chunk in chunks) { Mesh[] array = (Mesh[])(object)new Mesh[chunk.Colliders.Length]; for (int i = 0; i < array.Length; i++) { array[i] = M(chunk.Colliders[i], $"col{chunk.Chunk}_{i}", render: false); } meshCache.Add((chunk.Origin, M(chunk.Opaque, $"op{chunk.Chunk}", render: true), M(chunk.Cutout, $"cut{chunk.Chunk}", render: true), M(chunk.Emissive, $"em{chunk.Chunk}", render: true), M(chunk.Water, $"wa{chunk.Chunk}", render: true), array)); } chunks = null; Plugin.Log.LogInfo((object)$"Maillages prêts en {stopwatch.ElapsedMilliseconds} ms ({meshCache.Count} tronçons)."); static Mesh M(MeshBuffer b, string n, bool render) { if (!b.Empty) { Mesh obj = b.ToMesh(n, render); MatLib.Keep((Object)(object)obj); return obj; } return null; } } private static void Build(Scene scene) { //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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0286: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_018b: 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_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) Stopwatch stopwatch = Stopwatch.StartNew(); EnsureWorld(); GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); GameObject? obj = ((IEnumerable<GameObject>)rootGameObjects).FirstOrDefault((Func<GameObject, bool>)((GameObject r) => r.CompareTag("OutsideLevelNavMesh"))) ?? ((IEnumerable<GameObject>)rootGameObjects).FirstOrDefault((Func<GameObject, bool>)((GameObject r) => ((Object)r).name == "Environment")); if ((Object)(object)obj == (Object)null) { throw new Exception("objet Environment introuvable"); } GameObject val = ((IEnumerable<GameObject>)GameObject.FindGameObjectsWithTag("ItemShipLandingNode")).FirstOrDefault((Func<GameObject, bool>)((GameObject g) => g.scene == scene)); float num = float.NaN; RaycastHit val2 = default(RaycastHit); if ((Object)(object)val != (Object)null && Physics.Raycast(val.transform.position + Vector3.up * 4f, Vector3.down, ref val2, 60f, -1, (QueryTriggerInteraction)1)) { num = ((RaycastHit)(ref val2)).point.y; } HideVanilla(rootGameObjects); Root = new GameObject("MinecraftWorld"); SceneManager.MoveGameObjectToScene(Root, scene); BuildChunks(obj.transform); PlaceEntrances(rootGameObjects); if ((Object)(object)val != (Object)null && !float.IsNaN(num)) { Vector3 position = val.transform.position; float num2 = GroundY(position.x, position.z); Transform obj2 = (((Object)(object)val.transform.parent != (Object)null) ? val.transform.parent : val.transform); obj2.position += Vector3.up * (num2 - num); Plugin.Log.LogInfo((object)$"Navette de livraison déplacée de {num2 - num:0.00} m."); } GameObject val3 = GameObject.FindGameObjectWithTag("MoldAttractionPoint"); if ((Object)(object)val3 != (Object)null) { val3.transform.position = new Vector3(40f, GroundY(40f, 80f), 80f); } Decorations.Build(Root.transform, World); Triggers(Root.transform); SkyController.Create(Root, scene); Root.AddComponent<AmbientMusic>(); Root.AddComponent<AutoStep>(); GameObject val4 = new GameObject("PortalHum"); val4.transform.SetParent(Root.transform, false); val4.transform.position = World.Points["fire_exit"]; AudioSource obj3 = val4.AddComponent<AudioSource>(); obj3.clip = Music.PortalHum; obj3.loop = true; obj3.spatialBlend = 1f; obj3.rolloffMode = (AudioRolloffMode)1; obj3.minDistance = 2f; obj3.maxDistance = 16f; obj3.volume = 0.55f; obj3.Play(); NavMeshAndNodes(obj); Built = true; Plugin.Log.LogInfo((object)$"Monde Minecraft construit en {stopwatch.ElapsedMilliseconds} ms."); } public static void SpawnTreasures(RoundManager rm) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_009c: 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_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_0111: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)rm).IsServer || World == null) { return; } Random random = new Random(StartOfRound.Instance.randomMapSeed + 64); List<NetworkObjectReference> list = new List<NetworkObjectReference>(); List<int> list2 = new List<int>(); foreach (Vector3 treasure in World.Treasures) { if (!(random.NextDouble() < 0.25)) { McItems.Def def = McItems.All[random.Next(McItems.All.Count)]; GameObject obj = Object.Instantiate<GameObject>(def.Item.spawnPrefab, treasure + Vector3.up * def.Item.verticalOffset, Quaternion.Euler(def.Item.restingRotation), rm.spawnedScrapContainer); GrabbableObject component = obj.GetComponent<GrabbableObject>(); component.isInFactory = false; component.fallTime = 0f; NetworkObject component2 = obj.GetComponent<NetworkObject>(); component2.Spawn(false); int num = random.Next(def.Min, def.Max + 1); component.SetScrapValue(num); list.Add(NetworkObjectReference.op_Implicit(component2)); list2.Add(num); } } if (list.Count > 0) { rm.SyncScrapValuesClientRpc(list.ToArray(), list2.ToArray()); } Plugin.Log.LogInfo((object)$"{list.Count} trésors posés sur les coffres."); } public static float GroundY(float wx, float wz) { int num = VoxelWorld.BX(wx); int num2 = VoxelWorld.BZ(wz); int num3 = World.TopSolid(Mathf.Clamp(num, 0, 303), Mathf.Clamp(num2, 0, 303)); return -25.75f + (float)num3 + 1f; } private static bool UnderKeep(Transform t) { Transform val = t; while ((Object)(object)val != (Object)null) { if (KeepRoots.Contains(((Object)val).name)) { return true; } val = val.parent; } return false; } private static void HideVanilla(GameObject[] roots) { int num = 0; GameObject[] array = roots; for (int i = 0; i < array.Length; i++) { Component[] componentsInChildren = array[i].GetComponentsInChildren<Component>(true); foreach (Component val in componentsInChildren) { if ((Object)(object)val == (Object)null || val is Transform || UnderKeep(val.transform)) { continue; } Component val2 = val; Renderer val3 = (Renderer)(object)((val2 is Renderer) ? val2 : null); if (val3 == null) { Collider val4 = (Collider)(object)((val2 is Collider) ? val2 : null); if (val4 == null) { Terrain val5 = (Terrain)(object)((val2 is Terrain) ? val2 : null); if (val5 == null) { Light val6 = (Light)(object)((val2 is Light) ? val2 : null); if (val6 == null) { LocalVolumetricFog val7 = (LocalVolumetricFog)(object)((val2 is LocalVolumetricFog) ? val2 : null); if (val7 == null) { NavMeshObstacle val8 = (NavMeshObstacle)(object)((val2 is NavMeshObstacle) ? val2 : null); if (val8 == null) { NavMeshModifierVolume val9 = (NavMeshModifierVolume)(object)((val2 is NavMeshModifierVolume) ? val2 : null); if (val9 == null) { NavMeshModifier val10 = (NavMeshModifier)(object)((val2 is NavMeshModifier) ? val2 : null); if (val10 == null) { Volume val11 = (Volume)(object)((val2 is Volume) ? val2 : null); if (val11 == null) { ParticleSystem val12 = (ParticleSystem)(object)((val2 is ParticleSystem) ? val2 : null); if (val12 != null) { val12.Stop(true, (ParticleSystemStopBehavior)0); } } else if (!val11.isGlobal) { ((Behaviour)val11).enabled = false; } } else { ((Behaviour)val10).enabled = false; } } else { ((Behaviour)val9).enabled = false; } } else { ((Behaviour)val8).enabled = false; } } else { ((Behaviour)val7).enabled = false; num++; } } else { ((Behaviour)val6).enabled = false; num++; } } else { ((Behaviour)val5).enabled = false; val5.drawHeightmap = false; num++; } } else { val4.enabled = false; num++; } } else { val3.enabled = false; num++; } } } array = GameObject.FindGameObjectsWithTag("OutsideAINode"); foreach (GameObject val13 in array) { if (roots.Contains(((Component)val13.transform.root).gameObject)) { val13.tag = "Untagged"; val13.SetActive(false); } } Plugin.Log.LogInfo((object)$"Décor vanilla caché ({num} composants)."); } private static void BuildChunks(Transform env) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0029: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Expected O, but got Unknown //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) int layer = LayerMask.NameToLayer("Room"); GameObject val = new GameObject("MinecraftTerrain"); val.transform.SetParent(env, false); val.transform.position = Vector3.zero; val.transform.rotation = Quaternion.identity; val.layer = layer; foreach (var item in meshCache) { GameObject val2 = new GameObject("Chunk"); val2.layer = layer; val2.transform.SetParent(val.transform, false); val2.transform.position = item.origin; AddRenderer(val2, item.opaque, MatLib.Opaque, (ShadowCastingMode)1); AddRenderer(val2, item.cutout, MatLib.Cutout, (ShadowCastingMode)1); AddRenderer(val2, item.emissive, MatLib.Emissive, (ShadowCastingMode)1); AddRenderer(val2, item.water, MatLib.Water, (ShadowCastingMode)0); for (int i = 0; i < item.colliders.Length; i++) { if (!((Object)(object)item.colliders[i] == (Object)null)) { GameObject val3 = new GameObject("Col_" + SurfaceTags[i]) { layer = layer, tag = SurfaceTags[i] }; val3.transform.SetParent(val2.transform, false); val3.AddComponent<MeshCollider>().sharedMesh = item.colliders[i]; } } } GameObject walls = new GameObject("WorldBorder") { layer = LayerMask.NameToLayer("Colliders") }; walls.transform.SetParent(val.transform, false); float num = -151f; float num2 = 151f; float num3 = -151f; float num4 = 151f; float num5 = 22.25f; float num6 = 156f; Wall(new Vector3(num - 1f, num5, (num3 + num4) / 2f), new Vector3(2f, num6, num4 - num3 + 4f)); Wall(new Vector3(num2 + 1f, num5, (num3 + num4) / 2f), new Vector3(2f, num6, num4 - num3 + 4f)); Wall(new Vector3((num + num2) / 2f, num5, num3 - 1f), new Vector3(num2 - num + 4f, num6, 2f)); Wall(new Vector3((num + num2) / 2f, num5, num4 + 1f), new Vector3(num2 - num + 4f, num6, 2f)); void Wall(Vector3 c, Vector3 s) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) BoxCollider obj = walls.AddComponent<BoxCollider>(); obj.center = c; obj.size = s; } } private static void AddRenderer(GameObject parent, Mesh mesh, Material mat, ShadowCastingMode shadows) { //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_0021: 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_004b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)mesh == (Object)null)) { GameObject val = new GameObject(((Object)mat).name) { layer = parent.layer }; val.transform.SetParent(parent.transform, false); val.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = mat; ((Renderer)obj).shadowCastingMode = shadows; } } private static void PlaceEntrances(GameObject[] roots) { //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_0123: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0257: 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_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) foreach (EntranceTeleport item in (from e in roots.SelectMany((GameObject r) => r.GetComponentsInChildren<EntranceTeleport>(true)) where e.isEntranceToBuilding select e).ToList()) { string text = ((item.entranceId == 0) ? "main_entrance" : "fire_exit"); if (World.Points.TryGetValue(text, out var value)) { Transform entrancePoint = item.entrancePoint; ((Component)item).transform.SetPositionAndRotation(value, World.Rotations[text]); if ((Object)(object)entrancePoint != (Object)null) { entrancePoint.SetPositionAndRotation(World.Points[text + "_exit"], World.Rotations[text + "_exit"]); } Plugin.Log.LogInfo((object)$"Entrée {item.entranceId} placée en {value}."); } } GameObject[] array = (from g in GameObject.FindGameObjectsWithTag("SpawnDenialPoint") where roots.Contains(((Component)g.transform.root).gameObject) select g).ToArray(); if (array.Length != 0) { array[0].transform.position = World.Points["mine_mouth"]; } if (array.Length > 1) { array[1].transform.position = World.Points["fire_exit_exit"]; } foreach (ScanNodeProperties item2 in roots.SelectMany((GameObject r) => r.GetComponentsInChildren<ScanNodeProperties>(true))) { if (!UnderShip(((Component)item2).transform)) { string text2 = (item2.headerText ?? "").ToLowerInvariant(); if (text2.Contains("main")) { ((Component)item2).transform.position = World.Points["main_entrance"] + Vector3.up * 1.2f; } else if (text2.Contains("exit") || text2.Contains("fire")) { ((Component)item2).transform.position = World.Points["fire_exit"]; } Plugin.Log.LogInfo((object)$"Nœud de scan « {item2.headerText} » en {((Component)item2).transform.position}."); } } } private static bool UnderShip(Transform t) { Transform val = t; while ((Object)(object)val != (Object)null) { if (((Object)val).name == "ItemShipAnimContainer") { return true; } val = val.parent; } return false; } private static void Triggers(Transform root) { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_030c: 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_031e: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023b: 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_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0259: 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_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0263: 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_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) int layer = LayerMask.NameToLayer("Triggers"); int[,] array = new int[304, 304]; int[,] array2 = new int[304, 304]; for (int i = 0; i < 304; i++) { for (int j = 0; j < 304; j++) { for (int num = 95; num > 0; num--) { if (World.Get(i, num, j) == B.Water) { int num2 = num; while (num2 > 0 && World.Get(i, num2 - 1, j) == B.Water) { num2--; } array[i, j] = num + 1; array2[i, j] = num2; break; } } } } GameObject val = new GameObject("Water") { layer = layer }; val.transform.SetParent(root, false); int num3 = 0; bool[,] array3 = new bool[304, 304]; for (int k = 0; k < 304; k++) { for (int l = 0; l < 304; l++) { if (array[k, l] == 0 || array3[k, l]) { continue; } int num4 = array[k, l]; int m; for (m = l; m + 1 < 304 && array[k, m + 1] == num4 && !array3[k, m + 1]; m++) { } int n; for (n = k; n + 1 < 304; n++) { bool flag = true; for (int num5 = l; num5 <= m && flag; num5++) { flag = array[n + 1, num5] == num4 && !array3[n + 1, num5]; } if (!flag) { break; } } int num6 = int.MaxValue; for (int num7 = k; num7 <= n; num7++) { for (int num8 = l; num8 <= m; num8++) { array3[num7, num8] = true; num6 = Mathf.Min(num6, array2[num7, num8]); } } Vector3 val2 = VoxelWorld.ToWorld(k, num6, l); Vector3 val3 = VoxelWorld.ToWorld(n + 1, (float)num4 - 0.125f, m + 1); GameObject val4 = new GameObject("WaterTrigger") { layer = layer }; val4.transform.SetParent(val.transform, false); val4.transform.position = (val2 + val3) / 2f; BoxCollider obj = val4.AddComponent<BoxCollider>(); ((Collider)obj).isTrigger = true; obj.size = val3 - val2; QuicksandTrigger obj2 = val4.AddComponent<QuicksandTrigger>(); obj2.isWater = true; obj2.movementHinderance = 1.4f; num3++; } } foreach (Bounds lavaZone in World.LavaZones) { Bounds current = lavaZone; GameObject val5 = new GameObject("LavaTrigger") { layer = layer }; val5.transform.SetParent(root, false); val5.transform.position = ((Bounds)(ref current)).center; BoxCollider obj3 = val5.AddComponent<BoxCollider>(); ((Collider)obj3).isTrigger = true; obj3.size = ((Bounds)(ref current)).size; val5.AddComponent<LavaTrigger>(); } Plugin.Log.LogInfo((object)$"{num3} zones d'eau, {World.LavaZones.Count} zones de lave."); } private static Mesh StepRamps() { //IL_00ea: 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_00f9: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_0139: 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_0142: 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_0145: 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_0151: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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_018f: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) VoxelWorld w = World; MeshBuffer meshBuffer = new MeshBuffer(); int[] array = new int[4] { 1, -1, 0, 0 }; int[] array2 = new int[4] { 0, 0, 1, -1 }; Vector3 val = default(Vector3); for (int i = 1; i < 303; i++) { for (int j = 1; j < 303; j++) { for (int k = 1; k < 92; k++) { if (!Walk(i, k, j) || Blocks.IsSolid(w.Get(i, k + 3, j))) { continue; } for (int l = 0; l < 4; l++) { int x = i + array[l]; int z = j + array2[l]; if (Walk(x, k + 1, z)) { ((Vector3)(ref val))..ctor((float)i + 0.5f + (float)array[l] * 0.5f, (float)k + 2f, (float)j + 0.5f + (float)array2[l] * 0.5f); Vector3 val2 = new Vector3((float)array2[l], 0f, (float)array[l]) * 0.5f; Vector3 val3 = new Vector3((float)(-array[l]), 0f, (float)(-array2[l])) * 0.9f; Vector3 val4 = new Vector3(-152f, -25.75f, -152f); Vector3 val5 = val4 + val + val2; Vector3 val6 = val4 + val - val2; Vector3 val7 = val4 + val + val2 + val3 + Vector3.down; Vector3 val8 = val4 + val - val2 + val3 + Vector3.down; meshBuffer.Quad(val7, val5, val6, val8, Vector3.up, default(Rect), withUv: false); meshBuffer.Quad(val8, val6, val5, val7, Vector3.up, default(Rect), withUv: false); } } } } } Mesh result = meshBuffer.ToMesh("NavRamps", render: false); Plugin.Log.LogInfo((object)$"NavMesh : {meshBuffer.V.Count / 8} rampes de marche."); return result; bool Walk(int x2, int y, int z2) { if (Blocks.IsSolid(w.Get(x2, y, z2)) && !Blocks.IsSolid(w.Get(x2, y + 1, z2)) && !Blocks.IsSolid(w.Get(x2, y + 2, z2)) && w.Get(x2, y + 1, z2) != B.Water) { return w.Get(x2, y + 1, z2) != B.Lava; } return false; } } private static void NavMeshAndNodes(GameObject env) { //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0235: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_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_0119: 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_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: 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_0288: Expected O, but got Unknown //IL_016b: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0199: 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_01a5: 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_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: 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_033e: Unknown result type (might be due to invalid IL or missing references) Stopwatch stopwatch = Stopwatch.StartNew(); NavMeshSurface component = env.GetComponent<NavMeshSurface>(); if ((Object)(object)component != (Object)null) { if ((Object)(object)navCache != (Object)null) { component.RemoveData(); component.navMeshData = navCache; component.AddData(); } else { NavMeshBuildSettings settingsByID = NavMesh.GetSettingsByID(component.agentTypeID); ((NavMeshBuildSettings)(ref settingsByID)).agentSlope = Mathf.Max(((NavMeshBuildSettings)(ref settingsByID)).agentSlope, 50f); ((NavMeshBuildSettings)(ref settingsByID)).overrideVoxelSize = true; ((NavMeshBuildSettings)(ref settingsByID)).voxelSize = 0.25f; ((NavMeshBuildSettings)(ref settingsByID)).overrideTileSize = true; ((NavMeshBuildSettings)(ref settingsByID)).tileSize = 128; ((NavMeshBuildSettings)(ref settingsByID)).agentSlope = 60f; List<NavMeshBuildSource> list = new List<NavMeshBuildSource>(); NavMeshBuilder.CollectSources(env.transform, LayerMask.op_Implicit(component.layerMask), (NavMeshCollectGeometry)1, component.defaultArea, new List<NavMeshBuildMarkup>(), list); Mesh sourceObject = StepRamps(); NavMeshBuildSource item = default(NavMeshBuildSource); ((NavMeshBuildSource)(ref item)).shape = (NavMeshBuildSourceShape)0; ((NavMeshBuildSource)(ref item)).sourceObject = (Object)(object)sourceObject; ((NavMeshBuildSource)(ref item)).transform = Matrix4x4.identity; ((NavMeshBuildSource)(ref item)).area = component.defaultArea; list.Add(item); string[] array = ((NavMeshBuildSettings)(ref settingsByID)).ValidationReport(new Bounds(Vector3.zero, Vector3.one * 300f)); foreach (string text in array) { Plugin.Log.LogWarning((object)("NavMesh : " + text)); } Bounds val = default(Bounds); ((Bounds)(ref val))..ctor(new Vector3(0f, 22.25f, 0f) - env.transform.position, new Vector3(304f, 100f, 304f)); NavMeshData navMeshData = NavMeshBuilder.BuildNavMeshData(settingsByID, list, val, env.transform.position, env.transform.rotation); component.RemoveData(); component.navMeshData = navMeshData; component.AddData(); navCache = navMeshData; if ((Object)(object)navCache != (Object)null) { MatLib.Keep((Object)(object)navCache); } Plugin.Log.LogInfo((object)$"NavMesh : {list.Count} sources, escalade {((NavMeshBuildSettings)(ref settingsByID)).agentClimb} m + rampes."); } } NavMeshTriangulation val2 = NavMesh.CalculateTriangulation(); ManualLogSource log = Plugin.Log; object arg = stopwatch.ElapsedMilliseconds; object arg2 = val2.vertices.Length; object arg3; if (!((Object)(object)component != (Object)null)) { arg3 = "?"; } else { NavMeshData navMeshData2 = component.navMeshData; arg3 = ((navMeshData2 != null) ? ((object)navMeshData2.sourceBounds/*cast due to .constrained prefix*/).ToString() : null); } log.LogInfo((object)$"NavMesh prêt en {arg} ms ({arg2} sommets, surface {arg3})."); GameObject val3 = new GameObject("OutsideAINodes"); val3.transform.SetParent(Root.transform, false); int num = 0; NavMeshHit val4 = default(NavMeshHit); for (int j = 6; j < 298; j += 9) { for (int k = 6; k < 298; k += 9) { int num2 = World.TopSolid(j, k); if (num2 >= 0 && World.Get(j, num2 + 1, k) != B.Water && World.Get(j, num2 + 1, k) != B.Lava && NavMesh.SamplePosition(VoxelWorld.StandOn(j, num2, k), ref val4, 2.5f, -1)) { GameObject val5 = new GameObject("OutsideNode") { tag = "OutsideAINode" }; val5.transform.SetParent(val3.transform, false); val5.transform.position = ((NavMeshHit)(ref val4)).position; num++; } } } if ((Object)(object)RoundManager.Instance != (Object)null) { RoundManager.Instance.outsideAINodes = null; RoundManager.Instance.outsideAIDryNodes = null; RoundManager.Instance.outsideAIWaterNodes = null; } Plugin.Log.LogInfo((object)$"{num} nœuds d'IA extérieurs."); } } internal class AutoStep : MonoBehaviour { private Vector3 lastPos; private float lift; private float cooldown; private bool jumping; private bool airborne; internal static Vector3? TestDirection; private void Update() { //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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: 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_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0369: 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_037e: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0390: 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_03b6: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; VoxelWorld world = MoonBuilder.World; if ((Object)(object)val == (Object)null || world == null || Plugin.StepHeight.Value <= 0f) { return; } CharacterController thisController = val.thisController; Vector3 position = ((Component)val).transform.position; Vector3 val2 = (position - lastPos) / Mathf.Max(Time.deltaTime, 0.0001f); lastPos = position; cooldown -= Time.deltaTime; if (jumping) { if (!thisController.isGrounded) { airborne = true; } else if (airborne || cooldown < -0.5f) { jumping = false; val.isFallingFromJump = false; } } if (lift > 0f) { val.fallValue = Mathf.Min(val.jumpForce, Mathf.Sqrt(76f * (Plugin.StepHeight.Value + 0.3f))); val.fallValueUncapped = val.fallValue; val.isFallingFromJump = true; jumping = true; airborne = false; lift = 0f; if (TestDirection.HasValue) { Plugin.Log.LogInfo((object)$"AutoStep : saut (force {val.fallValue:0.0})"); } return; } if (TestDirection.HasValue) { Plugin.Log.LogInfo((object)$"AutoStep : pos={position} dedans={val.isInsideFactory} vaisseau={val.isInHangarShipRoom} échelle={val.isClimbingLadder} anim={val.inSpecialInteractAnimation} enfonce={val.isSinking} cd={cooldown:0.00} bloc dessous={world.Get(VoxelWorld.BX(position.x), VoxelWorld.BY(position.y + 0.1f) - 1, VoxelWorld.BZ(position.z))} devant={world.Get(VoxelWorld.BX(position.x + 0.75f), VoxelWorld.BY(position.y + 0.1f), VoxelWorld.BZ(position.z))}"); } if (val.isInsideFactory || val.isInHangarShipRoom || val.isClimbingLadder || val.isPlayerDead || val.inSpecialInteractAnimation || val.isSinking || cooldown > 0f) { return; } int num = VoxelWorld.BY(position.y + 0.1f); if (position.y - (-25.75f + (float)num) > 0.2f || !Blocks.IsSolid(world.Get(VoxelWorld.BX(position.x), num - 1, VoxelWorld.BZ(position.z)))) { return; } Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(val2.x, 0f, val2.z); Vector3 val4 = (Vector3)(((??)TestDirection) ?? ((((Vector2)(ref val.moveInputVector)).sqrMagnitude > 0.01f) ? ((Component)val).transform.TransformDirection(new Vector3(val.moveInputVector.x, 0f, val.moveInputVector.y)) : val3)); if (((Vector3)(ref val4)).sqrMagnitude < 0.01f) { return; } Vector3 normalized = ((Vector3)(ref val4)).normalized; int num2 = VoxelWorld.BY(position.y + 0.1f); Vector3 val5 = position + normalized * 0.75f; int num3 = VoxelWorld.BX(val5.x); int num4 = VoxelWorld.BZ(val5.z); int num5 = VoxelWorld.BX(position.x); int num6 = VoxelWorld.BZ(position.z); if ((num3 == num5 && num4 == num6) || !Blocks.IsSolid(world.Get(num3, num2, num4)) || Blocks.IsSolid(world.Get(num3, num2 + 1, num4)) || Blocks.IsSolid(world.Get(num3, num2 + 2, num4)) || Blocks.IsSolid(world.Get(num5, num2 + 2, num6))) { return; } switch (world.Get(num3, num2, num4)) { case B.Glass: if (num2 > 0 && Blocks.IsSolid(world.Get(num3, num2 - 1, num4)) && world.Get(num3, num2 - 1, num4) == B.Glass) { return; } break; case B.Cactus: return; } lift = Plugin.StepHeight.Value; cooldown = 0.35f; } } internal class LavaTrigger : MonoBehaviour { private float next; private void OnTriggerStay(Collider other) { //IL_0068: 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) if (!(Time.time < next) && ((Component)other).CompareTag("Player")) { PlayerControllerB component = ((Component)other).GetComponent<PlayerControllerB>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component != (Object)(object)GameNetworkManager.Instance.localPlayerController) && !component.isPlayerDead) { next = Time.time + 0.5f; component.DamagePlayer(Plugin.LavaDamage.Value, true, true, (CauseOfDeath)13, 0, false, Vector3.up * 2f); } } } } internal static class MoonRegistry { public const string PlanetName = "64 Overworld"; internal static SelectableLevel Level; internal static int LevelIndex = -1; private static GameObject planetTemplate; private const string Description = "POPULATION: Villagers (hmm...)\nCONDITIONS: Everything here is made of perfect one-meter cubes. The sun is square. Sand refuses to fall.\nFAUNA: Unclear. Crew members report a faint hissing sound right before they stop reporting."; public static void Register(StartOfRound sor) { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: 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) //IL_01bf: 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_01ce: Expected O, but got Unknown //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing