Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ChaosSuiteCore v0.2.1
plugins/ChaosSuite-ChaosSuiteCore/ChaosSuite.Core.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Microsoft.CodeAnalysis; [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("ChaosSuite.Core")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a3464fa3098fa6be253d588a5b7ca9ba01bef4dd")] [assembly: AssemblyProduct("ChaosSuite.Core")] [assembly: AssemblyTitle("ChaosSuite.Core")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] 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 ChaosSuite.Core { public readonly record struct EntityId(ulong Value) { public bool IsValid => Value != 0; public static readonly EntityId None = new EntityId(0uL); } public readonly record struct ActionReceipt(EntityId Entity, ulong Sequence, bool Accepted, string Reason) { public static ActionReceipt Reject(EntityId entity, ulong sequence, string reason) { return new ActionReceipt(entity, sequence, Accepted: false, reason); } public static ActionReceipt Accept(EntityId entity, ulong sequence) { return new ActionReceipt(entity, sequence, Accepted: true, string.Empty); } } public static class TargetedClientOutcome { public static bool IsRecipient(ulong localClientId, ulong targetClientId) { return localClientId == targetClientId; } } public sealed class MonotonicActionGuard { private readonly Dictionary<ulong, ulong> lastSequenceBySender = new Dictionary<ulong, ulong>(); public bool TryAccept(ulong senderId, ulong sequence) { if (lastSequenceBySender.TryGetValue(senderId, out var value) && sequence <= value) { return false; } lastSequenceBySender[senderId] = sequence; return true; } public void Forget(ulong senderId) { lastSequenceBySender.Remove(senderId); } } public sealed class IdempotentCleanup { private readonly List<Action> actions = new List<Action>(); private bool completed; public bool IsCompleted => completed; public void Register(Action action) { if (action == null) { throw new ArgumentNullException("action"); } if (completed) { action(); } else { actions.Add(action); } } public void Complete() { if (completed) { return; } completed = true; List<Exception> list = null; for (int num = actions.Count - 1; num >= 0; num--) { try { actions[num](); } catch (Exception item) { (list ?? (list = new List<Exception>())).Add(item); } } actions.Clear(); if (list == null || list.Count <= 0) { return; } throw new AggregateException(list); } } public sealed class PersistentCleanupCycle { private readonly List<Action> persistentActions = new List<Action>(); private IdempotentCleanup current = new IdempotentCleanup(); private bool terminallyCompleted; public IdempotentCleanup Current => current; public bool IsTerminallyCompleted => terminallyCompleted; public void RegisterPersistent(Action action) { if (action == null) { throw new ArgumentNullException("action"); } if (terminallyCompleted) { action(); } else if (!persistentActions.Contains(action)) { persistentActions.Add(action); current.Register(action); } } public void Reset() { if (terminallyCompleted) { return; } try { current.Complete(); } finally { current = new IdempotentCleanup(); for (int i = 0; i < persistentActions.Count; i++) { current.Register(persistentActions[i]); } } } public void Complete() { if (terminallyCompleted) { return; } terminallyCompleted = true; try { current.Complete(); } finally { persistentActions.Clear(); } } } public readonly record struct BoundedSetting<T>(T Value, T Minimum, T Maximum) where T : IComparable<T> { public T Clamp() { if (Value.CompareTo(Minimum) >= 0) { if (Value.CompareTo(Maximum) <= 0) { return Value; } return Maximum; } return Minimum; } } public readonly record struct GameplaySettings(bool Enabled, bool AllowIndoor, bool AllowOutdoor, int SpawnWeight, int PowerLevel, int MaximumCount, int Health, float StunSeconds, float CooldownSeconds, int Damage, float EffectSeconds, float NoiseRange, float NoiseLoudness, bool DebugLogging) { public GameplaySettings Validated() { return this with { SpawnWeight = Math.Clamp(SpawnWeight, 0, 100), PowerLevel = Math.Clamp(PowerLevel, 0, 100), MaximumCount = Math.Clamp(MaximumCount, 0, 8), Health = Math.Clamp(Health, 1, 1000), StunSeconds = Math.Clamp(StunSeconds, 0f, 60f), CooldownSeconds = Math.Clamp(CooldownSeconds, 0f, 300f), Damage = Math.Clamp(Damage, 0, 100), EffectSeconds = Math.Clamp(EffectSeconds, 0.1f, 300f), NoiseRange = Math.Clamp(NoiseRange, 0f, 200f), NoiseLoudness = Math.Clamp(NoiseLoudness, 0f, 1f) }; } } public readonly record struct AccessibilitySettings(float ScreenShake, float CameraRoll, float Flash, float MotionTrail, bool Subtitles, float SubtitleScale, float Volume, bool ReducedMotion) { public AccessibilitySettings Validated() { return this with { ScreenShake = Math.Clamp(ScreenShake, 0f, 1f), CameraRoll = Math.Clamp(CameraRoll, 0f, 1f), Flash = Math.Clamp(Flash, 0f, 1f), MotionTrail = Math.Clamp(MotionTrail, 0f, 1f), SubtitleScale = Math.Clamp(SubtitleScale, 0.75f, 2f), Volume = Math.Clamp(Volume, 0f, 1f) }; } } public readonly record struct Seed(ulong Value) { public Seed Combine(ulong value) { return new Seed(Mix(Value ^ value)); } public static Seed From(params ulong[] values) { Seed result = new Seed(11400714819323198485uL); foreach (ulong value in values) { result = result.Combine(value); } return result; } private static ulong Mix(ulong value) { value ^= value >> 30; value *= 13787848793156543929uL; value ^= value >> 27; value *= 10723151780598845931uL; return value ^ (value >> 31); } } public sealed class DeterministicRandom { private ulong state; public DeterministicRandom(Seed seed) { state = ((seed.Value == 0L) ? 11562461410679940143uL : seed.Value); } public ulong NextUInt64() { state += 11400714819323198485uL; ulong num = state; long num2 = (long)(num ^ (num >> 30)) * -4658895280553007687L; long num3 = (num2 ^ (num2 >>> 27)) * -7723592293110705685L; return (ulong)(num3 ^ (num3 >>> 31)); } public int NextInt(int exclusiveMax) { if (exclusiveMax <= 0) { throw new ArgumentOutOfRangeException("exclusiveMax"); } return (int)(NextUInt64() % (uint)exclusiveMax); } public double NextUnit() { return (double)(NextUInt64() >> 11) * 1.1102230246251565E-16; } } public readonly record struct Weighted<T>(T Value, int Weight); public static class WeightedPicker { public static T Pick<T>(IReadOnlyList<Weighted<T>> options, DeterministicRandom random) { if (options.Count == 0) { throw new ArgumentException("At least one option is required.", "options"); } int num = 0; foreach (Weighted<T> option in options) { if (option.Weight < 0) { throw new ArgumentOutOfRangeException("options", "Weights cannot be negative."); } num = checked(num + option.Weight); } if (num == 0) { throw new ArgumentException("At least one option must have positive weight.", "options"); } int num2 = random.NextInt(num); foreach (Weighted<T> option2 in options) { if (num2 < option2.Weight) { return option2.Value; } num2 -= option2.Weight; } throw new InvalidOperationException("Weighted selection exhausted unexpectedly."); } } public sealed class EffectOwnerLedger { private sealed class Entry { internal ulong LifetimeOwner { get; set; } internal HashSet<ulong> AffectedOwners { get; } = new HashSet<ulong>(); internal Entry(ulong lifetimeOwner) { LifetimeOwner = lifetimeOwner; } } private readonly Dictionary<EntityId, Entry> entries = new Dictionary<EntityId, Entry>(); public int Count => entries.Count; public void Track(EntityId effectId, ulong lifetimeOwner = ulong.MaxValue) { if (!effectId.IsValid) { throw new ArgumentException("A valid effect id is required.", "effectId"); } if (entries.TryGetValue(effectId, out Entry value)) { if (value.LifetimeOwner == ulong.MaxValue && lifetimeOwner != ulong.MaxValue) { value.LifetimeOwner = lifetimeOwner; } } else { entries.Add(effectId, new Entry(lifetimeOwner)); } } public bool Associate(EntityId effectId, ulong affectedOwner) { if (effectId.IsValid && affectedOwner != ulong.MaxValue && entries.TryGetValue(effectId, out Entry value)) { return value.AffectedOwners.Add(affectedOwner); } return false; } public bool Disassociate(EntityId effectId, ulong affectedOwner) { if (effectId.IsValid && affectedOwner != ulong.MaxValue && entries.TryGetValue(effectId, out Entry value)) { return value.AffectedOwners.Remove(affectedOwner); } return false; } public bool Forget(EntityId effectId) { return entries.Remove(effectId); } public void Clear() { entries.Clear(); } public IReadOnlyList<EntityId> OwnedOrAffectedBy(ulong owner) { return Collect(owner, includeLifetimeOwner: true); } public IReadOnlyList<EntityId> AffectedBy(ulong owner) { return Collect(owner, includeLifetimeOwner: false); } private IReadOnlyList<EntityId> Collect(ulong owner, bool includeLifetimeOwner) { List<EntityId> list = new List<EntityId>(); foreach (KeyValuePair<EntityId, Entry> entry in entries) { if ((includeLifetimeOwner && entry.Value.LifetimeOwner == owner) || entry.Value.AffectedOwners.Contains(owner)) { list.Add(entry.Key); } } return list; } } public readonly record struct DestinationCandidate(EntityId Id, bool PathComplete, bool InInterior, bool IsShip, bool IsCompany, bool NearPit, bool NearMine, bool LockedRegion, bool UnderMap, float DangerScore, float Distance); public static class DestinationSafety { public static bool IsSafe(in DestinationCandidate candidate, float maximumDanger, float minimumDistance, bool allowShip = false, bool allowCompany = false) { if (candidate.Id.IsValid && candidate.PathComplete && candidate.InInterior && !candidate.UnderMap && !candidate.NearPit && !candidate.NearMine && !candidate.LockedRegion && (allowShip || !candidate.IsShip) && (allowCompany || !candidate.IsCompany) && candidate.DangerScore <= maximumDanger) { return candidate.Distance >= minimumDistance; } return false; } public static DestinationCandidate? Choose(IReadOnlyList<DestinationCandidate> candidates, DeterministicRandom random, float maximumDanger, float minimumDistance) { List<DestinationCandidate> list = new List<DestinationCandidate>(); foreach (DestinationCandidate candidate2 in candidates) { DestinationCandidate candidate = candidate2; if (IsSafe(in candidate, maximumDanger, minimumDistance)) { list.Add(candidate); } } if (list.Count == 0) { return null; } return list[random.NextInt(list.Count)]; } } public sealed class RateLimiter { private readonly Dictionary<EntityId, double> nextAllowedAt = new Dictionary<EntityId, double>(); public bool TryAcquire(EntityId key, double now, double minimumInterval) { if (minimumInterval < 0.0) { throw new ArgumentOutOfRangeException("minimumInterval"); } if (nextAllowedAt.TryGetValue(key, out var value) && now < value) { return false; } nextAllowedAt[key] = now + minimumInterval; return true; } public void Clear(EntityId key) { nextAllowedAt.Remove(key); } public void ClearAll() { nextAllowedAt.Clear(); } } public enum SystemicThreatKind : byte { RestraintOrDisplacement, RoomScaleEnvironmental, PersistentCurse } public sealed class SystemicThreatBudget { private readonly int[] capacities = new int[3] { 1, 1, 1 }; private readonly HashSet<EntityId>[] leases = new HashSet<EntityId>[3] { new HashSet<EntityId>(), new HashSet<EntityId>(), new HashSet<EntityId>() }; public void SetCapacity(SystemicThreatKind kind, int capacity) { capacities[Index(kind)] = Math.Clamp(capacity, 0, 8); } public int Capacity(SystemicThreatKind kind) { return capacities[Index(kind)]; } public int Active(SystemicThreatKind kind) { return leases[Index(kind)].Count; } public bool TryAcquire(SystemicThreatKind kind, EntityId entity) { if (!entity.IsValid) { return false; } HashSet<EntityId> hashSet = leases[Index(kind)]; if (hashSet.Contains(entity)) { return true; } if (hashSet.Count >= capacities[Index(kind)]) { return false; } hashSet.Add(entity); return true; } public bool Release(SystemicThreatKind kind, EntityId entity) { if (entity.IsValid) { return leases[Index(kind)].Remove(entity); } return false; } public int Release(EntityId entity) { if (!entity.IsValid) { return 0; } int num = 0; for (int i = 0; i < leases.Length; i++) { if (leases[i].Remove(entity)) { num++; } } return num; } public void Clear() { for (int i = 0; i < leases.Length; i++) { leases[i].Clear(); } } private static int Index(SystemicThreatKind kind) { if (kind < (SystemicThreatKind)3) { return (int)kind; } throw new ArgumentOutOfRangeException("kind"); } } } namespace System.Runtime.CompilerServices { internal static class IsExternalInit { } }
plugins/ChaosSuite-ChaosSuiteCore/ChaosSuite.Runtime.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ChaosSuite.Core; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; [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("ChaosSuite.Runtime")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a3464fa3098fa6be253d588a5b7ca9ba01bef4dd")] [assembly: AssemblyProduct("ChaosSuite.Runtime")] [assembly: AssemblyTitle("ChaosSuite.Runtime")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] 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 ChaosSuite.Runtime { public static class BundlePathResolver { public static string Resolve(string rootDirectory, string relativePath) { if (string.IsNullOrWhiteSpace(rootDirectory)) { throw new ArgumentException("A bundle root directory is required.", "rootDirectory"); } if (string.IsNullOrWhiteSpace(relativePath)) { throw new ArgumentException("A relative bundle path is required.", "relativePath"); } if (Path.IsPathRooted(relativePath)) { throw new ArgumentException("Bundle paths must be relative to the plugin directory.", "relativePath"); } string fullPath = Path.GetFullPath(rootDirectory); string fullPath2 = Path.GetFullPath(Path.Combine(fullPath, relativePath)); string value = (fullPath.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal) ? fullPath : (fullPath + Path.DirectorySeparatorChar)); if (!fullPath2.StartsWith(value, StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException("Bundle path escapes the plugin directory.", "relativePath"); } return fullPath2; } } public static class ChaosAssetPaths { public static string BundleName(string moduleName) { return "chaossuite_" + ValidateModuleName(moduleName).ToLowerInvariant(); } public static string VisualPrefab(string moduleName) { string text = ValidateModuleName(moduleName); return "Assets/ChaosSuite/Generated/" + text + "/" + text + "Visual.prefab"; } public static string EnemyType(string moduleName) { string text = ValidateModuleName(moduleName); return "Assets/ChaosSuite/Generated/" + text + "/" + text + "EnemyType.asset"; } public static string ItemDefinition(string moduleName) { string text = ValidateModuleName(moduleName); return "Assets/ChaosSuite/Generated/" + text + "/" + text + "Item.asset"; } public static string ItemDefinition(string moduleName, string itemName) { string text = ValidateModuleName(moduleName); string text2 = ValidateModuleName(itemName); return "Assets/ChaosSuite/Generated/" + text + "/" + text2 + ".asset"; } public static string NetworkPrefab(string moduleName, string prefabName) { string text = ValidateModuleName(moduleName); string text2 = ValidateModuleName(prefabName); return "Assets/ChaosSuite/Generated/" + text + "/" + text2 + ".prefab"; } public static string AudioFolder(string moduleName) { string text = ValidateModuleName(moduleName); return "Assets/ChaosSuite/Generated/Audio/" + text + "/"; } public static string AudioClip(string moduleName, string wavFileName) { if (string.IsNullOrWhiteSpace(wavFileName) || !string.Equals(Path.GetFileName(wavFileName), wavFileName, StringComparison.Ordinal) || !string.Equals(Path.GetExtension(wavFileName), ".wav", StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException("An audio clip must be a simple .wav file name.", "wavFileName"); } return AudioFolder(moduleName) + wavFileName; } private static string ValidateModuleName(string moduleName) { if (string.IsNullOrWhiteSpace(moduleName)) { throw new ArgumentException("A module name is required.", "moduleName"); } foreach (char c in moduleName) { if ((c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9')) { throw new ArgumentException("Module names may contain only ASCII letters and digits.", "moduleName"); } } return moduleName; } } public sealed class AssetBundleRegistry { private readonly record struct BundleRecord(string Path, AssetBundle Bundle); private readonly record struct AssetKey(string BundleId, string AssetName, Type Type); private readonly string rootDirectory; private readonly ManualLogSource log; private readonly Dictionary<string, BundleRecord> bundles = new Dictionary<string, BundleRecord>(StringComparer.OrdinalIgnoreCase); private readonly Dictionary<AssetKey, Object> assets = new Dictionary<AssetKey, Object>(); public IReadOnlyCollection<string> LoadedBundleIds => bundles.Keys; internal AssetBundleRegistry(string rootDirectory, ManualLogSource log) { this.rootDirectory = Path.GetFullPath(rootDirectory ?? throw new ArgumentNullException("rootDirectory")); this.log = log ?? throw new ArgumentNullException("log"); } public bool TryLoadBundle(string bundleId, string relativePath, out AssetBundle? bundle) { string path = BundlePathResolver.Resolve(rootDirectory, relativePath); return TryLoadBundleAtPath(bundleId, path, out bundle); } public bool TryLoadModuleBundle(string moduleName, Assembly featureAssembly, out AssetBundle? bundle) { if ((object)featureAssembly == null) { throw new ArgumentNullException("featureAssembly"); } if (string.IsNullOrWhiteSpace(featureAssembly.Location)) { throw new ArgumentException("The feature assembly must have an installed file location.", "featureAssembly"); } string text = ChaosAssetPaths.BundleName(moduleName); string path = BundlePathResolver.Resolve(Path.GetDirectoryName(Path.GetFullPath(featureAssembly.Location)), text); return TryLoadBundleAtPath(text, path, out bundle); } private bool TryLoadBundleAtPath(string bundleId, string path, out AssetBundle? bundle) { ValidateBundleId(bundleId); if (bundles.TryGetValue(bundleId, out var value)) { if (!string.Equals(value.Path, path, StringComparison.OrdinalIgnoreCase)) { throw new InvalidOperationException("Bundle id '" + bundleId + "' is already registered from another path."); } bundle = value.Bundle; return Object.op_Implicit((Object)(object)bundle); } if (!File.Exists(path)) { log.LogError((object)("Asset bundle '" + bundleId + "' was not found at '" + path + "'.")); bundle = null; return false; } try { bundle = AssetBundle.LoadFromFile(path); } catch (Exception ex) { log.LogError((object)("Failed to read asset bundle '" + bundleId + "' at '" + path + "': " + ex.Message)); bundle = null; return false; } if (!Object.op_Implicit((Object)(object)bundle)) { log.LogError((object)("Unity rejected asset bundle '" + bundleId + "' at '" + path + "'. Check the Unity editor version and target platform.")); bundle = null; return false; } bundles.Add(bundleId, new BundleRecord(path, bundle)); log.LogInfo((object)("Loaded asset bundle '" + bundleId + "' from '" + path + "'.")); return true; } public bool TryGetBundle(string bundleId, out AssetBundle? bundle) { if (bundles.TryGetValue(bundleId, out var value) && Object.op_Implicit((Object)(object)value.Bundle)) { bundle = value.Bundle; return true; } bundle = null; return false; } public bool TryLoadAsset<T>(string bundleId, string assetName, out T? asset) where T : Object { return TryLoadAsset<T>(bundleId, assetName, logMissing: true, out asset); } public bool TryLoadAssetIfPresent<T>(string bundleId, string assetName, out T? asset) where T : Object { return TryLoadAsset<T>(bundleId, assetName, logMissing: false, out asset); } private bool TryLoadAsset<T>(string bundleId, string assetName, bool logMissing, out T? asset) where T : Object { if (string.IsNullOrWhiteSpace(assetName)) { throw new ArgumentException("An asset name is required.", "assetName"); } AssetKey key = new AssetKey(bundleId, assetName, typeof(T)); if (assets.TryGetValue(key, out Object value) && Object.op_Implicit(value)) { asset = (T)(object)((value is T) ? value : null); return Object.op_Implicit((Object)(object)asset); } if (!TryGetBundle(bundleId, out AssetBundle bundle)) { asset = default(T); return false; } asset = bundle.LoadAsset<T>(assetName); if (!Object.op_Implicit((Object)(object)asset)) { if (logMissing) { log.LogError((object)("Asset '" + assetName + "' (" + typeof(T).Name + ") was not found in bundle '" + bundleId + "'.")); } asset = default(T); return false; } assets[key] = (Object)(object)asset; return true; } public bool UnloadBundle(string bundleId, bool unloadLoadedObjects) { if (!bundles.Remove(bundleId, out var value)) { return false; } List<AssetKey> list = new List<AssetKey>(); foreach (AssetKey key in assets.Keys) { if (string.Equals(key.BundleId, bundleId, StringComparison.OrdinalIgnoreCase)) { list.Add(key); } } foreach (AssetKey item in list) { assets.Remove(item); } if (Object.op_Implicit((Object)(object)value.Bundle)) { value.Bundle.Unload(unloadLoadedObjects); } return true; } public void UnloadAll(bool unloadLoadedObjects) { foreach (BundleRecord value in bundles.Values) { if (Object.op_Implicit((Object)(object)value.Bundle)) { value.Bundle.Unload(unloadLoadedObjects); } } assets.Clear(); bundles.Clear(); } private static void ValidateBundleId(string bundleId) { if (string.IsNullOrWhiteSpace(bundleId)) { throw new ArgumentException("A bundle id is required.", "bundleId"); } foreach (char c in bundleId) { bool flag = (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); if (!flag) { bool flag2 = ((c == '-' || c == '.' || c == '_') ? true : false); flag = flag2; } if (!flag) { throw new ArgumentException("Bundle ids may contain only ASCII letters, digits, periods, underscores, and hyphens.", "bundleId"); } } } } public sealed class HostRequestValidator { private readonly Func<bool> isServer; private readonly Func<ulong, bool> isConnected; private readonly Func<ulong, EntityId, bool> controlsEntity; private readonly MonotonicActionGuard sequences = new MonotonicActionGuard(); public HostRequestValidator(Func<bool> isServer, Func<ulong, bool> isConnected, Func<ulong, EntityId, bool> controlsEntity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown this.isServer = isServer ?? throw new ArgumentNullException("isServer"); this.isConnected = isConnected ?? throw new ArgumentNullException("isConnected"); this.controlsEntity = controlsEntity ?? throw new ArgumentNullException("controlsEntity"); } public ActionReceipt Validate(ulong senderId, EntityId entity, ulong sequence) { //IL_000d: 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_0023: 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_0052: 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_0045: 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_0061: 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_0085: 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_007d: Unknown result type (might be due to invalid IL or missing references) if (!isServer()) { return ActionReceipt.Reject(entity, sequence, "not-host"); } if (!((EntityId)(ref entity)).IsValid) { return ActionReceipt.Reject(entity, sequence, "invalid-entity"); } if (!isConnected(senderId)) { return ActionReceipt.Reject(entity, sequence, "sender-not-connected"); } if (!controlsEntity(senderId, entity)) { return ActionReceipt.Reject(entity, sequence, "sender-does-not-control-entity"); } if (!sequences.TryAccept(senderId, sequence)) { return ActionReceipt.Reject(entity, sequence, "replayed-sequence"); } return ActionReceipt.Accept(entity, sequence); } public void ForgetSender(ulong senderId) { sequences.Forget(senderId); } } public static class NetworkAuthority { public static bool IsHostAuthority { get { if (Object.op_Implicit((Object)(object)NetworkManager.Singleton)) { return NetworkManager.Singleton.IsServer; } return false; } } public static bool IsConnectedClient(ulong clientId) { NetworkManager singleton = NetworkManager.Singleton; if (singleton != null && Object.op_Implicit((Object)(object)singleton) && singleton.IsServer) { return singleton.ConnectedClients.ContainsKey(clientId); } return false; } public static bool ClientOwns(ulong clientId, NetworkObject? target) { if (target != null && Object.op_Implicit((Object)(object)target) && target.IsSpawned) { return target.OwnerClientId == clientId; } return false; } } public sealed class NoiseService { private readonly ManualLogSource log; private readonly RateLimiter limiter = new RateLimiter(); internal NoiseService(ManualLogSource log) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown this.log = log; } public bool TryEmit(EntityId emitter, Vector3 position, float range, float loudness, int noiseId, double now, double minimumInterval, bool insideClosedShip = false) { //IL_0024: 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_008f: Unknown result type (might be due to invalid IL or missing references) if (!NetworkAuthority.IsHostAuthority || !Object.op_Implicit((Object)(object)RoundManager.Instance)) { return false; } if (!((EntityId)(ref emitter)).IsValid || !limiter.TryAcquire(emitter, now, Math.Max(0.0, minimumInterval))) { return false; } RoundManager.Instance.PlayAudibleNoise(position, Mathf.Clamp(range, 0f, 200f), Mathf.Clamp(loudness, 0f, 1f), 1, insideClosedShip, noiseId); log.LogDebug((object)$"Noise {noiseId} emitted by {((EntityId)(ref emitter)).Value} at {position}."); return true; } public void Forget(EntityId emitter) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) limiter.Clear(emitter); } public void Clear() { limiter.ClearAll(); } } public sealed class SystemicThreatBudgetService { private readonly SystemicThreatBudget budget = new SystemicThreatBudget(); private readonly HashSet<EntityId> trackedEntities = new HashSet<EntityId>(); private readonly EffectCleanupRegistry cleanup; private readonly ManualLogSource log; internal SystemicThreatBudgetService(EffectCleanupRegistry cleanup, ManualLogSource log) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown this.cleanup = cleanup; this.log = log; } internal void Configure(int restraintOrDisplacement, int roomScaleEnvironmental, int persistentCurse) { budget.SetCapacity((SystemicThreatKind)0, restraintOrDisplacement); budget.SetCapacity((SystemicThreatKind)1, roomScaleEnvironmental); budget.SetCapacity((SystemicThreatKind)2, persistentCurse); } public bool TryAcquire(NetworkObject target, SystemicThreatKind kind) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (!NetworkAuthority.IsHostAuthority || target == null || !Object.op_Implicit((Object)(object)target) || !target.IsSpawned) { return false; } EntityId val = default(EntityId); ((EntityId)(ref val))..ctor(target.NetworkObjectId); if (!budget.TryAcquire(kind, val)) { return false; } Track(target, val); log.LogDebug((object)$"Systemic threat lease acquired: {kind} by {((EntityId)(ref val)).Value}."); return true; } public bool TryTransfer(NetworkObject source, NetworkObject target, SystemicThreatKind kind) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_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_009e: 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_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) if (!NetworkAuthority.IsHostAuthority || (Object)(object)source == (Object)null || !Object.op_Implicit((Object)(object)source) || !source.IsSpawned || (Object)(object)target == (Object)null || !Object.op_Implicit((Object)(object)target) || !target.IsSpawned) { return false; } EntityId val = default(EntityId); ((EntityId)(ref val))..ctor(source.NetworkObjectId); EntityId val2 = default(EntityId); ((EntityId)(ref val2))..ctor(target.NetworkObjectId); if (val == val2) { return budget.TryAcquire(kind, val); } if (!budget.Release(kind, val)) { return false; } if (!budget.TryAcquire(kind, val2)) { budget.TryAcquire(kind, val); return false; } Track(target, val2); log.LogDebug((object)$"Systemic threat lease transferred: {kind} from {((EntityId)(ref val)).Value} to {((EntityId)(ref val2)).Value}."); return true; } public void Release(NetworkObject? target, SystemicThreatKind kind, string reason) { //IL_001f: 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_0033: Unknown result type (might be due to invalid IL or missing references) if (target != null && Object.op_Implicit((Object)(object)target)) { EntityId val = default(EntityId); ((EntityId)(ref val))..ctor(target.NetworkObjectId); if (budget.Release(kind, val)) { log.LogDebug((object)$"Systemic threat lease released: {kind} by {((EntityId)(ref val)).Value} ({reason})."); } } } public void Clear() { budget.Clear(); trackedEntities.Clear(); } private void Track(NetworkObject target, EntityId id) { //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_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_006c: Unknown result type (might be due to invalid IL or missing references) if (trackedEntities.Add(id)) { cleanup.GetOrCreate(id, target.OwnerClientId).Register((Action)delegate { //IL_000c: 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) budget.Release(id); trackedEntities.Remove(id); }); (((Component)target).GetComponent<EffectLifetime>() ?? ((Component)target).gameObject.AddComponent<EffectLifetime>()).Track(cleanup, id); } } } public sealed class EffectCleanupRegistry { private sealed class Entry { internal ulong LifetimeOwner { get; private set; } internal PersistentCleanupCycle Cycle { get; } = new PersistentCleanupCycle(); internal Entry(ulong lifetimeOwner) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown LifetimeOwner = lifetimeOwner; } internal void TrackLifetimeOwner(ulong owner) { if (LifetimeOwner == ulong.MaxValue && owner != ulong.MaxValue) { LifetimeOwner = owner; } } } private readonly ManualLogSource log; private readonly Dictionary<EntityId, Entry> effects = new Dictionary<EntityId, Entry>(); private readonly EffectOwnerLedger owners = new EffectOwnerLedger(); public int Count => effects.Count; internal EffectCleanupRegistry(ManualLogSource log) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown this.log = log; } public IdempotentCleanup GetOrCreate(EntityId id, ulong ownerClientId = ulong.MaxValue) { //IL_001f: 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_0063: 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) if (!((EntityId)(ref id)).IsValid) { throw new ArgumentException("A spawned network entity id is required.", "id"); } if (effects.TryGetValue(id, out Entry value)) { value.TrackLifetimeOwner(ownerClientId); owners.Track(id, ownerClientId); return value.Cycle.Current; } Entry entry = new Entry(ownerClientId); effects.Add(id, entry); owners.Track(id, ownerClientId); return entry.Cycle.Current; } public void Register(NetworkObject target, Action cleanup) { //IL_0034: 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) if (!Object.op_Implicit((Object)(object)target)) { throw new ArgumentNullException("target"); } if (!target.IsSpawned) { throw new InvalidOperationException("Cleanup can only be attached to a spawned NetworkObject."); } EntityId val = default(EntityId); ((EntityId)(ref val))..ctor(target.NetworkObjectId); GetOrCreate(val, target.OwnerClientId); effects[val].Cycle.RegisterPersistent(cleanup); (((Component)target).GetComponent<EffectLifetime>() ?? ((Component)target).gameObject.AddComponent<EffectLifetime>()).Track(this, val); } public bool AssociateAffectedOwner(EntityId effectId, ulong ownerClientId) { //IL_0006: 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 (effects.ContainsKey(effectId)) { return owners.Associate(effectId, ownerClientId); } return false; } public bool DisassociateAffectedOwner(EntityId effectId, ulong ownerClientId) { //IL_0006: 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 (effects.ContainsKey(effectId)) { return owners.Disassociate(effectId, ownerClientId); } return false; } public void Release(EntityId id, string reason) { //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_001f: Unknown result type (might be due to invalid IL or missing references) if (effects.Remove(id, out Entry value)) { owners.Forget(id); RunCleanup(id, reason, (Action)value.Cycle.Complete); } } public void ReleaseOwner(ulong ownerClientId, string reason) { //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_002f: 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_0043: Unknown result type (might be due to invalid IL or missing references) if (effects.Count == 0) { return; } foreach (EntityId item in owners.OwnedOrAffectedBy(ownerClientId)) { if (effects.TryGetValue(item, out Entry value)) { if (value.LifetimeOwner == ownerClientId) { Release(item, reason); } else { Reset(item, value, reason); } } } } public void ReleaseAffectedOwner(ulong ownerClientId, string reason) { //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_002f: 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) if (effects.Count == 0) { return; } foreach (EntityId item in owners.AffectedBy(ownerClientId)) { if (effects.TryGetValue(item, out Entry value)) { Reset(item, value, reason); } } } public void Clear(string reason) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (effects.Count == 0) { return; } foreach (EntityId item in new List<EntityId>(effects.Keys)) { Release(item, reason); } } private void Reset(EntityId id, Entry entry, string reason) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) owners.Forget(id); owners.Track(id, entry.LifetimeOwner); RunCleanup(id, reason, (Action)entry.Cycle.Reset); } private void RunCleanup(EntityId id, string reason, Action cleanup) { try { cleanup(); } catch (AggregateException arg) { log.LogError((object)$"Cleanup failure for {((EntityId)(ref id)).Value} ({reason}): {arg}"); } } } public static class TeleportCleanupGuard { [ThreadStatic] private static int suppressionDepth; public static bool IsSuppressed => suppressionDepth > 0; public static void RunWithoutCleanup(Action teleport) { if (teleport == null) { throw new ArgumentNullException("teleport"); } suppressionDepth++; try { teleport(); } finally { suppressionDepth--; } } } internal sealed class EffectLifetime : MonoBehaviour { private EffectCleanupRegistry? registry; private EntityId entity; internal void Track(EffectCleanupRegistry owner, EntityId id) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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 (registry != null && (registry != owner || entity != id)) { throw new InvalidOperationException("An effect lifetime cannot track two network entities."); } registry = owner; entity = id; } private void OnDestroy() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) registry?.Release(entity, "network object despawned"); registry = null; } } public static class ChaosPresentation { private static readonly int Action = Animator.StringToHash("Action"); public static bool TriggerAction(Component source) { if (!Object.op_Implicit((Object)(object)source) || !source.gameObject.activeInHierarchy) { return false; } Animator[] componentsInChildren = source.GetComponentsInChildren<Animator>(true); foreach (Animator val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.activeInHierarchy && !((Object)(object)val.runtimeAnimatorController == (Object)null)) { val.ResetTrigger(Action); val.SetTrigger(Action); return true; } } return false; } } [BepInPlugin("com.chaossuite.core", "Chaos Suite Core", "0.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class ChaosSuiteRuntimePlugin : BaseUnityPlugin { public const string PluginGuid = "com.chaossuite.core"; public const string PluginName = "Chaos Suite Core"; public const string PluginVersion = "0.2.0"; private Harmony? harmony; public static ChaosSuiteRuntimePlugin? Instance { get; private set; } public NoiseService Noise { get; private set; } public EffectCleanupRegistry Cleanup { get; private set; } public SystemicThreatBudgetService ThreatBudget { get; private set; } public AssetBundleRegistry Assets { get; private set; } public SynchronizedConfigService SynchronizedConfig { get; private set; } public ChaosSuiteSettings Settings { get; private set; } public LethalLibContentRegistration Content { get; private set; } private void Awake() { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown Instance = this; Noise = new NoiseService(((BaseUnityPlugin)this).Logger); Cleanup = new EffectCleanupRegistry(((BaseUnityPlugin)this).Logger); Assets = new AssetBundleRegistry(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), ((BaseUnityPlugin)this).Logger); SynchronizedConfig = new SynchronizedConfigService(((BaseUnityPlugin)this).Logger); Settings = new ChaosSuiteSettings(((BaseUnityPlugin)this).Config, SynchronizedConfig); ThreatBudget = new SystemicThreatBudgetService(Cleanup, ((BaseUnityPlugin)this).Logger); ThreatBudget.Configure(Settings.MaximumRestraintOrDisplacement.Value, Settings.MaximumRoomScaleEnvironmental.Value, Settings.MaximumPersistentCurse.Value); Content = new LethalLibContentRegistration(Assets, Settings, ((BaseUnityPlugin)this).Logger); harmony = new Harmony("com.chaossuite.core"); int num = LifecyclePatches.Install(harmony, ((BaseUnityPlugin)this).Logger); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Chaos Suite Core loaded with {num} verified lifecycle hooks. Gameplay effects are host-authoritative and round scoped."); } public ContentRegistrationReport RegisterFeatureContent(string moduleName, Assembly featureAssembly) { ContentRegistrationReport result = Content.RegisterModuleContent(moduleName, featureAssembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Chaos Suite '{moduleName}' registration finished: {result.Registered} registered, {result.Skipped} skipped, {result.Failed} failed."); return result; } private void Update() { SynchronizedConfig?.Tick(); if (ThreatBudget != null && Settings != null) { ThreatBudget.Configure(Settings.MaximumRestraintOrDisplacement.Value, Settings.MaximumRoomScaleEnvironmental.Value, Settings.MaximumPersistentCurse.Value); } } private void OnDestroy() { SynchronizedConfig?.Dispose(); Noise?.Clear(); ThreatBudget?.Clear(); Cleanup?.Clear("plugin teardown"); Assets?.UnloadAll(unloadLoadedObjects: false); Harmony? obj = harmony; if (obj != null) { obj.UnpatchSelf(); } harmony = null; Instance = null; } } public sealed class ChaosSuiteSettings { private static readonly string[] Modules = new string[8] { "MasklessMimic", "NewtonsApple", "JobApplication", "Professor", "Webhead", "HorrorBowler", "MonkeysPaw", "Relocator" }; private readonly Dictionary<string, SynchronizedConfigEntry<bool>> enabled = new Dictionary<string, SynchronizedConfigEntry<bool>>(StringComparer.Ordinal); private readonly Dictionary<string, SynchronizedConfigEntry<int>> rarity = new Dictionary<string, SynchronizedConfigEntry<int>>(StringComparer.Ordinal); public ConfigEntry<bool> Subtitles { get; } public ConfigEntry<float> EffectsVolume { get; } public ConfigEntry<bool> ReducedMotion { get; } public ConfigEntry<float> CameraIntensity { get; } internal SynchronizedConfigEntry<int> MaximumRestraintOrDisplacement { get; } internal SynchronizedConfigEntry<int> MaximumRoomScaleEnvironmental { get; } internal SynchronizedConfigEntry<int> MaximumPersistentCurse { get; } internal ChaosSuiteSettings(ConfigFile config, SynchronizedConfigService synchronized) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: 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 string[] modules = Modules; foreach (string text in modules) { int num = DefaultRarity(text); enabled.Add(text, synchronized.Register<bool>(text + ".Enabled", config.Bind<bool>("Host Gameplay", text + " Enabled", true, "Host-authoritative enable state for " + text + "."))); rarity.Add(text, synchronized.Register<int>(text + ".Rarity", config.Bind<int>("Host Gameplay", text + " Rarity", num, new ConfigDescription("Host-authoritative natural spawn or scrap rarity for " + text + ".", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())))); } MaximumRestraintOrDisplacement = synchronized.Register<int>("Suite.MaximumRestraintOrDisplacement", config.Bind<int>("Host Gameplay", "Maximum Active Restraint Or Displacement", 1, new ConfigDescription("Global cap for simultaneous Webhead/Relocator control effects.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8), Array.Empty<object>()))); MaximumRoomScaleEnvironmental = synchronized.Register<int>("Suite.MaximumRoomScaleEnvironmental", config.Bind<int>("Host Gameplay", "Maximum Active Room Environmental", 1, new ConfigDescription("Global cap for simultaneous room-scale gravity/environment effects.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8), Array.Empty<object>()))); MaximumPersistentCurse = synchronized.Register<int>("Suite.MaximumPersistentCurse", config.Bind<int>("Host Gameplay", "Maximum Active Persistent Curse", 1, new ConfigDescription("Global cap for simultaneous strong player curse systems.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 8), Array.Empty<object>()))); Subtitles = config.Bind<bool>("Local Accessibility", "Subtitles", true, "Show Chaos Suite textual voice cues where supported."); EffectsVolume = config.Bind<float>("Local Accessibility", "Effects Volume", 1f, new ConfigDescription("Local Chaos Suite effects and voice volume multiplier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); ReducedMotion = config.Bind<bool>("Local Accessibility", "Reduced Motion", false, "Suppress optional camera motion and trails; gameplay state is unchanged."); CameraIntensity = config.Bind<float>("Local Accessibility", "Camera Intensity", 1f, new ConfigDescription("Local optional camera effect intensity.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); } public bool IsEnabled(string module) { if (enabled.TryGetValue(module, out SynchronizedConfigEntry<bool> value)) { return value.Value; } return true; } public int Rarity(string module, int fallback) { if (!rarity.TryGetValue(module, out SynchronizedConfigEntry<int> value)) { return Math.Clamp(fallback, 0, 100); } return Math.Clamp(value.Value, 0, 100); } private static int DefaultRarity(string module) { return module switch { "MasklessMimic" => 0, "NewtonsApple" => 18, "JobApplication" => 14, "Professor" => 12, "Webhead" => 15, "HorrorBowler" => 9, "MonkeysPaw" => 8, "Relocator" => 11, _ => 0, }; } } public enum LethalContentKind : byte { NaturalEnemy, ScrapItem, PlainItem, NetworkPrefab } public readonly record struct LethalContentDefinition(string ModuleName, string PluginGuid, LethalContentKind Kind, string AssetPath, int Rarity); public readonly record struct ContentRegistrationReport(int Registered, int Skipped, int Failed); public readonly record struct FallbackComponentDefinition(string ModuleName, string PrefabName, string TypeName); public sealed class LethalLibContentRegistration { private readonly AssetBundleRegistry assets; private readonly ChaosSuiteSettings settings; private readonly ManualLogSource log; private readonly HashSet<string> registeredAssets = new HashSet<string>(StringComparer.Ordinal); private readonly RuntimeContentFactory fallbackFactory; public LethalLibContentRegistration(AssetBundleRegistry assets, ChaosSuiteSettings settings, ManualLogSource log) { this.assets = assets ?? throw new ArgumentNullException("assets"); this.settings = settings ?? throw new ArgumentNullException("settings"); this.log = log ?? throw new ArgumentNullException("log"); fallbackFactory = new RuntimeContentFactory(assets, log); } public ContentRegistrationReport RegisterKnownInstalledContent() { Assembly assembly; return RegisterDefinitions(KnownLethalContent.Definitions, (LethalContentDefinition definition) => (!TryFindFeatureAssembly(definition.PluginGuid, out assembly)) ? null : assembly); } public ContentRegistrationReport RegisterModuleContent(string moduleName, Assembly featureAssembly) { if (string.IsNullOrWhiteSpace(moduleName)) { throw new ArgumentException("A module name is required.", "moduleName"); } if ((object)featureAssembly == null) { throw new ArgumentNullException("featureAssembly"); } return RegisterDefinitions(KnownLethalContent.Definitions.Where((LethalContentDefinition definition) => string.Equals(definition.ModuleName, moduleName, StringComparison.Ordinal)), (LethalContentDefinition _) => featureAssembly); } private ContentRegistrationReport RegisterDefinitions(IEnumerable<LethalContentDefinition> definitions, Func<LethalContentDefinition, Assembly?> resolveAssembly) { int num = 0; int num2 = 0; int num3 = 0; HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); HashSet<string> hashSet2 = new HashSet<string>(StringComparer.Ordinal); foreach (LethalContentDefinition definition in definitions) { if (!settings.IsEnabled(definition.ModuleName)) { num2++; continue; } if (registeredAssets.Contains(definition.AssetPath)) { num2++; continue; } Assembly assembly = resolveAssembly(definition); if ((object)assembly == null) { if (hashSet2.Add(definition.ModuleName)) { log.LogDebug((object)("Skipping '" + definition.ModuleName + "' content because plugin '" + definition.PluginGuid + "' is not installed.")); } num2++; continue; } if (hashSet2.Contains(definition.ModuleName)) { num3++; continue; } if (!hashSet.Contains(definition.ModuleName)) { if (!assets.TryLoadModuleBundle(definition.ModuleName, assembly, out AssetBundle _)) { hashSet2.Add(definition.ModuleName); num3++; continue; } hashSet.Add(definition.ModuleName); } try { if (!Register(definition, assembly)) { num3++; continue; } registeredAssets.Add(definition.AssetPath); num++; } catch (Exception ex) { log.LogError((object)$"Failed to register {definition.Kind} asset '{definition.AssetPath}' for '{definition.ModuleName}': {ex}"); num3++; } } return new ContentRegistrationReport(num, num2, num3); } private bool Register(LethalContentDefinition definition, Assembly featureAssembly) { string bundle = ChaosAssetPaths.BundleName(definition.ModuleName); switch (definition.Kind) { case LethalContentKind.NaturalEnemy: { if (!TryResolveAsset<EnemyType>(bundle, definition, featureAssembly, out EnemyType asset2) || !Object.op_Implicit((Object)(object)asset2)) { return Missing(definition, "EnemyType"); } if (!ValidateEnemy(definition, asset2)) { return false; } RegisterNetworkPrefab(asset2.enemyPrefab, definition); int num = settings.Rarity(definition.ModuleName, definition.Rarity); Enemies.RegisterEnemy(asset2, num, (LevelTypes)(-1), (TerminalNode)null, (TerminalKeyword)null); log.LogInfo((object)$"Registered enemy '{asset2.enemyName}' from '{definition.ModuleName}' at rarity {num}."); return true; } case LethalContentKind.ScrapItem: { if (!TryResolveAsset<Item>(bundle, definition, featureAssembly, out Item asset3) || !Object.op_Implicit((Object)(object)asset3)) { return Missing(definition, "Item"); } if (!ValidateItem(definition, asset3)) { return false; } RegisterNetworkPrefab(asset3.spawnPrefab, definition); int num2 = settings.Rarity(definition.ModuleName, definition.Rarity); Items.RegisterScrap(asset3, num2, (LevelTypes)(-1)); log.LogInfo((object)$"Registered scrap '{asset3.itemName}' from '{definition.ModuleName}' at rarity {num2}."); return true; } case LethalContentKind.PlainItem: { if (!TryResolveAsset<Item>(bundle, definition, featureAssembly, out Item asset4) || !Object.op_Implicit((Object)(object)asset4)) { return Missing(definition, "Item"); } if (!ValidateItem(definition, asset4)) { return false; } RegisterNetworkPrefab(asset4.spawnPrefab, definition); Items.RegisterItem(asset4); log.LogInfo((object)("Registered non-random item '" + asset4.itemName + "' from '" + definition.ModuleName + "'.")); return true; } case LethalContentKind.NetworkPrefab: { if (!TryResolveAsset<GameObject>(bundle, definition, featureAssembly, out GameObject asset) || !Object.op_Implicit((Object)(object)asset)) { return Missing(definition, "GameObject"); } RegisterNetworkPrefab(asset, definition); log.LogInfo((object)("Registered supporting network prefab '" + ((Object)asset).name + "' from '" + definition.ModuleName + "'.")); return true; } default: throw new ArgumentOutOfRangeException("definition", definition.Kind, "Unsupported content kind."); } } private bool TryResolveAsset<T>(string bundle, LethalContentDefinition definition, Assembly featureAssembly, out T? asset) where T : Object { if (assets.TryLoadAssetIfPresent<T>(bundle, definition.AssetPath, out asset) && Object.op_Implicit((Object)(object)asset)) { return true; } if (fallbackFactory.TryCreate(definition, featureAssembly, out Object created)) { T val = (T)(object)((created is T) ? created : null); if (val != null && Object.op_Implicit((Object)(object)val)) { asset = val; log.LogInfo((object)("Using original in-memory definition for '" + definition.AssetPath + "'. It was built from the module visual prefab and component '" + ((object)val).GetType().Name + "'; no game asset was copied.")); return true; } } asset = default(T); return false; } private bool ValidateEnemy(LethalContentDefinition definition, EnemyType enemyType) { if (!Object.op_Implicit((Object)(object)enemyType.enemyPrefab)) { return Invalid(definition, "EnemyType.enemyPrefab is missing"); } if (!Object.op_Implicit((Object)(object)enemyType.enemyPrefab.GetComponentInChildren<EnemyAI>(true))) { return Invalid(definition, "enemy prefab has no EnemyAI component"); } return ValidateNetworkPrefab(definition, enemyType.enemyPrefab); } private bool ValidateItem(LethalContentDefinition definition, Item item) { if (!Object.op_Implicit((Object)(object)item.spawnPrefab)) { return Invalid(definition, "Item.spawnPrefab is missing"); } if (!Object.op_Implicit((Object)(object)item.spawnPrefab.GetComponentInChildren<GrabbableObject>(true))) { return Invalid(definition, "item prefab has no GrabbableObject component"); } return ValidateNetworkPrefab(definition, item.spawnPrefab); } private bool ValidateNetworkPrefab(LethalContentDefinition definition, GameObject prefab) { if (!Object.op_Implicit((Object)(object)prefab.GetComponent<NetworkObject>())) { return Invalid(definition, "prefab '" + ((Object)prefab).name + "' has no root NetworkObject component"); } return true; } private void RegisterNetworkPrefab(GameObject prefab, LethalContentDefinition definition) { if (!ValidateNetworkPrefab(definition, prefab)) { throw new InvalidOperationException("Invalid network prefab '" + ((Object)prefab).name + "'."); } Utilities.FixMixerGroups(prefab); NetworkPrefabs.RegisterNetworkPrefab(prefab); } private bool Missing(LethalContentDefinition definition, string expectedType) { log.LogError((object)("Required " + expectedType + " asset '" + definition.AssetPath + "' is missing from bundle '" + ChaosAssetPaths.BundleName(definition.ModuleName) + "'; '" + definition.ModuleName + "' content was not registered.")); return false; } private bool Invalid(LethalContentDefinition definition, string reason) { log.LogError((object)("Asset '" + definition.AssetPath + "' for '" + definition.ModuleName + "' is invalid: " + reason + "; content was not registered.")); return false; } private static bool TryFindFeatureAssembly(string pluginGuid, out Assembly? assembly) { if (Chainloader.PluginInfos.TryGetValue(pluginGuid, out var value) && Object.op_Implicit((Object)(object)value.Instance)) { assembly = ((object)value.Instance).GetType().Assembly; return true; } assembly = null; return false; } } internal sealed class RuntimeContentFactory { private readonly record struct EnemyRecipe(GameObject Prefab, EnemyType Type, EnemyAI Behaviour); private readonly record struct ItemRecipe(GameObject Prefab, Item Item, GrabbableObject Behaviour); private readonly AssetBundleRegistry assets; private readonly ManualLogSource log; private readonly Dictionary<string, Object> generated = new Dictionary<string, Object>(StringComparer.Ordinal); private readonly HashSet<string> builtModules = new HashSet<string>(StringComparer.Ordinal); internal RuntimeContentFactory(AssetBundleRegistry assets, ManualLogSource log) { this.assets = assets; this.log = log; } internal bool TryCreate(LethalContentDefinition definition, Assembly featureAssembly, out Object? created) { if (generated.TryGetValue(definition.AssetPath, out created) && Object.op_Implicit(created)) { return true; } if (!builtModules.Contains(definition.ModuleName)) { if (!TryLoadVisual(definition.ModuleName, out GameObject visual)) { created = null; return false; } try { BuildModule(definition.ModuleName, featureAssembly, visual); builtModules.Add(definition.ModuleName); log.LogInfo((object)("Built startup-only content definitions for '" + definition.ModuleName + "'. Templates are hidden and are not spawned by the factory.")); } catch (Exception arg) { log.LogError((object)$"Could not build fallback content for '{definition.ModuleName}': {arg}"); created = null; return false; } } if (generated.TryGetValue(definition.AssetPath, out created)) { return Object.op_Implicit(created); } return false; } private bool TryLoadVisual(string module, out GameObject? visual) { if (assets.TryLoadAsset<GameObject>(ChaosAssetPaths.BundleName(module), ChaosAssetPaths.VisualPrefab(module), out visual)) { return Object.op_Implicit((Object)(object)visual); } return false; } private void BuildModule(string module, Assembly assembly, GameObject visual) { //IL_0184: Unknown result type (might be due to invalid IL or missing references) switch (module) { case "NewtonsApple": { ItemRecipe itemRecipe3 = CreateItem("NewtonsApple", "BlackAppleCore", null, visual, 65, 110, 1.08f); Cache(ChaosAssetPaths.ItemDefinition(module, "BlackAppleCoreItem"), (Object)(object)itemRecipe3.Item); EnemyRecipe enemyRecipe2 = CreateEnemy(module, "NewtonsAppleEnemy", RequireType(assembly, "ChaosSuite.NewtonsApple.NewtonsAppleEnemy"), visual, 1.5f, 2); BoxCollider val = CreateChild(enemyRecipe2.Prefab.transform, "InfluenceVolume").AddComponent<BoxCollider>(); ((Collider)val).isTrigger = true; val.size = new Vector3(14f, 6f, 14f); SetField(enemyRecipe2.Behaviour, "influenceVolume", val); SetField(enemyRecipe2.Behaviour, "stem", FindChild(enemyRecipe2.Prefab.transform, "Stem") ?? enemyRecipe2.Prefab.transform); SetField(enemyRecipe2.Behaviour, "blackCorePrefab", itemRecipe3.Prefab); Cache(ChaosAssetPaths.EnemyType(module), (Object)(object)enemyRecipe2.Type); break; } case "JobApplication": { Type behaviourType = RequireType(assembly, "ChaosSuite.JobApplication.JobApplicationItem"); Type behaviourType2 = RequireType(assembly, "ChaosSuite.JobApplication.ApplicantEnemyAI"); Type behaviourType3 = RequireType(assembly, "ChaosSuite.JobApplication.PaperEmployeeAI"); ItemRecipe itemRecipe4 = CreateItem(module, "JobApplication", behaviourType, visual, 35, 65, 1.02f); EnemyRecipe enemyRecipe3 = CreateEnemy(module, "ApplicantEnemy", behaviourType2, visual, 1.2f, 1); EnemyRecipe enemyRecipe4 = CreateEnemy(module, "PaperEmployee", behaviourType3, visual, 0.6f, 3); SetField(itemRecipe4.Behaviour, "applicantEnemyPrefab", enemyRecipe3.Prefab); GameObject val2 = CreateChild(itemRecipe4.Prefab.transform, "ResumeSheet"); SetField(itemRecipe4.Behaviour, "resumeSheet", val2.transform); SetField(itemRecipe4.Behaviour, "announcementSource", AddSpatialAudio(itemRecipe4.Prefab)); GameObject val3 = CreatePaperCocoon(enemyRecipe3.Prefab.transform); val3.SetActive(false); SetField(enemyRecipe3.Behaviour, "paperEmployeePrefab", enemyRecipe4.Prefab); SetField(enemyRecipe3.Behaviour, "cocoonVisual", val3); SetField(enemyRecipe4.Behaviour, "applicationPrefab", itemRecipe4.Prefab); Cache(ChaosAssetPaths.ItemDefinition(module), (Object)(object)itemRecipe4.Item); Cache(ChaosAssetPaths.NetworkPrefab(module, "ApplicantEnemy"), (Object)(object)enemyRecipe3.Prefab); Cache(ChaosAssetPaths.NetworkPrefab(module, "PaperEmployee"), (Object)(object)enemyRecipe4.Prefab); break; } case "Professor": CacheEnemy(module, "ProfessorEnemy", "ChaosSuite.Professor.ProfessorEnemyAI", assembly, visual, 2f, 1); break; case "Webhead": CacheEnemy(module, "WebheadEnemy", "ChaosSuite.Webhead.WebheadEnemyAI", assembly, visual, 2f, 2); break; case "HorrorBowler": { EnemyRecipe enemyRecipe = CreateEnemy(module, "HorrorBowlerEnemy", RequireType(assembly, "ChaosSuite.HorrorBowler.HorrorBowlerEnemyAI"), visual, 3f, 1); Transform? obj = FindChild(enemyRecipe.Prefab.transform, "Boulder"); GameObject obj2 = ((obj != null) ? ((Component)obj).gameObject : null) ?? throw new InvalidOperationException("Horror Bowler fallback visual does not contain a Boulder child."); obj2.AddComponent<SphereCollider>().radius = 0.8f; Type type = RequireType(assembly, "ChaosSuite.HorrorBowler.BoulderController"); Component value = obj2.AddComponent(type); SetField(enemyRecipe.Behaviour, "boulder", value); Cache(ChaosAssetPaths.EnemyType(module), (Object)(object)enemyRecipe.Type); break; } case "MonkeysPaw": { ItemRecipe itemRecipe = CreateItem(module, "CursedFortune", null, visual, 90, 150, 1.05f); ItemRecipe itemRecipe2 = CreateItem(module, "MonkeysPaw", RequireType(assembly, "ChaosSuite.MonkeysPaw.MonkeysPawItem"), visual, 75, 135, 1.04f); SetField(itemRecipe2.Behaviour, "cursedFortunePrefab", itemRecipe.Prefab); SetField(itemRecipe2.Behaviour, "pawAudio", AddSpatialAudio(itemRecipe2.Prefab)); Cache(ChaosAssetPaths.ItemDefinition(module), (Object)(object)itemRecipe2.Item); Cache(ChaosAssetPaths.ItemDefinition(module, "CursedFortuneItem"), (Object)(object)itemRecipe.Item); break; } case "Relocator": CacheEnemy(module, "RelocatorEnemy", "ChaosSuite.Quagmire.RelocatorEnemyAI", assembly, visual, 2f, 1); break; default: throw new InvalidOperationException("No fallback content recipe exists for module '" + module + "'."); } } private void CacheEnemy(string module, string prefabName, string typeName, Assembly assembly, GameObject visual, float power, int maximum) { EnemyRecipe enemyRecipe = CreateEnemy(module, prefabName, RequireType(assembly, typeName), visual, power, maximum); Cache(ChaosAssetPaths.EnemyType(module), (Object)(object)enemyRecipe.Type); } private EnemyRecipe CreateEnemy(string module, string prefabName, Type behaviourType, GameObject visual, float power, int maximum) { //IL_00ac: 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_00c3: Expected O, but got Unknown //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Expected O, but got Unknown if (!typeof(EnemyAI).IsAssignableFrom(behaviourType)) { throw new InvalidOperationException("Fallback type '" + behaviourType.FullName + "' is not an EnemyAI."); } GameObject val = NetworkPrefabs.CreateNetworkPrefab("ChaosSuite_" + prefabName + "_Fallback"); NavMeshAgent val2 = val.AddComponent<NavMeshAgent>(); val2.radius = 0.45f; val2.height = 1.8f; val2.speed = 3.2f; val2.angularSpeed = 180f; val2.acceleration = 12f; CapsuleCollider obj = val.AddComponent<CapsuleCollider>(); obj.radius = 0.42f; obj.height = 1.8f; obj.center = new Vector3(0f, 0.9f, 0f); EnemyAI val3 = (EnemyAI)val.AddComponent(behaviourType); GameObject val4 = AttachVisual(val, visual, prefabName); Type type = Type.GetType("UnityEngine.Animator, UnityEngine.AnimationModule", throwOnError: true); Component value = val4.GetComponentInChildren(type, true) ?? val4.AddComponent(type); Component value2 = AddSpatialAudio(val); Component value3 = AddSpatialAudio(val); GameObject obj2 = CreateChild(val.transform, "EnemyCollisionDetector"); CapsuleCollider obj3 = obj2.AddComponent<CapsuleCollider>(); ((Collider)obj3).isTrigger = true; obj3.radius = 0.5f; obj3.height = 1.8f; EnemyAICollisionDetect obj4 = obj2.AddComponent<EnemyAICollisionDetect>(); obj4.mainScript = val3; obj4.canCollideWithEnemies = true; EnemyType val5 = ScriptableObject.CreateInstance<EnemyType>(); ((Object)val5).name = prefabName + "EnemyTypeFallback"; ((Object)val5).hideFlags = (HideFlags)61; val5.enemyName = FriendlyName(module); val5.enemyPrefab = val; val5.PowerLevel = Mathf.Clamp(power, 0.5f, 10f); val5.MaxCount = Mathf.Clamp(maximum, 1, 8); val5.canDie = true; val5.canBeDestroyed = true; val5.destroyOnDeath = true; val5.canBeStunned = true; val5.stunTimeMultiplier = 1f; val5.doorSpeedMultiplier = 1f; val5.probabilityCurve = AnimationCurve.Linear(0f, 1f, 1f, 1f); val5.numberSpawnedFalloff = AnimationCurve.Linear(0f, 1f, 1f, 0.2f); val5.useNumberSpawnedFalloff = true; val5.spawnInGroupsOf = 1; val3.enemyType = val5; val3.agent = val2; SetField(val3, "creatureAnimator", value); SetField(val3, "creatureVoice", value2); SetField(val3, "creatureSFX", value3); val3.meshRenderers = val4.GetComponentsInChildren<MeshRenderer>(true); val3.skinnedMeshRenderers = val4.GetComponentsInChildren<SkinnedMeshRenderer>(true); val3.enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[1] { new EnemyBehaviourState { name = "Active" } }; val3.AIIntervalTime = 0.2f; return new EnemyRecipe(val, val5, val3); } private ItemRecipe CreateItem(string module, string prefabName, Type? behaviourType, GameObject visual, int minimumValue, int maximumValue, float weight) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown if ((object)behaviourType != null && !typeof(GrabbableObject).IsAssignableFrom(behaviourType)) { throw new InvalidOperationException("Fallback type '" + behaviourType.FullName + "' is not a GrabbableObject."); } GameObject val = NetworkPrefabs.CreateNetworkPrefab("ChaosSuite_" + prefabName + "_Fallback"); Rigidbody val2 = val.AddComponent<Rigidbody>(); val2.mass = 1f; val2.collisionDetectionMode = (CollisionDetectionMode)1; BoxCollider val3 = val.AddComponent<BoxCollider>(); val3.size = new Vector3(0.45f, 0.3f, 0.45f); GrabbableObject val4 = (GrabbableObject)val.AddComponent(behaviourType ?? typeof(RuntimeFallbackItem)); if (val4 == null || !Object.op_Implicit((Object)(object)val4)) { throw new InvalidOperationException("Unity could not add fallback item component '" + (behaviourType ?? typeof(RuntimeFallbackItem)).FullName + "'."); } GameObject val5 = AttachVisual(val, visual, prefabName); Item val6 = ScriptableObject.CreateInstance<Item>(); ((Object)val6).name = prefabName + "ItemFallback"; ((Object)val6).hideFlags = (HideFlags)61; val6.itemName = FriendlyName(prefabName); val6.spawnPrefab = val; val6.isScrap = true; val6.itemSpawnsOnGround = true; val6.canBeGrabbedBeforeGameStart = true; val6.weight = Mathf.Clamp(weight, 1f, 3.75f); val6.minValue = Math.Max(1, minimumValue); val6.maxValue = Math.Max(val6.minValue, maximumValue); val6.highestSalePercentage = 100; val6.grabAnimationTime = 0.4f; val6.verticalOffset = 0.05f; val6.spawnPositionTypes = new List<ItemGroup>(); val6.toolTips = new string[2] { "Use item : [LMB]", "Alternate use : [RMB]" }; val6.meshVariants = Array.Empty<Mesh>(); val6.materialVariants = Array.Empty<Material>(); val4.itemProperties = val6; val4.propBody = val2; val4.propColliders = (Collider[])(object)new Collider[1] { (Collider)val3 }; int visited = 0; val4.mainObjectRenderer = FindFirstActiveMeshRenderer(val5.transform, 0, ref visited) ?? throw new InvalidOperationException("Fallback item '" + prefabName + "' selected a presentation form with no active MeshRenderer."); val4.grabbable = true; val4.grabbableToEnemies = true; return new ItemRecipe(val, val6, val4); } private static GameObject AttachVisual(GameObject prefab, GameObject visual, string prefabName) { GameObject obj = Object.Instantiate<GameObject>(visual, prefab.transform, false); ((Object)obj).name = ((Object)visual).name + "_FallbackVisual"; SelectPresentationForm(obj.transform, prefabName); return obj; } private static void SelectPresentationForm(Transform visual, string prefabName) { Transform val = FindChild(visual, "EnemyForm"); Transform val2 = FindChild(visual, "ItemForm"); Transform val3 = FindChild(visual, "PawForm"); Transform val4 = FindChild(visual, "FortuneForm"); bool flag = prefabName == "BlackAppleCore" || prefabName == "JobApplication"; if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(!flag); } if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(flag); } if ((Object)(object)val3 != (Object)null) { ((Component)val3).gameObject.SetActive(prefabName == "MonkeysPaw"); } if ((Object)(object)val4 != (Object)null) { ((Component)val4).gameObject.SetActive(prefabName == "CursedFortune"); } } private static Component AddSpatialAudio(GameObject prefab) { Type type = Type.GetType("UnityEngine.AudioSource, UnityEngine.AudioModule", throwOnError: true); Component obj = prefab.AddComponent(type); SetProperty(obj, "playOnAwake", false); SetProperty(obj, "spatialBlend", 1f); SetProperty(obj, "minDistance", 2f); SetProperty(obj, "maxDistance", 28f); return obj; } private static GameObject CreateChild(Transform parent, string name) { //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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown GameObject val = new GameObject(name) { hideFlags = (HideFlags)61 }; val.transform.SetParent(parent, false); return val; } private static GameObject CreatePaperCocoon(Transform parent) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00bc: 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_0157: Unknown result type (might be due to invalid IL or missing references) GameObject val = CreateChild(parent, "PaperCocoon"); val.transform.localPosition = Vector3.up * 0.85f; Material sharedMaterial = new Material(Shader.Find("Standard")) { color = new Color(0.48f, 0.42f, 0.31f, 1f) }; Material sharedMaterial2 = new Material(Shader.Find("Standard")) { color = new Color(0.055f, 0.045f, 0.035f, 1f) }; GameObject obj = GameObject.CreatePrimitive((PrimitiveType)1); ((Object)obj).name = "CrumpledPaperShell"; obj.transform.SetParent(val.transform, false); obj.transform.localScale = new Vector3(0.75f, 1.05f, 0.62f); obj.GetComponent<Renderer>().sharedMaterial = sharedMaterial; Collider component = obj.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } for (int i = 0; i < 3; i++) { GameObject obj2 = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)obj2).name = "PaperBinding" + i; obj2.transform.SetParent(val.transform, false); obj2.transform.localPosition = Vector3.up * (-0.48f + (float)i * 0.48f); obj2.transform.localScale = new Vector3(0.62f, 0.035f, 0.52f); obj2.GetComponent<Renderer>().sharedMaterial = sharedMaterial2; Collider component2 = obj2.GetComponent<Collider>(); if ((Object)(object)component2 != (Object)null) { Object.Destroy((Object)(object)component2); } } return val; } private static Transform? FindChild(Transform root, string name) { if (string.Equals(((Object)root).name, name, StringComparison.Ordinal)) { return root; } for (int i = 0; i < root.childCount; i++) { Transform val = FindChild(root.GetChild(i), name); if (Object.op_Implicit((Object)(object)val)) { return val; } } return null; } private static MeshRenderer? FindFirstActiveMeshRenderer(Transform root, int depth, ref int visited) { if (!Object.op_Implicit((Object)(object)root) || depth > 24 || visited++ >= 512 || !((Component)root).gameObject.activeSelf) { return null; } MeshRenderer component = ((Component)root).GetComponent<MeshRenderer>(); if ((Object)(object)component != (Object)null && Object.op_Implicit((Object)(object)component) && ((Renderer)component).enabled) { return component; } int num = Math.Min(root.childCount, 512 - visited); for (int i = 0; i < num; i++) { MeshRenderer val = FindFirstActiveMeshRenderer(root.GetChild(i), depth + 1, ref visited); if ((Object)(object)val != (Object)null) { return val; } } return null; } private static Type RequireType(Assembly assembly, string fullName) { return assembly.GetType(fullName, throwOnError: false, ignoreCase: false) ?? throw new TypeLoadException("Feature assembly '" + assembly.GetName().Name + "' does not contain required fallback component '" + fullName + "'."); } private static void SetField(object target, string fieldName, object value) { FieldInfo field = target.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if ((object)field == null) { throw new MissingFieldException(target.GetType().FullName, fieldName); } if (!field.FieldType.IsInstanceOfType(value)) { throw new InvalidOperationException("Cannot assign '" + value.GetType().FullName + "' to '" + target.GetType().FullName + "." + fieldName + "'."); } field.SetValue(target, value); } private static void SetProperty(object target, string propertyName, object value) { PropertyInfo property = target.GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public); if ((object)property == null || !property.CanWrite) { throw new MissingMemberException(target.GetType().FullName, propertyName); } property.SetValue(target, value, null); } private void Cache(string path, Object value) { if (!Object.op_Implicit(value)) { throw new InvalidOperationException("Fallback asset '" + path + "' is null."); } generated[path] = value; } private static string FriendlyName(string value) { if (string.IsNullOrEmpty(value)) { return "Chaos Content"; } StringBuilder stringBuilder = new StringBuilder(value.Length + 6); for (int i = 0; i < value.Length; i++) { if (i > 0 && char.IsUpper(value[i]) && char.IsLower(value[i - 1])) { stringBuilder.Append(' '); } stringBuilder.Append(value[i]); } return stringBuilder.ToString(); } } public sealed class RuntimeFallbackItem : GrabbableObject { } public static class KnownLethalContent { private static readonly IReadOnlyList<LethalContentDefinition> definitions = Array.AsReadOnly(new LethalContentDefinition[11] { Enemy("NewtonsApple", "com.chaossuite.newtonsapple", 18), PlainItem("NewtonsApple", "com.chaossuite.newtonsapple", "BlackAppleCoreItem"), Scrap("JobApplication", "com.chaossuite.jobapplication", 14), Prefab("JobApplication", "com.chaossuite.jobapplication", "ApplicantEnemy"), Prefab("JobApplication", "com.chaossuite.jobapplication", "PaperEmployee"), Enemy("Professor", "com.chaossuite.professor", 12), Enemy("Webhead", "com.chaossuite.webhead", 15), Enemy("HorrorBowler", "com.chaossuite.horrorbowler", 9), Scrap("MonkeysPaw", "com.chaossuite.monkeyspaw", 8), PlainItem("MonkeysPaw", "com.chaossuite.monkeyspaw", "CursedFortuneItem"), Enemy("Relocator", "com.chaossuite.relocator", 11) }); public static readonly IReadOnlyList<string> Modules = Array.AsReadOnly(new string[8] { "MasklessMimic", "NewtonsApple", "JobApplication", "Professor", "Webhead", "HorrorBowler", "MonkeysPaw", "Relocator" }); public static readonly IReadOnlyList<FallbackComponentDefinition> FallbackComponents = Array.AsReadOnly(new FallbackComponentDefinition[9] { new FallbackComponentDefinition("NewtonsApple", "NewtonsAppleEnemy", "ChaosSuite.NewtonsApple.NewtonsAppleEnemy"), new FallbackComponentDefinition("JobApplication", "JobApplication", "ChaosSuite.JobApplication.JobApplicationItem"), new FallbackComponentDefinition("JobApplication", "ApplicantEnemy", "ChaosSuite.JobApplication.ApplicantEnemyAI"), new FallbackComponentDefinition("JobApplication", "PaperEmployee", "ChaosSuite.JobApplication.PaperEmployeeAI"), new FallbackComponentDefinition("Professor", "ProfessorEnemy", "ChaosSuite.Professor.ProfessorEnemyAI"), new FallbackComponentDefinition("Webhead", "WebheadEnemy", "ChaosSuite.Webhead.WebheadEnemyAI"), new FallbackComponentDefinition("HorrorBowler", "HorrorBowlerEnemy", "ChaosSuite.HorrorBowler.HorrorBowlerEnemyAI"), new FallbackComponentDefinition("MonkeysPaw", "MonkeysPaw", "ChaosSuite.MonkeysPaw.MonkeysPawItem"), new FallbackComponentDefinition("Relocator", "RelocatorEnemy", "ChaosSuite.Quagmire.RelocatorEnemyAI") }); public static IReadOnlyList<LethalContentDefinition> Definitions => definitions; private static LethalContentDefinition Enemy(string module, string guid, int rarity) { return new LethalContentDefinition(module, guid, LethalContentKind.NaturalEnemy, ChaosAssetPaths.EnemyType(module), rarity); } private static LethalContentDefinition Scrap(string module, string guid, int rarity) { return new LethalContentDefinition(module, guid, LethalContentKind.ScrapItem, ChaosAssetPaths.ItemDefinition(module), rarity); } private static LethalContentDefinition PlainItem(string module, string guid, string itemName) { return new LethalContentDefinition(module, guid, LethalContentKind.PlainItem, ChaosAssetPaths.ItemDefinition(module, itemName), 0); } private static LethalContentDefinition Prefab(string module, string guid, string prefabName) { return new LethalContentDefinition(module, guid, LethalContentKind.NetworkPrefab, ChaosAssetPaths.NetworkPrefab(module, prefabName), 0); } } internal static class LifecyclePatches { private static readonly MethodInfo ClearRoundMethod = AccessTools.Method(typeof(LifecyclePatches), "ClearRound", (Type[])null, (Type[])null); private static readonly MethodInfo ClearLevelMethod = AccessTools.Method(typeof(LifecyclePatches), "ClearLevel", (Type[])null, (Type[])null); private static readonly MethodInfo ClearMenuMethod = AccessTools.Method(typeof(LifecyclePatches), "ClearMenu", (Type[])null, (Type[])null); private static readonly MethodInfo ClientDisconnectedMethod = AccessTools.Method(typeof(LifecyclePatches), "ClientDisconnected", (Type[])null, (Type[])null); private static readonly MethodInfo PlayerRemovedMethod = AccessTools.Method(typeof(LifecyclePatches), "PlayerRemoved", (Type[])null, (Type[])null); private static readonly MethodInfo NetworkObjectDespawnedMethod = AccessTools.Method(typeof(LifecyclePatches), "NetworkObjectDespawned", (Type[])null, (Type[])null); private static readonly MethodInfo PlayerTeleportedMethod = AccessTools.Method(typeof(LifecyclePatches), "PlayerTeleported", (Type[])null, (Type[])null); private static EffectCleanupRegistry? Registry => ChaosSuiteRuntimePlugin.Instance?.Cleanup; internal static int Install(Harmony harmony, ManualLogSource log) { //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown int num = 0; num += PatchPrefix(harmony, log, typeof(StartOfRound), "ShipLeave", Type.EmptyTypes, ClearRoundMethod); num += PatchPrefix(harmony, log, typeof(StartOfRound), "ChangeLevel", new Type[1] { typeof(int) }, ClearLevelMethod); num += PatchPrefix(harmony, log, typeof(GameNetworkManager), "Disconnect", Type.EmptyTypes, ClearMenuMethod); num += PatchPrefix(harmony, log, typeof(StartOfRound), "OnDestroy", Type.EmptyTypes, ClearMenuMethod); num += PatchPostfix(harmony, log, typeof(StartOfRound), "OnClientDisconnect", new Type[1] { typeof(ulong) }, ClientDisconnectedMethod); num += PatchPostfix(harmony, log, typeof(PlayerControllerB), "KillPlayer", new Type[6] { typeof(Vector3), typeof(bool), typeof(CauseOfDeath), typeof(int), typeof(Vector3), typeof(bool) }, PlayerRemovedMethod); num += PatchPrefix(harmony, log, typeof(PlayerControllerB), "OnDestroy", Type.EmptyTypes, PlayerRemovedMethod); num += PatchPrefix(harmony, log, typeof(NetworkObject), "InvokeBehaviourNetworkDespawn", Type.EmptyTypes, NetworkObjectDespawnedMethod); MethodInfo[] array = (from method in AccessTools.GetDeclaredMethods(typeof(PlayerControllerB)) where method.Name == "TeleportPlayer" select method).ToArray(); if (array.Length == 0) { log.LogError((object)"Required lifecycle hook was not found: PlayerControllerB.TeleportPlayer. Teleporter cleanup safety is degraded for this game version."); } for (int num2 = 0; num2 < array.Length; num2++) { harmony.Patch((MethodBase)array[num2], (HarmonyMethod)null, new HarmonyMethod(PlayerTeleportedMethod), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); num++; log.LogDebug((object)("Installed lifecycle hook: " + array[num2].DeclaringType?.FullName + "." + array[num2].Name + ".")); } return num; } private static int PatchPrefix(Harmony harmony, ManualLogSource log, Type type, string name, Type[] arguments, MethodInfo callback) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown return Patch(harmony, log, type, name, arguments, new HarmonyMethod(callback), null); } private static int PatchPostfix(Harmony harmony, ManualLogSource log, Type type, string name, Type[] arguments, MethodInfo callback) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown return Patch(harmony, log, type, name, arguments, null, new HarmonyMethod(callback)); } private static int Patch(Harmony harmony, ManualLogSource log, Type type, string name, Type[] arguments, HarmonyMethod? prefix, HarmonyMethod? postfix) { MethodInfo methodInfo = AccessTools.DeclaredMethod(type, name, arguments, (Type[])null); if ((object)methodInfo == null) { log.LogError((object)("Required lifecycle hook was not found: " + type.FullName + "." + name + ". Runtime cleanup safety is degraded for this game version.")); return 0; } harmony.Patch((MethodBase)methodInfo, prefix, postfix, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); log.LogDebug((object)("Installed lifecycle hook: " + methodInfo.DeclaringType?.FullName + "." + methodInfo.Name + ".")); return 1; } private static void ClearRound() { ClearAll("ship departure"); } private static void ClearLevel() { ClearAll("level change"); } private static void ClearMenu() { ClearAll("disconnect or return to menu"); } private static void ClearAll(string reason) { Registry?.Clear(reason); ChaosSuiteRuntimePlugin.Instance?.Noise.Clear(); ChaosSuiteRuntimePlugin.Instance?.ThreatBudget.Clear(); } private static void ClientDisconnected(ulong clientId) { Registry?.ReleaseOwner(clientId, "client disconnected"); ChaosSuiteRuntimePlugin.Instance?.SynchronizedConfig.ForgetClient(clientId); } private static void PlayerRemoved(PlayerControllerB __instance) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) EffectCleanupRegistry registry = Registry; if (registry != null && Object.op_Implicit((Object)(object)__instance)) { registry.ReleaseAffectedOwner(__instance.actualClientId, "player death or despawn"); if (((NetworkBehaviour)__instance).NetworkObjectId != 0L) { registry.Release(new EntityId(((NetworkBehaviour)__instance).NetworkObjectId), "player death or despawn"); } } } private static void NetworkObjectDespawned(NetworkObject __instance) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)__instance) && __instance.NetworkObjectId != 0L) { Registry?.Release(new EntityId(__instance.NetworkObjectId), "network object despawned"); } } private static void PlayerTeleported(PlayerControllerB __instance) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (TeleportCleanupGuard.IsSuppressed) { return; } EffectCleanupRegistry registry = Registry; if (registry != null && Object.op_Implicit((Object)(object)__instance)) { registry.ReleaseAffectedOwner(__instance.actualClientId, "player teleported"); if (((NetworkBehaviour)__instance).NetworkObjectId != 0L) { registry.Release(new EntityId(((NetworkBehaviour)__instance).NetworkObjectId), "player teleported"); } } } } public static class ConfigSnapshotCodec { private const uint Magic = 1129530182u; private const ushort Version = 1; public const int MaximumEntries = 256; public const int MaximumPacketBytes = 32768; private const int MaximumKeyBytes = 256; private const int MaximumValueBytes = 4096; public static byte[] Encode(IReadOnlyDictionary<string, string> values) { if (values == null) { throw new ArgumentNullException("values"); } if (values.Count > 256) { throw new ArgumentException($"A config snapshot may contain at most {256} entries.", "values"); } using MemoryStream memoryStream = new MemoryStream(); using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream, Encoding.UTF8, leaveOpen: true)) { binaryWriter.Write(1129530182u); binaryWriter.Write((ushort)1); binaryWriter.Write((ushort)values.Count); List<string> list = new List<string>(values.Keys); list.Sort(StringComparer.Ordinal); foreach (string item in list) { WriteString(binaryWriter, item, 256); WriteString(binaryWriter, values[item], 4096); } } if (memoryStream.Length > 32768) { throw new InvalidDataException($"Encoded config snapshot exceeds {32768} bytes."); } return memoryStream.ToArray(); } public static IReadOnlyDictionary<string, string> Decode(byte[] payload) { if (payload == null) { throw new ArgumentNullException("payload"); } if (payload.Length > 32768) { throw new InvalidDataException("Config snapshot is too large."); } using MemoryStream memoryStream = new MemoryStream(payload, writable: false); using BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.UTF8, leaveOpen: false); if (binaryReader.ReadUInt32() != 1129530182) { throw new InvalidDataException("Config snapshot magic is invalid."); } if (binaryReader.ReadUInt16() != 1) { throw new InvalidDataException("Config snapshot protocol version is unsupported."); } ushort num = binaryReader.ReadUInt16(); if (num > 256) { throw new InvalidDataException("Config snapshot contains too many entries."); } Dictionary<string, string> dictionary = new Dictionary<string, string>(num, StringComparer.Ordinal); for (int i = 0; i < num; i++) { string text = ReadString(binaryReader, 256); string value = ReadString(binaryReader, 4096); if (!dictionary.TryAdd(text, value)) { throw new InvalidDataException("Config snapshot repeats key '" + text + "'."); } } if (memoryStream.Position != memoryStream.Length) { throw new InvalidDataException("Config snapshot has trailing data."); } return dictionary; } private static void WriteString(BinaryWriter writer, string value, int maximumBytes) { if (value == null) { throw new ArgumentNullException("value"); } byte[] bytes = Encoding.UTF8.GetBytes(value); if (bytes.Length > maximumBytes) { throw new InvalidDataException($"Config text exceeds its {maximumBytes}-byte limit."); } writer.Write((ushort)bytes.Length); writer.Write(bytes); } private static string ReadString(BinaryReader reader, int maximumBytes) { ushort num = reader.ReadUInt16(); if (num > maximumBytes) { throw new InvalidDataException("Config text exceeds its length limit."); } byte[] array = reader.ReadBytes(num); if (array.Length != num) { throw new EndOfStreamException("Config snapshot ended inside a text value."); } return new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true).GetString(array); } } public sealed class SynchronizedConfigEntry<T> { private readonly ConfigEntry<T> localEntry; private T effectiveValue; public T Value => effectiveValue; public T LocalValue => localEntry.Value; internal SynchronizedConfigEntry(ConfigEntry<T> localEntry) { this.localEntry = localEntry; effectiveValue = localEntry.Value; } internal string SerializeLocal() { return TomlTypeConverter.ConvertToString((object)localEntry.Value, typeof(T)); } internal void UseLocal() { effectiveValue = localEntry.Value; } internal void ApplyRemote(string value) { effectiveValue = (T)TomlTypeConverter.ConvertToValue(value, typeof(T)); } internal void Unsubscribe(EventHandler handler) { localEntry.SettingChanged -= handler; } } public sealed class SynchronizedConfigService : IDisposable { private interface IBinding { string SerializeLocal(); void ApplyRemote(string value); void UseLocal(); void Unsubscribe(EventHandler handler); } private sealed class Binding<T> : IBinding { private readonly SynchronizedConfigEntry<T> entry; internal Binding(SynchronizedConfigEntry<T> entry) { this.entry = entry; } public string SerializeLocal() { return entry.SerializeLocal(); } public void ApplyRemote(string value) { entry.ApplyRemote(value); } public void UseLocal() { entry.UseLocal(); } public void Unsubscribe(EventHandler handler) { entry.Unsubscribe(handler); } } private const string MessageName = "ChaosSuite.Config.v1"; private const byte RequestMessage = 1; private const byte SnapshotMessage = 2; private const byte AcknowledgementMessage = 3; private const double RequestMinimumInterval = 1.0; private const double RejectionLogMinimumInterval = 2.0; private readonly ManualLogSource log; private readonly Dictionary<string, IBinding> bindings = new Dictionary<string, IBinding>(StringComparer.Ordinal); private readonly HashSet<ulong> synchronizedClients = new HashSet<ulong>(); private readonly RateLimiter requestLimiter = new RateLimiter(); private readonly RateLimiter rejectionLogLimiter = new RateLimiter(); private NetworkManager? attachedManager; private bool dirty; private float nextBroadcastTime; internal SynchronizedConfigService(ManualLogSource log) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown this.log = log; } public SynchronizedConfigEntry<T> Register<T>(string key, ConfigEntry<T> entry) { ValidateKey(key); if (entry == null) { throw new ArgumentNullException("entry"); } if (!TomlTypeConverter.CanConvert(typeof(T))) { throw new NotSupportedException("BepInEx cannot serialize synchronized config type " + typeof(T).FullName + "."); } SynchronizedConfigEntry<T> synchronizedConfigEntry = new SynchronizedConfigEntry<T>(entry); if (!bindings.TryAdd(key, new Binding<T>(synchronizedConfigEntry))) { throw new InvalidOperationException("Synchronized config key '" + key + "' is already registered."); } entry.SettingChanged += LocalSettingChanged; dirty = true; return synchronizedConfigEntry; } public void Tick() { NetworkManager singleton = NetworkManager.Singleton; if (singleton == null || !Object.op_Implicit((Object)(object)singleton) || !singleton.IsListening) { Detach(); return; } if (singleton != attachedManager) { Attach(singleton); } if (singleton.IsServer && dirty && Time.unscaledTime >= nextBroadcastTime) { BroadcastSnapshot(); nextBroadcastTime = Time.unscaledTime + 0.25f; } } public void ForgetClient(ulong clientId) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) EntityId val = ClientRateKey(clientId); requestLimiter.Clear(val); rejectionLogLimiter.Clear(val); if (synchronizedClients.Remove(clientId)) { log.LogDebug((object)$"Released synchronized-config session state for client {clientId}."); } } public bool IsClientSynchronized(ulong clientId) { return synchronizedClients.Contains(clientId); } public void Dispose() { foreach (IBinding value in bindings.Values) { value.Unsubscribe(LocalSettingChanged); } bindings.Clear(); Detach(); } private void Attach(NetworkManager manager) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown Detach(); attachedManager = manager; manager.CustomMessagingManager.RegisterNamedMessageHandler("ChaosSuite.Config.v1", new HandleNamedMessageDelegate(ReceiveMessage)); manager.OnClientConnectedCallback += ClientConnected; manager.OnClientDisconnectCallback += ClientDisconnected; foreach (IBinding value in bindings.Values) { value.UseLocal(); } if (manager.IsClient && !manager.IsServer) { SendRequest(); } if (manager.IsServer) { dirty = true; } } private void Detach() { NetworkManager val = attachedManager; if (val != null && Object.op_Implicit((Object)(object)val)) { val.CustomMessagingManager.UnregisterNamedMessageHandler("ChaosSuite.Config.v1"); val.OnClientConnectedCallback -= ClientConnected; val.OnClientDisconnectCallback -= ClientDisconnected; } attachedManager = null; synchronizedClients.Clear(); requestLimiter.ClearAll(); rejectionLogLimiter.ClearAll(); foreach (IBinding value in bindings.Values) { value.UseLocal(); } } private void LocalSettingChanged(object sender, EventArgs args) { NetworkManager val = attachedManager; if (val != null && Object.op_Implicit((Object)(object)val) && !val.IsServer) { return; } foreach (IBinding value in bindings.Values) { value.UseLocal(); } dirty = true; } private void ClientConnected(ulong clientId) { NetworkManager val = attachedManager; if (val != null && Object.op_Implicit((Object)(object)val)) { if (val.IsServer && clientId != 0L) { SendSnapshot(clientId); } else if (!val.IsServer && clientId == val.LocalClientId) { SendRequest(); } } } private void ClientDisconnected(ulong clientId) { ForgetClient(clientId); NetworkManager val = attachedManager; if (val == null || !Object.op_Implicit((Object)(object)val) || clientId != val.LocalClientId) { return; } foreach (IBinding value in bindings.Values) { value.UseLocal(); } } private void ReceiveMessage(ulong senderId, FastBufferReader reader) { //IL_010a: 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_00aa: 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 val = attachedManager; if (val == null || !Object.op_Implicit((Object)(object)val)) { return; } try { byte b = default(byte); ((FastBufferReader)(ref reader)).ReadByteSafe(ref b); switch (b) { case 1: if (val.IsServer && val.ConnectedClients.ContainsKey(senderId) && requestLimiter.TryAcquire(ClientRateKey(senderId), Time.unscaledTimeAsDouble, 1.0)) { SendSnapshot(senderId); } break; case 3: if (val.IsServer && val.ConnectedClients.ContainsKey(senderId)) { synchronizedClients.Add(senderId); } break; case 2: if (!val.IsServer && senderId == 0L) { int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); if (num < 0 || num > 32768 || num > ((FastBufferReader)(ref reader)).Length - ((FastBufferReader)(ref reader)).Position) { throw new InvalidDataException("Config snapshot payload length is invalid."); } byte[] payload = null; ((FastBufferReader)(ref reader)).ReadBytesSafe(ref payload, num, 0); ApplySnapshot(ConfigSnapshotCodec.Decode(payload)); SendAcknowledgement(); } break; } } catch (Exception ex) { if (rejectionLogLimiter.TryAcquire(ClientRateKey(senderId), Time.unscaledTimeAsDouble, 2.0)) { log.LogWarning((object)$"Rejected synchronized config message from client {senderId}: {ex.Message}"); } } } private void ApplySnapshot(IReadOnlyDictionary<string, string> values) { foreach (IBinding value2 in bindings.Values) { value2.UseLocal(); } foreach (KeyValuePair<string, string> value3 in values) { if (bindings.TryGetValue(value3.Key, out IBinding value)) { try { value.ApplyRemote(value3.Value); } catch (Exception ex) { log.LogWarning((object)("Rejected synchronized config value '" + value3.Key + "': " + ex.Message)); } } } log.LogDebug((object)$"Applied {values.Count} host config values."); } private unsafe void SendRequest() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = attachedManager; if (val == null || !Object.op_Implicit((Object)(object)val) || !val.IsClient || val.IsServer) { return; } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(1, (Allocator)2, -1); try { ((FastBufferWriter)(ref val2)).WriteByteSafe((byte)1); val.CustomMessagingManager.SendNamedMessage("ChaosSuite.Config.v1", 0uL, val2, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose(); } } private unsafe void SendAcknowledgement() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = attachedManager; if (val == null || !Object.op_Implicit((Object)(object)val) || !val.IsClient || val.IsServer) { return; } FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(1, (Allocator)2, -1); try { ((FastBufferWriter)(ref val2)).WriteByteSafe((byte)3); val.CustomMessagingManager.SendNamedMessage("ChaosSuite.Config.v1", 0uL, val2, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose(); } } private void BroadcastSnapshot() { NetworkManager val = attachedManager; if (val == null || !Object.op_Implicit((Object)(object)val) || !val.IsServer) { return; } foreach (ulong connectedClientsId in val.ConnectedClientsIds) { if (connectedClientsId != 0L) { SendSnapshot(connectedClientsId); } } dirty = false; } private unsafe void SendSnapshot(ulong clientId) { //IL_00b1: 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_00d6: Unknown result type (might be due to invalid IL or missing references) NetworkManager val = attachedManager; if (val == null || !Object.op_Implicit((Object)(object)val) || !val.IsServer || !val.ConnectedClients.ContainsKey(clientId)) { return; } Dictionary<string, string> dictionary = new Dictionary<string, string>(bindings.Count, StringComparer.Ordinal); foreach (KeyValuePair<string, IBinding> binding in bindings) { dictionary.Add(binding.Key, binding.Value.SerializeLocal()); } byte[] array = ConfigSnapshotCodec.Encode(dictionary); FastBufferWriter val2 = default(FastBufferWriter); ((FastBufferWriter)(ref val2))..ctor(array.Length + 8, (Allocator)2, -1); try { ((FastBufferWriter)(ref val2)).WriteByteSafe((byte)2); int num = array.Length; ((FastBufferWriter)(ref val2)).WriteValueSafe<int>(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val2)).WriteBytesSafe(array, array.Length, 0); val.CustomMessagingManager.SendNamedMessage("ChaosSuite.Config.v1", clientId, val2, (NetworkDelivery)3); synchronizedClients.Remove(clientId); } finally { ((IDisposable)(*(FastBufferWriter*)(&val2))/*cast due to .constrained prefix*/).Dispose(); } } private static void ValidateKey(string key) { if (string.IsNullOrWhiteSpace(key) || key.Length > 128) { throw new ArgumentException("Synchronized config keys must contain 1-128 characters.", "key"); } } private static EntityId ClientRateKey(ulong clientId) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) return new EntityId(clientId + 1); } } } namespace System.Runtime.CompilerServices { internal static class IsExternalInit { } }
plugins/ChaosSuite-JobApplication/ChaosSuite.JobApplication.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using ChaosSuite.Core; using ChaosSuite.JobApplication.NetcodePatcher; using ChaosSuite.Runtime; using GameNetcodeStuff; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Netcode; using UnityEngine; [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("ChaosSuite.JobApplication")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a3464fa3098fa6be253d588a5b7ca9ba01bef4dd")] [assembly: AssemblyProduct("ChaosSuite.JobApplication")] [assembly: AssemblyTitle("ChaosSuite.JobApplication")] [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 ChaosSuite.JobApplication { public sealed class ApplicantEnemyAI : EnemyAI { private const double FatalOutcomeRetryInterval = 0.75; private const double FatalOutcomeTimeout = 4.0; private const byte FatalOutcomeMaximumAttempts = 5; private readonly CocoonController cocoon = new CocoonController(); private readonly Dictionary<ulong, double> nextRescueHitAt = new Dictionary<ulong, double>(); private readonly ulong[] fatalOutcomeTarget = new ulong[1]; private readonly NetworkVariable<ulong> targetClient = new NetworkVariable<ulong>(ulong.MaxValue, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<byte> phase = new NetworkVariable<byte>((byte)3, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<double> rescueEndsAt = new NetworkVariable<double>(0.0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<byte> rescueIntegrity = new NetworkVariable<byte>((byte)0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private bool localCocoonApplied; private bool localMoveInputPrior; private double nextHudAt; private uint fatalOutcomeSequence; private uint pendingFatalOutcomeRevision; private ulong pendingFatalOutcomeClient = ulong.MaxValue; private Vector3 pendingFatalOutcomePosition; private Quaternion pendingFatalOutcomeRotation = Quaternion.identity; private int pendingFatalOutcomeSuit; private string pendingFatalOutcomeName = "EMPLOYEE"; private double nextFatalOutcomeRetryAt; private double fatalOutcomeExpiresAt; private byte fatalOutcomeAttempts; private bool fatalOutcomeAcknowledged; private ulong cleanupAffectedOwner = ulong.MaxValue; [Header("Authored prefab references")] [SerializeField] private GameObject paperEmployeePrefab; [SerializeField] private GameObject cocoonVisual; [SerializeField] [Min(1f)] private float rescueSeconds = 8f; [SerializeField] [Min(1f)] private int cocoonIntegrity = 4; public void InitializeTarget(ulong clientId) { if (((NetworkBehaviour)this).IsServer) { SetCleanupAffectedOwner(clientId); targetClient.Value = clientId; phase.Value = 3; } } public override void Start() { ((EnemyAI)this).Start(); base.AIIntervalTime = 0.15f; if ((Object)(object)((Component)this).GetComponentInChildren<Renderer>(true) == (Object)null && (Object)(object)JobApplicationPlugin.VisualPrefab != (Object)null) { Object.Instantiate<GameObject>(JobApplicationPlugin.VisualPrefab, ((Component)this).transform, false); } ChaosPresentation.TriggerAction((Component)(object)this); if ((Object)(object)base.creatureVoice != (Object)null && (Object)(object)JobApplicationPlugin.HiringClip != (Object)null) { base.creatureVoice.PlayOneShot(JobApplicationPlugin.HiringClip); } } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); RegisterPersistentCleanup(); NetworkVariable<byte> obj = phase; obj.OnValueChanged = (OnValueChangedDelegate<byte>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<byte>(OnCocoonStateChanged)); NetworkVariable<ulong> obj2 = targetClient; obj2.OnValueChanged = (OnValueChangedDelegate<ulong>)(object)Delegate.Combine((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<ulong>(OnTargetChanged)); RefreshLocalCocoon(); } public override void Update() { ((EnemyAI)this).Update(); RefreshLocalCocoon(); ShowCocoonHud(); } public override void DoAIInterval() { //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_00f1: 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_011d: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).DoAIInterval(); if (!((NetworkBehaviour)this).IsServer || base.isEnemyDead || (Object)(object)NetworkManager.Singleton == (Object)null) { return; } PlayerControllerB val = FindPlayer(targetClient.Value); NetworkTime serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; double time = ((NetworkTime)(ref serverTime)).Time; if (pendingFatalOutcomeClient != ulong.MaxValue) { AdvanceFatalOutcome(time); return; } if ((Object)(object)val == (Object)null || val.isPlayerDead || val.disconnectedMidGame || val.teleportedLastFrame || val.isInHangarShipRoom || (Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.shipIsLeaving || StartOfRound.Instance.inShipPhase) { ReleaseCocoon(); ((EnemyAI)this).KillEnemy(false); return; } if (phase.Value == 4) { if (cocoon.HasExpired(time)) { BeginFatalOutcome(val, time); } return; } base.targetPlayer = val; ((EnemyAI)this).SetMovingTowardsTargetPlayer(val); ((EnemyAI)this).SetDestinationToPosition(((Component)val).transform.position, true); ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.Noise.TryEmit(new EntityId(((NetworkBehaviour)this).NetworkObjectId), ((Component)this).transform.position, 28f, 0.8f, 71002, Time.timeAsDouble, 0.5, false); } } public override void OnCollideWithPlayer(Collider other) { //IL_0077: 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) ((EnemyAI)this).OnCollideWithPlayer(other); if (!((NetworkBehaviour)this).IsServer || phase.Value != 3) { return; } PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, true, false); if ((Object)(object)val == (Object)null || ((NetworkBehaviour)val).OwnerClientId != targetClient.Value) { return; } ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance == null || !instance.ThreatBudget.TryAcquire(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)0)) { return; } CocoonController cocoonController = cocoon; EntityId target = new EntityId(val.playerClientId + 1); int integrity = cocoonIntegrity; NetworkTime serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; if (!cocoonController.Begin(target, integrity, ((NetworkTime)(ref serverTime)).Time, rescueSeconds)) { ChaosSuiteRuntimePlugin instance2 = ChaosSuiteRuntimePlugin.Instance; if (instance2 != null) { instance2.ThreatBudget.Release(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)0, "applicant cocoon rejected"); } } else { phase.Value = 4; rescueEndsAt.Value = cocoon.State.RescueEndsAt; rescueIntegrity.Value = (byte)Mathf.Clamp(cocoon.State.Integrity, 0, 255); base.agent.isStopped = true; SetCocoonClientRpc(((NetworkBehaviour)val).OwnerClientId, active: true); } } public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsServer || (Object)(object)playerWhoHit == (Object)null) { return; } NetworkTime serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; if (!TryAuthorizeRescueHit(playerWhoHit, ((NetworkTime)(ref serverTime)).Time)) { return; } ((EnemyAI)this).HitEnemy(Mathf.Clamp(force, 1, 10), playerWhoHit, playHitSFX, hitID); if (cocoon.Strike(Math.Max(1, force))) { rescueIntegrity.Value = (byte)Mathf.Clamp(cocoon.State.Integrity, 0, 255); if (cocoon.State.Resolved) { ReleaseCocoon(); ((EnemyAI)this).KillEnemy(false); } } } private bool TryAuthorizeRescueHit(PlayerControllerB player, double now) { //IL_0071: 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_0076: 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_0083: 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_00bc: 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_00d6: 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_00e5: 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) if (RoundEnding() || pendingFatalOutcomeClient != ulong.MaxValue || phase.Value != 4 || player.isPlayerDead || player.disconnectedMidGame || (!(player.currentlyHeldObjectServer is Shovel) && !(player.currentlyHeldObjectServer is KnifeItem))) { return false; } Vector3 val = (((Object)(object)cocoonVisual != (Object)null) ? cocoonVisual.transform.position : ((Component)this).transform.position); if (Vector3.SqrMagnitude(((Component)player).transform.position - val) > 16f) { return false; } if (nextRescueHitAt.TryGetValue(((NetworkBehaviour)player).OwnerClientId, out var value) && now < value) { return false; } Vector3 val2 = ((Component)player).transform.position + Vector3.up * 1.2f + ((Component)player).transform.forward * 0.35f; int num = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.collidersAndRoomMaskAndDefault : (-1)); RaycastHit val3 = default(RaycastHit); if (Physics.Linecast(val2, val, ref val3, num, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val3)).transform != (Object)(object)((Component)this).transform && !((RaycastHit)(ref val3)).transform.IsChildOf(((Component)this).transform)) { return false; } nextRescueHitAt[((NetworkBehaviour)player).OwnerClientId] = now + 0.18; return true; } private void BeginFatalOutcome(PlayerControllerB target, double now) { //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_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) if (((NetworkBehaviour)this).IsServer && pendingFatalOutcomeClient == ulong.MaxValue && !((Object)(object)target == (Object)null) && !target.isPlayerDead) { cocoon.Resolve(); fatalOutcomeSequence++; if (fatalOutcomeSequence == 0) { fatalOutcomeSequence = 1u; } pendingFatalOutcomeRevision = fatalOutcomeSequence; pendingFatalOutcomeClient = ((NetworkBehaviour)target).OwnerClientId; pendingFatalOutcomePosition = ((Component)target).transform.position; pendingFatalOutcomeRotation = ((Component)target).transform.rotation; pendingFatalOutcomeSuit = target.currentSuitID; pendingFatalOutcomeName = SanitizeName(target.playerUsername); fatalOutcomeExpiresAt = now + 4.0; nextFatalOutcomeRetryAt = now; fatalOutcomeAttempts = 0; fatalOutcomeAcknowledged = false; HiringFailurePresentationClientRpc(); AdvanceFatalOutcome(now); } } private void AdvanceFatalOutcome(double now) { //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_016a: 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) if (!((NetworkBehaviour)this).IsServer || pendingFatalOutcomeClient == ulong.MaxValue) { return; } PlayerControllerB val = FindPlayer(pendingFatalOutcomeClient); if ((Object)(object)val != (Object)null && Object.op_Implicit((Object)(object)val) && fatalOutcomeAcknowledged && val.isPlayerDead) { CommitFatalOutcome(); } else if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.shipIsLeaving || StartOfRound.Instance.inShipPhase || (Object)(object)val == (Object)null || !Object.op_Implicit((Object)(object)val) || val.disconnectedMidGame || (!val.isPlayerControlled && !val.isPlayerDead) || val.teleportedLastFrame || val.isInHangarShipRoom) { AbortFatalOutcome("target left the active round"); } else if (now >= fatalOutcomeExpiresAt) { AbortFatalOutcome("owner acknowledgement timed out"); } else if (fatalOutcomeAttempts < 5 && !(now < nextFatalOutcomeRetryAt)) { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || !singleton.ConnectedClients.ContainsKey(pendingFatalOutcomeClient)) { AbortFatalOutcome("target owner disconnected"); return; } fatalOutcomeAttempts++; nextFatalOutcomeRetryAt = now + 0.75; fatalOutcomeTarget[0] = pendingFatalOutcomeClient; ApplyHiringFailureClientRpc(pendingFatalOutcomeClient, pendingFatalOutcomeRevision, new ClientRpcParams { Send = new ClientRpcSendParams { TargetClientIds = fatalOutcomeTarget } }); } } private void CommitFatalOutcome() { //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_001b: 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_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) if (!((NetworkBehaviour)this).IsServer || pendingFatalOutcomeClient == ulong.MaxValue) { return; } Vector3 val = pendingFatalOutcomePosition; Quaternion val2 = pendingFatalOutcomeRotation; int suitId = pendingFatalOutcomeSuit; string sanitizedName = pendingFatalOutcomeName; ClearFatalOutcomeState(); if ((Object)(object)paperEmployeePrefab != (Object)null && PaperEmployeeAI.ActiveCount < 2) { GameObject val3 = Object.Instantiate<GameObject>(paperEmployeePrefab, val, val2); NetworkObject component = val3.GetComponent<NetworkObject>(); PaperEmployeeAI component2 = val3.GetComponent<PaperEmployeeAI>(); if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null) { component.Spawn(true); component2.InitializeSuit(suitId, sanitizedName); } else { Object.Destroy((Object)(object)val3); } } ReleaseCocoon(); ((EnemyAI)this).KillEnemy(false); } private void AbortFatalOutcome(string reason) { if (((NetworkBehaviour)this).IsServer && pendingFatalOutcomeClient != ulong.MaxValue) { Debug.LogWarning((object)("[ChaosSuite.JobApplication] Applicant fatal outcome cancelled: " + reason + ".")); ClearFatalOutcomeState(); ((EnemyAI)this).KillEnemy(false); } } private void ClearFatalOutcomeState() { //IL_0010: 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_001b: 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) pendingFatalOutcomeClient = ulong.MaxValue; pendingFatalOutcomeRevision = 0u; pendingFatalOutcomePosition = Vector3.zero; pendingFatalOutcomeRotation = Quaternion.identity; pendingFatalOutcomeSuit = 0; pendingFatalOutcomeName = "EMPLOYEE"; nextFatalOutcomeRetryAt = 0.0; fatalOutcomeExpiresAt = 0.0; fatalOutcomeAttempts = 0; fatalOutcomeAcknowledged = false; } private void ReleaseCocoon() { if (targetClient.Value != ulong.MaxValue) { SetCocoonClientRpc(targetClient.Value, active: false); } cocoon.Reset(); rescueEndsAt.Value = 0.0; rescueIntegrity.Value = 0; ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.ThreatBudget.Release(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)0, "applicant cocoon released"); } if ((Object)(object)base.agent != (Object)null && base.agent.isOnNavMesh) { base.agent.isStopped = false; } } private void RegisterPersistentCleanup() { if (((NetworkBehaviour)this).IsServer && !((Object)(object)((NetworkBehaviour)this).NetworkObject == (Object)null) && ((NetworkBehaviour)this).NetworkObject.IsSpawned) { ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.Cleanup.Register(((NetworkBehaviour)this).NetworkObject, (Action)CleanupPersistentEffect); } } } private void CleanupPersistentEffect() { if (((NetworkBehaviour)this).IsServer) { ClearFatalOutcomeState(); ReleaseCocoon(); SetCleanupAffectedOwner(ulong.MaxValue); targetClient.Value = ulong.MaxValue; if (phase.Value != 6) { phase.Value = 0; } ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.ThreatBudget.Release(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)2, "applicant persistent cleanup"); } } } private void SetCleanupAffectedOwner(ulong nextOwner) { //IL_003f: 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) if (((NetworkBehaviour)this).IsServer && cleanupAffectedOwner != nextOwner) { ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; EffectCleanupRegistry val = ((instance != null) ? instance.Cleanup : null); EntityId val2 = default(EntityId); ((EntityId)(ref val2))..ctor(((NetworkBehaviour)this).NetworkObjectId); if (cleanupAffectedOwner != ulong.MaxValue && val != null) { val.DisassociateAffectedOwner(val2, cleanupAffectedOwner); } cleanupAffectedOwner = nextOwner; if (cleanupAffectedOwner != ulong.MaxValue && val != null) { val.AssociateAffectedOwner(val2, cleanupAffectedOwner); } } } [ClientRpc] private void SetCocoonClientRpc(ulong target, bool active) { //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(2027601905u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, target); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref active, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2027601905u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if ((Object)(object)cocoonVisual != (Object)null) { cocoonVisual.SetActive(active); } if (active) { ChaosPresentation.TriggerAction((Component)(object)this); } RefreshLocalCocoon(); } } [ClientRpc] private void HiringFailurePresentationClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(26811851u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 26811851u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ChaosPresentation.TriggerAction((Component)(object)this); } } } [ClientRpc] private void ApplyHiringFailureClientRpc(ulong target, uint outcomeRevision, ClientRpcParams clientRpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2848090098u, clientRpcParams, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, target); BytePacker.WriteValueBitPacked(val, outcomeRevision); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2848090098u, clientRpcParams, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; NetworkManager singleton = NetworkManager.Singleton; if (singleton == null || singleton.LocalClientId != target) { return; } PlayerControllerB val2 = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val2 == (Object)null) && ((NetworkBehaviour)val2).OwnerClientId == target) { if (!val2.isPlayerDead) { val2.DamagePlayer(200, true, true, (CauseOfDeath)5, 0, false, default(Vector3)); } if (val2.isPlayerDead) { AcknowledgeHiringFailureServerRpc(outcomeRevision); } } } [ServerRpc(RequireOwnership = false)] private void AcknowledgeHiringFailureServerRpc(uint outcomeRevision, ServerRpcParams rpc = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_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) //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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2688439296u, rpc, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, outcomeRevision); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 2688439296u, rpc, (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 && pendingFatalOutcomeClient != ulong.MaxValue && rpc.Receive.SenderClientId == pendingFatalOutcomeClient && outcomeRevision != 0 && outcomeRevision == pendingFatalOutcomeRevision) { fatalOutcomeAcknowledged = true; PlayerControllerB val2 = FindPlayer(pendingFatalOutcomeClient); if ((Object)(object)val2 != (Object)null && val2.isPlayerDead) { CommitFatalOutcome(); } } } public override void KillEnemy(bool destroy = false) { if (((NetworkBehaviour)this).IsServer) { ClearFatalOutcomeState(); } if (!base.isEnemyDead) { ReleaseCocoon(); } if (((NetworkBehaviour)this).IsServer) { SetCleanupAffectedOwner(ulong.MaxValue); ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.ThreatBudget.Release(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)2, "applicant ended"); } } ((EnemyAI)this).KillEnemy(destroy); } public override void OnNetworkDespawn() { RestoreLocalCocoonInput(); if (((NetworkBehaviour)this).IsServer) { ClearFatalOutcomeState(); ReleaseCocoon(); } else { cocoon.Reset(); } NetworkVariable<byte> obj = phase; obj.OnValueChanged = (OnValueChangedDelegate<byte>)(object)Delegate.Remove((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<byte>(OnCocoonStateChanged)); NetworkVariable<ulong> obj2 = targetClient; obj2.OnValueChanged = (OnValueChangedDelegate<ulong>)(object)Delegate.Remove((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<ulong>(OnTargetChanged)); if (((NetworkBehaviour)this).IsServer) { SetCleanupAffectedOwner(ulong.MaxValue); ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.ThreatBudget.Release(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)2, "applicant despawned"); } } nextRescueHitAt.Clear(); ((NetworkBehaviour)this).OnNetworkDespawn(); } private void OnDisable() { RestoreLocalCocoonInput(); } private void RestoreLocalCocoonInput() { if ((Object)(object)cocoonVisual != (Object)null) { cocoonVisual.SetActive(false); } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (localCocoonApplied && !((Object)(object)val == (Object)null)) { val.disableMoveInput = localMoveInputPrior; localCocoonApplied = false; } } private void RefreshLocalCocoon() { bool flag = phase.Value == 4; if ((Object)(object)cocoonVisual != (Object)null) { cocoonVisual.SetActive(flag); } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; int num; if ((Object)(object)val != (Object)null) { NetworkManager singleton = NetworkManager.Singleton; num = ((((singleton != null) ? new ulong?(singleton.LocalClientId) : ((ulong?)null)) == targetClient.Value) ? 1 : 0); } else { num = 0; } bool flag2 = (byte)num != 0; if (!flag || !flag2) { RestoreLocalCocoonInput(); return; } if (!localCocoonApplied) { localMoveInputPrior = val.disableMoveInput; } val.disableMoveInput = true; localCocoonApplied = true; } private void ShowCocoonHud() { //IL_0064: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) if (phase.Value != 4 || Time.timeAsDouble < nextHudAt || (Object)(object)HUDManager.Instance == (Object)null) { return; } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; PlayerControllerB val2 = FindPlayer(targetClient.Value); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null) && !(Vector3.SqrMagnitude(((Component)val).transform.position - ((Component)val2).transform.position) > 64f)) { nextHudAt = Time.timeAsDouble + 1.0; double value = rescueEndsAt.Value; NetworkManager singleton = NetworkManager.Singleton; double num; if (singleton == null) { num = Time.timeAsDouble; } else { NetworkTime serverTime = singleton.ServerTime; num = ((NetworkTime)(ref serverTime)).Time; } double num2 = Math.Max(0.0, Math.Ceiling(value - num)); NetworkManager singleton2 = NetworkManager.Singleton; string text = ((((singleton2 != null) ? new ulong?(singleton2.LocalClientId) : ((ulong?)null)) == targetClient.Value) ? "PAPER COCOON" : "RESCUE THE APPLICANT"); HUDManager.Instance.DisplayTip(text, $"{num2:0}s remaining - {rescueIntegrity.Value} tear hits", true, false, "ChaosSuite_ApplicantCocoon"); } } private void OnCocoonStateChanged(byte previous, byte current) { RefreshLocalCocoon(); } private void OnTargetChanged(ulong previous, ulong current) { RefreshLocalCocoon(); } private static PlayerControllerB? FindPlayer(ulong clientId) { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return null; } for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null && ((NetworkBehaviour)array[i]).OwnerClientId == clientId) { return array[i]; } } return null; } private static bool RoundEnding() { if (Object.op_Implicit((Object)(object)StartOfRound.Instance) && !StartOfRound.Instance.shipIsLeaving) { return StartOfRound.Instance.inShipPhase; } return true; } private static string SanitizeName(string value) { if (string.IsNullOrWhiteSpace(value)) { return "EMPLOYEE"; } char[] array = new char[Math.Min(value.Length, 24)]; int num = 0; for (int i = 0; i < value.Length; i++) { if (num >= array.Length) { break; } bool flag = char.IsLetterOrDigit(value[i]); if (!flag) { char c = value[i]; bool flag2 = ((c == ' ' || c == '-' || c == '_') ? true : false); flag = flag2; } if (flag) { array[num++] = value[i]; } } if (num != 0) { return new string(array, 0, num); } return "EMPLOYEE"; } protected override void __initializeVariables() { if (targetClient == null) { throw new Exception("ApplicantEnemyAI.targetClient cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)targetClient).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)targetClient, "targetClient"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)targetClient); if (phase == null) { throw new Exception("ApplicantEnemyAI.phase cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)phase).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)phase, "phase"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)phase); if (rescueEndsAt == null) { throw new Exception("ApplicantEnemyAI.rescueEndsAt cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)rescueEndsAt).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)rescueEndsAt, "rescueEndsAt"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)rescueEndsAt); if (rescueIntegrity == null) { throw new Exception("ApplicantEnemyAI.rescueIntegrity cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)rescueIntegrity).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)rescueIntegrity, "rescueIntegrity"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)rescueIntegrity); ((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 ((NetworkBehaviour)this).__registerRpc(2027601905u, new RpcReceiveHandler(__rpc_handler_2027601905), "SetCocoonClientRpc"); ((NetworkBehaviour)this).__registerRpc(26811851u, new RpcReceiveHandler(__rpc_handler_26811851), "HiringFailurePresentationClientRpc"); ((NetworkBehaviour)this).__registerRpc(2848090098u, new RpcReceiveHandler(__rpc_handler_2848090098), "ApplyHiringFailureClientRpc"); ((NetworkBehaviour)this).__registerRpc(2688439296u, new RpcReceiveHandler(__rpc_handler_2688439296), "AcknowledgeHiringFailureServerRpc"); ((EnemyAI)this).__initializeRpcs(); } private static void __rpc_handler_2027601905(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) { ulong target2 = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref target2); bool active = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref active, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((ApplicantEnemyAI)(object)target).SetCocoonClientRpc(target2, active); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_26811851(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((ApplicantEnemyAI)(object)target).HiringFailurePresentationClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2848090098(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_003d: 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_0043: 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_0060: 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) { ulong target2 = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref target2); uint outcomeRevision = default(uint); ByteUnpacker.ReadValueBitPacked(reader, ref outcomeRevision); ClientRpcParams client = rpcParams.Client; target.__rpc_exec_stage = (__RpcExecStage)1; ((ApplicantEnemyAI)(object)target).ApplyHiringFailureClientRpc(target2, outcomeRevision, client); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2688439296(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_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_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_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { uint outcomeRevision = default(uint); ByteUnpacker.ReadValueBitPacked(reader, ref outcomeRevision); ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((ApplicantEnemyAI)(object)target).AcknowledgeHiringFailureServerRpc(outcomeRevision, server); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "ApplicantEnemyAI"; } } public sealed class PaperEmployeeAI : EnemyAI { internal const int MaximumActive = 2; private readonly NetworkVariable<int> suit = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<FixedString32Bytes> employeeName = new NetworkVariable<FixedString32Bytes>(default(FixedString32Bytes), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); [SerializeField] private GameObject applicationPrefab; private double nextAttachAt; private bool countedActive; internal static int ActiveCount { get; private set; } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); if (((NetworkBehaviour)this).IsServer && !countedActive) { countedActive = true; ActiveCount++; } } public void InitializeSuit(int suitId, string sanitizedName) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsServer) { suit.Value = Mathf.Max(0, suitId); employeeName.Value = FixedString32Bytes.op_Implicit(sanitizedName); } } public override void Start() { ((EnemyAI)this).Start(); base.enemyHP = 1; base.AIIntervalTime = 0.25f; } public override void DoAIInterval() { //IL_008a: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).DoAIInterval(); if (((NetworkBehaviour)this).IsServer && !base.isEnemyDead) { if (RoundEnding()) { ((EnemyAI)this).KillEnemy(false); } else if (((EnemyAI)this).TargetClosestPlayer(1.5f, false, 70f, false, true, true) && !((Object)(object)base.targetPlayer == (Object)null) && !base.targetPlayer.isPlayerDead && !base.targetPlayer.disconnectedMidGame && !base.targetPlayer.isInHangarShipRoom) { ((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer); ((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, true); } } } public override void OnCollideWithPlayer(Collider other) { //IL_0048: 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_0065: 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_0097: 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_00eb: 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) ((EnemyAI)this).OnCollideWithPlayer(other); if (!((NetworkBehaviour)this).IsServer || base.isEnemyDead || RoundEnding()) { return; } PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false); if ((Object)(object)val == (Object)null || val.isInHangarShipRoom || val.disconnectedMidGame) { return; } NetworkTime serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; if (((NetworkTime)(ref serverTime)).Time < nextAttachAt) { return; } serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; nextAttachAt = ((NetworkTime)(ref serverTime)).Time + 8.0; ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.Noise.TryEmit(new EntityId(((NetworkBehaviour)this).NetworkObjectId), ((Component)val).transform.position, 24f, 0.7f, 71003, Time.timeAsDouble, 0.8, val.isInHangarShipRoom); } if (!((Object)(object)applicationPrefab == (Object)null)) { GameObject val2 = Object.Instantiate<GameObject>(applicationPrefab, ((Component)val).transform.position, ((Component)val).transform.rotation); NetworkObject component = val2.GetComponent<NetworkObject>(); if ((Object)(object)component != (Object)null) { component.Spawn(true); } else { Object.Destroy((Object)(object)val2); } ((EnemyAI)this).KillEnemy(false); } } public override void KillEnemy(bool destroy = false) { if (((NetworkBehaviour)this).IsServer) { ReleaseActiveSlot(); } ((EnemyAI)this).KillEnemy(destroy); } public override void OnNetworkDespawn() { if (((NetworkBehaviour)this).IsServer) { ReleaseActiveSlot(); } ((NetworkBehaviour)this).OnNetworkDespawn(); } private void ReleaseActiveSlot() { if (countedActive) { countedActive = false; ActiveCount = Math.Max(0, ActiveCount - 1); } } private static bool RoundEnding() { if (Object.op_Implicit((Object)(object)StartOfRound.Instance) && !StartOfRound.Instance.shipIsLeaving) { return StartOfRound.Instance.inShipPhase; } return true; } protected override void __initializeVariables() { if (suit == null) { throw new Exception("PaperEmployeeAI.suit cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)suit).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)suit, "suit"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)suit); if (employeeName == null) { throw new Exception("PaperEmployeeAI.employeeName cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)employeeName).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)employeeName, "employeeName"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)employeeName); ((EnemyAI)this).__initializeVariables(); } protected override void __initializeRpcs() { ((EnemyAI)this).__initializeRpcs(); } protected internal override string __getTypeName() { return "PaperEmployeeAI"; } } public enum ApplicantPhase : byte { Dormant, Attached, Announcing, Hiring, Cocooned, Minion, Destroyed } public enum QualificationEvent : byte { ScrapPickup, ValuableScrap, TwoHandedCarry, SustainedSprint, FacilityOperation, WalkieControl, Teamwork, SurvivedDamage, ReturnedScrap, IdleResponse, PropertyDrop } [Flags] public enum QualificationCategory : byte { None = 0, Productivity = 1, Initiative = 2, Teamwork = 4, All = 7 } public readonly record struct ApplicationState(ApplicantPhase Phase, EntityId Holder, int Score, double NextAnnouncementAt, uint Revision); public sealed class QualificationLedger { private readonly Dictionary<(EntityId, QualificationEvent), double> cooldowns = new Dictionary<(EntityId, QualificationEvent), double>(); public int Threshold => 7; public bool TryScore(ref ApplicationState state, QualificationEvent kind, int delta, double now, double cooldown) { //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_003c: Unknown result type (might be due to invalid IL or missing references) EntityId holder = state.Holder; bool flag = !((EntityId)(ref holder)).IsValid; if (!flag) { ApplicantPhase phase = state.Phase; bool flag2 = phase - 4 <= ApplicantPhase.Announcing; flag = flag2; } if (flag) { return false; } (EntityId, QualificationEvent) key = (state.Holder, kind); if (cooldowns.TryGetValue(key, out var value) && now < value) { return false; } cooldowns[key] = now + Math.Max(0.0, cooldown); QualificationCategory qualificationCategory = CategoryFor(kind); int num = state.Score; if (delta > 0) { num |= (int)qualificationCategory; } else if (delta < 0) { num &= (int)(~(uint)qualificationCategory); } num &= Threshold; if (num == state.Score) { return false; } state = state with { Score = num, Phase = ((num != Threshold) ? ApplicantPhase.Attached : ApplicantPhase.Hiring), Revision = state.Revision + 1 }; return true; } public bool TryTransfer(ref ApplicationState state, EntityId nextHolder, bool targetIsValid) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) bool flag = !targetIsValid || !((EntityId)(ref nextHolder)).IsValid || state.Holder == nextHolder; if (!flag) { ApplicantPhase phase = state.Phase; bool flag2 = ((phase - 3 <= ApplicantPhase.Attached || phase == ApplicantPhase.Destroyed) ? true : false); flag = flag2; } if (flag) { return false; } state = state with { Holder = nextHolder, Phase = ApplicantPhase.Attached, Revision = state.Revision + 1 }; return true; } public void Forget(EntityId holder) { //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) List<(EntityId, QualificationEvent)> list = new List<(EntityId, QualificationEvent)>(); foreach (KeyValuePair<(EntityId, QualificationEvent), double> cooldown in cooldowns) { if (cooldown.Key.Item1 == holder) { list.Add(cooldown.Key); } } foreach (var item in list) { cooldowns.Remove(item); } } public void Clear() { cooldowns.Clear(); } public static QualificationCategory CategoryFor(QualificationEvent kind) { switch (kind) { case QualificationEvent.ScrapPickup: case QualificationEvent.ValuableScrap: case QualificationEvent.TwoHandedCarry: case QualificationEvent.ReturnedScrap: case QualificationEvent.PropertyDrop: return QualificationCategory.Productivity; case QualificationEvent.SustainedSprint: case QualificationEvent.FacilityOperation: case QualificationEvent.WalkieControl: case QualificationEvent.SurvivedDamage: case QualificationEvent.IdleResponse: return QualificationCategory.Initiative; case QualificationEvent.Teamwork: return QualificationCategory.Teamwork; default: return QualificationCategory.None; } } } public readonly record struct CocoonState(EntityId Target, int Integrity, double RescueEndsAt, bool Resolved, uint Revision); public sealed class CocoonController { public CocoonState State { get; private set; } public bool Begin(EntityId target, int integrity, double now, double rescueSeconds) { //IL_0045: 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) if (((EntityId)(ref target)).IsValid && integrity >= 1 && !(rescueSeconds <= 0.0)) { if (!State.Resolved) { EntityId target2 = State.Target; if (((EntityId)(ref target2)).IsValid) { goto IL_0042; } } State = new CocoonState(target, integrity, now + rescueSeconds, Resolved: false, State.Revision + 1); return true; } goto IL_0042; IL_0042: return false; } public bool Strike(int force) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!State.Resolved) { EntityId target = State.Target; if (((EntityId)(ref target)).IsValid && force > 0) { int num = Math.Max(0, State.Integrity - force); State = State with { Integrity = num, Resolved = (num == 0), Revision = State.Revision + 1 }; return true; } } return false; } public bool HasExpired(double now) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!State.Resolved) { EntityId target = State.Target; if (((EntityId)(ref target)).IsValid) { return now >= State.RescueEndsAt; } } return false; } public void Resolve() { if (!State.Resolved) { State = State with { Resolved = true, Revision = State.Revision + 1 }; } } public void Reset() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) State = new CocoonState(EntityId.None, 0, 0.0, Resolved: true, State.Revision + 1); } } public sealed class JobApplicationItem : GrabbableObject, IHittable { private static readonly Collider[] TransferBuffer = (Collider[])(object)new Collider[32]; private readonly QualificationLedger ledger = new QualificationLedger(); private readonly NetworkVariable<ulong> holderClient = new NetworkVariable<ulong>(ulong.MaxValue, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<int> qualification = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<byte> applicantPhase = new NetworkVariable<byte>((byte)0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<ulong> entityAnchor = new NetworkVariable<ulong>(ulong.MaxValue, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<double> entityAnchorEndsAt = new NetworkVariable<double>(0.0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly Dictionary<ulong, uint> lastHitSequence = new Dictionary<ulong, uint>(); private readonly Dictionary<ulong, uint> lastTransferSequence = new Dictionary<ulong, uint>(); private readonly Dictionary<ulong, double> nextHitAt = new Dictionary<ulong, double>(); private readonly Dictionary<ulong, double> nextTransferAt = new Dictionary<ulong, double>(); private readonly Transform?[] qualificationChecks = (Transform?[])(object)new Transform[3]; private ApplicationState state = new ApplicationState(ApplicantPhase.Dormant, EntityId.None, 0, 0.0, 0u); private ulong lastHeldObjectId = ulong.MaxValue; private float sprintSeconds; private int lastHealth = 100; private int resumeIntegrity = 4; private double nextPoll; private double responseWindowAt; private uint localHitSequence; private uint localTransferSequence; private ulong cleanupAffectedOwner = ulong.MaxValue; [Header("Authored prefab references")] [SerializeField] private GameObject applicantEnemyPrefab; [SerializeField] private Transform resumeSheet; [SerializeField] private AudioSource announcementSource; [SerializeField] private AudioClip[] qualificationAnnouncements = Array.Empty<AudioClip>(); [SerializeField] [Min(1f)] private float transferRange = 2.5f; [SerializeField] [Min(1f)] private int valuableThreshold = 80; public override void Start() { ((GrabbableObject)this).Start(); if (qualificationAnnouncements.Length == 0) { qualificationAnnouncements = (AudioClip[])((JobApplicationPlugin.AnnouncementClips.Length != 0) ? JobApplicationPlugin.AnnouncementClips : ((!((Object)(object)JobApplicationPlugin.MechanicClip != (Object)null)) ? ((Array)Array.Empty<AudioClip>()) : ((Array)new AudioClip[1] { JobApplicationPlugin.MechanicClip }))); } CacheQualificationChecks(); UpdateQualificationChecks(qualification.Value); } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); RegisterPersistentCleanup(); NetworkVariable<int> obj = qualification; obj.OnValueChanged = (OnValueChangedDelegate<int>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<int>(OnQualificationChanged)); NetworkVariable<ulong> obj2 = holderClient; obj2.OnValueChanged = (OnValueChangedDelegate<ulong>)(object)Delegate.Combine((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<ulong>(OnPresentationHolderChanged)); NetworkVariable<byte> obj3 = applicantPhase; obj3.OnValueChanged = (OnValueChangedDelegate<byte>)(object)Delegate.Combine((Delegate?)(object)obj3.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<byte>(OnPresentationPhaseChanged)); NetworkVariable<ulong> obj4 = entityAnchor; obj4.OnValueChanged = (OnValueChangedDelegate<ulong>)(object)Delegate.Combine((Delegate?)(object)obj4.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<ulong>(OnPresentationAnchorChanged)); CacheQualificationChecks(); UpdateQualificationChecks(qualification.Value); RefreshAttachedPresentation(); } public override void Update() { //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_003d: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_00b2: 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_013a: 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_00cf: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) ((GrabbableObject)this).Update(); if (!((NetworkBehaviour)this).IsServer || (Object)(object)NetworkManager.Singleton == (Object)null) { return; } NetworkTime serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; double time = ((NetworkTime)(ref serverTime)).Time; EntityId holder; if (RoundEnding()) { holder = state.Holder; if (((EntityId)(ref holder)).IsValid || entityAnchor.Value != ulong.MaxValue || state.Phase != ApplicantPhase.Dormant) { ReleaseApplication(((Component)this).transform.position); } return; } if (entityAnchor.Value != ulong.MaxValue) { if (time >= entityAnchorEndsAt.Value || !TryResolveNetworkObject(entityAnchor.Value, out NetworkObject networkObject)) { ReleaseApplication(((Component)this).transform.position); } else { ((Component)this).transform.position = ((Component)networkObject).transform.position + Vector3.up * 0.55f; } return; } holder = state.Holder; if (!((EntityId)(ref holder)).IsValid && (Object)(object)base.playerHeldBy != (Object)null && !base.playerHeldBy.isPlayerDead) { Attach(base.playerHeldBy, time); } if (time < nextPoll) { return; } holder = state.Holder; if (!((EntityId)(ref holder)).IsValid) { return; } nextPoll = time + 0.5; PlayerControllerB val = FindPlayer(holderClient.Value); if ((Object)(object)val == (Object)null || val.isPlayerDead || val.disconnectedMidGame || val.teleportedLastFrame || val.isInHangarShipRoom || StartOfRound.Instance.shipIsLeaving || StartOfRound.Instance.inShipPhase) { ReleaseApplication((val != null) ? ((Component)val).transform.position : ((Component)this).transform.position); return; } Observe(val, time); if (state.Phase == ApplicantPhase.Hiring && time >= state.NextAnnouncementAt) { BeginHiring(val); } } public override void LateUpdate() { //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_0044: 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_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) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00e8: Unknown result type (might be due to invalid IL or missing references) ((GrabbableObject)this).LateUpdate(); if (entityAnchor.Value != ulong.MaxValue && TryResolveNetworkObject(entityAnchor.Value, out NetworkObject networkObject)) { ((Component)this).transform.SetPositionAndRotation(((Component)networkObject).transform.position + Vector3.up * 0.55f, ((Component)networkObject).transform.rotation); } else if (holderClient.Value != ulong.MaxValue) { PlayerControllerB val = FindPlayer(holderClient.Value); if (!((Object)(object)val == (Object)null)) { ((Component)this).transform.SetPositionAndRotation(((Component)val).transform.position - ((Component)val).transform.forward * 0.22f + Vector3.up * 1.35f, ((Component)val).transform.rotation * Quaternion.Euler(0f, 180f, 0f)); } } } public override void ItemActivate(bool used, bool buttonDown = true) { //IL_0053: 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) ((GrabbableObject)this).ItemActivate(used, buttonDown); if (((NetworkBehaviour)this).IsOwner && buttonDown && !((Object)(object)base.playerHeldBy == (Object)null)) { localTransferSequence++; if (localTransferSequence == 0) { localTransferSequence = 1u; } RequestTransferServerRpc(((NetworkBehaviour)base.playerHeldBy).OwnerClientId, localTransferSequence); } } bool IHittable.Hit(int force, Vector3 hitDirection, PlayerControllerB? playerWhoHit, bool playHitSFX, int hitID) { //IL_001b: 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_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) if ((Object)(object)playerWhoHit == (Object)null) { return false; } if (((NetworkBehaviour)this).IsServer) { NetworkTime serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; if (TryAuthorizeResumeHit(playerWhoHit, ((NetworkTime)(ref serverTime)).Time)) { ApplyResumeHit(force, playerWhoHit); } } else { localHitSequence++; if (localHitSequence == 0) { localHitSequence = 1u; } ResumeHitServerRpc(((NetworkBehaviour)playerWhoHit).OwnerClientId, localHitSequence); } return true; } [ServerRpc(RequireOwnership = false)] private void RequestTransferServerRpc(ulong claimedHolder, uint sequence, ServerRpcParams rpc = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //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_0145: 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_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: 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_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(686112506u, rpc, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, claimedHolder); BytePacker.WriteValueBitPacked(val, sequence); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 686112506u, rpc, (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 || RoundEnding() || rpc.Receive.SenderClientId != claimedHolder || claimedHolder != holderClient.Value || state.Phase != ApplicantPhase.Attached || sequence == 0 || (lastTransferSequence.TryGetValue(claimedHolder, out var value) && sequence <= value)) { return; } lastTransferSequence[claimedHolder] = sequence; NetworkTime serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; double time = ((NetworkTime)(ref serverTime)).Time; if (nextTransferAt.TryGetValue(claimedHolder, out var value2) && time < value2) { return; } nextTransferAt[claimedHolder] = time + 0.35; PlayerControllerB val2 = FindPlayer(claimedHolder); if ((Object)(object)val2 == (Object)null || val2.isPlayerDead) { return; } if (TryFindSupportedEntityAnchor(val2, out NetworkObject selected) && (Object)(object)selected != (Object)null) { SetCleanupAffectedOwner(ulong.MaxValue); entityAnchor.Value = selected.NetworkObjectId; entityAnchorEndsAt.Value = time + 15.0; state = state with { Holder = new EntityId(selected.NetworkObjectId + 1), Phase = ApplicantPhase.Attached, Revision = state.Revision + 1 }; holderClient.Value = ulong.MaxValue; Publish(); return; } PlayerControllerB val3 = null; float num = transferRange * transferRange; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val4 in allPlayerScripts) { if (!((Object)(object)val4 == (Object)null) && !((Object)(object)val4 == (Object)(object)val2) && !val4.isPlayerDead && val4.isPlayerControlled && val4.isInHangarShipRoom == val2.isInHangarShipRoom) { float num2 = Vector3.SqrMagnitude(((Component)val4).transform.position - ((Component)val2).transform.position); if (!(num2 >= num)) { num = num2; val3 = val4; } } } if (!((Object)(object)val3 == (Object)null) && ledger.TryTransfer(ref state, PlayerId(val3), targetIsValid: true)) { SetCleanupAffectedOwner(((NetworkBehaviour)val3).OwnerClientId); holderClient.Value = ((NetworkBehaviour)val3).OwnerClientId; Publish(); } } [ServerRpc(RequireOwnership = false)] private void ResumeHitServerRpc(ulong claimedPlayer, uint sequence, ServerRpcParams rpc = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3020773868u, rpc, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, claimedPlayer); BytePacker.WriteValueBitPacked(val, sequence); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 3020773868u, rpc, (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 || RoundEnding() || rpc.Receive.SenderClientId != claimedPlayer || sequence == 0 || (lastHitSequence.TryGetValue(claimedPlayer, out var value) && sequence <= value)) { return; } PlayerControllerB val2 = FindPlayer(claimedPlayer); if (!((Object)(object)val2 == (Object)null)) { NetworkTime serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; if (TryAuthorizeResumeHit(val2, ((NetworkTime)(ref serverTime)).Time)) { lastHitSequence[claimedPlayer] = sequence; ApplyResumeHit(1, val2); } } } private bool TryAuthorizeResumeHit(PlayerControllerB player, double now) { //IL_0062: 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_0067: 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_0073: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) if (RoundEnding() || state.Phase == ApplicantPhase.Destroyed || player.isPlayerDead || player.disconnectedMidGame || (!(player.currentlyHeldObjectServer is Shovel) && !(player.currentlyHeldObjectServer is KnifeItem))) { return false; } Vector3 val = (((Object)(object)resumeSheet != (Object)null) ? resumeSheet.position : ((Component)this).transform.position); if (Vector3.SqrMagnitude(((Component)player).transform.position - val) > 16f) { return false; } if (nextHitAt.TryGetValue(((NetworkBehaviour)player).OwnerClientId, out var value) && now < value) { return false; } Vector3 val2 = ((Component)player).transform.position + Vector3.up * 1.2f + ((Component)player).transform.forward * 0.35f; int num = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.collidersAndRoomMaskAndDefault : (-1)); RaycastHit val3 = default(RaycastHit); if (Physics.Linecast(val2, val, ref val3, num, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val3)).transform != (Object)(object)((Component)this).transform && !((RaycastHit)(ref val3)).transform.IsChildOf(((Component)this).transform)) { return false; } nextHitAt[((NetworkBehaviour)player).OwnerClientId] = now + 0.18; return true; } private void ApplyResumeHit(int force, PlayerControllerB player) { //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) if (!((NetworkBehaviour)this).IsServer || state.Phase == ApplicantPhase.Destroyed) { return; } resumeIntegrity = Math.Max(0, resumeIntegrity - 1); QualificationLedger qualificationLedger = ledger; ref ApplicationState reference = ref state; NetworkTime serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; qualificationLedger.TryScore(ref reference, QualificationEvent.PropertyDrop, -2, ((NetworkTime)(ref serverTime)).Time, 0.5); Publish(); if (resumeIntegrity <= 0) { state = state with { Phase = ApplicantPhase.Destroyed, Revision = state.Revision + 1 }; Publish(); if ((Object)(object)((NetworkBehaviour)this).NetworkObject != (Object)null && ((NetworkBehaviour)this).NetworkObject.IsSpawned) { ((NetworkBehaviour)this).NetworkObject.Despawn(true); } } } private void Attach(PlayerControllerB holder, double now) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null && instance.ThreatBudget.TryAcquire(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)2)) { state = new ApplicationState(ApplicantPhase.Attached, PlayerId(holder), 0, now + 4.0, state.Revision + 1); SetCleanupAffectedOwner(((NetworkBehaviour)holder).OwnerClientId); holderClient.Value = ((NetworkBehaviour)holder).OwnerClientId; entityAnchor.Value = ulong.MaxValue; entityAnchorEndsAt.Value = 0.0; lastHealth = holder.health; responseWindowAt = now + 18.0; Publish(); AttachPresentationClientRpc(((NetworkBehaviour)holder).OwnerClientId); } } [ClientRpc] private void AttachPresentationClientRpc(ulong targetClient) { //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) //IL_011f: 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) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2416355524u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, targetClient); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2416355524u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ApplyAttachedPresentation(attached: true); NetworkManager singleton = NetworkManager.Singleton; if (singleton != null && singleton.LocalClientId == targetClient) { PlayerControllerB val3 = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)val3?.currentlyHeldObjectServer == (Object)(object)this) { val3.DiscardHeldObject(false, (NetworkObject)null, default(Vector3), true); } } } private void Observe(PlayerControllerB holder, double now) { //IL_00c9: 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_019f: 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_0290: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) int score = state.Score; GrabbableObject currentlyHeldObjectServer = holder.currentlyHeldObjectServer; ulong num = (((Object)(object)currentlyHeldObjectServer != (Object)null) ? ((NetworkBehaviour)currentlyHeldObjectServer).NetworkObjectId : ulong.MaxValue); if ((Object)(object)currentlyHeldObjectServer != (Object)null && (Object)(object)currentlyHeldObjectServer != (Object)(object)this && num != lastHeldObjectId) { Score(QualificationEvent.ScrapPickup, 1, now, 1.0); if (currentlyHeldObjectServer.scrapValue >= valuableThreshold) { Score(QualificationEvent.ValuableScrap, 2, now, 5.0); } if (currentlyHeldObjectServer.itemProperties.twoHanded) { Score(QualificationEvent.TwoHandedCarry, 2, now, 5.0); } } if (lastHeldObjectId != ulong.MaxValue && (Object)(object)currentlyHeldObjectServer == (Object)null) { Score(QualificationEvent.PropertyDrop, -1, now, 2.0); } lastHeldObjectId = num; Vector3 playerVelocity; if (holder.isSprinting) { playerVelocity = holder.GetPlayerVelocity(); if (((Vector3)(ref playerVelocity)).sqrMagnitude > 4f) { sprintSeconds += 0.5f; if (sprintSeconds >= 3f) { Score(QualificationEvent.SustainedSprint, 2, now, 8.0); sprintSeconds = 0f; } goto IL_0126; } } sprintSeconds = 0f; goto IL_0126; IL_0126: if (holder.speakingToWalkieTalkie) { Score(QualificationEvent.WalkieControl, 1, now, 8.0); } if (CountNearbyTeammates(holder, 5f) >= 2) { Score(QualificationEvent.Teamwork, 1, now, 10.0); } if (holder.health < lastHealth && !holder.isPlayerDead) { Score(QualificationEvent.SurvivedDamage, 1, now, 8.0); } lastHealth = holder.health; if (now >= responseWindowAt) { playerVelocity = holder.GetPlayerVelocity(); if (((Vector3)(ref playerVelocity)).sqrMagnitude < 0.05f) { Score(QualificationEvent.IdleResponse, -2, now, 12.0); } responseWindowAt = now + 18.0; } if (state.Score > score && state.Score < ledger.Threshold && now >= state.NextAnnouncementAt) { state = state with { Phase = ApplicantPhase.Announcing, NextAnnouncementAt = now + 4.0, Revision = state.Revision + 1 }; Publish(); AnnounceClientRpc((byte)(state.Score % Math.Max(1, qualificationAnnouncements.Length))); ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.Noise.TryEmit(new EntityId(((NetworkBehaviour)this).NetworkObjectId), ((Component)holder).transform.position, 32f, 0.85f, 71001, now, 1.0, holder.isInHangarShipRoom && StartOfRound.Instance.hangarDoorsClosed); } state = state with { Phase = ApplicantPhase.Attached, Revision = state.Revision + 1 }; Publish(); } } private void Score(QualificationEvent kind, int amount, double now, double cooldown) { ApplicantPhase phase = state.Phase; if (ledger.TryScore(ref state, kind, amount, now, cooldown)) { if (phase != ApplicantPhase.Hiring && state.Phase == ApplicantPhase.Hiring) { state = state with { NextAnnouncementAt = now + 3.0, Revision = state.Revision + 1 }; FinalWarningClientRpc(); } Publish(); } } [ClientRpc] private void FinalWarningClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2102059928u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2102059928u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ChaosPresentation.TriggerAction((Component)(object)this); if ((Object)(object)announcementSource != (Object)null && qualificationAnnouncements.Length != 0) { announcementSource.PlayOneShot(qualificationAnnouncements[qualificationAnnouncements.Length - 1]); } if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip("APPLICATION COMPLETE", "Three qualifications verified. Tear or transfer the resume now.", true, false, "ChaosSuite_ApplicationFinalWarning"); } } } private void BeginHiring(PlayerControllerB holder) { //IL_0069: 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_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) if ((Object)(object)applicantEnemyPrefab == (Object)null) { Debug.LogError((object)"[ChaosSuite.JobApplication] Hiring threshold reached but ApplicantEnemy prefab is not assigned."); state = state with { Score = ledger.Threshold - 1, Phase = ApplicantPhase.Attached, Revision = state.Revision + 1 }; Publish(); return; } GameObject val = Object.Instantiate<GameObject>(applicantEnemyPrefab, ((Component)this).transform.position, ((Component)this).transform.rotation); NetworkObject component = val.GetComponent<NetworkObject>(); ApplicantEnemyAI component2 = val.GetComponent<ApplicantEnemyAI>(); if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) { Object.Destroy((Object)(object)val); return; } component.Spawn(true); ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance == null || !instance.ThreatBudget.TryTransfer(((NetworkBehaviour)this).NetworkObject, component, (SystemicThreatKind)2)) { component.Despawn(true); ApplicationState applicationState = state; NetworkTime serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; applicationState.NextAnnouncementAt = ((NetworkTime)(ref serverTime)).Time + 1.5; applicationState.Revision = state.Revision + 1; state = applicationState; Publish(); return; } component2.InitializeTarget(((NetworkBehaviour)holder).OwnerClientId); state = state with { Phase = ApplicantPhase.Destroyed, Revision = state.Revision + 1 }; Publish(); if (((NetworkBehaviour)this).NetworkObject.IsSpawned) { ((NetworkBehaviour)this).NetworkObject.Despawn(true); } } private void ReleaseApplication(Vector3 at) { //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) //IL_0035: 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_00b7: 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) SetCleanupAffectedOwner(ulong.MaxValue); EntityId holder = state.Holder; if (((EntityId)(ref holder)).IsValid) { ledger.Forget(state.Holder); } state = new ApplicationState(ApplicantPhase.Dormant, EntityId.None, 0, 0.0, state.Revision + 1); holderClient.Value = ulong.MaxValue; entityAnchor.Value = ulong.MaxValue; entityAnchorEndsAt.Value = 0.0; resumeIntegrity = 4; ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.ThreatBudget.Release(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)2, "application released"); } ((Component)this).transform.position = at; Publish(); ReleasePresentationClientRpc(at); } private void RegisterPersistentCleanup() { if (((NetworkBehaviour)this).IsServer && !((Object)(object)((NetworkBehaviour)this).NetworkObject == (Object)null) && ((NetworkBehaviour)this).NetworkObject.IsSpawned) { ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.Cleanup.Register(((NetworkBehaviour)this).NetworkObject, (Action)CleanupPersistentEffect); } } } private void CleanupPersistentEffect() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsServer) { ReleaseApplication(((Component)this).transform.position); } } private void SetCleanupAffectedOwner(ulong nextOwner) { //IL_003f: 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) if (((NetworkBehaviour)this).IsServer && cleanupAffectedOwner != nextOwner) { ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; EffectCleanupRegistry val = ((instance != null) ? instance.Cleanup : null); EntityId val2 = default(EntityId); ((EntityId)(ref val2))..ctor(((NetworkBehaviour)this).NetworkObjectId); if (cleanupAffectedOwner != ulong.MaxValue && val != null) { val.DisassociateAffectedOwner(val2, cleanupAffectedOwner); } cleanupAffectedOwner = nextOwner; if (cleanupAffectedOwner != ulong.MaxValue && val != null) { val.AssociateAffectedOwner(val2, cleanupAffectedOwner); } } } [ClientRpc] private void ReleasePresentationClientRpc(Vector3 at) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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(2182354518u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe(ref at); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2182354518u, 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.position = at; ApplyAttachedPresentation(attached: false); } } } [ClientRpc] private void AnnounceClientRpc(byte index) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(723872053u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref index, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 723872053u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (!((Object)(object)announcementSource == (Object)null) && qualificationAnnouncements.Length != 0) { AudioClip val3 = qualificationAnnouncements[index % qualificationAnnouncements.Length]; if ((Object)(object)val3 != (Object)null) { announcementSource.PlayOneShot(val3); } } } private int CountNearbyTeammates(PlayerControllerB holder, float range) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) int num = 0; float num2 = range * range; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)holder && !val.isPlayerDead && val.isPlayerControlled && Vector3.SqrMagnitude(((Component)val).transform.position - ((Component)holder).transform.position) <= num2) { num++; } } return num; } private bool TryFindSupportedEntityAnchor(PlayerControllerB holder, out NetworkObject? selected) { //IL_0017: 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_00cc: 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) selected = null; float num = transferRange * transferRange; int num2 = Physics.OverlapSphereNonAlloc(((Component)holder).transform.position, transferRange, TransferBuffer, -1, (QueryTriggerInteraction)2); for (int i = 0; i < num2; i++) { NetworkObject val = (((Object)(object)TransferBuffer[i] != (Object)null) ? ((Component)TransferBuffer[i]).GetComponentInParent<NetworkObject>() : null); if (!((Object)(object)val == (Object)null) && Object.op_Implicit((Object)(object)val) && val.IsSpawned && !((Object)(object)val == (Object)(object)((NetworkBehaviour)this).NetworkObject) && !((Object)(object)val == (Object)(object)((NetworkBehaviour)holder).NetworkObject) && ((Object)(object)((Component)val).GetComponent<EnemyAI>() != (Object)null || (Object)(object)((Component)val).GetComponent<GrabbableObject>() != (Object)null || (Object)(object)((Component)val).GetComponentInChildren<DeadBodyInfo>(true) != (Object)null)) { float num3 = Vector3.SqrMagnitude(((Component)val).transform.position - ((Component)holder).transform.position); if (!(num3 >= num)) { num = num3; selected = val; } } } return (Object)(object)selected != (Object)null; } private static bool TryResolveNetworkObject(ulong id, out NetworkObject networkObject) { networkObject = null; NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)null && singleton.SpawnManager.SpawnedObjects.TryGetValue(id, out networkObject) && (Object)(object)networkObject != (Object)null) { return networkObject.IsSpawned; } return false; } private static PlayerControllerB? FindPlayer(ulong clientId) { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return null; } for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null && ((NetworkBehaviour)array[i]).OwnerClientId == clientId) { return array[i]; } } return null; } private static EntityId PlayerId(PlayerControllerB player) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) return new EntityId(player.playerClientId + 1); } private static bool RoundEnding() { if (Object.op_Implicit((Object)(object)StartOfRound.Instance) && !StartOfRound.Instance.shipIsLeaving) { return StartOfRound.Instance.inShipPhase; } return true; } private void Publish() { //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_0025: Unknown result type (might be due to invalid IL or missing references) NetworkVariable<ulong> obj = holderClient; EntityId holder = state.Holder; obj.Value = (((EntityId)(ref holder)).IsValid ? FindClientId(state.Holder) : ulong.MaxValue); qualification.Value = state.Score; applicantPhase.Value = (byte)state.Phase; } private static ulong FindClientId(EntityId id) { //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) PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return ulong.MaxValue; } for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null && PlayerId(array[i]) == id) { return ((NetworkBehaviour)array[i]).OwnerClientId; } } return ulong.MaxValue; } public override void OnNetworkDespawn() {
plugins/ChaosSuite-NewtonsApple/ChaosSuite.NewtonsApple.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using ChaosSuite.Core; using ChaosSuite.NewtonsApple.NetcodePatcher; using ChaosSuite.Runtime; using GameNetcodeStuff; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; [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("ChaosSuite.NewtonsApple")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a3464fa3098fa6be253d588a5b7ca9ba01bef4dd")] [assembly: AssemblyProduct("ChaosSuite.NewtonsApple")] [assembly: AssemblyTitle("ChaosSuite.NewtonsApple")] [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 ChaosSuite.NewtonsApple { public enum ApplePhase : byte { Dormant, Telegraph, Shift, Travel, Stunned, Recovering, Dead } public enum GravityDirection : byte { Floor, Ceiling, Left, Right, Forward, Rear } public readonly record struct AxisVector(float X, float Y, float Z) { public static AxisVector operator +(AxisVector left, AxisVector right) { return new AxisVector(left.X + right.X, left.Y + right.Y, left.Z + right.Z); } } public readonly record struct AppleMassSample(GravityDirection Direction, float Mass, bool Valid); public readonly record struct AppleState(ApplePhase Phase, GravityDirection Direction, double PhaseEndsAt, byte Impacts, uint Revision); public readonly record struct AppleTuning(double TelegraphSeconds, double ShiftSeconds, double StunSeconds, double RecoverySeconds) { public static AppleTuning Default => new AppleTuning(2.0, 6.0, 4.0, 2.0); public AppleTuning Validated() { return new AppleTuning(Math.Clamp(TelegraphSeconds, 0.5, 5.0), Math.Clamp(ShiftSeconds, 0.5, 15.0), Math.Clamp(StunSeconds, 0.5, 15.0), Math.Clamp(RecoverySeconds, 0.25, 10.0)); } } public static class AppleDirectionSelector { public static GravityDirection Select(IReadOnlyList<AppleMassSample> samples, GravityDirection fallback, AxisVector impactBias) { Span<float> span = stackalloc float[6]; foreach (AppleMassSample sample in samples) { if (sample.Valid && sample.Mass > 0f) { span[(int)sample.Direction] += sample.Mass; } } span[(int)FromAxis(impactBias, fallback)] += Magnitude(impactBias) * 2f; GravityDirection result = fallback; float num = span[(int)fallback]; for (int i = 0; i < span.Length; i++) { if (!(span[i] <= num)) { num = span[i]; result = (GravityDirection)i; } } return result; } public static GravityDirection FromAxis(AxisVector vector, GravityDirection fallback) { float num = Math.Abs(vector.X); float num2 = Math.Abs(vector.Y); float num3 = Math.Abs(vector.Z); if (num <= float.Epsilon && num2 <= float.Epsilon && num3 <= float.Epsilon) { return fallback; } if (num2 >= num && num2 >= num3) { if (!(vector.Y >= 0f)) { return GravityDirection.Floor; } return GravityDirection.Ceiling; } if (num >= num3) { if (!(vector.X >= 0f)) { return GravityDirection.Left; } return GravityDirection.Right; } if (!(vector.Z >= 0f)) { return GravityDirection.Rear; } return GravityDirection.Forward; } private static float Magnitude(AxisVector value) { return MathF.Sqrt(value.X * value.X + value.Y * value.Y + value.Z * value.Z); } } public sealed class AppleController { private readonly AppleTuning tuning; private AxisVector accumulatedImpacts; private double gravityEndsAt; public AppleState State { get; private set; } = new AppleState(ApplePhase.Dormant, GravityDirection.Floor, 0.0, 0, 0u); public AxisVector ImpactBias => accumulatedImpacts; public double GravityEndsAt => gravityEndsAt; public AppleController(AppleTuning? tuning = null) { this.tuning = (tuning ?? AppleTuning.Default).Validated(); } public bool BeginTelegraph(GravityDirection direction, double now) { ApplePhase phase = State.Phase; if ((phase != ApplePhase.Dormant && phase != ApplePhase.Travel) || 1 == 0) { return false; } State = new AppleState(ApplePhase.Telegraph, direction, now + tuning.TelegraphSeconds, State.Impacts, State.Revision + 1); return true; } public bool Advance(double now) { AppleState state = State; AppleState state2; switch (State.Phase) { case ApplePhase.Telegraph: if (now >= State.PhaseEndsAt) { state2 = BeginShift(now); break; } goto default; case ApplePhase.Shift: if (now >= State.PhaseEndsAt) { state2 = State with { Phase = ApplePhase.Travel, PhaseEndsAt = gravityEndsAt, Revision = State.Revision + 1 }; break; } goto default; case ApplePhase.Travel: if (now >= State.PhaseEndsAt) { state2 = State with { Phase = ApplePhase.Stunned, PhaseEndsAt = now + tuning.StunSeconds, Revision = State.Revision + 1 }; break; } goto default; case ApplePhase.Stunned: if (now >= State.PhaseEndsAt) { state2 = State with { Phase = ApplePhase.Recovering, PhaseEndsAt = now + tuning.RecoverySeconds, Revision = State.Revision + 1 }; break; } goto default; case ApplePhase.Recovering: if (now >= State.PhaseEndsAt) { state2 = State with { Phase = ApplePhase.Dormant, Revision = State.Revision + 1 }; break; } goto default; default: state2 = State; break; } State = state2; return state != State; } public bool RegisterStunImpact(AxisVector direction) { if (State.Phase != ApplePhase.Stunned) { return false; } accumulatedImpacts += direction; State = State with { Impacts = (byte)Math.Min(3, State.Impacts + 1), Revision = State.Revision + 1 }; return true; } public bool Impact(double now) { ApplePhase phase = State.Phase; if (phase - 2 > ApplePhase.Telegraph) { return false; } State = State with { Phase = ApplePhase.Stunned, PhaseEndsAt = now + tuning.StunSeconds, Revision = State.Revision + 1 }; return true; } public AxisVector ConsumeImpactBias() { if (State.Impacts < 3) { return default(AxisVector); } AxisVector result = accumulatedImpacts; accumulatedImpacts = default(AxisVector); State = State with { Impacts = 0, Revision = State.Revision + 1 }; return result; } public void Kill() { State = State with { Phase = ApplePhase.Dead, PhaseEndsAt = 0.0, Revision = State.Revision + 1 }; } public void Reset() { accumulatedImpacts = default(AxisVector); gravityEndsAt = 0.0; State = new AppleState(ApplePhase.Dormant, GravityDirection.Floor, 0.0, 0, State.Revision + 1); } private AppleState BeginShift(double now) { gravityEndsAt = now + tuning.ShiftSeconds; double num = Math.Min(0.75, Math.Max(0.1, tuning.ShiftSeconds / 3.0)); return State with { Phase = ApplePhase.Shift, PhaseEndsAt = now + num, Revision = State.Revision + 1 }; } } public sealed class NewtonsAppleEnemy : EnemyAI, IHittable { private const int OverlapCapacity = 64; private readonly Collider[] overlap = (Collider[])(object)new Collider[64]; private readonly int[] seenBodies = new int[64]; private readonly List<AppleMassSample> massSamples = new List<AppleMassSample>(64); private readonly AppleController controller = new AppleController(); private readonly Dictionary<ulong, uint> lastHitSequence = new Dictionary<ulong, uint>(); private readonly Dictionary<ulong, double> nextHitAt = new Dictionary<ulong, double>(); private readonly HashSet<ulong> cleanupAffectedOwners = new HashSet<ulong>(); private readonly NetworkVariable<byte> phase = new NetworkVariable<byte>((byte)0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<byte> gravityDirection = new NetworkVariable<byte>((byte)0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<double> phaseEndsAt = new NetworkVariable<double>(0.0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<double> gravityEndsAt = new NetworkVariable<double>(0.0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<uint> revision = new NetworkVariable<uint>(0u, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<bool> coreExposed = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private double nextGravityTick; private int seenBodyCount; private GameObject? directionIndicator; private Transform? authoredCore; private bool localGravityActive; private Vector3 localGravity; private double localGravityEndsAt; private uint localHitSequence; private bool roundEndingHandled; [Header("Authored prefab references")] [SerializeField] private BoxCollider influenceVolume; [SerializeField] private Transform stem; [SerializeField] private GameObject blackCorePrefab; [SerializeField] [Min(1f)] private float gravityAcceleration = 16f; [SerializeField] [Min(0.2f)] private float gravityTickSeconds = 0.2f; [SerializeField] [Min(0.5f)] private float travelSpeed = 4.5f; public override void Start() { ((EnemyAI)this).Start(); base.AIIntervalTime = 0.2f; if ((Object)(object)((Component)this).GetComponentInChildren<Renderer>(true) == (Object)null && (Object)(object)NewtonsApplePlugin.VisualPrefab != (Object)null) { Object.Instantiate<GameObject>(NewtonsApplePlugin.VisualPrefab, ((Component)this).transform, false); } authoredCore = FindNamed(((Component)this).transform, "BlackCore") ?? FindNamed(((Component)this).transform, "Core"); CreateDirectionIndicator(); SetCoreExposed(coreExposed.Value); } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); RegisterPersistentCleanup(); NetworkVariable<byte> obj = phase; obj.OnValueChanged = (OnValueChangedDelegate<byte>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<byte>(OnGravityStateChanged)); NetworkVariable<byte> obj2 = gravityDirection; obj2.OnValueChanged = (OnValueChangedDelegate<byte>)(object)Delegate.Combine((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<byte>(OnGravityDirectionChanged)); NetworkVariable<double> obj3 = gravityEndsAt; obj3.OnValueChanged = (OnValueChangedDelegate<double>)(object)Delegate.Combine((Delegate?)(object)obj3.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<double>(OnGravityDeadlineChanged)); RefreshLocalGravity(); } public override void DoAIInterval() { //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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).DoAIInterval(); if (!((NetworkBehaviour)this).IsServer || base.isEnemyDead || (Object)(object)influenceVolume == (Object)null) { return; } if (RoundEnding()) { if (!roundEndingHandled) { roundEndingHandled = true; CleanupPersistentEffect(); } return; } roundEndingHandled = false; NetworkTime serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; double time = ((NetworkTime)(ref serverTime)).Time; if (controller.Advance(time)) { PublishState(); if (controller.State.Phase == ApplePhase.Shift) { ShiftPresentationClientRpc(); BeginPlayerGravity(DirectionVector(controller.State.Direction)); if ((Object)(object)base.agent != (Object)null && ((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = false; } } else if (controller.State.Phase == ApplePhase.Stunned) { ClearPlayerGravity(); HideDirectionClientRpc(); ReattachAgent(); } if (controller.State.Phase == ApplePhase.Stunned) { ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.ThreatBudget.Release(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)1, "apple impact stun"); } } } if (controller.State.Phase == ApplePhase.Dormant) { ChaosSuiteRuntimePlugin instance2 = ChaosSuiteRuntimePlugin.Instance; if (instance2 == null || !instance2.ThreatBudget.TryAcquire(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)1)) { return; } GravityDirection direction = SelectDirection(); if (controller.BeginTelegraph(direction, time)) { PublishState(); TelegraphDirectionClientRpc((byte)direction); PlayMechanicClientRpc(); } } ApplePhase applePhase = controller.State.Phase; bool flag = applePhase - 2 <= ApplePhase.Telegraph; if (flag && time >= nextGravityTick) { nextGravityTick = time + (double)gravityTickSeconds; ApplyRigidBodyGravity(DirectionVector(controller.State.Direction)); } if (controller.State.Phase == ApplePhase.Travel) { MoveApple(DirectionVector(controller.State.Direction), time); } } public override void Update() { //IL_009a: 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_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) //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_00e6: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).Update(); if (!localGravityActive) { RefreshLocalGravity(); } if (!localGravityActive) { return; } PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val == (Object)null) && !val.isPlayerDead && !val.disconnectedMidGame && !val.isClimbingLadder && !val.teleportedLastFrame && !val.isInHangarShipRoom && !((Object)(object)StartOfRound.Instance == (Object)null) && !StartOfRound.Instance.shipIsLeaving && !StartOfRound.Instance.inShipPhase && !((Object)(object)NetworkManager.Singleton == (Object)null)) { NetworkTime serverTime = NetworkManager.Singleton.ServerTime; if (!(((NetworkTime)(ref serverTime)).Time >= localGravityEndsAt) && IsInsideInfluence(((Component)val).transform.position)) { val.externalForces += localGravity * Time.deltaTime; return; } } localGravityActive = false; } public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsServer && !((Object)(object)playerWhoHit == (Object)null)) { NetworkTime serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; if (TryAuthorizeStemHit(playerWhoHit, ((NetworkTime)(ref serverTime)).Time)) { RegisterAuthorizedStemImpact(playerWhoHit); } } } bool IHittable.Hit(int force, Vector3 hitDirection, PlayerControllerB? playerWhoHit, bool playHitSFX, int hitID) { //IL_004b: 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) { ((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID); } else if ((Object)(object)playerWhoHit != (Object)null) { localHitSequence++; if (localHitSequence == 0) { localHitSequence = 1u; } RegisterStemHitServerRpc(((NetworkBehaviour)playerWhoHit).OwnerClientId, localHitSequence); } return phase.Value == 4; } [ServerRpc(RequireOwnership = false)] private void RegisterStemHitServerRpc(ulong claimedPlayer, uint sequence, ServerRpcParams rpc = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1609497886u, rpc, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, claimedPlayer); BytePacker.WriteValueBitPacked(val, sequence); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 1609497886u, rpc, (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 || RoundEnding() || rpc.Receive.SenderClientId != claimedPlayer || sequence == 0 || (lastHitSequence.TryGetValue(claimedPlayer, out var value) && sequence <= value)) { return; } PlayerControllerB val2 = FindPlayer(claimedPlayer); if (!((Object)(object)val2 == (Object)null)) { NetworkTime serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; if (TryAuthorizeStemHit(val2, ((NetworkTime)(ref serverTime)).Time)) { lastHitSequence[claimedPlayer] = sequence; RegisterAuthorizedStemImpact(val2); } } } public override void KillEnemy(bool destroy = false) { //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) if (base.isEnemyDead) { return; } if (((NetworkBehaviour)this).IsServer && (Object)(object)blackCorePrefab != (Object)null) { NetworkObject component = Object.Instantiate<GameObject>(blackCorePrefab, ((Component)this).transform.position, Quaternion.identity).GetComponent<NetworkObject>(); if ((Object)(object)component != (Object)null) { component.Spawn(true); } } controller.Kill(); lastHitSequence.Clear(); nextHitAt.Clear(); ClearPlayerGravity(); ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.ThreatBudget.Release(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)1, "apple killed"); } ((EnemyAI)this).KillEnemy(destroy); } public override void OnNetworkDespawn() { localGravityActive = false; roundEndingHandled = false; NetworkVariable<byte> obj = phase; obj.OnValueChanged = (OnValueChangedDelegate<byte>)(object)Delegate.Remove((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<byte>(OnGravityStateChanged)); NetworkVariable<byte> obj2 = gravityDirection; obj2.OnValueChanged = (OnValueChangedDelegate<byte>)(object)Delegate.Remove((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<byte>(OnGravityDirectionChanged)); NetworkVariable<double> obj3 = gravityEndsAt; obj3.OnValueChanged = (OnValueChangedDelegate<double>)(object)Delegate.Remove((Delegate?)(object)obj3.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<double>(OnGravityDeadlineChanged)); lastHitSequence.Clear(); nextHitAt.Clear(); if (((NetworkBehaviour)this).IsServer) { ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.ThreatBudget.Release(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)1, "apple despawned"); } } ((NetworkBehaviour)this).OnNetworkDespawn(); } private void OnDisable() { localGravityActive = false; } private bool TryAuthorizeStemHit(PlayerControllerB player, double now) { //IL_0064: 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_0069: 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) //IL_0076: 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_00af: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00f8: Unknown result type (might be due to invalid IL or missing references) if (controller.State.Phase != ApplePhase.Stunned || player.isPlayerDead || player.disconnectedMidGame || (!(player.currentlyHeldObjectServer is Shovel) && !(player.currentlyHeldObjectServer is KnifeItem))) { return false; } Vector3 val = (((Object)(object)stem != (Object)null) ? stem.position : ((Component)this).transform.position); if (Vector3.SqrMagnitude(((Component)player).transform.position - val) > 16f) { return false; } if (nextHitAt.TryGetValue(((NetworkBehaviour)player).OwnerClientId, out var value) && now < value) { return false; } Vector3 val2 = ((Component)player).transform.position + Vector3.up * 1.2f + ((Component)player).transform.forward * 0.35f; int num = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.collidersAndRoomMaskAndDefault : (-1)); RaycastHit val3 = default(RaycastHit); if (Physics.Linecast(val2, val, ref val3, num, (QueryTriggerInteraction)1) && (Object)(object)((RaycastHit)(ref val3)).transform != (Object)(object)((Component)this).transform && !((RaycastHit)(ref val3)).transform.IsChildOf(((Component)this).transform)) { return false; } nextHitAt[((NetworkBehaviour)player).OwnerClientId] = now + 0.18; return true; } private GravityDirection SelectDirection() { //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_0020: 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_003d: 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) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00d5: Unknown result type (might be due to invalid IL or missing references) massSamples.Clear(); seenBodyCount = 0; Bounds bounds = ((Collider)influenceVolume).bounds; int num = Physics.OverlapBoxNonAlloc(((Bounds)(ref bounds)).center, ((Bounds)(ref bounds)).extents, overlap, ((Component)influenceVolume).transform.rotation, -1, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider val = overlap[i]; if ((Object)(object)val == (Object)null || ((Component)val).transform.IsChildOf(((Component)this).transform)) { continue; } PlayerControllerB componentInParent = ((Component)val).GetComponentInParent<PlayerControllerB>(); if ((Object)(object)componentInParent != (Object)null) { if (!componentInParent.isPlayerDead && !componentInParent.isInHangarShipRoom && TryRemember(((Object)componentInParent).GetInstanceID())) { massSamples.Add(new AppleMassSample(ToDirection(((Component)componentInParent).transform.position - ((Bounds)(ref bounds)).center), Mathf.Max(1f, componentInParent.carryWeight), Valid: true)); } continue; } Rigidbody attachedRigidbody = val.attachedRigidbody; if (!((Object)(object)attachedRigidbody == (Object)null) && !attachedRigidbody.isKinematic && TryRemember(((Object)attachedRigidbody).GetInstanceID())) { massSamples.Add(new AppleMassSample(ToDirection(attachedRigidbody.worldCenterOfMass - ((Bounds)(ref bounds)).center), Mathf.Clamp(attachedRigidbody.mass, 0.1f, 50f), Valid: true)); } } AxisVector impactBias = controller.ConsumeImpactBias(); return AppleDirectionSelector.Select(massSamples, GravityDirection.Floor, impactBias); } private void BeginPlayerGravity(Vector3 direction) { //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_0014: 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_0031: 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_010b: Unknown result type (might be due to invalid IL or missing references) DisassociateGravityOwners(); Bounds bounds = ((Collider)influenceVolume).bounds; int num = Physics.OverlapBoxNonAlloc(((Bounds)(ref bounds)).center, ((Bounds)(ref bounds)).extents, overlap, ((Component)influenceVolume).transform.rotation, -1, (QueryTriggerInteraction)1); ulong[] array = new ulong[StartOfRound.Instance.allPlayerScripts.Length]; int num2 = 0; for (int i = 0; i < num; i++) { Collider val = overlap[i]; if (!((Object)(object)val == (Object)null) && !((Component)val).transform.IsChildOf(((Component)this).transform)) { PlayerControllerB componentInParent = ((Component)val).GetComponentInParent<PlayerControllerB>(); if ((Object)(object)componentInParent != (Object)null && !componentInParent.isPlayerDead && !componentInParent.isInHangarShipRoom && !Contains(array, num2, ((NetworkBehaviour)componentInParent).OwnerClientId)) { array[num2++] = ((NetworkBehaviour)componentInParent).OwnerClientId; } } } if (num2 == 0) { return; } if (num2 != array.Length) { Array.Resize(ref array, num2); } ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; EffectCleanupRegistry val2 = ((instance != null) ? instance.Cleanup : null); EntityId val3 = default(EntityId); ((EntityId)(ref val3))..ctor(((NetworkBehaviour)this).NetworkObjectId); for (int j = 0; j < array.Length; j++) { if (val2 != null) { val2.AssociateAffectedOwner(val3, array[j]); } cleanupAffectedOwners.Add(array[j]); } ApplyGravityClientRpc(array, direction, gravityAcceleration, controller.GravityEndsAt); } private void ApplyRigidBodyGravity(Vector3 direction) { //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_000e: 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_002b: 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_0093: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = ((Collider)influenceVolume).bounds; int num = Physics.OverlapBoxNonAlloc(((Bounds)(ref bounds)).center, ((Bounds)(ref bounds)).extents, overlap, ((Component)influenceVolume).transform.rotation, -1, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider val = overlap[i]; if (!((Object)(object)val == (Object)null) && !((Component)val).transform.IsChildOf(((Component)this).transform) && !((Object)(object)((Component)val).GetComponentInParent<PlayerControllerB>() != (Object)null)) { Rigidbody attachedRigidbody = val.attachedRigidbody; if ((Object)(object)attachedRigidbody != (Object)null && !attachedRigidbody.isKinematic) { attachedRigidbody.AddForce(direction * gravityAcceleration, (ForceMode)5); } } } } [ClientRpc] private void ApplyGravityClientRpc(ulong[] affectedClients, Vector3 direction, float acceleration, double endsAt) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_0088: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_010a: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) 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(1688451801u, val2, (RpcDelivery)0); bool flag = affectedClients != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(affectedClients, default(ForPrimitives)); } ((FastBufferWriter)(ref val)).WriteValueSafe(ref direction); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref acceleration, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<double>(ref endsAt, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1688451801u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if (!((Object)(object)NetworkManager.Singleton == (Object)null) && Contains(affectedClients, affectedClients.Length, NetworkManager.Singleton.LocalClientId)) { PlayerControllerB val3 = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val3 == (Object)null) && !val3.isInHangarShipRoom) { localGravity = direction * Mathf.Clamp(acceleration, 0f, 30f); localGravityEndsAt = endsAt; localGravityActive = true; } } } [ClientRpc] private void ClearGravityClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(316672261u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 316672261u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; localGravityActive = false; } } } private void RegisterPersistentCleanup() { if (((NetworkBehaviour)this).IsServer && !((Object)(object)((NetworkBehaviour)this).NetworkObject == (Object)null) && ((NetworkBehaviour)this).NetworkObject.IsSpawned) { ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.Cleanup.Register(((NetworkBehaviour)this).NetworkObject, (Action)CleanupPersistentEffect); } } } private void CleanupPersistentEffect() { localGravityActive = false; if (((NetworkBehaviour)this).IsServer) { roundEndingHandled = true; ClearGravityClientRpc(); HideDirectionClientRpc(); DisassociateGravityOwners(); controller.Reset(); PublishState(); ReattachAgent(); ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.ThreatBudget.Release(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)1, "apple persistent cleanup"); } } } private void ClearPlayerGravity() { localGravityActive = false; if (((NetworkBehaviour)this).IsServer) { ClearGravityClientRpc(); DisassociateGravityOwners(); } } private void DisassociateGravityOwners() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (cleanupAffectedOwners.Count == 0) { return; } ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; EffectCleanupRegistry val = ((instance != null) ? instance.Cleanup : null); EntityId val2 = default(EntityId); ((EntityId)(ref val2))..ctor(((NetworkBehaviour)this).NetworkObjectId); foreach (ulong cleanupAffectedOwner in cleanupAffectedOwners) { if (val != null) { val.DisassociateAffectedOwner(val2, cleanupAffectedOwner); } } cleanupAffectedOwners.Clear(); } [ClientRpc] private void PlayMechanicClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2147994083u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2147994083u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ChaosPresentation.TriggerAction((Component)(object)this); if ((Object)(object)base.creatureVoice != (Object)null && (Object)(object)NewtonsApplePlugin.MechanicClip != (Object)null) { base.creatureVoice.PlayOneShot(NewtonsApplePlugin.MechanicClip); } } } [ClientRpc] private void ShiftPresentationClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(317251569u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 317251569u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ChaosPresentation.TriggerAction((Component)(object)this); } } } [ClientRpc] private void TelegraphDirectionClientRpc(byte direction) { //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) //IL_00ea: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: 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) 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(2232205684u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref direction, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2232205684u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; Vector3 val3 = DirectionVector((GravityDirection)Mathf.Clamp((int)direction, 0, 5)); if ((Object)(object)directionIndicator == (Object)null) { CreateDirectionIndicator(); } if (!((Object)(object)directionIndicator == (Object)null)) { directionIndicator.transform.rotation = Quaternion.FromToRotation(Vector3.up, val3); directionIndicator.SetActive(true); } } } [ClientRpc] private void HideDirectionClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(352819245u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 352819245u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; if ((Object)(object)directionIndicator != (Object)null) { directionIndicator.SetActive(false); } } } [ClientRpc] private void ExposeCoreClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3678215996u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 3678215996u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; SetCoreExposed(exposed: true); ChaosPresentation.TriggerAction((Component)(object)this); } } } private void PublishState() { phase.Value = (byte)controller.State.Phase; gravityDirection.Value = (byte)controller.State.Direction; phaseEndsAt.Value = controller.State.PhaseEndsAt; gravityEndsAt.Value = controller.GravityEndsAt; revision.Value = controller.State.Revision; } private void RefreshLocalGravity() { //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_0080: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) ApplePhase value = (ApplePhase)phase.Value; NetworkManager singleton = NetworkManager.Singleton; PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; bool flag = value - 2 <= ApplePhase.Telegraph; if (flag && !((Object)(object)singleton == (Object)null) && !((Object)(object)val == (Object)null) && !val.isPlayerDead && !val.disconnectedMidGame && !val.isInHangarShipRoom) { NetworkTime serverTime = singleton.ServerTime; if (!(((NetworkTime)(ref serverTime)).Time >= gravityEndsAt.Value) && IsInsideInfluence(((Component)val).transform.position)) { localGravity = DirectionVector((GravityDirection)Mathf.Clamp((int)gravityDirection.Value, 0, 5)) * Mathf.Clamp(gravityAcceleration, 0f, 30f); localGravityEndsAt = gravityEndsAt.Value; localGravityActive = true; return; } } localGravityActive = false; } private bool IsInsideInfluence(Vector3 position) { //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_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) if ((Object)(object)influenceVolume == (Object)null || !((Collider)influenceVolume).enabled) { return false; } return Vector3.SqrMagnitude(((Collider)influenceVolume).ClosestPoint(position) - position) <= 0.0001f; } private void OnGravityStateChanged(byte previous, byte current) { RefreshLocalGravity(); } private void OnGravityDirectionChanged(byte previous, byte current) { RefreshLocalGravity(); } private void OnGravityDeadlineChanged(double previous, double current) { RefreshLocalGravity(); } private static bool Contains(ulong[] values, int count, ulong target) { for (int i = 0; i < count; i++) { if (values[i] == target) { return true; } } return false; } private void RegisterAuthorizedStemImpact(PlayerControllerB player) { //IL_001f: 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_0034: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (coreExposed.Value) { ((EnemyAI)this).HitEnemy(10, player, true, -1); return; } Vector3 val = ((Component)this).transform.position - ((Component)player).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; if (controller.RegisterStunImpact(new AxisVector(normalized.x, normalized.y, normalized.z))) { if (controller.State.Impacts >= 3) { coreExposed.Value = true; ExposeCoreClientRpc(); } PublishState(); } } private void MoveApple(Vector3 direction, double now) { //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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_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) float num = travelSpeed * base.AIIntervalTime; Vector3 position = ((Component)this).transform.position; RaycastHit val = default(RaycastHit); if (Physics.SphereCast(position, 0.62f, direction, ref val, num, -1, (QueryTriggerInteraction)1) && !((RaycastHit)(ref val)).transform.IsChildOf(((Component)this).transform)) { ((Component)this).transform.position = ((RaycastHit)(ref val)).point - direction * 0.62f; if (controller.Impact(now)) { PublishState(); ClearPlayerGravity(); HideDirectionClientRpc(); ReattachAgent(); ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.ThreatBudget.Release(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)1, "apple collided"); } } } else { ((Component)this).transform.position = position + direction * num; } } private void ReattachAgent() { //IL_0022: 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_005d: Unknown result type (might be due to invalid IL or missing references) NavMeshHit val = default(NavMeshHit); if (!((Object)(object)base.agent == (Object)null) && !((Behaviour)base.agent).enabled && NavMesh.SamplePosition(((Component)this).transform.position, ref val, 3f, -1)) { ((Component)this).transform.position = ((NavMeshHit)(ref val)).position; ((Behaviour)base.agent).enabled = true; base.agent.Warp(((NavMeshHit)(ref val)).position); } } private bool TryRemember(int instanceId) { for (int i = 0; i < seenBodyCount; i++) { if (seenBodies[i] == instanceId) { return false; } } if (seenBodyCount >= seenBodies.Length) { return false; } seenBodies[seenBodyCount++] = instanceId; return true; } private void CreateDirectionIndicator() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0041: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00ad: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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_0147: 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_0151: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)directionIndicator != (Object)null)) { directionIndicator = new GameObject("GravityDirectionIndicator"); directionIndicator.transform.SetParent(((Component)this).transform, false); directionIndicator.transform.localPosition = Vector3.up * 1.15f; Material material = new Material(Shader.Find("Sprites/Default")) { color = new Color(0.72f, 0.18f, 0.09f, 0.95f) }; CreateIndicatorLine("Shaft", (Vector3[])(object)new Vector3[2] { Vector3.zero, Vector3.up * 0.9f }, material); CreateIndicatorLine("HeadLeft", (Vector3[])(object)new Vector3[2] { Vector3.up * 0.9f, Vector3.up * 0.62f + Vector3.left * 0.2f }, material); CreateIndicatorLine("HeadRight", (Vector3[])(object)new Vector3[2] { Vector3.up * 0.9f, Vector3.up * 0.62f + Vector3.right * 0.2f }, material); directionIndicator.SetActive(false); } } private void CreateIndicatorLine(string name, Vector3[] points, Material material) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(directionIndicator.transform, false); LineRenderer obj = val.AddComponent<LineRenderer>(); obj.useWorldSpace = false; ((Renderer)obj).sharedMaterial = material; obj.widthMultiplier = 0.065f; obj.positionCount = points.Length; obj.SetPositions(points); obj.numCapVertices = 2; } private void SetCoreExposed(bool exposed) { //IL_001e: 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_0017: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)authoredCore != (Object)null) { authoredCore.localScale = (exposed ? (Vector3.one * 1.22f) : Vector3.one); } } private static Transform? FindNamed(Transform root, string fragment) { Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if (((Object)componentsInChildren[i]).name.Contains(fragment, StringComparison.OrdinalIgnoreCase)) { return componentsInChildren[i]; } } return null; } private static PlayerControllerB? FindPlayer(ulong clientId) { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return null; } for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null && ((NetworkBehaviour)array[i]).OwnerClientId == clientId) { return array[i]; } } return null; } private static GravityDirection ToDirection(Vector3 offset) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) return AppleDirectionSelector.FromAxis(new AxisVector(offset.x, offset.y, offset.z), GravityDirection.Floor); } private static bool RoundEnding() { if (Object.op_Implicit((Object)(object)StartOfRound.Instance) && !StartOfRound.Instance.shipIsLeaving) { return StartOfRound.Instance.inShipPhase; } return true; } private static Vector3 DirectionVector(GravityDirection direction) { //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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //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_0038: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0056: 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) return (Vector3)(direction switch { GravityDirection.Floor => Vector3.down, GravityDirection.Ceiling => Vector3.up, GravityDirection.Left => Vector3.left, GravityDirection.Right => Vector3.right, GravityDirection.Forward => Vector3.forward, GravityDirection.Rear => Vector3.back, _ => Vector3.down, }); } protected override void __initializeVariables() { if (phase == null) { throw new Exception("NewtonsAppleEnemy.phase cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)phase).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)phase, "phase"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)phase); if (gravityDirection == null) { throw new Exception("NewtonsAppleEnemy.gravityDirection cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)gravityDirection).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)gravityDirection, "gravityDirection"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)gravityDirection); if (phaseEndsAt == null) { throw new Exception("NewtonsAppleEnemy.phaseEndsAt cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)phaseEndsAt).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)phaseEndsAt, "phaseEndsAt"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)phaseEndsAt); if (gravityEndsAt == null) { throw new Exception("NewtonsAppleEnemy.gravityEndsAt cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)gravityEndsAt).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)gravityEndsAt, "gravityEndsAt"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)gravityEndsAt); if (revision == null) { throw new Exception("NewtonsAppleEnemy.revision cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)revision).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)revision, "revision"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)revision); if (coreExposed == null) { throw new Exception("NewtonsAppleEnemy.coreExposed cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)coreExposed).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)coreExposed, "coreExposed"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)coreExposed); ((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 ((NetworkBehaviour)this).__registerRpc(1609497886u, new RpcReceiveHandler(__rpc_handler_1609497886), "RegisterStemHitServerRpc"); ((NetworkBehaviour)this).__registerRpc(1688451801u, new RpcReceiveHandler(__rpc_handler_1688451801), "ApplyGravityClientRpc"); ((NetworkBehaviour)this).__registerRpc(316672261u, new RpcReceiveHandler(__rpc_handler_316672261), "ClearGravityClientRpc"); ((NetworkBehaviour)this).__registerRpc(2147994083u, new RpcReceiveHandler(__rpc_handler_2147994083), "PlayMechanicClientRpc"); ((NetworkBehaviour)this).__registerRpc(317251569u, new RpcReceiveHandler(__rpc_handler_317251569), "ShiftPresentationClientRpc"); ((NetworkBehaviour)this).__registerRpc(2232205684u, new RpcReceiveHandler(__rpc_handler_2232205684), "TelegraphDirectionClientRpc"); ((NetworkBehaviour)this).__registerRpc(352819245u, new RpcReceiveHandler(__rpc_handler_352819245), "HideDirectionClientRpc"); ((NetworkBehaviour)this).__registerRpc(3678215996u, new RpcReceiveHandler(__rpc_handler_3678215996), "ExposeCoreClientRpc"); ((EnemyAI)this).__initializeRpcs(); } private static void __rpc_handler_1609497886(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_003d: 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_0043: 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_0060: 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) { ulong claimedPlayer = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref claimedPlayer); uint sequence = default(uint); ByteUnpacker.ReadValueBitPacked(reader, ref sequence); ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((NewtonsAppleEnemy)(object)target).RegisterStemHitServerRpc(claimedPlayer, sequence, server); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1688451801(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_0081: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00d7: 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_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); ulong[] affectedClients = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref affectedClients, default(ForPrimitives)); } Vector3 direction = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref direction); float acceleration = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref acceleration, default(ForPrimitives)); double endsAt = default(double); ((FastBufferReader)(ref reader)).ReadValueSafe<double>(ref endsAt, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((NewtonsAppleEnemy)(object)target).ApplyGravityClientRpc(affectedClients, direction, acceleration, endsAt); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_316672261(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((NewtonsAppleEnemy)(object)target).ClearGravityClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2147994083(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((NewtonsAppleEnemy)(object)target).PlayMechanicClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_317251569(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((NewtonsAppleEnemy)(object)target).ShiftPresentationClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2232205684(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) { byte direction = default(byte); ((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref direction, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((NewtonsAppleEnemy)(object)target).TelegraphDirectionClientRpc(direction); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_352819245(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((NewtonsAppleEnemy)(object)target).HideDirectionClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3678215996(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((NewtonsAppleEnemy)(object)target).ExposeCoreClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "NewtonsAppleEnemy"; } } [BepInPlugin("com.chaossuite.newtonsapple", "Newton's Apple", "0.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class NewtonsApplePlugin : BaseUnityPlugin { public const string PluginGuid = "com.chaossuite.newtonsapple"; public const string PluginName = "Newton's Apple"; public const string PluginVersion = "0.2.0"; private static bool netcodeInitialized; internal static NewtonsApplePlugin Instance { get; private set; } internal static GameObject? VisualPrefab { get; private set; } internal static AudioClip? MechanicClip { get; private set; } private void Awake() { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) Instance = this; InitializeGeneratedNetcode(); ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; AssetBundleRegistry val = ((instance != null) ? instance.Assets : null); string text = ChaosAssetPaths.BundleName("NewtonsApple"); AssetBundle val2 = default(AssetBundle); if (val != null && val.TryLoadModuleBundle("NewtonsApple", typeof(NewtonsApplePlugin).Assembly, ref val2)) { GameObject visualPrefab = default(GameObject); val.TryLoadAsset<GameObject>(text, ChaosAssetPaths.VisualPrefab("NewtonsApple"), ref visualPrefab); AudioClip mechanicClip = default(AudioClip); val.TryLoadAsset<AudioClip>(text, ChaosAssetPaths.AudioClip("NewtonsApple", "mechanic.wav"), ref mechanicClip); VisualPrefab = visualPrefab; MechanicClip = mechanicClip; } ChaosSuiteRuntimePlugin instance2 = ChaosSuiteRuntimePlugin.Instance; if (instance2 != null) { instance2.RegisterFeatureContent("NewtonsApple", typeof(NewtonsApplePlugin).Assembly); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Newton's Apple loaded. Gravity is room-local; global Physics.gravity is never modified."); } private static void InitializeGeneratedNetcode() { if (netcodeInitialized) { return; } netcodeInitialized = true; Type[] types = typeof(NewtonsApplePlugin).Assembly.GetTypes(); for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); } } } } } } namespace System.Runtime.CompilerServices { internal static class IsExternalInit { } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<byte>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<byte>(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<double>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<double>(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>(); } } } namespace ChaosSuite.NewtonsApple.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }
plugins/ChaosSuite-Relocator/ChaosSuite.Relocator.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using ChaosSuite.Core; using ChaosSuite.Relocator.NetcodePatcher; using ChaosSuite.Runtime; using GameNetcodeStuff; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; [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("ChaosSuite.Relocator")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a3464fa3098fa6be253d588a5b7ca9ba01bef4dd")] [assembly: AssemblyProduct("ChaosSuite.Relocator")] [assembly: AssemblyTitle("ChaosSuite.Relocator")] [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 ChaosSuite.Quagmire { [BepInPlugin("com.chaossuite.relocator", "Relocator", "0.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class RelocatorPlugin : BaseUnityPlugin { public const string PluginGuid = "com.chaossuite.relocator"; public const string PluginName = "Relocator"; public const string PluginVersion = "0.2.0"; private static bool netcodeInitialized; internal static GameObject? VisualPrefab { get; private set; } internal static AudioClip? Giggity { get; private set; } internal static AudioClip? Release { get; private set; } private void Awake() { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) InitializeGeneratedNetcode(); ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; AssetBundleRegistry val = ((instance != null) ? instance.Assets : null); AssetBundle val2 = default(AssetBundle); if (val != null && val.TryLoadModuleBundle("Relocator", typeof(RelocatorPlugin).Assembly, ref val2)) { string text = ChaosAssetPaths.BundleName("Relocator"); GameObject visualPrefab = default(GameObject); val.TryLoadAsset<GameObject>(text, ChaosAssetPaths.VisualPrefab("Relocator"), ref visualPrefab); VisualPrefab = visualPrefab; AudioClip giggity = default(AudioClip); val.TryLoadAsset<AudioClip>(text, ChaosAssetPaths.AudioClip("Relocator", "giggity.wav"), ref giggity); Giggity = giggity; AudioClip release = default(AudioClip); val.TryLoadAsset<AudioClip>(text, ChaosAssetPaths.AudioClip("Relocator", "release.wav"), ref release); Release = release; } ChaosSuiteRuntimePlugin instance2 = ChaosSuiteRuntimePlugin.Instance; if (instance2 != null) { instance2.RegisterFeatureContent("Relocator", typeof(RelocatorPlugin).Assembly); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Relocator gameplay adapter loaded; a registered network prefab and original voice clips are required."); } private static void InitializeGeneratedNetcode() { if (netcodeInitialized) { return; } netcodeInitialized = true; Type[] types = typeof(RelocatorPlugin).Assembly.GetTypes(); for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); } } } } } public enum RelocatorPhase : byte { Wander, Telegraph, Grabbing, Dragging, Releasing, Fleeing, Stunned, Dead } public enum ReleaseReason : byte { HostileNearby, DoorBlocked, Stunned, PathInvalid, Timeout, Arrived, VictimDied, VictimDisconnected, RoundEnded } public readonly record struct DragState(EntityId Victim, EntityId Destination, RelocatorPhase Phase, double EndsAt, uint Revision); public static class RelocatorRules { public static int DirectDamageInvariant => 0; public static bool MayGrab(EntityId victim, double now, IReadOnlyDictionary<EntityId, double> immunity) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (((EntityId)(ref victim)).IsValid) { if (immunity.TryGetValue(victim, out var value)) { return now >= value; } return true; } return false; } public static DragState Release(DragState state) { //IL_0004: 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) return state with { Victim = EntityId.None, Destination = EntityId.None, Phase = RelocatorPhase.Releasing, Revision = state.Revision + 1 }; } public static bool ShouldEndFlee(double now, double endsAt, float distanceSquared, bool pathUsable) { if (!(now >= endsAt) && !(distanceSquared <= 2.25f)) { return !pathUsable; } return true; } } public sealed class RelocatorEnemyAI : EnemyAI { private const int MaximumNodesConsidered = 64; private const float PullAcceleration = 34f; private const float MaximumPullDistance = 8f; private static readonly Collider[] DangerBuffer = (Collider[])(object)new Collider[16]; private readonly NetworkVariable<byte> phase = new NetworkVariable<byte>((byte)0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<ulong> victimId = new NetworkVariable<ulong>(0uL, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<Vector3> pullPoint = new NetworkVariable<Vector3>(default(Vector3), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly Dictionary<ulong, double> immunityUntil = new Dictionary<ulong, double>(); private readonly NavMeshPath destinationPath = new NavMeshPath(); private readonly Vector3[] routeCorners = (Vector3[])(object)new Vector3[32]; private PlayerControllerB? victim; private Vector3 dragDestination; private Vector3 releaseThreatPosition; private Vector3 fleeDestination; private double phaseEndsAt; private double nextPullPublish; private double nextNoiseAt; private double nextProgressCheck; private Vector3 lastProgressPosition; private byte stalledChecks; private bool localMovementWasDisabled; private bool localMovementPrior; private PlayerControllerB? localDraggedPlayer; private GameObject? visualInstance; private readonly NetworkVariable<uint> voiceRevision = new NetworkVariable<uint>(0u, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<uint> releaseRevision = new NetworkVariable<uint>(0u, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private ulong cleanupAffectedOwner = ulong.MaxValue; protected override void __initializeVariables() { ((NetworkVariableBase)phase).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)phase, "phase"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)phase); ((NetworkVariableBase)victimId).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)victimId, "victimId"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)victimId); ((NetworkVariableBase)pullPoint).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)pullPoint, "pullPoint"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)pullPoint); ((NetworkVariableBase)voiceRevision).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)voiceRevision, "voiceRevision"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)voiceRevision); ((NetworkVariableBase)releaseRevision).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)releaseRevision, "releaseRevision"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)releaseRevision); ((EnemyAI)this).__initializeVariables(); } public override void Start() { ((EnemyAI)this).Start(); if ((Object)(object)((Component)this).GetComponentInChildren<Renderer>(true) == (Object)null) { GameObject visualPrefab = RelocatorPlugin.VisualPrefab; if (visualPrefab != null && Object.op_Implicit((Object)(object)visualPrefab)) { visualInstance = Object.Instantiate<GameObject>(visualPrefab, ((Component)this).transform, false); } } if (Object.op_Implicit((Object)(object)base.agent)) { base.agent.speed = 3f; } } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); RegisterPersistentCleanup(); NetworkVariable<byte> obj = phase; obj.OnValueChanged = (OnValueChangedDelegate<byte>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<byte>(OnPhaseChanged)); NetworkVariable<uint> obj2 = voiceRevision; obj2.OnValueChanged = (OnValueChangedDelegate<uint>)(object)Delegate.Combine((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<uint>(OnVoiceRevision)); NetworkVariable<uint> obj3 = releaseRevision; obj3.OnValueChanged = (OnValueChangedDelegate<uint>)(object)Delegate.Combine((Delegate?)(object)obj3.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<uint>(OnReleaseRevision)); } public override void Update() { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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_00de: 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_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) ((EnemyAI)this).Update(); if (victimId.Value == 0L) { RestoreLocalVictim(); return; } PlayerControllerB val = FindPlayer(victimId.Value - 1); if (val == null || !Object.op_Implicit((Object)(object)val) || !((NetworkBehaviour)val).IsOwner || val.isPlayerDead) { RestoreLocalVictim(); return; } if ((Object)(object)localDraggedPlayer != (Object)null && (Object)(object)localDraggedPlayer != (Object)(object)val) { RestoreLocalVictim(); } if (!localMovementWasDisabled) { localMovementPrior = val.disableMoveInput; } localDraggedPlayer = val; val.disableMoveInput = true; localMovementWasDisabled = true; Vector3 val2 = pullPoint.Value - ((Component)val).transform.position; if (!(((Vector3)(ref val2)).sqrMagnitude <= 0.04f)) { val.externalForces += Vector3.ClampMagnitude(val2 * 7f, 34f) * Time.deltaTime; } } public override void DoAIInterval() { //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0482: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0291: 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_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: 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_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).DoAIInterval(); if (!((NetworkBehaviour)this).IsServer || base.isEnemyDead) { return; } double timeAsDouble = Time.timeAsDouble; if (RoundEnding()) { immunityUntil.Clear(); Release(ReleaseReason.RoundEnded); return; } PlayerControllerB val = victim; if (val != null && (!val.isPlayerControlled || val.disconnectedMidGame || val.isPlayerDead || val.teleportedLastFrame || val.isInHangarShipRoom)) { Release(val.isPlayerDead ? ReleaseReason.VictimDied : ReleaseReason.VictimDisconnected); return; } switch ((RelocatorPhase)phase.Value) { case RelocatorPhase.Wander: { PlayerControllerB val4 = ChooseIsolatedTarget(timeAsDouble); if (!((Object)(object)val4 == (Object)null)) { victim = val4; SetPhase(RelocatorPhase.Telegraph, timeAsDouble + 0.8); NetworkVariable<uint> obj2 = voiceRevision; uint value = obj2.Value; obj2.Value = value + 1; } break; } case RelocatorPhase.Telegraph: { if (timeAsDouble < phaseEndsAt) { break; } PlayerControllerB val2 = victim; if (val2 == null || !Object.op_Implicit((Object)(object)val2) || Vector3.SqrMagnitude(((Component)val2).transform.position - ((Component)this).transform.position) > 9f || !TryChooseDestination(out dragDestination)) { victim = null; SetPhase(RelocatorPhase.Wander, 0.0); break; } ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance == null || !instance.ThreatBudget.TryAcquire(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)0)) { victim = null; SetPhase(RelocatorPhase.Wander, timeAsDouble + 1.5); break; } if (Object.op_Implicit((Object)(object)val2.currentlyHeldObjectServer) && val2.currentlyHeldObjectServer.itemProperties.twoHanded) { val2.DropAllHeldItemsAndSyncNonexact(); } SetCleanupAffectedOwner(((NetworkBehaviour)val2).OwnerClientId); victimId.Value = val2.playerClientId + 1; pullPoint.Value = ((Component)this).transform.position + ((Component)this).transform.forward * 0.4f; ((EnemyAI)this).SetDestinationToPosition(dragDestination, true); lastProgressPosition = ((Component)this).transform.position; nextProgressCheck = timeAsDouble + 0.5; stalledChecks = 0; SetPhase(RelocatorPhase.Dragging, timeAsDouble + 8.0); break; } case RelocatorPhase.Dragging: { PlayerControllerB val3 = victim; if (val3 == null || !Object.op_Implicit((Object)(object)val3)) { Release(ReleaseReason.VictimDisconnected); break; } if (!base.agent.hasPath || base.agent.isPathStale || (int)base.agent.pathStatus != 0) { Release(ReleaseReason.PathInvalid); break; } if (Vector3.SqrMagnitude(((Component)val3).transform.position - pullPoint.Value) > 64f) { Release(ReleaseReason.PathInvalid); break; } if (HostileNearby()) { Release(ReleaseReason.HostileNearby); break; } if (timeAsDouble >= phaseEndsAt) { Release(ReleaseReason.Timeout); break; } if (Vector3.SqrMagnitude(((Component)this).transform.position - dragDestination) <= 4f) { Release(ReleaseReason.Arrived); break; } if (timeAsDouble >= nextProgressCheck) { stalledChecks = (byte)((Vector3.SqrMagnitude(((Component)this).transform.position - lastProgressPosition) < 0.0625f) ? ((byte)(stalledChecks + 1)) : 0); lastProgressPosition = ((Component)this).transform.position; nextProgressCheck = timeAsDouble + 0.5; if (!ValidateCurrentRoute()) { Release(ReleaseReason.PathInvalid); break; } if (stalledChecks >= 2) { Release(ReleaseReason.DoorBlocked); break; } } if (timeAsDouble >= nextPullPublish) { pullPoint.Value = ((Component)this).transform.position + ((Component)this).transform.forward * 0.4f; nextPullPublish = timeAsDouble + 0.2; } if (timeAsDouble >= nextNoiseAt) { ChaosSuiteRuntimePlugin instance2 = ChaosSuiteRuntimePlugin.Instance; if (instance2 != null) { instance2.Noise.TryEmit(new EntityId(((NetworkBehaviour)this).NetworkObjectId), ((Component)this).transform.position, 32f, 0.8f, 9941, timeAsDouble, 1.0, false); } NetworkVariable<uint> obj = voiceRevision; uint value = obj.Value; obj.Value = value + 1; nextNoiseAt = timeAsDouble + 1.4; } break; } case RelocatorPhase.Releasing: if (timeAsDouble >= phaseEndsAt) { if (TryChooseFleeDestination(releaseThreatPosition, out fleeDestination)) { ((EnemyAI)this).SetDestinationToPosition(fleeDestination, true); } SetPhase(RelocatorPhase.Fleeing, timeAsDouble + 2.2); } break; case RelocatorPhase.Fleeing: if (RelocatorRules.ShouldEndFlee(timeAsDouble, phaseEndsAt, Vector3.SqrMagnitude(((Component)this).transform.position - fleeDestination), (Object)(object)base.agent != (Object)null && base.agent.hasPath && !base.agent.isPathStale)) { SetPhase(RelocatorPhase.Wander, 0.0); } break; case RelocatorPhase.Stunned: if (timeAsDouble >= phaseEndsAt) { SetPhase(RelocatorPhase.Wander, 0.0); } break; case RelocatorPhase.Grabbing: break; } } public override void SetEnemyStunned(bool setToStunned, float setToStunTime = 1f, PlayerControllerB? setStunnedByPlayer = null) { ((EnemyAI)this).SetEnemyStunned(setToStunned, setToStunTime, setStunnedByPlayer); if (((NetworkBehaviour)this).IsServer && setToStunned) { Release(ReleaseReason.Stunned); SetPhase(RelocatorPhase.Stunned, Time.timeAsDouble + (double)Mathf.Max(0.5f, setToStunTime)); } } public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { ((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID); if (((NetworkBehaviour)this).IsServer && force > 0) { Release(ReleaseReason.Stunned); } } public override void KillEnemy(bool destroy) { if (((NetworkBehaviour)this).IsServer) { Release(ReleaseReason.RoundEnded); phase.Value = 7; } ((EnemyAI)this).KillEnemy(destroy); } public override void OnNetworkDespawn() { NetworkVariable<byte> obj = phase; obj.OnValueChanged = (OnValueChangedDelegate<byte>)(object)Delegate.Remove((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<byte>(OnPhaseChanged)); NetworkVariable<uint> obj2 = voiceRevision; obj2.OnValueChanged = (OnValueChangedDelegate<uint>)(object)Delegate.Remove((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<uint>(OnVoiceRevision)); NetworkVariable<uint> obj3 = releaseRevision; obj3.OnValueChanged = (OnValueChangedDelegate<uint>)(object)Delegate.Remove((Delegate?)(object)obj3.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<uint>(OnReleaseRevision)); if (((NetworkBehaviour)this).IsServer) { Release(ReleaseReason.RoundEnded); } immunityUntil.Clear(); RestoreLocalVictim(); GameObject val = visualInstance; if (val != null && Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } ((NetworkBehaviour)this).OnNetworkDespawn(); } private void OnDisable() { RestoreLocalVictim(); } private void OnVoiceRevision(uint prior, uint current) { if (current != prior && Object.op_Implicit((Object)(object)RelocatorPlugin.Giggity) && Object.op_Implicit((Object)(object)base.creatureVoice)) { base.creatureVoice.PlayOneShot(RelocatorPlugin.Giggity); } } private void OnPhaseChanged(byte prior, byte current) { bool flag = current != prior; if (flag) { RelocatorPhase relocatorPhase = (RelocatorPhase)current; bool flag2 = ((relocatorPhase == RelocatorPhase.Telegraph || relocatorPhase == RelocatorPhase.Dragging) ? true : false); flag = flag2; } if (flag) { ChaosPresentation.TriggerAction((Component)(object)this); } } private void OnReleaseRevision(uint prior, uint current) { if (current != prior) { ChaosPresentation.TriggerAction((Component)(object)this); if (Object.op_Implicit((Object)(object)RelocatorPlugin.Release) && Object.op_Implicit((Object)(object)base.creatureVoice)) { base.creatureVoice.PlayOneShot(RelocatorPlugin.Release); } } } private bool TryChooseDestination(out Vector3 chosen) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0080: 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_00aa: 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_00c5: Unknown result type (might be due to invalid IL or missing references) chosen = default(Vector3); if (Object.op_Implicit((Object)(object)RoundManager.Instance)) { GameObject[] insideAINodes = RoundManager.Instance.insideAINodes; if (insideAINodes != null && insideAINodes.Length > 0) { float num = 0f; int num2 = Math.Min(insideAINodes.Length, 64); for (int i = 0; i < num2; i++) { GameObject val = insideAINodes[i]; if (Object.op_Implicit((Object)(object)val)) { Vector3 position = val.transform.position; float num3 = Vector3.Distance(((Component)this).transform.position, position); if (!(num3 < 18f) && !(num3 <= num) && StandingPointIsSafe(position) && NavMesh.CalculatePath(((Component)this).transform.position, position, -1, destinationPath) && (int)destinationPath.status == 0 && ValidatePath(destinationPath)) { num = num3; chosen = position; } } } return num > 0f; } } return false; } private bool TryChooseFleeDestination(Vector3 threatPosition, out Vector3 chosen) { //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_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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_007b: 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_0088: 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_0096: 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_00bb: 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_00cf: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) chosen = ((Component)this).transform.position; if (Object.op_Implicit((Object)(object)RoundManager.Instance)) { GameObject[] insideAINodes = RoundManager.Instance.insideAINodes; if (insideAINodes != null && insideAINodes.Length > 0) { float num = Vector3.SqrMagnitude(((Component)this).transform.position - threatPosition); int num2 = Math.Min(insideAINodes.Length, 64); for (int i = 0; i < num2; i++) { GameObject val = insideAINodes[i]; if (Object.op_Implicit((Object)(object)val)) { Vector3 position = val.transform.position; float num3 = Vector3.SqrMagnitude(position - ((Component)this).transform.position); float num4 = Vector3.SqrMagnitude(position - threatPosition); if (!(num3 < 25f) && !(num3 > 576f) && !(num4 <= num) && StandingPointIsSafe(position) && NavMesh.CalculatePath(((Component)this).transform.position, position, -1, destinationPath) && (int)destinationPath.status == 0 && ValidatePath(destinationPath)) { num = num4; chosen = position; } } } return Vector3.SqrMagnitude(chosen - ((Component)this).transform.position) >= 25f; } } return false; } private bool IsDangerous(Vector3 candidate) { //IL_0000: 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_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_003c: Unknown result type (might be due to invalid IL or missing references) if (!(candidate.y < -50f)) { if (Object.op_Implicit((Object)(object)StartOfRound.Instance) && Object.op_Implicit((Object)(object)StartOfRound.Instance.shipBounds)) { Bounds bounds = StartOfRound.Instance.shipBounds.bounds; if (((Bounds)(ref bounds)).Contains(candidate)) { goto IL_0044; } } int num = Physics.OverlapSphereNonAlloc(candidate, 4f, DangerBuffer, -1, (QueryTriggerInteraction)2); for (int i = 0; i < num; i++) { if (Object.op_Implicit((Object)(object)((Component)DangerBuffer[i]).GetComponentInParent<Landmine>()) || Object.op_Implicit((Object)(object)((Component)DangerBuffer[i]).GetComponentInParent<Turret>())) { return true; } } return false; } goto IL_0044; IL_0044: return true; } private bool StandingPointIsSafe(Vector3 candidate) { //IL_0001: 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_0024: 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_0038: Unknown result type (might be due to invalid IL or missing references) if (IsDangerous(candidate) || (Object)(object)StartOfRound.Instance == (Object)null) { return false; } int collidersAndRoomMaskAndDefault = StartOfRound.Instance.collidersAndRoomMaskAndDefault; return Physics.Raycast(candidate + Vector3.up * 0.8f, Vector3.down, 2.5f, collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1); } private bool ValidateCurrentRoute() { if ((Object)(object)base.agent != (Object)null && base.agent.hasPath) { return ValidatePath(base.agent.path); } return false; } private bool ValidatePath(NavMeshPath path) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0086: 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_009a: Unknown result type (might be due to invalid IL or missing references) int cornersNonAlloc = path.GetCornersNonAlloc(routeCorners); if (cornersNonAlloc < 2 || cornersNonAlloc > routeCorners.Length) { return false; } for (int i = 0; i < cornersNonAlloc; i++) { if (!StandingPointIsSafe(routeCorners[i])) { return false; } if (i == 0) { continue; } Vector3 val = routeCorners[i - 1]; Vector3 val2 = routeCorners[i] - val; int num = Math.Min(8, Math.Max(1, Mathf.CeilToInt(((Vector3)(ref val2)).magnitude / 3f))); for (int j = 1; j < num; j++) { if (!StandingPointIsSafe(Vector3.Lerp(val, routeCorners[i], (float)j / (float)num))) { return false; } } } return true; } private PlayerControllerB? ChooseIsolatedTarget(double now) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_00cc: 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) PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return null; } PlayerControllerB result = null; float num = -1f; int num2 = Math.Min(array.Length, 16); for (int i = 0; i < num2; i++) { PlayerControllerB val = array[i]; if ((Object)(object)val == (Object)null || !MayGrab(val, now) || Vector3.SqrMagnitude(((Component)val).transform.position - ((Component)this).transform.position) > 36f || !HasLineOfSight(val)) { continue; } float num3 = float.PositiveInfinity; for (int j = 0; j < num2; j++) { PlayerControllerB val2 = array[j]; if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)val) && MayGrab(val2, now)) { num3 = Mathf.Min(num3, Vector3.SqrMagnitude(((Component)val2).transform.position - ((Component)val).transform.position)); } } if (!(num3 <= num)) { num = num3; result = val; } } return result; } private bool HasLineOfSight(PlayerControllerB target) { //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_0010: 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_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_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) Vector3 val = ((Component)this).transform.position + Vector3.up; Vector3 val2 = ((Component)target).transform.position + Vector3.up; RaycastHit val3 = default(RaycastHit); if (Physics.Linecast(val, val2, ref val3, -1, (QueryTriggerInteraction)1)) { return (Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<PlayerControllerB>() == (Object)(object)target; } return true; } private bool HostileNearby() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapSphereNonAlloc(((Component)this).transform.position, 5f, DangerBuffer, -1, (QueryTriggerInteraction)2); for (int i = 0; i < num; i++) { EnemyAI componentInParent = ((Component)DangerBuffer[i]).GetComponentInParent<EnemyAI>(); if (Object.op_Implicit((Object)(object)componentInParent) && (Object)(object)componentInParent != (Object)(object)this && !componentInParent.isEnemyDead) { return true; } } return false; } private bool MayGrab(PlayerControllerB candidate, double now) { if (candidate.isPlayerControlled && !candidate.isPlayerDead && !candidate.disconnectedMidGame && candidate.isInsideFactory && !candidate.isInHangarShipRoom) { if (immunityUntil.TryGetValue(candidate.playerClientId, out var value)) { return now >= value; } return true; } return false; } private void Release(ReleaseReason reason) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //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_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_00d5: 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_00eb: 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_007c: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsServer || (victimId.Value == 0L && !Object.op_Implicit((Object)(object)victim))) { return; } PlayerControllerB val = victim; if (val != null) { releaseThreatPosition = ((Component)val).transform.position; if (reason != ReleaseReason.RoundEnded) { immunityUntil[val.playerClientId] = Time.timeAsDouble + 25.0; } if (reason == ReleaseReason.Arrived && StandingPointIsSafe(dragDestination)) { SafeReleaseClientRpc(((NetworkBehaviour)val).OwnerClientId, dragDestination); } } else { releaseThreatPosition = ((Component)this).transform.position - ((Component)this).transform.forward * 2f; } SetCleanupAffectedOwner(ulong.MaxValue); victim = null; victimId.Value = 0uL; pullPoint.Value = Vector3.zero; fleeDestination = ((Component)this).transform.position; NetworkVariable<uint> obj = releaseRevision; uint value = obj.Value; obj.Value = value + 1; ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.ThreatBudget.Release(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)0, $"relocator release: {reason}"); } SetPhase((reason == ReleaseReason.Stunned) ? RelocatorPhase.Stunned : RelocatorPhase.Releasing, Time.timeAsDouble + 0.7); } private void RegisterPersistentCleanup() { if (((NetworkBehaviour)this).IsServer && !((Object)(object)((NetworkBehaviour)this).NetworkObject == (Object)null) && ((NetworkBehaviour)this).NetworkObject.IsSpawned) { ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.Cleanup.Register(((NetworkBehaviour)this).NetworkObject, (Action)CleanupPersistentEffect); } } } private void CleanupPersistentEffect() { Release(ReleaseReason.RoundEnded); } private void SetCleanupAffectedOwner(ulong nextOwner) { //IL_003f: 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) if (((NetworkBehaviour)this).IsServer && cleanupAffectedOwner != nextOwner) { ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; EffectCleanupRegistry val = ((instance != null) ? instance.Cleanup : null); EntityId val2 = default(EntityId); ((EntityId)(ref val2))..ctor(((NetworkBehaviour)this).NetworkObjectId); if (cleanupAffectedOwner != ulong.MaxValue && val != null) { val.DisassociateAffectedOwner(val2, cleanupAffectedOwner); } cleanupAffectedOwner = nextOwner; if (cleanupAffectedOwner != ulong.MaxValue && val != null) { val.AssociateAffectedOwner(val2, cleanupAffectedOwner); } } } [ClientRpc] private void SafeReleaseClientRpc(ulong targetClient, Vector3 destination) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e7: 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) 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(2161501617u, val2, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, targetClient); ((FastBufferWriter)(ref val)).WriteValueSafe(ref destination); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 2161501617u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; Vector3 destination2 = destination; NetworkManager singleton = NetworkManager.Singleton; if (singleton == null || singleton.LocalClientId != targetClient) { return; } PlayerControllerB local = GameNetworkManager.Instance?.localPlayerController; if ((Object)(object)local != (Object)null && !local.isPlayerDead) { TeleportCleanupGuard.RunWithoutCleanup((Action)delegate { //IL_0007: Unknown result type (might be due to invalid IL or missing references) local.TeleportPlayer(destination2, false, 0f, false, true); }); } } private PlayerControllerB? FindPlayer(ulong clientId) { if (!Object.op_Implicit((Object)(object)StartOfRound.Instance)) { return null; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; for (int i = 0; i < allPlayerScripts.Length; i++) { if (Object.op_Implicit((Object)(object)allPlayerScripts[i]) && allPlayerScripts[i].playerClientId == clientId) { return allPlayerScripts[i]; } } return null; } private void RestoreLocalVictim() { if (localMovementWasDisabled) { PlayerControllerB val = localDraggedPlayer; if ((Object)(object)val == (Object)null || !Object.op_Implicit((Object)(object)val)) { val = GameNetworkManager.Instance?.localPlayerController; } if ((Object)(object)val != (Object)null && Object.op_Implicit((Object)(object)val)) { val.disableMoveInput = localMovementPrior; } localDraggedPlayer = null; localMovementWasDisabled = false; } } private void SetPhase(RelocatorPhase next, double deadline) { phase.Value = (byte)next; phaseEndsAt = deadline; if (Object.op_Implicit((Object)(object)base.agent)) { base.agent.speed = next switch { RelocatorPhase.Wander => 3f, RelocatorPhase.Fleeing => 7f, RelocatorPhase.Dragging => 6.5f, _ => 0f, }; } } private static bool RoundEnding() { if (Object.op_Implicit((Object)(object)StartOfRound.Instance) && !StartOfRound.Instance.shipIsLeaving) { return StartOfRound.Instance.inShipPhase; } return true; } 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 ((NetworkBehaviour)this).__registerRpc(2161501617u, new RpcReceiveHandler(__rpc_handler_2161501617), "SafeReleaseClientRpc"); ((EnemyAI)this).__initializeRpcs(); } private static void __rpc_handler_2161501617(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_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) { ulong targetClient = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref targetClient); Vector3 destination = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref destination); target.__rpc_exec_stage = (__RpcExecStage)1; ((RelocatorEnemyAI)(object)target).SafeReleaseClientRpc(targetClient, destination); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "RelocatorEnemyAI"; } } } namespace System.Runtime.CompilerServices { internal static class IsExternalInit { } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<byte>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<byte>(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<Vector3>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<Vector3>(); } } } namespace ChaosSuite.Relocator.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }
plugins/ChaosSuite-Webhead/ChaosSuite.Webhead.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using ChaosSuite.Core; using ChaosSuite.Runtime; using ChaosSuite.Webhead.NetcodePatcher; using GameNetcodeStuff; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; [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("ChaosSuite.Webhead")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a3464fa3098fa6be253d588a5b7ca9ba01bef4dd")] [assembly: AssemblyProduct("ChaosSuite.Webhead")] [assembly: AssemblyTitle("ChaosSuite.Webhead")] [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 ChaosSuite.Webhead { [BepInPlugin("com.chaossuite.webhead", "Webhead", "0.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class WebheadPlugin : BaseUnityPlugin { public const string PluginGuid = "com.chaossuite.webhead"; public const string PluginName = "Webhead"; public const string PluginVersion = "0.2.0"; private static bool netcodeInitialized; internal static GameObject? VisualPrefab { get; private set; } private void Awake() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) InitializeGeneratedNetcode(); ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; AssetBundleRegistry val = ((instance != null) ? instance.Assets : null); AssetBundle val2 = default(AssetBundle); if (val != null && val.TryLoadModuleBundle("Webhead", typeof(WebheadPlugin).Assembly, ref val2)) { GameObject visualPrefab = default(GameObject); val.TryLoadAsset<GameObject>(ChaosAssetPaths.BundleName("Webhead"), ChaosAssetPaths.VisualPrefab("Webhead"), ref visualPrefab); VisualPrefab = visualPrefab; } ChaosSuiteRuntimePlugin instance2 = ChaosSuiteRuntimePlugin.Instance; if (instance2 != null) { instance2.RegisterFeatureContent("Webhead", typeof(WebheadPlugin).Assembly); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Webhead gameplay adapter loaded with host-authoritative staged webs and rescue interaction."); } private static void InitializeGeneratedNetcode() { if (netcodeInitialized) { return; } netcodeInitialized = true; Type[] types = typeof(WebheadPlugin).Assembly.GetTypes(); for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); } } } } } public enum WebheadPhase : byte { Crawling, Swinging, Aiming, Recovering, Stunned, Dead } public enum WebStage : byte { None, Tethered, Wrapped, Cocooned } public readonly record struct WebVictimState(EntityId Victim, EntityId Anchor, WebStage Stage, double RescueDeadline, uint Revision); public readonly record struct SwingState(EntityId StartAnchor, EntityId EndAnchor, ushort NormalizedProgress, WebheadPhase Phase, uint Revision); public static class WebRules { public static WebVictimState Apply(WebVictimState current, EntityId victim, EntityId anchor, double deadline) { //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) return new WebVictimState(victim, anchor, (WebStage)Math.Min(3, (int)(current.Stage + 1)), deadline, current.Revision + 1); } public static WebVictimState Clear(WebVictimState current) { //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) return new WebVictimState(EntityId.None, EntityId.None, WebStage.None, 0.0, current.Revision + 1); } public static bool CanRescue(WebStage stage, double distance, double maximumDistance) { if (stage != WebStage.None && distance >= 0.0 && maximumDistance > 0.0) { return distance <= maximumDistance; } return false; } public static bool MatchesRescueSnapshot(ulong activeVictim, uint activeRevision, ulong expectedVictim, uint expectedRevision) { if (activeVictim != 0L && activeVictim == expectedVictim) { return activeRevision == expectedRevision; } return false; } } public sealed class WebheadEnemyAI : EnemyAI { private const float RescueDistance = 3f; private const float TetherRadius = 4.5f; private const float WrappedRadius = 2.8f; private const double RescueRequestInterval = 0.2; private const double CocoonDuration = 12.0; private const double FatalOutcomeRetryInterval = 0.75; private const double FatalOutcomeTimeout = 4.0; private const byte FatalOutcomeMaximumAttempts = 5; private static readonly FieldInfo? MovementSpeedField = typeof(PlayerControllerB).GetField("movementSpeed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static readonly FieldInfo? JumpForceField = typeof(PlayerControllerB).GetField("jumpForce", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private readonly NetworkVariable<byte> phase = new NetworkVariable<byte>((byte)0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<byte> webStage = new NetworkVariable<byte>((byte)0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<ulong> victimId = new NetworkVariable<ulong>(0uL, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<Vector3> victimAnchor = new NetworkVariable<Vector3>(default(Vector3), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<double> rescueDeadline = new NetworkVariable<double>(0.0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<uint> webRevision = new NetworkVariable<uint>(0u, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<Vector3> swingStart = new NetworkVariable<Vector3>(default(Vector3), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<Vector3> swingEnd = new NetworkVariable<Vector3>(default(Vector3), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<ushort> swingProgress = new NetworkVariable<ushort>((ushort)0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<uint> shotRevision = new NetworkVariable<uint>(0u, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly NetworkVariable<bool> spiderEmployee = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); private readonly Dictionary<ulong, double> nextRescueRequestByClient = new Dictionary<ulong, double>(); private readonly ulong[] fatalOutcomeTarget = new ulong[1]; private PlayerControllerB? victim; private PlayerControllerB? restrictedLocalPlayer; private double phaseEndsAt; private double swingStartedAt; private double nextProgressPublish; private double minionWebExpiresAt; private double stageExpiresAt; private double nextLocalCocoonCorrection; private ulong cleanupAffectedOwner = ulong.MaxValue; private double nextMinionShotAt; private double nextLocalRescueRequestAt; private double nextHudAt; private uint localAnchorHitSequence; private uint fatalOutcomeSequence; private uint pendingFatalOutcomeRevision; private ulong pendingFatalOutcomeClient = ulong.MaxValue; private Vector3 pendingFatalOutcomePosition; private double nextFatalOutcomeRetryAt; private double fatalOutcomeExpiresAt; private byte fatalOutcomeAttempts; private bool fatalOutcomeAcknowledged; private Vector3 controlPoint; private GameObject? visualInstance; private GameObject? anchorKnot; private LineRenderer? webLine; private LineRenderer? aimLine; private Material? webMaterial; private AudioLowPassFilter? voiceMuffle; private bool savedDisableMoveInput; private float? savedMovementSpeed; private float? savedJumpForce; public WebheadPhase Phase => (WebheadPhase)phase.Value; public WebStage VictimStage => (WebStage)webStage.Value; public bool IsSpiderEmployee => spiderEmployee.Value; protected override void __initializeVariables() { ((NetworkVariableBase)phase).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)phase, "phase"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)phase); ((NetworkVariableBase)webStage).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)webStage, "webStage"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)webStage); ((NetworkVariableBase)victimId).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)victimId, "victimId"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)victimId); ((NetworkVariableBase)victimAnchor).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)victimAnchor, "victimAnchor"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)victimAnchor); ((NetworkVariableBase)rescueDeadline).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)rescueDeadline, "rescueDeadline"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)rescueDeadline); ((NetworkVariableBase)webRevision).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)webRevision, "webRevision"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)webRevision); ((NetworkVariableBase)swingStart).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)swingStart, "swingStart"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)swingStart); ((NetworkVariableBase)swingEnd).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)swingEnd, "swingEnd"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)swingEnd); ((NetworkVariableBase)swingProgress).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)swingProgress, "swingProgress"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)swingProgress); ((NetworkVariableBase)shotRevision).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)shotRevision, "shotRevision"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)shotRevision); ((NetworkVariableBase)spiderEmployee).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)spiderEmployee, "spiderEmployee"); ((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)spiderEmployee); ((EnemyAI)this).__initializeVariables(); } public override void Start() { ((EnemyAI)this).Start(); base.AIIntervalTime = 0.15f; if ((Object)(object)((Component)this).GetComponentInChildren<Renderer>(true) == (Object)null) { GameObject visualPrefab = WebheadPlugin.VisualPrefab; if (visualPrefab != null && Object.op_Implicit((Object)(object)visualPrefab)) { visualInstance = Object.Instantiate<GameObject>(visualPrefab, ((Component)this).transform, false); } } if (Object.op_Implicit((Object)(object)base.agent)) { base.agent.speed = 3.5f; } } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); RegisterPersistentCleanup(); NetworkVariable<byte> obj = webStage; obj.OnValueChanged = (OnValueChangedDelegate<byte>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<byte>(OnWebStageChanged)); NetworkVariable<ulong> obj2 = victimId; obj2.OnValueChanged = (OnValueChangedDelegate<ulong>)(object)Delegate.Combine((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<ulong>(OnVictimChanged)); NetworkVariable<Vector3> obj3 = victimAnchor; obj3.OnValueChanged = (OnValueChangedDelegate<Vector3>)(object)Delegate.Combine((Delegate?)(object)obj3.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<Vector3>(OnAnchorChanged)); NetworkVariable<uint> obj4 = shotRevision; obj4.OnValueChanged = (OnValueChangedDelegate<uint>)(object)Delegate.Combine((Delegate?)(object)obj4.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<uint>(OnShotRevisionChanged)); NetworkVariable<bool> obj5 = spiderEmployee; obj5.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)obj5.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(OnSpiderEmployeeChanged)); CreateWebPresentation(); RefreshLocalRestriction(); RefreshMinionPresentation(); } public override void Update() { //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_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_009a: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00de: 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_00e8: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).Update(); UpdateLocalWebPresentation(); UpdateLocalRestrictionAndRescue(); if (((NetworkBehaviour)this).IsServer && Phase == WebheadPhase.Swinging && !base.isEnemyDead && !IsSpiderEmployee) { double num = Math.Max(0.25, phaseEndsAt - swingStartedAt); float num2 = Mathf.Clamp01((float)((Time.timeAsDouble - swingStartedAt) / num)); float num3 = 1f - num2; ((Component)this).transform.position = num3 * num3 * swingStart.Value + 2f * num3 * num2 * controlPoint + num2 * num2 * swingEnd.Value; Transform transform = ((Component)this).transform; Vector3 forward = ((Component)this).transform.forward; Vector3 val = swingEnd.Value - ((Component)this).transform.position; transform.forward = Vector3.Slerp(forward, ((Vector3)(ref val)).normalized, Time.deltaTime * 8f); if (Time.timeAsDouble >= nextProgressPublish) { swingProgress.Value = (ushort)Mathf.RoundToInt(num2 * 65535f); nextProgressPublish = Time.timeAsDouble + 0.1; } RaycastHit val2 = default(RaycastHit); if (Physics.Linecast(((Component)this).transform.position, swingEnd.Value, ref val2, -1, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val2)).distance < 0.4f) { Crash(); } } } public override void DoAIInterval() { //IL_0194: Unknown result type (might be due to invalid IL or missing references) ((EnemyAI)this).DoAIInterval(); if (!((NetworkBehaviour)this).IsServer || base.isEnemyDead) { return; } double timeAsDouble = Time.timeAsDouble; if (pendingFatalOutcomeClient != ulong.MaxValue) { AdvanceFatalOutcome(timeAsDouble); return; } if (RoundEnding()) { ClearWeb(); return; } PlayerControllerB val = victim; if (val != null && (!val.isPlayerControlled || val.isPlayerDead || val.disconnectedMidGame || val.teleportedLastFrame || val.isInHangarShipRoom)) { ClearWeb(); } if (IsSpiderEmployee) { DoSpiderEmployeeInterval(timeAsDouble); return; } if ((int)VictimStage >= 2) { PlayerControllerB val2 = victim; if (val2 != null && Object.op_Implicit((Object)(object)val2.currentlyHeldObjectServer) && val2.currentlyHeldObjectServer.itemProperties.twoHanded) { val2.DropAllHeldItemsAndSyncNonexact(); } } WebStage victimStage = VictimStage; bool flag = victimStage - 1 <= WebStage.Tethered; if (flag && timeAsDouble >= stageExpiresAt) { DecayWebStage(timeAsDouble); } switch (Phase) { case WebheadPhase.Crawling: { if (timeAsDouble < phaseEndsAt) { return; } if (VictimStage == WebStage.None) { if (!((EnemyAI)this).TargetClosestPlayer(4f, true, 100f, false, true, false) || !Object.op_Implicit((Object)(object)base.targetPlayer)) { return; } victim = base.targetPlayer; } PlayerControllerB val3 = victim; if (val3 == null || !Object.op_Implicit((Object)(object)val3) || val3.isPlayerDead) { ClearWeb(); return; } victimId.Value = val3.playerClientId + 1; if (TryBeginSwing(((Component)val3).transform.position)) { return; } BeginAiming(timeAsDouble, 0.7); break; } case WebheadPhase.Swinging: if (timeAsDouble >= phaseEndsAt) { BeginAiming(timeAsDouble, 0.65); } break; case WebheadPhase.Aiming: if (timeAsDouble >= phaseEndsAt) { FireWeb(); SetPhase(WebheadPhase.Recovering, timeAsDouble + 1.1); } break; case WebheadPhase.Recovering: if (timeAsDouble >= phaseEndsAt) { SetPhase(WebheadPhase.Crawling, timeAsDouble + 2.4); } break; case WebheadPhase.Stunned: if (timeAsDouble >= phaseEndsAt) { SetPhase(WebheadPhase.Crawling, timeAsDouble + 2.4); } break; } if (VictimStage == WebStage.Cocooned && timeAsDouble >= rescueDeadline.Value) { PlayerControllerB val4 = victim; if (val4 != null && !val4.isPlayerDead) { BeginFatalOutcome(val4, timeAsDouble); } } } [ServerRpc(RequireOwnership = false)] private void RequestCutWebServerRpc(ulong expectedVictimId, uint expectedRevision, ServerRpcParams rpc = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3010056802u, rpc, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, expectedVictimId); BytePacker.WriteValueBitPacked(val, expectedRevision); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 3010056802u, rpc, (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 || pendingFatalOutcomeClient != ulong.MaxValue || RoundEnding() || VictimStage == WebStage.None || !WebRules.MatchesRescueSnapshot(victimId.Value, webRevision.Value, expectedVictimId, expectedRevision)) { return; } ulong senderClientId = rpc.Receive.SenderClientId; double timeAsDouble = Time.timeAsDouble; if (!nextRescueRequestByClient.TryGetValue(senderClientId, out var value) || !(timeAsDouble < value)) { nextRescueRequestByClient[senderClientId] = timeAsDouble + 0.2; PlayerControllerB val2 = FindPlayerByOwner(senderClientId); if (val2 != null && Object.op_Implicit((Object)(object)val2) && !val2.isPlayerDead && val2.isPlayerControlled && !val2.disconnectedMidGame && val2.playerClientId + 1 != victimId.Value) { TryCutWeb(val2); } } } [ServerRpc(RequireOwnership = false)] private void RequestAnchorHitServerRpc(ulong claimedPlayer, uint sequence, ulong expectedVictimId, uint expectedRevision, ServerRpcParams rpc = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_008b: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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_01af: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2277259762u, rpc, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, claimedPlayer); BytePacker.WriteValueBitPacked(val, sequence); BytePacker.WriteValueBitPacked(val, expectedVictimId); BytePacker.WriteValueBitPacked(val, expectedRevision); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 2277259762u, rpc, (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 || pendingFatalOutcomeClient != ulong.MaxValue || rpc.Receive.SenderClientId != claimedPlayer || sequence == 0 || RoundEnding() || !WebRules.MatchesRescueSnapshot(victimId.Value, webRevision.Value, expectedVictimId, expectedRevision)) { return; } PlayerControllerB val2 = FindPlayerByOwner(claimedPlayer); if (!((Object)(object)val2 == (Object)null) && !val2.isPlayerDead && !val2.disconnectedMidGame && (val2.currentlyHeldObjectServer is Shovel || val2.currentlyHeldObjectServer is KnifeItem) && !(Vector3.SqrMagnitude(((Component)val2).transform.position - victimAnchor.Value) > 9f) && HasLineOfSight((Component)(object)val2, victimAnchor.Value)) { ClearWeb(); if (!IsSpiderEmployee) { SetPhase(WebheadPhase.Stunned, Time.timeAsDouble + 2.5); } } } internal void HitAnchor(PlayerControllerB player) { //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) if ((Object)(object)player == (Object)null || VictimStage == WebStage.None) { return; } if (((NetworkBehaviour)this).IsServer) { TryCutWeb(player); return; } localAnchorHitSequence++; if (localAnchorHitSequence == 0) { localAnchorHitSequence = 1u; } RequestAnchorHitServerRpc(((NetworkBehaviour)player).OwnerClientId, localAnchorHitSequence, victimId.Value, webRevision.Value); } public bool TryCutWeb(PlayerControllerB rescuer) { //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_0078: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsServer && pendingFatalOutcomeClient == ulong.MaxValue && !RoundEnding() && Object.op_Implicit((Object)(object)rescuer) && !rescuer.isPlayerDead) { PlayerControllerB val = victim; if (val != null && !val.isPlayerDead) { float num = Vector3.Distance(((Component)rescuer).transform.position, victimAnchor.Value); if (!WebRules.CanRescue(VictimStage, num, 3.0) || !HasLineOfSight((Component)(object)rescuer, victimAnchor.Value)) { return false; } ClearWeb(); if (!IsSpiderEmployee) { SetPhase(WebheadPhase.Stunned, Time.timeAsDouble + 2.5); } return true; } } return false; } public override void SetEnemyStunned(bool setToStunned, float setToStunTime = 1f, PlayerControllerB? setStunnedByPlayer = null) { ((EnemyAI)this).SetEnemyStunned(setToStunned, setToStunTime, setStunnedByPlayer); if (((NetworkBehaviour)this).IsServer && setToStunned) { ClearWeb(); SetPhase(WebheadPhase.Stunned, Time.timeAsDouble + (double)Mathf.Max(0.5f, setToStunTime)); } } public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { ((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID); if (((NetworkBehaviour)this).IsServer && force > 0 && playerWhoHit != null && Object.op_Implicit((Object)(object)playerWhoHit) && VictimStage != WebStage.None) { TryCutWeb(playerWhoHit); } } public override void KillEnemy(bool destroy) { if (((NetworkBehaviour)this).IsServer) { ClearFatalOutcomeState(); ClearWeb(); phase.Value = 5; } ((EnemyAI)this).KillEnemy(destroy); } public override void OnNetworkDespawn() { NetworkVariable<byte> obj = webStage; obj.OnValueChanged = (OnValueChangedDelegate<byte>)(object)Delegate.Remove((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<byte>(OnWebStageChanged)); NetworkVariable<ulong> obj2 = victimId; obj2.OnValueChanged = (OnValueChangedDelegate<ulong>)(object)Delegate.Remove((Delegate?)(object)obj2.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<ulong>(OnVictimChanged)); NetworkVariable<Vector3> obj3 = victimAnchor; obj3.OnValueChanged = (OnValueChangedDelegate<Vector3>)(object)Delegate.Remove((Delegate?)(object)obj3.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<Vector3>(OnAnchorChanged)); NetworkVariable<uint> obj4 = shotRevision; obj4.OnValueChanged = (OnValueChangedDelegate<uint>)(object)Delegate.Remove((Delegate?)(object)obj4.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<uint>(OnShotRevisionChanged)); NetworkVariable<bool> obj5 = spiderEmployee; obj5.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Remove((Delegate?)(object)obj5.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(OnSpiderEmployeeChanged)); if (((NetworkBehaviour)this).IsServer) { ClearFatalOutcomeState(); ClearWeb(); } RestoreLocalRestriction(); DestroyWebPresentation(); nextRescueRequestByClient.Clear(); GameObject val = visualInstance; if (val != null && Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } ((NetworkBehaviour)this).OnNetworkDespawn(); } public override void OnDestroy() { RestoreLocalRestriction(); DestroyWebPresentation(); nextRescueRequestByClient.Clear(); ClearFatalOutcomeState(); ((EnemyAI)this).OnDestroy(); } private void OnDisable() { RestoreLocalRestriction(); RemoveVoiceMuffle(); LineRenderer val = webLine; if (val != null && Object.op_Implicit((Object)(object)val)) { ((Renderer)val).enabled = false; } LineRenderer val2 = aimLine; if (val2 != null && Object.op_Implicit((Object)(object)val2)) { ((Renderer)val2).enabled = false; } GameObject val3 = anchorKnot; if (val3 != null && Object.op_Implicit((Object)(object)val3)) { val3.SetActive(false); } } private bool TryBeginSwing(Vector3 toward) { //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_0010: 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_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_003d: 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_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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e6: 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_00f0: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (!Physics.Raycast(((Component)this).transform.position + Vector3.up, Vector3.up, ref val, 9f, -1, (QueryTriggerInteraction)1)) { return false; } Vector3 val2 = Vector3.ProjectOnPlane(toward - ((Component)this).transform.position, Vector3.up); Vector3 normalized = ((Vector3)(ref val2)).normalized; RaycastHit val3 = default(RaycastHit); if (!Physics.Raycast(((RaycastHit)(ref val)).point - Vector3.up * 0.2f, normalized, ref val3, 12f, -1, (QueryTriggerInteraction)1)) { return false; } swingStart.Value = ((Component)this).transform.position; swingEnd.Value = ((RaycastHit)(ref val3)).point - normalized * 0.6f; controlPoint = (swingStart.Value + swingEnd.Value) * 0.5f + Vector3.up * 4f; swingProgress.Value = 0; if (Object.op_Implicit((Object)(object)base.agent)) { ((Behaviour)base.agent).enabled = false; } swingStartedAt = Time.timeAsDouble; SetPhase(WebheadPhase.Swinging, swingStartedAt + 1.8); return true; } private void FireWeb() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_0048: 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_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) //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_0119: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = victim; if (val == null || val.isPlayerDead) { return; } Vector3 val2 = ((Component)this).transform.position + Vector3.up; Vector3 val3 = ((Component)val).transform.position + Vector3.up - val2; Vector3 normalized = ((Vector3)(ref val3)).normalized; NetworkVariable<uint> obj = shotRevision; uint value = obj.Value; obj.Value = value + 1; ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.Noise.TryEmit(new EntityId(((NetworkBehaviour)this).NetworkObjectId), val2, 18f, 0.65f, 9921, Time.timeAsDouble, 0.2, false); } RaycastHit val4 = default(RaycastHit); if (!Physics.SphereCast(val2, 0.18f, normalized, ref val4, 18f, -1, (QueryTriggerInteraction)1) || (Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent<PlayerControllerB>() != (Object)(object)val) { return; } if (VictimStage == WebStage.None) { ChaosSuiteRuntimePlugin instance2 = ChaosSuiteRuntimePlugin.Instance; if (instance2 == null || !instance2.ThreatBudget.TryAcquire(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)0)) { return; } } if (VictimStage == WebStage.None) { SetCleanupAffectedOwner(((NetworkBehaviour)val).OwnerClientId); victimAnchor.Value = FindSafeAnchor(val); } WebStage webStage = (WebStage)Math.Min(3, (int)(VictimStage + 1)); this.webStage.Value = (byte)webStage; stageExpiresAt = ((webStage == WebStage.Cocooned) ? 0.0 : (Time.timeAsDouble + 6.0)); rescueDeadline.Value = ((webStage == WebStage.Cocooned) ? (Time.timeAsDouble + 12.0) : 0.0); NetworkVariable<uint> obj2 = webRevision; value = obj2.Value; obj2.Value = value + 1; if ((int)webStage >= 2 && Object.op_Implicit((Object)(object)val.currentlyHeldObjectServer) && val.currentlyHeldObjectServer.itemProperties.twoHanded) { val.DropAllHeldItemsAndSyncNonexact(); } } private void BeginAiming(double now, double duration) { //IL_0020: 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) SetPhase(WebheadPhase.Aiming, now + duration); ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.Noise.TryEmit(new EntityId(((NetworkBehaviour)this).NetworkObjectId), ((Component)this).transform.position, 14f, 0.42f, 9920, now, 0.5, false); } TelegraphShotClientRpc(); } [ClientRpc] private void TelegraphShotClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1710922175u, val2, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1710922175u, val2, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; ChaosPresentation.TriggerAction((Component)(object)this); if ((Object)(object)base.creatureSFX != (Object)null) { ((Component)base.creatureSFX).gameObject.SendMessage("Play", (SendMessageOptions)1); } } } [ClientRpc] private void ApplyCocoonFatalOutcomeClientRpc(ulong targetClient, uint outcomeRevision, ClientRpcParams clientRpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0147: 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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(300530035u, clientRpcParams, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, targetClient); BytePacker.WriteValueBitPacked(val, outcomeRevision); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 300530035u, clientRpcParams, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } ((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0; NetworkManager singleton = NetworkManager.Singleton; if (singleton == null || singleton.LocalClientId != targetClient) { return; } PlayerControllerB val2 = GameNetworkManager.Instance?.localPlayerController; if (!((Object)(object)val2 == (Object)null) && ((NetworkBehaviour)val2).OwnerClientId == targetClient) { if (!val2.isPlayerDead) { val2.KillPlayer(Vector3.zero, true, (CauseOfDeath)5, 0, Vector3.zero, false); } if (val2.isPlayerDead) { AcknowledgeCocoonFatalOutcomeServerRpc(outcomeRevision); } } } [ServerRpc(RequireOwnership = false)] private void AcknowledgeCocoonFatalOutcomeServerRpc(uint outcomeRevision, ServerRpcParams rpc = default(ServerRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_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) //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) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1584528627u, rpc, (RpcDelivery)0); BytePacker.WriteValueBitPacked(val, outcomeRevision); ((NetworkBehaviour)this).__endSendServerRpc(ref val, 1584528627u, rpc, (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 && pendingFatalOutcomeClient != ulong.MaxValue && rpc.Receive.SenderClientId == pendingFatalOutcomeClient && outcomeRevision != 0 && outcomeRevision == pendingFatalOutcomeRevision) { fatalOutcomeAcknowledged = true; PlayerControllerB val2 = FindPlayerByOwner(pendingFatalOutcomeClient); if ((Object)(object)val2 != (Object)null && val2.isPlayerDead) { CommitFatalOutcome(); } } } private void BeginFatalOutcome(PlayerControllerB target, double now) { //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 (((NetworkBehaviour)this).IsServer && pendingFatalOutcomeClient == ulong.MaxValue && !((Object)(object)target == (Object)null) && !target.isPlayerDead) { fatalOutcomeSequence++; if (fatalOutcomeSequence == 0) { fatalOutcomeSequence = 1u; } pendingFatalOutcomeRevision = fatalOutcomeSequence; pendingFatalOutcomeClient = ((NetworkBehaviour)target).OwnerClientId; pendingFatalOutcomePosition = ((Component)target).transform.position; fatalOutcomeExpiresAt = now + 4.0; nextFatalOutcomeRetryAt = now; fatalOutcomeAttempts = 0; fatalOutcomeAcknowledged = false; AdvanceFatalOutcome(now); } } private void AdvanceFatalOutcome(double now) { //IL_012e: 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_014b: 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_0151: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)this).IsServer || pendingFatalOutcomeClient == ulong.MaxValue) { return; } PlayerControllerB val = FindPlayerByOwner(pendingFatalOutcomeClient); if ((Object)(object)val != (Object)null && Object.op_Implicit((Object)(object)val) && fatalOutcomeAcknowledged && val.isPlayerDead) { CommitFatalOutcome(); } else if (RoundEnding() || (Object)(object)val == (Object)null || !Object.op_Implicit((Object)(object)val) || val.disconnectedMidGame || (!val.isPlayerControlled && !val.isPlayerDead) || val.teleportedLastFrame || val.isInHangarShipRoom) { AbortFatalOutcome("victim left the active round"); } else if (now >= fatalOutcomeExpiresAt) { AbortFatalOutcome("owner acknowledgement timed out"); } else if (fatalOutcomeAttempts < 5 && !(now < nextFatalOutcomeRetryAt)) { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsListening || !singleton.ConnectedClients.ContainsKey(pendingFatalOutcomeClient)) { AbortFatalOutcome("victim owner disconnected"); return; } fatalOutcomeAttempts++; nextFatalOutcomeRetryAt = now + 0.75; fatalOutcomeTarget[0] = pendingFatalOutcomeClient; ApplyCocoonFatalOutcomeClientRpc(pendingFatalOutcomeClient, pendingFatalOutcomeRevision, new ClientRpcParams { Send = new ClientRpcSendParams { TargetClientIds = fatalOutcomeTarget } }); } } private void CommitFatalOutcome() { //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_0021: Unknown result type (might be due to invalid IL or missing references) if (((NetworkBehaviour)this).IsServer && pendingFatalOutcomeClient != ulong.MaxValue) { Vector3 spawnPosition = pendingFatalOutcomePosition; ClearFatalOutcomeState(); BecomeSpiderEmployee(spawnPosition); } } private void AbortFatalOutcome(string reason) { if (((NetworkBehaviour)this).IsServer && pendingFatalOutcomeClient != ulong.MaxValue) { Debug.LogWarning((object)("[ChaosSuite.Webhead] Cocoon fatal outcome cancelled: " + reason + ".")); ClearFatalOutcomeState(); ClearWeb(); if (!RoundEnding() && !base.isEnemyDead) { SetPhase(WebheadPhase.Stunned, Time.timeAsDouble + 2.0); } } } private void ClearFatalOutcomeState() { //IL_0010: 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) pendingFatalOutcomeClient = ulong.MaxValue; pendingFatalOutcomeRevision = 0u; pendingFatalOutcomePosition = Vector3.zero; nextFatalOutcomeRetryAt = 0.0; fatalOutcomeExpiresAt = 0.0; fatalOutcomeAttempts = 0; fatalOutcomeAcknowledged = false; } private Vector3 FindSafeAnchor(PlayerControllerB target) { //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_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_001f: 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_0021: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_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) //IL_00cb: 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_0052: 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_0061: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)target).transform.position + Vector3.up * 0.8f; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, Vector3.up, ref val2, 4f, -1, (QueryTriggerInteraction)1) && !Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<PlayerControllerB>())) { return ((RaycastHit)(ref val2)).point + ((RaycastHit)(ref val2)).normal * 0.8f; } Vector3 val3 = ((Component)this).transform.position - val; Vector3 normalized = ((Vector3)(ref val3)).normalized; RaycastHit val4 = default(RaycastHit); if (Physics.Raycast(val, normalized, ref val4, 5f, -1, (QueryTriggerInteraction)1) && !Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent<PlayerControllerB>())) { return ((RaycastHit)(ref val4)).point + ((RaycastHit)(ref val4)).normal * 0.8f; } return ((Component)target).transform.position; } private void DoSpiderEmployeeInterval(double now) { //IL_0053: 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_0086: 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_0111: 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_01a3: Unknown result type (might be due to invalid IL or missing references) if (VictimStage != WebStage.None && now >= minionWebExpiresAt) { ClearWeb(); } if (!((EnemyAI)this).TargetClosestPlayer(4f, true, 100f, false, true, false) || !Object.op_Implicit((Object)(object)base.targetPlayer)) { return; } ((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer); ((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, true); if (now < nextMinionShotAt || VictimStage != WebStage.None || Vector3.SqrMagnitude(((Component)base.targetPlayer).transform.position - ((Component)this).transform.position) > 36f || !HasLineOfSight((Component)(object)this, base.targetPlayer)) { return; } ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null && instance.ThreatBudget.TryAcquire(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)0)) { victim = base.targetPlayer; SetCleanupAffectedOwner(((NetworkBehaviour)base.targetPlayer).OwnerClientId); victimId.Value = base.targetPlayer.playerClientId + 1; victimAnchor.Value = FindSafeAnchor(base.targetPlayer); webStage.Value = 1; rescueDeadline.Value = 0.0; NetworkVariable<uint> obj = webRevision; uint value = obj.Value; obj.Value = value + 1; minionWebExpiresAt = now + 5.0; stageExpiresAt = now + 5.0; nextMinionShotAt = now + 8.0; ChaosSuiteRuntimePlugin instance2 = ChaosSuiteRuntimePlugin.Instance; if (instance2 != null) { instance2.Noise.TryEmit(new EntityId(((NetworkBehaviour)this).NetworkObjectId), ((Component)this).transform.position, 12f, 0.45f, 9922, now, 0.5, false); } } } private void BecomeSpiderEmployee(Vector3 spawnPosition) { //IL_001f: 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) ClearWeb(); spiderEmployee.Value = true; base.enemyHP = 1; ((Component)this).transform.position = spawnPosition; if (Object.op_Implicit((Object)(object)base.agent)) { if (!((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = true; } base.agent.speed = 2.2f; if (base.agent.isOnNavMesh) { base.agent.Warp(spawnPosition); } } SetPhase(WebheadPhase.Crawling, Time.timeAsDouble + 1.5); } private void Crash() { if (((NetworkBehaviour)this).IsServer) { if (Object.op_Implicit((Object)(object)base.agent) && !((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = true; } SetPhase(WebheadPhase.Stunned, Time.timeAsDouble + 3.0); } } private void ClearWeb() { //IL_0054: Unknown result type (might be due to invalid IL or missing references) ClearFatalOutcomeState(); if (((NetworkBehaviour)this).IsServer && (victimId.Value != 0L || VictimStage != WebStage.None || !((Object)(object)victim == (Object)null))) { SetCleanupAffectedOwner(ulong.MaxValue); victim = null; victimId.Value = 0uL; victimAnchor.Value = Vector3.zero; webStage.Value = 0; rescueDeadline.Value = 0.0; minionWebExpiresAt = 0.0; stageExpiresAt = 0.0; NetworkVariable<uint> obj = webRevision; uint value = obj.Value; obj.Value = value + 1; ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.ThreatBudget.Release(((NetworkBehaviour)this).NetworkObject, (SystemicThreatKind)0, "web cleared"); } } } private void RegisterPersistentCleanup() { if (((NetworkBehaviour)this).IsServer && !((Object)(object)((NetworkBehaviour)this).NetworkObject == (Object)null) && ((NetworkBehaviour)this).NetworkObject.IsSpawned) { ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; if (instance != null) { instance.Cleanup.Register(((NetworkBehaviour)this).NetworkObject, (Action)CleanupPersistentEffect); } } } private void CleanupPersistentEffect() { ClearWeb(); } private void SetCleanupAffectedOwner(ulong nextOwner) { //IL_003f: 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) if (((NetworkBehaviour)this).IsServer && cleanupAffectedOwner != nextOwner) { ChaosSuiteRuntimePlugin instance = ChaosSuiteRuntimePlugin.Instance; EffectCleanupRegistry val = ((instance != null) ? instance.Cleanup : null); EntityId val2 = default(EntityId); ((EntityId)(ref val2))..ctor(((NetworkBehaviour)this).NetworkObjectId); if (cleanupAffectedOwner != ulong.MaxValue && val != null) { val.DisassociateAffectedOwner(val2, cleanupAffectedOwner); } cleanupAffectedOwner = nextOwner; if (cleanupAffectedOwner != ulong.MaxValue && val != null) { val.AssociateAffectedOwner(val2, cleanupAffectedOwner); } } } private void DecayWebStage(double now) { bool flag = !((NetworkBehaviour)this).IsServer; if (!flag) { WebStage victimStage = VictimStage; bool flag2 = victimStage - 1 <= WebStage.Tethered; flag = !flag2; } if (!flag) { WebStage webStage = VictimStage - 1; if (webStage == WebStage.None) { ClearWeb(); return; } this.webStage.Value = (byte)webStage; rescueDeadline.Value = 0.0; stageExpiresAt = now + 6.0; NetworkVariable<uint> obj = webRevision; uint value = obj.Value; obj.Value = value + 1; } } private void SetPhase(WebheadPhase next, double deadline) { phase.Value = (byte)next; phaseEndsAt = deadline; if (Object.op_Implicit((Object)(object)base.agent) && next != WebheadPhase.Swinging && !((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = true; } } private void UpdateLocalRestrictionAndRescue() { //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_0130: 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_0144: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0299: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB local = GameNetworkManager.Instance?.localPlayerController; if (local == null || !Object.op_Implicit((Object)(object)local) || local.isPlayerDead || RoundEnding()) { RestoreLocalRestriction(); return; } PlayerControllerB val = FindPlayerByToken(victimId.Value); if (val == null || !Object.op_Implicit((Object)(object)val) || VictimStage == WebStage.None) { RestoreLocalRestriction(); } else if ((Object)(object)local == (Object)(object)val) { if ((Object)(object)restrictedLocalPlayer != (Object)(object)local) { RefreshLocalRestriction(); } float num = ((VictimStage == WebStage.Tethered) ? 4.5f : 2.8f); Vector3 val2 = ((Component)local).transform.position - victimAnchor.Value; if (((Vector3)(ref val2)).sqrMagnitude > num * num) { PlayerControllerB obj = local; obj.externalForces += Vector3.ClampMagnitude((victimAnchor.Value + ((Vector3)(ref val2)).normalized * num - ((Component)local).transform.position) * 8f, 22f) * Time.deltaTime; } if (VictimStage != WebStage.Cocooned) { return; } local.disableMoveInput = true; if (Time.timeAsDouble >= nextLocalCocoonCorrection && Vector3.SqrMagnitude(((Component)local).transform.position - victimAnchor.Value) > 0.0625f) { TeleportCleanupGuard.RunWithoutCleanup((Action)delegate { //IL_0011: Unknown result type (might be due to invalid IL or missing references) local.TeleportPlayer(victimAnchor.Value, false, 0f, false, true); }); nextLocalCocoonCorrection = Time.timeAsDouble + 0.25; } ShowRescueTimer(local); } else { RestoreLocalRestriction(); float num2 = Vector3.Distance(((Component)local).transform.position, victimAnchor.Value); if (VictimStage == WebStage.Cocooned && num2 <= 8f) { ShowRescueTimer(local); } else if (WebRules.CanRescue(VictimStage, num2, 3.0)) { ShowCutPrompt(); } if (WebRules.CanRescue(VictimStage, num2, 3.0) && !(Time.timeAsDouble < nextLocalRescueRequestAt) && InteractPressed()) { nextLocalRescueRequestAt = Time.timeAsDouble + 0.2; RequestCutWebServerRpc(victimId.Value, webRevision.Value); } } } private void ShowRescueTimer(PlayerControllerB local) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (!(Time.timeAsDouble < nextHudAt) && Object.op_Implicit((Object)(object)HUDManager.Instance)) { nextHudAt = Time.timeAsDouble + 1.0; double value = rescueDeadline.Value; NetworkTime serverTime = ((NetworkBehaviour)this).NetworkManager.ServerTime; double num = Math.Max(0.0, Math.Ceiling(value - ((NetworkTime)(ref serverTime)).Time)); HUDManager.Instance.DisplayTip("WEB COCOON", $"Rescue window: {num:0}s — teammate interact cuts the strand", true, false, "ChaosSuite_WebheadRescue"); } } private void ShowCutPrompt() { if (!(Time.timeAsDouble < nextHudAt) && Object.op_Implicit((Object)(object)HUDManager.Instance)) { nextHudAt = Time.timeAsDouble + 1.0; HUDManager.Instance.DisplayTip("WEB ANCHOR", "Interact near the knot to cut your teammate free", false, false, "ChaosSuite_WebheadCut"); } } private static bool InteractPressed() { IngamePlayerSettings instance = IngamePlayerSettings.Instance; object obj; if (instance == null) { obj = null; } else { PlayerInput playerInput = instance.playerInput; obj = ((playerInput != null) ? playerInput.actions : null); } if ((Object)obj == (Object)null) { return false; } InputAction obj2 = instance.playerInput.actions.FindAction("Interact", false); if (obj2 == null) { return false; } return obj2.WasPressedThisFrame(); } private void RefreshLocalRestriction() { PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController; PlayerControllerB val2 = FindPlayerByToken(victimId.Value); if (val == null || !Object.op_Implicit((Object)(object)val) || (Object)(object)val != (Object)(object)val2 || VictimStage == WebStage.None) { RestoreLocalRestriction(); return; } if ((Object)(object)restrictedLocalPlayer != (Object)(object)val) { RestoreLocalRestriction(); restrictedLocalPlayer = val; savedDisableMoveInput = val.disableMoveInput; savedMovementSpeed = ReadFloat(MovementSpeedField, val); savedJumpForce = ReadFloat(JumpForceField, val); } WebStage victimStage = VictimStage; if (victimStage == WebStage.Tethered) { WriteLowerFloat(MovementSpeedField, val, savedMovementSpeed, 3.2f); } if ((int)victimStage >= 2) { WriteLowerFloat(MovementSpeedField, val, savedMovementSpeed, 2.4f); WriteLowerFloat(JumpForceField, val, savedJumpForce, 7.5f); } val.disableMoveInput = victimStage == WebStage.Cocooned || savedDisableMoveInput; } private void RestoreLocalRestriction() { PlayerControllerB val = restrictedLocalPlayer; if (val == null || !Object.op_Implicit((Object)(object)val)) { restrictedLocalPlayer = null; return; } val.disableMoveInput = savedDisableMoveInput; if (savedMovementSpeed.HasValue) { MovementSpeedField?.SetValue(val, savedMovementSpeed.Value); } if (savedJumpForce.HasValue) { JumpForceField?.SetValue(val, savedJumpForce.Value); } restrictedLocalPlayer = null; savedMovementSpeed = null; savedJumpForce = null; } private static float? ReadFloat(FieldInfo? field, PlayerControllerB player) { object obj = field?.GetValue(player); if (!(obj is float)) { return null; } return (float)obj; } private static void WriteLowerFloat(FieldInfo? field, PlayerControllerB player, float? baseline, float cap) { if (field != null && baseline.HasValue) { field.SetValue(player, Mathf.Min(baseline.Value, cap)); } } private void CreateWebPresentation() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_0104: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ChaosSuite Web Strand"); val.transform.SetParent(((Component)this).transform, false); webLine = val.AddComponent<LineRenderer>(); webLine.positionCount = 2; webLine.useWorldSpace = true; webLine.numCapVertices = 3; ((Renderer)webLine).enabled = false; Shader val2 = Shader.Find("Sprites/Default"); if (Object.op_Implicit((Object)(object)val2)) { webMaterial = new Material(val2); ((Renderer)webLine).material = webMaterial; } GameObject val3 = new GameObject("ChaosSuite Web Aim Telegraph"); val3.transform.SetParent(((Component)this).transform, false); aimLine = val3.AddComponent<LineRenderer>(); aimLine.positionCount = 2; aimLine.useWorldSpace = true; aimLine.startWidth = 0.025f; aimLine.endWidth = 0.025f; aimLine.startColor = new Color(1f, 0.35f, 0.25f, 0.7f); aimLine.endColor = new Color(1f, 0.8f, 0.7f, 0.25f); ((Renderer)aimLine).enabled = false; if (Object.op_Implicit((Object)(object)webMaterial)) { ((Renderer)aimLine).material = webMaterial; } anchorKnot = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)anchorKnot).name = "ChaosSuite Web Anchor Knot"; anchorKnot.transform.localScale = Vector3.one * 0.22f; Collider component = anchorKnot.GetComponent<Collider>(); if (Object.op_Implicit((Object)(object)component)) { component.isTrigger = true; } anchorKnot.AddComponent<WebAnchorHitProxy>().Initialize(this); anchorKnot.SetActive(false); } private void UpdateLocalWebPresentation() { //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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: 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) LineRenderer val = webLine; GameObject val2 = anchorKnot; LineRenderer val3 = aimLine; if (val != null && Object.op_Implicit((Object)(object)val) && val2 != null && Object.op_Implicit((Object)(object)val2) && val3 != null && Object.op_Implicit((Object)(object)val3)) { PlayerControllerB val4 = FindPlayerByToken(victimId.Value); if (((Renderer)val3).enabled = val4 != null && Object.op_Implicit((Object)(object)val4) && Phase == WebheadPhase.Aiming && !IsSpiderEmployee) { val3.SetPosition(0, ((Component)this).transform.position + Vector3.up); val3.SetPosition(1, ((Component)val4).transform.position + Vector3.up); } bool flag2 = (((Renderer)val).enabled = val4 != null && Object.op_Implicit((Object)(object)val4) && VictimStage != WebStage.None); val2.SetActive(flag2); if (flag2) { val.startWidth = ((VictimStage == WebStage.Cocooned) ? 0.18f : ((VictimStage == WebStage.Wrapped) ? 0.1f : 0.055f)); val.endWidth = val.startWidth; val.SetPosition(0, victimAnchor.Value); val.SetPosition(1, ((Component)val4).transform.position + Vector3.up); val2.transform.position = victimAnchor.Value; RefreshVoiceMuffle(val4); } } } private void DestroyWebPresentation() { LineRenderer val = webLine; if (val != null && Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)((Component)val).gameObject); } LineRenderer val2 = aimLine; if (val2 != null && Object.op_Implicit((Object)(object)val2)) { Object.Destroy((Object)(object)((Component)val2).gameObject); } GameObject val3 = anchorKnot; if (val3 != null && Object.op_Implicit((Object)(object)val3)) { Object.Destroy((Object)(object)val3); } Material val4 = webMaterial; if (val4 != null && Object.op_Implicit((Object)(object)val4)) { Object.Destroy((Object)(object)val4); } RemoveVoiceMuffle(); webLine = null; aimLine = null; anchorKnot = null; webMaterial = null; } private void OnWebStageChanged(byte previous, byte current) { if (current != previous && current != 0) { ChaosPresentation.TriggerAction((Component)(object)this); } RefreshLocalRestriction(); if (current < 2) { RemoveVoiceMuffle(); } } private void OnVictimChanged(ulong previous, ulong current) { RefreshLocalRestriction(); if (current == 0L) { RemoveVoiceMuffle(); } } private void OnAnchorChanged(Vector3 previous, Vector3 current) { UpdateLocalWebPresentation(); } private void OnShotRevisionChanged(uint previous, uint current) { if (current != previous) { ChaosPresentation.TriggerAction((Component)(object)this); if (Object.op_Implicit((Object)(object)base.creatureVoice) && Object.op_Implicit((Object)(object)base.creatureVoice.clip)) { base.creatureVoice.PlayOneShot(base.creatureVoice.clip); } } } private void OnSpiderEmployeeChanged(bool previous, bool current) { RefreshMinionPresentation(); } private void RefreshMinionPresentation() { //IL_0027: 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_0020: Unknown result type (might be due to invalid IL or missing references) GameObject val = visualInstance; if (val != null && Object.op_Implicit((Object)(object)val)) { val.transform.localScale = (IsSpiderEmployee ? (Vector3.one * 0.72f) : Vector3.one); } } private void RefreshVoiceMuffle(PlayerControllerB target) { AudioSource currentVoiceChatAudioSource = target.currentVoiceChatAudioSource; if ((int)VictimStage < 2 || currentVoiceChatAudioSource == null || !Object.op_Implicit((Object)(object)currentVoiceChatAudioSource)) { RemoveVoiceMuffle(); return; } AudioLowPassFilter val = voiceMuffle; if (val == null || !Object.op_Implicit((Object)(object)val) || !((Object)(object)((Component)val).gameObject == (Object)(object)((Component)currentVoiceChatAudioSource).gameObject)) { RemoveVoiceMuffle(); voiceMuffle = ((Component)currentVoiceChatAudioSource).gameObject.AddComponent<AudioLowPassFilter>(); voiceMuffle.cutoffFrequency = 900f; voiceMuffle.lowpassResonanceQ = 1.1f; } } private void RemoveVoiceMuffle() { AudioLowPassFilter val = voiceMuffle; if (val != null && Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } voiceMuffle = null; } private static PlayerControllerB? FindPlayerByOwner(ulong ownerClientId) { PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return null; } for (int i = 0; i < array.Length; i++) { if (Object.op_Implicit((Object)(object)array[i]) && ((NetworkBehaviour)array[i]).OwnerClientId == ownerClientId) { return array[i]; } } return null; } private static PlayerControllerB? FindPlayerByToken(ulong token) { if (token == 0L) { return null; } PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts; if (array == null) { return null; } ulong num = token - 1; for (int i = 0; i < array.Length; i++) { if (Object.op_Implicit((Object)(object)array[i]) && array[i].playerClientId == num) { return array[i]; } } return null; } private static bool HasLineOfSight(Component source, PlayerControllerB target) { //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_0010: 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_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_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) Vector3 val = source.transform.position + Vector3.up; Vector3 val2 = ((Component)target).transform.position + Vector3.up; RaycastHit val3 = default(RaycastHit); if (Physics.Linecast(val, val2, ref val3, -1, (QueryTriggerInteraction)1)) { return (Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<PlayerControllerB>() == (Object)(object)target; } return true; } private static bool HasLineOfSight(Component source, Vector3 target) { //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_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_001f: 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_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_0027: 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_0039: 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) Vector3 val = source.transform.position + Vector3.up * 1.2f; Vector3 val2 = target - val; float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude <= 0.05f)) { return !Physics.Raycast(val, val2 / magnitude, magnitude, -1, (QueryTriggerInteraction)1); } return true; } private static bool RoundEnding() { if (Object.op_Implicit((Object)(object)StartOfRound.Instance) && !StartOfRound.Instance.shipIsLeaving) { return StartOfRound.Instance.inShipPhase; } return true; } 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 ((NetworkBehaviour)this).__registerRpc(3010056802u, new RpcReceiveHandler(__rpc_handler_3010056802), "RequestCutWebServerRpc"); ((NetworkBehaviour)this).__registerRpc(2277259762u, new RpcReceiveHandler(__rpc_handler_2277259762), "RequestAnchorHitServerRpc"); ((NetworkBehaviour)this).__registerRpc(1710922175u, new RpcReceiveHandler(__rpc_handler_1710922175), "TelegraphShotClientRpc"); ((NetworkBehaviour)this).__registerRpc(300530035u, new RpcReceiveHandler(__rpc_handler_300530035), "ApplyCocoonFatalOutcomeClientRpc"); ((NetworkBehaviour)this).__registerRpc(1584528627u, new RpcReceiveHandler(__rpc_handler_1584528627), "AcknowledgeCocoonFatalOutcomeServerRpc"); ((EnemyAI)this).__initializeRpcs(); } private static void __rpc_handler_3010056802(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_003d: 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_0043: 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_0060: 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) { ulong expectedVictimId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref expectedVictimId); uint expectedRevision = default(uint); ByteUnpacker.ReadValueBitPacked(reader, ref expectedRevision); ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((WebheadEnemyAI)(object)target).RequestCutWebServerRpc(expectedVictimId, expectedRevision, server); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_2277259762(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_003d: 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_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_005d: 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_0082: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { ulong claimedPlayer = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref claimedPlayer); uint sequence = default(uint); ByteUnpacker.ReadValueBitPacked(reader, ref sequence); ulong expectedVictimId = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref expectedVictimId); uint expectedRevision = default(uint); ByteUnpacker.ReadValueBitPacked(reader, ref expectedRevision); ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((WebheadEnemyAI)(object)target).RequestAnchorHitServerRpc(claimedPlayer, sequence, expectedVictimId, expectedRevision, server); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1710922175(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((WebheadEnemyAI)(object)target).TelegraphShotClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_300530035(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_003d: 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_0043: 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_0060: 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) { ulong targetClient = default(ulong); ByteUnpacker.ReadValueBitPacked(reader, ref targetClient); uint outcomeRevision = default(uint); ByteUnpacker.ReadValueBitPacked(reader, ref outcomeRevision); ClientRpcParams client = rpcParams.Client; target.__rpc_exec_stage = (__RpcExecStage)1; ((WebheadEnemyAI)(object)target).ApplyCocoonFatalOutcomeClientRpc(targetClient, outcomeRevision, client); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1584528627(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_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_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_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { uint outcomeRevision = default(uint); ByteUnpacker.ReadValueBitPacked(reader, ref outcomeRevision); ServerRpcParams server = rpcParams.Server; target.__rpc_exec_stage = (__RpcExecStage)1; ((WebheadEnemyAI)(object)target).AcknowledgeCocoonFatalOutcomeServerRpc(outcomeRevision, server); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "WebheadEnemyAI"; } } internal sealed class WebAnchorHitProxy : MonoBehaviour, IHittable { private WebheadEnemyAI? owner; internal void Initialize(WebheadEnemyAI webhead) { owner = webhead; } public bool Hit(int force, Vector3 hitDirection, PlayerControllerB? playerWhoHit, bool playHitSFX = false, int hitID = -1) { if (force <= 0 || (Object)(object)playerWhoHit == (Object)null || (Object)(object)owner == (Object)null || !Object.op_Implicit((Object)(object)owner)) { return false; } owner.HitAnchor(playerWhoHit); return true; } } } namespace System.Runtime.CompilerServices { internal static class IsExternalInit { } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<byte>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<byte>(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<Vector3>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<Vector3>(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<double>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<double>(); NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>(); } } } namespace ChaosSuite.Webhead.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }