using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Dawn; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using SimonSays.AI; using SimonSays.NetcodePatcher; using SimonSays.Utils; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; using Y4NGZMonsters.Shared; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SimonSays")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+25ca94fed298fe073d4c739917e3b7f046e875bf")] [assembly: AssemblyProduct("SimonSays")] [assembly: AssemblyTitle("SimonSays")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 SimonSays { [BepInPlugin("y4ngz.lethalcompany.simonsays", "Y4NGZ Simon Says", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal const string DisplayName = "Simon Says"; internal const string DawnNamespace = "y4ngz_monsters"; internal const string DawnEnemyKey = "simon_says"; internal const string TerminalKeyword = "simon"; internal const string ScanNodeSubtitle = "Only obey when Simon says"; internal const string BestiaryText = "Simon Says\n\nDanger level: 100%\n\nSigurd's notes: It's a wheeled jester cart with a clockwork skull. It picks one crew member, puts a spotlight on them, and plays a game. Three commands. It cannot be killed, and when it is done it leaves in a cloud of smoke.\n\nThe rule is the whole trick: only obey a command it prefixes with \"Simon says\". Obey one it does not, and it kills you for it. Ignore one it does, and it kills you for that too. Listen for the words \"and\" (either order) versus \"then\" (that order).\n\n"; internal static ManualLogSource Log; private static bool _loggedScanNodeLayer; internal static SimonSaysConfig ModConfig; internal static AssetBundle ModAssets; internal static EnemyType SimonSaysEnemy; internal static AudioClip LetsPlayClip; internal static AudioClip SimonSaysWordClip; internal static AudioClip AndClip; internal static AudioClip ThenClip; internal static AudioClip CongratulationsClip; internal static AudioClip GoodbyeClip; private static readonly AudioClip[] _actionClips = (AudioClip[])(object)new AudioClip[4]; internal static AudioClip SpotlightStartClip; internal static GameObject VanishSmokePrefab; private const string SpotlightStartSfxFileName = "simon_says_spotlight.mp3"; private static bool _netcodeInitialized = false; private Harmony _harmony; internal static AudioClip ActionClip(ActionType action) { if (action < ActionType.Jump || (int)action >= _actionClips.Length) { return null; } return _actionClips[(int)action]; } private void Awake() { //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; try { InitializeNetcodeRPCs(); ModConfig = new SimonSaysConfig(((BaseUnityPlugin)this).Config); if (!ModConfig.Enabled.Value) { Log.LogInfo((object)"Y4NGZ Simon Says is disabled in config; skipping registration."); return; } if (ModConfig?.DebugLogs?.Value == true) { ProbeRpcFuncTables(); } string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); ((MonoBehaviour)this).StartCoroutine(LoadSpotlightStartClip(directoryName)); string text = Path.Combine(directoryName, "simonsays.bundle"); ModAssets = AssetBundle.LoadFromFile(text); if ((Object)(object)ModAssets == (Object)null) { Log.LogError((object)("Failed to load asset bundle at: " + text)); return; } GameObject val = LoadEnemyPrefab(); if ((Object)(object)val == (Object)null) { Log.LogError((object)"Failed to load SimonSays prefab from bundle. Available assets:"); string[] allAssetNames = ModAssets.GetAllAssetNames(); foreach (string text2 in allAssetNames) { Log.LogError((object)(" - " + text2)); } return; } Log.LogInfo((object)("Loaded prefab '" + ((Object)val).name + "' with " + $"{val.GetComponents().Length} root components.")); LoadAudioFromBundle(); LoadEffectsFromBundle(); AssignUniqueNetworkHash(val); RebindTexturesFromBundle(val); SetupPrefabComponents(val); SimonSaysEnemy = CreateEnemyType(val); SimonSaysAI component = val.GetComponent(); if ((Object)(object)component != (Object)null) { ((EnemyAI)component).enemyType = SimonSaysEnemy; } SimonSaysSpawnWeights spawnWeights = new SimonSaysSpawnWeights(() => ModConfig.SpawnWeightMultiplier.Value); DawnLib.RegisterNetworkPrefab(val); DawnLib.DefineEnemy(NamespacedKey.From("y4ngz_monsters", "simon_says"), SimonSaysEnemy, (Action)delegate(EnemyInfoBuilder builder) { ((BaseInfoBuilder)(object)builder.DefineInside((Action)delegate(EnemyLocationBuilder location) { location.SetWeights((Action>)delegate(WeightTableBuilder table) { table.SetGlobalWeight((IWeighted)(object)spawnWeights); }); }).CreateBestiaryNode("Simon Says\n\nDanger level: 100%\n\nSigurd's notes: It's a wheeled jester cart with a clockwork skull. It picks one crew member, puts a spotlight on them, and plays a game. Three commands. It cannot be killed, and when it is done it leaves in a cloud of smoke.\n\nThe rule is the whole trick: only obey a command it prefixes with \"Simon says\". Obey one it does not, and it kills you for it. Ignore one it does, and it kills you for that too. Listen for the words \"and\" (either order) versus \"then\" (that order).\n\n").CreateNameKeyword("simon")).AddTags((IEnumerable)(object)new NamespacedKey[3] { Tags.Hostile, Tags.Mechanical, Tags.Medium }); }); _harmony = new Harmony("y4ngz.lethalcompany.simonsays"); _harmony.PatchAll(typeof(Plugin).Assembly); Log.LogInfo((object)"Y4NGZ Simon Says v1.0.1 loaded."); } catch (Exception arg) { Log.LogError((object)string.Format("Failed to initialize {0}: {1}", "Y4NGZ Simon Says", arg)); } } private static void InitializeNetcodeRPCs() { if (_netcodeInitialized) { return; } _netcodeInitialized = true; Type[] types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type type in types) { MethodInfo[] methods; try { methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } catch (Exception ex) { Log.LogWarning((object)("[NetcodeInit] skipped type " + type.FullName + ": " + ex.GetType().Name)); continue; } MethodInfo[] array = methods; foreach (MethodInfo methodInfo in array) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { try { methodInfo.Invoke(null, null); Log.LogInfo((object)("[NetcodeInit] invoked " + type.Name + "." + methodInfo.Name)); } catch (Exception arg) { Log.LogError((object)$"[NetcodeInit] {type.Name}.{methodInfo.Name} threw: {arg}"); } } } } } private static void ProbeRpcFuncTables() { try { FieldInfo fieldInfo = AccessTools.TypeByName("Unity.Netcode.NetworkManager")?.GetField("__rpc_func_table", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (fieldInfo != null) { IDictionary dictionary = fieldInfo.GetValue(null) as IDictionary; Log.LogInfo((object)$"[NetcodeInit] post-scan NetworkManager.__rpc_func_table count: {dictionary?.Count ?? (-1)}"); if (dictionary != null) { foreach (object key in dictionary.Keys) { Log.LogInfo((object)$"[NetcodeInit] NM key: {key}"); } } } else { Log.LogWarning((object)"[NetcodeInit] NetworkManager.__rpc_func_table field not found"); } } catch (Exception arg) { Log.LogError((object)$"[NetcodeInit] NM probe threw: {arg}"); } try { FieldInfo fieldInfo2 = AccessTools.TypeByName("Unity.Netcode.NetworkBehaviour")?.GetField("__rpc_func_table", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (fieldInfo2 != null) { IDictionary dictionary2 = fieldInfo2.GetValue(null) as IDictionary; Log.LogInfo((object)$"[NetcodeInit] post-scan NetworkBehaviour.__rpc_func_table type-count: {dictionary2?.Count ?? (-1)}"); if (dictionary2 == null) { return; } { foreach (DictionaryEntry item in dictionary2) { int num = (item.Value as IDictionary)?.Count ?? (-1); Log.LogInfo((object)$"[NetcodeInit] NB type={item.Key} inner-count={num}"); } return; } } Log.LogWarning((object)"[NetcodeInit] NetworkBehaviour.__rpc_func_table field not found"); } catch (Exception arg2) { Log.LogError((object)$"[NetcodeInit] NB probe threw: {arg2}"); } } private static GameObject LoadEnemyPrefab() { string[] array = new string[4] { "Assets/Y4NGZ/SimonSays/SimonSays.prefab", "assets/y4ngz/simonsays/simonsays.prefab", "Assets/SimonSays/SimonSays.prefab", "assets/simonsays/simonsays.prefab" }; foreach (string text in array) { GameObject val = ModAssets.LoadAsset(text); if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent() != (Object)null) { Log.LogInfo((object)("Loaded SimonSays prefab by path '" + text + "'.")); return val; } } GameObject[] array2 = ModAssets.LoadAllAssets(); foreach (GameObject val2 in array2) { if ((Object)(object)val2 != (Object)null && (Object)(object)val2.GetComponent() != (Object)null) { Log.LogWarning((object)("SimonSays prefab not at any known path; recovered '" + ((Object)val2).name + "' by scanning the bundle for SimonSaysAI. Update knownPaths.")); return val2; } } return null; } private static void LoadAudioFromBundle() { LetsPlayClip = LoadClip("ss_lets_play"); SimonSaysWordClip = LoadClip("ss_simon_says"); AndClip = LoadClip("ss_and"); ThenClip = LoadClip("ss_then"); CongratulationsClip = LoadClip("ss_congratulations"); GoodbyeClip = LoadClip("ss_goodbye"); _actionClips[0] = LoadClip("ss_jump"); _actionClips[1] = LoadClip("ss_crouch"); _actionClips[2] = LoadClip("ss_dance"); _actionClips[3] = LoadClip("ss_turn_around"); WarnIfMissing(LetsPlayClip, "ss_lets_play"); WarnIfMissing(CongratulationsClip, "ss_congratulations"); WarnIfMissing(GoodbyeClip, "ss_goodbye"); if ((1u & (RequireCommandClip(SimonSaysWordClip, "ss_simon_says") ? 1u : 0u) & (RequireCommandClip(AndClip, "ss_and") ? 1u : 0u) & (RequireCommandClip(ThenClip, "ss_then") ? 1u : 0u) & (RequireCommandClip(_actionClips[0], "ss_jump") ? 1u : 0u) & (RequireCommandClip(_actionClips[1], "ss_crouch") ? 1u : 0u) & (RequireCommandClip(_actionClips[2], "ss_dance") ? 1u : 0u) & (RequireCommandClip(_actionClips[3], "ss_turn_around") ? 1u : 0u)) == 0) { Log.LogFatal((object)"[SimonSays] Command word bank is incomplete; SimonSays will not register because a partial spoken command must never be judged."); throw new InvalidDataException("[SimonSays] Command word bank is incomplete; SimonSays will not register because a partial spoken command must never be judged."); } } private static void WarnIfMissing(AudioClip clip, string name) { if ((Object)(object)clip == (Object)null) { Log.LogError((object)("SimonSays audio '" + name + "' not found in bundle.")); } } private static bool RequireCommandClip(AudioClip clip, string name) { if ((Object)(object)clip != (Object)null) { return true; } Log.LogFatal((object)("[SimonSays] Required command clip '" + name + "' not found in bundle.")); return false; } private static void LoadEffectsFromBundle() { VanishSmokePrefab = ModAssets.LoadAsset("SimonSaysVanishSmoke") ?? ModAssets.LoadAsset("Assets/Y4NGZ/SimonSays/Effects/SimonSaysVanishSmoke.prefab"); if ((Object)(object)VanishSmokePrefab == (Object)null) { Log.LogWarning((object)"SimonSaysVanishSmoke prefab not in bundle; the vanish will use the code-built smoke cloud instead."); } } private static void RebindTexturesFromBundle(GameObject prefab) { //IL_00ea: 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) try { Texture2D val = ModAssets.LoadAsset("Meshy_AI_Clockwork_Jester_0505033555_texture"); Texture2D val2 = ModAssets.LoadAsset("Meshy_AI_Clockwork_Jester_0505033555_texture_normal"); Texture2D val3 = ModAssets.LoadAsset("Meshy_AI_Clockwork_Jester_0505033555_texture_metallic"); Texture2D val4 = ModAssets.LoadAsset("Meshy_AI_Clockwork_Jester_0505033555_texture_emission"); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"Albedo texture missing from bundle."); } else { Log.LogInfo((object)$"Albedo loaded: {((Texture)val).width}x{((Texture)val).height}"); } int num = 0; Renderer[] componentsInChildren = prefab.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Material[] sharedMaterials = componentsInChildren[i].sharedMaterials; foreach (Material val5 in sharedMaterials) { if (!((Object)(object)val5 == (Object)null)) { if ((Object)(object)val != (Object)null) { val5.SetTexture("_BaseColorMap", (Texture)(object)val); val5.SetTexture("_MainTex", (Texture)(object)val); val5.SetColor("_BaseColor", Color.white); val5.SetColor("_Color", Color.white); } if ((Object)(object)val2 != (Object)null) { val5.SetTexture("_NormalMap", (Texture)(object)val2); val5.SetTexture("_BumpMap", (Texture)(object)val2); val5.EnableKeyword("_NORMALMAP"); val5.EnableKeyword("_NORMALMAP_TANGENT_SPACE"); } if ((Object)(object)val3 != (Object)null) { val5.SetTexture("_MaskMap", (Texture)(object)val3); val5.SetTexture("_MetallicGlossMap", (Texture)(object)val3); val5.EnableKeyword("_MASKMAP"); } if ((Object)(object)val4 != (Object)null) { val5.SetTexture("_EmissiveColorMap", (Texture)(object)val4); val5.SetTexture("_EmissionMap", (Texture)(object)val4); val5.EnableKeyword("_EMISSIVE_COLOR_MAP"); } num++; } } } Log.LogInfo((object)$"RebindTexturesFromBundle: applied to {num} material slot(s)."); } catch (Exception arg) { Log.LogError((object)$"RebindTexturesFromBundle: {arg}"); } } private static void AssignUniqueNetworkHash(GameObject prefab) { try { NetworkObject component = prefab.GetComponent(); if ((Object)(object)component == (Object)null) { Log.LogWarning((object)"Prefab missing NetworkObject — skipping hash override"); return; } uint num = BitConverter.ToUInt32(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes("y4ngz.lethalcompany.simonsays.SimonSays")), 0); PropertyInfo property = typeof(NetworkObject).GetProperty("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite) { property.SetValue(component, num); } else { FieldInfo field = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(component, num); } else { Log.LogWarning((object)"Could not locate GlobalObjectIdHash via property or field — hash unchanged"); } } Log.LogInfo((object)$"SimonSays NetworkObject GlobalObjectIdHash = {num}"); } catch (Exception arg) { Log.LogError((object)$"AssignUniqueNetworkHash: {arg}"); } } private static AudioClip LoadClip(params string[] candidates) { foreach (string text in candidates) { AudioClip val = ModAssets.LoadAsset(text); if ((Object)(object)val != (Object)null) { return val; } } return null; } private IEnumerator LoadSpotlightStartClip(string assemblyDir) { string path = Path.Combine(assemblyDir, "simon_says_spotlight.mp3"); if (!File.Exists(path)) { Log.LogWarning((object)("Spotlight start sound missing: " + path)); yield break; } UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(new Uri(path).AbsoluteUri, (AudioType)13); try { yield return request.SendWebRequest(); if ((int)request.result != 1) { Log.LogWarning((object)("Failed loading spotlight start sound '" + path + "': " + request.error)); yield break; } AudioClip content = DownloadHandlerAudioClip.GetContent(request); if ((Object)(object)content == (Object)null) { Log.LogWarning((object)("Spotlight start sound decoded null: " + path)); yield break; } ((Object)content).name = "SimonSays_SpotlightStart"; SpotlightStartClip = content; Log.LogInfo((object)("Loaded spotlight start sound from '" + path + "'.")); } finally { ((IDisposable)request)?.Dispose(); } } private static void SetupPrefabComponents(GameObject prefab) { //IL_0029: 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_0039: 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) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_006c: 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_007f: Expected O, but got Unknown //IL_0081: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //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_00b6: 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_00c9: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_00f7: 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_0107: 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_011a: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_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_016b: Expected O, but got Unknown EnsureScanNode(prefab); SimonSaysAI component = prefab.GetComponent(); if ((Object)(object)component != (Object)null) { EnsureNavigation(prefab, component); ((EnemyAI)component).enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[8] { new EnemyBehaviourState { name = "Roaming", IsAnimTrigger = false, parameterString = "isWalking", boolValue = true }, new EnemyBehaviourState { name = "Approaching", IsAnimTrigger = false, parameterString = "isWalking", boolValue = true }, new EnemyBehaviourState { name = "Intro", IsAnimTrigger = true, parameterString = "command" }, new EnemyBehaviourState { name = "Commanding", IsAnimTrigger = true, parameterString = "command" }, new EnemyBehaviourState { name = "Judging", IsAnimTrigger = false, parameterString = "isWalking", boolValue = false }, new EnemyBehaviourState { name = "Punishing", IsAnimTrigger = true, parameterString = "playerFailed" }, new EnemyBehaviourState { name = "Celebrating", IsAnimTrigger = true, parameterString = "playerPassed" }, new EnemyBehaviourState { name = "Departing", IsAnimTrigger = false, parameterString = "isWalking", boolValue = true } }; EnsureCollision(prefab, component); } } private static void EnsureNavigation(GameObject prefab, SimonSaysAI ai) { NavMeshAgent val = prefab.GetComponent(); if ((Object)(object)val == (Object)null) { val = prefab.AddComponent(); val.radius = 0.5f; val.height = 2f; val.baseOffset = 0f; val.angularSpeed = 240f; val.acceleration = 12f; val.autoBraking = true; val.areaMask = -1; Log.LogWarning((object)"[SimonSays] Prefab was missing a root NavMeshAgent; added a vanilla-compatible runtime agent."); } val.speed = ModConfig?.ApproachSpeed?.Value ?? 3.5f; ((EnemyAI)ai).agent = val; } internal static void EnsureScanNode(GameObject prefab) { //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) ScanNodeProperties val = null; ScanNodeProperties[] componentsInChildren = prefab.GetComponentsInChildren(true); foreach (ScanNodeProperties val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).gameObject == (Object)(object)prefab)) { bool flag = val2.creatureScanID >= 0; bool flag2 = (Object)(object)val != (Object)null && val.creatureScanID >= 0; bool flag3 = string.Equals(((Object)((Component)val2).gameObject).name, "ScanNode", StringComparison.Ordinal); bool flag4 = (Object)(object)val != (Object)null && string.Equals(((Object)((Component)val).gameObject).name, "ScanNode", StringComparison.Ordinal); if ((Object)(object)val == (Object)null || (flag && !flag2) || (flag == flag2 && flag3 && !flag4)) { val = val2; } } } if (componentsInChildren.Length > 1) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)$"[SimonSays] Found {componentsInChildren.Length} scan nodes; retiring every duplicate."); } } for (int j = 0; j < componentsInChildren.Length; j++) { if ((Object)(object)componentsInChildren[j] != (Object)(object)val) { RetireExtraScanNode(componentsInChildren[j], val, prefab); } } Transform val3 = (((Object)(object)val != (Object)null) ? ((Component)val).transform : FindOrCreateChild(prefab.transform, "ScanNode", new Vector3(0f, 1.25f, 0f))); ((Object)((Component)val3).gameObject).name = "ScanNode"; val3.localRotation = Quaternion.identity; val3.localScale = Vector3.one; TrySetTag(((Component)val3).gameObject, "DoNotSet"); TrySetLayer(((Component)val3).gameObject, "ScanNode"); EnsureHierarchyActive(val3, prefab.transform); ((Component)val3).gameObject.SetActive(true); if (!_loggedScanNodeLayer) { _loggedScanNodeLayer = true; ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)($"[SimonSays] Scan node layer resolved to {((Component)val3).gameObject.layer} " + string.Format("(NameToLayer(\"ScanNode\")={0}, fallback 22); ", LayerMask.NameToLayer("ScanNode")) + $"active={((Component)val3).gameObject.activeInHierarchy}.")); } } BoxCollider val4 = ((Component)val3).GetComponent(); if ((Object)(object)val4 == (Object)null) { val4 = ((Component)val3).gameObject.AddComponent(); } ((Collider)val4).enabled = true; ((Collider)val4).isTrigger = true; val4.center = Vector3.zero; val4.size = new Vector3(1.2f, 1.8f, 1.2f); if ((Object)(object)val == (Object)null) { val = ((Component)val3).gameObject.AddComponent(); } val.headerText = "Simon Says"; val.subText = "Only obey when Simon says"; val.maxRange = 13; val.minRange = 1; val.requiresLineOfSight = true; val.nodeType = 1; } private static void RetireExtraScanNode(ScanNodeProperties extra, ScanNodeProperties preferred, GameObject root) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)extra == (Object)null) { return; } Scene scene; if ((Object)(object)((Component)extra).gameObject == (Object)(object)root || ((Object)(object)preferred != (Object)null && (Object)(object)((Component)extra).gameObject == (Object)(object)((Component)preferred).gameObject)) { ((Behaviour)extra).enabled = false; scene = root.scene; if (((Scene)(ref scene)).IsValid()) { Object.Destroy((Object)(object)extra); } else { Object.DestroyImmediate((Object)(object)extra, true); } return; } GameObject gameObject = ((Component)extra).gameObject; gameObject.SetActive(false); Collider[] components = gameObject.GetComponents(); for (int i = 0; i < components.Length; i++) { components[i].enabled = false; } scene = root.scene; if (((Scene)(ref scene)).IsValid()) { Object.Destroy((Object)(object)gameObject); } else { Object.DestroyImmediate((Object)(object)gameObject, true); } } private static void EnsureCollision(GameObject prefab, SimonSaysAI ai) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) TrySetTag(prefab, "Enemy"); TrySetLayer(prefab, "Enemies"); Transform val = FindOrCreateChild(prefab.transform, "Collision", new Vector3(0f, 1f, 0f)); TrySetTag(((Component)val).gameObject, "Enemy"); TrySetLayer(((Component)val).gameObject, "Enemies"); BoxCollider obj = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); ((Collider)obj).enabled = true; ((Collider)obj).isTrigger = true; obj.center = Vector3.zero; obj.size = new Vector3(1.25f, 1.85f, 1.25f); Rigidbody obj2 = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); obj2.isKinematic = true; obj2.useGravity = false; obj2.detectCollisions = true; EnemyAICollisionDetect obj3 = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); obj3.mainScript = (EnemyAI)(object)ai; obj3.alwaysAllowHitting = true; obj3.canCollideWithEnemies = false; obj3.onlyCollideWhenGrounded = false; } private static EnemyType CreateEnemyType(GameObject prefab) { //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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //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_00f7: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown EnemyType val = ScriptableObject.CreateInstance(); val.enemyName = "Simon Says"; val.enemyPrefab = prefab; val.PowerLevel = ModConfig.PowerLevel.Value; val.DiversityPowerLevel = 1; val.MaxCount = 1; val.canDie = false; val.canBeStunned = false; val.canBeDestroyed = true; val.stunTimeMultiplier = 1f; val.stunGameDifficultyMultiplier = 1f; val.destroyOnDeath = false; val.doorSpeedMultiplier = 1f; val.isOutsideEnemy = false; val.isDaytimeEnemy = false; val.normalizedTimeInDayToLeave = 1f; val.probabilityCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 1f), new Keyframe(1f, 1f) }); val.numberSpawnedFalloff = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 1f), new Keyframe(1f, 1f) }); return val; } private static Transform FindOrCreateChild(Transform parent, string name, Vector3 localPosition) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) Transform val = parent.Find(name); if ((Object)(object)val != (Object)null) { return val; } val = new GameObject(name).transform; val.SetParent(parent, false); val.localPosition = localPosition; return val; } private static void TrySetTag(GameObject gameObject, string tag) { try { gameObject.tag = tag; } catch { } } private static void TrySetLayer(GameObject gameObject, string layerName) { if ((Object)(object)gameObject == (Object)null) { return; } int num = LayerMask.NameToLayer(layerName); if (num < 0) { num = ResolveLayerFallback(layerName); } if (num >= 0 && num <= 31) { gameObject.layer = num; return; } ManualLogSource log = Log; if (log != null) { log.LogWarning((object)$"[SimonSays] Layer '{layerName}' unresolved; '{((Object)gameObject).name}' stays on layer {gameObject.layer}."); } } private static int ResolveLayerFallback(string layerName) { if (string.Equals(layerName, "ScanNode", StringComparison.OrdinalIgnoreCase)) { return 22; } if (string.Equals(layerName, "Enemies", StringComparison.OrdinalIgnoreCase)) { return 19; } return -1; } private static void EnsureHierarchyActive(Transform child, Transform stopAt) { Transform val = child; while ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(true); if (!((Object)(object)val == (Object)(object)stopAt)) { val = val.parent; continue; } break; } } } public static class PluginInfo { public const string PLUGIN_GUID = "y4ngz.lethalcompany.simonsays"; public const string PLUGIN_NAME = "Y4NGZ Simon Says"; public const string PLUGIN_VERSION = "1.0.1"; } public sealed class SimonSaysConfig { private const string SectionGeneral = "General"; private const string SectionSpawning = "Spawning"; private const string SectionMovement = "Movement"; private const string SectionAbilities = "Abilities"; private const string SectionPresentation = "Audio and Presentation"; private const string SectionDiagnostics = "Diagnostics"; public ConfigEntry Enabled { get; } public ConfigEntry SpawnWeightMultiplier { get; } public ConfigEntry PowerLevel { get; } public ConfigEntry ApproachSpeed { get; } public ConfigEntry RetreatDuration { get; } public ConfigEntry RoundsPerEncounter { get; } public ConfigEntry ComplianceWindowSeconds { get; } public ConfigEntry TrapWindowSeconds { get; } public ConfigEntry SimonSaysChance { get; } public ConfigEntry TwoActionRoundChance { get; } public ConfigEntry BetweenRoundPause { get; } public ConfigEntry SpotlightIntensity { get; } public ConfigEntry DebugLogs { get; } public ConfigEntry VanishSmokeForceHdrpShaders { get; } public int Rounds => Mathf.Clamp(RoundsPerEncounter.Value, 1, 8); public float Window => Mathf.Clamp(ComplianceWindowSeconds.Value, 0.75f, 30f); public float TrapWindow => Mathf.Clamp(TrapWindowSeconds.Value, 0.5f, 30f); public float SimonChance => Mathf.Clamp01(SimonSaysChance.Value); public float TwoActionChance => Mathf.Clamp01(TwoActionRoundChance.Value); public float RoundPause => Mathf.Clamp(BetweenRoundPause.Value, 0f, 5f); public SimonSaysConfig(ConfigFile config) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Expected O, but got Unknown //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Expected O, but got Unknown //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Expected O, but got Unknown //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Expected O, but got Unknown bool saveOnConfigSet = config.SaveOnConfigSet; config.SaveOnConfigSet = false; try { SimonSaysConfigMigration.TryMigrate(config, Plugin.Log); ConfigSectionNameMigration.TryMigrate(config, Plugin.Log, "Simon Says"); Enabled = config.Bind("General", "Enabled", true, "Enable the Simon Says encounter."); SpawnWeightMultiplier = config.Bind("Spawning", "SpawnWeightMultiplier", 1f, new ConfigDescription("Multiplier applied to Simon Says' contextual moon/interior spawn policy. 0 disables natural spawns.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); PowerLevel = config.Bind("Spawning", "PowerLevel", 2.5f, new ConfigDescription("Indoor enemy power budget cost for Simon Says.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 20f), Array.Empty())); ApproachSpeed = config.Bind("Movement", "ApproachSpeed", 3.5f, new ConfigDescription("Movement speed while rolling toward the selected worker.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 20f), Array.Empty())); RetreatDuration = config.Bind("Movement", "RetreatDuration", 3f, new ConfigDescription("Seconds the cart rolls away before vanishing after its game.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 15f), Array.Empty())); RoundsPerEncounter = config.Bind("Abilities", "RoundsPerEncounter", 3, new ConfigDescription("Number of challenges issued during one encounter.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 8), Array.Empty())); ComplianceWindowSeconds = config.Bind("Abilities", "ComplianceWindowSeconds", 4f, new ConfigDescription("Seconds available to obey a command prefixed with 'Simon says'.", (AcceptableValueBase)(object)new AcceptableValueRange(0.75f, 30f), Array.Empty())); TrapWindowSeconds = config.Bind("Abilities", "TrapWindowSeconds", 1.75f, new ConfigDescription("Seconds a command without 'Simon says' remains dangerous while the correct response is to do nothing.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 30f), Array.Empty())); SimonSaysChance = config.Bind("Abilities", "SimonSaysChance", 0.6f, new ConfigDescription("Chance that a round is a genuine 'Simon says' command instead of a trap.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); TwoActionRoundChance = config.Bind("Abilities", "TwoActionRoundChance", 0.5f, new ConfigDescription("Chance that a round requests two actions instead of one.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); BetweenRoundPause = config.Bind("Abilities", "BetweenRoundPause", 0.3f, new ConfigDescription("Pause between one round's judgment and the next spoken command.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); SpotlightIntensity = config.Bind("Audio and Presentation", "SpotlightIntensity", 12f, new ConfigDescription("Brightness of the client-side focus spotlights.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 50f), Array.Empty())); DebugLogs = config.Bind("Diagnostics", "DebugLogs", false, "Write verbose encounter and RPC diagnostics."); VanishSmokeForceHdrpShaders = config.Bind("Diagnostics", "VanishSmokeForceHdrpShaders", false, "Force fallback HDRP particle shaders when intact source materials render incorrectly."); } finally { config.SaveOnConfigSet = saveOnConfigSet; if (saveOnConfigSet) { config.Save(); } } } } internal static class SimonSaysConfigMigration { private static readonly ConfigDefinition LegacySpawnWeight = new ConfigDefinition("Spawning", "SpawnWeight"); private static readonly Dictionary RemovedDefaults = new Dictionary { { new ConfigDefinition("Movement", "StoppingDistance"), "3.5" }, { new ConfigDefinition("Encounter", "WordGapSeconds"), "0.06" }, { new ConfigDefinition("Detection", "TurnAroundYawDegrees"), "150" }, { new ConfigDefinition("Detection", "AllowTurnAroundInTrapRounds"), "false" } }; internal static bool TryMigrate(ConfigFile config, ManualLogSource log) { string configFilePath = config.ConfigFilePath; if (!File.Exists(configFilePath)) { return false; } Dictionary dictionary = null; string text = null; try { dictionary = ReadValues(configFilePath); if (!ContainsLegacyConfig(dictionary)) { return false; } text = GetBackupPath(configFilePath); File.Copy(configFilePath, text, overwrite: false); File.WriteAllText(configFilePath, BuildMigratedConfig(dictionary), new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); config.Reload(); } catch (Exception ex) { string text2 = "The original config was not modified."; if (!string.IsNullOrEmpty(text) && File.Exists(text)) { try { File.Copy(text, configFilePath, overwrite: true); config.Reload(); text2 = "The original config was restored from its backup."; } catch (Exception ex2) { text2 = "Automatic restore also failed: " + ex2.GetBaseException().Message + ". Recover manually from " + text + "."; } } if (log != null) { log.LogWarning((object)("[SimonSays] Could not migrate legacy config: " + ex.GetBaseException().Message + " " + text2)); } return false; } List list = FindCustomizedDroppedKeys(dictionary); if (log != null) { log.LogInfo((object)("[SimonSays] Migrated legacy config to the compact DawnLib layout. Backup: " + text)); } if (list.Count > 0 && log != null) { log.LogWarning((object)("[SimonSays] These customized legacy settings are now authored source tuning and were not carried forward: " + string.Join(", ", list))); } return true; } private static bool ContainsLegacyConfig(Dictionary values) { foreach (ConfigDefinition key in values.Keys) { if (key.Section == "Spawning" || key.Section == "Visuals" || key.Section == "Movement" || key.Section == "Behavior" || key.Section == "Encounter" || key.Section == "Detection") { return true; } } return false; } private static string BuildMigratedConfig(Dictionary values) { string text = GetValue(values, "10 - Spawning", "SpawnWeightMultiplier", null); if (string.IsNullOrWhiteSpace(text)) { text = ((!float.TryParse(GetValue(values, LegacySpawnWeight, "30"), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) ? "1" : Math.Max(0f, Math.Min(5f, result / 30f)).ToString("0.###", CultureInfo.InvariantCulture)); } StringBuilder stringBuilder = new StringBuilder(); AppendSection(stringBuilder, "00 - General", ("Enabled", GetRetained(values, "00 - General", "General", "Enabled", "true"))); AppendSection(stringBuilder, "10 - Spawning", ("SpawnWeightMultiplier", text), ("PowerLevel", GetRetained(values, "10 - Spawning", "Spawning", "PowerLevel", "2.5"))); AppendSection(stringBuilder, "40 - Movement", ("ApproachSpeed", GetRetained(values, "40 - Movement", "Movement", "ApproachSpeed", "3.5")), ("RetreatDuration", GetRetained(values, "40 - Movement", "Behavior", "RetreatDuration", "3"))); AppendSection(stringBuilder, "60 - Abilities", ("RoundsPerEncounter", GetRetained(values, "60 - Abilities", "Encounter", "RoundsPerEncounter", "3")), ("ComplianceWindowSeconds", GetRetained(values, "60 - Abilities", "Encounter", "ComplianceWindowSeconds", "4")), ("TrapWindowSeconds", GetRetained(values, "60 - Abilities", "Encounter", "TrapWindowSeconds", "1.75")), ("SimonSaysChance", GetRetained(values, "60 - Abilities", "Encounter", "SimonSaysChance", "0.6")), ("TwoActionRoundChance", GetRetained(values, "60 - Abilities", "Encounter", "TwoActionRoundChance", "0.5")), ("BetweenRoundPause", GetRetained(values, "60 - Abilities", "Encounter", "BetweenRoundPause", "0.3"))); AppendSection(stringBuilder, "70 - Audio and Presentation", ("SpotlightIntensity", GetRetained(values, "70 - Audio and Presentation", "Visuals", "SpotlightIntensity", "12"))); AppendSection(stringBuilder, "99 - Diagnostics", ("DebugLogs", GetRetained(values, "99 - Diagnostics", "Behavior", "DebugLogs", "false")), ("VanishSmokeForceHdrpShaders", GetRetained(values, "99 - Diagnostics", "Visuals", "VanishSmokeForceHdrpShaders", "false"))); return stringBuilder.ToString(); } private static void AppendSection(StringBuilder output, string section, params (string Key, string Value)[] entries) { output.Append('[').Append(section).AppendLine("]"); for (int i = 0; i < entries.Length; i++) { output.Append(entries[i].Key).Append(" = ").AppendLine(entries[i].Value); } output.AppendLine(); } private static string GetRetained(Dictionary values, string currentSection, string legacySection, string key, string fallback) { return GetValue(values, currentSection, key, null) ?? GetValue(values, legacySection, key, fallback); } private static string GetValue(Dictionary values, string section, string key, string fallback) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown return GetValue(values, new ConfigDefinition(section, key), fallback); } private static string GetValue(Dictionary values, ConfigDefinition definition, string fallback) { if (!values.TryGetValue(definition, out var value)) { return fallback; } return value; } private static Dictionary ReadValues(string path) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown Dictionary dictionary = new Dictionary(); string text = string.Empty; string[] array = File.ReadAllLines(path); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.Length == 0 || text2.StartsWith("#", StringComparison.Ordinal)) { continue; } if (text2.StartsWith("[", StringComparison.Ordinal) && text2.EndsWith("]", StringComparison.Ordinal)) { text = text2.Substring(1, text2.Length - 2); continue; } int num = text2.IndexOf('='); if (num > 0) { string text3 = text2.Substring(0, num).Trim(); string value = text2.Substring(num + 1).Trim(); dictionary[new ConfigDefinition(text, text3)] = value; } } return dictionary; } private static List FindCustomizedDroppedKeys(Dictionary values) { List list = new List(); foreach (KeyValuePair removedDefault in RemovedDefaults) { if (values.TryGetValue(removedDefault.Key, out var value) && !ValuesEquivalent(value, removedDefault.Value)) { list.Add(removedDefault.Key.Section + "." + removedDefault.Key.Key); } } list.Sort(StringComparer.OrdinalIgnoreCase); return list; } private static bool ValuesEquivalent(string left, string right) { if (string.Equals(left.Trim(), right.Trim(), StringComparison.OrdinalIgnoreCase)) { return true; } if (float.TryParse(left, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(right, NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { return Math.Abs(result - result2) < 0.0001f; } return false; } private static string GetBackupPath(string configPath) { string text = configPath + ".pre-dawn.bak"; if (!File.Exists(text)) { return text; } for (int i = 2; i < 1000; i++) { string text2 = configPath + $".pre-dawn.{i}.bak"; if (!File.Exists(text2)) { return text2; } } throw new IOException("Could not allocate a Simon Says config backup filename."); } } internal sealed class SimonSaysSpawnWeights : IWeighted, IContextualWeighted { internal const int DefaultWeight = 3; internal const int MaximumWeight = 100; private readonly Func _multiplier; internal SimonSaysSpawnWeights(Func multiplier) { _multiplier = multiplier ?? throw new ArgumentNullException("multiplier"); } public int GetWeight() { return Scale(3, 1f); } public int GetWeight(SpawnWeightContext context) { int moonWeight = GetMoonWeight(((SpawnWeightContext)(ref context)).Moon); if (moonWeight <= 0) { return 0; } return Scale(moonWeight, GetDungeonMultiplier(((SpawnWeightContext)(ref context)).Dungeon)); } internal static int GetMoonWeight(DawnMoonInfo moon) { if (moon == null) { return 3; } if (((DawnBaseInfo)(object)moon).HasTag(Tags.Company) || ((DawnBaseInfo)(object)moon).HasTag(Tags.Unimplemented) || KeyEquals(((DawnBaseInfo)(object)moon).TypedKey, MoonKeys.Test)) { return 0; } if (KeyEquals(((DawnBaseInfo)(object)moon).TypedKey, MoonKeys.Experimentation)) { return 1; } if (KeyEquals(((DawnBaseInfo)(object)moon).TypedKey, MoonKeys.Assurance) || KeyEquals(((DawnBaseInfo)(object)moon).TypedKey, MoonKeys.Vow)) { return 3; } if (KeyEquals(((DawnBaseInfo)(object)moon).TypedKey, MoonKeys.Offense) || KeyEquals(((DawnBaseInfo)(object)moon).TypedKey, MoonKeys.March) || KeyEquals(((DawnBaseInfo)(object)moon).TypedKey, MoonKeys.Embrion)) { return 5; } if (KeyEquals(((DawnBaseInfo)(object)moon).TypedKey, MoonKeys.Adamance)) { return 7; } if (KeyEquals(((DawnBaseInfo)(object)moon).TypedKey, MoonKeys.Rend) || KeyEquals(((DawnBaseInfo)(object)moon).TypedKey, MoonKeys.Dine)) { return 9; } if (KeyEquals(((DawnBaseInfo)(object)moon).TypedKey, MoonKeys.Titan) || KeyEquals(((DawnBaseInfo)(object)moon).TypedKey, MoonKeys.Artifice) || KeyEquals(((DawnBaseInfo)(object)moon).TypedKey, MoonKeys.Liquidation)) { return 11; } if (((DawnBaseInfo)(object)moon).HasTag(Tags.Paid)) { return 8; } ((DawnBaseInfo)(object)moon).HasTag(Tags.Free); return 3; } internal static float GetDungeonMultiplier(DawnDungeonInfo dungeon) { if (dungeon == null) { return 1f; } if (KeyEquals(((DawnBaseInfo)(object)dungeon).TypedKey, DungeonKeys.FacilityFlow) || KeyEquals(((DawnBaseInfo)(object)dungeon).TypedKey, DungeonKeys.FacilityFlowThreeExits) || KeyEquals(((DawnBaseInfo)(object)dungeon).TypedKey, DungeonKeys.FacilityFlowExtraLarge) || ((DawnBaseInfo)(object)dungeon).HasTag(Tags.Industrial) || ((DawnBaseInfo)(object)dungeon).HasTag(Tags.Mechanical) || ((DawnBaseInfo)(object)dungeon).HasTag(Tags.Factory) || ((DawnBaseInfo)(object)dungeon).HasTag(Tags.Bunker)) { return 1.25f; } if (KeyEquals(((DawnBaseInfo)(object)dungeon).TypedKey, DungeonKeys.MansionFlow) || ((DawnBaseInfo)(object)dungeon).HasTag(Tags.Gothic) || ((DawnBaseInfo)(object)dungeon).HasTag(Tags.Grand) || ((DawnBaseInfo)(object)dungeon).HasTag(Tags.Ornate) || ((DawnBaseInfo)(object)dungeon).HasTag(Tags.Lavish) || ((DawnBaseInfo)(object)dungeon).HasTag(Tags.Eerie)) { return 1f; } if (KeyEquals(((DawnBaseInfo)(object)dungeon).TypedKey, DungeonKeys.MineshaftFlow) || ((DawnBaseInfo)(object)dungeon).HasTag(Tags.Cavern) || ((DawnBaseInfo)(object)dungeon).HasTag(Tags.Quarry) || ((DawnBaseInfo)(object)dungeon).HasTag(Tags.Flooded)) { return 0.5f; } return 0.75f; } private int Scale(int moonWeight, float dungeonMultiplier) { float num = Mathf.Clamp(_multiplier(), 0f, 5f); return Mathf.Clamp(Mathf.RoundToInt((float)moonWeight * dungeonMultiplier * num), 0, 100); } private static bool KeyEquals(NamespacedKey left, NamespacedKey right) where T : INamespaced { if (left != null && right != null) { return ((object)left).Equals((object?)right); } return false; } } internal static class SimonSaysTuning { internal const int MaxCount = 1; internal const float StoppingDistance = 3.5f; internal const float WordGapSeconds = 0.06f; internal const float TurnAroundYawDegrees = 150f; internal const bool AllowTurnAroundInTrapRounds = false; } } namespace SimonSays.Utils { public static class CreatureAudio { private static readonly HashSet _warnedKeys = new HashSet(); public static void PlayRandom(AudioSource source, AudioClip[] pool, string poolName, float volumeScale = 1f) { if ((Object)(object)source == (Object)null) { WarnOnce(poolName + ":source=null"); return; } if (pool == null || pool.Length == 0) { WarnOnce(poolName + ":empty"); return; } AudioClip val = pool[Random.Range(0, pool.Length)]; if ((Object)(object)val == (Object)null) { WarnOnce(poolName + ":nullclip"); } else { source.PlayOneShot(val, volumeScale); } } public static void StartLoop(AudioSource source, AudioClip clip) { if (!((Object)(object)source == (Object)null) && !((Object)(object)clip == (Object)null) && (!source.isPlaying || !((Object)(object)source.clip == (Object)(object)clip))) { source.loop = true; source.clip = clip; source.Play(); } } public static void StopLoop(AudioSource source) { if (!((Object)(object)source == (Object)null) && source.isPlaying) { source.Stop(); source.clip = null; } } private static void WarnOnce(string key) { if (_warnedKeys.Add(key)) { Debug.LogWarning((object)("[CreatureAudio] " + key)); } } } } namespace SimonSays.AI { public static class BlackHoleEffect { public static void BeginFor(PlayerControllerB player) { //IL_000c: 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_001c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return; } try { player.KillPlayer(Vector3.zero, true, (CauseOfDeath)2, 0, default(Vector3), false); } catch (Exception arg) { Plugin.Log.LogError((object)$"BlackHoleEffect.BeginFor: {arg}"); } } } public enum SimonState { ROAMING, APPROACHING, INTRO, COMMANDING, JUDGING, PUNISHING, CELEBRATING, DEPARTING } public class SimonSaysAI : EnemyAI { private AudioSource _sfxSource; private AudioSource _voiceSource; private const float VoiceVolume = 1.35f; private const float SfxVolume = 1.15f; private const float FocusLeadIn = 0.45f; private const float PunishHold = 1.5f; private const float DespawnRpcGrace = 0.4f; public AudioClip wheelsRollLoopClip; public AudioClip jesterSwingClip; public AudioSource loopSource; private bool _wheelsLoopDesired; private Coroutine _stateCoroutine; private Coroutine _speechCoroutine; private bool _encounterStarted; private bool _encounterFinished; private ulong _targetClientId; private bool _hasTarget; private int _awaitingRoundIndex = -1; private bool _roundReported; private bool _roundComplied; private bool _judging; private SimonRound _judgeRound; private int _judgeRoundIndex = -1; private bool _judgeReported; private readonly Dictionary _edgeState = new Dictionary(); private readonly Dictionary _actionEnteredFrame = new Dictionary(); private readonly List _satisfied = new List(2); private int _nextOrderedIndex; private int _orderedStepAvailableFrame; private float _yawNet; private float _lastYaw; private bool _turnAroundFired; private SpotlightController _observerSpotlight; private Vector3 _lastAnimPosition; private bool _animInitialized; private float _smoothedSpeed; private bool _walkAnimOn; private static SimonSaysConfig Cfg => Plugin.ModConfig; private float ApproachSpeed => Cfg?.ApproachSpeed?.Value ?? 3.5f; private float StoppingDist => 3.5f; private float RetreatDuration => Cfg?.RetreatDuration?.Value ?? 3f; private bool DebugLogs => Cfg?.DebugLogs?.Value == true; private float WordGap => 0.06f; private void DLog(string m) { if (DebugLogs) { Plugin.Log.LogInfo((object)("[SimonSays] " + m)); } } private static float ClipLen(AudioClip c) { if (!((Object)(object)c != (Object)null)) { return 0f; } return c.length; } public override void Awake() { try { ((EnemyAI)this).Awake(); Transform val = ((Component)this).transform.Find("CreatureSFX"); if ((Object)(object)val != (Object)null) { _sfxSource = ((Component)val).GetComponent(); } Transform val2 = ((Component)this).transform.Find("CreatureVoice"); if ((Object)(object)val2 != (Object)null) { _voiceSource = ((Component)val2).GetComponent(); } if ((Object)(object)base.creatureSFX == (Object)null && (Object)(object)_sfxSource != (Object)null) { base.creatureSFX = _sfxSource; } if ((Object)(object)base.creatureVoice == (Object)null && (Object)(object)_voiceSource != (Object)null) { base.creatureVoice = _voiceSource; } if ((Object)(object)_sfxSource == (Object)null) { _sfxSource = base.creatureSFX; } if ((Object)(object)_voiceSource == (Object)null) { _voiceSource = base.creatureVoice; } if ((Object)(object)base.creatureAnimator == (Object)null) { base.creatureAnimator = ((Component)this).GetComponent(); } if ((Object)(object)base.eye == (Object)null) { Transform val3 = ((Component)this).transform.Find("Eye"); if ((Object)(object)val3 != (Object)null) { base.eye = val3; } } ConfigureVoiceMix(); } catch (Exception arg) { Plugin.Log.LogError((object)$"SimonSaysAI.Awake: {arg}"); } } public override void Start() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) try { ((EnemyAI)this).Start(); Plugin.EnsureScanNode(((Component)this).gameObject); ConfigureVoiceMix(); if ((Object)(object)base.agent != (Object)null) { base.agent.speed = ApproachSpeed; base.agent.stoppingDistance = 0f; if (base.agent.areaMask == 0) { base.agent.areaMask = -1; } base.agent.autoTraverseOffMeshLink = true; if (base.openDoorSpeedMultiplier <= 0f) { base.openDoorSpeedMultiplier = (((Object)(object)base.enemyType != (Object)null && base.enemyType.doorSpeedMultiplier > 0f) ? base.enemyType.doorSpeedMultiplier : 1f); } } _lastAnimPosition = ((Component)this).transform.position; _animInitialized = true; if (((NetworkBehaviour)this).IsServer) { ((EnemyAI)this).SwitchToBehaviourClientRpc(0); } DLog($"spawned. IsServer={((NetworkBehaviour)this).IsServer} agentOnNavMesh={(Object)(object)base.agent != (Object)null && base.agent.isOnNavMesh} " + $"areaMask={(((Object)(object)base.agent != (Object)null) ? base.agent.areaMask : 0)} doorSpeed={base.openDoorSpeedMultiplier}"); } catch (Exception arg) { Plugin.Log.LogError((object)$"SimonSaysAI.Start: {arg}"); } } public override void Update() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) try { ((EnemyAI)this).Update(); UpdateWalkAnimation(); if (((NetworkBehaviour)this).IsServer) { int num; if ((Object)(object)base.agent != (Object)null) { Vector3 velocity = base.agent.velocity; num = ((((Vector3)(ref velocity)).sqrMagnitude > 0.01f) ? 1 : 0); } else { num = 0; } bool flag = (byte)num != 0; if (flag != _wheelsLoopDesired) { _wheelsLoopDesired = flag; SetWheelsLoopClientRpc(flag); } } if (_judging) { RunLocalObedienceCheck(); } } catch (Exception arg) { Plugin.Log.LogError((object)$"SimonSaysAI.Update: {arg}"); } } private void UpdateWalkAnimation() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.creatureAnimator == (Object)null) { return; } if (!_animInitialized) { _lastAnimPosition = ((Component)this).transform.position; _animInitialized = true; return; } Vector3 val = ((Component)this).transform.position - _lastAnimPosition; val.y = 0f; _lastAnimPosition = ((Component)this).transform.position; float num = ((Time.deltaTime > 0f) ? (((Vector3)(ref val)).magnitude / Time.deltaTime) : 0f); _smoothedSpeed = Mathf.Lerp(_smoothedSpeed, num, 1f - Mathf.Exp(-8f * Time.deltaTime)); if (_walkAnimOn && _smoothedSpeed < 0.1f) { _walkAnimOn = false; } else if (!_walkAnimOn && _smoothedSpeed > 0.22f) { _walkAnimOn = true; } base.creatureAnimator.SetBool("isWalking", _walkAnimOn); } public override void DoAIInterval() { try { ((EnemyAI)this).DoAIInterval(); if (((NetworkBehaviour)this).IsServer && !((Object)(object)StartOfRound.Instance == (Object)null) && !StartOfRound.Instance.allPlayersDead && !_encounterFinished) { switch ((SimonState)base.currentBehaviourStateIndex) { case SimonState.ROAMING: DoRoaming(); break; case SimonState.APPROACHING: DoApproaching(); break; } } } catch (Exception arg) { Plugin.Log.LogError((object)$"SimonSaysAI.DoAIInterval: {arg}"); } } public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { } public override void KillEnemy(bool destroy = false) { CleanupEffects(); } private void DoRoaming() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)base.agent == (Object)null)) { if (base.currentSearch == null || !base.currentSearch.inProgress) { ((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null); } base.agent.speed = ApproachSpeed; base.agent.stoppingDistance = 0f; PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForPlayer(70f, 30, -1); if ((Object)(object)val != (Object)null) { ((EnemyAI)this).StopSearch(base.currentSearch, true); _targetClientId = val.actualClientId; _hasTarget = true; base.targetPlayer = val; DLog("acquired target " + val.playerUsername); SetTargetPlayerClientRpc(_targetClientId); ((EnemyAI)this).SwitchToBehaviourClientRpc(1); } } } private void DoApproaching() { //IL_004c: 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_006e: Unknown result type (might be due to invalid IL or missing references) if (!TargetStillValid()) { AbortEncounter(); } else { if ((Object)(object)base.agent == (Object)null) { return; } base.agent.speed = ApproachSpeed; base.agent.stoppingDistance = StoppingDist; ((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false); if (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) <= StoppingDist && !_encounterStarted) { _encounterStarted = true; if (base.currentSearch != null && base.currentSearch.inProgress) { ((EnemyAI)this).StopSearch(base.currentSearch, true); } HoldStationForEncounter(); _stateCoroutine = ((MonoBehaviour)this).StartCoroutine(EncounterRoutine()); } } } private void HoldStationForEncounter() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; if (!((Object)(object)base.agent == (Object)null) && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.ResetPath(); base.agent.velocity = Vector3.zero; base.agent.isStopped = true; } } private bool TargetStillValid() { if (_hasTarget && (Object)(object)base.targetPlayer != (Object)null && !base.targetPlayer.isPlayerDead) { return base.targetPlayer.isPlayerControlled; } return false; } private void FaceTarget() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0051: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)base.targetPlayer == (Object)null)) { Vector3 val = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { ((Component)this).transform.rotation = Quaternion.LookRotation(val); } } } private IEnumerator EncounterRoutine() { FaceTarget(); ((EnemyAI)this).SwitchToBehaviourClientRpc(2); BeginFocusClientRpc(_targetClientId); yield return (object)new WaitForSeconds(0.45f); PlayIntroClientRpc(); yield return (object)new WaitForSeconds(ClipLen(Plugin.LetsPlayClip) + WordGap); int rounds = ((Cfg != null) ? Cfg.Rounds : 3); for (int i = 0; i < rounds; i++) { if (!TargetStillValid()) { yield return DepartRoutine(); yield break; } SimonRound round = SimonSaysWords.Roll((Cfg != null) ? Cfg.SimonChance : 0.6f, (Cfg != null) ? Cfg.TwoActionChance : 0.5f, allowTurnAroundInTraps: false); int packed = round.Pack(); DLog($"round {i + 1}/{rounds}: \"{round}\""); _awaitingRoundIndex = i; _roundReported = false; _roundComplied = false; ((EnemyAI)this).SwitchToBehaviourClientRpc(3); SpeakRoundClientRpc(packed, i); yield return (object)new WaitForSeconds(SimonSaysWords.UtteranceLength(round, WordGap) + 0.05f); if (!TargetStillValid()) { yield return DepartRoutine(); yield break; } ((EnemyAI)this).SwitchToBehaviourClientRpc(4); OpenWindowClientRpc(packed, i); float window = ((!round.SimonSaid) ? ((Cfg != null) ? Cfg.TrapWindow : 1.75f) : ((Cfg != null) ? Cfg.Window : 4f)); float elapsed = 0f; while (elapsed < window && !_roundReported && TargetStillValid()) { elapsed += Time.deltaTime; yield return null; } CloseWindowClientRpc(); _awaitingRoundIndex = -1; if (!TargetStillValid()) { yield return DepartRoutine(); yield break; } bool flag = _roundReported && _roundComplied; bool flag2 = (round.SimonSaid ? flag : (!flag)); DLog(string.Format("round {0} complied={1} simonSaid={2} -> {3}", i + 1, flag, round.SimonSaid, flag2 ? "PASS" : "FAIL")); if (!flag2) { yield return PunishRoutine(); yield break; } float num = ((Cfg != null) ? Cfg.RoundPause : 0.3f); if (num > 0f) { yield return (object)new WaitForSeconds(num); } } ((EnemyAI)this).SwitchToBehaviourClientRpc(6); PlayCongratulationsClientRpc(); yield return (object)new WaitForSeconds(ClipLen(Plugin.CongratulationsClip) + 0.2f); yield return DepartRoutine(); } private IEnumerator PunishRoutine() { ((EnemyAI)this).SwitchToBehaviourClientRpc(5); PlayerFailedClientRpc(_targetClientId); yield return (object)new WaitForSeconds(1.5f); yield return DepartRoutine(); } private IEnumerator DepartRoutine() { if (!_encounterFinished) { _encounterFinished = true; ((EnemyAI)this).SwitchToBehaviourClientRpc(7); EndFocusClientRpc(); PlayGoodbyeClientRpc(); SetRetreatDestination(); float num = Mathf.Max(RetreatDuration, ClipLen(Plugin.GoodbyeClip) + 0.2f); yield return (object)new WaitForSeconds(num); VanishClientRpc(((Component)this).transform.position); yield return (object)new WaitForSeconds(0.4f); DespawnSelf(); } } private void SetRetreatDestination() { //IL_0073: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0107: 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) try { if (!((Object)(object)base.agent == (Object)null) && base.agent.isOnNavMesh) { base.agent.isStopped = false; base.agent.speed = ApproachSpeed; base.agent.stoppingDistance = 0f; Vector3 val = (((Object)(object)base.targetPlayer != (Object)null) ? ((Component)base.targetPlayer).transform.position : ((Component)this).transform.position); Vector3 val2 = ((Component)this).transform.position - val; val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = ((Component)this).transform.forward; } Vector3 val3 = ((Component)this).transform.position + ((Vector3)(ref val2)).normalized * 15f; int num = ((base.agentMask != 0) ? base.agentMask : (-1)); NavMeshHit val4 = default(NavMeshHit); if (NavMesh.SamplePosition(val3, ref val4, 12f, num)) { ((EnemyAI)this).SetDestinationToPosition(((NavMeshHit)(ref val4)).position, false); } else { ((EnemyAI)this).SetDestinationToPosition(val3, false); } } } catch (Exception arg) { Plugin.Log.LogError((object)$"SetRetreatDestination: {arg}"); } } private void DespawnSelf() { try { if ((Object)(object)RoundManager.Instance != (Object)null && ((NetworkBehaviour)this).IsServer && (Object)(object)((NetworkBehaviour)this).NetworkObject != (Object)null && ((NetworkBehaviour)this).NetworkObject.IsSpawned) { RoundManager.Instance.DespawnEnemyOnServer(((NetworkBehaviour)this).NetworkObject); } } catch (Exception arg) { Plugin.Log.LogError((object)$"despawn failed: {arg}"); } } private void AbortEncounter() { if (!_encounterFinished) { _encounterStarted = true; if (_stateCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_stateCoroutine); _stateCoroutine = null; } _stateCoroutine = ((MonoBehaviour)this).StartCoroutine(DepartRoutine()); } } [ClientRpc] public void SetTargetPlayerClientRpc(ulong clientId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_00ce: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3618932334u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, clientId); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 3618932334u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; try { _targetClientId = clientId; _hasTarget = true; base.targetPlayer = ResolvePlayer(clientId) ?? base.targetPlayer; } catch (Exception arg) { Plugin.Log.LogError((object)$"SetTargetPlayerClientRpc: {arg}"); } } [ClientRpc] public void BeginFocusClientRpc(ulong targetClientId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_00ce: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1593938165u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, targetClientId); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1593938165u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; try { _targetClientId = targetClientId; _hasTarget = true; PlayerControllerB val3 = ResolvePlayer(targetClientId); if ((Object)(object)val3 != (Object)null) { base.targetPlayer = val3; } if (IsLocalTarget()) { PlayerControllerB val4 = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.localPlayerController : null); if ((Object)(object)val4 != (Object)null) { SimonSaysFocusEffect.Begin(this, val4, Cfg?.SpotlightIntensity?.Value ?? 8f); } } else if ((Object)(object)val3 != (Object)null) { if ((Object)(object)_observerSpotlight == (Object)null) { _observerSpotlight = SpotlightController.SpawnFor(val3, Cfg?.SpotlightIntensity?.Value ?? 8f); } else { _observerSpotlight.Retarget(val3); } } } catch (Exception arg) { Plugin.Log.LogError((object)$"BeginFocusClientRpc: {arg}"); } } [ClientRpc] public void EndFocusClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1344786899u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1344786899u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; try { EndFocusLocal(); } catch (Exception arg) { Plugin.Log.LogError((object)$"EndFocusClientRpc: {arg}"); } } private void EndFocusLocal() { SimonSaysFocusEffect.EndFor(this); if ((Object)(object)_observerSpotlight != (Object)null) { _observerSpotlight.Despawn(); _observerSpotlight = null; } } [ClientRpc] public void PlayIntroClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1746222514u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1746222514u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; try { SpeakClips(new List { Plugin.LetsPlayClip }); } catch (Exception arg) { Plugin.Log.LogError((object)$"PlayIntroClientRpc: {arg}"); } } [ClientRpc] public void SpeakRoundClientRpc(int packedRound, int roundIndex) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0096: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(212779188u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, packedRound); BytePacker.WriteValueBitPacked(val, roundIndex); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 212779188u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; try { SimonRound round = SimonRound.Unpack(packedRound); SpeakClips(SimonSaysWords.BuildUtterance(round)); } catch (Exception arg) { Plugin.Log.LogError((object)$"SpeakRoundClientRpc: {arg}"); } } [ClientRpc] public void OpenWindowClientRpc(int packedRound, int roundIndex) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0096: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2369853749u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, packedRound); BytePacker.WriteValueBitPacked(val, roundIndex); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2369853749u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; try { if (IsLocalTarget()) { BeginLocalJudging(SimonRound.Unpack(packedRound), roundIndex); } } catch (Exception arg) { Plugin.Log.LogError((object)$"OpenWindowClientRpc: {arg}"); } } [ClientRpc] public void CloseWindowClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(447314282u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 447314282u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; _judging = false; _judgeRoundIndex = -1; } } } [ClientRpc] public void PlayCongratulationsClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3841940082u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 3841940082u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; try { SpeakClips(new List { Plugin.CongratulationsClip }); } catch (Exception arg) { Plugin.Log.LogError((object)$"PlayCongratulationsClientRpc: {arg}"); } } [ClientRpc] public void PlayGoodbyeClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2046626769u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2046626769u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; try { SpeakClips(new List { Plugin.GoodbyeClip }); } catch (Exception arg) { Plugin.Log.LogError((object)$"PlayGoodbyeClientRpc: {arg}"); } } [ClientRpc] public void PlayerFailedClientRpc(ulong targetClientId) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_00ce: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3584274768u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, targetClientId); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 3584274768u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; try { _judging = false; if (IsLocalTarget()) { EndFocusLocal(); PlayerControllerB val3 = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.localPlayerController : null); if ((Object)(object)val3 != (Object)null) { BlackHoleEffect.BeginFor(val3); } } } catch (Exception arg) { Plugin.Log.LogError((object)$"PlayerFailedClientRpc: {arg}"); } } [ClientRpc] public void VanishClientRpc(Vector3 position) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00ea: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1932661538u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref position); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1932661538u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; try { EndFocusLocal(); StopSpeech(); CreatureAudio.StopLoop(loopSource); VanishSmokeEffect.SpawnAt(position, Cfg != null && Cfg.VanishSmokeForceHdrpShaders.Value); ((EnemyAI)this).EnableEnemyMesh(false, false, false); } catch (Exception arg) { Plugin.Log.LogError((object)$"VanishClientRpc: {arg}"); } } [ClientRpc] public void SetWheelsLoopClientRpc(bool on) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1535394079u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref on, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1535394079u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (on) { CreatureAudio.StartLoop(loopSource, wheelsRollLoopClip); } else { CreatureAudio.StopLoop(loopSource); } } } [ServerRpc(RequireOwnership = false)] public void ReportRoundOutcomeServerRpc(int roundIndex, bool complied, ServerRpcParams rpcParams = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1726491939u, rpcParams, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, roundIndex); ((FastBufferWriter)(ref val)).WriteValueSafe(ref complied, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 1726491939u, rpcParams, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; try { if (rpcParams.Receive.SenderClientId == _targetClientId && roundIndex == _awaitingRoundIndex) { _roundReported = true; _roundComplied = complied; DLog($"target reported round {roundIndex}: complied={complied}"); } } catch (Exception arg) { Plugin.Log.LogError((object)$"ReportRoundOutcomeServerRpc: {arg}"); } } private void SpeakClips(List clips) { StopSpeech(); if (clips != null && clips.Count != 0) { _speechCoroutine = ((MonoBehaviour)this).StartCoroutine(SpeakRoutine(clips)); } } private void StopSpeech() { if (_speechCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_speechCoroutine); _speechCoroutine = null; } } private IEnumerator SpeakRoutine(List clips) { AudioSource src = _voiceSource ?? base.creatureVoice; if ((Object)(object)src == (Object)null) { yield break; } float gap = WordGap; for (int i = 0; i < clips.Count; i++) { AudioClip val = clips[i]; if (!((Object)(object)val == (Object)null)) { if ((Object)(object)src == (Object)null) { yield break; } src.PlayOneShot(val, 1.35f); yield return (object)new WaitForSeconds(val.length); if (i < clips.Count - 1 && gap > 0f) { yield return (object)new WaitForSeconds(gap); } } } _speechCoroutine = null; } private void BeginLocalJudging(SimonRound round, int roundIndex) { _judgeRound = round; _judgeRoundIndex = roundIndex; _judgeReported = false; _judging = true; _nextOrderedIndex = 0; _orderedStepAvailableFrame = Time.frameCount; _satisfied.Clear(); _edgeState.Clear(); _actionEnteredFrame.Clear(); _turnAroundFired = false; _yawNet = 0f; PlayerControllerB val = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.localPlayerController : null); _lastYaw = (((Object)(object)val != (Object)null) ? LocalYaw(val) : 0f); ActionType[] array = round.Sequence(); for (int i = 0; i < array.Length; i++) { _edgeState[array[i]] = IsPlayerDoingAction(val, array[i], this); } } private void RunLocalObedienceCheck() { if (_judgeReported) { return; } PlayerControllerB val = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.localPlayerController : null); if ((Object)(object)val == (Object)null) { return; } UpdateTurnAroundTracking(val); ActionType[] array = _judgeRound.Sequence(); foreach (ActionType actionType in array) { bool flag = IsPlayerDoingAction(val, actionType, this); if (!_edgeState.TryGetValue(actionType, out var value)) { value = false; } _edgeState[actionType] = flag; int num; if (flag) { num = ((!value) ? 1 : 0); if (num != 0) { _actionEnteredFrame[actionType] = Time.frameCount; } } else { num = 0; } if (num != 0) { if (!_judgeRound.SimonSaid) { ReportOutcome(complied: true); return; } if (!_judgeRound.Ordered && !_satisfied.Contains(actionType)) { _satisfied.Add(actionType); } } } if (!_judgeRound.SimonSaid) { return; } if (_judgeRound.Ordered) { while (_nextOrderedIndex < array.Length) { ActionType key = array[_nextOrderedIndex]; if (!_edgeState.TryGetValue(key, out var value2) || !value2 || !_actionEnteredFrame.TryGetValue(key, out var value3) || value3 < _orderedStepAvailableFrame) { break; } _nextOrderedIndex++; _orderedStepAvailableFrame = Time.frameCount; } } if (_judgeRound.Ordered ? (_nextOrderedIndex >= array.Length) : (_satisfied.Count >= array.Length)) { ReportOutcome(complied: true); } } private void ReportOutcome(bool complied) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) _judgeReported = true; _judging = false; ReportRoundOutcomeServerRpc(_judgeRoundIndex, complied); } private void UpdateTurnAroundTracking(PlayerControllerB local) { if (!_turnAroundFired && _judgeRound.Names(ActionType.TurnAround)) { float num = LocalYaw(local); float num2 = Mathf.DeltaAngle(_lastYaw, num); _lastYaw = num; num2 = Mathf.Clamp(num2, -45f, 45f); _yawNet += num2; float num3 = 150f; if (Mathf.Abs(_yawNet) >= num3) { _turnAroundFired = true; } } } private static float LocalYaw(PlayerControllerB player) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return 0f; } return (((Object)(object)player.gameplayCamera != (Object)null) ? ((Component)player.gameplayCamera).transform : ((Component)player).transform).eulerAngles.y; } public static bool IsPlayerDoingAction(PlayerControllerB player, ActionType action, SimonSaysAI context = null) { try { if ((Object)(object)player == (Object)null) { return false; } switch (action) { case ActionType.Jump: return player.isFallingFromJump || ((Object)(object)player.playerBodyAnimator != (Object)null && player.playerBodyAnimator.GetBool("Jumping")); case ActionType.Crouch: return player.isCrouching; case ActionType.Dance: return player.performingEmote; case ActionType.TurnAround: return (Object)(object)context != (Object)null && context._turnAroundFired; } } catch (Exception arg) { Plugin.Log.LogError((object)$"IsPlayerDoingAction: {arg}"); } return false; } private void ConfigureVoiceMix() { ConfigureSource(_sfxSource, 1.15f); ConfigureSource(_voiceSource, 1.35f); ConfigureSource(base.creatureSFX, 1.15f); ConfigureSource(base.creatureVoice, 1.35f); ConfigureSource(loopSource, 1.05f); } private static void ConfigureSource(AudioSource source, float volume) { if (!((Object)(object)source == (Object)null)) { source.volume = Mathf.Max(source.volume, volume); source.spatialBlend = Mathf.Max(source.spatialBlend, 0.65f); source.maxDistance = Mathf.Max(source.maxDistance, 30f); } } private bool IsLocalTarget() { PlayerControllerB val = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.localPlayerController : null); if ((Object)(object)val != (Object)null) { return val.actualClientId == _targetClientId; } return false; } private static PlayerControllerB ResolvePlayer(ulong clientId) { if ((Object)(object)StartOfRound.Instance == (Object)null) { return null; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && val.actualClientId == clientId) { return val; } } return null; } private void CleanupEffects() { EndFocusLocal(); StopSpeech(); CreatureAudio.StopLoop(loopSource); } public void OnDestroy() { try { ((EnemyAI)this).OnDestroy(); CleanupEffects(); } catch (Exception arg) { Plugin.Log.LogError((object)$"SimonSaysAI.OnDestroy: {arg}"); } } public void Anim_JesterSwing() { try { if ((Object)(object)jesterSwingClip != (Object)null && (Object)(object)base.creatureSFX != (Object)null) { base.creatureSFX.PlayOneShot(jesterSwingClip, 1.15f); } } catch (Exception arg) { Plugin.Log.LogError((object)$"Anim_JesterSwing: {arg}"); } } protected override void __initializeVariables() { ((EnemyAI)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(3618932334u, new RpcReceiveHandler(__rpc_handler_3618932334), "SetTargetPlayerClientRpc"); ((NetworkBehaviour)this).__registerRpc(1593938165u, new RpcReceiveHandler(__rpc_handler_1593938165), "BeginFocusClientRpc"); ((NetworkBehaviour)this).__registerRpc(1344786899u, new RpcReceiveHandler(__rpc_handler_1344786899), "EndFocusClientRpc"); ((NetworkBehaviour)this).__registerRpc(1746222514u, new RpcReceiveHandler(__rpc_handler_1746222514), "PlayIntroClientRpc"); ((NetworkBehaviour)this).__registerRpc(212779188u, new RpcReceiveHandler(__rpc_handler_212779188), "SpeakRoundClientRpc"); ((NetworkBehaviour)this).__registerRpc(2369853749u, new RpcReceiveHandler(__rpc_handler_2369853749), "OpenWindowClientRpc"); ((NetworkBehaviour)this).__registerRpc(447314282u, new RpcReceiveHandler(__rpc_handler_447314282), "CloseWindowClientRpc"); ((NetworkBehaviour)this).__registerRpc(3841940082u, new RpcReceiveHandler(__rpc_handler_3841940082), "PlayCongratulationsClientRpc"); ((NetworkBehaviour)this).__registerRpc(2046626769u, new RpcReceiveHandler(__rpc_handler_2046626769), "PlayGoodbyeClientRpc"); ((NetworkBehaviour)this).__registerRpc(3584274768u, new RpcReceiveHandler(__rpc_handler_3584274768), "PlayerFailedClientRpc"); ((NetworkBehaviour)this).__registerRpc(1932661538u, new RpcReceiveHandler(__rpc_handler_1932661538), "VanishClientRpc"); ((NetworkBehaviour)this).__registerRpc(1535394079u, new RpcReceiveHandler(__rpc_handler_1535394079), "SetWheelsLoopClientRpc"); ((NetworkBehaviour)this).__registerRpc(1726491939u, new RpcReceiveHandler(__rpc_handler_1726491939), "ReportRoundOutcomeServerRpc"); ((EnemyAI)this).__initializeRpcs(); } private static void __rpc_handler_3618932334(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong targetPlayerClientRpc = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref targetPlayerClientRpc); target.__rpc_exec_stage = (__RpcExecStage)1; ((SimonSaysAI)(object)target).SetTargetPlayerClientRpc(targetPlayerClientRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1593938165(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong targetClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref targetClientId); target.__rpc_exec_stage = (__RpcExecStage)1; ((SimonSaysAI)(object)target).BeginFocusClientRpc(targetClientId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1344786899(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((SimonSaysAI)(object)target).EndFocusClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1746222514(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((SimonSaysAI)(object)target).PlayIntroClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_212779188(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int packedRound = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref packedRound); int roundIndex = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref roundIndex); target.__rpc_exec_stage = (__RpcExecStage)1; ((SimonSaysAI)(object)target).SpeakRoundClientRpc(packedRound, roundIndex); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2369853749(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int packedRound = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref packedRound); int roundIndex = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref roundIndex); target.__rpc_exec_stage = (__RpcExecStage)1; ((SimonSaysAI)(object)target).OpenWindowClientRpc(packedRound, roundIndex); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_447314282(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((SimonSaysAI)(object)target).CloseWindowClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3841940082(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((SimonSaysAI)(object)target).PlayCongratulationsClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2046626769(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((SimonSaysAI)(object)target).PlayGoodbyeClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3584274768(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong targetClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref targetClientId); target.__rpc_exec_stage = (__RpcExecStage)1; ((SimonSaysAI)(object)target).PlayerFailedClientRpc(targetClientId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1932661538(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 position = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref position); target.__rpc_exec_stage = (__RpcExecStage)1; ((SimonSaysAI)(object)target).VanishClientRpc(position); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1535394079(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool wheelsLoopClientRpc = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref wheelsLoopClientRpc, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((SimonSaysAI)(object)target).SetWheelsLoopClientRpc(wheelsLoopClientRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1726491939(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0051: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int roundIndex = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref roundIndex); bool complied = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref complied, default(ForPrimitives)); ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((SimonSaysAI)(object)target).ReportRoundOutcomeServerRpc(roundIndex, complied, server); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "SimonSaysAI"; } } internal sealed class SimonSaysFocusEffect : MonoBehaviour { private struct AudioSourceState { public float Volume; public AudioLowPassFilter LowPass; public bool AddedLowPass; public bool LowPassEnabled; public float Cutoff; public float Resonance; } private struct SimonSourceState { public float Volume; public float MaxDistance; } private struct LightState { public float Intensity; public bool Enabled; } private struct RenderSettingsState { public bool Captured; public AmbientMode AmbientMode; public Color AmbientLight; public float AmbientIntensity; public float ReflectionIntensity; } private const float OtherAudioVolumeMultiplier = 0.08f; private const float OtherAudioLowPassCutoff = 430f; private const float SimonAudioVolumeMultiplier = 1.85f; private const float SceneLightMultiplier = 0.035f; private const float ScreenDarknessAlpha = 0.45f; private const float RescanInterval = 1f; private static SimonSaysFocusEffect _active; private readonly Dictionary _dampenedSources = new Dictionary(); private readonly Dictionary _boostedSimonSources = new Dictionary(); private readonly Dictionary _dimmedLights = new Dictionary(); private SimonSaysAI _owner; private Transform _simonRoot; private PlayerControllerB _player; private SpotlightController _simonSpotlight; private SpotlightController _playerSpotlight; private RenderSettingsState _renderState; private float _audioScanTimer; private float _lightScanTimer; private GameObject _darknessOverlayRoot; public static void Begin(SimonSaysAI owner, PlayerControllerB player, float spotlightIntensity) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if ((Object)(object)owner == (Object)null || (Object)(object)player == (Object)null) { return; } EndActive(); GameObject val = null; try { val = new GameObject("SimonSays_LocalFocusEffect"); SimonSaysFocusEffect simonSaysFocusEffect = val.AddComponent(); simonSaysFocusEffect.BeginInternal(owner, player, spotlightIntensity); _active = simonSaysFocusEffect; } catch (Exception arg) { Plugin.Log.LogError((object)$"SimonSaysFocusEffect.Begin: {arg}"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } } public static void EndFor(SimonSaysAI owner) { if (!((Object)(object)_active == (Object)null) && ((Object)(object)owner == (Object)null || (Object)(object)_active._owner == (Object)(object)owner)) { EndActive(); } } public static void EndActive() { if (!((Object)(object)_active == (Object)null)) { SimonSaysFocusEffect active = _active; _active = null; active.EndInternal(); } } private void BeginInternal(SimonSaysAI owner, PlayerControllerB player, float spotlightIntensity) { //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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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) _owner = owner; _simonRoot = ((Component)owner).transform; _player = player; CaptureRenderSettings(); ApplyRenderDarkness(); DimSceneLights(); EnsureDarknessOverlay(); float num = Mathf.Max(spotlightIntensity, 24f); _simonSpotlight = SpotlightController.SpawnAbove(_simonRoot, _simonRoot, 10.5f, Vector3.zero, Vector3.up * 1.2f, num * 1.45f, "SimonSays_LocalSimonSpotlight", 31f, 30f); _playerSpotlight = SpotlightController.SpawnAbove(((Component)player).transform, ((Component)player).transform, 12f, Vector3.zero, Vector3.up * 0.9f, num, "SimonSays_LocalPlayerSpotlight", 36f, 28f); ScanAudioSources(); PlaySpotlightStartSfx(); } private void Update() { if (!IsStillValid()) { EndActive(); return; } ApplyRenderDarkness(); _lightScanTimer -= Time.unscaledDeltaTime; if (_lightScanTimer <= 0f) { _lightScanTimer = 1f; DimSceneLights(); } _audioScanTimer -= Time.unscaledDeltaTime; if (_audioScanTimer <= 0f) { _audioScanTimer = 1f; ScanAudioSources(); } } private bool IsStillValid() { if ((Object)(object)_owner == (Object)null || (Object)(object)_simonRoot == (Object)null || (Object)(object)_player == (Object)null) { return false; } PlayerControllerB val = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.localPlayerController : null); if ((Object)(object)val != (Object)null && val.actualClientId == _player.actualClientId) { return !val.isPlayerDead; } return false; } private void CaptureRenderSettings() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (!_renderState.Captured) { _renderState = new RenderSettingsState { Captured = true, AmbientMode = RenderSettings.ambientMode, AmbientLight = RenderSettings.ambientLight, AmbientIntensity = RenderSettings.ambientIntensity, ReflectionIntensity = RenderSettings.reflectionIntensity }; } } private static void ApplyRenderDarkness() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = new Color(0.0015f, 0.0015f, 0.002f, 1f); RenderSettings.ambientIntensity = 0.005f; RenderSettings.reflectionIntensity = 0.01f; } private void RestoreRenderSettings() { //IL_0014: 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) if (_renderState.Captured) { RenderSettings.ambientMode = _renderState.AmbientMode; RenderSettings.ambientLight = _renderState.AmbientLight; RenderSettings.ambientIntensity = _renderState.AmbientIntensity; RenderSettings.reflectionIntensity = _renderState.ReflectionIntensity; _renderState.Captured = false; } } private void DimSceneLights() { Light[] array = Object.FindObjectsOfType(); foreach (Light val in array) { if (!((Object)(object)val == (Object)null) && !IsFocusLight(val)) { if (!_dimmedLights.TryGetValue(val, out var value)) { value = new LightState { Intensity = val.intensity, Enabled = ((Behaviour)val).enabled }; _dimmedLights[val] = value; } val.intensity = value.Intensity * 0.035f; } } } private static bool IsFocusLight(Light light) { if ((Object)(object)light != (Object)null) { return (Object)(object)((Component)light).GetComponentInParent() != (Object)null; } return false; } private void RestoreSceneLights() { foreach (KeyValuePair dimmedLight in _dimmedLights) { Light key = dimmedLight.Key; if (!((Object)(object)key == (Object)null)) { key.intensity = dimmedLight.Value.Intensity; ((Behaviour)key).enabled = dimmedLight.Value.Enabled; } } _dimmedLights.Clear(); } private void PlaySpotlightStartSfx() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if ((Object)(object)Plugin.SpotlightStartClip == (Object)null) { return; } try { GameObject val = new GameObject("SimonSays_LocalSpotlightStartSfx"); if ((Object)(object)_simonRoot != (Object)null) { val.transform.SetParent(_simonRoot, false); } AudioSource obj = val.AddComponent(); obj.clip = Plugin.SpotlightStartClip; obj.volume = 1.35f; obj.spatialBlend = 0f; obj.loop = false; obj.Play(); Object.Destroy((Object)(object)val, Plugin.SpotlightStartClip.length + 0.25f); } catch (Exception arg) { Plugin.Log.LogError((object)$"SimonSaysFocusEffect.PlaySpotlightStartSfx: {arg}"); } } private void ScanAudioSources() { AudioSource[] array = Object.FindObjectsOfType(); foreach (AudioSource val in array) { if (!((Object)(object)val == (Object)null)) { if (IsSimonSource(val)) { RestoreDampenedSource(val); BoostSimonSource(val); } else { DampNonSimonSource(val); } } } } private bool IsSimonSource(AudioSource source) { if ((Object)(object)source != (Object)null && (Object)(object)_simonRoot != (Object)null && (Object)(object)((Component)source).transform != (Object)null) { return ((Component)source).transform.IsChildOf(_simonRoot); } return false; } private void DampNonSimonSource(AudioSource source) { if ((Object)(object)source == (Object)null) { return; } if (_dampenedSources.TryGetValue(source, out var value)) { float num = value.Volume * 0.08f; if (source.volume > num + 0.01f) { value.Volume = source.volume; _dampenedSources[source] = value; } ApplyDampenedState(source, value); return; } AudioLowPassFilter val = ((Component)source).GetComponent(); bool addedLowPass = false; if ((Object)(object)val == (Object)null) { val = ((Component)source).gameObject.AddComponent(); addedLowPass = true; } AudioSourceState audioSourceState = new AudioSourceState { Volume = source.volume, LowPass = val, AddedLowPass = addedLowPass, LowPassEnabled = ((Object)(object)val != (Object)null && ((Behaviour)val).enabled), Cutoff = (((Object)(object)val != (Object)null) ? val.cutoffFrequency : 22000f), Resonance = (((Object)(object)val != (Object)null) ? val.lowpassResonanceQ : 1f) }; _dampenedSources[source] = audioSourceState; ApplyDampenedState(source, audioSourceState); } private static void ApplyDampenedState(AudioSource source, AudioSourceState state) { source.volume = state.Volume * 0.08f; if ((Object)(object)state.LowPass != (Object)null) { ((Behaviour)state.LowPass).enabled = true; state.LowPass.cutoffFrequency = 430f; state.LowPass.lowpassResonanceQ = 1.8f; } } private void BoostSimonSource(AudioSource source) { if (!((Object)(object)source == (Object)null) && !_boostedSimonSources.ContainsKey(source)) { SimonSourceState value = new SimonSourceState { Volume = source.volume, MaxDistance = source.maxDistance }; _boostedSimonSources[source] = value; source.volume = Mathf.Max(source.volume * 1.85f, source.volume + 0.65f); source.maxDistance = Mathf.Max(source.maxDistance, 42f); } } private void RestoreDampenedSource(AudioSource source) { if ((Object)(object)source == (Object)null || !_dampenedSources.TryGetValue(source, out var value)) { return; } source.volume = value.Volume; if ((Object)(object)value.LowPass != (Object)null) { if (value.AddedLowPass) { Object.Destroy((Object)(object)value.LowPass); } else { ((Behaviour)value.LowPass).enabled = value.LowPassEnabled; value.LowPass.cutoffFrequency = value.Cutoff; value.LowPass.lowpassResonanceQ = value.Resonance; } } _dampenedSources.Remove(source); } private void RestoreAllAudio() { foreach (KeyValuePair dampenedSource in _dampenedSources) { AudioSource key = dampenedSource.Key; if ((Object)(object)key == (Object)null) { continue; } AudioSourceState value = dampenedSource.Value; key.volume = value.Volume; if ((Object)(object)value.LowPass != (Object)null) { if (value.AddedLowPass) { Object.Destroy((Object)(object)value.LowPass); continue; } ((Behaviour)value.LowPass).enabled = value.LowPassEnabled; value.LowPass.cutoffFrequency = value.Cutoff; value.LowPass.lowpassResonanceQ = value.Resonance; } } _dampenedSources.Clear(); foreach (KeyValuePair boostedSimonSource in _boostedSimonSources) { AudioSource key2 = boostedSimonSource.Key; if (!((Object)(object)key2 == (Object)null)) { key2.volume = boostedSimonSource.Value.Volume; key2.maxDistance = boostedSimonSource.Value.MaxDistance; } } _boostedSimonSources.Clear(); } private void EndInternal() { RestoreAllAudio(); RestoreSceneLights(); RestoreRenderSettings(); if ((Object)(object)_simonSpotlight != (Object)null) { _simonSpotlight.Despawn(); } if ((Object)(object)_playerSpotlight != (Object)null) { _playerSpotlight.Despawn(); } if ((Object)(object)_darknessOverlayRoot != (Object)null) { Object.Destroy((Object)(object)_darknessOverlayRoot); } if ((Object)(object)this != (Object)null && (Object)(object)((Component)this).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); } } private void EnsureDarknessOverlay() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_00ba: 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_00f1: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_darknessOverlayRoot != (Object)null)) { Canvas val = null; if ((Object)(object)HUDManager.Instance != (Object)null && (Object)(object)HUDManager.Instance.playerScreenTexture != (Object)null) { val = ((Graphic)HUDManager.Instance.playerScreenTexture).canvas; } _darknessOverlayRoot = new GameObject("SimonSays_FocusDarknessOverlay"); if ((Object)(object)val != (Object)null) { _darknessOverlayRoot.transform.SetParent(((Component)val).transform, false); _darknessOverlayRoot.transform.SetAsLastSibling(); } else { Canvas obj = _darknessOverlayRoot.AddComponent(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 650; CanvasScaler obj2 = _darknessOverlayRoot.AddComponent(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); } RectTransform val2 = _darknessOverlayRoot.GetComponent(); if ((Object)(object)val2 == (Object)null) { val2 = _darknessOverlayRoot.AddComponent(); } val2.anchorMin = Vector2.zero; val2.anchorMax = Vector2.one; val2.offsetMin = Vector2.zero; val2.offsetMax = Vector2.zero; ((Transform)val2).localScale = Vector3.one; Image obj3 = _darknessOverlayRoot.AddComponent(); ((Graphic)obj3).raycastTarget = false; ((Graphic)obj3).color = new Color(0f, 0f, 0f, 0.45f); } } private void OnDestroy() { if ((Object)(object)_active == (Object)(object)this) { _active = null; } } } public enum ActionType { Jump, Crouch, Dance, TurnAround } public enum RoundConnector { And, Then } public struct SimonRound { public bool SimonSaid; public ActionType First; public ActionType Second; public bool HasSecond; public RoundConnector Connector; public bool Ordered { get { if (HasSecond) { return Connector == RoundConnector.Then; } return false; } } public bool Names(ActionType action) { if (First != action) { if (HasSecond) { return Second == action; } return false; } return true; } public int Pack() { int num = 0; if (SimonSaid) { num |= 1; } if (HasSecond) { num |= 2; } if (Connector == RoundConnector.Then) { num |= 4; } num |= (int)(First & ActionType.TurnAround) << 3; return num | ((int)(Second & ActionType.TurnAround) << 5); } public static SimonRound Unpack(int v) { return new SimonRound { SimonSaid = ((v & 1) != 0), HasSecond = ((v & 2) != 0), Connector = (((v & 4) != 0) ? RoundConnector.Then : RoundConnector.And), First = (ActionType)((v >> 3) & 3), Second = (ActionType)((v >> 5) & 3) }; } public ActionType[] Sequence() { if (HasSecond) { return new ActionType[2] { First, Second }; } return new ActionType[1] { First }; } public override string ToString() { StringBuilder stringBuilder = new StringBuilder(); if (SimonSaid) { stringBuilder.Append("simon says "); } stringBuilder.Append(SimonSaysWords.Spell(First)); if (HasSecond) { stringBuilder.Append((Connector == RoundConnector.Then) ? " then " : " and "); stringBuilder.Append(SimonSaysWords.Spell(Second)); } return stringBuilder.ToString(); } } public static class SimonSaysWords { private static readonly ActionType[] AllActions = new ActionType[4] { ActionType.Jump, ActionType.Crouch, ActionType.Dance, ActionType.TurnAround }; public static string Spell(ActionType a) { return a switch { ActionType.Jump => "jump", ActionType.Crouch => "crouch", ActionType.Dance => "dance", ActionType.TurnAround => "turn around", _ => a.ToString(), }; } public static SimonRound Roll(float simonChance, float twoActionChance, bool allowTurnAroundInTraps) { bool flag = (Object)(object)Plugin.SimonSaysWordClip != (Object)null; bool flag2 = flag && Random.value < simonChance; List list = new List(AllActions.Length); for (int i = 0; i < AllActions.Length; i++) { if ((flag2 || allowTurnAroundInTraps || AllActions[i] != ActionType.TurnAround) && !((Object)(object)Plugin.ActionClip(AllActions[i]) == (Object)null)) { list.Add(AllActions[i]); } } if (list.Count == 0 && !flag2 && flag) { flag2 = true; for (int j = 0; j < AllActions.Length; j++) { if ((Object)(object)Plugin.ActionClip(AllActions[j]) != (Object)null) { list.Add(AllActions[j]); } } } if (list.Count == 0) { throw new InvalidOperationException("[SimonSays] Cannot roll a round because no eligible action clips are loaded."); } SimonRound result = new SimonRound { SimonSaid = flag2, First = list[Random.Range(0, list.Count)] }; List list2 = new List(2); if ((Object)(object)Plugin.AndClip != (Object)null) { list2.Add(RoundConnector.And); } if ((Object)(object)Plugin.ThenClip != (Object)null) { list2.Add(RoundConnector.Then); } if (list.Count > 1 && list2.Count > 0 && Random.value < twoActionChance) { list.Remove(result.First); result.HasSecond = true; result.Second = list[Random.Range(0, list.Count)]; result.Connector = list2[Random.Range(0, list2.Count)]; } return result; } public static List BuildUtterance(SimonRound round) { List list = new List(4); if (round.SimonSaid) { AddRequired(list, Plugin.SimonSaysWordClip, "ss_simon_says"); } AddRequired(list, Plugin.ActionClip(round.First), "ss_" + Spell(round.First).Replace(" ", "_")); if (round.HasSecond) { bool flag = round.Connector == RoundConnector.Then; AddRequired(list, flag ? Plugin.ThenClip : Plugin.AndClip, flag ? "ss_then" : "ss_and"); AddRequired(list, Plugin.ActionClip(round.Second), "ss_" + Spell(round.Second).Replace(" ", "_")); } return list; } private static void AddRequired(List list, AudioClip clip, string assetName) { if ((Object)(object)clip == (Object)null) { throw new InvalidOperationException("[SimonSays] Cannot build utterance: required clip '" + assetName + "' is missing."); } list.Add(clip); } public static float UtteranceLength(SimonRound round, float wordGap) { return SequenceLength(BuildUtterance(round), wordGap); } public static float SequenceLength(List clips, float wordGap) { if (clips == null || clips.Count == 0) { return 0f; } float num = 0f; for (int i = 0; i < clips.Count; i++) { num += (((Object)(object)clips[i] != (Object)null) ? clips[i].length : 0f); } return num + wordGap * (float)Math.Max(0, clips.Count - 1); } } public class SpotlightController : MonoBehaviour { private Transform _followTarget; private Transform _lookTarget; private Vector3 _followOffset; private Vector3 _lookOffset; private Light _light; public static SpotlightController SpawnFor(PlayerControllerB target, float intensity) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)null) { return null; } return SpawnAbove(((Component)target).transform, ((Component)target).transform, 12f, Vector3.zero, Vector3.up * 1f, intensity, "SimonSays_PlayerSpotlight", 34f, 24f); } public static SpotlightController SpawnAbove(Transform followTarget, Transform lookTarget, float height, Vector3 followOffset, Vector3 lookOffset, float intensity, string name, float spotAngle, float range) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)followTarget == (Object)null || (Object)(object)lookTarget == (Object)null) { return null; } GameObject val = new GameObject(string.IsNullOrEmpty(name) ? "SimonSays_Spotlight" : name); SpotlightController spotlightController = val.AddComponent(); spotlightController._followTarget = followTarget; spotlightController._lookTarget = lookTarget; spotlightController._followOffset = followOffset + Vector3.up * height; spotlightController._lookOffset = lookOffset; Light val2 = val.AddComponent(); val2.type = (LightType)0; val2.range = range; val2.spotAngle = spotAngle; val2.innerSpotAngle = Mathf.Max(1f, spotAngle * 0.62f); val2.intensity = intensity; val2.color = new Color(1f, 0.95f, 0.82f); val2.shadows = (LightShadows)2; spotlightController._light = val2; spotlightController.UpdatePose(); return spotlightController; } catch (Exception arg) { Plugin.Log.LogError((object)$"SpotlightController.SpawnAbove: {arg}"); return null; } } public void Retarget(PlayerControllerB target) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)target == (Object)null)) { _followTarget = ((Component)target).transform; _lookTarget = ((Component)target).transform; _followOffset = Vector3.up * 12f; _lookOffset = Vector3.up * 1f; UpdatePose(); } } public void Despawn() { try { if ((Object)(object)this != (Object)null && (Object)(object)((Component)this).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); } } catch { } } private void LateUpdate() { if (!((Object)(object)_followTarget == (Object)null) && !((Object)(object)_lookTarget == (Object)null)) { UpdatePose(); } } private void UpdatePose() { //IL_0023: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_followTarget == (Object)null) && !((Object)(object)_lookTarget == (Object)null)) { Vector3 val = _followTarget.position + _followOffset; Vector3 val2 = _lookTarget.position + _lookOffset - val; if (((Vector3)(ref val2)).sqrMagnitude < 0.001f) { val2 = Vector3.down; } Vector3 val3 = ((Mathf.Abs(Vector3.Dot(((Vector3)(ref val2)).normalized, Vector3.up)) > 0.94f) ? Vector3.forward : Vector3.up); ((Component)this).transform.position = val; ((Component)this).transform.rotation = Quaternion.LookRotation(((Vector3)(ref val2)).normalized, val3); } } } public static class VanishSmokeEffect { private const float PrefabTransformScale = 0.65f; private const float PrefabLifetimeMultiplier = 0.85f; private const float PrefabSizeMultiplier = 0.75f; private const float PrefabSpeedMultiplier = 0.7f; private static readonly Color SmokeTint = new Color(0.54f, 0.57f, 0.6f, 0.58f); private static readonly Dictionary RuntimeMaterials = new Dictionary(); private static Material _generatedMaterial; private static Texture2D _softCircle; public static void SpawnAt(Vector3 position, bool forceHdrpShaders) { //IL_0028: 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) try { GameObject vanishSmokePrefab = Plugin.VanishSmokePrefab; if ((Object)(object)vanishSmokePrefab != (Object)null) { SpawnFromPrefab(vanishSmokePrefab, position, forceHdrpShaders); return; } Plugin.Log.LogWarning((object)"[SimonSays] Vanish smoke prefab missing from bundle; using generated cloud."); SpawnGenerated(position); } catch (Exception arg) { Plugin.Log.LogError((object)$"VanishSmokeEffect.SpawnAt: {arg}"); } } private static void SpawnFromPrefab(GameObject prefab, Vector3 position, bool forceHdrpShaders) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_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) GameObject val = Object.Instantiate(prefab, position + Vector3.up * 0.12f, Quaternion.identity); ((Object)val).name = "SimonSaysVanishSmoke"; val.transform.localScale = Vector3.one * 0.65f; RepairParticleRenderers(val, forceHdrpShaders); ParticleSystem[] componentsInChildren = val.GetComponentsInChildren(true); foreach (ParticleSystem val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null)) { MainModule main = val2.main; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0; ((MainModule)(ref main)).startLifetimeMultiplier = ((MainModule)(ref main)).startLifetimeMultiplier * 0.85f; ((MainModule)(ref main)).startSizeMultiplier = ((MainModule)(ref main)).startSizeMultiplier * 0.75f; ((MainModule)(ref main)).startSpeedMultiplier = ((MainModule)(ref main)).startSpeedMultiplier * 0.7f; ((Component)val2).gameObject.SetActive(true); val2.Play(true); } } Object.Destroy((Object)(object)val, 8f); } private static void SpawnGenerated(Vector3 position) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00f3: 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_011f: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Expected O, but got Unknown //IL_023a: 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_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: 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_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SimonSaysGeneratedVanishSmoke"); val.transform.position = position + Vector3.up * 0.18f; val.transform.localScale = Vector3.one * 1.65f; ParticleSystem val2 = val.AddComponent(); MainModule main = val2.main; ((MainModule)(ref main)).duration = 2.8f; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(2f, 4.2f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(1.1f, 3.4f); ((MainModule)(ref main)).startSize = new MinMaxCurve(1.4f, 3.8f); ((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, MathF.PI * 2f); ((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(0.62f, 0.65f, 0.67f, 0.82f), new Color(0.25f, 0.28f, 0.3f, 0.48f)); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.08f); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0; EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[2] { new Burst(0f, (short)180), new Burst(0.18f, (short)90) }); ShapeModule shape = val2.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 1.15f; VelocityOverLifetimeModule velocityOverLifetime = val2.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).radial = new MinMaxCurve(0.55f, 1.25f); ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.15f, 0.65f); NoiseModule noise = val2.noise; ((NoiseModule)(ref noise)).enabled = true; ((NoiseModule)(ref noise)).strength = MinMaxCurve.op_Implicit(1.1f); ((NoiseModule)(ref noise)).frequency = 0.55f; ((NoiseModule)(ref noise)).scrollSpeed = MinMaxCurve.op_Implicit(0.4f); ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val3 = new Gradient(); val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(new Color(0.68f, 0.7f, 0.72f), 0f), new GradientColorKey(new Color(0.32f, 0.34f, 0.36f), 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[4] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(0.82f, 0.08f), new GradientAlphaKey(0.45f, 0.62f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3); ParticleSystemRenderer component = ((Component)val2).GetComponent(); component.renderMode = (ParticleSystemRenderMode)0; ((Renderer)component).material = GetOrCreateGeneratedMaterial(); component.sortingFudge = 12f; val2.Play(true); Object.Destroy((Object)(object)val, 7.5f); } internal static void RepairParticleRenderers(GameObject root, bool force) { if ((Object)(object)root == (Object)null) { return; } Renderer[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } Material[] sharedMaterials = val.sharedMaterials; if (sharedMaterials == null || sharedMaterials.Length == 0) { continue; } bool flag = false; for (int j = 0; j < sharedMaterials.Length; j++) { Material val2 = sharedMaterials[j]; if (force || IsMaterialBroken(val2)) { sharedMaterials[j] = GetOrCreateRuntimeMaterial(val2); flag = true; } } if (flag) { val.sharedMaterials = sharedMaterials; } } } private static bool IsMaterialBroken(Material material) { if ((Object)(object)material == (Object)null) { return true; } Shader shader = material.shader; if ((Object)(object)shader == (Object)null) { return true; } if (!(((Object)shader).name == "Hidden/InternalErrorShader")) { return string.IsNullOrEmpty(((Object)shader).name); } return true; } private static Material GetOrCreateRuntimeMaterial(Material source) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)source == (Object)null) { return GetOrCreateGeneratedMaterial(); } if (RuntimeMaterials.TryGetValue(source, out var value) && (Object)(object)value != (Object)null) { return value; } Material val = BuildAlphaParticleMaterial((((Object)(object)source != (Object)null) ? ((Object)source).name : "SimonSays") + "_RuntimeSmoke", SmokeTint, ReadTexture(source)); if ((Object)(object)val != (Object)null) { RuntimeMaterials[source] = val; } return val ?? source; } private static Material GetOrCreateGeneratedMaterial() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_generatedMaterial == (Object)null) { _generatedMaterial = BuildAlphaParticleMaterial("SimonSays_GeneratedSmoke", SmokeTint, (Texture)(object)GetOrCreateSoftCircleTexture()); } return _generatedMaterial; } private static Material BuildAlphaParticleMaterial(string name, Color color, Texture texture) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00a3: 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_00af: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Expected O, but got Unknown Shader val = Shader.Find("Particles/Standard Unlit") ?? Shader.Find("Legacy Shaders/Particles/Alpha Blended") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Standard"); if ((Object)(object)val == (Object)null) { Plugin.Log.LogError((object)"[SimonSays] No usable shader for the vanish smoke material."); return null; } if ((Object)(object)texture == (Object)null) { texture = (Texture)(object)GetOrCreateSoftCircleTexture(); } Material val2 = new Material(val) { name = name, renderQueue = 3000, hideFlags = (HideFlags)61 }; SetTexture(val2, "_BaseColorMap", texture); SetTexture(val2, "_MainTex", texture); SetColor(val2, "_BaseColor", color); SetColor(val2, "_Color", color); SetColor(val2, "_TintColor", color); SetFloat(val2, "_Mode", 2f); SetFloat(val2, "_Cutoff", 0f); SetFloat(val2, "_ZWrite", 0f); SetFloat(val2, "_SrcBlend", 5f); SetFloat(val2, "_DstBlend", 10f); SetFloat(val2, "_CullMode", 0f); val2.SetOverrideTag("RenderType", "Transparent"); val2.DisableKeyword("_ALPHATEST_ON"); val2.EnableKeyword("_ALPHABLEND_ON"); val2.DisableKeyword("_ALPHAPREMULTIPLY_ON"); return val2; } private static Texture2D GetOrCreateSoftCircleTexture() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_softCircle != (Object)null) { return _softCircle; } Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false) { name = "SimonSays_SmokeSprite", hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1 }; float num = 15.5f; for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { float num2 = Mathf.Sqrt(((float)j - num) * ((float)j - num) + ((float)i - num) * ((float)i - num)) / num; float num3 = Mathf.Clamp01(1f - num2); num3 *= num3; val.SetPixel(j, i, new Color(1f, 1f, 1f, num3)); } } val.Apply(false, true); _softCircle = val; return val; } private static Texture ReadTexture(Material material) { if ((Object)(object)material == (Object)null) { return null; } string[] array = new string[3] { "_BaseColorMap", "_MainTex", "_UnlitColorMap" }; for (int i = 0; i < array.Length; i++) { if (material.HasProperty(array[i])) { Texture texture = material.GetTexture(array[i]); if ((Object)(object)texture != (Object)null) { return texture; } } } return null; } private static void SetTexture(Material m, string p, Texture t) { if (m.HasProperty(p)) { m.SetTexture(p, t); } } private static void SetColor(Material m, string p, Color c) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (m.HasProperty(p)) { m.SetColor(p, c); } } private static void SetFloat(Material m, string p, float v) { if (m.HasProperty(p)) { m.SetFloat(p, v); } } } } namespace Y4NGZMonsters.Shared { internal static class ConfigSectionNameMigration { private static readonly IReadOnlyDictionary SectionNames = new Dictionary(StringComparer.Ordinal) { { "00 - General", "General" }, { "10 - Spawning", "Spawning" }, { "20 - Core Stats", "Core Stats" }, { "20 - Video", "Video" }, { "30 - Detection", "Detection" }, { "30 - Encounter Pacing", "Encounter Pacing" }, { "30 - Encounter Rules", "Encounter Rules" }, { "40 - Movement", "Movement" }, { "50 - Combat", "Combat" }, { "60 - Abilities", "Abilities" }, { "60 - Presentation", "Presentation" }, { "60 - Audio", "Audio" }, { "70 - Audio and Presentation", "Audio and Presentation" }, { "99 - Diagnostics", "Diagnostics" } }; private static readonly Regex NumberedSectionHeader = new Regex("^(?[ \\t]*)\\[(?
00 - General|10 - Spawning|20 - Core Stats|20 - Video|30 - Detection|30 - Encounter Pacing|30 - Encounter Rules|40 - Movement|50 - Combat|60 - Abilities|60 - Presentation|60 - Audio|70 - Audio and Presentation|99 - Diagnostics)\\](?[ \\t]*)(?\\r?)$", RegexOptions.Multiline | RegexOptions.Compiled | RegexOptions.CultureInvariant); internal static bool TryMigrate(ConfigFile config, ManualLogSource log, string creatureName) { string configFilePath = config.ConfigFilePath; if (!File.Exists(configFilePath)) { return false; } string text = null; try { int replacementCount; string contents = RenameSectionHeaders(File.ReadAllText(configFilePath), out replacementCount); if (replacementCount == 0) { return false; } text = GetBackupPath(configFilePath); File.Copy(configFilePath, text, overwrite: false); File.WriteAllText(configFilePath, contents, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); config.Reload(); if (log != null) { log.LogInfo((object)($"[{creatureName}] Removed numeric prefixes from {replacementCount} config section header(s). " + "The previous config is backed up at '" + text + "'.")); } return true; } catch (Exception ex) { string text2 = "The original config was not modified."; if (!string.IsNullOrEmpty(text) && File.Exists(text)) { try { File.Copy(text, configFilePath, overwrite: true); config.Reload(); text2 = "The original config was restored from its backup."; } catch (Exception ex2) { text2 = "Automatic restore also failed (" + ex2.Message + "). Restore '" + text + "' manually before editing the config."; } } if (log != null) { log.LogWarning((object)("[" + creatureName + "] Could not remove numeric config section prefixes: " + ex.Message + " " + text2)); } return false; } } internal static string RenameSectionHeaders(string text, out int replacementCount) { int count = 0; string result = NumberedSectionHeader.Replace(text, delegate(Match match) { string value = match.Groups["section"].Value; if (!SectionNames.TryGetValue(value, out var value2)) { return match.Value; } count++; return match.Groups["leading"].Value + "[" + value2 + "]" + match.Groups["trailing"].Value + match.Groups["carriage"].Value; }); replacementCount = count; return result; } private static string GetBackupPath(string configPath) { string text = configPath + ".pre-section-names.bak"; int num = 1; while (File.Exists(text)) { text = configPath + $".pre-section-names.{num}.bak"; num++; } return text; } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace SimonSays.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }