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 CountryRoadCreature v1.0.9
CountryRoadCreature.dll
Decompiled a month agousing 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 BepInEx; using BepInEx.Configuration; using BigEyes.Utils; using CountryRoadCreature.Scripts; using GameNetcodeStuff; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using LethalLib.Modules; 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("CountryRoadCreature")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("CountryRoadCreature")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+4ae1ab042e32784f9e5fb3f32e8fd980838199fe")] [assembly: AssemblyProduct("CountryRoadCreature")] [assembly: AssemblyTitle("CountryRoadCreature")] [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 BigEyes.Utils { public class RegisterUtil { public static void RegisterEnemyWithConfig(string configMoonRarity, EnemyType enemy, TerminalNode terminalNode, TerminalKeyword terminalKeyword, float powerLevel, int spawnCount) { enemy.MaxCount = spawnCount; enemy.PowerLevel = powerLevel; var (dictionary, dictionary2) = ConfigParsing(configMoonRarity); Enemies.RegisterEnemy(enemy, dictionary, dictionary2, terminalNode, terminalKeyword); } public static void RegisterScrapWithConfig(string configMoonRarity, Item scrap) { var (dictionary, dictionary2) = ConfigParsing(configMoonRarity); Items.RegisterScrap(scrap, dictionary, dictionary2); } public static void RegisterShopItemWithConfig(bool enabledScrap, Item item, TerminalNode terminalNode, int itemCost, string configMoonRarity) { Items.RegisterShopItem(item, (TerminalNode)null, (TerminalNode)null, terminalNode, itemCost); if (enabledScrap) { RegisterScrapWithConfig(configMoonRarity, item); } } public static (Dictionary<LevelTypes, int> spawnRateByLevelType, Dictionary<string, int> spawnRateByCustomLevelType) ConfigParsing(string configMoonRarity) { //IL_0099: 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) Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>(); Dictionary<string, int> dictionary2 = new Dictionary<string, int>(); foreach (string item in from s in configMoonRarity.Split(',') select s.Trim()) { string[] array = item.Split(':'); if (array.Length != 2) { continue; } string text = array[0]; if (!int.TryParse(array[1], out var result)) { continue; } if (Enum.TryParse<LevelTypes>(text, ignoreCase: true, out LevelTypes result2)) { dictionary[result2] = result; continue; } string value = text + "Level"; if (Enum.TryParse<LevelTypes>(value, ignoreCase: true, out result2)) { dictionary[result2] = result; } else { dictionary2[text] = result; } } return (dictionary, dictionary2); } } } namespace CountryRoadCreature { [BepInPlugin("wexop.country_road_creature", "CountryRoadCreature", "1.0.9")] [BepInDependency("evaisa.lethallib", "0.15.1")] public class CountryRoadCreaturePlugin : BaseUnityPlugin { private const string GUID = "wexop.country_road_creature"; private const string NAME = "CountryRoadCreature"; private const string VERSION = "1.0.9"; public Dictionary<int, LightInformation> lightsInUse = new Dictionary<int, LightInformation>(); public static CountryRoadCreaturePlugin instance; public ConfigEntry<string> spawnMoonRarity; public ConfigEntry<string> headScrapMoonRarity; public ConfigEntry<string> handScrapMoonRarity; public ConfigEntry<int> maxCountryRoadCreatureSpawnNb; public ConfigEntry<float> countryRoadBaseSpeed; public ConfigEntry<float> countryRoadMaxSpeedMutliplier; public ConfigEntry<int> scrapHitPlayerChance; private void Awake() { instance = this; ((BaseUnityPlugin)this).Logger.LogInfo((object)"CountryRoadCreature starting...."); string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "countryroadcreature"); AssetBundle bundle = AssetBundle.LoadFromFile(text); ((BaseUnityPlugin)this).Logger.LogInfo((object)"CountryRoadCreature bundle found !"); LoadConfigs(); RegisterMonster(bundle); RegisterScrap(bundle); ((BaseUnityPlugin)this).Logger.LogInfo((object)"CountryRoadCreature is ready!"); } private void LoadConfigs() { spawnMoonRarity = ((BaseUnityPlugin)this).Config.Bind<string>("General", "SpawnRarity", "Modded:40,ExperimentationLevel:20,AssuranceLevel:20,VowLevel:20,OffenseLevel:25,MarchLevel:25,RendLevel:30,DineLevel:30,TitanLevel:50,Adamance:50,Embrion:50,Artifice:55", "Chance for Country road creature to spawn for any moon, example => assurance:100,offense:50 . You need to restart the game."); CreateStringConfig(spawnMoonRarity, requireRestart: true); maxCountryRoadCreatureSpawnNb = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxSpawnNumber", 1, "Max country road creatures spawn number. You need to restart the game."); CreateIntConfig(maxCountryRoadCreatureSpawnNb); handScrapMoonRarity = ((BaseUnityPlugin)this).Config.Bind<string>("General", "HandScrapSpawnRarity", "Modded:30,ExperimentationLevel:20,AssuranceLevel:20,VowLevel:25,OffenseLevel:25,MarchLevel:30,RendLevel:35,DineLevel:35,TitanLevel:35,Adamance:35,Embrion:35,Artifice:40", "Chance for creature hand scrap to spawn for any moon, example => assurance:100,offense:50 . You need to restart the game."); CreateStringConfig(handScrapMoonRarity, requireRestart: true); headScrapMoonRarity = ((BaseUnityPlugin)this).Config.Bind<string>("General", "HeadScrapSpawnRarity", "Modded:10,ExperimentationLevel:5,AssuranceLevel:5,VowLevel:10,OffenseLevel:10,MarchLevel:10,RendLevel:13,DineLevel:13,TitanLevel:15,Adamance:15,Embrion:20,Artifice:22", "Chance for creature head scrap to spawn for any moon, example => assurance:100,offense:50 . You need to restart the game."); CreateStringConfig(headScrapMoonRarity, requireRestart: true); scrapHitPlayerChance = ((BaseUnityPlugin)this).Config.Bind<int>("General", "HeadScrapHitPlayerChance", 10, "Chance for creature head scrap item to hit player after lights animation. You don't need to restart the game."); CreateIntConfig(scrapHitPlayerChance); countryRoadBaseSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("MonsterBehavior", "CountryRoadBaseSpeed", 3.33f, "Country road Creature base speed. You don't need to restart the game."); CreateFloatConfig(countryRoadBaseSpeed); countryRoadMaxSpeedMutliplier = ((BaseUnityPlugin)this).Config.Bind<float>("MonsterBehavior", "CountryRoadMaxSpeedMultiplier", 2.4f, "Country road Creature max speed multiplier, based on his angry gauge. You don't need to restart the game."); CreateFloatConfig(countryRoadMaxSpeedMutliplier, 1f, 50f); } private void RegisterMonster(AssetBundle bundle) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown EnemyType val = bundle.LoadAsset<EnemyType>("Assets/LethalCompany/Mods/CountryRoadCreature/CountryRoadCreature.asset"); val.MaxCount = maxCountryRoadCreatureSpawnNb.Value; ((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val).name + " FOUND")); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"{val.enemyPrefab} prefab"); NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab); Utilities.FixMixerGroups(val.enemyPrefab); TerminalNode val2 = new TerminalNode(); val2.creatureName = "CountryRoadCreature"; val2.displayText = "Run."; TerminalKeyword val3 = new TerminalKeyword(); val3.word = "CountryRoadCreature"; RegisterUtil.RegisterEnemyWithConfig(spawnMoonRarity.Value, val, val2, val3, val.PowerLevel, val.MaxCount); } private void RegisterScrap(AssetBundle bundle) { Item val = bundle.LoadAsset<Item>("Assets/LethalCompany/Mods/CountryRoadCreature/CountryRoadCreatureScrap.asset"); ((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val).name + " FOUND")); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"{val.spawnPrefab} prefab"); NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab); Utilities.FixMixerGroups(val.spawnPrefab); RegisterUtil.RegisterScrapWithConfig(headScrapMoonRarity.Value, val); Item val2 = bundle.LoadAsset<Item>("Assets/LethalCompany/Mods/CountryRoadCreature/CountryRoadCreatureHandScrap.asset"); ((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)val2).name + " FOUND")); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"{val2.spawnPrefab} prefab"); NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab); Utilities.FixMixerGroups(val2.spawnPrefab); RegisterUtil.RegisterScrapWithConfig(handScrapMoonRarity.Value, val2); } private void CreateFloatConfig(ConfigEntry<float> configEntry, float min = 0f, float max = 100f) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown FloatSliderOptions val = new FloatSliderOptions(); ((BaseRangeOptions<float>)val).Min = min; ((BaseRangeOptions<float>)val).Max = max; ((BaseOptions)val).RequiresRestart = false; FloatSliderConfigItem val2 = new FloatSliderConfigItem(configEntry, val); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2); } private void CreateIntConfig(ConfigEntry<int> configEntry, int min = 0, int max = 100) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown IntSliderOptions val = new IntSliderOptions(); ((BaseRangeOptions<int>)val).Min = min; ((BaseRangeOptions<int>)val).Max = max; ((BaseOptions)val).RequiresRestart = false; IntSliderConfigItem val2 = new IntSliderConfigItem(configEntry, val); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2); } private void CreateStringConfig(ConfigEntry<string> configEntry, bool requireRestart = false) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown TextInputFieldConfigItem val = new TextInputFieldConfigItem(configEntry, new TextInputFieldOptions { RequiresRestart = requireRestart }); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val); } } public static class PluginInfo { public const string PLUGIN_GUID = "CountryRoadCreature"; public const string PLUGIN_NAME = "CountryRoadCreature"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace CountryRoadCreature.Scripts { public class CountryRoadCreatureEnemyAI : EnemyAI { [CompilerGenerated] private sealed class <ParanoidAnimation>d__43 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CountryRoadCreatureEnemyAI <>4__this; private List<Light> <closeLights>5__1; private List<Light>.Enumerator <>s__2; private Light <closeObject>5__3; private LightInformation <lightInformation>5__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ParanoidAnimation>d__43(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <closeLights>5__1 = null; <>s__2 = default(List<Light>.Enumerator); <closeObject>5__3 = null; <lightInformation>5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Expected O, but got Unknown //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Expected O, but got Unknown //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Expected O, but got Unknown //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Expected O, but got Unknown //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Expected O, but got Unknown //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Expected O, but got Unknown //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Expected O, but got Unknown //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Expected O, but got Unknown //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Expected O, but got Unknown //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this.lights.Clear(); <closeLights>5__1 = Object.FindObjectsByType<Light>((FindObjectsSortMode)0).ToList().FindAll((Light light) => Vector3.Distance(((Component)light).transform.position, ((Component)<>4__this).transform.position) < 20f && Object.op_Implicit((Object)(object)light)); <>s__2 = <closeLights>5__1.GetEnumerator(); try { while (<>s__2.MoveNext()) { <closeObject>5__3 = <>s__2.Current; <lightInformation>5__4 = new LightInformation(); <lightInformation>5__4.Light = <closeObject>5__3; <lightInformation>5__4.color = <closeObject>5__3.color; <>4__this.lights.Add(<lightInformation>5__4); <lightInformation>5__4 = null; <closeObject>5__3 = null; } } finally { ((IDisposable)<>s__2).Dispose(); } <>s__2 = default(List<Light>.Enumerator); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 1f)); <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this.creatureObject.SetActive(false); <>4__this.ActiveLightList(active: true); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 1.2f)); <>1__state = 2; return true; case 2: <>1__state = -1; <>4__this.creatureObject.SetActive(true); <>4__this.ActiveLightList(active: false); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 1.5f)); <>1__state = 3; return true; case 3: <>1__state = -1; <>4__this.creatureObject.SetActive(false); <>4__this.ActiveLightList(active: true); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 2f)); <>1__state = 4; return true; case 4: <>1__state = -1; <>4__this.creatureObject.SetActive(true); <>4__this.ActiveLightList(active: false); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 2.1f)); <>1__state = 5; return true; case 5: <>1__state = -1; <>4__this.creatureObject.SetActive(false); <>4__this.ActiveLightList(active: true); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 2.2f)); <>1__state = 6; return true; case 6: <>1__state = -1; <>4__this.creatureObject.SetActive(true); <>4__this.ActiveLightList(active: false); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 2.3f)); <>1__state = 7; return true; case 7: <>1__state = -1; <>4__this.creatureObject.SetActive(false); <>4__this.ActiveLightList(active: true); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 2.4f)); <>1__state = 8; return true; case 8: <>1__state = -1; <>4__this.creatureObject.SetActive(true); <>4__this.ActiveLightList(active: false); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 2.5f)); <>1__state = 9; return true; case 9: <>1__state = -1; <>4__this.creatureObject.SetActive(false); <>4__this.ActiveLightList(active: false); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > <>4__this.monsterLookPlayerTime)); <>1__state = 10; return true; case 10: <>1__state = -1; <>4__this.creatureObject.SetActive(true); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 11; return true; case 11: <>1__state = -1; <>4__this.ActiveLightList(active: true); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public AudioClip seePlayerSound; public List<AudioClip> walkSounds; public AudioClip screamSound; public AudioClip runSound; public AudioSource walkSource; public GameObject creatureObject; public Transform grabPosition; private static readonly int walk = Animator.StringToHash("walk"); private static readonly int grab = Animator.StringToHash("grab"); private static readonly int walkSpeed = Animator.StringToHash("walkSpeed"); private static readonly int stun = Animator.StringToHash("stun"); public float aiInterval; public int lastBehaviorState; private float lookAtPlayerTimer; private float monsterRunTimer; private float walkSoundTimer; private float animationParanoidTimer; private float animationGrabTimer; private float lostPlayerTimer; private float stunedTimer; private bool isLookingAtPlayer = false; private bool isRunningToPlayer = false; private bool isWalking = false; private bool isStuned = false; private float monsterAngryValue = 0f; private float monsterSpeedMultiplier = 1f; private float monsterLookPlayerTime = 2.5f; private float monsterRunToPlayerTime = 5f; private float monsterGrabTime = 3f; private float lostPlayerTime = 2f; private float stunTime = 1.25f; private float speed = 3.33f; private float normalAcceleration = 255f; private float angularSpeed = 900f; private float visionWidth = 60f; private float maxSpeed = 2f; private float timeBetweenWalkSound = 0.75f; private PlayerControllerB playerToKIll = null; private List<LightInformation> lights = new List<LightInformation>(); private bool playerToKillIsLocal; private void AddAngryValue(float value) { monsterAngryValue = Mathf.Clamp(monsterAngryValue += value, 0f, 100f); monsterSpeedMultiplier = 1f + maxSpeed * (monsterAngryValue / 100f); } private void WalkingSound() { if (walkSoundTimer <= 0f) { walkSource.clip = walkSounds[Random.Range(0, walkSounds.Count)]; walkSource.Play(); walkSoundTimer = timeBetweenWalkSound / Mathf.Clamp(monsterSpeedMultiplier, 1f, 1.3f); } } private void ActiveLightList(bool active) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) foreach (LightInformation light in lights) { float num = Random.Range(0.1f, 0.5f); light.Light.color = (Color)(active ? light.color : new Color(num, 0f, 0f)); } } [IteratorStateMachine(typeof(<ParanoidAnimation>d__43))] private IEnumerator ParanoidAnimation() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ParanoidAnimation>d__43(0) { <>4__this = this }; } public override void Start() { speed = CountryRoadCreaturePlugin.instance.countryRoadBaseSpeed.Value; maxSpeed = CountryRoadCreaturePlugin.instance.countryRoadMaxSpeedMutliplier.Value - 1f; ((EnemyAI)this).Start(); AllClientOnSwitchBehaviorState(); base.agent.angularSpeed = angularSpeed; } public override void Update() { //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).Update(); aiInterval -= Time.deltaTime; walkSoundTimer -= Time.deltaTime; animationGrabTimer -= Time.deltaTime; if (isStuned) { stunedTimer -= Time.deltaTime; } if (isLookingAtPlayer) { lookAtPlayerTimer -= Time.deltaTime; animationParanoidTimer += Time.deltaTime; } if (isRunningToPlayer) { monsterRunTimer -= Time.deltaTime; } if (isWalking) { lostPlayerTimer -= Time.deltaTime; WalkingSound(); } if (isStuned) { isStuned = stunedTimer > 0f; } if (lastBehaviorState != base.currentBehaviourStateIndex) { lastBehaviorState = base.currentBehaviourStateIndex; AllClientOnSwitchBehaviorState(); } if (isRunningToPlayer && GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 0.25f, 100f, 60, -1f, -1)) { GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(0.8f, true); } if (base.currentBehaviourStateIndex == 3) { GrabAnimation(); } if (aiInterval <= 0f && ((NetworkBehaviour)this).IsOwner) { aiInterval = base.AIIntervalTime; ((EnemyAI)this).DoAIInterval(); } } public override void DoAIInterval() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).DoAIInterval(); switch (base.currentBehaviourStateIndex) { case 0: if (lostPlayerTimer <= 0f) { ((EnemyAI)this).TargetClosestPlayer(1.5f, true, visionWidth, false, false, true); } if ((Object)(object)base.targetPlayer == (Object)null) { if (!base.currentSearch.inProgress) { AISearchRoutine val = new AISearchRoutine(); val.searchWidth = 200f; val.searchPrecision = 8f; ((EnemyAI)this).StartSearch(((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)this).transform.position, true, 0, false, 50, -1).position, val); } } else if (((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true)) { lookAtPlayerTimer = monsterLookPlayerTime; ((EnemyAI)this).SwitchToBehaviourState(1); } break; case 1: base.currentSearch.inProgress = false; if (lookAtPlayerTimer > 0f) { ((Component)this).transform.LookAt(((Component)base.targetPlayer).transform); } else if (((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true)) { monsterRunTimer = monsterRunToPlayerTime; ((EnemyAI)this).SwitchToBehaviourState(2); } else { ((EnemyAI)this).SwitchToBehaviourState(0); } break; case 2: if (monsterRunTimer <= 0f) { ((EnemyAI)this).TargetClosestPlayer(1.5f, true, visionWidth, false, false, true); if ((Object)(object)base.targetPlayer != (Object)null) { monsterRunTimer += 1f; break; } lostPlayerTimer = lostPlayerTime; ((EnemyAI)this).SwitchToBehaviourState(0); } else if ((Object)(object)base.targetPlayer != (Object)null && ((EnemyAI)this).PlayerIsTargetable(base.targetPlayer, false, false, true)) { ((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer); } break; case 3: if (!(animationGrabTimer <= 0f)) { base.targetPlayer = null; } break; case 4: Debug.Log((object)$"IS STUNED {isStuned}"); if (!isStuned) { monsterRunTimer = monsterRunToPlayerTime; ((EnemyAI)this).SwitchToBehaviourState(2); } break; } } private void LateUpdate() { //IL_0051: 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) if ((Object)(object)playerToKIll != (Object)null && animationGrabTimer > 0f && (Object)(object)base.inSpecialAnimationWithPlayer != (Object)null && !isStuned) { ((Component)base.inSpecialAnimationWithPlayer.gameplayCamera).transform.rotation = grabPosition.rotation; base.inSpecialAnimationWithPlayer.cameraContainerTransform.rotation = grabPosition.rotation; } } private void CancelPlayerEffects() { if ((Object)(object)playerToKIll != (Object)null) { playerToKIll.disableMoveInput = false; playerToKIll.disableLookInput = false; playerToKIll.inAnimationWithEnemy = null; playerToKIll.isInElevator = false; playerToKIll.disableInteract = false; playerToKIll.isInHangarShipRoom = false; } if (playerToKillIsLocal) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; localPlayerController.disableMoveInput = false; localPlayerController.disableLookInput = false; localPlayerController.inAnimationWithEnemy = null; localPlayerController.isInElevator = false; localPlayerController.disableInteract = false; localPlayerController.isInHangarShipRoom = false; } base.inSpecialAnimationWithPlayer = null; base.inSpecialAnimation = false; } private void GrabAnimation() { //IL_0091: 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_00e0: 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_00f0: Unknown result type (might be due to invalid IL or missing references) base.targetPlayer = null; if ((Object)(object)playerToKIll == (Object)null || !playerToKillIsLocal) { return; } if (animationGrabTimer > 0f) { base.inSpecialAnimation = true; playerToKIll.disableMoveInput = true; playerToKIll.disableLookInput = true; playerToKIll.disableInteract = true; base.inSpecialAnimationWithPlayer = playerToKIll; playerToKIll.inAnimationWithEnemy = (EnemyAI)(object)this; ((Component)playerToKIll).transform.position = grabPosition.position; ((Component)playerToKIll).transform.rotation = grabPosition.rotation; } else { ((EnemyAI)this).SwitchToBehaviourServerRpc(0); CancelPlayerEffects(); if (playerToKillIsLocal) { GameNetworkManager.Instance.localPlayerController.KillPlayer(Vector3.zero, false, (CauseOfDeath)8, 0, default(Vector3), false); playerToKillIsLocal = false; } playerToKIll = null; } } public void AllClientOnSwitchBehaviorState() { //IL_012e: 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_02ca: Unknown result type (might be due to invalid IL or missing references) base.agent.speed = speed * monsterSpeedMultiplier; base.agent.acceleration = normalAcceleration; switch (base.currentBehaviourStateIndex) { case 0: lostPlayerTimer = lostPlayerTime; isLookingAtPlayer = false; isRunningToPlayer = false; isWalking = true; base.creatureAnimator.SetBool(walk, true); base.creatureAnimator.SetBool(grab, false); base.creatureAnimator.SetBool(stun, false); base.creatureAnimator.SetFloat(walkSpeed, 1f); break; case 1: monsterRunTimer = monsterRunToPlayerTime; base.agent.speed = 0f; base.creatureVoice.clip = seePlayerSound; base.creatureVoice.Play(); lookAtPlayerTimer = monsterLookPlayerTime; isLookingAtPlayer = true; isWalking = false; animationParanoidTimer = 0f; base.agent.velocity = Vector3.zero; AddAngryValue(15f); base.creatureAnimator.SetBool(walk, false); base.creatureAnimator.SetBool(grab, false); base.creatureAnimator.SetBool(stun, false); ((MonoBehaviour)this).StartCoroutine(ParanoidAnimation()); break; case 2: base.creatureVoice.clip = runSound; base.creatureVoice.Play(); monsterRunTimer = monsterRunToPlayerTime; isRunningToPlayer = true; base.creatureAnimator.SetBool(walk, true); base.creatureAnimator.SetBool(grab, false); base.creatureAnimator.SetBool(stun, false); base.creatureAnimator.SetFloat(walkSpeed, Mathf.Clamp(monsterSpeedMultiplier, 1f, 1.5f)); isWalking = true; break; case 3: AddAngryValue(100f); base.agent.speed = 0f; base.agent.velocity = Vector3.zero; animationGrabTimer = monsterGrabTime; base.creatureVoice.clip = screamSound; base.creatureVoice.Play(); base.creatureAnimator.SetBool(grab, true); base.creatureAnimator.SetBool(stun, false); break; case 4: AddAngryValue(100f); base.agent.speed = 0f; base.agent.velocity = Vector3.zero; base.creatureVoice.clip = screamSound; base.creatureVoice.Play(); base.creatureAnimator.SetBool(stun, true); isRunningToPlayer = false; monsterRunTimer = monsterRunToPlayerTime; break; } } public override void OnCollideWithPlayer(Collider other) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0083: 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_008c: 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_0095: 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 (!((Object)(object)playerToKIll != (Object)null) && !isStuned && !(animationGrabTimer > 0f)) { animationGrabTimer = monsterGrabTime; PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, true); if ((Object)(object)val != (Object)null) { ((EnemyAI)this).SwitchToBehaviourServerRpc(3); playerToKillIsLocal = true; playerToKIll = val; playerToKIll.DropAllHeldItems(true, false, false, false, default(Vector3), default(Vector3), default(Vector3), default(Vector3), default(Vector3)); } ((EnemyAI)this).PlayAnimationOfCurrentState(); } } public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { if (!isStuned) { animationGrabTimer = 0.75f; CancelPlayerEffects(); playerToKIll = null; playerToKillIsLocal = false; stunedTimer = stunTime; isStuned = true; base.targetPlayer = playerWhoHit; ((EnemyAI)this).SwitchToBehaviourServerRpc(4); } } } public class CountryRoadCreatureHeadItem : NoisemakerProp { [CompilerGenerated] private sealed class <ParanoidAnimation>d__10 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public CountryRoadCreatureHeadItem <>4__this; private List<Light> <closeLights>5__1; private bool <canHitPlayerValue>5__2; private bool <hitPlayer>5__3; private List<Light>.Enumerator <>s__4; private Light <closeObject>5__5; private LightInformation <lightInformation>5__6; private int <instanceId>5__7; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ParanoidAnimation>d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <closeLights>5__1 = null; <>s__4 = default(List<Light>.Enumerator); <closeObject>5__5 = null; <lightInformation>5__6 = null; <>1__state = -2; } private bool MoveNext() { //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Expected O, but got Unknown //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Expected O, but got Unknown //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Expected O, but got Unknown //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Expected O, but got Unknown //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Expected O, but got Unknown //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Expected O, but got Unknown //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Expected O, but got Unknown //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Expected O, but got Unknown //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this.lights.Clear(); <closeLights>5__1 = Object.FindObjectsByType<Light>((FindObjectsSortMode)0).ToList().FindAll((Light light) => Vector3.Distance(((Component)light).transform.position, ((Component)<>4__this).transform.position) < 15f && Object.op_Implicit((Object)(object)light)); <>s__4 = <closeLights>5__1.GetEnumerator(); try { while (<>s__4.MoveNext()) { <closeObject>5__5 = <>s__4.Current; <lightInformation>5__6 = new LightInformation(); <lightInformation>5__6.Light = <closeObject>5__5; <lightInformation>5__6.color = <closeObject>5__5.color; <instanceId>5__7 = ((Object)<closeObject>5__5).GetInstanceID(); if (CountryRoadCreaturePlugin.instance.lightsInUse.ContainsKey(<instanceId>5__7)) { <>4__this.lights.Add(CountryRoadCreaturePlugin.instance.lightsInUse[<instanceId>5__7]); } else { CountryRoadCreaturePlugin.instance.lightsInUse.Add(<instanceId>5__7, <lightInformation>5__6); <>4__this.lights.Add(<lightInformation>5__6); } <lightInformation>5__6 = null; <closeObject>5__5 = null; } } finally { ((IDisposable)<>s__4).Dispose(); } <>s__4 = default(List<Light>.Enumerator); <>4__this.ActiveLightList(active: true); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 1f)); <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this.ActiveLightList(active: true); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 1.2f)); <>1__state = 2; return true; case 2: <>1__state = -1; <>4__this.ActiveLightList(active: false); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 1.5f)); <>1__state = 3; return true; case 3: <>1__state = -1; <>4__this.ActiveLightList(active: true); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 2f)); <>1__state = 4; return true; case 4: <>1__state = -1; <>4__this.ActiveLightList(active: false); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 2.1f)); <>1__state = 5; return true; case 5: <>1__state = -1; <>4__this.ActiveLightList(active: true); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 2.2f)); <>1__state = 6; return true; case 6: <>1__state = -1; <>4__this.ActiveLightList(active: false); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 2.3f)); <>1__state = 7; return true; case 7: <>1__state = -1; <>4__this.ActiveLightList(active: true); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 2.4f)); <>1__state = 8; return true; case 8: <>1__state = -1; <>4__this.ActiveLightList(active: false); <>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.animationParanoidTimer > 2.5f)); <>1__state = 9; return true; case 9: <>1__state = -1; <>4__this.ActiveLightList(active: false); <>2__current = (object)new WaitForSeconds(2f); <>1__state = 10; return true; case 10: <>1__state = -1; <canHitPlayerValue>5__2 = (Object)(object)((GrabbableObject)<>4__this).playerHeldBy != (Object)null && <>4__this.canHitPlayer; <hitPlayer>5__3 = (Random.Range(0, 100) < <>4__this.hitPlayerChance) & <canHitPlayerValue>5__2; if (!<hitPlayer>5__3) { <>4__this.ActiveLightList(active: true); <>4__this.animationPlaying = false; break; } GameNetworkManager.Instance.localPlayerController.DamagePlayer(15, true, true, (CauseOfDeath)0, 0, false, default(Vector3)); <>4__this.laughtAudioSource.Play(); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 11; return true; case 11: <>1__state = -1; <>4__this.animationPlaying = false; <>4__this.ActiveLightList(active: true); break; } <>4__this.lights.ForEach(delegate(LightInformation l) { CountryRoadCreaturePlugin.instance.lightsInUse.Remove(((Object)l.Light).GetInstanceID()); }); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public AudioSource hitPlayerAudioSource; public AudioSource laughtAudioSource; private List<LightInformation> lights = new List<LightInformation>(); private float animationParanoidTimer; private bool animationPlaying; private int hitPlayerChance = 10; public bool canHitPlayer; public override void Start() { ((NoisemakerProp)this).Start(); hitPlayerChance = CountryRoadCreaturePlugin.instance.scrapHitPlayerChance.Value; } private void ActiveLightList(bool active) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) foreach (LightInformation light in lights) { float num = Random.Range(0.1f, 0.5f); light.Light.color = (Color)(active ? light.color : new Color(num, 0f, 0f)); } } public override void Update() { ((GrabbableObject)this).Update(); if (animationPlaying) { animationParanoidTimer += Time.deltaTime; } } [IteratorStateMachine(typeof(<ParanoidAnimation>d__10))] private IEnumerator ParanoidAnimation() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ParanoidAnimation>d__10(0) { <>4__this = this }; } public override void ItemActivate(bool used, bool buttonDown = true) { canHitPlayer = (Object)(object)((GrabbableObject)this).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController; if (!animationPlaying) { animationPlaying = true; animationParanoidTimer = 0f; ((MonoBehaviour)this).StartCoroutine(ParanoidAnimation()); } ((NoisemakerProp)this).ItemActivate(used, buttonDown); } } public class LightInformation { public Light Light; public Color color; } }