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 Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using Y4NGZDreadweaver.AI; using Y4NGZDreadweaver.NetcodePatcher; 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("Y4NGZDreadweaver")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+25ca94fed298fe073d4c739917e3b7f046e875bf")] [assembly: AssemblyProduct("Y4NGZDreadweaver")] [assembly: AssemblyTitle("Y4NGZDreadweaver")] [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 Y4NGZDreadweaver { internal sealed class DreadweaverConfig { public ConfigEntry Enabled { get; } public ConfigEntry SpawnWeightMultiplier { get; } public ConfigEntry MaxCount { get; } public ConfigEntry PowerLevel { get; } public ConfigEntry Health { get; } public ConfigEntry SightingIntervalMinSeconds { get; } public ConfigEntry SightingIntervalMaxSeconds { get; } public ConfigEntry AttackDelayMinSeconds { get; } public ConfigEntry AttackDelayMaxSeconds { get; } public ConfigEntry StalkMoveSpeed { get; } public ConfigEntry CrawlSpeed { get; } public ConfigEntry AttackSpeed { get; } public ConfigEntry AttackDamage { get; } public ConfigEntry AttackCooldown { get; } public ConfigEntry CreatureSpotlightEnabled { get; } public ConfigEntry FlashlightHarassEnabled { get; } public ConfigEntry DebugLogs { get; } public DreadweaverConfig(ConfigFile config) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Expected O, but got Unknown //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Expected O, but got Unknown //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Expected O, but got Unknown //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Expected O, but got Unknown //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Expected O, but got Unknown //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Expected O, but got Unknown bool saveOnConfigSet = config.SaveOnConfigSet; config.SaveOnConfigSet = false; try { DreadweaverConfigMigration.TryMigrate(config, Plugin.Log); ConfigSectionNameMigration.TryMigrate(config, Plugin.Log, "Dreadweaver"); Enabled = config.Bind("General", "Enabled", true, "Enable the Dreadweaver encounter."); SpawnWeightMultiplier = config.Bind("Spawning", "SpawnWeightMultiplier", 1f, new ConfigDescription("Multiplier applied to Dreadweaver's contextual moon/interior spawn policy. 0 disables natural spawns.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 5f), Array.Empty())); MaxCount = config.Bind("Spawning", "MaxCount", 1, new ConfigDescription("Maximum number of living Dreadweavers at once.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 4), Array.Empty())); PowerLevel = config.Bind("Spawning", "PowerLevel", 2.8f, new ConfigDescription("Indoor enemy power budget cost for each Dreadweaver.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 20f), Array.Empty())); Health = config.Bind("Core Stats", "Health", 5, new ConfigDescription("Hits the Dreadweaver can take before dying.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 100), Array.Empty())); SightingIntervalMinSeconds = config.Bind("Encounter Pacing", "SightingIntervalMinSeconds", 45f, new ConfigDescription("Minimum hidden time between completed sightings.", (AcceptableValueBase)(object)new AcceptableValueRange(8f, 120f), Array.Empty())); SightingIntervalMaxSeconds = config.Bind("Encounter Pacing", "SightingIntervalMaxSeconds", 65f, new ConfigDescription("Maximum hidden time between completed sightings; values below the minimum are raised at runtime.", (AcceptableValueBase)(object)new AcceptableValueRange(8f, 150f), Array.Empty())); AttackDelayMinSeconds = config.Bind("Encounter Pacing", "AttackDelayMinSeconds", 15f, new ConfigDescription("Minimum hidden time between the final sighting and attack reveal.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 60f), Array.Empty())); AttackDelayMaxSeconds = config.Bind("Encounter Pacing", "AttackDelayMaxSeconds", 30f, new ConfigDescription("Maximum hidden time before attack reveal; values below the minimum are raised at runtime.", (AcceptableValueBase)(object)new AcceptableValueRange(5f, 90f), Array.Empty())); StalkMoveSpeed = config.Bind("Movement", "StalkMoveSpeed", 1.5f, new ConfigDescription("Movement speed outside committed attacks.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 4f), Array.Empty())); CrawlSpeed = config.Bind("Movement", "CrawlSpeed", 2.1f, new ConfigDescription("Movement speed during a crawl attack reveal.", (AcceptableValueBase)(object)new AcceptableValueRange(0.8f, 4f), Array.Empty())); AttackSpeed = config.Bind("Movement", "AttackSpeed", 5.15f, new ConfigDescription("Movement speed during committed pursuit.", (AcceptableValueBase)(object)new AcceptableValueRange(2f, 9f), Array.Empty())); AttackDamage = config.Bind("Combat", "AttackDamage", 40, new ConfigDescription("Damage dealt by a successful strike.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 100), Array.Empty())); AttackCooldown = config.Bind("Combat", "AttackCooldown", 1.8f, new ConfigDescription("Minimum recovery between attack attempts.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 6f), Array.Empty())); CreatureSpotlightEnabled = config.Bind("Presentation", "CreatureSpotlightEnabled", true, "Light the visible Dreadweaver so the encounter remains readable in dark interiors."); FlashlightHarassEnabled = config.Bind("Presentation", "FlashlightHarassEnabled", true, "Briefly glitch the stalked player's flashlight or helmet lamp when it cloaks nearby."); DebugLogs = config.Bind("Diagnostics", "DebugLogs", false, "Log detailed Dreadweaver targeting and setup diagnostics."); } finally { config.SaveOnConfigSet = saveOnConfigSet; if (saveOnConfigSet) { config.Save(); } } } } internal static class DreadweaverConfigMigration { private static readonly ConfigDefinition LegacySpawnWeight = new ConfigDefinition("Spawning", "SpawnWeight"); private static readonly ConfigDefinition[] RetainedLegacyDefinitions = (ConfigDefinition[])(object)new ConfigDefinition[15] { new ConfigDefinition("Spawning", "MaxCount"), new ConfigDefinition("Spawning", "PowerLevel"), new ConfigDefinition("Stats", "Health"), new ConfigDefinition("Movement", "StalkMoveSpeed"), new ConfigDefinition("Movement", "CrawlSpeed"), new ConfigDefinition("Movement", "AttackSpeed"), new ConfigDefinition("Sightings", "SightingIntervalMinSeconds"), new ConfigDefinition("Sightings", "SightingIntervalMaxSeconds"), new ConfigDefinition("Attack", "AttackDelayMinSeconds"), new ConfigDefinition("Attack", "AttackDelayMaxSeconds"), new ConfigDefinition("Attack", "AttackDamage"), new ConfigDefinition("Attack", "AttackCooldown"), new ConfigDefinition("Visuals", "CreatureSpotlightEnabled"), new ConfigDefinition("Visuals", "FlashlightHarassEnabled"), new ConfigDefinition("Debug", "DebugLogs") }; private static readonly Dictionary RemovedDefaults = new Dictionary { { new ConfigDefinition("Spawning", "LevelMask"), "-1" }, { new ConfigDefinition("Stats", "ModelScale"), "1.75" }, { new ConfigDefinition("Movement", "TurnSpeed"), "420" }, { new ConfigDefinition("Movement", "Acceleration"), "18" }, { new ConfigDefinition("Sightings", "LongSightingMinDistance"), "30" }, { new ConfigDefinition("Sightings", "LongSightingMaxDistance"), "50" }, { new ConfigDefinition("Sightings", "LongSightingHoldSeconds"), "1.35" }, { new ConfigDefinition("Sightings", "MediumSightingMinDistance"), "15" }, { new ConfigDefinition("Sightings", "MediumSightingMaxDistance"), "30" }, { new ConfigDefinition("Sightings", "MediumSightingHoldSeconds"), "1.15" }, { new ConfigDefinition("Sightings", "ShortSightingMinDistance"), "4" }, { new ConfigDefinition("Sightings", "ShortSightingMaxDistance"), "8" }, { new ConfigDefinition("Sightings", "ShortSightingHoldSeconds"), "1" }, { new ConfigDefinition("Sightings", "SightingRetryMinSeconds"), "15" }, { new ConfigDefinition("Sightings", "SightingRetryMaxSeconds"), "30" }, { new ConfigDefinition("Sightings", "SightingTimeoutSeconds"), "12" }, { new ConfigDefinition("Sightings", "PlayerSpotAngle"), "25" }, { new ConfigDefinition("Sightings", "CreatureSightRange"), "60" }, { new ConfigDefinition("Stalking ambience", "LightFlickerRadius"), "18" }, { new ConfigDefinition("Stalking ambience", "LightFlickerIntervalMinSeconds"), "40" }, { new ConfigDefinition("Stalking ambience", "LightFlickerIntervalMaxSeconds"), "70" }, { new ConfigDefinition("Stalking ambience", "DoorSlamRadius"), "14" }, { new ConfigDefinition("Stalking ambience", "DoorSlamIntervalMinSeconds"), "35" }, { new ConfigDefinition("Stalking ambience", "DoorSlamIntervalMaxSeconds"), "70" }, { new ConfigDefinition("Attack", "AttackRevealMinDistance"), "8" }, { new ConfigDefinition("Attack", "AttackRevealMaxDistance"), "16" }, { new ConfigDefinition("Attack", "CrawlAdvanceSeconds"), "3" }, { new ConfigDefinition("Attack", "AttackRange"), "2.35" }, { new ConfigDefinition("Attack", "AttackDamageDelay"), "0.48" }, { new ConfigDefinition("Attack", "AttackHitArcDegrees"), "120" }, { new ConfigDefinition("Attack", "AttackLoseDistance"), "48" }, { new ConfigDefinition("Attack", "AttackLostSightGraceSeconds"), "12" }, { new ConfigDefinition("Attack", "PursuitRepositionCooldownMinSeconds"), "2" }, { new ConfigDefinition("Attack", "PursuitRepositionCooldownMaxSeconds"), "5" }, { new ConfigDefinition("Attack", "PursuitRepositionMinDistance"), "10" }, { new ConfigDefinition("Attack", "ChainAttackRadius"), "13" }, { new ConfigDefinition("Camo", "VanishFlickerSeconds"), "0.65" }, { new ConfigDefinition("Camo", "DecloakFlickerSeconds"), "0.55" }, { new ConfigDefinition("Animation", "MatchAnimationToMovement"), "true" }, { new ConfigDefinition("Animation", "AuthoredWalkSpeed"), "1.9" }, { new ConfigDefinition("Animation", "AuthoredCrawlSpeed"), "1.9" }, { new ConfigDefinition("Animation", "AuthoredRunSpeed"), "3.6" }, { new ConfigDefinition("Visuals", "CreatureSpotlightIntensity"), "18" }, { new ConfigDefinition("Visuals", "CreatureSpotlightRange"), "14" }, { new ConfigDefinition("Visuals", "CreatureSpotlightAngle"), "42" }, { new ConfigDefinition("Visuals", "CreatureSpotlightHeight"), "5" }, { new ConfigDefinition("Visuals", "DramaticSpotlightChance"), "0.35" } }; 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)("[Dreadweaver] Could not migrate legacy config: " + ex.GetBaseException().Message + " " + text2)); } return false; } List list = FindCustomizedDroppedKeys(dictionary); if (log != null) { log.LogInfo((object)("[Dreadweaver] Migrated legacy config to the compact DawnLib layout. Backup: " + text)); } if (list.Count > 0 && log != null) { log.LogWarning((object)("[Dreadweaver] 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) { if (values.ContainsKey(LegacySpawnWeight)) { return true; } for (int i = 0; i < RetainedLegacyDefinitions.Length; i++) { if (values.ContainsKey(RetainedLegacyDefinitions[i])) { return true; } } foreach (ConfigDefinition key in RemovedDefaults.Keys) { if (values.ContainsKey(key)) { return true; } } return false; } private static string BuildMigratedConfig(Dictionary values) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00ed: 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_010b: Expected O, but got Unknown //IL_010b: Expected O, but got Unknown //IL_0127: 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_0145: Expected O, but got Unknown //IL_0145: Expected O, but got Unknown //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown //IL_0190: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_01db: Expected O, but got Unknown //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Expected O, but got Unknown //IL_0215: Expected O, but got Unknown //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Expected O, but got Unknown //IL_024f: Expected O, but got Unknown //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Expected O, but got Unknown //IL_0289: Expected O, but got Unknown //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Expected O, but got Unknown //IL_02d4: Expected O, but got Unknown //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Expected O, but got Unknown //IL_030e: Expected O, but got Unknown //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Expected O, but got Unknown //IL_0348: Expected O, but got Unknown //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Expected O, but got Unknown //IL_0393: Expected O, but got Unknown //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Expected O, but got Unknown //IL_03cd: Expected O, but got Unknown //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Expected O, but got Unknown //IL_0418: Expected O, but got Unknown //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Expected O, but got Unknown //IL_0452: Expected O, but got Unknown //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Expected O, but got Unknown //IL_049d: Expected O, but got Unknown string text = GetValue(values, new ConfigDefinition("10 - Spawning", "SpawnWeightMultiplier"), null, null); if (string.IsNullOrWhiteSpace(text)) { text = ((!float.TryParse(GetValue(values, LegacySpawnWeight, null, "12"), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) ? "1" : Math.Max(0f, Math.Min(5f, result / 12f)).ToString("0.###", CultureInfo.InvariantCulture)); } StringBuilder stringBuilder = new StringBuilder(); AppendSection(stringBuilder, "00 - General", ("Enabled", GetValue(values, new ConfigDefinition("00 - General", "Enabled"), null, "true"))); AppendSection(stringBuilder, "10 - Spawning", ("SpawnWeightMultiplier", text), ("MaxCount", GetValue(values, new ConfigDefinition("10 - Spawning", "MaxCount"), new ConfigDefinition("Spawning", "MaxCount"), "1")), ("PowerLevel", GetValue(values, new ConfigDefinition("10 - Spawning", "PowerLevel"), new ConfigDefinition("Spawning", "PowerLevel"), "2.8"))); AppendSection(stringBuilder, "20 - Core Stats", ("Health", GetValue(values, new ConfigDefinition("20 - Core Stats", "Health"), new ConfigDefinition("Stats", "Health"), "5"))); AppendSection(stringBuilder, "30 - Encounter Pacing", ("SightingIntervalMinSeconds", GetValue(values, new ConfigDefinition("30 - Encounter Pacing", "SightingIntervalMinSeconds"), new ConfigDefinition("Sightings", "SightingIntervalMinSeconds"), "45")), ("SightingIntervalMaxSeconds", GetValue(values, new ConfigDefinition("30 - Encounter Pacing", "SightingIntervalMaxSeconds"), new ConfigDefinition("Sightings", "SightingIntervalMaxSeconds"), "65")), ("AttackDelayMinSeconds", GetValue(values, new ConfigDefinition("30 - Encounter Pacing", "AttackDelayMinSeconds"), new ConfigDefinition("Attack", "AttackDelayMinSeconds"), "15")), ("AttackDelayMaxSeconds", GetValue(values, new ConfigDefinition("30 - Encounter Pacing", "AttackDelayMaxSeconds"), new ConfigDefinition("Attack", "AttackDelayMaxSeconds"), "30"))); AppendSection(stringBuilder, "40 - Movement", ("StalkMoveSpeed", GetValue(values, new ConfigDefinition("40 - Movement", "StalkMoveSpeed"), new ConfigDefinition("Movement", "StalkMoveSpeed"), "1.5")), ("CrawlSpeed", GetValue(values, new ConfigDefinition("40 - Movement", "CrawlSpeed"), new ConfigDefinition("Movement", "CrawlSpeed"), "2.1")), ("AttackSpeed", GetValue(values, new ConfigDefinition("40 - Movement", "AttackSpeed"), new ConfigDefinition("Movement", "AttackSpeed"), "5.15"))); AppendSection(stringBuilder, "50 - Combat", ("AttackDamage", GetValue(values, new ConfigDefinition("50 - Combat", "AttackDamage"), new ConfigDefinition("Attack", "AttackDamage"), "40")), ("AttackCooldown", GetValue(values, new ConfigDefinition("50 - Combat", "AttackCooldown"), new ConfigDefinition("Attack", "AttackCooldown"), "1.8"))); AppendSection(stringBuilder, "60 - Presentation", ("CreatureSpotlightEnabled", GetValue(values, new ConfigDefinition("60 - Presentation", "CreatureSpotlightEnabled"), new ConfigDefinition("Visuals", "CreatureSpotlightEnabled"), "true")), ("FlashlightHarassEnabled", GetValue(values, new ConfigDefinition("60 - Presentation", "FlashlightHarassEnabled"), new ConfigDefinition("Visuals", "FlashlightHarassEnabled"), "true"))); AppendSection(stringBuilder, "99 - Diagnostics", ("DebugLogs", GetValue(values, new ConfigDefinition("99 - Diagnostics", "DebugLogs"), new ConfigDefinition("Debug", "DebugLogs"), "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 GetValue(Dictionary values, ConfigDefinition preferred, ConfigDefinition legacy, string fallback) { if (preferred != (ConfigDefinition)null && values.TryGetValue(preferred, out var value)) { return value; } if (legacy != (ConfigDefinition)null && values.TryGetValue(legacy, out value)) { return value; } return fallback; } 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 Dreadweaver config backup filename."); } } internal sealed class DreadweaverSpawnWeights : IWeighted, IContextualWeighted { internal const int DefaultWeight = 3; internal const int MaximumWeight = 100; private readonly Func _multiplier; internal DreadweaverSpawnWeights(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.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 1.25f; } 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 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 DreadweaverTuning { internal const float ModelScale = 1.75f; internal const float TurnSpeed = 420f; internal const float Acceleration = 18f; internal const float AgentRadius = 0.86f; internal const float AgentHeight = 2.45f; internal const float LongSightingMinDistance = 30f; internal const float LongSightingMaxDistance = 50f; internal const float LongSightingHoldSeconds = 1.35f; internal const float MediumSightingMinDistance = 15f; internal const float MediumSightingMaxDistance = 30f; internal const float MediumSightingHoldSeconds = 1.15f; internal const float ShortSightingMinDistance = 4f; internal const float ShortSightingMaxDistance = 8f; internal const float ShortSightingHoldSeconds = 1f; internal const float SightingRetryMinSeconds = 15f; internal const float SightingRetryMaxSeconds = 30f; internal const float SightingTimeoutSeconds = 12f; internal const float PlayerSpotAngle = 25f; internal const float CreatureSightRange = 60f; internal const float StalkLightFlickerRadius = 18f; internal const float StalkLightFlickerIntervalMinSeconds = 40f; internal const float StalkLightFlickerIntervalMaxSeconds = 70f; internal const float StalkDoorSlamRadius = 14f; internal const float StalkDoorSlamIntervalMinSeconds = 35f; internal const float StalkDoorSlamIntervalMaxSeconds = 70f; internal const float AttackRevealMinDistance = 8f; internal const float AttackRevealMaxDistance = 16f; internal const float CrawlAdvanceSeconds = 3f; internal const float AttackRange = 2.35f; internal const float AttackDamageDelay = 0.48f; internal const float AttackHitArcDegrees = 120f; internal const float AttackLoseDistance = 48f; internal const float AttackLostSightGraceSeconds = 12f; internal const float PursuitRepositionCooldownMinSeconds = 2f; internal const float PursuitRepositionCooldownMaxSeconds = 5f; internal const float PursuitRepositionMinDistance = 10f; internal const float ChainAttackRadius = 13f; internal const float VanishFlickerSeconds = 0.65f; internal const float DecloakFlickerSeconds = 0.55f; internal const bool MatchAnimationToMovement = true; internal const float AuthoredWalkSpeed = 1.9f; internal const float AuthoredCrawlSpeed = 1.9f; internal const float AuthoredRunSpeed = 3.6f; internal const float CreatureSpotlightIntensity = 18f; internal const float CreatureSpotlightRange = 14f; internal const float CreatureSpotlightAngle = 42f; internal const float CreatureSpotlightHeight = 5f; } [BepInPlugin("y4ngz.lethalcompany.dreadweaver", "Y4NGZ Dreadweaver", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { internal const string BundleFilename = "dreadweaver.bundle"; internal const string PrefabName = "SK_Dreadweaver"; internal const string AlternatePrefabName = "Dreadweaver"; internal const string DawnNamespace = "y4ngz_monsters"; internal const string DawnEnemyKey = "dreadweaver"; internal const string ScanNodeSubtitle = ""; internal const string BestiaryText = "Dreadweaver\n\nDanger level: high\n\nA facility stalker that fixates on a single worker. It stages a sequence of sightings, each closer than the last, vanishing the moment it is approached or watched too long. A third, very close sighting means the hunt is nearly over.\n\n"; internal static ManualLogSource Log; internal static DreadweaverConfig ModConfig; internal static AssetBundle ModAssets; internal static EnemyType DreadweaverEnemyType; private static bool _netcodeInitialized; private static bool _loggedScanNodeLayer; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; try { InitializeNetcodeRPCs(); ModConfig = new DreadweaverConfig(((BaseUnityPlugin)this).Config); if (!ModConfig.Enabled.Value) { Log.LogInfo((object)"Y4NGZ Dreadweaver is disabled by config."); } else { if (!LoadBundle()) { return; } GameObject val = LoadBundlePrefab(); if ((Object)(object)val == (Object)null) { Log.LogError((object)"Prefab 'SK_Dreadweaver' not found in dreadweaver.bundle."); DumpBundleAssets(); return; } PreparePrefab(val); DreadweaverEnemyType = CreateEnemyType(val); DreadweaverAI component = val.GetComponent(); if ((Object)(object)component != (Object)null) { ((EnemyAI)component).enemyType = DreadweaverEnemyType; } RegisterWithDawn(val); Log.LogInfo((object)"Y4NGZ Dreadweaver v0.1.0 loaded. Registered as 'dreadweaver'."); } } catch (Exception arg) { Log.LogError((object)string.Format("[{0}] Initialization failed: {1}", "Y4NGZ Dreadweaver", arg)); } } private static void RegisterWithDawn(GameObject prefab) { DreadweaverSpawnWeights spawnWeights = new DreadweaverSpawnWeights(() => ModConfig.SpawnWeightMultiplier.Value); DawnLib.RegisterNetworkPrefab(prefab); DawnLib.DefineEnemy(NamespacedKey.From("y4ngz_monsters", "dreadweaver"), DreadweaverEnemyType, (Action)delegate(EnemyInfoBuilder builder) { ((BaseInfoBuilder)(object)builder.DefineInside((Action)delegate(EnemyLocationBuilder location) { location.SetWeights((Action>)delegate(WeightTableBuilder table) { table.SetGlobalWeight((IWeighted)(object)spawnWeights); }); }).CreateBestiaryNode("Dreadweaver\n\nDanger level: high\n\nA facility stalker that fixates on a single worker. It stages a sequence of sightings, each closer than the last, vanishing the moment it is approached or watched too long. A third, very close sighting means the hunt is nearly over.\n\n").CreateNameKeyword("dreadweaver")).AddTags((IEnumerable)(object)new NamespacedKey[5] { Tags.Hostile, Tags.Organic, Tags.Killable, Tags.Biped, Tags.Medium }); }); } 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 { continue; } foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length == 0) { continue; } try { methodInfo.Invoke(null, null); } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[NetcodeInit] " + type.Name + "." + methodInfo.Name + " failed: " + ex.Message)); } } } } } private static bool LoadBundle() { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); if (string.IsNullOrEmpty(directoryName)) { Log.LogError((object)"Could not resolve plugin assembly directory."); return false; } string text = Path.Combine(directoryName, "dreadweaver.bundle"); if (!File.Exists(text)) { Log.LogError((object)("Missing asset bundle: " + text)); return false; } ModAssets = AssetBundle.LoadFromFile(text); if ((Object)(object)ModAssets == (Object)null) { Log.LogError((object)("AssetBundle.LoadFromFile returned null for " + text + ".")); return false; } return true; } private static GameObject LoadBundlePrefab() { GameObject val = ModAssets.LoadAsset("SK_Dreadweaver") ?? ModAssets.LoadAsset("Dreadweaver"); if ((Object)(object)val != (Object)null) { return val; } string[] allAssetNames = ModAssets.GetAllAssetNames(); foreach (string text in allAssetNames) { string text2 = text.Replace('\\', '/'); string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text2); if (text2.EndsWith("/sk_dreadweaver.prefab", StringComparison.OrdinalIgnoreCase) || text2.EndsWith("/dreadweaver.prefab", StringComparison.OrdinalIgnoreCase) || string.Equals(fileNameWithoutExtension, "SK_Dreadweaver", StringComparison.OrdinalIgnoreCase) || string.Equals(fileNameWithoutExtension, "Dreadweaver", StringComparison.OrdinalIgnoreCase)) { val = ModAssets.LoadAsset(text); if ((Object)(object)val != (Object)null) { return val; } } } return null; } private static void PreparePrefab(GameObject prefab) { //IL_0029: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) AssignUniqueNetworkHash(prefab); prefab.SetActive(true); TrySetTag(prefab, "Enemy"); TrySetLayer(prefab, "Enemies"); prefab.transform.localScale = Vector3.one * 1.75f; DreadweaverAI dreadweaverAI = prefab.GetComponent(); if ((Object)(object)dreadweaverAI == (Object)null) { dreadweaverAI = prefab.AddComponent(); } if ((Object)(object)prefab.GetComponent() == (Object)null) { prefab.AddComponent(); } Animator val = prefab.GetComponent() ?? prefab.GetComponentInChildren(true); if ((Object)(object)val != (Object)null) { val.applyRootMotion = false; val.cullingMode = (AnimatorCullingMode)0; dreadweaverAI.visualAnimator = val; } else { Log.LogWarning((object)"[Dreadweaver] Prefab has no Animator."); } NavMeshAgent val2 = prefab.GetComponent(); if ((Object)(object)val2 == (Object)null) { val2 = prefab.AddComponent(); } ConfigureAgent(val2); ((EnemyAI)dreadweaverAI).agent = val2; ((EnemyAI)dreadweaverAI).creatureSFX = FindOrCreateAudioSource(prefab.transform, "CreatureSFX", 42f); ((EnemyAI)dreadweaverAI).creatureVoice = FindOrCreateAudioSource(prefab.transform, "CreatureVoice", 46f); ((EnemyAI)dreadweaverAI).eye = FindOrCreateChild(prefab.transform, "EyeTransform", new Vector3(0f, 1.85f, 0.55f)); dreadweaverAI.attackOrigin = FindOrCreateChild(prefab.transform, "AttackOrigin", new Vector3(0f, 1.2f, 0.95f)); AssignDreadweaverAudio(dreadweaverAI); EnsureDreadweaverRendering(prefab, (EnemyAI)(object)dreadweaverAI); EnsureBehaviourStates(dreadweaverAI); EnsureScanNode(prefab); EnsureCollision(prefab, dreadweaverAI); } private static void ConfigureAgent(NavMeshAgent agent) { agent.speed = ModConfig.StalkMoveSpeed.Value; agent.angularSpeed = 420f; agent.acceleration = 18f; agent.stoppingDistance = Mathf.Max(0.5f, 1.5274999f); agent.radius = 0.86f; agent.height = 2.45f; agent.baseOffset = 0f; agent.autoBraking = true; agent.autoRepath = true; agent.updateRotation = false; agent.areaMask = -1; agent.obstacleAvoidanceType = (ObstacleAvoidanceType)4; agent.avoidancePriority = 31; } private static void EnsureDreadweaverRendering(GameObject prefab, EnemyAI ai) { //IL_0020: 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_003e: 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) SkinnedMeshRenderer[] componentsInChildren = prefab.GetComponentsInChildren(true); MeshRenderer[] componentsInChildren2 = prefab.GetComponentsInChildren(true); ai.skinnedMeshRenderers = componentsInChildren; ai.meshRenderers = componentsInChildren2; Bounds localBounds = default(Bounds); ((Bounds)(ref localBounds))..ctor(Vector3.up * 1.25f, new Vector3(7.5f, 5.5f, 7.5f)); foreach (SkinnedMeshRenderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !IsRuntimeHelperRenderer((Renderer)(object)val)) { ActivateRendererHierarchy(prefab.transform, ((Component)val).transform); ((Component)val).gameObject.SetActive(true); ((Renderer)val).enabled = true; ((Renderer)val).forceRenderingOff = false; val.updateWhenOffscreen = true; ((Renderer)val).localBounds = localBounds; ((Renderer)val).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)val).receiveShadows = true; EnsureRendererHasOpaqueMaterial((Renderer)(object)val); } } foreach (MeshRenderer val2 in componentsInChildren2) { if (!((Object)(object)val2 == (Object)null) && !IsRuntimeHelperRenderer((Renderer)(object)val2)) { ActivateRendererHierarchy(prefab.transform, ((Component)val2).transform); ((Component)val2).gameObject.SetActive(true); ((Renderer)val2).enabled = true; ((Renderer)val2).forceRenderingOff = false; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)val2).receiveShadows = true; EnsureRendererHasOpaqueMaterial((Renderer)(object)val2); } } ManualLogSource log = Log; if (log != null) { log.LogInfo((object)$"[DreadweaverRenderer] Prepared {componentsInChildren.Length} skinned renderer(s), {componentsInChildren2.Length} mesh renderer(s)."); } } private static void ActivateRendererHierarchy(Transform prefabRoot, Transform rendererTransform) { Transform val = rendererTransform; while ((Object)(object)val != (Object)null) { if (!((Component)val).gameObject.activeSelf) { ((Component)val).gameObject.SetActive(true); } if (!((Object)(object)val == (Object)(object)prefabRoot)) { val = val.parent; continue; } break; } } private static bool IsRuntimeHelperRenderer(Renderer renderer) { Transform val = (((Object)(object)renderer != (Object)null) ? ((Component)renderer).transform : null); while ((Object)(object)val != (Object)null) { string text = ((Object)val).name ?? string.Empty; if (text.IndexOf("ScanNode", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Collision", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("MapDot", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } val = val.parent; } return false; } private static void EnsureRendererHasOpaqueMaterial(Renderer renderer) { Material[] array = renderer.sharedMaterials; if (array == null || array.Length == 0) { array = (Material[])(object)new Material[1]; } bool flag = false; for (int i = 0; i < array.Length; i++) { Material val = array[i]; if ((Object)(object)val == (Object)null || (Object)(object)val.shader == (Object)null || ShouldReplaceDreadweaverMaterial(val)) { array[i] = CreateOpaqueDreadweaverMaterial(val); flag = true; } else { ForceOpaqueMaterial(val); } } if (flag) { renderer.sharedMaterials = array; } } private static bool ShouldReplaceDreadweaverMaterial(Material material) { string text = (((Object)(object)material.shader != (Object)null) ? ((Object)material.shader).name : string.Empty); if (text.IndexOf("InternalError", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (text.IndexOf("Standard", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (material.IsKeywordEnabled("_ALPHATEST_ON") || material.renderQueue == 2450 || material.renderQueue >= 3000) { return true; } return false; } private static Material CreateOpaqueDreadweaverMaterial(Material source) { //IL_0055: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_0144: Expected O, but got Unknown Shader val = Shader.Find("HDRP/Lit") ?? Shader.Find("HDRP/Unlit") ?? Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard") ?? Shader.Find("Diffuse"); Material val2 = (((Object)(object)val != (Object)null) ? new Material(val) : new Material(source)); ((Object)val2).name = "M_DreadweaverRuntimeVisible"; Texture texture = (((Object)(object)source != (Object)null) ? source.mainTexture : null); Texture texture2 = (((Object)(object)source != (Object)null && source.HasProperty("_BumpMap")) ? source.GetTexture("_BumpMap") : null); Texture texture3 = (((Object)(object)source != (Object)null && source.HasProperty("_MetallicGlossMap")) ? source.GetTexture("_MetallicGlossMap") : null); Texture texture4 = (((Object)(object)source != (Object)null && source.HasProperty("_OcclusionMap")) ? source.GetTexture("_OcclusionMap") : null); SetMaterialTexture(val2, "_BaseColorMap", texture); SetMaterialTexture(val2, "_MainTex", texture); SetMaterialTexture(val2, "_NormalMap", texture2); SetMaterialTexture(val2, "_BumpMap", texture2); SetMaterialTexture(val2, "_MaskMap", texture3); SetMaterialTexture(val2, "_MetallicGlossMap", texture3); SetMaterialTexture(val2, "_OcclusionMap", texture4); ForceOpaqueMaterial(val2); return val2; } private static void ForceOpaqueMaterial(Material material) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)material == (Object)null)) { SetMaterialColor(material, "_BaseColor", Color.white); SetMaterialColor(material, "_Color", Color.white); SetMaterialFloat(material, "_SurfaceType", 0f); SetMaterialFloat(material, "_BlendMode", 0f); SetMaterialFloat(material, "_AlphaCutoffEnable", 0f); SetMaterialFloat(material, "_AlphaClip", 0f); SetMaterialFloat(material, "_Cutoff", 0f); SetMaterialFloat(material, "_ZWrite", 1f); SetMaterialFloat(material, "_SrcBlend", 1f); SetMaterialFloat(material, "_DstBlend", 0f); SetMaterialFloat(material, "_AlphaSrcBlend", 1f); SetMaterialFloat(material, "_AlphaDstBlend", 0f); SetMaterialFloat(material, "_Mode", 0f); SetMaterialFloat(material, "_DoubleSidedEnable", 1f); SetMaterialFloat(material, "_CullMode", 0f); SetMaterialFloat(material, "_Cull", 0f); material.SetOverrideTag("RenderType", "Opaque"); material.renderQueue = -1; material.DisableKeyword("_ALPHATEST_ON"); material.DisableKeyword("_ALPHATESTENABLE_ON"); material.DisableKeyword("_SURFACE_TYPE_TRANSPARENT"); material.DisableKeyword("_ALPHABLEND_ON"); } } private static void SetMaterialTexture(Material material, string propertyName, Texture texture) { if ((Object)(object)material != (Object)null && (Object)(object)texture != (Object)null && material.HasProperty(propertyName)) { material.SetTexture(propertyName, texture); } } private static void SetMaterialColor(Material material, string propertyName, Color color) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)material != (Object)null && material.HasProperty(propertyName)) { material.SetColor(propertyName, color); } } private static void SetMaterialFloat(Material material, string propertyName, float value) { if ((Object)(object)material != (Object)null && material.HasProperty(propertyName)) { material.SetFloat(propertyName, value); } } private static void EnsureBehaviourStates(DreadweaverAI ai) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0030: 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_0041: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0069: 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_007a: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown ((EnemyAI)ai).enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[11] { new EnemyBehaviourState { name = "HiddenAcquireTarget" }, new EnemyBehaviourState { name = "HiddenFindWatch" }, new EnemyBehaviourState { name = "SightingVisible" }, new EnemyBehaviourState { name = "HiddenBetweenSightings" }, new EnemyBehaviourState { name = "HiddenPreAttackDelay" }, new EnemyBehaviourState { name = "AttackSetup" }, new EnemyBehaviourState { name = "CrawlAdvance" }, new EnemyBehaviourState { name = "Pursuit" }, new EnemyBehaviourState { name = "AttackVanishReposition" }, new EnemyBehaviourState { name = "Hit" }, new EnemyBehaviourState { name = "Dead" } }; ((EnemyAI)ai).currentBehaviourStateIndex = 0; ((EnemyAI)ai).previousBehaviourStateIndex = 0; ((EnemyAI)ai).currentBehaviourState = ((EnemyAI)ai).enemyBehaviourStates[0]; } internal static void EnsureScanNode(GameObject prefab) { //IL_0125: 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_0234: 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) { 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)$"[Dreadweaver] 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.45f, 0f))); ((Object)((Component)val3).gameObject).name = "ScanNode"; 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)($"[Dreadweaver] 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.75f, 2.35f, 1.35f); if ((Object)(object)val == (Object)null) { val = ((Component)val3).gameObject.AddComponent(); } val.headerText = "Dreadweaver"; val.subText = ""; val.maxRange = 25; val.minRange = 1; val.requiresLineOfSight = true; val.nodeType = 1; } private static void RetireExtraScanNode(ScanNodeProperties extra, ScanNodeProperties preferred, GameObject root) { //IL_0035: 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_0080: 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) 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)) { 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, DreadweaverAI ai) { //IL_002e: 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_00af: 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) CapsuleCollider obj = prefab.GetComponent() ?? prefab.AddComponent(); ((Collider)obj).isTrigger = false; obj.direction = 1; obj.center = new Vector3(0f, 1.18f, 0f); obj.radius = 0.86f; obj.height = 2.45f; Transform val = FindOrCreateChild(prefab.transform, "Collision", new Vector3(0f, 1.1f, 0f)); TrySetTag(((Component)val).gameObject, "Enemy"); TrySetLayer(((Component)val).gameObject, "Enemies"); BoxCollider obj2 = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); ((Collider)obj2).isTrigger = true; obj2.center = Vector3.zero; obj2.size = new Vector3(2.05f, 2.25f, 1.9f); Rigidbody obj3 = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); obj3.isKinematic = true; obj3.useGravity = false; obj3.detectCollisions = true; EnemyAICollisionDetect obj4 = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); obj4.mainScript = (EnemyAI)(object)ai; obj4.alwaysAllowHitting = true; obj4.canCollideWithEnemies = true; obj4.onlyCollideWhenGrounded = false; } private static EnemyType CreateEnemyType(GameObject prefab) { EnemyType obj = ScriptableObject.CreateInstance(); obj.enemyName = "Dreadweaver"; obj.enemyPrefab = prefab; obj.PowerLevel = ModConfig.PowerLevel.Value; obj.DiversityPowerLevel = 1; obj.MaxCount = ModConfig.MaxCount.Value; obj.canDie = true; obj.canBeStunned = true; obj.canBeDestroyed = true; obj.stunTimeMultiplier = 1f; obj.stunGameDifficultyMultiplier = 1f; obj.destroyOnDeath = false; obj.doorSpeedMultiplier = 1.1f; obj.isOutsideEnemy = false; obj.isDaytimeEnemy = false; obj.normalizedTimeInDayToLeave = 1f; obj.probabilityCurve = AnimationCurve.Constant(0f, 1f, 1f); obj.numberSpawnedFalloff = AnimationCurve.Linear(0f, 1f, 1f, 0.35f); obj.useNumberSpawnedFalloff = true; obj.disableAnimatorWhenFar = false; return obj; } private static AudioSource FindOrCreateAudioSource(Transform parent, string childName, float maxDistance) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Transform val = FindOrCreateChild(parent, childName, Vector3.zero); AudioSource obj = ((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent(); obj.playOnAwake = false; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = 3f; obj.maxDistance = maxDistance; return obj; } private static void AssignDreadweaverAudio(DreadweaverAI ai) { if ((Object)(object)ai == (Object)null || (Object)(object)ModAssets == (Object)null) { return; } string[] allAssetNames = ModAssets.GetAllAssetNames(); ai.spotClips = LoadAudioClipSet(allAssetNames, "Spot_01", "Spot_02", "Spot_03"); ai.footstepClips = LoadAudioClipSet(allAssetNames, "Footstep Metal Running 1_01", "Footstep Metal Running 1_02", "Footstep Metal Running 1_03", "Footstep Metal Running 1_04", "Footstep Metal Running 1_05", "Footstep Metal Running 1_06", "Footstep Metal Running 1_07", "Footstep Metal Running 1_08"); ai.initialAttackClip = LoadAudioClip(allAssetNames, "Jumpscare_InitialAttack_01"); ai.spottedClip = ((ai.spotClips.Length != 0) ? ai.spotClips[0] : null); ai.attackClip = ai.initialAttackClip; if (ai.spotClips.Length != 3 || ai.footstepClips.Length != 8 || (Object)(object)ai.initialAttackClip == (Object)null) { ManualLogSource log = Log; if (log != null) { log.LogWarning((object)($"[DreadweaverAudio] Incomplete bundle audio: spots={ai.spotClips.Length}/3, " + $"footsteps={ai.footstepClips.Length}/8, initialAttack={(((Object)(object)ai.initialAttackClip != (Object)null) ? 1 : 0)}/1.")); } } else { ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)"[DreadweaverAudio] Loaded 3 stalking stingers, 8 footsteps, and 1 initial-attack jumpscare."); } } } private static AudioClip[] LoadAudioClipSet(string[] bundleAssets, params string[] clipNames) { List list = new List(clipNames.Length); for (int i = 0; i < clipNames.Length; i++) { AudioClip val = LoadAudioClip(bundleAssets, clipNames[i]); if ((Object)(object)val != (Object)null) { list.Add(val); } } return list.ToArray(); } private static AudioClip LoadAudioClip(string[] bundleAssets, string clipName) { foreach (string text in bundleAssets) { if (string.Equals(Path.GetFileNameWithoutExtension(text), clipName, StringComparison.OrdinalIgnoreCase)) { AudioClip val = ModAssets.LoadAsset(text); if ((Object)(object)val != (Object)null) { return val; } } } ManualLogSource log = Log; if (log != null) { log.LogWarning((object)("[DreadweaverAudio] Missing AudioClip '" + clipName + "' in dreadweaver.bundle.")); } return null; } private static Transform FindOrCreateChild(Transform parent, string name, Vector3 localPosition) { //IL_001b: 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_0012: Unknown result type (might be due to invalid IL or missing references) Transform val = parent.Find(name); if ((Object)(object)val != (Object)null) { val.localPosition = localPosition; return val; } val = new GameObject(name).transform; val.SetParent(parent, false); val.localPosition = localPosition; return val; } private static void AssignUniqueNetworkHash(GameObject prefab) { try { NetworkObject val = prefab.GetComponent(); if ((Object)(object)val == (Object)null) { val = prefab.AddComponent(); } uint num = BitConverter.ToUInt32(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes("y4ngz.lethalcompany.dreadweaver.SK_Dreadweaver")), 0); PropertyInfo property = typeof(NetworkObject).GetProperty("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null && property.CanWrite) { property.SetValue(val, num); return; } FieldInfo fieldInfo = typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? typeof(NetworkObject).GetField("k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic); if (fieldInfo != null) { fieldInfo.SetValue(val, num); } } catch (Exception ex) { Log.LogWarning((object)("Could not assign NetworkObject hash for Dreadweaver: " + ex.Message)); } } private static void DumpBundleAssets() { if (!((Object)(object)ModAssets == (Object)null)) { string[] allAssetNames = ModAssets.GetAllAssetNames(); foreach (string text in allAssetNames) { Log.LogError((object)(" - " + text)); } } } 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)$"[Dreadweaver] 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; } } } internal static class PluginInfo { public const string PLUGIN_GUID = "y4ngz.lethalcompany.dreadweaver"; public const string PLUGIN_NAME = "Y4NGZ Dreadweaver"; public const string PLUGIN_VERSION = "0.1.0"; } } namespace Y4NGZDreadweaver.AI { public sealed class DreadweaverAI : EnemyAI { private struct AttackProfile { public readonly int AnimationCode; public readonly float StrikeTimeSeconds; public readonly float RecoverySeconds; public readonly float RangeMultiplier; public readonly float ArcMultiplier; public readonly float SelectionWeight; public AttackProfile(int animationCode, float strikeTimeSeconds, float recoverySeconds, float rangeMultiplier, float arcMultiplier, float selectionWeight) { AnimationCode = animationCode; StrikeTimeSeconds = strikeTimeSeconds; RecoverySeconds = recoverySeconds; RangeMultiplier = rangeMultiplier; ArcMultiplier = arcMultiplier; SelectionWeight = selectionWeight; } } private struct FlickerLight { public Light Light; public bool Enabled; public float Intensity; } private enum SightingStage { Long, Medium, Short } private enum SightingPresentation { HallwayEnd, CornerReveal, DeadEndBehind } private enum AttackEngageMode { WalkThenRun, RunImmediately, CrawlThenRun } private sealed class CamoShellRenderer { public Renderer Renderer; public Material[] Materials; } private sealed class LightFlickerState { public Light Light; public bool Enabled; public float Intensity; } public const int StateHiddenAcquireTarget = 0; public const int StateHiddenFindWatch = 1; public const int StateSightingVisible = 2; public const int StateHiddenBetweenSightings = 3; public const int StateHiddenPreAttackDelay = 4; public const int StateAttackSetup = 5; public const int StateCrawlAdvance = 6; public const int StatePursuit = 7; public const int StateAttackVanishReposition = 8; public const int StateHit = 9; public const int StateDead = 10; private const ulong NoTargetClientId = ulong.MaxValue; private const float EyeHeight = 1.65f; private const float RevealUnseenHalfAngle = 35f; private const float DirectRevealHalfAngle = 12f; private const float AttackRevealUnseenHalfAngle = 45f; private const float ShortCornerMaxPathDistance = 16f; private const float ShortApproachVanishDistance = 2.4f; private const float DirectRevealDelaySeconds = 0.75f; private const float ReengageCamoPreviewSeconds = 0.72f; private const int MaxRapidReengagements = 3; private const float WatchSearchRelaxSeconds = 5f; private const float LongSearchRelaxSeconds = 8f; private const float RevealSearchTimeoutSeconds = 12f; private const float SightingSeenCloseThreshold = 1.1f; private const float WatchLosGraceSeconds = 2.5f; private const float MinDistanceFromLastVanish = 8f; private const float VisibilityResyncInterval = 6f; private const float PresentationSyncInterval = 0.08f; private const float PresentationYawThreshold = 1.25f; private const float RevealFacingLockSeconds = 0.8f; private const float RevealReadableFraction = 0.72f; private const float VanishColliderDisableFraction = 0.6f; private const float ReplicatedFacingTurnSpeed = 540f; private const float AnimationCrossFadeSeconds = 0.18f; private const float SightingMinimumStareSeconds = 0.85f; private const float UnseenPresentationTimeoutSeconds = 6f; private const float CornerPresentationMaxPathDistance = 23f; private const float DeadEndBehindMaxPathDistance = 26f; private const float RequiredSightingIntervalMinSeconds = 45f; private const float RequiredSightingIntervalFallbackMaxSeconds = 65f; private const float RetrySightingIntervalMinSeconds = 15f; private const float RetrySightingIntervalFallbackMaxSeconds = 30f; private const float AttackReadyDelayMinSeconds = 15f; private const float AttackReadyDelayMaxSeconds = 30f; private const float ExitDodgeSeconds = 0.42f; private const float ExitDodgeVisibleSeconds = 0.16f; private const float ExitDodgeCamoSeconds = 0.24f; private const float LongSightingDodgeChance = 0.12f; private const float MediumSightingDodgeChance = 0.06f; private const float ExitWalkBackSeconds = 0.82f; private const float ExitWalkBackDistance = 4.75f; private const float ExitDodgeDistance = 6.5f; private const float PlacementClearanceRadius = 0.82f; private const float PlacementClearanceHeight = 2.45f; private const float DefaultAttackDamageDelay = 0.48f; private const float AttackStuckRecoverySeconds = 7f; private const float AttackSoftPathRepairSeconds = 1.6f; private const float AttackPathRepairCooldownSeconds = 1.4f; private const float AttackProgressCheckIntervalSeconds = 0.35f; private const float AttackProgressMinDistance = 0.18f; private const float AttackWalkIntroSeconds = 3f; private const float StalkLightFlickerInitialMinSeconds = 12f; private const float StalkLightFlickerInitialMaxSeconds = 24f; private const float StalkLightFlickerDurationSeconds = 1.15f; private const int StalkLightFlickerBudgetMin = 2; private const int StalkLightFlickerBudgetMax = 3; private const int MaxStalkFlickerLights = 10; private const int MaxStalkFlickerAnimators = 8; private const int MaxPoweredLightSightingCandidates = 16; private const float PoweredLightCandidateSearchPadding = 8f; private const float PoweredLightCandidateSampleRadius = 4.5f; private const float PoweredLightAffinityRadius = 9f; private const float PoweredLightAffinityMaxScore = 4.75f; private const float StalkDoorSlamInitialMinSeconds = 24f; private const float StalkDoorSlamInitialMaxSeconds = 40f; private const float DoorSlamOpenSeconds = 0.2f; private const float DoorSlamClosedSeconds = 0.16f; private const int DoorSlamCycles = 3; private const float DamageStunFreezeSeconds = 1f; private const float FootstepPhaseOffset = 0.08f; private const int FootstepsPerLocomotionCycle = 2; private const string CamoShellName = "_DreadweaverCamoShell"; private const int AnimIdle1 = 0; private const int AnimIdle2 = 1; private const int AnimIdle3 = 2; private const int AnimIdle4 = 3; private const int AnimWalk1 = 4; private const int AnimWalk2 = 5; private const int AnimWalkBack = 6; private const int AnimWalkLeft = 7; private const int AnimWalkLeft2 = 8; private const int AnimWalkRight = 9; private const int AnimRun = 10; private const int AnimCrawl = 11; private const int AnimDodgeLeft = 12; private const int AnimDodgeRight = 13; private const int AnimDodgeForward = 14; private const int AnimDodgeBackward = 15; private const int AnimTurnLeft = 16; private const int AnimTurnRight = 17; private const int AnimWeaveFear = 18; private const int AnimAttackBase = 20; private const int AnimTakingDamage1 = 40; private const int AnimTakingDamage2 = 41; private const int AnimDeath1 = 50; private const int AnimDeath2 = 51; private static readonly AttackProfile[] AttackProfiles = new AttackProfile[9] { new AttackProfile(21, 0.37f, 0.83f, 0.92f, 0.92f, 1.15f), new AttackProfile(22, 0.48f, 1.5f, 1f, 1f, 1f), new AttackProfile(23, 0.43f, 1.2f, 0.96f, 1.06f, 1.1f), new AttackProfile(24, 0.53f, 1.83f, 1f, 1f, 1f), new AttackProfile(25, 0.53f, 1.83f, 1f, 1f, 1f), new AttackProfile(26, 0.65f, 2.67f, 1.08f, 0.9f, 0.7f), new AttackProfile(27, 0.6f, 2.43f, 1.05f, 0.95f, 0.8f), new AttackProfile(28, 0.58f, 2.43f, 1.05f, 1f, 0.8f), new AttackProfile(29, 0.55f, 2.13f, 1f, 1.08f, 0.9f) }; [Header("Dreadweaver anchors")] public Transform attackOrigin; public Animator visualAnimator; [Header("Dreadweaver search")] public AISearchRoutine attackRecoverySearch = new AISearchRoutine(); [Header("Dreadweaver audio")] public AudioClip[] spotClips = (AudioClip[])(object)new AudioClip[0]; public AudioClip[] footstepClips = (AudioClip[])(object)new AudioClip[0]; public AudioClip initialAttackClip; public AudioClip spottedClip; public AudioClip vanishClip; public AudioClip decloakClip; public AudioClip attackClip; public AudioClip hitClip; public AudioClip deathClip; private readonly RaycastHit[] _lineOfSightHits = (RaycastHit[])(object)new RaycastHit[48]; private readonly Collider[] _placementColliders = (Collider[])(object)new Collider[24]; private readonly List _camoShells = new List(); private readonly List _activeLightFlickerStates = new List(); private readonly NetworkVariable _networkState = new NetworkVariable(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkTargetClientId = new NetworkVariable(ulong.MaxValue, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkStage = new NetworkVariable(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkPresentation = new NetworkVariable(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkAnimationCode = new NetworkVariable(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkAnimationNormalizedTime = new NetworkVariable(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkVisible = new NetworkVariable(true, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkVisibilitySequence = new NetworkVariable(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkFacingYaw = new NetworkVariable(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkRevealSequence = new NetworkVariable(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkRevealPosition = new NetworkVariable(Vector3.zero, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkFacingLockDuration = new NetworkVariable(0.8f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkPresentationReadyDelay = new NetworkVariable(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkModelScale = new NetworkVariable(Vector3.one, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkMovementSpeed = new NetworkVariable(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkLocomotionPlayback = new NetworkVariable(1f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkSpotlightActive = new NetworkVariable(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkSpotlightIntensity = new NetworkVariable(0f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkSpotlightAngle = new NetworkVariable(42f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkSpotlightRange = new NetworkVariable(14f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkSpotlightHeight = new NetworkVariable(5f, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable _networkSpotlightColor = new NetworkVariable(Vector3.one, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private Renderer[] _bodyRenderers = (Renderer[])(object)new Renderer[0]; private bool[] _bodyRendererDefaults = new bool[0]; private Collider[] _bodyColliders = (Collider[])(object)new Collider[0]; private bool[] _bodyColliderDefaults = new bool[0]; private bool _visualsCaptured; private bool _camoShellsCreated; private bool _usingBundledCamoMaterial; private bool _loggedCamoFallback; private bool _logicalVisible = true; private bool _renderersShown = true; private int _visSeq; private int _appliedVisSeq = -1; private Coroutine _flickerRoutine; private Coroutine _camoPreviewRoutine; private Coroutine _localLightFlickerRoutine; private float _nextVisibilityResyncTime; private float _presentationReadyAt; private float _nextPresentationSyncTime; private float _lastPublishedFacingYaw; private float _lastPublishedMovementSpeed = -1f; private float _lastPublishedLocomotionPlayback = -1f; private int _clientAppliedRevealSequence; private float _clientFacingLockUntil; private SightingStage _stage; private SightingPresentation _pendingPresentation; private ulong _targetClientId = ulong.MaxValue; private ulong _lastKilledTargetClientId = ulong.MaxValue; private ulong _lastHitByClientId = ulong.MaxValue; private float _phaseEnteredAt; private float _nextActionTime; private bool _hasPendingWatchPosition; private float _watchRevealDeadline; private float _sightingFirstSeenAt = -1f; private float _sightingSeenDistance; private float _losLostSince = -1f; private Vector3 _lastVanishPosition; private bool _hasLastVanishPosition; private Coroutine _sightingExitRoutine; private bool _isEndingSighting; private Coroutine _stalkDoorSlamRoutine; private DoorLock _stalkDoorSlamDoor; private float _nextStalkLightFlickerTime; private float _nextStalkDoorSlamTime; private int _remainingStalkLightFlickers; private Vector3 _lastAttackRevealPosition; private bool _hasLastAttackRevealPosition; private AttackEngageMode _attackEngageMode = AttackEngageMode.CrawlThenRun; private int _attackAdvanceAnimation = 11; private float _attackAdvanceEndTime; private float _nextAttackTime; private float _lostSightTimer; private float _repositionRelaxAt; private Vector3 _lastKnownAttackTargetPosition; private Vector3 _lastAttackProgressPosition; private float _lastAttackProgressDistance; private float _attackStuckTimer; private float _nextAttackProgressCheckTime; private float _nextAttackPathRepairTime; private Coroutine _attackRoutine; private Coroutine _reengageCueRoutine; private bool _isAttackAnimating; private bool _isHitStaggering; private AttackProfile _activeAttackProfile; private bool _resolvePostTargetDownAfterSwing; private float _attackMovementReadyAt; private bool _pursuitSpotlightProfileApplied; private int _rapidReengagementCount; private float _nextLocalFearTime; private float _lastLocalMovementAnimTime; private float _animationLockUntil; private float _damageStunUntil; private float _preDamageStunAnimatorSpeed = 1f; private string _currentAnimationName; private int _currentAnimationCode = int.MinValue; private float _currentAnimationNormalizedTime; private bool _damageStunFrozen; private bool _locomotionMoving; private int _footstepAnimatorStateHash; private int _footstepTick = int.MinValue; private float _lastFootstepNormalizedTime; private int _lastFootstepClipIndex = -1; private bool _hasPlayedInitialAttackJumpscare; private static AudioClip _directionalCamoCue; private DreadweaverSpotlight _spotlight; private bool _spotlightActive; private float _spotlightIntensity; private float _spotlightAngle = 42f; private float _spotlightRange = 14f; private float _spotlightHeight = 5f; private Vector3 _spotlightColor = Vector3.one; private Coroutine _flashlightHarassRoutine; private readonly List _flashlightHarassLights = new List(); private float _nextFlashlightHarassTime; private float StalkMoveSpeed => Mathf.Clamp(Plugin.ModConfig?.StalkMoveSpeed.Value ?? 1.5f, 0.5f, 4f); private float CrawlSpeed => Mathf.Clamp(Plugin.ModConfig?.CrawlSpeed.Value ?? 2.1f, 0.8f, 4f); private float AttackWalkSpeed => Mathf.Clamp(Mathf.Max(StalkMoveSpeed, CrawlSpeed * 0.85f), 1.25f, 3.2f); private float AttackSpeed => Mathf.Clamp(Plugin.ModConfig?.AttackSpeed.Value ?? 5.15f, 2f, 9f); private float TurnSpeed => 420f; private float Acceleration => 18f; private float SpotHalfAngle => 25f; private float CreatureSightRange => 60f; private float SightingIntervalMin => Mathf.Clamp(Plugin.ModConfig?.SightingIntervalMinSeconds.Value ?? 45f, 8f, 120f); private float SightingIntervalMax => ResolveIntervalMax(Plugin.ModConfig?.SightingIntervalMaxSeconds.Value ?? 65f, SightingIntervalMin, 65f, 150f); private float SightingRetryMin => 15f; private float SightingRetryMax => 30f; private float SightingTimeoutSeconds => 12f; private float StalkLightFlickerRadius => 18f; private float StalkLightFlickerIntervalMin => 40f; private float StalkLightFlickerIntervalMax => 70f; private float StalkDoorSlamRadius => 14f; private float StalkDoorSlamIntervalMin => 35f; private float StalkDoorSlamIntervalMax => 70f; private float AttackDelayMin => Mathf.Clamp(Plugin.ModConfig?.AttackDelayMinSeconds.Value ?? 15f, 5f, 60f); private float AttackDelayMax => Mathf.Max(AttackDelayMin, Mathf.Clamp(Plugin.ModConfig?.AttackDelayMaxSeconds.Value ?? 30f, AttackDelayMin, 90f)); private float AttackRevealMin => 8f; private float AttackRevealMax => 16f; private float CrawlAdvanceSeconds => 3f; private float AttackRange => 2.35f; private float AttackCooldown => Mathf.Clamp(Plugin.ModConfig?.AttackCooldown.Value ?? 1.8f, 0.5f, 6f); private float AttackDamageDelay => 0.48f; private float AttackHitHalfAngle => 60f; private int AttackDamage => Mathf.Clamp(Plugin.ModConfig?.AttackDamage.Value ?? 40, 1, 100); private float AttackLoseDistance => 48f; private float AttackLostSightGraceSeconds => 12f; private float PursuitRepositionCooldownMin => 2f; private float PursuitRepositionCooldownMax => 5f; private float PursuitRepositionMinDistance => 10f; private float ChainAttackRadius => 13f; private float VanishFlickerSeconds => 0.65f; private float DecloakFlickerSeconds => 0.55f; private bool DebugLogs => Plugin.ModConfig?.DebugLogs.Value ?? false; private bool MatchAnimationToMovement => true; private float AuthoredWalkSpeed => 1.9f; private float AuthoredCrawlSpeed => 1.9f; private float AuthoredRunSpeed => 3.6f; private bool CreatureSpotlightEnabled => Plugin.ModConfig?.CreatureSpotlightEnabled.Value ?? true; private bool FlashlightHarassEnabled => Plugin.ModConfig?.FlashlightHarassEnabled.Value ?? true; private bool CanSendRpc { get { if ((Object)(object)((NetworkBehaviour)this).NetworkObject != (Object)null) { return ((NetworkBehaviour)this).NetworkObject.IsSpawned; } return false; } } private static float ResolveIntervalMax(float configuredValue, float min, float fallbackMax, float hardMax) { if (configuredValue < min + 0.1f) { return Mathf.Max(min + 1f, fallbackMax); } return Mathf.Max(min, Mathf.Clamp(configuredValue, min, hardMax)); } public override void Awake() { try { ((EnemyAI)this).Awake(); ResolveReferences(); ConfigureAttackSearchDefaults(); } catch (Exception arg) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)$"[DreadweaverAI] Awake failed: {arg}"); } } } public override void OnNetworkSpawn() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) ((NetworkBehaviour)this).OnNetworkSpawn(); _clientAppliedRevealSequence = -1; if (((NetworkBehaviour)this).IsServer) { _networkModelScale.Value = ((Component)this).transform.localScale; } else { ApplyNetworkSnapshotLocal(force: true); } } public override void Start() { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) try { ((EnemyAI)this).Start(); Plugin.EnsureScanNode(((Component)this).gameObject); ResolveReferences(); ConfigureAttackSearchDefaults(); CaptureVisuals(); base.enemyHP = Plugin.ModConfig?.Health.Value ?? 5; ConfigureAgent(StalkMoveSpeed); StopAgent(); SetStateLocal(0); PlayAnimationLocal(0, 0.18f, 0f); _hasPlayedInitialAttackJumpscare = false; ResetFootstepTracking(); if (((NetworkBehaviour)this).IsServer) { RepairFacilityAINodes(); PublishAuthoritativePresentationServer(force: true); VanishServer(playCue: false); _nextActionTime = Time.time + Random.Range(2f, 4f); } else if (((NetworkBehaviour)this).IsSpawned) { ApplyNetworkSnapshotLocal(force: true); } if (DebugLogs) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[DreadweaverAI] Spawned #{base.thisEnemyIndex} at {((Component)this).transform.position}."); } } } catch (Exception arg) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogError((object)$"[DreadweaverAI] Start failed: {arg}"); } } } public override void Update() { try { ((EnemyAI)this).Update(); if (base.isEnemyDead) { return; } ResolveReferences(); ApplyNetworkSnapshotLocal(); ApplyReplicatedFacingLocal(); if (ApplyDamageStunFreeze()) { return; } TickLocalFear(); TickAnimatorPlaybackSpeed(); TickLocalFootsteps(); if (!((NetworkBehaviour)this).IsServer || (Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayersDead) { return; } if (Time.time >= _nextVisibilityResyncTime) { _nextVisibilityResyncTime = Time.time + 6f; if (CanSendRpc) { ResyncVisibilityClientRpc(_logicalVisible, _visSeq); } } if (!_isHitStaggering) { TickStalkingEnvironmentScares(); switch (base.currentBehaviourStateIndex) { case 0: TickHiddenAcquireTarget(); break; case 1: TickHiddenFindWatch(); break; case 2: TickSightingVisible(Time.deltaTime); break; case 3: TickHiddenWait(1); break; case 4: TickHiddenWait(5); break; case 5: TickAttackSetup(); break; case 6: TickCrawlAdvance(Time.deltaTime); break; case 7: TickPursuit(Time.deltaTime); break; case 8: TickAttackVanishReposition(); break; } TickAuthoritativeLocomotionAnimation(); PublishAuthoritativePresentationServer(); } } catch (Exception arg) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)$"[DreadweaverAI] Update failed: {arg}"); } } } public override void DoAIInterval() { try { ((EnemyAI)this).DoAIInterval(); } catch (Exception arg) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)$"[DreadweaverAI] DoAIInterval failed: {arg}"); } } } public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { try { ((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID); if (base.isEnemyDead) { return; } BeginDamageStunFreeze(); if (!((NetworkBehaviour)this).IsServer) { return; } base.enemyHP -= Mathf.Max(1, force); if (base.enemyHP <= 0) { DieFromDamage(); return; } _lastHitByClientId = (((Object)(object)playerWhoHit != (Object)null) ? playerWhoHit.actualClientId : ulong.MaxValue); if (!_isHitStaggering) { ((MonoBehaviour)this).StartCoroutine(HitStaggerRoutine()); } } catch (Exception arg) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)$"[DreadweaverAI] HitEnemy failed: {arg}"); } } } public override void KillEnemy(bool destroy = false) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) try { StopManagedRoutines(); if (_flickerRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_flickerRoutine); _flickerRoutine = null; } if (_camoPreviewRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_camoPreviewRoutine); _camoPreviewRoutine = null; } StopLocalLightFlicker(); StopFlashlightHarass(); _spotlightActive = false; ApplyCreatureSpotlight(active: false, 0f, 0f, 0f, 0f, Vector3.zero); _logicalVisible = true; _isEndingSighting = false; SetCollidersEnabled(enabled: true); SetCamoShellsShown(shown: false); SetRenderersShown(shown: true); ClearDamageStunFreeze(); StopAgent(); ((EnemyAI)this).KillEnemy(destroy); base.isEnemyDead = true; SetStateLocal(10); PlayAnimationLocal((Random.value < 0.5f) ? 50 : 51, 0.08f, 0f); if ((Object)(object)deathClip != (Object)null && (Object)(object)base.creatureVoice != (Object)null) { base.creatureVoice.PlayOneShot(deathClip, 1f); } } catch (Exception arg) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)$"[DreadweaverAI] KillEnemy failed: {arg}"); } } } private void TickHiddenAcquireTarget() { if (!(Time.time < _nextActionTime)) { _nextActionTime = Time.time + 1.5f; PlayerControllerB val = ChooseFixationTarget(); if (!((Object)(object)val == (Object)null)) { SetFixationTarget(val, "new stalking target"); _stage = SightingStage.Long; EnterPhase(1); } } } private void TickHiddenWait(int nextState) { if ((Object)(object)RequireStalkTarget() == (Object)null) { RestartStalkCycle("target lost while hidden"); } else if (!(Time.time < _nextActionTime)) { EnterPhase(nextState); } } private void TickHiddenFindWatch() { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = RequireStalkTarget(); if ((Object)(object)val == (Object)null) { RestartStalkCycle("target lost while finding watch position"); } else if (!_hasPendingWatchPosition) { if (Time.time < _nextActionTime) { return; } _nextActionTime = Time.time + 0.65f; if (!TryFindSightingPosition(val, _stage, out var position)) { if (Time.time - _phaseEnteredAt > 12f) { RestartStalkCycle("no stalking presentation found"); } } else { TeleportFacing(position, GetPlayerFocusPoint(val)); _hasPendingWatchPosition = true; _watchRevealDeadline = Time.time + 0.75f; } } else if (!ValidateWatchPosition(val, _stage)) { _hasPendingWatchPosition = false; } else { if (AnyPlayerWouldSeePosition(GetCreatureFocusPoint(), 12f) && Time.time < _watchRevealDeadline) { return; } TeleportFacing(((Component)this).transform.position, GetPlayerFocusPoint(val)); RevealServer(Mathf.Max(0.08f, DecloakFlickerSeconds * 0.75f)); PlayStalkingRevealSoundServer(val); PlayAnimationServer(ChooseSightingIntroAnimation(), 0.2f, GetSightingIntroNormalizedTime()); EnterPhase(2); if (DebugLogs) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[DreadweaverAI] {_stage}/{_pendingPresentation} sighting revealed at {((Component)this).transform.position}."); } } } } private bool ValidateWatchPosition(PlayerControllerB target, SightingStage stage) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) GetStageParameters(stage, out var min, out var max, out var _, out var panic); float num = Vector3.Distance(((Component)this).transform.position, ((Component)target).transform.position); float radius = ((_pendingPresentation == SightingPresentation.HallwayEnd && stage != SightingStage.Short) ? panic : Mathf.Max(2.6f, 2.4f)); if (TooCloseToAnyPlayer(((Component)this).transform.position, radius)) { return false; } if (_pendingPresentation == SightingPresentation.CornerReveal) { if (num <= Mathf.Max(max + 10f, 13f)) { return HasShortCompletePath(((Component)this).transform.position, ((Component)target).transform.position, 23f); } return false; } if (_pendingPresentation == SightingPresentation.DeadEndBehind) { if (num >= 3.5f && num <= Mathf.Max(max + 12f, 18f)) { return HasShortCompletePath(((Component)this).transform.position, ((Component)target).transform.position, 26f); } return false; } if (num < min * 0.6f || num > max * 1.35f) { return false; } return HasClearLineOfSight(GetCreatureFocusPoint(), GetPlayerFocusPoint(target), ((Component)target).transform); } private void TickSightingVisible(float deltaTime) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = RequireStalkTarget(); if ((Object)(object)val == (Object)null) { RestartStalkCycle("target lost while visible"); return; } StopAgent(); FaceTargetForStalking(val); if (_isEndingSighting) { return; } GetStageParameters(_stage, out var min, out var max, out var hold, out var panic); hold = Mathf.Max(0.85f, hold); float num = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position); float num2 = Mathf.Max(panic, GetApproachExitDistance(_pendingPresentation, _stage, min, max)); bool flag = Time.time >= _presentationReadyAt && TargetSeesCreature(val); if (flag && _sightingFirstSeenAt < 0f) { _sightingFirstSeenAt = Time.time; _sightingSeenDistance = num; } if ((_stage != SightingStage.Short || _sightingFirstSeenAt >= 0f) && TryGetClosestLivingPlayer(out var _, out var closestDistance) && closestDistance <= num2) { EndSighting("player too close"); return; } if (NonTargetPlayerSeesCreature(val)) { EndSighting("seen by another player"); return; } if (flag) { if (num < _sightingSeenDistance - 1.1f) { EndSighting("target moved closer"); } else if (Time.time - _sightingFirstSeenAt >= Mathf.Max(0.85f, hold)) { EndSighting("hold complete"); } return; } if (_sightingFirstSeenAt >= 0f) { if (Time.time - _sightingFirstSeenAt >= hold) { EndSighting("hold complete after look-away"); } return; } if (_stage != SightingStage.Short) { if (HasClearLineOfSight(GetCreatureFocusPoint(), GetPlayerFocusPoint(val), ((Component)val).transform)) { _losLostSince = -1f; } else if (_losLostSince < 0f) { _losLostSince = Time.time; } if ((_losLostSince >= 0f && Time.time - _losLostSince > 2.5f) || num > max * 1.35f) { EndSighting("watch position became bad"); return; } } else if (Time.time >= _nextActionTime) { _nextActionTime = Time.time + 0.75f; if (!HasShortCompletePath(((Component)this).transform.position, ((Component)val).transform.position, 22f)) { EndSighting("target left the corner area"); return; } } if (Time.time - _phaseEnteredAt > Mathf.Min(SightingTimeoutSeconds, GetUnseenPresentationTimeout(_pendingPresentation))) { EndSighting("sighting timed out"); } } private void EndSighting(string reason) { if (!_isEndingSighting) { _sightingExitRoutine = ((MonoBehaviour)this).StartCoroutine(EndSightingRoutine(reason)); } } private IEnumerator EndSightingRoutine(string reason) { _isEndingSighting = true; bool wasSeen = _sightingFirstSeenAt >= 0f; PlayerControllerB val = ResolveTargetById(_targetClientId); if (DebugLogs) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[DreadweaverAI] {_stage}/{_pendingPresentation} sighting ending ({reason}); seen={wasSeen}."); } } if ((Object)(object)val != (Object)null) { FaceTargetForStalking(val); } if (!wasSeen && _stage == SightingStage.Short) { VanishServer(playCue: false, 0f); _isEndingSighting = false; _sightingExitRoutine = null; CompleteSightingTransition(wasSeen); yield break; } Vector3 dodgeDestination = Vector3.zero; int animationCode = 15; if (ShouldAttemptDodgeExit(val) && TryFindDodgeExitDestination(val, out dodgeDestination, out animationCode)) { PlayAnimationServer(animationCode, 0.04f, 0f); MoveAgentTo(dodgeDestination, Mathf.Max(7.5f, AttackSpeed + 1.5f), 0.15f, autoBrake: false); yield return (object)new WaitForSeconds(0.16f); VanishServer(playCue: true, 0.24f); yield return (object)new WaitForSeconds(Mathf.Max(0.05f, 0.26f)); if (TrySampleNavPosition(dodgeDestination, 2f, out var position)) { MoveRootTo(position, ((Component)this).transform.rotation); } } else { StopAgent(); yield return (object)new WaitForSeconds(0.08f); VanishServer(playCue: true); yield return (object)new WaitForSeconds(Mathf.Max(0.12f, VanishFlickerSeconds)); } _isEndingSighting = false; _sightingExitRoutine = null; CompleteSightingTransition(wasSeen); } private void CompleteSightingTransition(bool wasSeen) { if (!wasSeen) { EnterPhase(3); _nextActionTime = Time.time + Random.Range(SightingRetryMin, SightingRetryMax); } else if (_stage == SightingStage.Short) { EnterPhase(4); _nextActionTime = Time.time + Random.Range(AttackDelayMin, AttackDelayMax); } else { _stage = ((_stage == SightingStage.Long) ? SightingStage.Medium : SightingStage.Short); EnterPhase(3); _nextActionTime = Time.time + Random.Range(SightingIntervalMin, SightingIntervalMax); } } private int ChooseSightingIntroAnimation() { return 18; } private float GetSightingIntroNormalizedTime() { return _stage switch { SightingStage.Long => 0.08f, SightingStage.Medium => 0.12f, _ => 0.16f, }; } private void PlayStalkingRevealSoundServer(PlayerControllerB target) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_0083: 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) if (!((NetworkBehaviour)this).IsServer || (Object)(object)target == (Object)null) { return; } int num = ((spotClips != null && spotClips.Length != 0) ? Random.Range(0, spotClips.Length) : (-1)); if (num >= 0 || (Object)(object)spottedClip != (Object)null) { float spotStingerVolume = GetSpotStingerVolume(num); Vector3 worldPosition = ((Component)target).transform.position + Vector3.up * 1.1f; if (CanSendRpc) { PlayStalkingRevealSoundClientRpc(num, worldPosition, spotStingerVolume); } else { PlayStalkingRevealSoundLocal(num, worldPosition, spotStingerVolume); } } PlayDirectionalCamoCueServer((_stage == SightingStage.Short) ? 0.78f : ((_stage == SightingStage.Medium) ? 0.62f : 0.48f)); } private static float GetSpotStingerVolume(int clipIndex) { return clipIndex switch { 0 => 0.72f, 1 => 1f, 2 => 0.82f, _ => 0.85f, }; } private void PlayDirectionalCamoCueServer(float volume) { if (CanSendRpc) { PlayOneShotClientRpc(5, Mathf.Clamp01(volume)); } else if ((Object)(object)base.creatureSFX != (Object)null) { base.creatureSFX.PlayOneShot(GetDirectionalCamoCue(), Mathf.Clamp01(volume)); } } private static float GetUnseenPresentationTimeout(SightingPresentation presentation) { if (presentation != SightingPresentation.HallwayEnd) { return 4.5f; } return 7.5f; } private static float GetApproachExitDistance(SightingPresentation presentation, SightingStage stage, float minDistance, float maxDistance) { switch (presentation) { case SightingPresentation.HallwayEnd: if (stage != SightingStage.Long) { return Mathf.Max(10f, minDistance * 0.7f); } return Mathf.Max(18f, minDistance * 0.65f); case SightingPresentation.DeadEndBehind: return 5.5f; default: if (stage != SightingStage.Short) { return Mathf.Max(6f, minDistance * 0.5f); } return 4.25f; } } private bool ShouldAttemptDodgeExit(PlayerControllerB target) { //IL_0027: 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 ((Object)(object)target == (Object)null || _stage == SightingStage.Short || _sightingFirstSeenAt < 0f) { return false; } if (Vector3.Distance(((Component)this).transform.position, ((Component)target).transform.position) < 12f) { return false; } float num = ((_stage == SightingStage.Long) ? 0.12f : 0.06f); return Random.value <= num; } private bool TryFindDodgeExitDestination(PlayerControllerB target, out Vector3 destination, out int animationCode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_008f: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0109: 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_0121: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_020e: 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_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) destination = Vector3.zero; animationCode = 15; if ((Object)(object)target == (Object)null) { return false; } Vector3 position = ((Component)this).transform.position; Vector3 playerFocusPoint = GetPlayerFocusPoint(target); Vector3 val = ((Component)this).transform.right; val.y = 0f; val = ((((Vector3)(ref val)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val)).normalized : Vector3.right); Vector3 val2 = position - playerFocusPoint; val2.y = 0f; val2 = ((((Vector3)(ref val2)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val2)).normalized : (-((Component)this).transform.forward)); Vector3[] obj = new Vector3[5] { val, -val, default(Vector3), default(Vector3), default(Vector3) }; Vector3 val3 = val + val2; obj[2] = ((Vector3)(ref val3)).normalized; val3 = -val + val2; obj[3] = ((Vector3)(ref val3)).normalized; obj[4] = val2; Vector3[] array = (Vector3[])(object)obj; float num = float.NegativeInfinity; for (int i = 0; i < array.Length; i++) { Vector3 val4 = array[i]; if (((Vector3)(ref val4)).sqrMagnitude < 0.001f) { continue; } Vector3 origin = position + ((Vector3)(ref val4)).normalized * Random.Range(4.875f, 7.8f); if (!TrySampleNavPosition(origin, 3.5f, out var position2) || TooCloseToAnyPlayer(position2, 2.6f) || !HasShortCompletePath(position, position2, 12f)) { continue; } Vector3 candidateSightPoint = GetCandidateSightPoint(position2); bool flag = PlayerWouldSeePosition(target, candidateSightPoint, 35f); bool flag2 = !HasClearLineOfSight(playerFocusPoint, candidateSightPoint, ((Component)target).transform); if (!(!flag2 || flag)) { float num2 = Mathf.Abs(Vector3.Dot(((Vector3)(ref val4)).normalized, val)); float num3 = Vector3.Distance(position, position2); float num4 = num2 * 4f + num3 * 0.25f + (flag2 ? 2.5f : 0f) + Random.Range(0f, 1f); if (!(num4 <= num)) { num = num4; destination = position2; animationCode = ((Vector3.Dot(((Vector3)(ref val4)).normalized, val) >= 0f) ? 13 : 12); } } } return !float.IsNegativeInfinity(num); } private void TickStalkingEnvironmentScares() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsServer || base.isEnemyDead || !IsStalkingEnvironmentScareState(base.currentBehaviourStateIndex)) { return; } PlayerControllerB val = ResolveTargetById(_targetClientId); if (!IsValidTarget(val) || !val.isInsideFactory) { return; } Vector3 position = ((Component)val).transform.position; Vector3 position2 = ((Component)this).transform.position; if (Time.time >= _nextStalkLightFlickerTime) { if (_remainingStalkLightFlickers <= 0) { _nextStalkLightFlickerTime = float.PositiveInfinity; } else if ((HasNearbyPoweredLight(position, StalkLightFlickerRadius) || HasNearbyPoweredLight(position2, StalkLightFlickerRadius)) && CanSendRpc) { int seed = Random.Range(1, int.MaxValue); TriggerStalkLightFlickerClientRpc(position, position2, StalkLightFlickerRadius, seed, 1.15f); _remainingStalkLightFlickers = Mathf.Max(0, _remainingStalkLightFlickers - 1); ScheduleNextLightFlicker(initial: false); } else { _nextStalkLightFlickerTime = Time.time + Random.Range(12f, 24f); } } if (base.currentBehaviourStateIndex != 2 && _stalkDoorSlamRoutine == null && Time.time >= _nextStalkDoorSlamTime) { if (TryFindNearbyStalkDoor(val, out var selectedDoor)) { _stalkDoorSlamDoor = selectedDoor; _stalkDoorSlamRoutine = ((MonoBehaviour)this).StartCoroutine(StalkDoorSlamRoutine(selectedDoor)); ScheduleNextDoorSlam(initial: false); } else { _nextStalkDoorSlamTime = Time.time + Random.Range(8f, 16f); } } } private static bool IsStalkingEnvironmentScareState(int state) { if (state != 1 && state != 2 && state != 3) { return state == 4; } return true; } private void ScheduleInitialStalkingScares() { _remainingStalkLightFlickers = Random.Range(2, 4); ScheduleNextLightFlicker(initial: true); ScheduleNextDoorSlam(initial: true); } private void ScheduleNextLightFlicker(bool initial) { if (_remainingStalkLightFlickers <= 0) { _nextStalkLightFlickerTime = float.PositiveInfinity; return; } float num = (initial ? Random.Range(12f, 24f) : Random.Range(StalkLightFlickerIntervalMin, StalkLightFlickerIntervalMax)); _nextStalkLightFlickerTime = Time.time + num; } private void ScheduleNextDoorSlam(bool initial) { float stalkDoorSlamIntervalMin = StalkDoorSlamIntervalMin; float stalkDoorSlamIntervalMax = StalkDoorSlamIntervalMax; float num = (initial ? Random.Range(Mathf.Min(24f, stalkDoorSlamIntervalMin), Mathf.Min(40f, stalkDoorSlamIntervalMax)) : Random.Range(stalkDoorSlamIntervalMin, stalkDoorSlamIntervalMax)); _nextStalkDoorSlamTime = Time.time + Mathf.Max(4f, num); } private void ClearStalkingScareTimers() { _nextStalkLightFlickerTime = float.PositiveInfinity; _nextStalkDoorSlamTime = float.PositiveInfinity; _remainingStalkLightFlickers = 0; } private bool HasNearbyPoweredLight(Vector3 center, float radius) { //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_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) RoundManager instance = RoundManager.Instance; if ((Object)(object)instance == (Object)null) { return false; } if (instance.allPoweredLights == null || instance.allPoweredLights.Count == 0) { instance.RefreshLightsList(); } if (instance.allPoweredLights == null) { return false; } float num = radius * radius; for (int i = 0; i < instance.allPoweredLights.Count; i++) { Light val = instance.allPoweredLights[i]; if (!((Object)(object)val == (Object)null)) { Vector3 val2 = ((Component)val).transform.position - center; if (((Vector3)(ref val2)).sqrMagnitude <= num) { return true; } } } return false; } private bool TryFindNearbyStalkDoor(PlayerControllerB target, out DoorLock selectedDoor) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_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) selectedDoor = null; if ((Object)(object)target == (Object)null) { return false; } DoorLock[] array = Object.FindObjectsOfType(); if (array == null || array.Length == 0) { return false; } Vector3 position = ((Component)target).transform.position; float num = StalkDoorSlamRadius * StalkDoorSlamRadius; float num2 = float.PositiveInfinity; foreach (DoorLock val in array) { if (!CanUseDoorForSlam(val, requireClosed: true)) { continue; } Vector3 val2 = ((Component)val).transform.position - position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (!(sqrMagnitude > num)) { float num3 = sqrMagnitude + Random.Range(0f, 12f); if (!(num3 >= num2)) { num2 = num3; selectedDoor = val; } } } return (Object)(object)selectedDoor != (Object)null; } private IEnumerator StalkDoorSlamRoutine(DoorLock door) { for (int i = 0; i < 3; i++) { if (!CanUseDoorForSlam(door, requireClosed: true)) { break; } TriggerDoorSlamOpen(door); yield return (object)new WaitForSeconds(0.2f); if (!CanUseDoorForSlam(door, requireClosed: false)) { break; } TriggerDoorSlamClosed(door); yield return (object)new WaitForSeconds(0.16f); } _stalkDoorSlamDoor = null; _stalkDoorSlamRoutine = null; } private static bool CanUseDoorForSlam(DoorLock door, bool requireClosed) { if ((Object)(object)door == (Object)null || !((Behaviour)door).isActiveAndEnabled || door.isLocked || door.isPickingLock) { return false; } if ((Object)(object)door.doorTrigger != (Object)null && door.doorTrigger.isBeingHeldByPlayer) { return false; } if ((Object)(object)door.doorTriggerB != (Object)null && door.doorTriggerB.isBeingHeldByPlayer) { return false; } AnimatedObjectTrigger component = ((Component)door).GetComponent(); if ((Object)(object)component == (Object)null || !component.isBool) { return false; } if (requireClosed) { return !component.boolValue; } return true; } private static void TriggerDoorSlamOpen(DoorLock door) { if (!((Object)(object)door == (Object)null)) { AnimatedObjectTrigger component = ((Component)door).GetComponent(); if ((Object)(object)component != (Object)null && !component.boolValue) { component.TriggerAnimationNonPlayer(true, true, false); } door.OpenDoorAsEnemyServerRpc(); } } private static void TriggerDoorSlamClosed(DoorLock door) { if (!((Object)(object)door == (Object)null)) { AnimatedObjectTrigger component = ((Component)door).GetComponent(); if ((Object)(object)component != (Object)null && component.boolValue) { component.TriggerAnimationNonPlayer(true, true, true); } door.CloseDoorNonPlayerServerRpc(); } } private void StartStalkLightFlicker(Vector3 targetCenter, Vector3 creatureCenter, float radius, int seed, float duration) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (((Behaviour)this).isActiveAndEnabled && !base.isEnemyDead && _localLightFlickerRoutine == null) { _localLightFlickerRoutine = ((MonoBehaviour)this).StartCoroutine(StalkLightFlickerRoutine(targetCenter, creatureCenter, radius, seed, duration)); } } private IEnumerator StalkLightFlickerRoutine(Vector3 targetCenter, Vector3 creatureCenter, float radius, int seed, float duration) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) RestoreActiveLightFlicker(); _activeLightFlickerStates.Clear(); CaptureNearbyLightFlickerStates(targetCenter, radius, seed); Vector3 val = creatureCenter - targetCenter; if (((Vector3)(ref val)).sqrMagnitude > 4f) { CaptureNearbyLightFlickerStates(creatureCenter, radius, seed ^ 0x2D5A91); } TriggerNearbyPoweredLightAnimators(targetCenter, radius); val = creatureCenter - targetCenter; if (((Vector3)(ref val)).sqrMagnitude > 4f) { TriggerNearbyPoweredLightAnimators(creatureCenter, radius); } if (_activeLightFlickerStates.Count == 0) { _localLightFlickerRoutine = null; yield break; } Random random = new Random(seed); float endTime = Time.time + Mathf.Clamp(duration, 0.25f, 3f); while (Time.time < endTime) { for (int i = 0; i < _activeLightFlickerStates.Count; i++) { LightFlickerState lightFlickerState = _activeLightFlickerStates[i]; Light light = lightFlickerState.Light; if (!((Object)(object)light == (Object)null)) { if ((float)random.NextDouble() < 0.38f) { ((Behaviour)light).enabled = false; continue; } ((Behaviour)light).enabled = true; light.intensity = lightFlickerState.Intensity * Mathf.Lerp(0.08f, 1.25f, (float)random.NextDouble()); } } yield return (object)new WaitForSeconds(Mathf.Lerp(0.045f, 0.14f, (float)random.NextDouble())); } RestoreActiveLightFlicker(); _localLightFlickerRoutine = null; } private void CaptureNearbyLightFlickerStates(Vector3 center, float radius, int seed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) CaptureNearbyLightFlickerStates(center, radius, seed, Mathf.Max(3, 5)); } private void CaptureNearbyLightFlickerStates(Vector3 center, float radius, int seed, int maxAdditionalLights) { //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) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) RoundManager instance = RoundManager.Instance; if ((Object)(object)instance == (Object)null) { return; } if (instance.allPoweredLights == null || instance.allPoweredLights.Count == 0) { instance.RefreshLightsList(); } if (instance.allPoweredLights == null) { return; } Random random = new Random(seed ^ 0x51D34D); float num = radius * radius; int count = _activeLightFlickerStates.Count; int num2 = Mathf.Min(10, count + Mathf.Max(1, maxAdditionalLights)); int num3 = 0; for (int i = 0; i < instance.allPoweredLights.Count; i++) { Light val = instance.allPoweredLights[i]; if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy) { continue; } Vector3 val2 = ((Component)val).transform.position - center; if (((Vector3)(ref val2)).sqrMagnitude > num || IsLightAlreadyCaptured(val)) { continue; } num3++; LightFlickerState lightFlickerState = new LightFlickerState { Light = val, Enabled = ((Behaviour)val).enabled, Intensity = val.intensity }; if (_activeLightFlickerStates.Count < num2) { _activeLightFlickerStates.Add(lightFlickerState); continue; } int num4 = random.Next(num3); int num5 = Mathf.Max(0, num2 - count); if (num4 < num5) { _activeLightFlickerStates[count + num4] = lightFlickerState; } } } private bool IsLightAlreadyCaptured(Light light) { for (int i = 0; i < _activeLightFlickerStates.Count; i++) { if ((Object)(object)_activeLightFlickerStates[i]?.Light == (Object)(object)light) { return true; } } return false; } private static void TriggerNearbyPoweredLightAnimators(Vector3 center, float radius) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) RoundManager instance = RoundManager.Instance; if ((Object)(object)instance == (Object)null) { return; } if (instance.allPoweredLightsAnimators == null || instance.allPoweredLightsAnimators.Count == 0) { instance.RefreshLightsList(); } if (instance.allPoweredLightsAnimators == null) { return; } float num = radius * radius; int num2 = 0; for (int i = 0; i < instance.allPoweredLightsAnimators.Count; i++) { if (num2 >= 8) { break; } Animator val = instance.allPoweredLightsAnimators[i]; if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeInHierarchy) { Vector3 val2 = ((Component)val).transform.position - center; if (!(((Vector3)(ref val2)).sqrMagnitude > num)) { val.SetTrigger("Flicker"); num2++; } } } } private void StopLocalLightFlicker() { if (_localLightFlickerRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_localLightFlickerRoutine); _localLightFlickerRoutine = null; } RestoreActiveLightFlicker(); } private void RestoreActiveLightFlicker() { for (int i = 0; i < _activeLightFlickerStates.Count; i++) { LightFlickerState lightFlickerState = _activeLightFlickerStates[i]; if (!((Object)(object)lightFlickerState?.Light == (Object)null)) { ((Behaviour)lightFlickerState.Light).enabled = lightFlickerState.Enabled; lightFlickerState.Light.intensity = lightFlickerState.Intensity; } } _activeLightFlickerStates.Clear(); } private void TickAttackSetup() { //IL_0081: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = RequireStalkTarget(); if ((Object)(object)val == (Object)null) { RestartStalkCycle("target lost during attack setup"); } else { if (Time.time < _nextActionTime) { return; } _nextActionTime = Time.time + 0.7f; bool relaxed = Time.time - _phaseEnteredAt > 8f; if (!TryFindAttackRevealPosition(val, relaxed, 0f, out var position)) { if (Time.time - _phaseEnteredAt > 12f) { RestartStalkCycle("no initial attack reveal found"); } } else { BeginAttackReveal(val, position, AttackEngageMode.WalkThenRun); } } } private void BeginAttackReveal(PlayerControllerB target, Vector3 position, AttackEngageMode engageMode) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (base.currentBehaviourStateIndex == 8) { if (_reengageCueRoutine == null) { _reengageCueRoutine = ((MonoBehaviour)this).StartCoroutine(ReengageCueRoutine(target, position, engageMode)); } } else { CompleteAttackReveal(target, position, engageMode, wasReengagement: false); } } private IEnumerator ReengageCueRoutine(PlayerControllerB target, Vector3 position, AttackEngageMode engageMode) { //IL_0015: 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) StopSearchIfNeeded(); TeleportFacing(position, GetPlayerFocusPoint(target)); StartCamoPreviewServer(0.72f); PlayDirectionalCamoCueServer(0.58f); yield return (object)new WaitForSeconds(0.72f); if (!IsValidTarget(target) || base.currentBehaviourStateIndex != 8) { _reengageCueRoutine = null; if (!IsValidTarget(target)) { ResolvePostTargetDown(); } } else { Vector3 position2 = ((Component)this).transform.position; _reengageCueRoutine = null; CompleteAttackReveal(target, position2, engageMode, wasReengagement: true); } } private void CompleteAttackReveal(PlayerControllerB target, Vector3 position, AttackEngageMode engageMode, bool wasReengagement) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) StopSearchIfNeeded(); TeleportFacing(position, GetPlayerFocusPoint(target)); _lastAttackRevealPosition = ((Component)this).transform.position; _hasLastAttackRevealPosition = true; _lastKnownAttackTargetPosition = ((Component)target).transform.position; ResetAttackMovementRecovery(target); _attackEngageMode = engageMode; RevealServer(DecloakFlickerSeconds); PlayDirectionalCamoCueServer(wasReengagement ? 0.92f : 0.82f); if ((Object)(object)decloakClip != (Object)null && CanSendRpc) { PlayOneShotClientRpc(2, 1f); } _attackMovementReadyAt = Mathf.Max(_presentationReadyAt + 0.12f, Time.time + 0.9f); _pursuitSpotlightProfileApplied = false; _nextAttackTime = Mathf.Max(Time.time + 0.6f, _attackMovementReadyAt + 0.45f); _lostSightTimer = 0f; if (engageMode == AttackEngageMode.RunImmediately) { EnterPhase(7); } else { _attackAdvanceAnimation = ((engageMode == AttackEngageMode.WalkThenRun) ? ChooseAttackWalkAnimation() : 11); _attackAdvanceEndTime = _attackMovementReadyAt + GetAttackAdvanceSeconds(engageMode); EnterPhase(6); } StopAgent(); PlayAnimationServer(18, 0.08f, 0.16f); if (DebugLogs) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[DreadweaverAI] Attack reveal at {((Component)this).transform.position} ({engageMode}, reengage={wasReengagement})."); } } } private AttackEngageMode ChooseRepositionAttackEngageMode() { float value = Random.value; if (_rapidReengagementCount < 2) { if (!(value < 0.5f)) { return AttackEngageMode.CrawlThenRun; } return AttackEngageMode.WalkThenRun; } if (value < 0.4f) { return AttackEngageMode.WalkThenRun; } if (value < 0.6f) { return AttackEngageMode.RunImmediately; } return AttackEngageMode.CrawlThenRun; } private int ChooseAttackWalkAnimation() { if (!(Random.value < 0.5f)) { return 5; } return 4; } private float GetAttackAdvanceSeconds(AttackEngageMode engageMode) { if (engageMode != AttackEngageMode.WalkThenRun) { return Mathf.Max(0.8f, CrawlAdvanceSeconds); } return 3f; } private float GetAttackAdvanceSpeed() { if (_attackEngageMode != AttackEngageMode.WalkThenRun) { return CrawlSpeed; } return AttackWalkSpeed; } private void TickCrawlAdvance(float deltaTime) { //IL_004c: 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_00a1: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = ResolveTargetById(_targetClientId); if (!IsValidTarget(val)) { if (_resolvePostTargetDownAfterSwing && _isAttackAnimating) { StopAgent(); } else { ResolvePostTargetDown(); } return; } base.targetPlayer = val; if (_isAttackAnimating) { StopAgent(); return; } FacePosition(GetPlayerFocusPoint(val), TurnSpeed * deltaTime); if (Time.time < _attackMovementReadyAt) { StopAgent(); return; } ConfigureAgent(GetAttackAdvanceSpeed()); ((EnemyAI)this).SetMovingTowardsTargetPlayer(val); if (!TickAttackMovementRecovery(val, deltaTime)) { if (Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) <= AttackRange && Time.time >= _nextAttackTime) { BeginAttackSwing(val); } else if (Time.time >= _attackAdvanceEndTime) { EnterPhase(7); ConfigureAgent(AttackSpeed); PlayAnimationServer(10, 0.14f, 0f); } } } private void TickPursuit(float deltaTime) { //IL_004c: 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_00cc: 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) PlayerControllerB val = ResolveTargetById(_targetClientId); if (!IsValidTarget(val)) { if (_resolvePostTargetDownAfterSwing && _isAttackAnimating) { StopAgent(); } else { ResolvePostTargetDown(); } return; } base.targetPlayer = val; if (_isAttackAnimating) { StopAgent(); return; } FacePosition(GetPlayerFocusPoint(val), TurnSpeed * deltaTime); if (Time.time < _attackMovementReadyAt) { StopAgent(); return; } if (!_pursuitSpotlightProfileApplied) { _pursuitSpotlightProfileApplied = true; RefreshCreatureSpotlightServer(); } ConfigureAgent(AttackSpeed); ((EnemyAI)this).SetMovingTowardsTargetPlayer(val); if (!TickAttackMovementRecovery(val, deltaTime)) { float num = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position); if ((num <= CreatureSightRange && HasClearLineOfSight(GetCreatureFocusPoint(), GetPlayerFocusPoint(val), ((Component)val).transform)) || num <= AttackRange * 2.8f) { _lostSightTimer = 0f; } else { _lostSightTimer += deltaTime; } if (num > AttackLoseDistance || _lostSightTimer >= AttackLostSightGraceSeconds) { BeginPursuitReposition("target escaped"); } else if (num <= AttackRange && Time.time >= _nextAttackTime) { BeginAttackSwing(val); } } } private void BeginPursuitReposition(string reason) { //IL_0098: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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) if (_rapidReengagementCount >= 3) { RestartStalkCycle("target survived the reengagement chain"); return; } _rapidReengagementCount++; StopManagedRoutines(); StopAgent(); VanishServer(playCue: true); EnterPhase(8); float num = (float)Mathf.Max(0, _rapidReengagementCount - 1) * 1.25f; _nextActionTime = Time.time + Random.Range(PursuitRepositionCooldownMin, PursuitRepositionCooldownMax) + num; _attackStuckTimer = 0f; _nextAttackPathRepairTime = Time.time + 1.4f; Vector3 start = ((_lastKnownAttackTargetPosition == Vector3.zero) ? ((Component)this).transform.position : _lastKnownAttackTargetPosition); StartAttackRecoverySearch(start); if (DebugLogs) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[DreadweaverAI] Pursuit reposition: " + reason + ".")); } } } private void TickAttackVanishReposition() { //IL_003a: 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_007d: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = ResolveTargetById(_targetClientId); if (!IsValidTarget(val)) { ResolvePostTargetDown(); } else { if (_reengageCueRoutine != null) { return; } if (Time.time < _nextActionTime) { MaintainAttackRecoverySearch(((Component)val).transform.position); return; } _nextActionTime = Time.time + 0.7f; bool relaxed = Time.time > _repositionRelaxAt; if (!TryFindAttackRevealPosition(val, relaxed, PursuitRepositionMinDistance, out var position)) { MaintainAttackRecoverySearch(((Component)val).transform.position); if (Time.time - _phaseEnteredAt > 12f) { RestartStalkCycle("no attack reposition found"); } } else { BeginAttackReveal(val, position, ChooseRepositionAttackEngageMode()); } } } private void BeginAttackSwing(PlayerControllerB target) { if (_attackRoutine != null) { CancelAttackSwing(0f); } AttackProfile attackProfile = ChooseAttackProfile(); if (CanStrikeTarget(target, attackProfile, 0.75f)) { base.targetPlayer = target; _activeAttackProfile = attackProfile; _attackRoutine = ((MonoBehaviour)this).StartCoroutine(AttackSwingRoutine()); } } private void CancelAttackSwing(float recoverySeconds) { if (_attackRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_attackRoutine); _attackRoutine = null; } if (_isAttackAnimating) { _nextAttackTime = Mathf.Max(_nextAttackTime, Time.time + Mathf.Max(0f, recoverySeconds)); } _isAttackAnimating = false; _resolvePostTargetDownAfterSwing = false; } private void TryPlayInitialAttackJumpscareServer() { if (!((NetworkBehaviour)this).IsServer || _hasPlayedInitialAttackJumpscare) { return; } AudioClip val = (((Object)(object)initialAttackClip != (Object)null) ? initialAttackClip : attackClip); if ((Object)(object)val == (Object)null) { return; } _hasPlayedInitialAttackJumpscare = true; if (CanSendRpc) { PlayOneShotClientRpc(3, 1f); return; } AudioSource val2 = (((Object)(object)base.creatureVoice != (Object)null) ? base.creatureVoice : base.creatureSFX); if ((Object)(object)val2 != (Object)null) { val2.PlayOneShot(val, 1f); } } private IEnumerator AttackSwingRoutine() { int animationCode = _activeAttackProfile.AnimationCode; float totalDuration = GetAttackAnimationDuration(_activeAttackProfile); float strikeDelay = GetAttackStrikeDelay(_activeAttackProfile, totalDuration); _isAttackAnimating = true; _nextAttackTime = Time.time + totalDuration; StopAgent(); if ((Object)(object)base.targetPlayer != (Object)null) { FacePosition(GetPlayerFocusPoint(base.targetPlayer), TurnSpeed); } PlayAnimationServer(animationCode, 0.06f, 0f); TryPlayInitialAttackJumpscareServer(); yield return (object)new WaitForSeconds(strikeDelay); if (_isAttackAnimating && !base.isEnemyDead && base.currentBehaviourStateIndex != 9) { ApplyAttackDamageIfValid(); } yield return (object)new WaitForSeconds(Mathf.Max(0.1f, totalDuration - strikeDelay)); bool resolvePostTargetDownAfterSwing = _resolvePostTargetDownAfterSwing; _resolvePostTargetDownAfterSwing = false; _isAttackAnimating = false; _attackRoutine = null; if (resolvePostTargetDownAfterSwing) { ResolvePostTargetDown(); } else if (!base.isEnemyDead && base.currentBehaviourStateIndex == 7) { ConfigureAgent(AttackSpeed); PlayAnimationServer(10, 0.12f, 0f); } } private static AttackProfile ChooseAttackProfile() { float num = 0f; for (int i = 0; i < AttackProfiles.Length; i++) { num += Mathf.Max(0f, AttackProfiles[i].SelectionWeight); } float num2 = Random.value * Mathf.Max(0.01f, num); for (int j = 0; j < AttackProfiles.Length; j++) { num2 -= Mathf.Max(0f, AttackProfiles[j].SelectionWeight); if (num2 <= 0f) { return AttackProfiles[j]; } } return AttackProfiles[AttackProfiles.Length - 1]; } private float GetAttackAnimationDuration(AttackProfile profile) { return Mathf.Max(AttackCooldown, profile.RecoverySeconds); } private float GetAttackAnimationDuration(int animationCode) { for (int i = 0; i < AttackProfiles.Length; i++) { if (AttackProfiles[i].AnimationCode == animationCode) { return GetAttackAnimationDuration(AttackProfiles[i]); } } return AttackCooldown; } private float GetAttackStrikeDelay(AttackProfile profile, float totalDuration) { float num = AttackDamageDelay / 0.48f; return Mathf.Clamp(profile.StrikeTimeSeconds * num, 0.05f, Mathf.Max(0.05f, totalDuration - 0.15f)); } private void ApplyAttackDamageIfValid() { //IL_003a: 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_004f: 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_0082: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = ResolveTargetById(_targetClientId); if (((NetworkBehaviour)this).IsServer && IsValidTarget(val) && CanStrikeTarget(val, _activeAttackProfile, 0.45f)) { Vector3 force = ((Component)val).transform.position - ((Component)this).transform.position; force.y = 0f; if (((Vector3)(ref force)).sqrMagnitude < 0.01f) { force = ((Component)this).transform.forward; } force = ((Vector3)(ref force)).normalized * 18f + Vector3.up * 2f; ApplyAttackDamageClientRpc(val.actualClientId, AttackDamage, force); } } [ClientRpc] private void ApplyAttackDamageClientRpc(ulong targetClientId, int damage, Vector3 force) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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(2181752049u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, targetClientId); BytePacker.WriteValueBitPacked(val, damage); ((FastBufferWriter)(ref val)).WriteValueSafe(ref force); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2181752049u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; PlayerControllerB val3 = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if (!((Object)(object)val3 == (Object)null) && !val3.isPlayerDead && (val3.actualClientId == targetClientId || val3.playerClientId == targetClientId)) { val3.DamagePlayer(damage, true, true, (CauseOfDeath)6, 0, false, force); if (val3.isPlayerDead || val3.health <= 0) { ReportTargetDownServerRpc(targetClientId); } } } [ServerRpc(RequireOwnership = false)] private void ReportTargetDownServerRpc(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.IsClient || networkManager.IsHost)) { ServerRpcParams val2 = default(ServerRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2785260190u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, targetClientId); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 2785260190u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (((NetworkBehaviour)this).IsServer && !base.isEnemyDead) { _lastKilledTargetClientId = targetClientId; if (_isAttackAnimating) { _resolvePostTargetDownAfterSwing = true; } else { ResolvePostTargetDown(); } } } private bool CanStrikeTarget(PlayerControllerB target, AttackProfile profile, float rangePadding) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)null) { return false; } Vector3 val = (((Object)(object)attackOrigin != (Object)null) ? attackOrigin.position : (((Component)this).transform.position + Vector3.up * GetSightOriginHeight() * 0.65f + ((Component)this).transform.forward * GetHorizontalWorldScale() * 0.95f)); Vector3 val2 = ((Component)target).transform.position + Vector3.up * 0.9f; float num = AttackRange * profile.RangeMultiplier + Mathf.Max(0f, rangePadding); if (Vector3.Distance(((Component)this).transform.position, ((Component)target).transform.position) > num) { return false; } Vector3 val3 = val2 - val; if (((Vector3)(ref val3)).magnitude > num) { return false; } Vector3 val4 = val3; val4.y = 0f; if (((Vector3)(ref val4)).sqrMagnitude > 0.001f) { float num2 = Mathf.Cos(Mathf.Clamp(AttackHitHalfAngle * profile.ArcMultiplier, 20f, 85f) * (MathF.PI / 180f)); if (Vector3.Dot(((Component)this).transform.forward, ((Vector3)(ref val4)).normalized) < num2) { return false; } } return HasClearLineOfSight(val, val2, ((Component)target).transform); } private void ResolvePostTargetDown() { PlayerControllerB val = ResolveTargetById(_lastKilledTargetClientId); PlayerControllerB val2 = (((Object)(object)val != (Object)null) ? FindChainTargetNear(val) : null); _lastKilledTargetClientId = ulong.MaxValue; if ((Object)(object)val2 != (Object)null) { SetFixationTarget(val2, "chain after kill"); if (!_logicalVisible) { RevealServer(Mathf.Max(0.05f, DecloakFlickerSeconds * 0.5f)); } _nextAttackTime = Time.time + 0.8f; _lostSightTimer = 0f; EnterPhase(7); ConfigureAgent(AttackSpeed); PlayAnimationServer(10, 0.12f, 0f); } else { RestartStalkCycle("no chain target"); } } private void RestartStalkCycle(string reason) { StopManagedRoutines(); StopSearchIfNeeded(); StopAgent(); VanishServer(_logicalVisible); _stage = SightingStage.Long; _rapidReengagementCount = 0; _attackMovementReadyAt = 0f; SetFixationTarget(null, reason); EnterPhase(0); _nextActionTime = Time.time + Random.Range(2.5f, 5f); if (DebugLogs) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[DreadweaverAI] Restarting stalk cycle: " + reason + ".")); } } } private void EnterPhase(int state) { SetStateServer(state); _phaseEnteredAt = Time.time; _nextActionTime = 0f; switch (state) { case 1: _hasPendingWatchPosition = false; _isEndingSighting = false; break; case 2: _sightingFirstSeenAt = -1f; _sightingSeenDistance = 0f; _losLostSince = -1f; _isEndingSighting = false; break; case 8: _repositionRelaxAt = Time.time + 8f; break; } } private IEnumerator HitStaggerRoutine() { _isHitStaggering = true; int phaseBefore = base.currentBehaviourStateIndex; SetStateServer(9); StopAgent(); PlayAnimationServer((Random.value < 0.35f) ? 41 : 40, 0.05f, 0f); if ((Object)(object)hitClip != (Object)null && CanSendRpc) { PlayOneShotClientRpc(4, 0.85f); } yield return (object)new WaitForSeconds(0.78f); _damageStunUntil = 0f; ClearDamageStunFreeze(); _isHitStaggering = false; if (base.isEnemyDead) { yield break; } bool num = phaseBefore == 5 || phaseBefore == 6 || phaseBefore == 7 || phaseBefore == 8; PlayerControllerB player = ResolveTargetById(_lastHitByClientId); _lastHitByClientId = ulong.MaxValue; PlayerControllerB player2 = ResolveTargetById(_targetClientId); if (num) { if (IsValidTarget(player2)) { if (_logicalVisible) { EnterPhase(7); ConfigureAgent(AttackSpeed); PlayAnimationServer(10, 0.12f, 0f); } else { EnterPhase(5); _nextActionTime = Time.time + 0.8f; } } else { ResolvePostTargetDown(); } } else { if (IsValidTarget(player)) { SetFixationTarget(player, "retaliating against attacker"); } if (IsValidTarget(ResolveTargetById(_targetClientId))) { VanishServer(playCue: true); EnterPhase(5); } else { RestartStalkCycle("hit with no valid target"); } } } private void DieFromDamage() { if (base.isEnemyDead) { return; } StopManagedRoutines(); StopSearchIfNeeded(); StopAgent(); _logicalVisible = true; _visSeq++; SetStateServer(10); if (((NetworkBehaviour)this).IsServer) { ((EnemyAI)this).KillEnemy(false); if ((Object)(object)((NetworkBehaviour)this).NetworkObject != (Object)null && ((NetworkBehaviour)this).NetworkObject.IsSpawned) { ((EnemyAI)this).KillEnemyClientRpc(false); } } else if (((NetworkBehaviour)this).IsOwner) { ((EnemyAI)this).KillEnemyOnOwnerClient(false); } } private PlayerControllerB RequireStalkTarget() { PlayerControllerB val = ResolveTargetById(_targetClientId); if (!IsValidTarget(val)) { return null; } base.targetPlayer = val; return val; } private PlayerControllerB ChooseFixationTarget() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null) { return null; } PlayerControllerB result = null; float num = float.NegativeInfinity; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (IsValidTarget(val)) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position); int num3 = CountLivingAlliesNear(val, 11f); float num4 = Random.Range(0f, 3f); num4 += ((num3 == 0) ? 8f : ((float)(-num3) * 2f)); num4 += Mathf.Clamp(45f - num2, -10f, 16f) * 0.1f; if (num4 > num) { num = num4; result = val; } } } return result; } private void SetFixationTarget(PlayerControllerB player, string reason) { base.targetPlayer = player; _targetClientId = (((Object)(object)player != (Object)null) ? player.actualClientId : ulong.MaxValue); _lostSightTimer = 0f; if ((Object)(object)player != (Object)null) { ScheduleInitialStalkingScares(); } else { ClearStalkingScareTimers(); } if (((NetworkBehaviour)this).IsServer && CanSendRpc) { _networkTargetClientId.Value = _targetClientId; SyncTargetClientRpc(_targetClientId); } if (DebugLogs) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[DreadweaverAI] Target=" + ((_targetClientId == ulong.MaxValue) ? "" : _targetClientId.ToString()) + "; " + reason + ".")); } } } private PlayerControllerB ResolveTargetById(ulong clientId) { if (clientId == ulong.MaxValue || (Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null) { return null; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && (val.actualClientId == clientId || val.playerClientId == clientId)) { return val; } } return null; } private bool IsValidTarget(PlayerControllerB player) { if ((Object)(object)player != (Object)null) { return ((EnemyAI)this).PlayerIsTargetable(player, true, false, true); } return false; } private PlayerControllerB FindChainTargetNear(PlayerControllerB killedTarget) { //IL_006d: 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_007d: 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) if ((Object)(object)killedTarget == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null) { return null; } PlayerControllerB result = null; float num = ChainAttackRadius * ChainAttackRadius; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)killedTarget) && IsValidTarget(val)) { Vector3 val2 = ((Component)val).transform.position - ((Component)killedTarget).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val; } } } return result; } private void GetStageParameters(SightingStage stage, out float min, out float max, out float hold, out float panic) { switch (stage) { case SightingStage.Long: min = 30f; max = 50f; hold = 1.35f; panic = Mathf.Max(12f, min * 0.5f); break; case SightingStage.Medium: min = 15f; max = 30f; hold = 1.15f; panic = Mathf.Max(8f, min * 0.55f); break; default: min = 4f; max = 8f; hold = 1f; panic = 2.4f; break; } } private bool TryFindSightingPosition(PlayerControllerB target, SightingStage stage, out Vector3 position) { switch (stage) { case SightingStage.Long: if (TryFindHallwayEndPosition(target, stage, out position)) { return true; } if (Time.time - _phaseEnteredAt >= 8f && TryFindRelaxedLongLitPosition(target, out position)) { return true; } return false; case SightingStage.Medium: if (TryFindCornerApproachPosition(target, stage, out position)) { return true; } if (TryFindHallwayEndPosition(target, stage, out position)) { return true; } if (TryFindDeadEndBehindPosition(target, stage, out position)) { return true; } return false; default: if (TryFindCornerApproachPosition(target, stage, out position)) { return true; } if (TryFindDeadEndBehindPosition(target, stage, out position)) { return true; } if (TryFindShortCornerPosition(target, out position)) { _pendingPresentation = SightingPresentation.CornerReveal; return true; } return TryFindHallwayEndPosition(target, stage, out position); } } private bool TryFindRelaxedLongLitPosition(PlayerControllerB target, out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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_0033: 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_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) //IL_0052: 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_0090: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; Vector3 position2 = ((Component)target).transform.position; Vector3 playerFocusPoint = GetPlayerFocusPoint(target); Vector3 flatCameraForward = GetFlatCameraForward(target); float bestScore = float.NegativeInfinity; Vector3 best = Vector3.zero; List list = ScorePoweredLightCandidates(position2, 43f); for (int i = 0; i < list.Count; i++) { ScoreLongMediumCandidate(list[i], target, position2, playerFocusPoint, flatCameraForward, 18f, 35f, 10f, ref bestScore, ref best); } if (float.IsNegativeInfinity(bestScore)) { return false; } _pendingPresentation = SightingPresentation.HallwayEnd; position = best; return true; } private bool TryFindHallwayEndPosition(PlayerControllerB target, SightingStage stage, out Vector3 position) { if (TryFindLongMediumPosition(target, stage, out position)) { _pendingPresentation = SightingPresentation.HallwayEnd; return true; } return false; } private bool TryFindCornerApproachPosition(PlayerControllerB target, SightingStage stage, out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0082: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_009d: 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_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_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_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; RepairFacilityAINodes(); GetStageParameters(stage, out var min, out var max, out var _, out var _); float num = ((stage == SightingStage.Short) ? Mathf.Max(3.5f, min * 0.75f) : Mathf.Max(6f, min * 0.65f)); float num2 = ((stage == SightingStage.Short) ? Mathf.Max(max + 4f, 11f) : Mathf.Max(max * 0.75f, num + 6f)); Vector3 position2 = ((Component)target).transform.position; Vector3 playerFocusPoint = GetPlayerFocusPoint(target); Vector3 flatCameraForward = GetFlatCameraForward(target); float bestScore = float.NegativeInfinity; Vector3 best = Vector3.zero; GameObject[] allAINodes = base.allAINodes; if (allAINodes != null && allAINodes.Length != 0) { int num3 = Random.Range(0, allAINodes.Length); for (int i = 0; i < allAINodes.Length; i++) { GameObject val = allAINodes[(num3 + i) % allAINodes.Length]; if (!((Object)(object)val == (Object)null)) { Vector3 val2 = val.transform.position - position2; if (!(((Vector3)(ref val2)).sqrMagnitude > (num2 + 12f) * (num2 + 12f)) && TrySampleNavPosition(val.transform.position, 4.5f, out var position3)) { ScoreCornerApproachCandidate(position3, target, position2, playerFocusPoint, flatCameraForward, num, num2, ref bestScore, ref best); } } } } List list = ScorePoweredLightCandidates(position2, num2 + 8f); for (int j = 0; j < list.Count; j++) { ScoreCornerApproachCandidate(list[j], target, position2, playerFocusPoint, flatCameraForward, num, num2, ref bestScore, ref best); } for (int k = 0; k < 38; k++) { if (TryRingSample(position2, num, num2, out var position4)) { ScoreCornerApproachCandidate(position4, target, position2, playerFocusPoint, flatCameraForward, num, num2, ref bestScore, ref best); } } if (float.IsNegativeInfinity(bestScore)) { return false; } _pendingPresentation = SightingPresentation.CornerReveal; position = best; return true; } private void ScoreCornerApproachCandidate(Vector3 candidate, PlayerControllerB target, Vector3 targetPosition, Vector3 targetFocus, Vector3 cameraForward, float min, float max, ref float bestScore, ref Vector3 best) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_004f: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Distance(candidate, targetPosition); if (num < min || num > max || (_hasLastVanishPosition && Vector3.Distance(candidate, _lastVanishPosition) < 6f) || TooCloseToAnyPlayer(candidate, 3f) || !HasShortCompletePath(candidate, targetPosition, 23f)) { return; } Vector3 candidateSightPoint = GetCandidateSightPoint(candidate); bool flag = HasClearLineOfSight(candidateSightPoint, targetFocus, ((Component)target).transform); bool flag2 = PlayerWouldSeePosition(target, candidateSightPoint, 12f); bool flag3 = PlayerWouldSeePosition(target, candidateSightPoint, 35f); if ((flag || !(num > max * 0.82f)) && !AnyOtherPlayerWouldSeePosition(candidateSightPoint, target, 35f)) { Vector3 val = candidate - targetPosition; val.y = 0f; float num2 = ((((Vector3)(ref val)).sqrMagnitude > 0.001f) ? Vector3.Dot(cameraForward, ((Vector3)(ref val)).normalized) : 0f); float num3 = Mathf.Lerp(min, max, 0.45f); float num4 = (0f - Mathf.Abs(num - num3)) * 0.55f; num4 += num2 * 2.75f; num4 += (flag ? 1.5f : 4.5f); num4 += (flag3 ? 2.75f : 0f); num4 += (flag2 ? (-1.5f) : 0f); num4 += GetPoweredLightAffinityScore(candidate) * 0.85f; num4 += Random.Range(0f, 2f); if (num4 > bestScore) { bestScore = num4; best = candidate; } } } private bool TryFindDeadEndBehindPosition(PlayerControllerB target, SightingStage stage, out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; RepairFacilityAINodes(); Vector3 position2 = ((Component)target).transform.position; Vector3 playerFocusPoint = GetPlayerFocusPoint(target); Vector3 flatCameraForward = GetFlatCameraForward(target); float num = ((stage == SightingStage.Short) ? 4.75f : 6.5f); float num2 = ((stage == SightingStage.Long) ? 16f : 12.5f); float bestScore = float.NegativeInfinity; Vector3 best = Vector3.zero; for (int i = 0; i < 12; i++) { float num3 = Random.Range(num, num2); Vector3 val = Quaternion.AngleAxis(Random.Range(-35f, 35f), Vector3.up) * -flatCameraForward; if (TrySampleNavPosition(position2 + val * num3, 4f, out var position3)) { ScoreDeadEndBehindCandidate(position3, target, position2, playerFocusPoint, flatCameraForward, num, num2, ref bestScore, ref best); } } GameObject[] allAINodes = base.allAINodes; if (allAINodes != null && allAINodes.Length != 0) { int num4 = Random.Range(0, allAINodes.Length); for (int j = 0; j < allAINodes.Length; j++) { GameObject val2 = allAINodes[(num4 + j) % allAINodes.Length]; if (!((Object)(object)val2 == (Object)null) && TrySampleNavPosition(val2.transform.position, 4f, out var position4)) { ScoreDeadEndBehindCandidate(position4, target, position2, playerFocusPoint, flatCameraForward, num, num2, ref bestScore, ref best); } } } List list = ScorePoweredLightCandidates(position2, num2 + 8f); for (int k = 0; k < list.Count; k++) { ScoreDeadEndBehindCandidate(list[k], target, position2, playerFocusPoint, flatCameraForward, num, num2, ref bestScore, ref best); } if (float.IsNegativeInfinity(bestScore)) { return false; } _pendingPresentation = SightingPresentation.DeadEndBehind; position = best; return true; } private void ScoreDeadEndBehindCandidate(Vector3 candidate, PlayerControllerB target, Vector3 targetPosition, Vector3 targetFocus, Vector3 cameraForward, float min, float max, ref float bestScore, ref Vector3 best) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00e1: 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_0113: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Distance(candidate, targetPosition); if (num < min || num > max || (_hasLastVanishPosition && Vector3.Distance(candidate, _lastVanishPosition) < 6f) || TooCloseToAnyPlayer(candidate, 3.2f) || !HasShortCompletePath(candidate, targetPosition, 26f)) { return; } Vector3 val = candidate - targetPosition; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude < 0.001f) { return; } float num2 = Vector3.Dot(cameraForward, ((Vector3)(ref val)).normalized); if (num2 > -0.25f) { return; } Vector3 candidateSightPoint = GetCandidateSightPoint(candidate); if (HasClearLineOfSight(candidateSightPoint, targetFocus, ((Component)target).transform) && !AnyOtherPlayerWouldSeePosition(candidateSightPoint, target, 35f)) { float num3 = (0f - Mathf.Abs(num - Mathf.Lerp(min, max, 0.45f))) * 0.45f; num3 += (0f - num2) * 4f; num3 += GetPoweredLightAffinityScore(candidate) * 0.7f; num3 += Random.Range(0f, 1.75f); if (num3 > bestScore) { bestScore = num3; best = candidate; } } } private bool TryFindLongMediumPosition(PlayerControllerB target, SightingStage stage, out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_007c: 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_0092: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; RepairFacilityAINodes(); GetStageParameters(stage, out var min, out var max, out var _, out var panic); int num; float num2; if (stage == SightingStage.Medium) { num = ((Time.time - _phaseEnteredAt >= 5f) ? 1 : 0); if (num != 0) { num2 = Mathf.Max(10f, min * 0.65f); goto IL_0054; } } else { num = 0; } num2 = min; goto IL_0054; IL_0054: float num3 = num2; float num4 = ((num != 0) ? Mathf.Max(max, num3 + 12f) : max); Vector3 position2 = ((Component)target).transform.position; Vector3 playerFocusPoint = GetPlayerFocusPoint(target); Vector3 cameraForward = (((Object)(object)target.gameplayCamera != (Object)null) ? ((Component)target.gameplayCamera).transform.forward : ((Component)target).transform.forward); cameraForward.y = 0f; cameraForward = ((((Vector3)(ref cameraForward)).sqrMagnitude > 0.001f) ? ((Vector3)(ref cameraForward)).normalized : Vector3.forward); float bestScore = float.NegativeInfinity; Vector3 best = Vector3.zero; GameObject[] allAINodes = base.allAINodes; if (allAINodes != null && allAINodes.Length != 0) { int num5 = Random.Range(0, allAINodes.Length); for (int i = 0; i < allAINodes.Length; i++) { GameObject val = allAINodes[(num5 + i) % allAINodes.Length]; if (!((Object)(object)val == (Object)null) && TrySampleNavPosition(val.transform.position, 4f, out var position3)) { ScoreLongMediumCandidate(position3, target, position2, playerFocusPoint, cameraForward, num3, num4, panic, ref bestScore, ref best); } } } List list = ScorePoweredLightCandidates(position2, num4 + 8f); for (int j = 0; j < list.Count; j++) { ScoreLongMediumCandidate(list[j], target, position2, playerFocusPoint, cameraForward, num3, num4, panic, ref bestScore, ref best); } for (int k = 0; k < 42; k++) { if (TryRingSample(position2, num3, num4, out var position4)) { ScoreLongMediumCandidate(position4, target, position2, playerFocusPoint, cameraForward, num3, num4, panic, ref bestScore, ref best); } } if (float.IsNegativeInfinity(bestScore)) { return false; } position = best; return true; } private void ScoreLongMediumCandidate(Vector3 candidate, PlayerControllerB target, Vector3 targetPosition, Vector3 targetFocus, Vector3 cameraForward, float min, float max, float panic, ref float bestScore, ref Vector3 best) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_0082: 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_00a8: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Distance(candidate, targetPosition); if (num < min || num > max || (_hasLastVanishPosition && Vector3.Distance(candidate, _lastVanishPosition) < 8f) || TooCloseToAnyPlayer(candidate, panic + 2f) || TooCloseToNonTargetPlayer(candidate, target, 12f)) { return; } Vector3 candidateSightPoint = GetCandidateSightPoint(candidate); if (HasClearLineOfSight(candidateSightPoint, targetFocus, ((Component)target).transform) && !AnyOtherPlayerWouldSeePosition(candidateSightPoint, target, 35f)) { Vector3 val = candidate - targetPosition; val.y = 0f; float num2 = ((((Vector3)(ref val)).sqrMagnitude > 0.001f) ? Vector3.Dot(cameraForward, ((Vector3)(ref val)).normalized) : 0f); bool flag = PlayerWouldSeePosition(target, candidateSightPoint, SpotHalfAngle); bool flag2 = PlayerWouldSeePosition(target, candidateSightPoint, 35f); bool flag3 = PlayerWouldSeePosition(target, candidateSightPoint, 12f); float num3 = Mathf.Lerp(min, max, 0.55f); float num4 = (0f - Mathf.Abs(num - num3)) * 0.5f; num4 += num2 * 4f; num4 += (flag ? 7f : (-1.25f)); num4 += (flag2 ? 3f : 0.5f); num4 += (flag3 ? (-2.5f) : 0f); num4 += GetPoweredLightAffinityScore(candidate); num4 += Random.Range(0f, 2f); if (num4 > bestScore) { bestScore = num4; best = candidate; } } } private bool TryFindShortCornerPosition(PlayerControllerB target, out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00ce: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; RepairFacilityAINodes(); GetStageParameters(SightingStage.Short, out var min, out var max, out var _, out var _); Vector3 position2 = ((Component)target).transform.position; Vector3 playerFocusPoint = GetPlayerFocusPoint(target); float bestScore = float.NegativeInfinity; Vector3 best = Vector3.zero; GameObject[] allAINodes = base.allAINodes; if (allAINodes != null && allAINodes.Length != 0) { int num = Random.Range(0, allAINodes.Length); for (int i = 0; i < allAINodes.Length; i++) { GameObject val = allAINodes[(num + i) % allAINodes.Length]; if (!((Object)(object)val == (Object)null)) { Vector3 val2 = val.transform.position - position2; if (!(((Vector3)(ref val2)).sqrMagnitude > (max + 6f) * (max + 6f)) && TrySampleNavPosition(val.transform.position, 4f, out var position3)) { ScoreShortCornerCandidate(position3, target, position2, playerFocusPoint, min, max, ref bestScore, ref best); } } } } List list = ScorePoweredLightCandidates(position2, max + 8f); for (int j = 0; j < list.Count; j++) { ScoreShortCornerCandidate(list[j], target, position2, playerFocusPoint, min, max, ref bestScore, ref best); } for (int k = 0; k < 24; k++) { if (TryRingSample(position2, min, max, out var position4)) { ScoreShortCornerCandidate(position4, target, position2, playerFocusPoint, min, max, ref bestScore, ref best); } } if (float.IsNegativeInfinity(bestScore)) { return false; } position = best; return true; } private void ScoreShortCornerCandidate(Vector3 candidate, PlayerControllerB target, Vector3 targetPosition, Vector3 targetFocus, float min, float max, ref float bestScore, ref Vector3 best) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_002d: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_00ac: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Distance(candidate, targetPosition); if (num < Mathf.Max(2.5f, min) || num > max || TooCloseToAnyPlayer(candidate, 2.6f)) { return; } Vector3 candidateSightPoint = GetCandidateSightPoint(candidate); if (!HasClearLineOfSight(targetFocus, candidateSightPoint, ((Component)target).transform) && !AnyOtherPlayerWouldSeePosition(candidateSightPoint, target, 35f) && HasShortCompletePath(candidate, targetPosition, 16f)) { float num2 = 0f - Mathf.Abs(num - Mathf.Lerp(min, max, 0.45f)); num2 += GetPoweredLightAffinityScore(candidate) * 0.6f; num2 += Random.Range(0f, 1.5f); if (num2 > bestScore) { bestScore = num2; best = candidate; } } } private bool TryFindAttackRevealPosition(PlayerControllerB target, bool relaxed, float minDistanceFromPrevious, out Vector3 position) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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) //IL_00dd: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; RepairFacilityAINodes(); float attackRevealMin = AttackRevealMin; float attackRevealMax = AttackRevealMax; Vector3 position2 = ((Component)target).transform.position; Vector3 cameraForward = (((Object)(object)target.gameplayCamera != (Object)null) ? ((Component)target.gameplayCamera).transform.forward : ((Component)target).transform.forward); cameraForward.y = 0f; cameraForward = ((((Vector3)(ref cameraForward)).sqrMagnitude > 0.001f) ? ((Vector3)(ref cameraForward)).normalized : Vector3.forward); float bestScore = float.NegativeInfinity; Vector3 best = Vector3.zero; GameObject[] allAINodes = base.allAINodes; if (allAINodes != null && allAINodes.Length != 0) { int num = Random.Range(0, allAINodes.Length); for (int i = 0; i < allAINodes.Length; i++) { GameObject val = allAINodes[(num + i) % allAINodes.Length]; if (!((Object)(object)val == (Object)null)) { Vector3 val2 = val.transform.position - position2; if (!(((Vector3)(ref val2)).sqrMagnitude > (attackRevealMax + 8f) * (attackRevealMax + 8f)) && TrySampleNavPosition(val.transform.position, 4f, out var position3)) { ScoreAttackRevealCandidate(position3, position2, cameraForward, attackRevealMin, attackRevealMax, relaxed, minDistanceFromPrevious, ref bestScore, ref best); } } } } for (int j = 0; j < 24; j++) { if (TryRingSample(position2, attackRevealMin, attackRevealMax, out var position4)) { ScoreAttackRevealCandidate(position4, position2, cameraForward, attackRevealMin, attackRevealMax, relaxed, minDistanceFromPrevious, ref bestScore, ref best); } } if (float.IsNegativeInfinity(bestScore)) { return false; } position = best; return true; } private void ScoreAttackRevealCandidate(Vector3 candidate, Vector3 targetPosition, Vector3 cameraForward, float min, float max, bool relaxed, float minDistanceFromPrevious, ref float bestScore, ref Vector3 best) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_0045: 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_0024: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Distance(candidate, targetPosition); if (num < min || num > max || (minDistanceFromPrevious > 0f && _hasLastAttackRevealPosition && Vector3.Distance(candidate, _lastAttackRevealPosition) < minDistanceFromPrevious) || TooCloseToAnyPlayer(candidate, 4f) || !HasShortCompletePath(candidate, targetPosition, max * 2.5f)) { return; } Vector3 candidateSightPoint = GetCandidateSightPoint(candidate); bool flag = AnyPlayerWouldSeePosition(candidateSightPoint, 45f); if (!flag || relaxed) { Vector3 val = candidate - targetPosition; val.y = 0f; float num2 = (0f - ((((Vector3)(ref val)).sqrMagnitude > 0.001f) ? Vector3.Dot(cameraForward, ((Vector3)(ref val)).normalized) : 0f)) * 5f; num2 -= Mathf.Abs(num - Mathf.Lerp(min, max, 0.5f)) * 0.4f; num2 += (flag ? (-4f) : 2f); num2 += Random.Range(0f, 2f); if (num2 > bestScore) { bestScore = num2; best = candidate; } } } private bool TryRingSample(Vector3 center, float minRadius, float maxRadius, out Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0038: Unknown result type (might be due to invalid IL or missing references) Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(minRadius, maxRadius); Vector3 origin = center + new Vector3(val.x, 0f, val.y); return TrySampleNavPosition(origin, Mathf.Max(4f, maxRadius * 0.5f), out position); } private List ScorePoweredLightCandidates(Vector3 targetPosition, float searchRadius) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) List list = new List(16); RoundManager instance = RoundManager.Instance; if ((Object)(object)instance == (Object)null) { return list; } if (instance.allPoweredLights == null || instance.allPoweredLights.Count == 0) { instance.RefreshLightsList(); } if (instance.allPoweredLights == null || instance.allPoweredLights.Count == 0) { return list; } float num = searchRadius * searchRadius; int count = instance.allPoweredLights.Count; int num2 = Random.Range(0, count); for (int i = 0; i < count; i++) { Light val = instance.allPoweredLights[(num2 + i) % count]; if (!CanUsePoweredLightForSighting(val)) { continue; } Vector3 val2 = ((Component)val).transform.position - targetPosition; if (!(((Vector3)(ref val2)).sqrMagnitude > num) && TrySampleNavPosition(((Component)val).transform.position, 4.5f, out var position) && !IsDuplicatePoweredLightCandidate(list, position)) { list.Add(position); if (list.Count >= 16) { break; } } } return list; } private static bool IsDuplicatePoweredLightCandidate(List candidates, Vector3 candidate) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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) for (int i = 0; i < candidates.Count; i++) { Vector3 val = candidates[i] - candidate; if (((Vector3)(ref val)).sqrMagnitude < 1.44f) { return true; } } return false; } private float GetPoweredLightAffinityScore(Vector3 candidate) { //IL_0077: 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_007d: 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) RoundManager instance = RoundManager.Instance; if ((Object)(object)instance == (Object)null) { return 0f; } if (instance.allPoweredLights == null || instance.allPoweredLights.Count == 0) { instance.RefreshLightsList(); } if (instance.allPoweredLights == null || instance.allPoweredLights.Count == 0) { return 0f; } float num = 81f; bool flag = false; for (int i = 0; i < instance.allPoweredLights.Count; i++) { Light val = instance.allPoweredLights[i]; if (CanUsePoweredLightForSighting(val)) { Vector3 val2 = ((Component)val).transform.position - candidate; val2.y = 0f; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (!(sqrMagnitude >= num)) { num = sqrMagnitude; flag = true; } } } if (!flag) { return 0f; } float num2 = Mathf.Sqrt(num); float num3 = 1f - Mathf.Clamp01(num2 / 9f); return num3 * num3 * 4.75f; } private static bool CanUsePoweredLightForSighting(Light light) { if ((Object)(object)light != (Object)null && ((Component)light).gameObject.activeInHierarchy && ((Behaviour)light).enabled) { return light.intensity > 0.05f; } return false; } private void VanishServer(bool playCue, float? flickerOverrideSeconds = null) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) bool logicalVisible = _logicalVisible; _lastVanishPosition = ((Component)this).transform.position; _hasLastVanishPosition = true; _logicalVisible = false; _visSeq++; _presentationReadyAt = float.PositiveInfinity; StopAgent(); if (((NetworkBehaviour)this).IsServer && CanSendRpc) { _networkVisible.Value = false; _networkVisibilitySequence.Value = _visSeq; } if (playCue && logicalVisible && (Object)(object)vanishClip != (Object)null && CanSendRpc) { PlayOneShotClientRpc(1, 0.85f); } float flickerSeconds = ((playCue && logicalVisible) ? Mathf.Max(0.15f, VanishFlickerSeconds) : 0f); if (flickerOverrideSeconds.HasValue) { flickerSeconds = Mathf.Max(0f, flickerOverrideSeconds.Value); } if (CanSendRpc) { SetVisibilityClientRpc(visible: false, _visSeq, flickerSeconds); } else { ApplyVisibility(visible: false, _visSeq, 0f); } DisableCreatureSpotlightServer(); if (logicalVisible) { TryTriggerFlashlightHarassOnVanish(); } } private void TryTriggerFlashlightHarassOnVanish() { //IL_0059: 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) if (!((NetworkBehaviour)this).IsServer || !FlashlightHarassEnabled || base.isEnemyDead || !IsStalkingEnvironmentScareState(base.currentBehaviourStateIndex) || Time.time < _nextFlashlightHarassTime) { return; } PlayerControllerB val = ResolveTargetById(_targetClientId); if (IsValidTarget(val) && val.isInsideFactory && !(Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) > 16f)) { _nextFlashlightHarassTime = Time.time + 6f; int seed = Random.Range(1, int.MaxValue); if (CanSendRpc) { FlashlightHarassClientRpc(_targetClientId, seed, 0.55f); } else { TryStartFlashlightHarass(_targetClientId, seed, 0.55f); } } } private void TryStartFlashlightHarass(ulong targetClientId, int seed, float duration) { if (((Behaviour)this).isActiveAndEnabled && !base.isEnemyDead && _flashlightHarassRoutine == null) { PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if (!((Object)(object)val == (Object)null) && !val.isPlayerDead && (val.actualClientId == targetClientId || val.playerClientId == targetClientId)) { _flashlightHarassRoutine = ((MonoBehaviour)this).StartCoroutine(FlashlightHarassRoutine(val, seed, duration)); } } } private IEnumerator FlashlightHarassRoutine(PlayerControllerB player, int seed, float duration) { CaptureFlashlightHarassLights(player); if (_flashlightHarassLights.Count == 0) { _flashlightHarassRoutine = null; yield break; } Random random = new Random(seed); float endTime = Time.time + Mathf.Clamp(duration, 0.15f, 1.2f); while (Time.time < endTime) { for (int i = 0; i < _flashlightHarassLights.Count; i++) { Light light = _flashlightHarassLights[i].Light; if ((Object)(object)light == (Object)null) { continue; } if (random.NextDouble() < 0.5) { ((Behaviour)light).enabled = false; continue; } ((Behaviour)light).enabled = _flashlightHarassLights[i].Enabled; if (((Behaviour)light).enabled) { light.intensity = _flashlightHarassLights[i].Intensity * Mathf.Lerp(0.1f, 1f, (float)random.NextDouble()); } } yield return (object)new WaitForSeconds(Mathf.Lerp(0.04f, 0.11f, (float)random.NextDouble())); } RestoreFlashlightHarass(); _flashlightHarassRoutine = null; } private void CaptureFlashlightHarassLights(PlayerControllerB player) { _flashlightHarassLights.Clear(); if (!((Object)(object)player == (Object)null)) { AddFlashlightHarassLight(player.helmetLight); GrabbableObject currentlyHeldObjectServer = player.currentlyHeldObjectServer; FlashlightItem val = (FlashlightItem)(object)((currentlyHeldObjectServer is FlashlightItem) ? currentlyHeldObjectServer : null); if ((Object)(object)val != (Object)null) { AddFlashlightHarassLight(val.flashlightBulb); AddFlashlightHarassLight(val.flashlightBulbGlow); } GrabbableObject pocketedFlashlight = player.pocketedFlashlight; FlashlightItem val2 = (FlashlightItem)(object)((pocketedFlashlight is FlashlightItem) ? pocketedFlashlight : null); if ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)val) { AddFlashlightHarassLight(val2.flashlightBulb); AddFlashlightHarassLight(val2.flashlightBulbGlow); } } } private void AddFlashlightHarassLight(Light light) { if (!((Object)(object)light == (Object)null) && ((Behaviour)light).enabled) { _flashlightHarassLights.Add(new FlickerLight { Light = light, Enabled = ((Behaviour)light).enabled, Intensity = light.intensity }); } } private void RestoreFlashlightHarass() { for (int i = 0; i < _flashlightHarassLights.Count; i++) { Light light = _flashlightHarassLights[i].Light; if (!((Object)(object)light == (Object)null)) { ((Behaviour)light).enabled = _flashlightHarassLights[i].Enabled; light.intensity = _flashlightHarassLights[i].Intensity; } } _flashlightHarassLights.Clear(); } private void StopFlashlightHarass() { if (_flashlightHarassRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_flashlightHarassRoutine); _flashlightHarassRoutine = null; } RestoreFlashlightHarass(); } private void RevealServer(float flickerSeconds) { //IL_0095: 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) float num = Mathf.Max(0f, flickerSeconds); _logicalVisible = true; _visSeq++; _presentationReadyAt = Time.time + num * 0.72f; if (((NetworkBehaviour)this).IsServer && CanSendRpc) { _networkVisible.Value = true; _networkVisibilitySequence.Value = _visSeq; _networkStage.Value = (int)_stage; _networkPresentation.Value = (int)_pendingPresentation; _networkRevealPosition.Value = ((Component)this).transform.position; _networkFacingYaw.Value = ((Component)this).transform.eulerAngles.y; _networkFacingLockDuration.Value = 0.8f; _networkPresentationReadyDelay.Value = num * 0.72f; _networkRevealSequence.Value += 1; } if (CanSendRpc) { SetVisibilityClientRpc(visible: true, _visSeq, num); } else { ApplyVisibility(visible: true, _visSeq, 0f); } EnableCreatureSpotlightServer(); } private void EnableCreatureSpotlightServer() { if (CreatureSpotlightEnabled) { _spotlightActive = true; RefreshCreatureSpotlightServer(); } } private void RefreshCreatureSpotlightServer() { //IL_00ea: 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_00c4: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsServer && _spotlightActive && CreatureSpotlightEnabled) { ResolveCreatureSpotlightProfile(out _spotlightIntensity, out _spotlightAngle, out _spotlightRange, out _spotlightHeight, out _spotlightColor); if (CanSendRpc) { _networkSpotlightActive.Value = true; _networkSpotlightIntensity.Value = _spotlightIntensity; _networkSpotlightAngle.Value = _spotlightAngle; _networkSpotlightRange.Value = _spotlightRange; _networkSpotlightHeight.Value = _spotlightHeight; _networkSpotlightColor.Value = _spotlightColor; SetCreatureSpotlightClientRpc(active: true, _spotlightIntensity, _spotlightAngle, _spotlightRange, _spotlightHeight, _spotlightColor); } else { ApplyCreatureSpotlight(active: true, _spotlightIntensity, _spotlightAngle, _spotlightRange, _spotlightHeight, _spotlightColor); } } } private void ResolveCreatureSpotlightProfile(out float intensity, out float angle, out float range, out float height, out Vector3 color) { //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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) float num; float num2; float num3; if (base.currentBehaviourStateIndex == 7 && Time.time >= _attackMovementReadyAt) { num = 0.42f; num2 = 0.82f; num3 = 0.86f; color = new Vector3(0.38f, 0.52f, 0.58f); } else if (base.currentBehaviourStateIndex == 5 || base.currentBehaviourStateIndex == 8 || base.currentBehaviourStateIndex == 6 || base.currentBehaviourStateIndex == 7) { num = 1.1f; num2 = 1.08f; num3 = 1.05f; color = new Vector3(0.56f, 0.9f, 1f); } else { switch (_stage) { case SightingStage.Long: num = 0.38f; num2 = 0.78f; num3 = 0.9f; color = new Vector3(0.52f, 0.68f, 0.78f); break; case SightingStage.Medium: num = 0.62f; num2 = 0.9f; num3 = 0.96f; color = new Vector3(0.45f, 0.78f, 0.9f); break; default: num = 0.95f; num2 = 1.04f; num3 = 1f; color = new Vector3(0.35f, 0.9f, 1f); break; } } float num4 = 18f; float num5 = 42f; float num6 = 14f; intensity = num4 * num; angle = Mathf.Clamp(num5 * num2, 5f, 120f); range = num6 * num3; height = 5f; } private void DisableCreatureSpotlightServer() { //IL_006b: 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) if (_spotlightActive) { _spotlightActive = false; if (((NetworkBehaviour)this).IsServer && CanSendRpc) { _networkSpotlightActive.Value = false; } if (CanSendRpc) { SetCreatureSpotlightClientRpc(active: false, 0f, 0f, 0f, 0f, Vector3.zero); } else { ApplyCreatureSpotlight(active: false, 0f, 0f, 0f, 0f, Vector3.zero); } } } private void ApplyCreatureSpotlight(bool active, float intensity, float angle, float range, float height, Vector3 colorVector) { //IL_002e: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (!active || base.isEnemyDead) { if ((Object)(object)_spotlight != (Object)null) { _spotlight.Despawn(); _spotlight = null; } } else { Color color = default(Color); ((Color)(ref color))..ctor(colorVector.x, colorVector.y, colorVector.z); if ((Object)(object)_spotlight == (Object)null) { _spotlight = DreadweaverSpotlight.SpawnAbove(((Component)this).transform, height, intensity, angle, range, color); } else { _spotlight.Configure(intensity, angle, range, height, color); } } } private void ApplyVisibility(bool visible, int sequence, float flickerSeconds) { CaptureVisuals(); EnsureCamoShells(); _logicalVisible = visible; _appliedVisSeq = sequence; if (!visible) { ResetFootstepTracking(); } if (_flickerRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_flickerRoutine); _flickerRoutine = null; } if (_camoPreviewRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_camoPreviewRoutine); _camoPreviewRoutine = null; } if (flickerSeconds <= 0.02f || !((Behaviour)this).isActiveAndEnabled || base.isEnemyDead) { SetCamoShellsShown(shown: false); SetRenderersShown(visible); SetCollidersEnabled(visible); } else { SetCollidersEnabled(!visible); _flickerRoutine = ((MonoBehaviour)this).StartCoroutine(ActiveCamoVisibilityRoutine(visible, sequence, flickerSeconds)); } } private IEnumerator ActiveCamoVisibilityRoutine(bool finalVisible, int sequence, float duration) { float elapsed = 0f; float safeDuration = Mathf.Max(0.12f, duration); if (finalVisible) { SetRenderersShown(shown: false); SetCamoShellsShown(shown: true); } else { SetRenderersShown(shown: true); SetCamoShellsShown(shown: true); } while (elapsed < safeDuration) { if (sequence != _appliedVisSeq) { SetCamoShellsShown(shown: false); SetCollidersEnabled(_logicalVisible); yield break; } float num = Mathf.Clamp01(elapsed / safeDuration); if (finalVisible) { ApplyCamoShellProperties(1f - num, Mathf.Lerp(1.15f, 0.25f, num)); if (num >= 0.72f) { SetRenderersShown(shown: true); SetCollidersEnabled(enabled: true); } } else { ApplyCamoShellProperties(num, Mathf.Lerp(0.65f, 1.35f, num)); if (num >= 0.45f) { SetRenderersShown(shown: false); } if (num >= 0.6f) { SetCollidersEnabled(enabled: false); } } elapsed += Time.deltaTime; yield return null; } if (sequence == _appliedVisSeq) { SetRenderersShown(finalVisible); SetCamoShellsShown(shown: false); SetCollidersEnabled(finalVisible); } _flickerRoutine = null; } private void StartCamoPreviewServer(float duration) { float duration2 = Mathf.Clamp(duration, 0.15f, 1.5f); if (CanSendRpc) { StartCamoPreviewClientRpc(duration2); } else { StartCamoPreview(duration2); } } private void StartCamoPreview(float duration) { if (!((Behaviour)this).isActiveAndEnabled || base.isEnemyDead) { return; } EnsureCamoShells(); if (_camoShells.Count != 0) { if (_camoPreviewRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_camoPreviewRoutine); _camoPreviewRoutine = null; } _camoPreviewRoutine = ((MonoBehaviour)this).StartCoroutine(CamoPreviewRoutine(duration)); } } private IEnumerator CamoPreviewRoutine(float duration) { SetCamoShellsShown(shown: true); float elapsed = 0f; float safeDuration = Mathf.Max(0.12f, duration); while (elapsed < safeDuration) { float num = Mathf.Clamp01(elapsed / safeDuration); ApplyCamoShellProperties(Mathf.Lerp(0.15f, 0.85f, num), Mathf.Lerp(0.8f, 1.25f, num)); elapsed += Time.deltaTime; yield return null; } SetCamoShellsShown(shown: false); _camoPreviewRoutine = null; } private void ApplyCamoShellProperties(float dissolve, float intensity) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp01(intensity); Color val = Color.Lerp(new Color(0.35f, 0.95f, 1f, 0.55f), new Color(0.75f, 1f, 1f, 0.85f), Mathf.Clamp01(intensity - 0.4f)); for (int i = 0; i < _camoShells.Count; i++) { CamoShellRenderer camoShellRenderer = _camoShells[i]; if (camoShellRenderer?.Materials == null) { continue; } for (int j = 0; j < camoShellRenderer.Materials.Length; j++) { Material val2 = camoShellRenderer.Materials[j]; if (!((Object)(object)val2 == (Object)null)) { SetMaterialFloatIfPresent(val2, "_Dissolve", dissolve); SetMaterialFloatIfPresent(val2, "_DissolveAmount", dissolve); SetMaterialFloatIfPresent(val2, "_Cutoff", Mathf.Clamp01(dissolve * 0.85f)); SetMaterialFloatIfPresent(val2, "_AlphaCutoff", Mathf.Clamp01(dissolve)); SetMaterialFloatIfPresent(val2, "_EdgeWidth", Mathf.Lerp(0.035f, 0.14f, num)); SetMaterialFloatIfPresent(val2, "_EmissionIntensity", Mathf.Lerp(1.5f, 5f, num)); SetMaterialFloatIfPresent(val2, "_EmissiveIntensity", Mathf.Lerp(1.5f, 5f, num)); SetMaterialColorIfPresent(val2, "_EdgeColor", val); SetMaterialColorIfPresent(val2, "_EmissionColor", val * Mathf.Lerp(1.4f, 3.5f, num)); SetMaterialColorIfPresent(val2, "_EmissiveColor", val * Mathf.Lerp(1.4f, 3.5f, num)); } } } } private void SetCamoShellsShown(bool shown) { EnsureCamoShells(); for (int i = 0; i < _camoShells.Count; i++) { Renderer val = _camoShells[i]?.Renderer; if ((Object)(object)val != (Object)null) { val.enabled = shown; } } } private static void SetMaterialFloatIfPresent(Material material, string propertyName, float value) { if ((Object)(object)material != (Object)null && material.HasProperty(propertyName)) { material.SetFloat(propertyName, value); } } private static void SetMaterialColorIfPresent(Material material, string propertyName, Color value) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)material != (Object)null && material.HasProperty(propertyName)) { material.SetColor(propertyName, value); } } private void CaptureVisuals() { if (_visualsCaptured) { return; } _visualsCaptured = true; Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren(true); List list = new List(componentsInChildren.Length); foreach (Renderer val in componentsInChildren) { if ((Object)(object)val != (Object)null && !IsRuntimeHelperTransform(((Component)val).transform)) { list.Add(val); } } _bodyRenderers = list.ToArray(); _bodyRendererDefaults = new bool[_bodyRenderers.Length]; for (int j = 0; j < _bodyRenderers.Length; j++) { _bodyRendererDefaults[j] = _bodyRenderers[j].enabled; } _bodyColliders = ((Component)this).GetComponentsInChildren(true); _bodyColliderDefaults = new bool[_bodyColliders.Length]; for (int k = 0; k < _bodyColliders.Length; k++) { _bodyColliderDefaults[k] = (Object)(object)_bodyColliders[k] != (Object)null && _bodyColliders[k].enabled; } } private void EnsureCamoShells() { if (_camoShellsCreated) { return; } _camoShellsCreated = true; CaptureVisuals(); Material val = CreateCamoShellMaterial(); if ((Object)(object)val == (Object)null) { return; } for (int i = 0; i < _bodyRenderers.Length; i++) { Renderer val2 = _bodyRenderers[i]; if ((Object)(object)val2 == (Object)null) { continue; } SkinnedMeshRenderer val3 = (SkinnedMeshRenderer)(object)((val2 is SkinnedMeshRenderer) ? val2 : null); if (val3 != null) { CreateSkinnedCamoShell(val3, val); continue; } MeshRenderer val4 = (MeshRenderer)(object)((val2 is MeshRenderer) ? val2 : null); if (val4 != null) { CreateMeshCamoShell(val4, val); } } if (DebugLogs) { string arg = (_usingBundledCamoMaterial ? "bundled dissolve material" : "runtime fallback material"); ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"[DreadweaverAI] Created {_camoShells.Count} active-camo shell renderer(s) using {arg}."); } } } private void CreateSkinnedCamoShell(SkinnedMeshRenderer source, Material template) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)source.sharedMesh == (Object)null)) { GameObject val = new GameObject("_DreadweaverCamoShell_" + ((Object)source).name) { hideFlags = (HideFlags)52, layer = ((Component)source).gameObject.layer }; val.transform.SetParent(((Component)source).transform, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; SkinnedMeshRenderer val2 = val.AddComponent(); val2.sharedMesh = source.sharedMesh; val2.bones = source.bones; val2.rootBone = source.rootBone; ((Renderer)val2).localBounds = ((Renderer)source).localBounds; val2.updateWhenOffscreen = true; ((Renderer)val2).forceRenderingOff = false; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; ((Renderer)val2).sharedMaterials = CreateCamoMaterialArray(((Renderer)source).sharedMaterials, template); ((Renderer)val2).enabled = false; _camoShells.Add(new CamoShellRenderer { Renderer = (Renderer)(object)val2, Materials = ((Renderer)val2).sharedMaterials }); } } private void CreateMeshCamoShell(MeshRenderer source, Material template) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_004d: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_008f: Unknown result type (might be due to invalid IL or missing references) MeshFilter component = ((Component)source).GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.sharedMesh == (Object)null)) { GameObject val = new GameObject("_DreadweaverCamoShell_" + ((Object)source).name) { hideFlags = (HideFlags)52, layer = ((Component)source).gameObject.layer }; val.transform.SetParent(((Component)source).transform, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; val.AddComponent().sharedMesh = component.sharedMesh; MeshRenderer val2 = val.AddComponent(); ((Renderer)val2).forceRenderingOff = false; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; ((Renderer)val2).sharedMaterials = CreateCamoMaterialArray(((Renderer)source).sharedMaterials, template); ((Renderer)val2).enabled = false; _camoShells.Add(new CamoShellRenderer { Renderer = (Renderer)(object)val2, Materials = ((Renderer)val2).sharedMaterials }); } } private Material[] CreateCamoMaterialArray(Material[] sourceMaterials, Material template) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown int num = Mathf.Max(1, (sourceMaterials != null) ? sourceMaterials.Length : 0); Material[] array = (Material[])(object)new Material[num]; for (int i = 0; i < num; i++) { Material val = ((sourceMaterials != null && i < sourceMaterials.Length) ? sourceMaterials[i] : null); Material val2 = new Material(template); ((Object)val2).name = "M_DreadweaverActiveCamoRuntime"; Texture texture = (((Object)(object)val != (Object)null) ? val.mainTexture : null); SetMaterialTextureIfPresent(val2, "_BaseColorMap", texture); SetMaterialTextureIfPresent(val2, "_MainTex", texture); SetMaterialTextureIfPresent(val2, "_BaseMap", texture); ConfigureCamoMaterial(val2); ApplySourceTintToCamoMaterial(val2, val); array[i] = val2; } return array; } private Material CreateCamoShellMaterial() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_003b: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown //IL_0147: Expected O, but got Unknown Material val = LoadBundledDissolveMaterial(); if ((Object)(object)val != (Object)null && IsUsableCamoShader(val.shader)) { _usingBundledCamoMaterial = true; Material val2 = new Material(val) { name = "M_DreadweaverBundledDissolveRuntime" }; ConfigureCamoMaterial(val2); return val2; } if ((Object)(object)val != (Object)null && !_loggedCamoFallback) { _loggedCamoFallback = true; string text = (((Object)(object)val.shader != (Object)null) ? ((Object)val.shader).name : ""); ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[DreadweaverAI] Bundled Dreadweaver camo material shader '" + text + "' was not usable; using runtime fallback.")); } } Shader val3 = Shader.Find("HDRP/Lit") ?? Shader.Find("HDRP/Unlit") ?? Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Universal Render Pipeline/Unlit") ?? Shader.Find("Standard") ?? Shader.Find("Unlit/Transparent") ?? Shader.Find("Legacy Shaders/Transparent/Diffuse") ?? Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Color") ?? Shader.Find("Diffuse"); if ((Object)(object)val3 == (Object)null) { return null; } _usingBundledCamoMaterial = false; Material val4 = new Material(val3) { name = "M_DreadweaverActiveCamoFallback" }; ConfigureCamoMaterial(val4); return val4; } private static Material LoadBundledDissolveMaterial() { if ((Object)(object)Plugin.ModAssets == (Object)null) { return null; } string[] array = new string[4] { "M_DreadweaverDissolveCamo", "assets/dreadweaver/materials/m_dreadweaverdissolvecamo.mat", "Shader Graphs_Dissolve_Dissolve_Metallic", "assets/shadergraph_dissolve/hdrp/materials/shader graphs_dissolve_dissolve_metallic.mat" }; for (int i = 0; i < array.Length; i++) { Material val = Plugin.ModAssets.LoadAsset(array[i]); if ((Object)(object)val != (Object)null) { return val; } } string[] allAssetNames = Plugin.ModAssets.GetAllAssetNames(); for (int j = 0; j < allAssetNames.Length; j++) { string text = allAssetNames[j].Replace('\\', '/'); if (text.IndexOf("dissolve", StringComparison.OrdinalIgnoreCase) >= 0 && text.EndsWith(".mat", StringComparison.OrdinalIgnoreCase)) { Material val2 = Plugin.ModAssets.LoadAsset(allAssetNames[j]); if ((Object)(object)val2 != (Object)null) { return val2; } } } return null; } private static bool IsUsableCamoShader(Shader shader) { if ((Object)(object)shader == (Object)null || !shader.isSupported) { return false; } string text = ((Object)shader).name ?? string.Empty; if (text.StartsWith("Y4NGZ/", StringComparison.OrdinalIgnoreCase)) { return true; } if (text.IndexOf("InternalError", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("Hidden/InternalErrorShader", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("Shader Graph", StringComparison.OrdinalIgnoreCase) < 0) { return text.IndexOf("Dissolve", StringComparison.OrdinalIgnoreCase) < 0; } return false; } private static void ConfigureCamoMaterial(Material material) { //IL_0046: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)material == (Object)null)) { Color value = default(Color); ((Color)(ref value))..ctor(0.08f, 0.48f, 0.55f, 0.38f); Color val = default(Color); ((Color)(ref val))..ctor(0.12f, 0.95f, 1f, 1f); SetMaterialColorIfPresent(material, "_BaseColor", value); SetMaterialColorIfPresent(material, "_Color", value); SetMaterialColorIfPresent(material, "_UnlitColor", value); SetMaterialColorIfPresent(material, "_TintColor", value); SetMaterialColorIfPresent(material, "_EdgeColor", val); SetMaterialColorIfPresent(material, "_EmissionColor", val * 2.5f); SetMaterialColorIfPresent(material, "_EmissiveColor", val * 2.5f); SetMaterialFloatIfPresent(material, "_SurfaceType", 1f); SetMaterialFloatIfPresent(material, "_BlendMode", 0f); SetMaterialFloatIfPresent(material, "_ZWrite", 0f); SetMaterialFloatIfPresent(material, "_SrcBlend", 5f); SetMaterialFloatIfPresent(material, "_DstBlend", 10f); SetMaterialFloatIfPresent(material, "_AlphaSrcBlend", 1f); SetMaterialFloatIfPresent(material, "_AlphaDstBlend", 10f); SetMaterialFloatIfPresent(material, "_Mode", 3f); SetMaterialFloatIfPresent(material, "_CullMode", 0f); SetMaterialFloatIfPresent(material, "_Cull", 0f); SetMaterialFloatIfPresent(material, "_DoubleSidedEnable", 1f); SetMaterialFloatIfPresent(material, "_Dissolve", 0f); SetMaterialFloatIfPresent(material, "_DissolveAmount", 0f); SetMaterialFloatIfPresent(material, "_EdgeWidth", 0.08f); SetMaterialFloatIfPresent(material, "_EdgeColorIntensity", 4.25f); SetMaterialFloatIfPresent(material, "_NoiseScale", 26f); SetMaterialFloatIfPresent(material, "_Alpha", 0.38f); material.SetOverrideTag("RenderType", "Transparent"); material.renderQueue = 3000; material.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); material.EnableKeyword("_ALPHABLEND_ON"); material.DisableKeyword("_ALPHATEST_ON"); material.DisableKeyword("_ALPHATESTENABLE_ON"); } } private static void ApplySourceTintToCamoMaterial(Material material, Material source) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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) if (!((Object)(object)material == (Object)null) && !((Object)(object)source == (Object)null)) { Texture texture = GetMaterialTexture(source, "_BaseColorMap") ?? GetMaterialTexture(source, "_BaseMap") ?? GetMaterialTexture(source, "_MainTex") ?? source.mainTexture; SetMaterialTextureIfPresent(material, "_BaseColorMap", texture); SetMaterialTextureIfPresent(material, "_BaseMap", texture); SetMaterialTextureIfPresent(material, "_MainTex", texture); Color val = (Color)(((??)GetMaterialColor(source, "_BaseColor")) ?? ((??)GetMaterialColor(source, "_Color")) ?? Color.white); Color val2 = new Color(0.08f, 0.52f, 0.6f, 1f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.06f, 0.85f, 0.95f, 1f); Color val4 = Color.Lerp(val2, val, 0.18f); val4 = Color.Lerp(val4, val3, 0.22f); val4.a = 0.38f; SetMaterialColorIfPresent(material, "_BaseColor", val4); SetMaterialColorIfPresent(material, "_Color", val4); } } private static Texture GetMaterialTexture(Material material, string propertyName) { if (!((Object)(object)material != (Object)null) || !material.HasProperty(propertyName)) { return null; } return material.GetTexture(propertyName); } private static Color? GetMaterialColor(Material material, string propertyName) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)material != (Object)null) || !material.HasProperty(propertyName)) { return null; } return material.GetColor(propertyName); } private static void SetMaterialTextureIfPresent(Material material, string propertyName, Texture texture) { if ((Object)(object)material != (Object)null && (Object)(object)texture != (Object)null && material.HasProperty(propertyName)) { material.SetTexture(propertyName, texture); } } private static bool IsRuntimeHelperTransform(Transform start) { Transform val = start; while ((Object)(object)val != (Object)null) { string text = ((Object)val).name ?? string.Empty; if (text.IndexOf("MapDot", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("ScanNode", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("_DreadweaverCamoShell", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } val = val.parent; } return false; } private void SetRenderersShown(bool shown) { CaptureVisuals(); _renderersShown = shown; for (int i = 0; i < _bodyRenderers.Length; i++) { Renderer val = _bodyRenderers[i]; if ((Object)(object)val != (Object)null) { val.enabled = shown && _bodyRendererDefaults[i]; } } } private void SetCollidersEnabled(bool enabled) { CaptureVisuals(); for (int i = 0; i < _bodyColliders.Length; i++) { Collider val = _bodyColliders[i]; if ((Object)(object)val != (Object)null) { val.enabled = enabled && _bodyColliderDefaults[i]; } } } private bool TargetSeesCreature(PlayerControllerB player) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!_logicalVisible || Time.time < _presentationReadyAt) { return false; } return PlayerWouldSeePosition(player, GetCreatureFocusPoint(), SpotHalfAngle); } private bool NonTargetPlayerSeesCreature(PlayerControllerB target) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (!_logicalVisible || Time.time < _presentationReadyAt || (Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null) { return false; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)target) && !val.isPlayerDead && val.isPlayerControlled && PlayerWouldSeePosition(val, GetCreatureFocusPoint(), SpotHalfAngle)) { return true; } } return false; } private bool AnyPlayerWouldSeePosition(Vector3 targetPoint, float halfAngle) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return AnyOtherPlayerWouldSeePosition(targetPoint, null, halfAngle); } private bool AnyOtherPlayerWouldSeePosition(Vector3 targetPoint, PlayerControllerB excluded, float halfAngle) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null) { return false; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)excluded) && !val.isPlayerDead && val.isPlayerControlled && PlayerWouldSeePosition(val, targetPoint, halfAngle)) { return true; } } return false; } private bool PlayerWouldSeePosition(PlayerControllerB player, Vector3 targetPoint, float halfAngle) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0083: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)player.gameplayCamera == (Object)null) { return false; } Vector3 position = ((Component)player.gameplayCamera).transform.position; Vector3 val = targetPoint - position; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.05f || magnitude > CreatureSightRange + 15f) { return false; } Vector3 val2 = val / magnitude; if (Vector3.Dot(((Component)player.gameplayCamera).transform.forward, val2) < Mathf.Cos(halfAngle * (MathF.PI / 180f))) { return false; } return HasClearLineOfSight(position, targetPoint, ((Component)player).transform); } private bool HasClearLineOfSight(Vector3 from, Vector3 to, Transform ignoredPlayerRoot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_0007: 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_0022: 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) Vector3 val = to - from; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude <= 0.05f) { return true; } int num = ResolveLineOfSightMask(); int num2 = Physics.RaycastNonAlloc(from, val / magnitude, _lineOfSightHits, magnitude - 0.05f, num, (QueryTriggerInteraction)1); for (int i = 0; i < num2; i++) { Collider collider = ((RaycastHit)(ref _lineOfSightHits[i])).collider; if (!((Object)(object)collider == (Object)null)) { Transform transform = ((Component)collider).transform; if (!((Object)(object)transform == (Object)null) && !transform.IsChildOf(((Component)this).transform) && (!((Object)(object)ignoredPlayerRoot != (Object)null) || !transform.IsChildOf(ignoredPlayerRoot))) { return false; } } } return true; } private int CountLivingAlliesNear(PlayerControllerB target, float radius) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null) { return 0; } int num = 0; float num2 = radius * radius; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)target) && !val.isPlayerDead && val.isPlayerControlled) { Vector3 val2 = ((Component)val).transform.position - ((Component)target).transform.position; if (((Vector3)(ref val2)).sqrMagnitude <= num2) { num++; } } } return num; } private bool TooCloseToAnyPlayer(Vector3 position, float radius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return TooCloseToNonTargetPlayer(position, null, radius); } private bool TooCloseToNonTargetPlayer(Vector3 position, PlayerControllerB excluded, float radius) { //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_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) if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null) { return false; } float num = radius * radius; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)excluded) && !val.isPlayerDead && val.isPlayerControlled) { Vector3 val2 = ((Component)val).transform.position - position; if (((Vector3)(ref val2)).sqrMagnitude <= num) { return true; } } } return false; } private bool TryGetClosestLivingPlayer(out PlayerControllerB closestPlayer, out float closestDistance) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) closestPlayer = null; closestDistance = float.PositiveInfinity; if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null) { return false; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && !val.isPlayerDead && val.isPlayerControlled) { float num = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position); if (num < closestDistance) { closestDistance = num; closestPlayer = val; } } } return (Object)(object)closestPlayer != (Object)null; } private Vector3 GetCreatureFocusPoint() { //IL_0020: 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_0030: 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_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.eye != (Object)null) { return base.eye.position; } return ((Component)this).transform.position + Vector3.up * GetSightOriginHeight(); } private Vector3 GetCandidateSightPoint(Vector3 rootPosition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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) return rootPosition + Vector3.up * GetSightOriginHeight(); } private float GetSightOriginHeight() { //IL_0019: 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) if ((Object)(object)base.eye != (Object)null) { return Mathf.Max(0.5f, base.eye.position.y - ((Component)this).transform.position.y); } return 1.65f * GetVerticalWorldScale(); } private float GetHorizontalWorldScale() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) Vector3 lossyScale = ((Component)this).transform.lossyScale; return Mathf.Max(0.1f, Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.z))); } private float GetVerticalWorldScale() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) return Mathf.Max(0.1f, Mathf.Abs(((Component)this).transform.lossyScale.y)); } private static Vector3 GetPlayerFocusPoint(PlayerControllerB player) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return Vector3.zero; } if (!((Object)(object)player.gameplayCamera != (Object)null)) { return ((Component)player).transform.position + Vector3.up * 1.45f; } return ((Component)player.gameplayCamera).transform.position; } private static Vector3 GetFlatCameraForward(PlayerControllerB player) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_005f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (((Object)(object)player != (Object)null && (Object)(object)player.gameplayCamera != (Object)null) ? ((Component)player.gameplayCamera).transform.forward : (((Object)(object)player != (Object)null) ? ((Component)player).transform.forward : Vector3.forward)); val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude > 0.001f)) { return Vector3.forward; } return ((Vector3)(ref val)).normalized; } private void ConfigureAgent(float speed) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.agent == (Object)null) { return; } if (!((Behaviour)base.agent).enabled) { NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(((Component)this).transform.position, ref val, 8f, -1)) { ((Component)this).transform.position = ((NavMeshHit)(ref val)).position; } ((Behaviour)base.agent).enabled = true; } base.agent.isStopped = false; base.agent.speed = speed; base.agent.angularSpeed = TurnSpeed; base.agent.acceleration = Acceleration; base.agent.stoppingDistance = Mathf.Max(0.5f, AttackRange * 0.65f); base.agent.radius = Mathf.Max(base.agent.radius, 0.86f); base.agent.height = Mathf.Max(base.agent.height, 2.45f); base.agent.autoBraking = base.currentBehaviourStateIndex != 7; base.agent.autoRepath = true; base.agent.updateRotation = false; base.agent.obstacleAvoidanceType = (ObstacleAvoidanceType)4; base.agent.avoidancePriority = 31; } private void StopAgent() { //IL_0054: 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.isStopped = true; if (base.agent.isOnNavMesh) { base.agent.ResetPath(); base.agent.velocity = Vector3.zero; } } } private void BeginDamageStunFreeze() { if (((NetworkBehaviour)this).IsServer) { CancelAttackSwing(0.5f); } _damageStunUntil = Mathf.Max(_damageStunUntil, Time.time + 1f); ApplyDamageStunFreeze(); } private bool ApplyDamageStunFreeze() { if (!(base.stunNormalizedTimer >= 0f) && !(Time.time < _damageStunUntil)) { ClearDamageStunFreeze(); return false; } StopAgent(); if (((NetworkBehaviour)this).IsServer && _attackRoutine != null) { CancelAttackSwing(0.5f); } if (base.stunNormalizedTimer < 0f) { ClearDamageStunFreeze(); return true; } if (!_damageStunFrozen) { Animator val = (((Object)(object)base.creatureAnimator != (Object)null) ? base.creatureAnimator : visualAnimator); _preDamageStunAnimatorSpeed = (((Object)(object)val != (Object)null) ? Mathf.Max(0.01f, val.speed) : 1f); _damageStunFrozen = true; } if ((Object)(object)base.creatureAnimator != (Object)null) { base.creatureAnimator.speed = 0f; } if ((Object)(object)visualAnimator != (Object)null && (Object)(object)visualAnimator != (Object)(object)base.creatureAnimator) { visualAnimator.speed = 0f; } return true; } private void ClearDamageStunFreeze() { if (_damageStunFrozen) { if ((Object)(object)base.creatureAnimator != (Object)null) { base.creatureAnimator.speed = _preDamageStunAnimatorSpeed; } if ((Object)(object)visualAnimator != (Object)null && (Object)(object)visualAnimator != (Object)(object)base.creatureAnimator) { visualAnimator.speed = _preDamageStunAnimatorSpeed; } _damageStunFrozen = false; } } private bool MoveAgentTo(Vector3 destination, float speed, float stoppingDistance, bool autoBrake) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.agent == (Object)null) { return false; } ConfigureAgent(speed); if (!((Behaviour)base.agent).enabled || !base.agent.isOnNavMesh) { return false; } base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = true; base.agent.isStopped = false; base.agent.stoppingDistance = Mathf.Max(0.05f, stoppingDistance); base.agent.autoBraking = autoBrake; return base.agent.SetDestination(destination); } private void ConfigureAttackSearchDefaults() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown if (attackRecoverySearch == null) { attackRecoverySearch = new AISearchRoutine(); } attackRecoverySearch.loopSearch = true; attackRecoverySearch.randomized = true; attackRecoverySearch.onlySearchNodesInLOS = false; attackRecoverySearch.searchWidth = Mathf.Max(36f, AttackLoseDistance); attackRecoverySearch.searchPrecision = 6f; } private void StartAttackRecoverySearch(Vector3 start) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsServer && !base.isEnemyDead && !((Object)(object)base.agent == (Object)null) && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { ConfigureAttackSearchDefaults(); if (base.currentSearch != null && base.currentSearch.inProgress) { ((EnemyAI)this).StopSearch(base.currentSearch, true); } ConfigureAgent(StalkMoveSpeed); base.movingTowardsTargetPlayer = false; ((EnemyAI)this).StartSearch(start, attackRecoverySearch); } } private void MaintainAttackRecoverySearch(Vector3 preferredStart) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsServer && !base.isEnemyDead && !((Object)(object)base.agent == (Object)null) && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { ConfigureAttackSearchDefaults(); if (base.currentSearch != attackRecoverySearch || !attackRecoverySearch.inProgress) { StartAttackRecoverySearch(preferredStart); } } } private void ResetAttackMovementRecovery(PlayerControllerB target) { //IL_0007: 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_0028: 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) _lastAttackProgressPosition = ((Component)this).transform.position; _lastAttackProgressDistance = (((Object)(object)target != (Object)null) ? Vector3.Distance(((Component)this).transform.position, ((Component)target).transform.position) : float.PositiveInfinity); _attackStuckTimer = 0f; _nextAttackProgressCheckTime = Time.time + 0.35f; } private bool TickAttackMovementRecovery(PlayerControllerB target, float deltaTime) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Invalid comparison between Unknown and I4 //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Invalid comparison between Unknown and I4 //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsServer || (Object)(object)target == (Object)null || _isAttackAnimating) { return false; } _lastKnownAttackTargetPosition = ((Component)target).transform.position; if ((Object)(object)base.agent == (Object)null || !((Behaviour)base.agent).enabled) { BeginPursuitReposition("agent unavailable"); return true; } if (!base.agent.isOnNavMesh) { if (TryRepairAgentOntoNavMesh()) { ResetAttackMovementRecovery(target); return false; } BeginPursuitReposition("off navmesh"); return true; } if (base.currentSearch != null && base.currentSearch.inProgress) { ((EnemyAI)this).StopSearch(base.currentSearch, true); } float num = Vector3.Distance(((Component)this).transform.position, ((Component)target).transform.position); if (num <= AttackRange * 1.8f) { ResetAttackMovementRecovery(target); return false; } if (!base.agent.pathPending && ((int)base.agent.pathStatus == 2 || (int)base.agent.pathStatus == 1) && Time.time >= _nextAttackPathRepairTime) { _nextAttackPathRepairTime = Time.time + 1.4f; if (TryRefreshAttackPath(target)) { _attackStuckTimer = Mathf.Min(_attackStuckTimer + 0.35f, 3.5f); return false; } _attackStuckTimer += 0.35f; if (_attackStuckTimer >= 7f) { BeginPursuitReposition("no complete path to target"); return true; } return false; } if (Time.time < _nextAttackProgressCheckTime) { return false; } float num2 = Mathf.Max(deltaTime, 0.35f); _nextAttackProgressCheckTime = Time.time + 0.35f; Vector3 val = ((Component)this).transform.position - _lastAttackProgressPosition; val.y = 0f; float num3 = _lastAttackProgressDistance - num; _lastAttackProgressPosition = ((Component)this).transform.position; _lastAttackProgressDistance = num; bool num4 = base.movingTowardsTargetPlayer || (base.agent.hasPath && !base.agent.pathPending && base.agent.remainingDistance > Mathf.Max(base.agent.stoppingDistance + 0.9f, 1.5f)); int num5; if (!(((Vector3)(ref val)).magnitude >= 0.18f) && !(num3 >= 0.18f)) { Vector3 velocity = base.agent.velocity; num5 = ((((Vector3)(ref velocity)).sqrMagnitude > 0.03f) ? 1 : 0); } else { num5 = 1; } bool flag = (byte)num5 != 0; if (!num4 || flag) { _attackStuckTimer = 0f; return false; } _attackStuckTimer += num2; if (_attackStuckTimer >= 1.6f && Time.time >= _nextAttackPathRepairTime) { _nextAttackPathRepairTime = Time.time + 1.4f; if (TryRefreshAttackPath(target)) { return false; } } if (_attackStuckTimer < 7f || Time.time < _nextAttackPathRepairTime) { return false; } _nextAttackPathRepairTime = Time.time + 1.4f; BeginPursuitReposition("movement stalled"); return true; } private bool TryRefreshAttackPath(PlayerControllerB target) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target == (Object)null || (Object)(object)base.agent == (Object)null || !((Behaviour)base.agent).enabled || !base.agent.isOnNavMesh) { return false; } if (!TrySampleNavPosition(((Component)target).transform.position, 4f, out var position)) { position = ((Component)target).transform.position; } base.targetPlayer = target; base.movingTowardsTargetPlayer = true; base.moveTowardsDestination = false; base.agent.isStopped = false; base.agent.ResetPath(); ((EnemyAI)this).SetMovingTowardsTargetPlayer(target); bool num = base.agent.SetDestination(position); if (num && DebugLogs) { ManualLogSource log = Plugin.Log; if (log == null) { return num; } log.LogInfo((object)"[DreadweaverAI] Refreshed attack path before falling back to camo reposition."); } return num; } private bool TryRepairAgentOntoNavMesh() { //IL_0022: 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_0046: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)base.agent == (Object)null) { return false; } int areaMask = base.agent.areaMask; NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(((Component)this).transform.position, ref val, 5f, areaMask)) { return false; } MoveRootTo(((NavMeshHit)(ref val)).position, ((Component)this).transform.rotation); if (((Behaviour)base.agent).enabled) { return base.agent.isOnNavMesh; } return false; } private bool TrySampleNavPosition(Vector3 origin, float radius, out Vector3 position) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) int num = (((Object)(object)base.agent != (Object)null) ? base.agent.areaMask : (-1)); NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(origin, ref val, Mathf.Max(0.5f, radius), num) && TryResolveClearNavPosition(((NavMeshHit)(ref val)).position, Mathf.Max(1f, radius), out position)) { return true; } position = Vector3.zero; return false; } private bool TryResolveClearNavPosition(Vector3 origin, float searchRadius, out Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) GetPlacementCapsule(origin, out var _, out var _, out var radius); if (HasPlacementClearance(origin)) { position = origin; return true; } int num = (((Object)(object)base.agent != (Object)null) ? base.agent.areaMask : (-1)); float num2 = Mathf.Clamp(Mathf.Max(searchRadius, radius * 2.5f), 1.25f, 7f); NavMeshHit val = default(NavMeshHit); for (int i = 0; i < 3; i++) { float num3 = Mathf.Lerp(0.75f, num2, ((float)i + 1f) / 3f); for (int j = 0; j < 8; j++) { float num4 = (float)j / 8f * MathF.PI * 2f + (float)i * 0.37f; if (NavMesh.SamplePosition(origin + new Vector3(Mathf.Cos(num4), 0f, Mathf.Sin(num4)) * num3, ref val, Mathf.Max(1.25f, radius * 0.85f), num) && HasPlacementClearance(((NavMeshHit)(ref val)).position)) { position = ((NavMeshHit)(ref val)).position; return true; } } } position = Vector3.zero; return false; } private bool HasPlacementClearance(Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) GetPlacementCapsule(position, out var bottom, out var top, out var radius); int num = ResolveLineOfSightMask(); int num2 = Physics.OverlapCapsuleNonAlloc(bottom, top, radius, _placementColliders, num, (QueryTriggerInteraction)1); for (int i = 0; i < num2; i++) { Collider val = _placementColliders[i]; _placementColliders[i] = null; if (!((Object)(object)val == (Object)null) && !val.isTrigger) { Transform transform = ((Component)val).transform; if (!((Object)(object)transform != (Object)null) || !transform.IsChildOf(((Component)this).transform)) { return false; } } } return true; } private void GetPlacementCapsule(Vector3 rootPosition, out Vector3 bottom, out Vector3 top, out float radius) { //IL_014e: 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_0167: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_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_0039: 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_006c: 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) //IL_009c: 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_00e6: 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_00f2: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) CapsuleCollider component = ((Component)this).GetComponent(); if ((Object)(object)component != (Object)null && component.direction == 1) { Vector3 lossyScale = ((Component)component).transform.lossyScale; radius = Mathf.Max(0.1f, component.radius * Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.z))); float num = Mathf.Max(radius * 2f, component.height * Mathf.Abs(lossyScale.y)); float num2 = ((Component)component).transform.TransformPoint(component.center).y - ((Component)this).transform.position.y; float num3 = Mathf.Max(0f, num * 0.5f - radius); float num4 = Mathf.Max(radius + 0.12f, num2 - num3); float num5 = Mathf.Max(num4, num2 + num3); bottom = rootPosition + Vector3.up * num4; top = rootPosition + Vector3.up * num5; } else { float horizontalWorldScale = GetHorizontalWorldScale(); float verticalWorldScale = GetVerticalWorldScale(); radius = Mathf.Max(0.1f, 0.82f * horizontalWorldScale); float num6 = Mathf.Max(radius * 2f, 2.45f * verticalWorldScale); bottom = rootPosition + Vector3.up * (radius + 0.12f); top = rootPosition + Vector3.up * Mathf.Max(radius + 0.12f, num6 - radius + 0.12f); } } private bool HasShortCompletePath(Vector3 start, Vector3 destination, float maxPathLength) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) NavMeshPath val = new NavMeshPath(); int num = (((Object)(object)base.agent != (Object)null) ? base.agent.areaMask : (-1)); if (!NavMesh.CalculatePath(start, destination, num, val) || (int)val.status != 0) { return false; } Vector3[] corners = val.corners; if (corners == null || corners.Length < 2) { return Vector3.Distance(start, destination) <= maxPathLength; } float num2 = 0f; for (int i = 1; i < corners.Length; i++) { num2 += Vector3.Distance(corners[i - 1], corners[i]); if (num2 > maxPathLength) { return false; } } return true; } private void TeleportFacing(Vector3 position, Vector3 lookAtPoint) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_003f: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) position = ResolveRootPlacement(position); Vector3 val = lookAtPoint - position; val.y = 0f; Quaternion rotation = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up) : ((Component)this).transform.rotation); ApplyRootTransform(position, rotation); } private void MoveRootTo(Vector3 position, Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) ApplyRootTransform(ResolveRootPlacement(position), rotation); } private Vector3 ResolveRootPlacement(Vector3 position) { //IL_0001: 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_000a: 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_002b: Unknown result type (might be due to invalid IL or missing references) if (!HasPlacementClearance(position) && TryResolveClearNavPosition(position, Mathf.Max(3.5f, GetHorizontalWorldScale() * 2f), out var position2)) { position = position2; } return position; } private void ApplyRootTransform(Vector3 position, Quaternion rotation) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.SetPositionAndRotation(position, rotation); base.serverPosition = position; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled) { base.agent.Warp(position); } if (((NetworkBehaviour)this).IsServer && CanSendRpc) { _lastPublishedFacingYaw = ((Quaternion)(ref rotation)).eulerAngles.y; _networkFacingYaw.Value = _lastPublishedFacingYaw; } if (CanSendRpc) { TeleportClientRpc(position, rotation); } } private void FacePosition(Vector3 point, float maxDegrees) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_003e: 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_005c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = point - ((Component)this).transform.position; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude < 0.001f)) { Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val2, Mathf.Max(1f, maxDegrees)); } } private void FaceTargetForStalking(PlayerControllerB target) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)target == (Object)null)) { FacePosition(GetPlayerFocusPoint(target), 36000f); } } private void SetStateServer(int state) { SetStateLocal(state); if (((NetworkBehaviour)this).IsServer && CanSendRpc) { _networkState.Value = state; } if (CanSendRpc) { SetStateClientRpc(state); } if (((NetworkBehaviour)this).IsServer && _logicalVisible && _spotlightActive) { RefreshCreatureSpotlightServer(); } } private void SetStateLocal(int state) { if (base.currentBehaviourStateIndex != state) { base.previousBehaviourStateIndex = base.currentBehaviourStateIndex; base.currentBehaviourStateIndex = state; if (base.enemyBehaviourStates != null && state >= 0 && state < base.enemyBehaviourStates.Length) { base.currentBehaviourState = base.enemyBehaviourStates[state]; } } } private void StopManagedRoutines() { if (_attackRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_attackRoutine); _attackRoutine = null; _isAttackAnimating = false; _resolvePostTargetDownAfterSwing = false; } if (_sightingExitRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_sightingExitRoutine); _sightingExitRoutine = null; } if (_camoPreviewRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_camoPreviewRoutine); _camoPreviewRoutine = null; SetCamoShellsShown(shown: false); } if (_reengageCueRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_reengageCueRoutine); _reengageCueRoutine = null; } if (_stalkDoorSlamRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_stalkDoorSlamRoutine); _stalkDoorSlamRoutine = null; TriggerDoorSlamClosed(_stalkDoorSlamDoor); _stalkDoorSlamDoor = null; } StopLocalLightFlicker(); _isEndingSighting = false; } private void StopSearchIfNeeded() { if (base.currentSearch != null && base.currentSearch.inProgress) { ((EnemyAI)this).StopSearch(base.currentSearch, true); } base.movingTowardsTargetPlayer = false; base.moveTowardsDestination = false; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && base.agent.isOnNavMesh) { base.agent.ResetPath(); } } private void RepairFacilityAINodes() { if (base.allAINodes == null || base.allAINodes.Length == 0) { GameObject[] array = null; if ((Object)(object)RoundManager.Instance != (Object)null) { array = RoundManager.Instance.insideAINodes; } if (array == null || array.Length == 0) { array = GameObject.FindGameObjectsWithTag("AINode"); } base.allAINodes = (GameObject[])(((object)array) ?? ((object)new GameObject[0])); } } private int ResolveLineOfSightMask() { if ((Object)(object)StartOfRound.Instance != (Object)null) { return StartOfRound.Instance.collidersAndRoomMaskAndDefault; } return -1; } private void ApplyNetworkSnapshotLocal(bool force = false) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0037: 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_004f: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsSpawned || ((NetworkBehaviour)this).IsServer) { return; } Vector3 value = _networkModelScale.Value; Vector3 val; if (value.x > 0.01f && value.y > 0.01f && value.z > 0.01f) { val = ((Component)this).transform.localScale - value; if (((Vector3)(ref val)).sqrMagnitude > 0.0001f) { ((Component)this).transform.localScale = value; } } ulong value2 = _networkTargetClientId.Value; if (force || _targetClientId != value2 || (Object)(object)base.targetPlayer == (Object)null) { _targetClientId = value2; base.targetPlayer = ResolveTargetById(value2); } int value3 = _networkState.Value; if (force || base.currentBehaviourStateIndex != value3) { SetStateLocal(value3); } _stage = (SightingStage)Mathf.Clamp(_networkStage.Value, 0, 2); _pendingPresentation = (SightingPresentation)Mathf.Clamp(_networkPresentation.Value, 0, 2); if (_appliedVisSeq < 0) { ApplyVisibility(_networkVisible.Value, _networkVisibilitySequence.Value, 0f); } int value4 = _networkAnimationCode.Value; if (force || _currentAnimationCode != value4) { PlayAnimationLocal(value4, 0.18f, _networkAnimationNormalizedTime.Value); } int value5 = _networkRevealSequence.Value; if (_clientAppliedRevealSequence != value5) { _clientAppliedRevealSequence = value5; if (value5 > 0 && _networkVisible.Value) { ((Component)this).transform.position = _networkRevealPosition.Value; base.serverPosition = _networkRevealPosition.Value; _presentationReadyAt = Time.time + Mathf.Max(0f, _networkPresentationReadyDelay.Value); _clientFacingLockUntil = Time.time + Mathf.Max(0.75f, _networkFacingLockDuration.Value); } } bool value6 = _networkSpotlightActive.Value; float value7 = _networkSpotlightIntensity.Value; float value8 = _networkSpotlightAngle.Value; float value9 = _networkSpotlightRange.Value; float value10 = _networkSpotlightHeight.Value; Vector3 value11 = _networkSpotlightColor.Value; if (!force && _spotlightActive == value6 && !(Mathf.Abs(_spotlightIntensity - value7) > 0.01f) && !(Mathf.Abs(_spotlightAngle - value8) > 0.01f) && !(Mathf.Abs(_spotlightRange - value9) > 0.01f) && !(Mathf.Abs(_spotlightHeight - value10) > 0.01f)) { val = _spotlightColor - value11; if (!(((Vector3)(ref val)).sqrMagnitude > 0.0001f)) { return; } } _spotlightActive = value6; _spotlightIntensity = value7; _spotlightAngle = value8; _spotlightRange = value9; _spotlightHeight = value10; _spotlightColor = value11; ApplyCreatureSpotlight(value6, value7, value8, value9, value10, value11); } private void ApplyReplicatedFacingLocal() { //IL_003b: 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_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_0078: 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) if (!((NetworkBehaviour)this).IsServer && ((NetworkBehaviour)this).IsSpawned && _logicalVisible && UsesReplicatedFacing(base.currentBehaviourStateIndex)) { Quaternion val = Quaternion.Euler(0f, _networkFacingYaw.Value, 0f); if (Time.time < _clientFacingLockUntil) { ((Component)this).transform.rotation = val; } else { ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val, 540f * Time.deltaTime); } } } private static bool UsesReplicatedFacing(int state) { if (state != 2 && state != 6 && state != 7) { return state == 9; } return true; } private void PublishAuthoritativePresentationServer(bool force = false) { //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsServer || !CanSendRpc) { return; } if (force) { _networkState.Value = base.currentBehaviourStateIndex; _networkTargetClientId.Value = _targetClientId; _networkStage.Value = (int)_stage; _networkPresentation.Value = (int)_pendingPresentation; _networkAnimationCode.Value = ((_currentAnimationCode != int.MinValue) ? _currentAnimationCode : 0); _networkAnimationNormalizedTime.Value = _currentAnimationNormalizedTime; _networkRevealPosition.Value = ((Component)this).transform.position; _networkFacingLockDuration.Value = 0.8f; _networkPresentationReadyDelay.Value = Mathf.Max(0f, _presentationReadyAt - Time.time); _networkModelScale.Value = ((Component)this).transform.localScale; _networkVisible.Value = _logicalVisible; _networkVisibilitySequence.Value = _visSeq; _networkSpotlightActive.Value = _spotlightActive; _networkSpotlightIntensity.Value = _spotlightIntensity; _networkSpotlightAngle.Value = _spotlightAngle; _networkSpotlightRange.Value = _spotlightRange; _networkSpotlightHeight.Value = _spotlightHeight; _networkSpotlightColor.Value = _spotlightColor; } float y = ((Component)this).transform.eulerAngles.y; bool flag = Mathf.Abs(Mathf.DeltaAngle(_lastPublishedFacingYaw, y)) >= 1.25f; bool flag2 = force || Time.time >= _nextPresentationSyncTime; if (force || (flag2 && flag)) { _lastPublishedFacingYaw = y; _networkFacingYaw.Value = y; } if (flag2) { _nextPresentationSyncTime = Time.time + 0.08f; float num; if (!((Object)(object)base.agent != (Object)null) || !((Behaviour)base.agent).enabled || base.agent.isStopped) { num = 0f; } else { Vector3 velocity = base.agent.velocity; num = ((Vector3)(ref velocity)).magnitude; } float num2 = num; float num3 = CalculateLocomotionPlayback(num2); if (force || Mathf.Abs(_lastPublishedMovementSpeed - num2) >= 0.04f) { _lastPublishedMovementSpeed = num2; _networkMovementSpeed.Value = num2; } if (force || Mathf.Abs(_lastPublishedLocomotionPlayback - num3) >= 0.025f) { _lastPublishedLocomotionPlayback = num3; _networkLocomotionPlayback.Value = num3; } } } private float CalculateLocomotionPlayback(float movementSpeed) { if (!MatchAnimationToMovement || _isAttackAnimating || _isHitStaggering || !IsLocomotionState(base.currentBehaviourStateIndex) || movementSpeed <= 0.05f) { return 1f; } float authoredLocomotionSpeed = GetAuthoredLocomotionSpeed(); float num = ((base.currentBehaviourStateIndex == 7) ? 1.9f : 1.35f); return Mathf.Clamp(movementSpeed / authoredLocomotionSpeed, 0.7f, num); } private void PlayAnimationServer(int animationCode, float fade, float normalizedTime) { PlayAnimationLocal(animationCode, fade, normalizedTime); if (((NetworkBehaviour)this).IsServer && CanSendRpc) { _networkAnimationCode.Value = animationCode; _networkAnimationNormalizedTime.Value = Mathf.Clamp01(normalizedTime); if (!IsFootstepAnimation(ResolveAnimationStateName(animationCode))) { _lastPublishedMovementSpeed = 0f; _networkMovementSpeed.Value = 0f; _lastPublishedLocomotionPlayback = 1f; _networkLocomotionPlayback.Value = 1f; } } if (CanSendRpc) { PlayAnimationClientRpc(animationCode, fade, normalizedTime); } } private void PlayAnimationLocal(int animationCode, float fade, float normalizedTime) { if ((Object)(object)visualAnimator == (Object)null) { return; } string text = ResolveAnimationStateName(animationCode); if (string.IsNullOrEmpty(text)) { return; } _currentAnimationCode = animationCode; _currentAnimationNormalizedTime = Mathf.Clamp01(normalizedTime); if (!string.Equals(_currentAnimationName, text, StringComparison.Ordinal) || (!IsLoopingAnimation(animationCode) && !(Time.time < _lastLocalMovementAnimTime + 0.5f))) { _currentAnimationName = text; _lastLocalMovementAnimTime = Time.time; if (animationCode > 20 && animationCode < 30) { _animationLockUntil = Time.time + Mathf.Max(0.75f, GetAttackAnimationDuration(animationCode) * 0.92f); } else if (animationCode == 40 || animationCode == 41 || animationCode == 50 || animationCode == 51 || animationCode == 18) { _animationLockUntil = Time.time + 0.9f; } visualAnimator.applyRootMotion = false; if (!IsFootstepAnimation(text)) { visualAnimator.speed = 1f; } visualAnimator.CrossFadeInFixedTime(text, Mathf.Max(0.02f, fade), 0, Mathf.Clamp01(normalizedTime)); } } private void TickAuthoritativeLocomotionAnimation() { //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) if (!((NetworkBehaviour)this).IsServer || (Object)(object)visualAnimator == (Object)null || Time.time < _animationLockUntil) { return; } float num; if (!((Object)(object)base.agent != (Object)null) || !((Behaviour)base.agent).enabled) { num = 0f; } else { Vector3 velocity = base.agent.velocity; num = ((Vector3)(ref velocity)).sqrMagnitude; } float num2 = num; bool flag = (Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled && !base.agent.isStopped && base.agent.hasPath && !base.agent.pathPending && base.agent.remainingDistance > base.agent.stoppingDistance + 0.5f; if (_locomotionMoving) { if (num2 < 0.02f && !flag) { _locomotionMoving = false; } } else if (num2 > 0.09f || flag) { _locomotionMoving = true; } bool locomotionMoving = _locomotionMoving; switch (base.currentBehaviourStateIndex) { case 7: EnsureLocomotionAnimationServer((!locomotionMoving) ? 1 : 10); break; case 6: EnsureLocomotionAnimationServer(locomotionMoving ? _attackAdvanceAnimation : 0); break; } } private void EnsureLocomotionAnimationServer(int animationCode) { if (!_isAttackAnimating && _currentAnimationCode != animationCode) { PlayAnimationServer(animationCode, 0.16f, 0f); } } private void TickAnimatorPlaybackSpeed() { //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) if ((Object)(object)visualAnimator == (Object)null || _damageStunFrozen) { return; } float num; if (!((NetworkBehaviour)this).IsServer) { num = _networkLocomotionPlayback.Value; } else { float movementSpeed; if (!((Object)(object)base.agent != (Object)null) || !((Behaviour)base.agent).enabled) { movementSpeed = 0f; } else { Vector3 velocity = base.agent.velocity; movementSpeed = ((Vector3)(ref velocity)).magnitude; } num = CalculateLocomotionPlayback(movementSpeed); } float num2 = num; visualAnimator.speed = Mathf.MoveTowards(visualAnimator.speed, num2, Time.deltaTime * 4f); } private void TickLocalFootsteps() { //IL_0078: 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) if (!_logicalVisible || base.isEnemyDead || (Object)(object)visualAnimator == (Object)null || (Object)(object)base.creatureSFX == (Object)null || footstepClips == null || footstepClips.Length == 0 || !IsFootstepAnimation(_currentAnimationName) || visualAnimator.IsInTransition(0) || _networkMovementSpeed.Value < 0.2f) { ResetFootstepTracking(); return; } AnimatorStateInfo currentAnimatorStateInfo = visualAnimator.GetCurrentAnimatorStateInfo(0); float num = Mathf.Max(0f, ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime); int fullPathHash = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash; int num2 = Mathf.FloorToInt((num + 0.92f) * 2f); if (_footstepAnimatorStateHash != fullPathHash || _footstepTick == int.MinValue || num + 0.01f < _lastFootstepNormalizedTime) { _footstepAnimatorStateHash = fullPathHash; _footstepTick = num2; _lastFootstepNormalizedTime = num; return; } _lastFootstepNormalizedTime = num; if (num2 > _footstepTick) { _footstepTick = num2; PlayFootstepLocal(); } } private static bool IsFootstepAnimation(string stateName) { if (stateName != null) { int length = stateName.Length; if (length <= 5) { if (length != 3) { if (length == 5) { char c = stateName[4]; if (c != '1') { if (c != '2') { if (c == 'l' && stateName == "Crawl") { goto IL_00ed; } } else if (stateName == "Walk2") { goto IL_00ed; } } else if (stateName == "Walk1") { goto IL_00ed; } } } else if (stateName == "Run") { goto IL_00ed; } } else if (length != 9) { if (length == 10) { char c = stateName[5]; if (c != 'L') { if (c == 'R' && stateName == "Walk_Right") { goto IL_00ed; } } else if (stateName == "Walk_Left2") { goto IL_00ed; } } } else { char c = stateName[5]; if (c != 'B') { if (c == 'L' && stateName == "Walk_Left") { goto IL_00ed; } } else if (stateName == "Walk_Back") { goto IL_00ed; } } } return false; IL_00ed: return true; } private void PlayFootstepLocal() { int num = Random.Range(0, footstepClips.Length); if (footstepClips.Length > 1 && num == _lastFootstepClipIndex) { num = (num + Random.Range(1, footstepClips.Length)) % footstepClips.Length; } AudioClip val = footstepClips[num]; if (!((Object)(object)val == (Object)null)) { _lastFootstepClipIndex = num; base.creatureSFX.PlayOneShot(val, 0.8f); } } private void ResetFootstepTracking() { _footstepAnimatorStateHash = 0; _footstepTick = int.MinValue; _lastFootstepNormalizedTime = 0f; } private static bool IsLocomotionState(int state) { if (state != 7) { return state == 6; } return true; } private float GetAuthoredLocomotionSpeed() { switch (base.currentBehaviourStateIndex) { case 7: return AuthoredRunSpeed; case 6: if (_attackAdvanceAnimation != 11) { return AuthoredWalkSpeed; } return AuthoredCrawlSpeed; default: return AuthoredWalkSpeed; } } private static bool IsLoopingAnimation(int animationCode) { if ((uint)animationCode <= 11u) { return true; } return false; } private static string ResolveAnimationStateName(int animationCode) { switch (animationCode) { case 0: return "Idle1"; case 1: return "Idle2"; case 2: return "Idle3"; case 3: return "Idle4"; case 4: return "Walk1"; case 5: return "Walk2"; case 6: return "Walk_Back"; case 7: return "Walk_Left"; case 8: return "Walk_Left2"; case 9: return "Walk_Right"; case 10: return "Run"; case 11: return "Crawl"; case 12: return "Dodge_Left"; case 13: return "Dodge_Right"; case 14: return "Dodge_Forward"; case 15: return "Dodge_Backward"; case 16: return "Turn_Left"; case 17: return "Turn_Right"; case 18: return "Weave_of_Fear"; case 40: return "Taking_Damage1"; case 41: return "Taking_Damage2"; case 50: return "Death1"; case 51: return "Death2"; default: if (animationCode > 20 && animationCode < 30) { return "Attack" + (animationCode - 20); } return null; } } private void TickLocalFear() { PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); if ((Object)(object)val == (Object)null || val.isPlayerDead || _targetClientId == ulong.MaxValue || (val.actualClientId != _targetClientId && val.playerClientId != _targetClientId) || Time.time < _nextLocalFearTime) { return; } _nextLocalFearTime = Time.time + 0.75f; try { if (base.currentBehaviourStateIndex == 7 || base.currentBehaviourStateIndex == 6) { val.JumpToFearLevel(0.72f, true); } else if (base.currentBehaviourStateIndex == 2 && _renderersShown) { val.IncreaseFearLevelOverTime(0.9f, 0.6f); } } catch { } } private void PlayStalkingRevealSoundLocal(int clipIndex, Vector3 worldPosition, float volume) { //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_004e: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown AudioClip val = null; if (spotClips != null && clipIndex >= 0 && clipIndex < spotClips.Length) { val = spotClips[clipIndex]; } if ((Object)(object)val == (Object)null) { val = spottedClip; } if (!((Object)(object)val == (Object)null)) { GameObject val2 = new GameObject("DreadweaverSpotStinger") { hideFlags = (HideFlags)52 }; val2.transform.position = worldPosition; AudioSource obj = val2.AddComponent(); obj.playOnAwake = false; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = 2.5f; obj.maxDistance = 38f; obj.dopplerLevel = 0f; obj.spread = 0f; obj.priority = 64; obj.PlayOneShot(val, Mathf.Clamp01(volume)); Object.Destroy((Object)val2, Mathf.Max(0.25f, val.length + 0.25f)); } } private static AudioClip GetDirectionalCamoCue() { if ((Object)(object)_directionalCamoCue != (Object)null) { return _directionalCamoCue; } int num = Mathf.CeilToInt(7497f); float[] array = new float[num]; Random random = new Random(1297565014); float num2 = 0f; for (int i = 0; i < num; i++) { float num3 = Mathf.Clamp01((float)i / 22050f / 0.34f); float num4 = Mathf.Sin(num3 * MathF.PI); num4 *= num4 * Mathf.Exp((0f - num3) * 1.8f); float num5 = Mathf.Lerp(1050f, 170f, num3); num2 += MathF.PI * 2f * num5 / 22050f; float num6 = Mathf.Sin(num2) * 0.42f; float num7 = ((float)random.NextDouble() * 2f - 1f) * 0.58f; array[i] = Mathf.Clamp((num6 + num7) * num4 * 0.38f, -0.8f, 0.8f); } _directionalCamoCue = AudioClip.Create("Dreadweaver_DirectionalCamo", num, 1, 22050, false); _directionalCamoCue.SetData(array, 0); return _directionalCamoCue; } private void ResolveReferences() { if ((Object)(object)base.agent == (Object)null) { base.agent = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren(true); } if ((Object)(object)visualAnimator == (Object)null) { visualAnimator = (((Object)(object)base.creatureAnimator != (Object)null) ? base.creatureAnimator : (((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren(true))); } if ((Object)(object)base.creatureSFX == (Object)null) { base.creatureSFX = FindAudioSource("CreatureSFX"); } if ((Object)(object)base.creatureVoice == (Object)null) { base.creatureVoice = FindAudioSource("CreatureVoice") ?? base.creatureSFX; } if ((Object)(object)base.eye == (Object)null) { base.eye = ((Component)this).transform.Find("EyeTransform") ?? ((Component)this).transform; } if ((Object)(object)attackOrigin == (Object)null) { attackOrigin = ((Component)this).transform.Find("AttackOrigin") ?? ((Component)this).transform; } } private AudioSource FindAudioSource(string childName) { Transform val = ((Component)this).transform.Find(childName); if (!((Object)(object)val != (Object)null)) { return null; } return ((Component)val).GetComponent(); } private void OnDisable() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) if (_flickerRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_flickerRoutine); _flickerRoutine = null; } if (_camoPreviewRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_camoPreviewRoutine); _camoPreviewRoutine = null; } if (_stalkDoorSlamRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_stalkDoorSlamRoutine); _stalkDoorSlamRoutine = null; TriggerDoorSlamClosed(_stalkDoorSlamDoor); _stalkDoorSlamDoor = null; } StopLocalLightFlicker(); StopFlashlightHarass(); _spotlightActive = false; ApplyCreatureSpotlight(active: false, 0f, 0f, 0f, 0f, Vector3.zero); _isEndingSighting = false; ResetFootstepTracking(); SetCamoShellsShown(shown: false); SetRenderersShown(shown: true); SetCollidersEnabled(enabled: true); } public override void OnDestroy() { ((EnemyAI)this).OnDestroy(); } [ClientRpc] private void SyncTargetClientRpc(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) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1561710965u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, clientId); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1561710965u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; _targetClientId = clientId; base.targetPlayer = ResolveTargetById(clientId); } } } [ClientRpc] private void SetStateClientRpc(int state) { //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) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2670048099u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, state); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2670048099u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; SetStateLocal(state); } } } [ClientRpc] private void PlayAnimationClientRpc(int animationCode, float fade, float normalizedTime) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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(2825695446u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, animationCode); ((FastBufferWriter)(ref val)).WriteValueSafe(ref fade, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref normalizedTime, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2825695446u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; PlayAnimationLocal(animationCode, fade, normalizedTime); } } } [ClientRpc] private void SetVisibilityClientRpc(bool visible, int sequence, float flickerSeconds) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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(1341084309u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref visible, default(ForPrimitives)); BytePacker.WriteValueBitPacked(val, sequence); ((FastBufferWriter)(ref val)).WriteValueSafe(ref flickerSeconds, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1341084309u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ApplyVisibility(visible, sequence, flickerSeconds); } } } [ClientRpc] private void StartCamoPreviewClientRpc(float duration) { //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) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3665063338u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref duration, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 3665063338u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; StartCamoPreview(duration); } } } [ClientRpc] private void TriggerStalkLightFlickerClientRpc(Vector3 targetCenter, Vector3 creatureCenter, float radius, int seed, float duration) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_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_00a6: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0125: 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(2228030270u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref targetCenter); ((FastBufferWriter)(ref val)).WriteValueSafe(ref creatureCenter); ((FastBufferWriter)(ref val)).WriteValueSafe(ref radius, default(ForPrimitives)); BytePacker.WriteValueBitPacked(val, seed); ((FastBufferWriter)(ref val)).WriteValueSafe(ref duration, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2228030270u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; StartStalkLightFlicker(targetCenter, creatureCenter, radius, seed, duration); } } } [ClientRpc] private void ResyncVisibilityClientRpc(bool visible, int sequence) { //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_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_008c: 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) 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(1147045660u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref visible, default(ForPrimitives)); BytePacker.WriteValueBitPacked(val, sequence); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1147045660u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (sequence != _appliedVisSeq) { ApplyVisibility(visible, sequence, 0f); } } } [ClientRpc] private void TeleportClientRpc(Vector3 position, Quaternion rotation) { //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_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) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0115: 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(1055467347u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref position); ((FastBufferWriter)(ref val)).WriteValueSafe(ref rotation); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1055467347u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ((Component)this).transform.SetPositionAndRotation(position, rotation); base.serverPosition = position; if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled) { base.agent.Warp(position); } } } [ClientRpc] private void SetCreatureSpotlightClientRpc(bool active, float intensity, float angle, float range, float height, Vector3 color) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00d4: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) 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(3663652314u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref active, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref intensity, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref angle, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref range, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref height, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref color); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 3663652314u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; _spotlightActive = active; _spotlightIntensity = intensity; _spotlightAngle = angle; _spotlightRange = range; _spotlightHeight = height; _spotlightColor = color; ApplyCreatureSpotlight(active, intensity, angle, range, height, color); } } } [ClientRpc] private void FlashlightHarassClientRpc(ulong targetClientId, int seed, float duration) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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(2980217333u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, targetClientId); BytePacker.WriteValueBitPacked(val, seed); ((FastBufferWriter)(ref val)).WriteValueSafe(ref duration, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2980217333u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; TryStartFlashlightHarass(targetClientId, seed, duration); } } } [ClientRpc] private void PlayStalkingRevealSoundClientRpc(int clipIndex, Vector3 worldPosition, float volume) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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(3476069871u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, clipIndex); ((FastBufferWriter)(ref val)).WriteValueSafe(ref worldPosition); ((FastBufferWriter)(ref val)).WriteValueSafe(ref volume, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 3476069871u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; PlayStalkingRevealSoundLocal(clipIndex, worldPosition, volume); } } } [ClientRpc] private void PlayOneShotClientRpc(int clipId, float volume) { //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) 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(2220773483u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, clipId); ((FastBufferWriter)(ref val)).WriteValueSafe(ref volume, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2220773483u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; AudioClip val3 = null; AudioSource val4 = base.creatureSFX; switch (clipId) { case 0: val3 = spottedClip; val4 = base.creatureVoice; break; case 1: val3 = vanishClip; break; case 2: val3 = decloakClip; val4 = base.creatureVoice; break; case 3: val3 = (((Object)(object)initialAttackClip != (Object)null) ? initialAttackClip : attackClip); val4 = (((Object)(object)base.creatureVoice != (Object)null) ? base.creatureVoice : base.creatureSFX); break; case 4: val3 = hitClip; break; case 5: val3 = GetDirectionalCamoCue(); val4 = base.creatureSFX; break; } if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null) { val4.PlayOneShot(val3, Mathf.Clamp01(volume)); } } } protected override void __initializeVariables() { if (_networkState == null) { throw new Exception("DreadweaverAI._networkState cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkState).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkState, "_networkState"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkState); if (_networkTargetClientId == null) { throw new Exception("DreadweaverAI._networkTargetClientId cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkTargetClientId).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkTargetClientId, "_networkTargetClientId"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkTargetClientId); if (_networkStage == null) { throw new Exception("DreadweaverAI._networkStage cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkStage).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkStage, "_networkStage"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkStage); if (_networkPresentation == null) { throw new Exception("DreadweaverAI._networkPresentation cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkPresentation).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkPresentation, "_networkPresentation"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkPresentation); if (_networkAnimationCode == null) { throw new Exception("DreadweaverAI._networkAnimationCode cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkAnimationCode).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkAnimationCode, "_networkAnimationCode"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkAnimationCode); if (_networkAnimationNormalizedTime == null) { throw new Exception("DreadweaverAI._networkAnimationNormalizedTime cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkAnimationNormalizedTime).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkAnimationNormalizedTime, "_networkAnimationNormalizedTime"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkAnimationNormalizedTime); if (_networkVisible == null) { throw new Exception("DreadweaverAI._networkVisible cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkVisible).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkVisible, "_networkVisible"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkVisible); if (_networkVisibilitySequence == null) { throw new Exception("DreadweaverAI._networkVisibilitySequence cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkVisibilitySequence).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkVisibilitySequence, "_networkVisibilitySequence"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkVisibilitySequence); if (_networkFacingYaw == null) { throw new Exception("DreadweaverAI._networkFacingYaw cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkFacingYaw).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkFacingYaw, "_networkFacingYaw"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkFacingYaw); if (_networkRevealSequence == null) { throw new Exception("DreadweaverAI._networkRevealSequence cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkRevealSequence).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkRevealSequence, "_networkRevealSequence"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkRevealSequence); if (_networkRevealPosition == null) { throw new Exception("DreadweaverAI._networkRevealPosition cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkRevealPosition).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkRevealPosition, "_networkRevealPosition"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkRevealPosition); if (_networkFacingLockDuration == null) { throw new Exception("DreadweaverAI._networkFacingLockDuration cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkFacingLockDuration).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkFacingLockDuration, "_networkFacingLockDuration"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkFacingLockDuration); if (_networkPresentationReadyDelay == null) { throw new Exception("DreadweaverAI._networkPresentationReadyDelay cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkPresentationReadyDelay).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkPresentationReadyDelay, "_networkPresentationReadyDelay"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkPresentationReadyDelay); if (_networkModelScale == null) { throw new Exception("DreadweaverAI._networkModelScale cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkModelScale).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkModelScale, "_networkModelScale"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkModelScale); if (_networkMovementSpeed == null) { throw new Exception("DreadweaverAI._networkMovementSpeed cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkMovementSpeed).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkMovementSpeed, "_networkMovementSpeed"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkMovementSpeed); if (_networkLocomotionPlayback == null) { throw new Exception("DreadweaverAI._networkLocomotionPlayback cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkLocomotionPlayback).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkLocomotionPlayback, "_networkLocomotionPlayback"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkLocomotionPlayback); if (_networkSpotlightActive == null) { throw new Exception("DreadweaverAI._networkSpotlightActive cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkSpotlightActive).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkSpotlightActive, "_networkSpotlightActive"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkSpotlightActive); if (_networkSpotlightIntensity == null) { throw new Exception("DreadweaverAI._networkSpotlightIntensity cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkSpotlightIntensity).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkSpotlightIntensity, "_networkSpotlightIntensity"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkSpotlightIntensity); if (_networkSpotlightAngle == null) { throw new Exception("DreadweaverAI._networkSpotlightAngle cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkSpotlightAngle).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkSpotlightAngle, "_networkSpotlightAngle"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkSpotlightAngle); if (_networkSpotlightRange == null) { throw new Exception("DreadweaverAI._networkSpotlightRange cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkSpotlightRange).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkSpotlightRange, "_networkSpotlightRange"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkSpotlightRange); if (_networkSpotlightHeight == null) { throw new Exception("DreadweaverAI._networkSpotlightHeight cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkSpotlightHeight).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkSpotlightHeight, "_networkSpotlightHeight"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkSpotlightHeight); if (_networkSpotlightColor == null) { throw new Exception("DreadweaverAI._networkSpotlightColor cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_networkSpotlightColor).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_networkSpotlightColor, "_networkSpotlightColor"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)_networkSpotlightColor); ((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 //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(2181752049u, new RpcReceiveHandler(__rpc_handler_2181752049), "ApplyAttackDamageClientRpc"); ((NetworkBehaviour)this).__registerRpc(2785260190u, new RpcReceiveHandler(__rpc_handler_2785260190), "ReportTargetDownServerRpc"); ((NetworkBehaviour)this).__registerRpc(1561710965u, new RpcReceiveHandler(__rpc_handler_1561710965), "SyncTargetClientRpc"); ((NetworkBehaviour)this).__registerRpc(2670048099u, new RpcReceiveHandler(__rpc_handler_2670048099), "SetStateClientRpc"); ((NetworkBehaviour)this).__registerRpc(2825695446u, new RpcReceiveHandler(__rpc_handler_2825695446), "PlayAnimationClientRpc"); ((NetworkBehaviour)this).__registerRpc(1341084309u, new RpcReceiveHandler(__rpc_handler_1341084309), "SetVisibilityClientRpc"); ((NetworkBehaviour)this).__registerRpc(3665063338u, new RpcReceiveHandler(__rpc_handler_3665063338), "StartCamoPreviewClientRpc"); ((NetworkBehaviour)this).__registerRpc(2228030270u, new RpcReceiveHandler(__rpc_handler_2228030270), "TriggerStalkLightFlickerClientRpc"); ((NetworkBehaviour)this).__registerRpc(1147045660u, new RpcReceiveHandler(__rpc_handler_1147045660), "ResyncVisibilityClientRpc"); ((NetworkBehaviour)this).__registerRpc(1055467347u, new RpcReceiveHandler(__rpc_handler_1055467347), "TeleportClientRpc"); ((NetworkBehaviour)this).__registerRpc(3663652314u, new RpcReceiveHandler(__rpc_handler_3663652314), "SetCreatureSpotlightClientRpc"); ((NetworkBehaviour)this).__registerRpc(2980217333u, new RpcReceiveHandler(__rpc_handler_2980217333), "FlashlightHarassClientRpc"); ((NetworkBehaviour)this).__registerRpc(3476069871u, new RpcReceiveHandler(__rpc_handler_3476069871), "PlayStalkingRevealSoundClientRpc"); ((NetworkBehaviour)this).__registerRpc(2220773483u, new RpcReceiveHandler(__rpc_handler_2220773483), "PlayOneShotClientRpc"); ((EnemyAI)this).__initializeRpcs(); } private static void __rpc_handler_2181752049(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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong targetClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref targetClientId); int damage = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref damage); Vector3 force = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref force); target.__rpc_exec_stage = (__RpcExecStage)1; ((DreadweaverAI)(object)target).ApplyAttackDamageClientRpc(targetClientId, damage, force); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2785260190(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; ((DreadweaverAI)(object)target).ReportTargetDownServerRpc(targetClientId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1561710965(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 clientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref clientId); target.__rpc_exec_stage = (__RpcExecStage)1; ((DreadweaverAI)(object)target).SyncTargetClientRpc(clientId); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2670048099(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) { int stateClientRpc = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref stateClientRpc); target.__rpc_exec_stage = (__RpcExecStage)1; ((DreadweaverAI)(object)target).SetStateClientRpc(stateClientRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2825695446(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_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_006c: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int animationCode = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref animationCode); float fade = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref fade, default(ForPrimitives)); float normalizedTime = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref normalizedTime, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((DreadweaverAI)(object)target).PlayAnimationClientRpc(animationCode, fade, normalizedTime); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1341084309(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_003e: 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_006c: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool visible = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref visible, default(ForPrimitives)); int sequence = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref sequence); float flickerSeconds = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref flickerSeconds, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((DreadweaverAI)(object)target).SetVisibilityClientRpc(visible, sequence, flickerSeconds); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3665063338(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) { float duration = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref duration, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((DreadweaverAI)(object)target).StartCamoPreviewClientRpc(duration); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2228030270(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0077: 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_0095: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 targetCenter = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref targetCenter); Vector3 creatureCenter = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref creatureCenter); float radius = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref radius, default(ForPrimitives)); int seed = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref seed); float duration = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref duration, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((DreadweaverAI)(object)target).TriggerStalkLightFlickerClientRpc(targetCenter, creatureCenter, radius, seed, duration); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1147045660(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_003e: 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_006f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool visible = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref visible, default(ForPrimitives)); int sequence = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref sequence); target.__rpc_exec_stage = (__RpcExecStage)1; ((DreadweaverAI)(object)target).ResyncVisibilityClientRpc(visible, sequence); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1055467347(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) { Vector3 position = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref position); Quaternion rotation = default(Quaternion); ((FastBufferReader)(ref reader)).ReadValueSafe(ref rotation); target.__rpc_exec_stage = (__RpcExecStage)1; ((DreadweaverAI)(object)target).TeleportClientRpc(position, rotation); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3663652314(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_004a: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool active = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe(ref active, default(ForPrimitives)); float intensity = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref intensity, default(ForPrimitives)); float angle = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref angle, default(ForPrimitives)); float range = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref range, default(ForPrimitives)); float height = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref height, default(ForPrimitives)); Vector3 color = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref color); target.__rpc_exec_stage = (__RpcExecStage)1; ((DreadweaverAI)(object)target).SetCreatureSpotlightClientRpc(active, intensity, angle, range, height, color); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2980217333(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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong targetClientId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref targetClientId); int seed = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref seed); float duration = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref duration, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((DreadweaverAI)(object)target).FlashlightHarassClientRpc(targetClientId, seed, duration); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3476069871(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int clipIndex = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref clipIndex); Vector3 worldPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref worldPosition); float volume = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref volume, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((DreadweaverAI)(object)target).PlayStalkingRevealSoundClientRpc(clipIndex, worldPosition, volume); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2220773483(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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { int clipId = default(int); ByteUnpacker.ReadValueBitPacked(reader, ref clipId); float volume = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe(ref volume, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((DreadweaverAI)(object)target).PlayOneShotClientRpc(clipId, volume); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "DreadweaverAI"; } } public sealed class DreadweaverSpotlight : MonoBehaviour { private Transform _followTarget; private float _height; private Light _light; private float _targetIntensity; private float _fadeRate = 40f; private bool _despawning; public static DreadweaverSpotlight SpawnAbove(Transform followTarget, float height, float intensity, float spotAngle, float range, Color color) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)followTarget == (Object)null) { return null; } GameObject val = new GameObject("Dreadweaver_Spotlight") { hideFlags = (HideFlags)52 }; DreadweaverSpotlight dreadweaverSpotlight = val.AddComponent(); dreadweaverSpotlight._followTarget = followTarget; dreadweaverSpotlight._height = height; Light val2 = val.AddComponent(); val2.type = (LightType)0; val2.shadows = (LightShadows)0; val2.renderMode = (LightRenderMode)1; val2.intensity = 0f; dreadweaverSpotlight._light = val2; dreadweaverSpotlight.Configure(intensity, spotAngle, range, height, color); dreadweaverSpotlight.UpdatePose(); return dreadweaverSpotlight; } catch (Exception arg) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogError((object)$"[DreadweaverSpotlight] Spawn failed: {arg}"); } return null; } } public void Configure(float intensity, float spotAngle, float range, float height, Color color) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) _height = height; if (!((Object)(object)_light == (Object)null)) { _targetIntensity = Mathf.Max(0f, intensity); _fadeRate = Mathf.Max(8f, _targetIntensity / 0.22f); _light.spotAngle = Mathf.Clamp(spotAngle, 5f, 160f); _light.innerSpotAngle = Mathf.Max(1f, _light.spotAngle * 0.55f); _light.range = Mathf.Max(1f, range); _light.color = color; UpdatePose(); } } public void Despawn() { if (!_despawning) { _despawning = true; _targetIntensity = 0f; float num = (((Object)(object)_light != (Object)null) ? _light.intensity : 0f); _fadeRate = Mathf.Max(8f, num / 0.18f); } } private void LateUpdate() { if ((Object)(object)_followTarget == (Object)null && !_despawning) { Despawn(); } if ((Object)(object)_light != (Object)null) { _light.intensity = Mathf.MoveTowards(_light.intensity, _targetIntensity, _fadeRate * Time.deltaTime); } if (_despawning && ((Object)(object)_light == (Object)null || _light.intensity <= 0.01f)) { Object.Destroy((Object)(object)((Component)this).gameObject); } else if ((Object)(object)_followTarget != (Object)null) { UpdatePose(); } } private void UpdatePose() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0036: 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) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_followTarget == (Object)null)) { Vector3 position = _followTarget.position + Vector3.up * _height; ((Component)this).transform.position = position; Vector3 forward = _followTarget.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.001f) { forward = Vector3.forward; } ((Component)this).transform.rotation = Quaternion.LookRotation(Vector3.down, ((Vector3)(ref forward)).normalized); } } } } 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() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable(); } } } namespace Y4NGZDreadweaver.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }