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 ShyGuy v1.0.0
plugins/ShyGuy.dll
Decompiled 19 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.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 HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using REPOLib.Objects.Sdk; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ShyGuy")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ShyGuy")] [assembly: AssemblyTitle("ShyGuy")] [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 ShyGuy { [HarmonyPatch] internal static class Patches { [HarmonyPatch(typeof(EnemyDirector), "Awake")] [HarmonyPrefix] [HarmonyPriority(800)] private static void BuildBeforeDirector(EnemyDirector __instance) { try { ShyBuilder.BuildAndRegister(__instance); } catch (Exception ex) { Plugin.Log.LogError((object)("Failed to build the Shy Guy: " + ex)); } } [HarmonyPatch(typeof(EnemyDirector), "AmountSetup")] [HarmonyPostfix] private static void ForceShyGuy(EnemyDirector __instance) { if (Plugin.AlwaysSpawn.Value && !((Object)(object)ShyBuilder.Setup == (Object)null)) { List<EnemySetup> enemyList = __instance.enemyList; int enemyListIndex = __instance.enemyListIndex; if (enemyListIndex < enemyList.Count) { enemyList[enemyListIndex] = ShyBuilder.Setup; return; } enemyList.Add(ShyBuilder.Setup); __instance.totalAmount++; } } } [BepInPlugin("bigbootyteam.shyguy", "ShyGuy", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "bigbootyteam.shyguy"; public const string Name = "ShyGuy"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static string Folder; internal static ConfigEntry<int> Health; internal static ConfigEntry<float> RageSeconds; internal static ConfigEntry<float> ChaseSpeed; internal static ConfigEntry<int> HitDamage; internal static ConfigEntry<bool> InstantKill; internal static ConfigEntry<bool> SmashDoors; internal static ConfigEntry<int> Difficulty; internal static ConfigEntry<float> Rarity; internal static ConfigEntry<bool> AlwaysSpawn; internal static readonly Fixed<float> Size = new Fixed<float>(1.2f); internal static readonly Fixed<float> ArmLength = new Fixed<float>(1.2f); internal static readonly Fixed<float> EyeGlow = new Fixed<float>(1f); internal static readonly Fixed<bool> SmoothModel = new Fixed<bool>(value: true); internal static readonly Fixed<float> SurfaceDetail = new Fixed<float>(1f); internal static readonly Fixed<float> RimLight = new Fixed<float>(0.3f); internal static readonly Fixed<float> CryDistance = new Fixed<float>(35f); internal static readonly Fixed<float> HurtRageSeconds = new Fixed<float>(3f); internal static readonly Fixed<float> WalkSpeed = new Fixed<float>(1.2f); internal static readonly Fixed<float> TriggerDistance = new Fixed<float>(18f); internal static readonly Fixed<bool> NeedsLight = new Fixed<bool>(value: true); internal static readonly Fixed<float> DarkSightDistance = new Fixed<float>(6f); internal static readonly Fixed<float> LookTimeCentre = new Fixed<float>(0.25f); internal static readonly Fixed<float> LookTimeEdge = new Fixed<float>(1.5f); internal static readonly Fixed<float> CooldownSeconds = new Fixed<float>(5f); internal static readonly Fixed<float> CalmSeconds = new Fixed<float>(20f); internal static readonly Fixed<float> HitInterval = new Fixed<float>(0.6f); internal static readonly Fixed<float> KnockForce = new Fixed<float>(65f); internal static readonly Fixed<float> HitRecoverySeconds = new Fixed<float>(1f); internal static readonly Fixed<float> StayOutMinutes = new Fixed<float>(4f); internal static readonly Fixed<float> AwayMinutes = new Fixed<float>(1.5f); private void Awake() { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Expected O, but got Unknown //IL_01e3: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); Health = ((BaseUnityPlugin)this).Config.Bind<int>("Shy Guy", "Health", 600, new ConfigDescription("How much damage it takes to kill him.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(50, 5000), Array.Empty<object>())); RageSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Shy Guy", "WindUpSeconds", 10f, new ConfigDescription("How long he screams after someone sees his face before he comes for them.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>())); ChaseSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Shy Guy", "ChaseSpeed", 7.5f, new ConfigDescription("How fast he runs while chasing (players sprint at about 5-6).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 20f), Array.Empty<object>())); HitDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Shy Guy", "HitDamage", 30, new ConfigDescription("Damage per hit (players start with 100 health).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 200), Array.Empty<object>())); InstantKill = ((BaseUnityPlugin)this).Config.Bind<bool>("Shy Guy", "InstantKill", false, "If true, his first hit kills."); SmashDoors = ((BaseUnityPlugin)this).Config.Bind<bool>("Shy Guy", "SmashDoors", true, "Does he smash through doors and props while chasing?"); Difficulty = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "DifficultyTier", 3, new ConfigDescription("Which enemy tier he spawns in (1 = weakest, 3 = strongest).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), Array.Empty<object>())); Rarity = ((BaseUnityPlugin)this).Config.Bind<float>("Spawning", "Rarity", 60f, new ConfigDescription("How likely he is to be picked in his tier (most vanilla enemies use 100).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>())); AlwaysSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Testing", "AlwaysSpawn", false, "If true, every level has a Shy Guy."); ShyAssets.LoadSounds((MonoBehaviour)(object)this); new Harmony("bigbootyteam.shyguy").PatchAll(typeof(Patches)); Log.LogInfo((object)"ShyGuy 1.0.0 loaded."); } } internal sealed class Fixed<T> { public readonly T Value; public Fixed(T value) { Value = value; } } internal static class ShyAssets { public static AudioClip Crying; public static AudioClip DocileToRage; public static AudioClip RageLoop; public static AudioClip RageToDocile; public static AudioClip Jumpscare; public static AudioClip EnragingTarget; public static AudioClip EnragingNonTarget; public static AudioClip ChaseTarget; public static AudioClip ChaseNonTarget; public static AudioClip Hit; public static AudioClip Hurt; public static AudioClip Killed; private static float loadStarted = -100f; private static bool loadDone; public static bool Loading { get { if (Time.realtimeSinceStartup - loadStarted < 15f) { return !loadDone; } return false; } } public static byte[] Embedded(string name) { using Stream stream = typeof(ShyAssets).Assembly.GetManifestResourceStream("ShyGuy." + name); if (stream == null) { throw new FileNotFoundException("Embedded resource missing: " + name); } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } public static Texture2D Texture(string name) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true) { name = "ShyGuy " + name }; ImageConversion.LoadImage(val, Embedded(name)); ((Texture)val).wrapMode = (TextureWrapMode)0; ((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x20); return val; } public static void LoadSounds(MonoBehaviour host) { loadStarted = Time.realtimeSinceStartup; loadDone = false; host.StartCoroutine(LoadAll()); } private static IEnumerator LoadAll() { string dir = Path.Combine(Plugin.Folder, "sounds"); yield return Load(dir, "crying.ogg", delegate(AudioClip c) { Crying = c; }); yield return Load(dir, "sl_docile_to_rage.ogg", delegate(AudioClip c) { DocileToRage = c; }); yield return Load(dir, "sl_rage_loop.ogg", delegate(AudioClip c) { RageLoop = c; }); yield return Load(dir, "sl_rage_to_docile.ogg", delegate(AudioClip c) { RageToDocile = c; }); yield return Load(dir, "sl_target_jumpscare.ogg", delegate(AudioClip c) { Jumpscare = c; }); yield return Load(dir, "sl_enraging_target.ogg", delegate(AudioClip c) { EnragingTarget = c; }); yield return Load(dir, "sl_enraging_nontarget.ogg", delegate(AudioClip c) { EnragingNonTarget = c; }); yield return Load(dir, "sl_chase_target.ogg", delegate(AudioClip c) { ChaseTarget = c; }); yield return Load(dir, "sl_chase_nontarget.ogg", delegate(AudioClip c) { ChaseNonTarget = c; }); yield return Load(dir, "sl_hit.ogg", delegate(AudioClip c) { Hit = c; }); yield return Load(dir, "sl_hurt.ogg", delegate(AudioClip c) { Hurt = c; }); yield return Load(dir, "sl_killed.ogg", delegate(AudioClip c) { Killed = c; }); loadDone = true; Plugin.Log.LogDebug((object)$"Sounds loaded: {((IEnumerable<AudioClip>)(object)new AudioClip[12] { Crying, DocileToRage, RageLoop, RageToDocile, Jumpscare, EnragingTarget, EnragingNonTarget, ChaseTarget, ChaseNonTarget, Hit, Hurt, Killed }).Count((AudioClip c) => Object.op_Implicit((Object)(object)c))} of 12."); } private static IEnumerator Load(string dir, string file, Action<AudioClip> set) { string text = Path.Combine(dir, file); if (!File.Exists(text)) { Plugin.Log.LogWarning((object)("Sound missing: " + text)); yield break; } UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip("file:///" + text.Replace('\\', '/'), (AudioType)14); try { yield return req.SendWebRequest(); if ((int)req.result != 1) { Plugin.Log.LogWarning((object)("Could not load " + file + ": " + req.error)); yield break; } AudioClip content = DownloadHandlerAudioClip.GetContent(req); ((Object)content).name = "ShyGuy " + file; ((Object)content).hideFlags = (HideFlags)(((Object)content).hideFlags | 0x20); set(content); } finally { ((IDisposable)req)?.Dispose(); } } } internal static class ShyBuilder { public const string PrefabName = "Enemy - Shy Guy"; public const float OriginalHeight = 2.4f; private static float restHeight = 6.5f; public static EnemySetup Setup; private static bool tried; public static void BuildAndRegister(EnemyDirector director) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Expected O, but got Unknown //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Expected O, but got Unknown //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Expected O, but got Unknown //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Expected O, but got Unknown //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Expected O, but got Unknown //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Expected O, but got Unknown //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Expected O, but got Unknown //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_0546: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Unknown result type (might be due to invalid IL or missing references) if (tried) { return; } tried = true; EnemySetup val = director.enemiesDifficulty1.Concat(director.enemiesDifficulty2).Concat(director.enemiesDifficulty3).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name.Contains("Robe"))); if ((Object)(object)val == (Object)null) { throw new Exception("Could not find REPO's Robe enemy to build on. The game may have been updated."); } GameObject? obj = val.spawnObjects.Select((PrefabRef r) => ((PrefabRef<GameObject>)(object)r)?.Prefab).FirstOrDefault((Func<GameObject, bool>)((GameObject p) => Object.op_Implicit((Object)(object)p) && Object.op_Implicit((Object)(object)p.GetComponent<EnemyParent>()))); if ((Object)(object)obj == (Object)null) { throw new Exception("The Robe enemy has no prefab."); } GameObject val2 = new GameObject("ShyGuy Prefabs"); val2.SetActive(false); ((Object)val2).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val2); GameObject val3 = Object.Instantiate<GameObject>(obj, val2.transform); ((Object)val3).name = "Enemy - Shy Guy"; EnemyParent component = val3.GetComponent<EnemyParent>(); Enemy componentInChildren = val3.GetComponentInChildren<Enemy>(true); EnemyRigidbody componentInChildren2 = val3.GetComponentInChildren<EnemyRigidbody>(true); if (!Object.op_Implicit((Object)(object)componentInChildren) || !Object.op_Implicit((Object)(object)componentInChildren2)) { throw new Exception("The Robe prefab is missing its Enemy or EnemyRigidbody."); } AudioMixerGroup mixer = (from a in val3.GetComponentsInChildren<AudioSource>(true) select a.outputAudioMixerGroup).FirstOrDefault((Func<AudioMixerGroup, bool>)((AudioMixerGroup g) => Object.op_Implicit((Object)(object)g))); Material baseMat = (from r in val3.GetComponentsInChildren<Renderer>(true) where !(r is ParticleSystemRenderer) select r.sharedMaterial).FirstOrDefault((Func<Material, bool>)((Material m) => Object.op_Implicit((Object)(object)m))); MonoBehaviour[] componentsInChildren = val3.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val4 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val4) && ((object)val4).GetType().Name.StartsWith("EnemyRobe")) { Object.DestroyImmediate((Object)(object)val4); } } Animator[] componentsInChildren2 = val3.GetComponentsInChildren<Animator>(true); for (int num = 0; num < componentsInChildren2.Length; num++) { ((Behaviour)componentsInChildren2[num]).enabled = false; } Renderer[] componentsInChildren3 = val3.GetComponentsInChildren<Renderer>(true); for (int num = 0; num < componentsInChildren3.Length; num++) { componentsInChildren3[num].enabled = false; } Light[] componentsInChildren4 = val3.GetComponentsInChildren<Light>(true); for (int num = 0; num < componentsInChildren4.Length; num++) { ((Behaviour)componentsInChildren4[num]).enabled = false; } AudioSource[] componentsInChildren5 = val3.GetComponentsInChildren<AudioSource>(true); for (int num = 0; num < componentsInChildren5.Length; num++) { componentsInChildren5[num].playOnAwake = false; } EnemyStateSpawn component2 = ((Component)componentInChildren).GetComponent<EnemyStateSpawn>(); if (Object.op_Implicit((Object)(object)component2)) { component2.OnSpawn = new UnityEvent(); } EnemyVision component3 = ((Component)componentInChildren).GetComponent<EnemyVision>(); if (Object.op_Implicit((Object)(object)component3)) { component3.onVisionTriggered = new UnityEvent(); } EnemyStateInvestigate component4 = ((Component)componentInChildren).GetComponent<EnemyStateInvestigate>(); if (Object.op_Implicit((Object)(object)component4)) { component4.onInvestigateTriggered = new UnityEvent(); } EnemyHealth component5 = ((Component)componentInChildren).GetComponent<EnemyHealth>(); if (Object.op_Implicit((Object)(object)component5)) { component5.onHurt = new UnityEvent(); component5.onDeathStart = new UnityEvent(); component5.onDeath = new UnityEvent(); component5.onObjectHurt = new UnityEvent(); component5.health = Plugin.Health.Value; component5.impactHurt = true; if (component5.impactLightDamage <= 0) { component5.impactLightDamage = 5; } if (component5.impactMediumDamage <= 0) { component5.impactMediumDamage = 15; } if (component5.impactHeavyDamage <= 0) { component5.impactHeavyDamage = 40; } Plugin.Log.LogDebug((object)$"Shy Guy health {component5.health}, slam damage {component5.impactLightDamage}/{component5.impactMediumDamage}/{component5.impactHeavyDamage}."); } ResetEvents(componentInChildren2); Animation anim; Transform head; float footLift; GameObject val5 = BuildModel(baseMat, out anim, out head, out footLift, ((Component)componentInChildren2).transform); if (Object.op_Implicit((Object)(object)component5)) { component5.meshParent = val5.transform; } AudioSource voice = NewSource(val5.transform, "Shy Voice", mixer, loop: true, 18f); AudioSource sting = NewSource(val5.transform, "Shy Sting", mixer, loop: false, 30f); AudioSource val6 = NewSource(val5.transform, "Shy Chase Music", mixer, loop: true, 30f); val6.spatialBlend = 0f; ShyGuyAI shyGuyAI = ((Component)componentInChildren).gameObject.AddComponent<ShyGuyAI>(); shyGuyAI.model = val5.transform; shyGuyAI.anim = anim; shyGuyAI.head = head; shyGuyAI.footLift = footLift; shyGuyAI.restHeight = restHeight; Vector3 centre; float num2 = MeasurePoseHeight(val5, anim, out centre); shyGuyAI.poseHeightPerScale = num2 / Mathf.Max(0.0001f, val5.transform.localScale.x); shyGuyAI.centerLocal = centre; shyGuyAI.runStride = Stride(val5, anim, "attackrun") / Mathf.Max(0.0001f, val5.transform.localScale.x); shyGuyAI.walkStride = Stride(val5, anim, "walk2") / Mathf.Max(0.0001f, val5.transform.localScale.x); RebuildBody(componentInChildren2, val5, num2); AddLimbColliders(val5.GetComponentInChildren<SkinnedMeshRenderer>(true), head); shyGuyAI.skin = val5.GetComponentInChildren<SkinnedMeshRenderer>(true); shyGuyAI.voice = voice; shyGuyAI.sting = sting; shyGuyAI.music = val6; component.enemyName = "Shy Guy"; component.enemyNameLocalized = null; component.difficulty = (Difficulty)(Mathf.Clamp(Plugin.Difficulty.Value, 1, 3) - 1); float num3 = Plugin.StayOutMinutes.Value * 60f; float num4 = Plugin.AwayMinutes.Value * 60f; component.SpawnedTimeMin = num3 * 0.75f; component.SpawnedTimeMax = num3 * 1.25f; component.DespawnedTimeMin = num4 * 0.67f; component.DespawnedTimeMax = num4 * 1.33f; Setup = Object.Instantiate<EnemySetup>(val); ((Object)Setup).name = "Enemy - Shy Guy"; RarityPreset val7 = ScriptableObject.CreateInstance<RarityPreset>(); ((Object)val7).name = "Rarity - Shy Guy"; val7.chance = Plugin.Rarity.Value; Setup.rarityPreset = val7; Object.DontDestroyOnLoad((Object)(object)Setup); Object.DontDestroyOnLoad((Object)(object)val7); EnemyContent val8 = ScriptableObject.CreateInstance<EnemyContent>(); AccessTools.Field(typeof(EnemyContent), "_setup").SetValue(val8, Setup); AccessTools.Field(typeof(EnemyContent), "_spawnObjects").SetValue(val8, new List<GameObject> { val3 }); Enemies.RegisterEnemy(val8); Plugin.Log.LogInfo((object)$"Registered the Shy Guy (difficulty tier {Plugin.Difficulty.Value})."); Plugin.Log.LogDebug((object)($"Shy Guy spawn rules: rarity {Plugin.Rarity.Value}, " + (Setup.levelsCompletedCondition ? string.Format("levels completed {0}-{1}", Setup.levelsCompletedMin, (Setup.levelsCompletedMax == 0) ? "any" : Setup.levelsCompletedMax.ToString()) : "any level") + $", needs {Setup.runsPlayed} runs played; stays out {component.SpawnedTimeMin:0}-{component.SpawnedTimeMax:0} s, away {component.DespawnedTimeMin:0}-{component.DespawnedTimeMax:0} s .")); } private static void ResetEvents(EnemyRigidbody rb) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown FieldInfo[] fields = typeof(EnemyRigidbody).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType == typeof(UnityEvent)) { fieldInfo.SetValue(rb, (object?)new UnityEvent()); } } } private static float Stride(GameObject model, Animation anim, string clipName) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) AnimationClip clip = anim.GetClip(clipName); SkinnedMeshRenderer componentInChildren = model.GetComponentInChildren<SkinnedMeshRenderer>(true); if (!Object.op_Implicit((Object)(object)clip) || !Object.op_Implicit((Object)(object)componentInChildren)) { return 0f; } Transform[] array = componentInChildren.bones.Where((Transform b) => Object.op_Implicit((Object)(object)b)).ToArray(); Vector3[,] array2 = new Vector3[32, array.Length]; for (int num = 0; num < 32; num++) { clip.SampleAnimation(model, clip.length * (float)num / 32f); for (int num2 = 0; num2 < array.Length; num2++) { array2[num, num2] = model.transform.InverseTransformPoint(array[num2].position); } } float num3 = float.MaxValue; Vector3[,] array3 = array2; foreach (Vector3 val in array3) { num3 = Mathf.Min(num3, val.y); } float num6 = 0f; for (int num7 = 0; num7 < array.Length; num7++) { float num8 = float.MaxValue; float num9 = float.MaxValue; float num10 = float.MinValue; for (int num11 = 0; num11 < 32; num11++) { num8 = Mathf.Min(num8, array2[num11, num7].y); num9 = Mathf.Min(num9, array2[num11, num7].z); num10 = Mathf.Max(num10, array2[num11, num7].z); } if (!(num8 - num3 > 0.6f)) { num6 = Mathf.Max(num6, num10 - num9); } } float num12 = num6 * 2f * model.transform.localScale.x; Plugin.Log.LogDebug((object)$"Shy Guy {clipName}: {num12:0.00} m per cycle ({clip.length:0.00} s)"); return num12; } private static float MeasurePoseHeight(GameObject model, Animation anim, out Vector3 centre) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: 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_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_0144: 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) SkinnedMeshRenderer componentInChildren = model.GetComponentInChildren<SkinnedMeshRenderer>(true); Mesh val = new Mesh(); List<Vector3> list = new List<Vector3>(); float num = 0f; float num2 = float.MaxValue; float num3 = float.MinValue; float num4 = float.MaxValue; float num5 = float.MinValue; string[] array = new string[2] { "walk2", "idle2" }; foreach (string text in array) { AnimationClip clip = anim.GetClip(text); if (!Object.op_Implicit((Object)(object)clip)) { continue; } for (int j = 0; j < 4; j++) { clip.SampleAnimation(model, clip.length * (float)j / 4f); componentInChildren.BakeMesh(val); val.GetVertices(list); Matrix4x4 val2 = Matrix4x4.TRS(((Component)componentInChildren).transform.position, ((Component)componentInChildren).transform.rotation, Vector3.one); float num6 = float.MaxValue; float num7 = float.MinValue; foreach (Vector3 item in list) { Vector3 val3 = ((Matrix4x4)(ref val2)).MultiplyPoint3x4(item); num6 = Mathf.Min(num6, val3.y); num7 = Mathf.Max(num7, val3.y); Vector3 val4 = model.transform.InverseTransformPoint(val3); num2 = Mathf.Min(num2, val4.x); num3 = Mathf.Max(num3, val4.x); num4 = Mathf.Min(num4, val4.z); num5 = Mathf.Max(num5, val4.z); } if (num7 > num6) { num = Mathf.Max(num, num7 - num6); } } } Object.Destroy((Object)(object)val); centre = (Vector3)((num2 < num3) ? new Vector3((num2 + num3) * 0.5f, 0f, (num4 + num5) * 0.5f) : Vector3.zero); ManualLogSource log = Plugin.Log; object arg = num; Vector3 val5 = model.transform.TransformVector(centre); log.LogDebug((object)$"Shy Guy walking height at build scale: {arg:0.00} m, body centre offset {((Vector3)(ref val5)).magnitude:0.00} m"); if (!(num > 0.1f)) { return 2.6f; } return num; } private static void RebuildBody(EnemyRigidbody erb, GameObject model, float poseHeight) { //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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_01ce: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)erb).transform; int num = -1; PhysicsMaterial sharedMaterial = null; Collider[] componentsInChildren = ((Component)transform).GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { if (((Component)val).transform.IsChildOf(model.transform)) { continue; } Plugin.Log.LogDebug((object)$"Robe collider: {((Object)val).name} ({((object)val).GetType().Name}) trigger={val.isTrigger} layer={LayerMask.LayerToName(((Component)val).gameObject.layer)} tag={((Component)val).tag}"); if (val.isTrigger || (Object)(object)val == (Object)(object)erb.playerCollision || !((Component)val).CompareTag("Phys Grab Object")) { continue; } if (num < 0) { num = ((Component)val).gameObject.layer; sharedMaterial = val.sharedMaterial; } GameObject gameObject = ((Component)val).gameObject; Object.DestroyImmediate((Object)(object)val); if (!Object.op_Implicit((Object)(object)gameObject.GetComponent<Collider>())) { PhysGrabObjectCollider component = gameObject.GetComponent<PhysGrabObjectCollider>(); if (Object.op_Implicit((Object)(object)component)) { Object.DestroyImmediate((Object)(object)component); } } } if (num < 0) { num = LayerMask.NameToLayer("PhysGrabObject"); } float num2 = Mathf.Clamp(poseHeight * 0.9f, 1.2f, 2f); GameObject val2 = new GameObject("Shy Body Collider") { layer = num, tag = "Phys Grab Object" }; val2.transform.SetParent(transform, false); CapsuleCollider obj = val2.AddComponent<CapsuleCollider>(); obj.direction = 1; obj.radius = 0.32f; obj.height = num2; obj.center = Vector3.zero; ((Collider)obj).sharedMaterial = sharedMaterial; val2.AddComponent<PhysGrabObjectCollider>(); erb.gravity = true; erb.stunFromFall = false; erb.grabStun = true; Rigidbody component2 = ((Component)transform).GetComponent<Rigidbody>(); if (Object.op_Implicit((Object)(object)component2)) { component2.centerOfMass = Vector3.zero; } Plugin.Log.LogDebug((object)$"Shy Guy body: capsule {num2:0.00} m tall."); } private static void AddLimbColliders(SkinnedMeshRenderer skin, Transform head) { //IL_009d: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_0180: 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_01a9: 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_01b5: 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_023b: Unknown result type (might be due to invalid IL or missing references) int num = LayerMask.NameToLayer("StaticGrabObject"); if (num < 0 || !Object.op_Implicit((Object)(object)skin)) { return; } HashSet<Transform> bones = new HashSet<Transform>(skin.bones.Where((Transform b) => Object.op_Implicit((Object)(object)b))); int num2 = 0; foreach (Transform item in bones) { if ((Object)(object)item == (Object)(object)head) { List<Transform> list = ((IEnumerable)item).Cast<Transform>().ToList(); Vector3 center = ((list.Count > 0) ? (list.Aggregate(Vector3.zero, (Vector3 acc, Transform k) => acc + k.localPosition) / (float)list.Count) : Vector3.zero); GameObject val = NewGrabPart(item, "Grab head", num); SphereCollider obj = val.AddComponent<SphereCollider>(); obj.center = center; obj.radius = 0.17f / Mathf.Max(0.0001f, val.transform.lossyScale.x); num2++; continue; } Transform val2 = ((IEnumerable)item).Cast<Transform>().FirstOrDefault((Func<Transform, bool>)((Transform c) => bones.Contains(c))); if (Object.op_Implicit((Object)(object)val2)) { float num3 = Vector3.Distance(item.position, val2.position); if (!(num3 < 0.1f)) { Vector3 localPosition = val2.localPosition; GameObject val3 = NewGrabPart(item, "Grab " + ((Object)item).name, num); val3.transform.localRotation = Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref localPosition)).normalized); float num4 = Mathf.Max(0.0001f, val3.transform.lossyScale.x); float num5 = Mathf.Clamp(num3 * 0.18f, 0.06f, 0.15f) / num4; CapsuleCollider obj2 = val3.AddComponent<CapsuleCollider>(); obj2.direction = 1; obj2.radius = num5; obj2.height = ((Vector3)(ref localPosition)).magnitude + num5 * 2f; obj2.center = new Vector3(0f, ((Vector3)(ref localPosition)).magnitude * 0.5f, 0f); num2++; } } } Plugin.Log.LogDebug((object)$"Shy Guy: {num2} grabbable body parts."); } private static GameObject NewGrabPart(Transform bone, string name, int layer) { //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_000d: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown GameObject val = new GameObject(name) { layer = layer, tag = "Phys Grab Object" }; val.transform.SetParent(bone, false); val.AddComponent<PhysGrabObjectCollider>(); return val; } private static GameObject BuildModel(Material baseMat, out Animation anim, out Transform head, out float footLift, Transform body) { //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05c9: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_05e0: Unknown result type (might be due to invalid IL or missing references) //IL_05fd: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Expected O, but got Unknown //IL_0695: Unknown result type (might be due to invalid IL or missing references) //IL_069c: Expected O, but got Unknown //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0273: 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_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0287: 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_0438: Unknown result type (might be due to invalid IL or missing references) B3DLoader.Result result = B3DLoader.Load(ShyAssets.Embedded("scp096.b3d"), "Shy Guy Model"); if (Plugin.SmoothModel.Value) { int num = result.Renderer.sharedMesh.triangles.Length / 3; result.Renderer.sharedMesh = MeshEnhance.Subdivide(result.Renderer.sharedMesh); Plugin.Log.LogDebug((object)$"Shy Guy model smoothed: {num} -> {result.Renderer.sharedMesh.triangles.Length / 3} triangles."); } GameObject root = result.Root; int layer = ((Component)body).gameObject.layer; Transform[] componentsInChildren = root.GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.layer = layer; } Texture2D val = ShyAssets.Texture("SCP096.jpg"); Texture2D val2 = ShyAssets.Texture("SCP096EYES.jpg"); Texture2D val3 = ((Plugin.SurfaceDetail.Value > 0f) ? MeshEnhance.NormalMapFrom(val, 2f) : null); Material[] array = (Material[])(object)new Material[result.SubmeshBrushes.Count]; for (int j = 0; j < array.Length; j++) { (int texture, Color color) tuple = result.SubmeshBrushes[j]; int item = tuple.texture; Color item2 = tuple.color; Texture2D val4 = ((item >= 0 && item < result.TextureFiles.Count && result.TextureFiles[item].ToUpperInvariant().Contains("EYES")) ? val2 : val); Material val5 = (Object.op_Implicit((Object)(object)baseMat) ? new Material(baseMat) : new Material(Shader.Find("Standard"))); ((Object)val5).name = "Shy Guy " + j; string[] array2 = new string[4] { "_BaseTexture", "_MainTex", "_BaseMap", "_AlbedoTexture" }; foreach (string text in array2) { if (val5.HasProperty(text)) { val5.SetTexture(text, (Texture)(object)val4); } } array2 = new string[3] { "_BaseColor", "_Color", "_AlbedoColor" }; foreach (string text2 in array2) { if (val5.HasProperty(text2)) { val5.SetColor(text2, item2); } } bool flag = (Object)(object)val4 == (Object)(object)val2; Color val6 = (flag ? (new Color(0.8f, 0.86f, 0.92f) * Plugin.EyeGlow.Value) : Color.black); if (val5.HasProperty("_EmissionColor")) { val5.SetColor("_EmissionColor", val6); } if (val5.HasProperty("_EmissionTexture")) { val5.SetTexture("_EmissionTexture", (Texture)(object)(flag ? val2 : Texture2D.blackTexture)); } if (val5.HasProperty("_EmissionMap")) { val5.SetTexture("_EmissionMap", (Texture)(object)(flag ? val2 : Texture2D.blackTexture)); if (flag) { val5.EnableKeyword("_EMISSION"); } } if (val5.HasProperty("_NormalTexture")) { val5.SetTexture("_NormalTexture", (Texture)(object)((!flag) ? val3 : null)); } if (val5.HasProperty("_NormalStrength")) { val5.SetFloat("_NormalStrength", (!flag && Object.op_Implicit((Object)(object)val3)) ? Plugin.SurfaceDetail.Value : 0f); } if (val5.HasProperty("_Metallic")) { val5.SetFloat("_Metallic", 0f); } if (val5.HasProperty("_MetallicTexture")) { val5.SetTexture("_MetallicTexture", (Texture)(object)Texture2D.blackTexture); } if (val5.HasProperty("_Smoothness")) { val5.SetFloat("_Smoothness", flag ? 0.8f : 0.42f); } if (val5.HasProperty("_SmoothnessTexture")) { val5.SetTexture("_SmoothnessTexture", (Texture)(object)Texture2D.whiteTexture); } if (val5.HasProperty("_FresnelAmount")) { val5.SetFloat("_FresnelAmount", flag ? 0f : Plugin.RimLight.Value); } if (val5.HasProperty("_FresnelColor")) { val5.SetColor("_FresnelColor", new Color(0.62f, 0.68f, 0.78f)); } if (val5.HasProperty("_TilingX")) { val5.SetFloat("_TilingX", 1f); val5.SetFloat("_TilingY", 1f); } if (val5.HasProperty("_OffsetX")) { val5.SetFloat("_OffsetX", 0f); val5.SetFloat("_OffsetY", 0f); } array[j] = val5; } ((Renderer)result.Renderer).sharedMaterials = array; if (Object.op_Implicit((Object)(object)baseMat)) { Shader shader = baseMat.shader; List<string> list = new List<string>(); for (int k = 0; k < shader.GetPropertyCount(); k++) { list.Add(shader.GetPropertyName(k)); } Plugin.Log.LogDebug((object)("Shy Guy material uses shader \"" + ((Object)shader).name + "\" (" + string.Join(", ", list) + ").")); } float num2 = 2.4f * Mathf.Max(0.5f, Plugin.Size.Value) / Mathf.Max(0.01f, ((Bounds)(ref result.Bounds)).size.y); restHeight = ((Bounds)(ref result.Bounds)).size.y; float num3 = ColliderFloor(body); footLift = (0f - ((Bounds)(ref result.Bounds)).min.y) * num2; root.transform.SetParent(body, false); root.transform.localScale = Vector3.one * num2; root.transform.localRotation = Quaternion.identity; root.transform.localPosition = new Vector3(0f, num3 - ((Bounds)(ref result.Bounds)).min.y * num2, 0f); anim = result.Animation; anim.playAutomatically = false; anim.cullingType = (AnimationCullingType)0; string[] source = new string[9] { "idle2", "idle3", "walk2", "sit2", "panic", "attackrun", "running", "teslagatehit", "sit" }; foreach (AnimationState item3 in anim) { AnimationState val7 = item3; val7.wrapMode = (WrapMode)(source.Contains(val7.name) ? 2 : 8); } head = ((IEnumerable<Transform>)root.GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Object)t).name == "head")) ?? root.transform; return root; } private static float ColliderFloor(Transform body) { //IL_00f5: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) float num = float.MaxValue; Collider[] componentsInChildren = ((Component)body).GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { if (val.isTrigger) { continue; } Transform transform = ((Component)val).transform; CapsuleCollider val2 = (CapsuleCollider)(object)((val is CapsuleCollider) ? val : null); IEnumerable<Vector3> enumerable; if (val2 != null) { Vector3 val3 = ((val2.direction == 0) ? Vector3.right : ((val2.direction == 1) ? Vector3.up : Vector3.forward)); float num2 = Mathf.Max(val2.height * 0.5f, val2.radius); enumerable = (IEnumerable<Vector3>)(object)new Vector3[3] { val2.center - val3 * num2, val2.center + val3 * num2, val2.center - Vector3.up * val2.radius }; } else { BoxCollider val4 = (BoxCollider)(object)((val is BoxCollider) ? val : null); if (val4 != null) { Vector3 val5 = val4.size * 0.5f; List<Vector3> list = new List<Vector3>(); for (int j = 0; j < 8; j++) { list.Add(val4.center + Vector3.Scale(val5, new Vector3((float)((j & 1) * 2 - 1), (float)((j & 2) - 1), (float)(((j & 4) >> 1) - 1)))); } enumerable = list; } else { SphereCollider val6 = (SphereCollider)(object)((val is SphereCollider) ? val : null); if (val6 == null) { continue; } enumerable = (IEnumerable<Vector3>)(object)new Vector3[1] { val6.center - Vector3.up * val6.radius }; } } foreach (Vector3 item in enumerable) { num = Mathf.Min(num, body.InverseTransformPoint(transform.TransformPoint(item)).y); } } if (num != float.MaxValue) { return num; } return 0f; } private static AudioSource NewSource(Transform parent, string name, AudioMixerGroup mixer, bool loop, float maxDistance) { //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) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); AudioSource obj = val.AddComponent<AudioSource>(); obj.playOnAwake = false; obj.loop = loop; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = 2f; obj.maxDistance = maxDistance; obj.dopplerLevel = 0f; obj.outputAudioMixerGroup = mixer; return obj; } } public class ShyGuyAI : MonoBehaviour { public enum State { Spawn, Idle, Roam, Sit, Rage, Chase, Attack, Calm, Stun, Despawn, Crawl, Cooldown, GetUp, Recover } private class PoseFix { public Transform t; public Vector3 basePos; public Vector3 setPos; public Vector3 baseScale; public Vector3 setScale; public Quaternion baseRot; public Quaternion setRot; public bool has; } public Transform model; public Transform head; public Animation anim; public AudioSource voice; public AudioSource sting; public AudioSource music; public float footLift; public float poseHeightPerScale; public float restHeight; public Vector3 centerLocal; public float runStride; public float walkStride; public SkinnedMeshRenderer skin; private float bottomOffset = float.NaN; private float nextBake; private Mesh baked; private readonly List<Vector3> bakedVerts = new List<Vector3>(); private Enemy enemy; private PhotonView photonView; private readonly SpringQuaternion rotationSpring = new SpringQuaternion { damping = 0.6f, speed = 8f }; private Quaternion rotationTarget = Quaternion.identity; public State state; private State previous; private bool stateImpulse = true; private float stateTimer; private Vector3 destination; private Vector3 cooldownSpot; private float rageRemaining = -1f; private float recoverHeadStart; private readonly List<PlayerAvatar> targets = new List<PlayerAvatar>(); private PlayerAvatar current; private readonly HashSet<int> targetIds = new HashSet<int>(); private float seenFor; private float lookMeter; private float nextReport; private Vector3 lastModelPos; private float speedSmoothed; private const float CrawlDrop = 0.7f; private const float CrawlSpeed = 1.4f; private const float CrawlRetract = 1.2f; private float crawlDistance; private float crawlTime; private float prone; private float slide; private bool crawlRetracting; private float retractTime; private float hitTimer; private float outOfReach; private State animState = (State)(-1); private const float AttackRange = 1.7f; private static int doorLevelId; private static float doorHeight; private readonly RaycastHit[] floorHits = (RaycastHit[])(object)new RaycastHit[8]; private float floorY = float.NaN; private float physBlend; private Vector3 uprightLocalPos; private bool uprightSaved; private readonly List<PoseFix> armFixes = new List<PoseFix>(); private PoseFix jawFix; private bool poseInit; private float jawOpen; private static readonly string[] ArmSegments = new string[6] { "Bone_012", "Bone_011", "Bone_023", "Bone_014", "Bone_013", "Bone_024" }; private static readonly string[] Hands = new string[2] { "Bone_023", "Bone_024" }; private Transform pelvis; private Vector3 hipLocal; private bool hipSet; private float pitchSmoothed = 70f; private Vector3 modelHome; private bool homeSet; private const float MaxCrawl = 3f; private bool crawlStopped; private static Light[] lamps = (Light[])(object)new Light[0]; private static float lampsAt = -100f; private float litUntil; private float unlitUntil; private readonly RaycastHit[] sightHits = (RaycastHit[])(object)new RaycastHit[16]; private readonly List<string> seq = new List<string>(); private int seqIndex; private WrapMode seqLastWrap; private State soundState = (State)(-1); private bool wasTarget; private float hurtAt = -100f; private float objectAttackerAt = -100f; private PlayerAvatar objectAttacker; private PlayerAvatar lastGrabber; private float lastGrabbedAt = -100f; private void Awake() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown enemy = ((Component)this).GetComponent<Enemy>(); photonView = ((Component)this).GetComponent<PhotonView>(); EnemyStateSpawn component = ((Component)this).GetComponent<EnemyStateSpawn>(); if (Object.op_Implicit((Object)(object)component)) { component.OnSpawn.AddListener(new UnityAction(OnSpawn)); } EnemyHealth component2 = ((Component)this).GetComponent<EnemyHealth>(); if (Object.op_Implicit((Object)(object)component2)) { component2.onDeath.AddListener(new UnityAction(OnDeath)); component2.onHurt.AddListener(new UnityAction(OnHurt)); component2.onObjectHurt.AddListener(new UnityAction(OnObjectHurt)); } } private void OnEnable() { if (Object.op_Implicit((Object)(object)photonView)) { photonView.RefreshRpcMonoBehaviourCache(); } FitHeight(); lookMeter = 0f; ApplyBodyPhysics(); } private void Start() { ApplyBodyPhysics(); } private void ApplyBodyPhysics() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) Rigidbody val = ((Object.op_Implicit((Object)(object)enemy) && Object.op_Implicit((Object)(object)enemy.Rigidbody)) ? ((Component)enemy.Rigidbody).GetComponent<Rigidbody>() : null); if (Object.op_Implicit((Object)(object)val)) { float num = Mathf.Max(0.1f, val.mass); float num2 = 0.45f; float num3 = 2f; val.automaticCenterOfMass = false; val.centerOfMass = Vector3.zero; val.automaticInertiaTensor = false; val.inertiaTensorRotation = Quaternion.identity; val.inertiaTensor = new Vector3(num * (3f * num2 * num2 + num3 * num3) / 12f, 0.5f * num * num2 * num2, num * (3f * num2 * num2 + num3 * num3) / 12f); } } private void FitHeight() { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)model) && !(poseHeightPerScale <= 0f) && !(restHeight <= 0f)) { float num; if (Plugin.Size.Value > 0f) { num = 2.4f * Plugin.Size.Value / Mathf.Max(0.01f, restHeight); } else { float num2 = DoorHeight(); num = ((num2 > 0f) ? (num2 * 0.96f) : 2.6f) / poseHeightPerScale; } model.localScale = Vector3.one * num; bottomOffset = float.NaN; } } private static float DoorHeight() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) int num = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0); if (num == doorLevelId && doorHeight > 0f) { return doorHeight; } List<float> list = new List<float>(); PhysGrabHinge[] array = Object.FindObjectsByType<PhysGrabHinge>((FindObjectsSortMode)0); foreach (PhysGrabHinge obj in array) { Bounds val = default(Bounds); bool flag = false; Collider[] componentsInChildren = ((Component)obj).GetComponentsInChildren<Collider>(true); foreach (Collider val2 in componentsInChildren) { if (!val2.isTrigger) { if (!flag) { val = val2.bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(val2.bounds); } } } if (flag && ((Bounds)(ref val)).size.y > 1.7f && ((Bounds)(ref val)).size.y < 4f && Mathf.Max(((Bounds)(ref val)).size.x, ((Bounds)(ref val)).size.z) > 0.6f) { list.Add(((Bounds)(ref val)).size.y); } } doorLevelId = num; if (list.Count == 0) { doorHeight = 0f; return 0f; } list.Sort(); doorHeight = list[list.Count / 2]; Plugin.Log.LogDebug((object)$"Doors in this level are {doorHeight:0.00} m tall ({list.Count} measured); sizing the Shy Guy to fit."); return doorHeight; } private void FixedUpdate() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00cb: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || !Object.op_Implicit((Object)(object)enemy) || !Object.op_Implicit((Object)(object)enemy.Rigidbody) || !Object.op_Implicit((Object)(object)enemy.Rigidbody.rb)) { return; } EnemyRigidbody rigidbody = enemy.Rigidbody; Rigidbody rb = rigidbody.rb; if ((!Object.op_Implicit((Object)(object)rigidbody.physGrabObject) || rigidbody.physGrabObject.playerGrabbing.Count <= 0) && !(Time.time - lastGrabbedAt < 1.5f)) { Vector3 angularVelocity = rb.angularVelocity; rb.angularVelocity = new Vector3(angularVelocity.x * 0.2f, enemy.IsStunned() ? (angularVelocity.y * 0.5f) : angularVelocity.y, angularVelocity.z * 0.2f); Quaternion rotation = rb.rotation; Quaternion val = Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y, 0f); if (Quaternion.Angle(rb.rotation, val) > 1f) { rb.MoveRotation(Quaternion.Slerp(rb.rotation, val, 0.25f)); } } } private void Update() { if (SemiFunc.IsMasterClientOrSingleplayer()) { HostLogic(); } LocalLookCheck(); Animate(); Sounds(); } private bool Physical() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) EnemyRigidbody val = (Object.op_Implicit((Object)(object)enemy) ? enemy.Rigidbody : null); if (!Object.op_Implicit((Object)(object)val)) { return false; } if (Object.op_Implicit((Object)(object)val.physGrabObject) && val.physGrabObject.playerGrabbing.Count > 0) { return true; } return Vector3.Angle(((Component)val).transform.up, Vector3.up) > 20f; } private void LateUpdate() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_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_01c4: 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_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_021b: 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_0241: 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_025a: 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_0261: 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_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_053a: 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) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: 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_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0561: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Expected O, but got Unknown //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)model)) { return; } PosePostProcess(); Transform parent = model.parent; physBlend = Mathf.MoveTowards(physBlend, (Physical() && state != State.Crawl) ? 1f : 0f, Time.deltaTime * 4f); if (physBlend >= 1f && uprightSaved) { model.localPosition = uprightLocalPos; model.localRotation = Quaternion.identity; return; } int num = Physics.RaycastNonAlloc(parent.position + Vector3.up * 0.5f, Vector3.down, floorHits, 4f, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1); float num2 = float.NegativeInfinity; for (int i = 0; i < num; i++) { Collider collider = ((RaycastHit)(ref floorHits[i])).collider; if (Object.op_Implicit((Object)(object)collider) && !((Component)collider).transform.IsChildOf(((Component)enemy.EnemyParent).transform) && !Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<PhysGrabObject>())) { num2 = Mathf.Max(num2, ((RaycastHit)(ref floorHits[i])).point.y); } } if (float.IsNegativeInfinity(num2)) { return; } floorY = ((float.IsNaN(floorY) || Mathf.Abs(floorY - num2) > 1.5f) ? num2 : Mathf.Lerp(floorY, num2, Time.deltaTime * 12f)); UpdateCrawlPose(); Vector3 val = parent.TransformPoint(modelHome) + parent.forward * slide; model.position = new Vector3(val.x, floorY + Mathf.Lerp(footLift, 0.3f, prone), val.z); model.localRotation = Quaternion.Euler(CrawlPitch() * prone, 0f, 0f); if (Object.op_Implicit((Object)(object)pelvis)) { Vector3 val2 = pelvis.position - parent.position; val2.y = 0f; Vector3 val3 = parent.InverseTransformDirection(val2); hipLocal = (hipSet ? Vector3.Lerp(hipLocal, val3, Time.deltaTime * 10f) : val3); hipSet = true; Transform obj = model; obj.position -= parent.TransformDirection(hipLocal) * (1f - prone); } if (Object.op_Implicit((Object)(object)skin)) { if (Time.time >= nextBake || float.IsNaN(bottomOffset) || prone > 0f) { nextBake = Time.time + 0.1f; if (!Object.op_Implicit((Object)(object)baked)) { baked = new Mesh { name = "Shy Guy Baked" }; } skin.BakeMesh(baked); baked.GetVertices(bakedVerts); Matrix4x4 val4 = Matrix4x4.TRS(((Component)skin).transform.position, ((Component)skin).transform.rotation, Vector3.one); float num3 = float.MaxValue; for (int j = 0; j < bakedVerts.Count; j += 3) { num3 = Mathf.Min(num3, ((Matrix4x4)(ref val4)).MultiplyPoint3x4(bakedVerts[j]).y); } if (num3 < float.MaxValue) { float num4 = Mathf.Clamp(num3 - model.position.y, 0f - footLift - 3f, 1f); bottomOffset = ((float.IsNaN(bottomOffset) || Mathf.Abs(num4 - bottomOffset) > 0.6f) ? num4 : Mathf.Lerp(bottomOffset, num4, 0.5f)); } } if (!float.IsNaN(bottomOffset)) { float num5 = floorY; if (prone > 0f) { PlayerAvatar val5 = CrawlTarget(); if (Object.op_Implicit((Object)(object)val5)) { num5 = Mathf.Min(num5, ((Component)val5).transform.position.y); } } float num6 = num5 - bottomOffset; float num7 = num6; if (prone > 0f && Object.op_Implicit((Object)(object)pelvis)) { float num8 = num5 + 0.22f - (pelvis.position.y - model.position.y); num7 = Mathf.Lerp(num6, num8, prone); } model.position = new Vector3(model.position.x, num7, model.position.z); } } if (physBlend <= 0f) { uprightLocalPos = model.localPosition; uprightSaved = true; } else if (uprightSaved) { model.localPosition = Vector3.Lerp(model.localPosition, uprightLocalPos, physBlend); model.localRotation = Quaternion.Slerp(model.localRotation, Quaternion.identity, physBlend); } } private void PosePostProcess() { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: 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_027f: 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_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) if (!poseInit) { poseInit = true; Transform[] componentsInChildren = ((Component)model).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (Array.IndexOf(ArmSegments, ((Object)val).name) >= 0) { armFixes.Add(new PoseFix { t = val }); } if (((Object)val).name == "lowerjaw") { jawFix = new PoseFix { t = val }; } } } float value = Plugin.ArmLength.Value; foreach (PoseFix armFix in armFixes) { Capture(armFix); armFix.setPos = armFix.basePos * value; armFix.setScale = ((Array.IndexOf(Hands, ((Object)armFix.t).name) >= 0) ? (armFix.baseScale * value) : armFix.baseScale); armFix.t.localPosition = armFix.setPos; armFix.t.localScale = armFix.setScale; armFix.setRot = armFix.t.localRotation; } if (jawFix != null) { float num = 0f; switch (state) { case State.Rage: case State.Chase: case State.Attack: case State.Crawl: case State.Recover: num = 1f; break; case State.Stun: num = 0.6f; break; case State.Cooldown: num = 0.4f; break; } jawOpen = Mathf.MoveTowards(jawOpen, num, Time.deltaTime * ((num > jawOpen) ? 3f : 1f)); Capture(jawFix); float num2 = ((jawOpen > 0.5f) ? (Mathf.PerlinNoise(Time.time * 9f, 3.7f) * 6f) : 0f); jawFix.setRot = jawFix.baseRot * Quaternion.Euler(0f - (jawOpen * 42f + num2), 0f, 0f); jawFix.t.localRotation = jawFix.setRot; jawFix.setPos = jawFix.t.localPosition; jawFix.setScale = jawFix.t.localScale; } } private static void Capture(PoseFix f) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_005e: 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) Transform t = f.t; if (!f.has || t.localPosition != f.setPos) { f.basePos = t.localPosition; } if (!f.has || t.localRotation != f.setRot) { f.baseRot = t.localRotation; } if (!f.has || t.localScale != f.setScale) { f.baseScale = t.localScale; } f.has = true; } private PlayerAvatar CrawlTarget() { //IL_006f: 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) if (Object.op_Implicit((Object)(object)current) && SemiFunc.IsMasterClientOrSingleplayer()) { return current; } PlayerAvatar result = null; float num = float.MaxValue; if (Object.op_Implicit((Object)(object)GameDirector.instance)) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (Object.op_Implicit((Object)(object)player) && targetIds.Contains(player.photonView.ViewID)) { float num2 = Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position); if (num2 < num) { num = num2; result = player; } } } } return result; } private float CrawlPitch() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)pelvis)) { Transform[] componentsInChildren = ((Component)model).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name == "pelvis") { pelvis = val; break; } } } if (!Object.op_Implicit((Object)(object)pelvis) || !Object.op_Implicit((Object)(object)head)) { return 70f; } Vector3 val2 = model.InverseTransformPoint(head.position) - model.InverseTransformPoint(pelvis.position); float num = Mathf.Clamp(Mathf.Atan2(val2.y, val2.z) * 57.29578f, 15f, 95f); pitchSmoothed = Mathf.Lerp(pitchSmoothed, num, Time.deltaTime * 6f); return pitchSmoothed; } private void UpdateCrawlPose() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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) if (!homeSet) { modelHome = model.localPosition; homeSet = true; } if (state == State.Crawl) { crawlTime += Time.deltaTime; prone = Mathf.MoveTowards(prone, 1f, Time.deltaTime / 0.7f); if (crawlRetracting) { retractTime += Time.deltaTime; slide = Mathf.MoveTowards(slide, 0f, Time.deltaTime * 1.4f * 1.5f); } else if (crawlTime > 0.7f) { PlayerAvatar val = CrawlTarget(); bool num = Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)head) && FlatDistance(head.position, ((Component)val).transform.position) < 0.6f; bool flag = WallAhead(); if (!num && !flag && slide < 3f) { slide += Time.deltaTime * 1.4f; crawlStopped = false; } else { crawlStopped = true; } } } else { crawlTime = 0f; crawlRetracting = false; retractTime = 0f; crawlStopped = false; prone = Mathf.MoveTowards(prone, 0f, Time.deltaTime / 0.7f); slide = Mathf.MoveTowards(slide, 0f, Time.deltaTime * 3f); } } private bool WallAhead() { //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_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_004f: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)head) || !Object.op_Implicit((Object)(object)model)) { return false; } Vector3 forward = model.parent.forward; forward.y = 0f; ((Vector3)(ref forward)).Normalize(); Vector3 position = head.position; position.y = Feet().y + 0.3f; int num = Physics.RaycastNonAlloc(position - forward * 0.2f, forward, sightHits, 0.6f, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Transform transform = ((RaycastHit)(ref sightHits[i])).transform; if (Object.op_Implicit((Object)(object)transform) && !transform.IsChildOf(((Component)enemy.EnemyParent).transform) && !Object.op_Implicit((Object)(object)((Component)transform).GetComponentInParent<PhysGrabObject>()) && !Object.op_Implicit((Object)(object)((Component)transform).GetComponentInParent<PlayerAvatar>())) { return true; } } return false; } private bool Hiding(PlayerAvatar p) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (!Alive(p) || !p.isCrawling || p.isTumbling) { return false; } if (SemiFunc.EnemyLookUnderCondition(enemy, 1f, 0.5f, p)) { return true; } Vector3 val = ((Component)p).transform.position + Vector3.up * 0.25f; if (SightBlocked(val, val + Vector3.up * 1.3f, p) && FlatDistance(Feet(), ((Component)p).transform.position) < 4f) { return !CanReach(p); } return false; } private float CrawlReach(PlayerAvatar p) { //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_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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Feet(); Vector3 val2 = ((Component)p).transform.position - val; val2.y = 0f; float magnitude = ((Vector3)(ref val2)).magnitude; float num = Mathf.Clamp(magnitude - 1.7f, 0f, 3f); if (magnitude > 0.01f) { val2 /= magnitude; int num2 = Physics.RaycastNonAlloc(val + Vector3.up * 0.3f, val2, sightHits, num + 1.2f, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1); for (int i = 0; i < num2; i++) { Transform transform = ((RaycastHit)(ref sightHits[i])).transform; if (Object.op_Implicit((Object)(object)transform) && !transform.IsChildOf(((Component)enemy.EnemyParent).transform) && !transform.IsChildOf(((Component)p).transform) && !Object.op_Implicit((Object)(object)((Component)transform).GetComponentInParent<PhysGrabObject>())) { num = Mathf.Min(num, Mathf.Max(0f, ((RaycastHit)(ref sightHits[i])).distance - 1.2f)); } } } return num; } private float FlatDistance(Vector3 a, Vector3 b) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) a.y = 0f; b.y = 0f; return Vector3.Distance(a, b); } private Vector3 Feet() { //IL_0020: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) Vector3 result = (Object.op_Implicit((Object)(object)model) ? model.position : ((Component)this).transform.position); if (!float.IsNaN(floorY)) { result.y = floorY; } return result; } private void HostLogic() { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Invalid comparison between Unknown and I4 //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Invalid comparison between Unknown and I4 //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_025e: 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_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0568: Unknown result type (might be due to invalid IL or missing references) //IL_08b6: Unknown result type (might be due to invalid IL or missing references) //IL_08bb: Unknown result type (might be due to invalid IL or missing references) //IL_0644: Unknown result type (might be due to invalid IL or missing references) //IL_0649: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_07e8: Unknown result type (might be due to invalid IL or missing references) //IL_07ed: Unknown result type (might be due to invalid IL or missing references) //IL_0656: Unknown result type (might be due to invalid IL or missing references) //IL_072d: Unknown result type (might be due to invalid IL or missing references) //IL_073d: Unknown result type (might be due to invalid IL or missing references) PruneTargets(); HandleHurtAggro(); if (targets.Count > 0 && state != State.Despawn) { EnemyParent enemyParent = enemy.EnemyParent; if (enemyParent.SpawnedTimer < 30f) { enemyParent.SpawnedTimer = 30f; } enemy.StuckCount = 0; if ((int)enemy.CurrentState == 11 && !enemyParent.forceLeave) { enemy.CurrentState = (EnemyState)2; } } if (enemy.IsStunned()) { if (state == State.Rage) { rageRemaining = Mathf.Max(1.5f, stateTimer); } Set(State.Stun); } else if ((int)enemy.CurrentState == 11) { Set(State.Despawn); } switch (state) { case State.Spawn: if (Impulse()) { stateTimer = 2f; } if ((stateTimer -= Time.deltaTime) <= 0f) { Set(State.Idle); } break; case State.Idle: if (Impulse()) { stateTimer = Random.Range(4f, 10f); StopMoving(); } if (!SemiFunc.EnemySpawnIdlePause() && (stateTimer -= Time.deltaTime) <= 0f) { Set((Random.value < 0.3f) ? State.Sit : State.Roam); } break; case State.Roam: if (Impulse()) { stateTimer = 12f; if (!PickRoamPoint()) { Set(State.Idle); break; } } enemy.NavMeshAgent.OverrideAgent(Plugin.WalkSpeed.Value, enemy.NavMeshAgent.DefaultAcceleration, 0.2f); enemy.NavMeshAgent.SetDestination(destination); if (enemy.Rigidbody.notMovingTimer > 1f) { stateTimer -= Time.deltaTime; } if (stateTimer <= 0f || Vector3.Distance(((Component)this).transform.position, destination) < 1.5f) { Set(State.Idle); } break; case State.Sit: case State.Calm: if (Impulse()) { StopMoving(); stateTimer = ((state == State.Calm) ? Plugin.CalmSeconds.Value : Random.Range(15f, 40f)); } enemy.NavMeshAgent.Stop(0.2f); if ((stateTimer -= Time.deltaTime) <= 0f) { Set(State.GetUp); } break; case State.Cooldown: if (Impulse()) { StopMoving(); stateTimer = Plugin.CooldownSeconds.Value; } enemy.NavMeshAgent.Stop(0.2f); if ((stateTimer -= Time.deltaTime) <= 0f) { Set(State.Calm); } break; case State.GetUp: if (Impulse()) { StopMoving(); stateTimer = ((Object.op_Implicit((Object)(object)anim) && TrackedReference.op_Implicit((TrackedReference)(object)anim["sit2end"])) ? anim["sit2end"].length : 3f); } enemy.NavMeshAgent.Stop(0.2f); if ((stateTimer -= Time.deltaTime) <= 0f) { Set(State.Roam); } break; case State.Rage: if (Impulse()) { StopMoving(); stateTimer = ((rageRemaining > 0f) ? rageRemaining : Plugin.RageSeconds.Value); rageRemaining = -1f; } enemy.NavMeshAgent.Stop(0.2f); if ((stateTimer -= Time.deltaTime) <= 0f) { Set((targets.Count > 0) ? State.Chase : State.Cooldown); } break; case State.Chase: { Impulse(); current = Nearest(); if (!Object.op_Implicit((Object)(object)current)) { Set(State.Cooldown); break; } float value = Plugin.ChaseSpeed.Value; enemy.NavMeshAgent.OverrideAgent(value, 40f, 0.2f); enemy.Rigidbody.OverrideFollowPosition(0.2f, value * 1.6f, -1f); if (Plugin.SmashDoors.Value) { enemy.SetChaseTimer(); } if (CanReach(current)) { Set(State.Attack); } else if (Hiding(current)) { Vector3 lastNavmeshPosition = current.LastNavmeshPosition; enemy.NavMeshAgent.SetDestination(lastNavmeshPosition); float num = FlatDistance(Feet(), lastNavmeshPosition); if (num < 1.3f || (num < 2.5f && enemy.Rigidbody.notMovingTimer > 0.6f)) { crawlDistance = CrawlReach(current); Set(State.Crawl); if (SemiFunc.IsMultiplayer()) { photonView.RPC("ShyGuy_CrawlRPC", (RpcTarget)1, new object[1] { crawlDistance }); } } } else { Vector3 val = ((Component)current).transform.position; if (FlatDistance(val, current.LastNavmeshPosition) > 0.4f || Mathf.Abs(val.y - current.LastNavmeshPosition.y) > 0.5f) { val = current.LastNavmeshPosition; } enemy.NavMeshAgent.SetDestination(val); } break; } case State.Crawl: if (Impulse()) { StopMoving(); stateTimer = 0f; crawlRetracting = false; retractTime = 0f; hitTimer = 0f; } enemy.NavMeshAgent.Stop(0.2f); stateTimer += Time.deltaTime; if (!crawlRetracting) { if (!(stateTimer >= 0.7f) || (!crawlStopped && !(stateTimer > 3.142857f))) { break; } if (Alive(current) && current.isCrawling && !current.isTumbling && Object.op_Implicit((Object)(object)head) && FlatDistance(head.position, ((Component)current).transform.position) < 1.4f && stateTimer < 25f) { if ((hitTimer -= Time.deltaTime) <= 0f) { Hit(current, pull: true); hitTimer = Plugin.HitInterval.Value; } } else { StartRetract(); } } else if (slide <= 0.01f && retractTime >= 1.2f) { if (Object.op_Implicit((Object)(object)current)) { cooldownSpot = ((Component)current).transform.position; } if (Object.op_Implicit((Object)(object)current) && !Alive(current)) { RemoveTarget(current); } Set((targets.Count > 0) ? State.Chase : State.Cooldown); } break; case State.Attack: if (Impulse()) { StopMoving(); hitTimer = 0.45f; outOfReach = 0f; } enemy.NavMeshAgent.Stop(0.2f); if (!Alive(current)) { if ((stateTimer += Time.deltaTime) > 1.2f) { if (Object.op_Implicit((Object)(object)current)) { cooldownSpot = ((Component)current).transform.position; } RemoveTarget(current); Set((targets.Count > 0) ? State.Chase : State.Cooldown); } break; } outOfReach = (CanReach(current, 2.4f) ? 0f : (outOfReach + Time.deltaTime)); if (outOfReach > 0.4f) { Set(State.Chase); } else if ((hitTimer -= Time.deltaTime) <= 0f) { hitTimer = Plugin.HitInterval.Value; if (Hit(current) && Plugin.HitRecoverySeconds.Value > 0f) { Set(State.Recover); } } break; case State.Recover: { if (Impulse()) { StopMoving(); stateTimer = 0f; recoverHeadStart = Plugin.HitRecoverySeconds.Value; } enemy.NavMeshAgent.Stop(0.2f); stateTimer += Time.deltaTime; bool flag = Alive(current) && current.isTumbling && stateTimer < 6f; if ((!flag || stateTimer < 0.3f) && stateTimer >= 0.3f) { recoverHeadStart -= Time.deltaTime; } if (!Alive(current) || (stateTimer >= 0.3f && !flag && recoverHeadStart <= 0f)) { Set((targets.Count > 0) ? State.Chase : State.Cooldown); } break; } case State.Stun: if (Impulse()) { StopMoving(); } if (!enemy.IsStunned()) { if (rageRemaining > 0f && targets.Count > 0) { Set(State.Rage); break; } rageRemaining = -1f; Set((targets.Count <= 0) ? State.Idle : State.Chase); } break; case State.Despawn: if (Impulse()) { StopMoving(); targets.Clear(); SendTargets(); Plugin.Log.LogDebug((object)"Shy Guy despawned (he will come back later)."); enemy.EnemyParent.Despawn(); } break; } RotationLogic(); } private bool Impulse() { if (!stateImpulse) { return false; } stateImpulse = false; return true; } private void StopMoving() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) enemy.NavMeshAgent.ResetPath(); enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false); } private bool PickRoamPoint() { //IL_0006: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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) LevelPoint val = SemiFunc.LevelPointGet(((Component)this).transform.position, 5f, 18f) ?? SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f); NavMeshHit val2 = default(NavMeshHit); if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 3f, ref val2, 5f, -1)) { destination = ((NavMeshHit)(ref val2)).position; return true; } return false; } private void RotationLogic() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; if ((state == State.Chase || state == State.Attack || state == State.Crawl || state == State.Recover) && Object.op_Implicit((Object)(object)current)) { val = ((Component)current).transform.position - ((Component)this).transform.position; } else if (state == State.Cooldown && cooldownSpot != Vector3.zero) { val = cooldownSpot - ((Component)this).transform.position; } else if (((Vector3)(ref enemy.NavMeshAgent.AgentVelocity)).magnitude > 0.1f) { val = enemy.NavMeshAgent.AgentVelocity; } val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { rotationTarget = Quaternion.LookRotation(val); } ((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(rotationSpring, rotationTarget, -1f); enemy.Rigidbody.rotationSpeedIdle = ((state == State.Roam) ? 1f : 2f); enemy.Rigidbody.rotationSpeedChase = ((state == State.Chase) ? 4f : 2f); } private PlayerAvatar Nearest() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar result = null; float num = float.MaxValue; foreach (PlayerAvatar target in targets) { float num2 = Vector3.Distance(((Component)target).transform.position, ((Component)this).transform.position); if (num2 < num) { num = num2; result = target; } } return result; } private bool CanReach(PlayerAvatar p, float range = 1.7f) { //IL_0020: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing