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 HerobrineMod v1.0.0
HerobrineMod.dll
Decompiled 2 years agousing System; using System.Collections; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using HerobrineMod.Patches; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("HerobrineMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A mod which adds herobrine to the game")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("HerobrineMod")] [assembly: AssemblyTitle("HerobrineMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace HerobrineMod { public class HerobrineEntity : MonoBehaviour { public PlayerControllerB player; private bool coroutineRunning = false; private float time = 0f; private void Awake() { Plugin.Instance.GetLogger().LogInfo((object)"Herobrine Added"); } private void Update() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.LookAt(((Component)player).transform); ((Component)this).transform.eulerAngles = new Vector3(0f, ((Component)this).transform.eulerAngles.y, 0f); time += Time.deltaTime; if (IsInSight() && !coroutineRunning) { ((MonoBehaviour)this).StartCoroutine(HerobrineSeen()); coroutineRunning = true; } if (time > 20f) { Plugin.Instance.GetLogger().LogInfo((object)"Herobrine Removed"); Object.Destroy((Object)(object)((Component)this).gameObject); } } private IEnumerator HerobrineSeen() { for (int i = 0; i < 6; i++) { if (!IsInSight()) { ((MonoBehaviour)this).StopAllCoroutines(); coroutineRunning = false; } yield return (object)new WaitForSeconds(0.1f); } Plugin.Instance.GetLogger().LogInfo((object)"Herobrine Seen"); Plugin.Instance.HerobrineSpawner.PlayCaveNoise(player); Object.Destroy((Object)(object)((Component)this).gameObject); } private bool IsInSight() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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) return player.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 0.4f, 60f, 100, 5f) && Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position) < 35f; } } public class HerobrineSpawner { private GameObject herobrinePrefab; private GameObject caveNoisePlayerPrefab; private AudioClip[] caveNoises; private HerobrineEntity herobrineEntity; public HerobrineSpawner() { herobrinePrefab = Plugin.Instance.ModAssets.LoadAsset<GameObject>("Assets/Prefabs/Herobrine.prefab"); caveNoises = Plugin.Instance.ModAssets.LoadAllAssets<AudioClip>(); caveNoisePlayerPrefab = Plugin.Instance.ModAssets.LoadAsset<GameObject>("Assets/Prefabs/Cave Noise Sound.prefab"); } public void TrySpawnHerobrine(PlayerControllerB player) { //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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)herobrineEntity != (Object)null)) { Vector3 val = FindHerobrineSpawnPoint(player); if (!(val == Vector3.zero)) { GameObject val2 = Object.Instantiate<GameObject>(herobrinePrefab, val, Quaternion.identity); herobrineEntity = val2.AddComponent<HerobrineEntity>(); herobrineEntity.player = player; } } } private Vector3 FindHerobrineSpawnPoint(PlayerControllerB player) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) GameObject[] array = (player.isInsideFactory ? RoundManager.Instance.insideAINodes : RoundManager.Instance.outsideAINodes); GameObject[] array2 = array; foreach (GameObject val in array2) { if (!Physics.Linecast(((Component)player.gameplayCamera).transform.position, val.transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && !player.HasLineOfSightToPosition(val.transform.position, 80f, 100, 8f)) { return val.transform.position; } } return Vector3.zero; } public void PlayCaveNoise(PlayerControllerB player) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) AudioClip clip = caveNoises[Random.Range(0, caveNoises.Length)]; GameObject val = Object.Instantiate<GameObject>(caveNoisePlayerPrefab, ((Component)player).transform.position, Quaternion.identity); AudioSource component = val.GetComponent<AudioSource>(); component.clip = clip; component.Play(); } } [BepInPlugin("StefanDeSterke.herobrinemod", "Herobrine Mod", "1.0.0")] public class Plugin : BaseUnityPlugin { private const string MOD_GUID = "StefanDeSterke.herobrinemod"; private const string MOD_NAME = "Herobrine Mod"; private const string MOD_VERSION = "1.0.0"; private readonly Harmony harmony = new Harmony("StefanDeSterke.herobrinemod"); public static Plugin Instance { get; private set; } public AssetBundle ModAssets { get; private set; } public HerobrineSpawner HerobrineSpawner { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Plugin instance already exists! Overriding singleton.."); } Instance = this; LoadAssets(); LoadPatches(); HerobrineSpawner = new HerobrineSpawner(); } private void LoadAssets() { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "modassets"); ModAssets = AssetBundle.LoadFromFile(text); } private void LoadPatches() { harmony.PatchAll(typeof(PlayerControllerPatch)); } public ManualLogSource GetLogger() { return ((BaseUnityPlugin)this).Logger; } } public static class PluginInfo { public const string PLUGIN_GUID = "HerobrineMod"; public const string PLUGIN_NAME = "HerobrineMod"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace HerobrineMod.Patches { public static class PlayerControllerPatch { [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPrefix] private static void OnPlayerUpdate(PlayerControllerB __instance) { if ((((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerControlled && (!((NetworkBehaviour)__instance).IsServer || __instance.isHostPlayerObject)) || __instance.isTestingPlayer) { float num = 0.01f; float num2 = 1f - Mathf.Pow(1f - num, Time.deltaTime); if (Random.Range(0f, 1f) <= num2) { Plugin.Instance.HerobrineSpawner.TrySpawnHerobrine(__instance); } } } } public static class StartOfRoundPatch { [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] private static void OnStartOfRoundAwakePatch() { } } }