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 Sigjak v0.1.12
BepInEx/plugins/AJ-Sigjak/Sigjak.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; 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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AJ.Sigjak { [BepInPlugin("aj.sigjak", "Sigjak", "0.1.12")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { internal static Plugin I; internal static GameObject Visual; internal static float Wander; internal static float Follow; internal static float Turn; internal static float Detection; internal static float Angle; internal static float GazeRange; internal static float Away; internal static float Fear; internal static float StopDistance; internal static float PullSpeed; internal static float PullRange; internal static float PullInputMultiplier; internal static bool PullEnabled; internal static int Weight; internal const string GazeChannel = "AJ.Sigjak.Gaze.2"; internal const string StateChannel = "AJ.Sigjak.State.5"; internal static readonly Dictionary<ulong, SigjakAI> Instances = new Dictionary<ulong, SigjakAI>(); private readonly NaturalSpawns natural = new NaturalSpawns(); private GameObject enemyPrefab; private NetworkManager manager; private AssetBundle bundle; private Harmony cameraPatch; private int settingsRevision; internal static bool SessionIsServer { get { NetworkManager singleton = NetworkManager.Singleton; return Object.op_Implicit((Object)(object)singleton) && singleton.IsListening && singleton.IsServer; } } internal static float VisualHeight => Visual.GetComponent<BoxCollider>().size.y; private float Setting(string group, string name, float value, float min, float max) { return Mathf.Clamp(((BaseUnityPlugin)this).Config.Bind<float>(group, name, value, (ConfigDescription)null).Value, min, max); } private float MovementSetting(string name, float value, float previous, float min, float max) { ConfigEntry<float> val = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", name, value, (ConfigDescription)null); float num = ((name == "WanderingSpeed") ? 0.35f : ((name == "FollowingSpeed") ? 0.45f : 70f)); if (settingsRevision < 4 && (Mathf.Approximately(val.Value, previous) || (settingsRevision < 2 && Mathf.Approximately(val.Value, num)))) { val.Value = value; } return Mathf.Clamp(val.Value, min, max); } private void Awake() { //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Expected O, but got Unknown I = this; ConfigEntry<int> val = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "FacilityWeight", 80, "Independent bonus-round chance weight against 100; zero disables natural spawns."); Weight = Mathf.Clamp(val.Value, 0, 1000); ConfigEntry<int> val2 = ((BaseUnityPlugin)this).Config.Bind<int>("Internal", "SettingsRevision", 0, (ConfigDescription)null); settingsRevision = val2.Value; if (settingsRevision < 7 && (Weight == 35 || (settingsRevision < 6 && Weight == 0))) { val.Value = 80; Weight = 80; } ConfigEntry<float> val3 = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "WanderingSpeed", 0.8f, (ConfigDescription)null); if (settingsRevision < 6 && Mathf.Approximately(val3.Value, 0.65f)) { val3.Value = 0.8f; } Wander = Mathf.Clamp(val3.Value, 0.01f, 3f); Follow = MovementSetting("FollowingSpeed", 0.9f, 0.7f, 0.01f, 3f); Turn = MovementSetting("RotationSpeed", 35f, 45f, 1f, 360f); StopDistance = Setting("Movement", "StoppingDistance", 2f, 0.5f, 8f); val2.Value = 7; Detection = Setting("Detection", "Distance", 18f, 1f, 80f); Angle = Setting("Gaze", "HalfAngleDegrees", 35f, 1f, 89f); GazeRange = Setting("Gaze", "Range", 25f, 1f, 80f); Away = Setting("Gaze", "LookAwaySeconds", 4f, 0.1f, 60f); ConfigEntry<float> val4 = ((BaseUnityPlugin)this).Config.Bind<float>("Gaze", "FearAfterSeconds", 2.5f, (ConfigDescription)null); if (settingsRevision < 5 && (Mathf.Approximately(val4.Value, 7f) || Mathf.Approximately(val4.Value, 4f))) { val4.Value = 2.5f; } Fear = Mathf.Clamp(val4.Value, 0.1f, 60f); PullEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("CameraPull", "Enabled", true, (ConfigDescription)null).Value; ConfigEntry<float> val5 = ((BaseUnityPlugin)this).Config.Bind<float>("CameraPull", "DegreesPerSecond", 90f, (ConfigDescription)null); if (settingsRevision < 7 && (Mathf.Approximately(val5.Value, 24f) || Mathf.Approximately(val5.Value, 32f) || Mathf.Approximately(val5.Value, 42f))) { val5.Value = 90f; } PullSpeed = Mathf.Clamp(val5.Value, 0f, 180f); PullInputMultiplier = Setting("CameraPull", "MouseControlMultiplier", 0.35f, 0.1f, 1f); ConfigEntry<float> val6 = ((BaseUnityPlugin)this).Config.Bind<float>("CameraPull", "Range", 18f, (ConfigDescription)null); if (settingsRevision < 6 && (Mathf.Approximately(val6.Value, 10f) || Mathf.Approximately(val6.Value, 25f) || (settingsRevision < 3 && Mathf.Approximately(val6.Value, 8f)))) { val6.Value = 18f; } PullRange = Mathf.Clamp(val6.Value, 1f, 80f); ((BaseUnityPlugin)this).Config.Save(); try { bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "sigjakassets")); if (!Object.op_Implicit((Object)(object)bundle)) { throw new Exception("Could not load sigjakassets"); } Visual = bundle.LoadAsset<GameObject>("SigjakVisual"); if (!Object.op_Implicit((Object)(object)Visual)) { throw new Exception("SigjakVisual missing"); } Register(); cameraPatch = new Harmony("aj.sigjak.camera"); cameraPatch.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)("SIGJAK_REGISTERED: Imperium display name Sigjak; natural weight=" + Weight + " follow=" + Follow + " turn=" + Turn + " stop=" + StopDistance + " cameraPull=" + PullEnabled)); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)ex); ((Behaviour)this).enabled = false; } } private void OnDestroy() { if (cameraPatch != null) { cameraPatch.UnpatchSelf(); } } private void Register() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00f2: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_0199: 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) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) GameObject val = NetworkPrefabs.CreateNetworkPrefab("AJ_SigjakEnemy"); ScanSetup.Add(val, VisualHeight); enemyPrefab = val; GameObject val2 = Object.Instantiate<GameObject>(Visual, val.transform); ((Object)val2).name = "Visual"; val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; SigjakAI sigjakAI = val.AddComponent<SigjakAI>(); NavMeshAgent val3 = val.AddComponent<NavMeshAgent>(); ((Behaviour)val3).enabled = false; val3.height = VisualHeight; val3.radius = 0.18f; val3.baseOffset = 0f; val3.speed = Wander; val3.acceleration = 1f; val3.angularSpeed = Turn; val3.updateRotation = false; ((EnemyAI)sigjakAI).agent = val3; GameObject val4 = new GameObject("Eye"); val4.transform.SetParent(val.transform, false); val4.transform.localPosition = Vector3.up * VisualHeight * 0.8f; ((EnemyAI)sigjakAI).eye = val4.transform; ((EnemyAI)sigjakAI).meshRenderers = val.GetComponentsInChildren<MeshRenderer>(); ((EnemyAI)sigjakAI).skinnedMeshRenderers = (SkinnedMeshRenderer[])(object)new SkinnedMeshRenderer[0]; ((EnemyAI)sigjakAI).enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[1] { new EnemyBehaviourState() }; GameObject val5 = new GameObject("EnemyCollision"); val5.transform.SetParent(val.transform, false); val5.layer = 19; CapsuleCollider val6 = val5.AddComponent<CapsuleCollider>(); val6.height = VisualHeight; val6.radius = 0.2f; val6.center = Vector3.up * VisualHeight / 2f; ((Collider)val6).isTrigger = true; val5.AddComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)sigjakAI; EnemyType val7 = ScriptableObject.CreateInstance<EnemyType>(); ((Object)val7).name = "Sigjak"; val7.enemyName = "Sigjak"; val7.enemyPrefab = val; val7.MaxCount = 6; val7.PowerLevel = 0f; val7.probabilityCurve = AnimationCurve.Constant(0f, 1f, 1f); ((EnemyAI)sigjakAI).enemyType = val7; Enemies.RegisterEnemy(val7, 0, (LevelTypes)(-1), (SpawnType)0, (TerminalNode)null, (TerminalKeyword)null); val7.PowerLevel = 0f; val7.spawningDisabled = true; ((Object)val7).hideFlags = (HideFlags)32; if (val.activeInHierarchy) { throw new Exception("Network template must be inactive"); } } private void Update() { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown NetworkManager singleton = NetworkManager.Singleton; if (!Object.op_Implicit((Object)(object)singleton) || !singleton.IsListening) { if (Object.op_Implicit((Object)(object)manager)) { manager.CustomMessagingManager.UnregisterNamedMessageHandler("AJ.Sigjak.Gaze.2"); manager.CustomMessagingManager.UnregisterNamedMessageHandler("AJ.Sigjak.State.5"); } manager = null; natural.Reset(); return; } natural.Tick(enemyPrefab); if (!((Object)(object)manager == (Object)(object)singleton)) { manager = singleton; singleton.CustomMessagingManager.RegisterNamedMessageHandler("AJ.Sigjak.Gaze.2", new HandleNamedMessageDelegate(ReceiveGaze)); singleton.CustomMessagingManager.RegisterNamedMessageHandler("AJ.Sigjak.State.5", new HandleNamedMessageDelegate(ReceiveState)); Log("SIGJAK_NETWORK_READY role=" + (singleton.IsServer ? "host" : "client") + " localClientId=" + singleton.LocalClientId + " version=0.1.12"); } } private void ReceiveGaze(ulong sender, FastBufferReader r) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0048: 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 (manager.IsServer) { ulong key = default(ulong); ((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref key, default(ForPrimitives)); int num = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref num, default(ForPrimitives)); bool value = default(bool); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref value, default(ForPrimitives)); if (Instances.TryGetValue(key, out var value2) && value2.TargetIndex == num && (Object)(object)value2.Target != (Object)null && value2.Target.actualClientId == sender) { value2.ReportGaze(value); } } } private void ReceiveState(ulong sender, FastBufferReader r) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00c1: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_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) if (sender == 0L && !manager.IsServer) { ulong key = default(ulong); ((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref key, default(ForPrimitives)); Vector3 p = default(Vector3); ((FastBufferReader)(ref r)).ReadValueSafe(ref p); Quaternion q = default(Quaternion); ((FastBufferReader)(ref r)).ReadValueSafe(ref q); int index = default(int); ((FastBufferReader)(ref r)).ReadValueSafe<int>(ref index, default(ForPrimitives)); bool move = default(bool); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref move, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<float>(ref Angle, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<float>(ref GazeRange, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<float>(ref Fear, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<bool>(ref PullEnabled, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<float>(ref PullSpeed, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<float>(ref PullRange, default(ForPrimitives)); ((FastBufferReader)(ref r)).ReadValueSafe<float>(ref PullInputMultiplier, default(ForPrimitives)); if (Instances.TryGetValue(key, out var value)) { value.Receive(p, q, index, move); } } } internal unsafe static void SendGaze(SigjakAI a, bool watched) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a3: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if (!Object.op_Implicit((Object)(object)singleton) || !singleton.IsListening || singleton.IsServer || !Object.op_Implicit((Object)(object)((NetworkBehaviour)a).NetworkObject) || !((NetworkBehaviour)a).NetworkObject.IsSpawned) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(32, (Allocator)2, -1); try { ulong networkObjectId = ((NetworkBehaviour)a).NetworkObjectId; ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref a.TargetIndex, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref watched, default(ForPrimitives)); singleton.CustomMessagingManager.SendNamedMessage("AJ.Sigjak.Gaze.2", 0uL, val, (NetworkDelivery)3); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } internal unsafe static void Broadcast(SigjakAI a, bool moving) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00c6: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if (!Object.op_Implicit((Object)(object)singleton) || !AuthorityRules.RunsHostAI(singleton.IsListening, singleton.IsServer, Object.op_Implicit((Object)(object)((NetworkBehaviour)a).NetworkObject) && ((NetworkBehaviour)a).NetworkObject.IsSpawned)) { return; } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, -1); try { ulong networkObjectId = ((NetworkBehaviour)a).NetworkObjectId; ((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref networkObjectId, default(ForPrimitives)); Vector3 position = ((Component)a).transform.position; ((FastBufferWriter)(ref val)).WriteValueSafe(ref position); Quaternion rotation = ((Component)a).transform.rotation; ((FastBufferWriter)(ref val)).WriteValueSafe(ref rotation); ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref a.TargetIndex, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref moving, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref Angle, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref GazeRange, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref Fear, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref PullEnabled, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref PullSpeed, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref PullRange, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref PullInputMultiplier, default(ForPrimitives)); foreach (ulong connectedClientsId in singleton.ConnectedClientsIds) { if (connectedClientsId != 0) { singleton.CustomMessagingManager.SendNamedMessage("AJ.Sigjak.State.5", connectedClientsId, val, (NetworkDelivery)1); } } } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } internal static void Log(string s) { ((BaseUnityPlugin)I).Logger.LogInfo((object)s); } } public sealed class SigjakAI : EnemyAI { internal int TargetIndex = -1; private readonly GazeTimers hostClock = new GazeTimers(); private readonly ExposureEffect exposure = new ExposureEffect(); private float lastGaze = -100f; private float gazeAt; private float sendAt; private float searchAt; private bool watched = true; private bool ready; private bool received; private bool moving; private Vector3 netPosition; private Quaternion netRotation; internal PlayerControllerB Target { get { StartOfRound instance = StartOfRound.Instance; return (Object.op_Implicit((Object)(object)instance) && TargetIndex >= 0 && TargetIndex < instance.allPlayerScripts.Length) ? instance.allPlayerScripts[TargetIndex] : null; } } private Vector3 Face => ((Component)this).transform.position + Vector3.up * Plugin.VisualHeight * 0.8f; internal Vector3 FacePosition => Face; public override void Awake() { if (Object.op_Implicit((Object)(object)RoundManager.Instance)) { base.thisEnemyIndex = RoundManager.Instance.numberOfEnemiesInScene; } } public override void Start() { InitializeSpawn(); } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); InitializeSpawn(); } private void InitializeSpawn() { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) if (ready || !Object.op_Implicit((Object)(object)((NetworkBehaviour)this).NetworkObject) || !((NetworkBehaviour)this).NetworkObject.IsSpawned || !Object.op_Implicit((Object)(object)NetworkManager.Singleton) || !NetworkManager.Singleton.IsListening) { return; } Plugin.Instances[((NetworkBehaviour)this).NetworkObjectId] = this; if (Plugin.SessionIsServer && NaturalSpawns.LiveCount() > 6) { Plugin.Log("SIGJAK_CAP_REJECTED: six already active"); ((NetworkBehaviour)this).NetworkObject.Despawn(true); return; } FixMaterials(); ready = true; netPosition = ((Component)this).transform.position; netRotation = ((Component)this).transform.rotation; if (!Object.op_Implicit((Object)(object)base.agent)) { base.agent = ((Component)this).GetComponent<NavMeshAgent>(); } if (!Plugin.SessionIsServer) { ((Behaviour)base.agent).enabled = false; Plugin.Log("SIGJAK_CLIENT_READY id=" + ((NetworkBehaviour)this).NetworkObjectId + " awaiting host snapshots"); return; } NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(((Component)this).transform.position, ref val, 1f, -1)) { Plugin.Log("SIGJAK_SPAWN_REJECTED: no nearby floor NavMesh"); ((NetworkBehaviour)this).NetworkObject.Despawn(true); return; } if (Object.op_Implicit((Object)(object)RoundManager.Instance) && !RoundManager.Instance.SpawnedEnemies.Contains((EnemyAI)(object)this)) { RoundManager.Instance.SpawnedEnemies.Add((EnemyAI)(object)this); } ((Component)this).transform.position = ((NavMeshHit)(ref val)).position; ((Behaviour)base.agent).enabled = true; base.agent.Warp(((NavMeshHit)(ref val)).position); base.agent.isStopped = true; Plugin.Log("SIGJAK_HOST_READY id=" + ((NetworkBehaviour)this).NetworkObjectId + " height=" + Plugin.VisualHeight + " navMesh=" + base.agent.isOnNavMesh); } public override void OnNetworkDespawn() { Plugin.Instances.Remove(((NetworkBehaviour)this).NetworkObjectId); if (Object.op_Implicit((Object)(object)RoundManager.Instance)) { RoundManager.Instance.SpawnedEnemies.Remove((EnemyAI)(object)this); } ready = false; ((NetworkBehaviour)this).OnNetworkDespawn(); } public override void DoAIInterval() { } public override void HitEnemy(int force, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1) { } public override void KillEnemy(bool destroy = false) { } private bool Valid(PlayerControllerB p) { return Object.op_Implicit((Object)(object)p) && p.isPlayerControlled && !p.isPlayerDead && p.isInsideFactory && Object.op_Implicit((Object)(object)p.gameplayCamera); } private bool Visible(PlayerControllerB p, float range) { //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_0033: 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) return Valid(p) && Vector3.Distance(((Component)p.gameplayCamera).transform.position, Face) <= range && !Physics.Linecast(((Component)p.gameplayCamera).transform.position, Face, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1); } private bool ExposureVisible(PlayerControllerB p) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (!Visible(p, Mathf.Min(Plugin.GazeRange, Plugin.PullRange))) { return false; } Vector3 val = p.gameplayCamera.WorldToViewportPoint(Face); return VisibilityRules.InView(val.x, val.y, val.z); } private bool Looking(PlayerControllerB p) { //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_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_003a: 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) int result; if (Visible(p, Plugin.GazeRange)) { Vector3 forward = ((Component)p.gameplayCamera).transform.forward; Vector3 val = Face - ((Component)p.gameplayCamera).transform.position; result = ((Vector3.Dot(forward, ((Vector3)(ref val)).normalized) >= Mathf.Cos(Plugin.Angle * ((float)Math.PI / 180f))) ? 1 : 0); } else { result = 0; } return (byte)result != 0; } internal bool CanPull(PlayerControllerB p) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) return PullGate.CanApply(ready && (Object)(object)Target == (Object)(object)p && Plugin.PullEnabled && Plugin.PullSpeed > 0f, exposure.Active, Looking(p), Vector3.Distance(((Component)p.gameplayCamera).transform.position, Face), Plugin.PullRange); } internal void ReportGaze(bool value) { watched = value && Visible(Target, Plugin.GazeRange); lastGaze = Time.time; } internal void Receive(Vector3 p, Quaternion q, int index, bool move) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_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) netPosition = p; netRotation = q; TargetIndex = index; moving = move; if (!received) { ((Component)this).transform.SetPositionAndRotation(p, q); received = true; } } public override void Update() { //IL_0192: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: 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_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_057c: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: Unknown result type (might be due to invalid IL or missing references) //IL_05ae: Unknown result type (might be due to invalid IL or missing references) //IL_05b3: Unknown result type (might be due to invalid IL or missing references) //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_0525: Expected O, but got Unknown //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Invalid comparison between Unknown and I4 //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) if (!ready) { InitializeSpawn(); } if (!ready || !Object.op_Implicit((Object)(object)StartOfRound.Instance) || !Object.op_Implicit((Object)(object)((NetworkBehaviour)this).NetworkObject) || !((NetworkBehaviour)this).NetworkObject.IsSpawned) { return; } PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; if (Valid(localPlayerController) && (Object)(object)Target == (Object)(object)localPlayerController) { bool flag = Looking(localPlayerController); bool clearLineOfSight = ExposureVisible(localPlayerController); if (exposure.Step(clearLineOfSight, Time.deltaTime, Plugin.Fear)) { localPlayerController.JumpToFearLevel(0.65f, true); } if (exposure.Active) { localPlayerController.IncreaseFearLevelOverTime(0.35f, 0.85f); } if (Plugin.SessionIsServer) { ReportGaze(flag); } else if (Time.time >= gazeAt || flag != watched) { Plugin.SendGaze(this, flag); gazeAt = Time.time + 0.05f; watched = flag; } } else { exposure.Reset(); } if (!Plugin.SessionIsServer) { if (((Behaviour)base.agent).enabled) { ((Behaviour)base.agent).enabled = false; } if (received) { ((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, netPosition, Mathf.Clamp01(Time.deltaTime * 20f)); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, netRotation, Mathf.Clamp01(Time.deltaTime * 20f)); } return; } StartOfRound instance = StartOfRound.Instance; if (instance.inShipPhase || instance.shipIsLeaving) { base.agent.isStopped = true; return; } if (!Valid(Target)) { TargetIndex = -1; hostClock.Reset(); watched = true; lastGaze = -100f; for (int i = 0; i < instance.allPlayerScripts.Length; i++) { if (Visible(instance.allPlayerScripts[i], Plugin.Detection)) { TargetIndex = i; break; } } } if (Valid(Target)) { Vector3 val = ((Component)Target).transform.position - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.001f) { ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, Quaternion.LookRotation(val), Plugin.Turn * Time.deltaTime); } bool flag2 = watched || Time.time - lastGaze > 0.35f; hostClock.Step(valid: true, flag2, Time.deltaTime, Plugin.Fear); moving = !flag2 && hostClock.Away >= Plugin.Away && FollowRange.ShouldMove(moving, ((Vector3)(ref val)).magnitude, Plugin.StopDistance); base.agent.stoppingDistance = Plugin.StopDistance; base.agent.isStopped = !moving; base.agent.speed = Plugin.Follow; if (!moving) { base.agent.velocity = Vector3.zero; } if (moving && Time.time >= searchAt) { searchAt = Time.time + 0.2f; NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(((Component)Target).transform.position, ref val2, 1f, -1)) { base.agent.SetDestination(((NavMeshHit)(ref val2)).position); } } } else { base.agent.stoppingDistance = 0.1f; base.agent.speed = Plugin.Wander; base.agent.isStopped = false; moving = true; if (Time.time >= searchAt && (!base.agent.hasPath || base.agent.remainingDistance < 0.3f)) { searchAt = Time.time + 2f; NavMeshHit val4 = default(NavMeshHit); for (int j = 0; j < 8; j++) { Vector3 val3 = ((Component)this).transform.position + Random.insideUnitSphere * 8f; if (NavMesh.SamplePosition(val3, ref val4, 2f, -1)) { NavMeshPath val5 = new NavMeshPath(); if (base.agent.CalculatePath(((NavMeshHit)(ref val4)).position, val5) && (int)val5.status == 0) { base.agent.SetPath(val5); break; } } } } Vector3 velocity = base.agent.velocity; if (((Vector3)(ref velocity)).sqrMagnitude > 0.001f) { ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, Quaternion.LookRotation(base.agent.velocity), Plugin.Turn * Time.deltaTime); } } if (Time.time >= sendAt) { sendAt = Time.time + 0.05f; Plugin.Broadcast(this, moving); } } private void FixMaterials() { //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //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_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) Material val = null; Material[] array = Resources.FindObjectsOfTypeAll<Material>(); foreach (Material val2 in array) { if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.shader) && ((Object)val2.shader).name == "HDRP/Lit" && val2.shader.isSupported && !((Object)val2).name.StartsWith("Sigjak_")) { val = val2; break; } } Dictionary<Material, Material> dictionary = new Dictionary<Material, Material>(); Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(); foreach (Renderer val3 in componentsInChildren) { Material[] sharedMaterials = val3.sharedMaterials; for (int k = 0; k < sharedMaterials.Length; k++) { Material val4 = sharedMaterials[k]; if (!Object.op_Implicit((Object)(object)val4)) { continue; } if (!dictionary.TryGetValue(val4, out var value)) { value = new Material(Object.op_Implicit((Object)(object)val) ? val.shader : val4.shader); ((Object)value).name = "Sigjak_" + ((Object)val4).name; Texture texture = val4.GetTexture("_BaseColorMap"); Color color = val4.GetColor("_BaseColor"); string[] array2 = new string[3] { "_NormalMap", "_MaskMap", "_EmissiveColorMap" }; foreach (string text in array2) { if (value.HasProperty(text)) { value.SetTexture(text, (Texture)null); } } value.SetColor("_BaseColor", color); value.SetTexture("_BaseColorMap", texture); value.SetFloat("_SurfaceType", 0f); value.DisableKeyword("_SURFACE_TYPE_TRANSPARENT"); value.SetFloat("_AlphaCutoffEnable", 0f); value.DisableKeyword("_ALPHATEST_ON"); value.SetFloat("_Metallic", 0f); value.SetFloat("_Smoothness", 0f); value.SetColor("_EmissiveColor", Color.black); value.DisableKeyword("_EMISSIVE_COLOR_MAP"); value.DisableKeyword("_NORMALMAP_TANGENT_SPACE"); value.DisableKeyword("_MASKMAP"); value.SetFloat("_UVBase", 0f); value.SetVector("_UVMappingMask", new Vector4(1f, 0f, 0f, 0f)); value.DisableKeyword("_MAPPING_PLANAR"); value.DisableKeyword("_MAPPING_TRIPLANAR"); value.SetTextureScale("_BaseColorMap", Vector2.one); value.SetTextureOffset("_BaseColorMap", Vector2.zero); value.renderQueue = 2000; MatteMaterial.Apply(value); if (!Object.op_Implicit((Object)(object)value.shader) || !value.shader.isSupported) { Plugin.Log("SIGJAK_SHADER_ERROR: " + ((Object)val4).name); } dictionary.Add(val4, value); } sharedMaterials[k] = value; } val3.sharedMaterials = sharedMaterials; } } } public sealed class GazeTimers { public float Away { get; private set; } public float Stare { get; private set; } public bool FearFired { get; private set; } public void Reset() { Away = 0f; Stare = 0f; FearFired = false; } public bool Step(bool valid, bool watched, float dt, float fearDelay) { if (!valid) { Reset(); return false; } dt = Math.Max(0f, dt); if (!watched) { Stare = 0f; FearFired = false; Away += dt; return false; } Away = 0f; Stare += dt; if (!FearFired && Stare >= fearDelay) { FearFired = true; return true; } return false; } } public static class FollowRange { public static bool ShouldMove(bool moving, float distance, float stop) { return distance > (moving ? stop : (stop + 0.15f)); } } public static class PullMath { public static float Step(float degrees, float speed, float dt) { float num = Math.Max(0f, speed) * Math.Min(0.05f, Math.Max(0f, dt)); return Math.Max(0f - num, Math.Min(num, degrees)); } } public static class PullGate { public static bool CanApply(bool eligibleTarget, bool fearActive, bool hasLineOfSight, float distance, float range) { return eligibleTarget && fearActive && hasLineOfSight && distance <= range; } } [HarmonyPatch] internal static class CameraPull { private static int lastFrame = -1; private static IEnumerable<MethodBase> TargetMethods() { string[] array = new string[2] { "CalculateNormalLookingInput", "CalculateSmoothLookingInput" }; foreach (string name in array) { MethodInfo m = AccessTools.Method(typeof(PlayerControllerB), name, (Type[])null, (Type[])null); if (m == null) { throw new MissingMethodException(name); } yield return m; } } [HarmonyPrefix] private static void Prefix(PlayerControllerB __instance, ref Vector2 __0) { //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: 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_0101: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if (!Plugin.PullEnabled || lastFrame == Time.frameCount || !Application.isFocused || !Object.op_Implicit((Object)(object)instance) || instance.inShipPhase || instance.shipIsLeaving || (Object)(object)instance.localPlayerController != (Object)(object)__instance || !__instance.isPlayerControlled || __instance.isPlayerDead || !__instance.isInsideFactory || !Object.op_Implicit((Object)(object)__instance.gameplayCamera) || __instance.disableLookInput || __instance.isClimbingLadder || __instance.inSpecialInteractAnimation || __instance.jetpackControls || __instance.inVehicleAnimation) { return; } SigjakAI sigjakAI = null; float num = float.PositiveInfinity; foreach (SigjakAI value in Plugin.Instances.Values) { if (Object.op_Implicit((Object)(object)value) && value.CanPull(__instance)) { Vector3 val = value.FacePosition - ((Component)__instance.gameplayCamera).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; sigjakAI = value; } } } if (Object.op_Implicit((Object)(object)sigjakAI)) { Transform transform = ((Component)__instance.gameplayCamera).transform; Vector3 val2 = sigjakAI.FacePosition - transform.position; Quaternion val3 = Quaternion.LookRotation(val2); Vector3 eulerAngles = ((Quaternion)(ref val3)).eulerAngles; float y = transform.eulerAngles.y; float num2 = Mathf.DeltaAngle(0f, transform.eulerAngles.x); __0 *= Plugin.PullInputMultiplier; Vector3 val4 = Quaternion.Euler(num2 - __0.y, y + __0.x, 0f) * Vector3.forward; if (!(Vector3.Dot(val4, ((Vector3)(ref val2)).normalized) < Mathf.Cos(Plugin.Angle * ((float)Math.PI / 180f)))) { float num3 = PullMath.Step(Mathf.DeltaAngle(y, eulerAngles.y), Plugin.PullSpeed, Time.deltaTime); float num4 = PullMath.Step(Mathf.DeltaAngle(num2, Mathf.DeltaAngle(0f, eulerAngles.x)), Plugin.PullSpeed, Time.deltaTime); __0 += new Vector2(num3, 0f - num4); lastFrame = Time.frameCount; } } } } public static class AuthorityRules { public static bool RunsHostAI(bool listening, bool server, bool spawned) { return listening && server && spawned; } } public sealed class ExposureEffect { private float elapsed; public bool Active { get; private set; } public bool Pulling { get; private set; } public void Reset() { elapsed = 0f; Active = false; Pulling = false; } public bool Step(bool clearLineOfSight, float dt, float delay) { if (!clearLineOfSight) { Reset(); return false; } bool active = Active; elapsed += Math.Max(0f, dt); Active = elapsed >= delay; Pulling = Active; return Active && !active; } } public static class SpawnPlan { public const int Cap = 6; public static int GroupSize(int roll) { if (roll < 120) { return 1; } if (roll < 170) { return 2; } if (roll < 190) { return 3; } if (roll < 196) { return 4; } if (roll < 199) { return 5; } return 6; } public static float Delay(Random random) { return 60f + (float)random.NextDouble() * 60f; } } internal sealed class NaturalSpawns { private bool planned; private int remaining; private float next; private Random random; internal void Reset() { planned = false; remaining = 0; next = 0f; random = null; } internal static int LiveCount() { int num = 0; foreach (SigjakAI value in Plugin.Instances.Values) { if (Object.op_Implicit((Object)(object)value) && Object.op_Implicit((Object)(object)((NetworkBehaviour)value).NetworkObject) && ((NetworkBehaviour)value).NetworkObject.IsSpawned) { num++; } } return num; } internal void Tick(GameObject prefab) { //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; RoundManager instance2 = RoundManager.Instance; if (!Plugin.SessionIsServer) { return; } if (!Object.op_Implicit((Object)(object)instance) || instance.inShipPhase || instance.shipIsLeaving) { Reset(); { foreach (SigjakAI item in new List<SigjakAI>(Plugin.Instances.Values)) { if (Object.op_Implicit((Object)(object)item) && Object.op_Implicit((Object)(object)((NetworkBehaviour)item).NetworkObject) && ((NetworkBehaviour)item).NetworkObject.IsSpawned) { ((NetworkBehaviour)item).NetworkObject.Despawn(true); } } return; } } if (!instance.shipHasLanded || !Object.op_Implicit((Object)(object)instance2) || instance2.allEnemyVents == null || instance2.allEnemyVents.Length == 0) { return; } if (!planned) { planned = true; random = new Random(instance.randomMapSeed ^ 0x519A7); if (Plugin.Weight <= 0 || random.NextDouble() >= (double)Plugin.Weight / (100.0 + (double)Plugin.Weight)) { Plugin.Log("SIGJAK_NATURAL_PLAN: none this round"); return; } remaining = SpawnPlan.GroupSize(random.Next(200)); next = Time.time + 45f + (float)random.NextDouble() * 45f; Plugin.Log("SIGJAK_NATURAL_PLAN: total=" + remaining + " first spawn in=" + (next - Time.time)); } if (remaining <= 0 || Time.time < next) { return; } if (LiveCount() >= 6) { next = Time.time + 15f; return; } NavMeshHit val2 = default(NavMeshHit); for (int i = 0; i < instance2.allEnemyVents.Length; i++) { EnemyVent val = instance2.allEnemyVents[random.Next(instance2.allEnemyVents.Length)]; if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.floorNode) || !NavMesh.SamplePosition(val.floorNode.position, ref val2, 1f, -1)) { continue; } bool flag = true; PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val3 in allPlayerScripts) { if (Object.op_Implicit((Object)(object)val3) && val3.isPlayerControlled && !val3.isPlayerDead && val3.isInsideFactory) { if (Vector3.Distance(((Component)val3).transform.position, ((NavMeshHit)(ref val2)).position) < 6f) { flag = false; break; } if (Object.op_Implicit((Object)(object)val3.gameplayCamera) && Vector3.Distance(((Component)val3).transform.position, ((NavMeshHit)(ref val2)).position) < 30f && !Physics.Linecast(((Component)val3.gameplayCamera).transform.position, ((NavMeshHit)(ref val2)).position + Vector3.up * 0.5f, instance.collidersAndRoomMask, (QueryTriggerInteraction)1)) { flag = false; break; } } } if (flag) { GameObject val4 = Object.Instantiate<GameObject>(prefab, ((NavMeshHit)(ref val2)).position, Quaternion.Euler(0f, (float)random.Next(360), 0f)); val4.SetActive(true); val4.GetComponent<NetworkObject>().Spawn(true); remaining--; next = Time.time + SpawnPlan.Delay(random); Plugin.Log("SIGJAK_NATURAL_SPAWN: remaining=" + remaining + " next delay=" + (next - Time.time)); return; } } next = Time.time + 15f; } } internal static class ScanSetup { internal static void Add(GameObject root, float height) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_002e: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SigjakScanNode"); val.transform.SetParent(root.transform, false); val.layer = 22; val.transform.localPosition = Vector3.up * height * 0.7f; BoxCollider val2 = val.AddComponent<BoxCollider>(); val2.size = new Vector3(0.45f, height * 0.6f, 0.35f); ((Collider)val2).isTrigger = false; ScanNodeProperties val3 = val.AddComponent<ScanNodeProperties>(); val3.headerText = "Sigjak"; val3.subText = ""; val3.nodeType = 1; val3.creatureScanID = -1; val3.minRange = 0; val3.maxRange = 20; val3.requiresLineOfSight = true; val3.scrapValue = 0; } } public static class VisibilityRules { public static bool InView(float x, float y, float depth) { return depth > 0f && x >= 0f && x <= 1f && y >= 0f && y <= 1f; } } internal static class MatteMaterial { internal static void Apply(Material m) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) string[] array = new string[6] { "_Metallic", "_Smoothness", "_SmoothnessRemapMin", "_SmoothnessRemapMax", "_CoatMask", "_Anisotropy" }; foreach (string text in array) { if (m.HasProperty(text)) { m.SetFloat(text, 0f); } } if (m.HasProperty("_MaterialID")) { m.SetFloat("_MaterialID", 4f); } if (m.HasProperty("_SpecularColor")) { m.SetColor("_SpecularColor", Color.black); } if (m.HasProperty("_SpecularColorMap")) { m.SetTexture("_SpecularColorMap", (Texture)null); } if (m.HasProperty("_EnergyConservingSpecularColor")) { m.SetFloat("_EnergyConservingSpecularColor", 0f); } if (m.HasProperty("_CoatMaskMap")) { m.SetTexture("_CoatMaskMap", (Texture)null); } string[] array2 = new string[6] { "_MATERIAL_FEATURE_CLEAR_COAT", "_MATERIAL_FEATURE_ANISOTROPY", "_MATERIAL_FEATURE_IRIDESCENCE", "_MATERIAL_FEATURE_SPECULAR_COLOR", "_MATERIAL_FEATURE_SUBSURFACE_SCATTERING", "_MATERIAL_FEATURE_TRANSMISSION" }; foreach (string text2 in array2) { m.DisableKeyword(text2); } m.DisableKeyword("_SPECULARCOLORMAP"); m.EnableKeyword("_MATERIAL_FEATURE_SPECULAR_COLOR"); m.EnableKeyword("_DISABLE_SSR"); } } }