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 ReworkedEnhancementsForAll v1.0.0
TazgmondScripts.dll
Decompiled 8 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using LethalLevelLoader; using SceneReplacer; using TazgmondScripts; using TazgmondScripts.NetcodePatcher; 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: AssemblyVersion("0.0.0.0")] [module: NetcodePatchedAssembly] namespace SceneReplacer { internal static class ReplacementApplier { private static readonly List<SceneReplacerAsset> Assets = new List<SceneReplacerAsset>(); private static bool assetsFound; internal static void FindAssets() { assetsFound = true; Assets.Clear(); SceneReplacerAsset[] array = Resources.FindObjectsOfTypeAll<SceneReplacerAsset>(); for (int i = 0; i < array.Length; i++) { AddAsset(array[i]); } foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if ((Object)(object)allLoadedAssetBundle == (Object)null || allLoadedAssetBundle.isStreamedSceneAssetBundle) { continue; } try { array = allLoadedAssetBundle.LoadAllAssets<SceneReplacerAsset>(); for (int i = 0; i < array.Length; i++) { AddAsset(array[i]); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not search bundle '" + ((Object)allLoadedAssetBundle).name + "': " + ex.Message)); } } Plugin.Log.LogInfo((object)("Found " + Assets.Count + " Scene Replacer asset(s).")); } private static void AddAsset(SceneReplacerAsset asset) { if ((Object)(object)asset != (Object)null && !Assets.Contains(asset)) { Assets.Add(asset); } } internal static void Apply() { if (!assetsFound) { FindAssets(); } Dictionary<string, string> dictionary = BuildSwapTable(); if (dictionary.Count == 0) { return; } HashSet<string> hashSet = new HashSet<string>(); foreach (ExtendedLevel extendedLevel in PatchedContent.ExtendedLevels) { if ((Object)(object)extendedLevel == (Object)null || (Object)(object)extendedLevel.SelectableLevel == (Object)null) { continue; } foreach (StringWithRarity sceneSelection in extendedLevel.SceneSelections) { if (sceneSelection != null && dictionary.TryGetValue(sceneSelection.Name, out var value)) { Plugin.Log.LogInfo((object)(extendedLevel.SelectableLevel.PlanetName + ": " + sceneSelection.Name + " -> " + value)); hashSet.Add(sceneSelection.Name); sceneSelection.Name = value; } } SelectableLevel selectableLevel = extendedLevel.SelectableLevel; if (selectableLevel.sceneName != null && dictionary.TryGetValue(selectableLevel.sceneName, out var value2)) { hashSet.Add(selectableLevel.sceneName); selectableLevel.sceneName = value2; } } foreach (string key in dictionary.Keys) { if (!hashSet.Contains(key)) { Plugin.Log.LogWarning((object)("No moon uses the scene '" + key + "', so nothing was replaced for it. Check the spelling (vanilla Assurance is 'Level2Assurance').")); } } } private static Dictionary<string, string> BuildSwapTable() { Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (SceneReplacerAsset asset in Assets) { if (asset.replacements == null) { continue; } foreach (SceneReplacement replacement in asset.replacements) { if (replacement == null || !replacement.enabled) { continue; } string text = replacement.originalSceneName?.Trim(); string text2 = replacement.replacementSceneName?.Trim(); string text3 = " (in '" + ((Object)asset).name + "')"; if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text2)) { Plugin.Log.LogWarning((object)("Skipping an entry with an empty scene name" + text3 + ".")); } else if (!(text == text2)) { string value; if (!PatchedContent.AllLevelSceneNames.Contains(text2)) { Plugin.Log.LogError((object)("Not replacing '" + text + "': scene '" + text2 + "' isn't in any loaded .lethalbundle" + text3 + ". The original scene will load instead.")); } else if (dictionary.TryGetValue(text, out value)) { Plugin.Log.LogWarning((object)("'" + text + "' is already being replaced with '" + value + "'; ignoring '" + text2 + "'" + text3 + ".")); } else { dictionary.Add(text, text2); } } } } return dictionary; } } [CreateAssetMenu(fileName = "New Scene Replacer", menuName = "Tonys Moons/Scene Replacer")] public class SceneReplacerAsset : ScriptableObject { public List<SceneReplacement> replacements = new List<SceneReplacement>(); private void OnValidate() { if (replacements == null) { return; } foreach (SceneReplacement replacement in replacements) { replacement?.TakeDroppedScenes((Object)(object)this); } } } [Serializable] public class SceneReplacement { [Tooltip("Untick to switch this replacement off without deleting it.")] public bool enabled = true; [Header("Scene to replace")] [Tooltip("Drag the scene you want to get rid of here, e.g. Level2Assurance from Assets/LethalCompany/Game/Scenes. Its name is copied into the field below.")] public Object dropOriginalSceneHere; [Tooltip("The scene that gets replaced. Filled in when you drop a scene above, or type it by hand.")] public string originalSceneName; [Header("Your scene")] [Tooltip("Drag your own scene here. It must be inside one of your scene .lethalbundles.")] public Object dropReplacementSceneHere; [Tooltip("The scene that loads instead. Filled in when you drop a scene above, or type it by hand.")] public string replacementSceneName; internal void TakeDroppedScenes(Object owner) { originalSceneName = TakeSceneName(ref dropOriginalSceneHere, originalSceneName, owner); replacementSceneName = TakeSceneName(ref dropReplacementSceneHere, replacementSceneName, owner); } private static string TakeSceneName(ref Object slot, string current, Object owner) { if (slot == (Object)null) { return current; } object obj = ((((object)slot).GetType().Name == "SceneAsset") ? slot.name : null); if (obj == null) { Debug.LogWarning((object)("[SceneReplacer] '" + slot.name + "' is not a scene - drop a .unity scene file."), owner); } slot = null; if (obj == null) { obj = current; } return (string)obj; } } } namespace TazgmondScripts { [AddComponentMenu("Tazgmond/Marching Birds")] [DisallowMultipleComponent] public class MarchingBirds : NetworkBehaviour { private class FallVisual { internal Transform Model; internal Quaternion RestRotation; internal Vector3 RestPosition; internal float TargetTilt; internal float CurrentTilt; } private struct PendingClientAction { internal NetworkObjectReference Target; internal bool IsFall; internal Vector3 Scale; internal bool Fallen; internal float Tilt; internal float AnimationSpeed; internal float GiveUpTime; } private enum SquadMode { Hatching, FormingUp, Marching, Flying, Alert, Rampage } [Header("Squad")] [Tooltip("How many Old Birds this one spawns. One of them becomes the giant leader that everyone (this bird included) follows.")] [Min(0f)] public int birdsToSpawn = 6; [Tooltip("enemyName of the Old Bird type the squad is made of. RadMech is the normal vanilla Old Bird. Each one hatches out of that type's own nest object (RadMechNestSpawnObject for vanilla), the same way Old Birds spawn normally. Must be an Old Bird (RadMechAI) type.")] public string birdEnemyName = "RadMech"; [Header("Leader Size")] [Tooltip("On: the leader's size is rolled between Min and Max Leader Size every time. Off: the leader is always exactly Leader Size.")] public bool randomLeaderSize = true; [Tooltip("Smallest the leader can roll, when Random Leader Size is on. 1 = a normal Old Bird.")] [Min(0.1f)] public float minLeaderSize = 1.5f; [Tooltip("Biggest the leader can roll, when Random Leader Size is on.")] [Min(0.1f)] public float maxLeaderSize = 2f; [Tooltip("The leader's size when Random Leader Size is off.")] [Min(0.1f)] public float leaderSize = 1.75f; [Header("Spawn Template (triangle of nests)")] [Tooltip("Distance between the nests in the spawn triangle. This bird is the tip; the nests fan out behind it.")] [Min(2f)] public float triangleSpacing = 10f; [Tooltip("Seconds the dormant nests sit in their triangle before the birds start hatching out of them.")] [Min(0f)] public float nestHoldTime = 3f; [Tooltip("Seconds between one bird hatching and the next.")] [Min(0.3f)] public float timeBetweenHatches = 0.6f; [Tooltip("Longest the walk from the triangle into the cube may take. Marching starts after this even if someone is still out of place.")] [Min(1f)] public float maxFormUpTime = 30f; [Header("Cube Formation")] [Tooltip("Distance between birds in the cube formation. The leader walks in front of the block.")] [Min(2f)] public float formationSpacing = 9f; [Tooltip("Degrees per second the formation swings round when the leader turns. Lower = wider, smoother turns.")] [Min(1f)] public float formationTurnSpeed = 40f; [Tooltip("The leader's walking speed compared to a normal Old Bird, so the block can keep up with it.")] [Range(0.2f, 1f)] public float leaderPace = 0.8f; [Tooltip("Walking speed multiplier for a bird that has fallen out of its place in the block.")] [Min(1f)] public float catchUpSpeed = 1.5f; [Header("Marching Around The Map")] [Tooltip("The leader only picks map spots at least this far away to march to.")] [Min(5f)] public float minWaypointDistance = 40f; [Tooltip("If the leader hasn't reached its spot after this many seconds, it picks another one.")] [Min(5f)] public float waypointTimeout = 60f; [Header("Group Flights")] [Tooltip("Off: the squad only ever walks.")] public bool groupFlights = true; [Min(5f)] public float minTimeBetweenFlights = 45f; [Min(5f)] public float maxTimeBetweenFlights = 90f; [Tooltip("The squad only flies to spots at least this far away.")] [Min(10f)] public float minFlightDistance = 60f; [Header("Shared Sight")] [Tooltip("On: every bird told about the player also goes straight to alerted (sirens, spotlight, shoots the moment it has a clear shot). Off: they head for the player but alert at the normal pace.")] public bool alertWholeSquad = true; [Tooltip("Seconds with no bird in the squad seeing the player before they give up and go on a rampage.")] [Min(0.5f)] public float loseSightTime = 4f; [Header("Rampage")] [Tooltip("How long the rampage lasts before the squad regroups into the cube.")] [Min(1f)] public float rampageDuration = 20f; [Tooltip("How far each bird marches in its own direction before turning a little and carrying on.")] [Min(5f)] public float rampageWalkDistance = 45f; [Min(0.1f)] public float minTimeBetweenRockets = 0.6f; [Min(0.1f)] public float maxTimeBetweenRockets = 2f; [Tooltip("How far left/right of where it's facing a rampage rocket can go, in degrees each side. 180 = any direction.")] [Range(0f, 180f)] public float rocketAimSpread = 50f; [Tooltip("Rockets are aimed this many degrees below level, at least. Negative aims upwards.")] [Range(-30f, 80f)] public float minRocketDownAngle = 5f; [Tooltip("...and at most this many degrees below level.")] [Range(-30f, 80f)] public float maxRocketDownAngle = 25f; [Header("Rare Malfunction (falls over)")] [Tooltip("Chance per bird, per minute of marching, that it falls over.")] [Range(0f, 100f)] public float fallChancePerMinute = 1f; [Tooltip("Chance per bird, per group flight, that it drops out of the sky and falls over where it lands.")] [Range(0f, 100f)] public float fallChancePerFlight = 3f; [Tooltip("How fast the walk animation plays while fallen. 10 = ten times speed.")] [Min(1f)] public float walkAnimationSpeed = 10f; [Min(0.5f)] public float minFallTime = 5f; [Min(0.5f)] public float maxFallTime = 8f; [Tooltip("How far it tips onto its side, in degrees. 0 = it stays upright and just runs on the spot.")] [Range(0f, 90f)] public float fallTiltAngle = 80f; [Tooltip("Lifts the model while it lies on its side so it doesn't sink into the ground. Raise it if a fallen bird clips into the floor, lower it if it floats.")] public float fallenHeightOffset = 1.2f; [Tooltip("On: a fallen bird keeps walking (and catching up) while its legs go 10x. Off: it lies still.")] public bool keepWalkingWhileFallen; internal bool spawnedBySquad; private const float FallOverSpeed = 260f; private const float GetUpSpeed = 110f; private const float PendingActionTimeout = 10f; private readonly Dictionary<RadMechAI, FallVisual> fallVisuals = new Dictionary<RadMechAI, FallVisual>(); private readonly List<RadMechAI> fallVisualsToRemove = new List<RadMechAI>(); private readonly HashSet<RadMechAI> spedUpBirds = new HashSet<RadMechAI>(); private readonly List<PendingClientAction> pendingClientActions = new List<PendingClientAction>(); private const float TickInterval = 0.2f; private const float VanillaRoamStepGap = 0.7f; private const int LandingAreaMask = -353; private const float NestQueueSyncDelay = 0.4f; private readonly List<SquadBird> birds = new List<SquadBird>(); private readonly List<NetworkObject> squadNests = new List<NetworkObject>(); private SquadBird self; private SquadBird leader; private SquadBird giant; private float giantSize = 1f; private bool slotsDirty = true; private SquadMode mode; private float modeStartTime; private float nextTickTime; private float nextErrorLogTime; private float formationYaw; private Vector3 formUpAnchor; private bool hasWaypoint; private Vector3 waypoint; private float waypointDeadline; private float nextFlightTime; private float flightYaw; private bool flightDivedOnPlayer; private IVisibleThreat sharedThreat; private Vector3 sharedThreatPosition; private float lastSquadSightTime; private float rampageEndTime; private float LeaderSize { get { if (leader == null || leader != giant) { return 1f; } return giantSize; } } private void Start() { if ((Object)(object)((Component)this).GetComponent<RadMechAI>() == (Object)null) { Debug.LogError((object)("[MarchingBirds] '" + ((Object)((Component)this).gameObject).name + "' has no RadMechAI on the same GameObject - Marching Birds only works on an Old Bird."), (Object)(object)this); } else if (((NetworkBehaviour)this).IsServer && !spawnedBySquad) { ((MonoBehaviour)this).StartCoroutine(RunSquad()); } } private void Update() { ProcessPendingClientActions(); UpdateSquad(); } private void LateUpdate() { UpdateFallVisuals(); } public override void OnDestroy() { ReleaseSquad(); RestoreAllFallVisuals(); ((NetworkBehaviour)this).OnDestroy(); } [ClientRpc] private void SetObjectScaleClientRpc(NetworkObjectReference target, Vector3 scale) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1774542163u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(ref target, default(ForNetworkSerializable)); ((FastBufferWriter)(ref val)).WriteValueSafe(ref scale); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1774542163u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; RunOrQueue(new PendingClientAction { Target = target, Scale = scale, GiveUpTime = Time.time + 10f }); } } } [ClientRpc] private void SetBirdFallenClientRpc(NetworkObjectReference bird, bool fallen, float tilt, float animationSpeed) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val2 = default(ClientRpcParams); FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1646750089u, val2, (RpcDelivery)0); ((FastBufferWriter)(ref val)).WriteValueSafe<NetworkObjectReference>(ref bird, default(ForNetworkSerializable)); ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref fallen, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref tilt, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref animationSpeed, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1646750089u, val2, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost)) { base.__rpc_exec_stage = (__RpcExecStage)0; RunOrQueue(new PendingClientAction { Target = bird, IsFall = true, Fallen = fallen, Tilt = tilt, AnimationSpeed = animationSpeed, GiveUpTime = Time.time + 10f }); } } } private void RunOrQueue(PendingClientAction action) { if (!TryRun(action)) { pendingClientActions.Add(action); } } private bool TryRun(PendingClientAction action) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) NetworkObject val = default(NetworkObject); if (!((NetworkObjectReference)(ref action.Target)).TryGet(ref val, (NetworkManager)null) || (Object)(object)val == (Object)null) { return false; } if (!action.IsFall) { ((Component)val).transform.localScale = action.Scale; return true; } RadMechAI component = ((Component)val).GetComponent<RadMechAI>(); if ((Object)(object)component != (Object)null) { ApplyFall(component, action.Fallen, action.Tilt, action.AnimationSpeed); } return true; } private void ProcessPendingClientActions() { for (int num = pendingClientActions.Count - 1; num >= 0; num--) { PendingClientAction action = pendingClientActions[num]; if (TryRun(action) || Time.time > action.GiveUpTime) { pendingClientActions.RemoveAt(num); } } } private void ApplyFall(RadMechAI ai, bool fallen, float tilt, float animationSpeed) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) Animator creatureAnimator = ((EnemyAI)ai).creatureAnimator; if ((Object)(object)creatureAnimator == (Object)null) { return; } creatureAnimator.speed = (fallen ? animationSpeed : 1f); if (fallen) { spedUpBirds.Add(ai); } else { spedUpBirds.Remove(ai); } if (!fallVisuals.TryGetValue(ai, out var value)) { if (!fallen || Mathf.Approximately(tilt, 0f)) { return; } Transform transform = ((Component)creatureAnimator).transform; value = new FallVisual { Model = transform, RestRotation = transform.localRotation, RestPosition = transform.localPosition }; fallVisuals.Add(ai, value); } value.TargetTilt = (fallen ? tilt : 0f); } private void UpdateFallVisuals() { //IL_00af: 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_00c9: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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) if (fallVisuals.Count == 0) { return; } foreach (KeyValuePair<RadMechAI, FallVisual> fallVisual in fallVisuals) { FallVisual value = fallVisual.Value; if ((Object)(object)fallVisual.Key == (Object)null || (Object)(object)value.Model == (Object)null) { fallVisualsToRemove.Add(fallVisual.Key); continue; } bool flag = Mathf.Abs(value.TargetTilt) > Mathf.Abs(value.CurrentTilt); value.CurrentTilt = Mathf.MoveTowards(value.CurrentTilt, value.TargetTilt, (flag ? 260f : 110f) * Time.deltaTime); value.Model.localRotation = value.RestRotation * Quaternion.Euler(0f, 0f, value.CurrentTilt); value.Model.localPosition = value.RestPosition + Vector3.up * (fallenHeightOffset * Mathf.Abs(value.CurrentTilt) / 90f); if (value.TargetTilt == 0f && value.CurrentTilt == 0f) { value.Model.localRotation = value.RestRotation; value.Model.localPosition = value.RestPosition; fallVisualsToRemove.Add(fallVisual.Key); } } foreach (RadMechAI item in fallVisualsToRemove) { fallVisuals.Remove(item); } fallVisualsToRemove.Clear(); } private void RestoreAllFallVisuals() { //IL_009e: 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) foreach (RadMechAI spedUpBird in spedUpBirds) { if ((Object)(object)spedUpBird != (Object)null && (Object)(object)((EnemyAI)spedUpBird).creatureAnimator != (Object)null) { ((EnemyAI)spedUpBird).creatureAnimator.speed = 1f; } } spedUpBirds.Clear(); foreach (KeyValuePair<RadMechAI, FallVisual> fallVisual in fallVisuals) { if ((Object)(object)fallVisual.Value.Model != (Object)null) { fallVisual.Value.Model.localRotation = fallVisual.Value.RestRotation; fallVisual.Value.Model.localPosition = fallVisual.Value.RestPosition; } } fallVisuals.Clear(); } private IEnumerator RunSquad() { yield return null; if ((Object)(object)RoundManager.Instance == (Object)null) { yield break; } RadMechAI component = ((Component)this).GetComponent<RadMechAI>(); self = new SquadBird(component); birds.Add(self); SetMode(SquadMode.Hatching); EnemyType birdType = FindBirdType(birdEnemyName); int toSpawn = (((Object)(object)birdType != (Object)null) ? birdsToSpawn : 0); Vector3 tip = ((Component)component).transform.position; float yaw = (formationYaw = ((Component)component).transform.eulerAngles.y); Quaternion facing = Quaternion.Euler(0f, yaw, 0f); int areaMask = (((Object)(object)birdType != (Object)null) ? RoundManager.Instance.GetLayermaskForEnemySizeLimit(birdType, false, -1) : (-1)); List<Vector3> list = BuildTriangleOffsets(toSpawn); List<Vector3> spawnPositions = new List<Vector3>(toSpawn); int giantIndex = ((toSpawn > 0) ? Random.Range(0, Mathf.Min(2, toSpawn)) : (-1)); giantSize = RollLeaderSize(); for (int i = 0; i < toSpawn; i++) { Vector3 val = SnapToNavMesh(tip + facing * list[i], 8f, tip, areaMask); spawnPositions.Add(val); NetworkObject val2 = SpawnNest(birdType, val, yaw); squadNests.Add(val2); if ((Object)(object)val2 != (Object)null && i == giantIndex) { SetScaleEverywhere(val2, birdType.nestSpawnPrefab.transform.localScale * giantSize); } } yield return (object)new WaitForSeconds(nestHoldTime); NetworkObject val4 = default(NetworkObject); for (int j = 0; j < toSpawn; j++) { if (!((NetworkBehaviour)this).IsSpawned || (Object)(object)RoundManager.Instance == (Object)null) { yield break; } NetworkObject nest = squadNests[j]; if ((Object)(object)birdType.nestSpawnPrefab != (Object)null) { if ((Object)(object)nest == (Object)null) { continue; } QueueNestNext(nest); yield return (object)new WaitForSeconds(0.4f); if ((Object)(object)nest == (Object)null || (Object)(object)RoundManager.Instance == (Object)null) { continue; } } NetworkObjectReference val3 = RoundManager.Instance.SpawnEnemyGameObject(spawnPositions[j], yaw, -1, birdType); if (((NetworkObjectReference)(ref val3)).TryGet(ref val4, (NetworkManager)null) && (Object)(object)val4 != (Object)null) { MarchingBirds component2 = ((Component)val4).GetComponent<MarchingBirds>(); if ((Object)(object)component2 != (Object)null) { component2.spawnedBySquad = true; } RadMechAI component3 = ((Component)val4).GetComponent<RadMechAI>(); if ((Object)(object)component3 != (Object)null) { SquadBird item = new SquadBird(component3); birds.Add(item); slotsDirty = true; if (j == giantIndex) { giant = item; leader = item; SetScaleEverywhere(val4, birdType.enemyPrefab.transform.localScale * giantSize); } } } yield return (object)new WaitForSeconds(timeBetweenHatches); } CleanUpLeftoverNests(); Plugin.Log.LogInfo((object)($"Marching Birds: '{((Object)((Component)this).gameObject).name}' hatched a squad of {birds.Count - 1} " + $"(leader size {giantSize:0.00}).")); if (mode == SquadMode.Hatching) { EnsureLeader(); formUpAnchor = SnapToNavMesh(tip + facing * Vector3.forward * LeaderGap(), 6f, tip, -1); SetMode(SquadMode.FormingUp); } } private EnemyType FindBirdType(string enemyName) { EnemyType val = null; EnemyType[] array = Resources.FindObjectsOfTypeAll<EnemyType>(); foreach (EnemyType val2 in array) { if ((Object)(object)val2 == (Object)null || (Object)(object)val2.enemyPrefab == (Object)null || !string.Equals(val2.enemyName, enemyName, StringComparison.OrdinalIgnoreCase)) { continue; } if ((Object)(object)val2.enemyPrefab.GetComponent<RadMechAI>() == (Object)null) { Plugin.Log.LogWarning((object)("Marching Birds: '" + val2.enemyName + "' isn't an Old Bird (no RadMechAI on its prefab).")); continue; } if (IsNetworkPrefab(val2.enemyPrefab)) { return val2; } if ((Object)(object)val == (Object)null) { val = val2; } } if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)("Marching Birds: no Old Bird EnemyType named '" + enemyName + "' is loaded, so '" + ((Object)((Component)this).gameObject).name + "' spawned no squad. Vanilla Old Birds are 'RadMech'.")); } return val; } private static bool IsNetworkPrefab(GameObject prefab) { try { return (Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.NetworkConfig.Prefabs.Contains(prefab); } catch (Exception) { return false; } } private float RollLeaderSize() { if (!randomLeaderSize) { return leaderSize; } return Random.Range(Mathf.Min(minLeaderSize, maxLeaderSize), Mathf.Max(minLeaderSize, maxLeaderSize)); } private List<Vector3> BuildTriangleOffsets(int count) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(count); int num = 1; while (list.Count < count) { int num2 = Mathf.Min(num + 1, count - list.Count); for (int i = 0; i < num2; i++) { list.Add(new Vector3(((float)i - (float)(num2 - 1) * 0.5f) * triangleSpacing, 0f, (float)(-num) * triangleSpacing)); } num++; } return list; } private static NetworkObject SpawnNest(EnemyType birdType, Vector3 position, float yaw) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)birdType == (Object)null || (Object)(object)birdType.nestSpawnPrefab == (Object)null) { return null; } GameObject val = Object.Instantiate<GameObject>(birdType.nestSpawnPrefab, position, Quaternion.Euler(0f, yaw, 0f)); NetworkObject componentInChildren = val.GetComponentInChildren<NetworkObject>(); if ((Object)(object)componentInChildren == (Object)null || (Object)(object)val.GetComponent<EnemyAINestSpawnObject>() == (Object)null) { Plugin.Log.LogWarning((object)("Marching Birds: nest prefab '" + ((Object)birdType.nestSpawnPrefab).name + "' has no NetworkObject/EnemyAINestSpawnObject; spawning that bird without a nest.")); Object.Destroy((Object)(object)val); return null; } componentInChildren.Spawn(true); return componentInChildren; } private static void QueueNestNext(NetworkObject nest) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) EnemyAINestSpawnObject component = ((Component)nest).GetComponent<EnemyAINestSpawnObject>(); List<EnemyAINestSpawnObject> enemyNestSpawnObjects = RoundManager.Instance.enemyNestSpawnObjects; enemyNestSpawnObjects.RemoveAll((EnemyAINestSpawnObject n) => (Object)(object)n == (Object)null); enemyNestSpawnObjects.Remove(component); enemyNestSpawnObjects.Insert(0, component); List<NetworkObjectReference> list = new List<NetworkObjectReference>(enemyNestSpawnObjects.Count); foreach (EnemyAINestSpawnObject item in enemyNestSpawnObjects) { NetworkObject componentInChildren = ((Component)item).GetComponentInChildren<NetworkObject>(); if ((Object)(object)componentInChildren != (Object)null && componentInChildren.IsSpawned) { list.Add(NetworkObjectReference.op_Implicit(componentInChildren)); } } RoundManager.Instance.SyncNestSpawnObjectsOrderServerRpc(list.ToArray()); } private void CleanUpLeftoverNests() { foreach (NetworkObject squadNest in squadNests) { if (!((Object)(object)squadNest == (Object)null)) { RoundManager.Instance?.enemyNestSpawnObjects.Remove(((Component)squadNest).GetComponent<EnemyAINestSpawnObject>()); if (squadNest.IsSpawned) { squadNest.Despawn(true); } } } squadNests.Clear(); } private void SetScaleEverywhere(NetworkObject target, Vector3 scale) { //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_0013: Unknown result type (might be due to invalid IL or missing references) ((Component)target).transform.localScale = scale; SetObjectScaleClientRpc(NetworkObjectReference.op_Implicit(target), scale); } private void SetMode(SquadMode newMode) { mode = newMode; modeStartTime = Time.time; } private void UpdateSquad() { if (self == null || Time.time < nextTickTime) { return; } nextTickTime = Time.time + 0.2f; try { Tick(); } catch (Exception ex) { if (Time.time > nextErrorLogTime) { nextErrorLogTime = Time.time + 10f; Plugin.Log.LogError((object)("Marching Birds: " + ex)); } } } private void Tick() { PruneDeadBirds(); if (birds.Count == 0) { return; } EnsureLeader(); if (slotsDirty) { AssignSlots(); } UpdateFalls(); if (mode != SquadMode.Alert && TryFindSpotter(out var spotter)) { EnterAlert(spotter); } switch (mode) { case SquadMode.Hatching: { foreach (SquadBird bird in birds) { if (bird.ReadyOnGround) { StandStill(bird); } } break; } case SquadMode.FormingUp: TickFormingUp(); break; case SquadMode.Marching: TickMarching(); break; case SquadMode.Flying: TickFlying(); break; case SquadMode.Alert: TickAlert(); break; case SquadMode.Rampage: TickRampage(); break; } } private void PruneDeadBirds() { for (int num = birds.Count - 1; num >= 0; num--) { if (!birds[num].Alive) { birds.RemoveAt(num); slotsDirty = true; } } } private void EnsureLeader() { //IL_0059: 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) if (leader != null && leader.Alive && birds.Contains(leader)) { return; } leader = null; foreach (SquadBird bird in birds) { if (leader == null || ((Component)bird.Ai).transform.lossyScale.x > ((Component)leader.Ai).transform.lossyScale.x) { leader = bird; } } slotsDirty = true; } private float LeaderGap() { return formationSpacing * (0.5f + 0.5f * Mathf.Max(1f, LeaderSize)); } private void AssignSlots() { //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_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) slotsDirty = false; List<SquadBird> list = new List<SquadBird>(birds.Count); if (self != null && self != leader && birds.Contains(self)) { list.Add(self); } foreach (SquadBird bird in birds) { if (bird != leader && bird != self) { list.Add(bird); } } List<Vector3> list2 = BuildCubeOffsets(list.Count); for (int i = 0; i < list.Count; i++) { list[i].SlotOffset = list2[i]; } if (leader != null) { leader.SlotOffset = Vector3.zero; } } private List<Vector3> BuildCubeOffsets(int count) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(count); if (count == 0) { return list; } int num = Mathf.CeilToInt(Mathf.Sqrt((float)count)); float num2 = LeaderGap(); int num3 = 0; while (list.Count < count) { int num4 = Mathf.Min(num, count - list.Count); for (int i = 0; i < num4; i++) { list.Add(new Vector3(((float)i - (float)(num4 - 1) * 0.5f) * formationSpacing, 0f, 0f - (num2 + (float)num3 * formationSpacing))); } num3++; } list.Sort((Vector3 a, Vector3 b) => ((Vector3)(ref a)).sqrMagnitude.CompareTo(((Vector3)(ref b)).sqrMagnitude)); return list; } private static void TakeControl(SquadBird bird) { RadMechAI ai = bird.Ai; if (((EnemyAI)ai).searchCoroutine != null || !ai.searchForPlayers.inProgress) { ((EnemyAI)ai).StopSearch(ai.searchForPlayers, false); ai.searchForPlayers.inProgress = true; } } private static void MoveTo(SquadBird bird, Vector3 position) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) TakeControl(bird); ((EnemyAI)bird.Ai).SetDestinationToPosition(position, false); } private static void StandStill(SquadBird bird) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) MoveTo(bird, bird.Position); } private static void SetPace(SquadBird bird, float multiplier) { if (!bird.Fallen) { bird.Ai.stepMovementSpeed = bird.BaseStepMovementSpeed * multiplier; } } private void ReleaseSquad() { foreach (SquadBird bird in birds) { if (bird.Alive) { RadMechAI ai = bird.Ai; if (((EnemyAI)ai).searchCoroutine == null && ai.searchForPlayers.inProgress) { ai.searchForPlayers.inProgress = false; } ai.stepMovementSpeed = bird.BaseStepMovementSpeed; ai.timeToTakeStep = bird.BaseTimeToTakeStep; } } birds.Clear(); } private static Vector3 SnapToNavMesh(Vector3 position, float radius, Vector3 fallback, int areaMask) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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) Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(position, default(NavMeshHit), radius, areaMask); if (!RoundManager.Instance.GotNavMeshPositionResult) { return fallback; } return navMeshPosition; } private static float FlatDistance(Vector3 a, Vector3 b) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) a.y = 0f; b.y = 0f; return Vector3.Distance(a, b); } private static bool HasOpenSky(Vector3 position) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_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) return !Physics.Raycast(position + Vector3.up * 9.62f, Vector3.up, 60f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1); } private static GameObject[] NodesFor(SquadBird bird) { GameObject[] allAINodes = ((EnemyAI)bird.Ai).allAINodes; if (allAINodes == null || allAINodes.Length == 0) { return RoundManager.Instance.outsideAINodes; } return allAINodes; } private void TickFormingUp() { //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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_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) Quaternion val = Quaternion.Euler(0f, formationYaw, 0f); bool flag = true; foreach (SquadBird bird in birds) { if (!bird.ReadyOnGround) { if (!((EnemyAI)bird.Ai).ventAnimationFinished) { flag = false; } } else if (!bird.Fallen || keepWalkingWhileFallen) { Vector3 val2 = ((bird == leader) ? formUpAnchor : SnapToNavMesh(formUpAnchor + val * bird.SlotOffset, 6f, formUpAnchor, -1)); SetPace(bird, 1f); MoveTo(bird, val2); if (FlatDistance(bird.Position, val2) > 3.5f) { flag = false; } } } if (flag || Time.time - modeStartTime > maxFormUpTime) { EnterMarching(keepFormationYaw: true); } } private void EnterMarching(bool keepFormationYaw) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) SetMode(SquadMode.Marching); hasWaypoint = false; sharedThreat = null; foreach (SquadBird bird in birds) { bird.ClearFlight(); bird.HasRampageTarget = false; bird.DivertedToThreat = false; } if (!keepFormationYaw && leader != null) { formationYaw = ((Component)leader.Ai).transform.eulerAngles.y; } nextFlightTime = Time.time + Random.Range(minTimeBetweenFlights, Mathf.Max(minTimeBetweenFlights, maxTimeBetweenFlights)); } private void TickMarching() { //IL_0093: 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_00c8: 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_0036: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_0135: 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_0164: Unknown result type (might be due to invalid IL or missing references) if (leader.ReadyOnGround && (!leader.Fallen || keepWalkingWhileFallen)) { if (!hasWaypoint || FlatDistance(leader.Position, waypoint) < 8f || Time.time > waypointDeadline) { PickWaypoint(); } SetPace(leader, leaderPace); MoveTo(leader, waypoint); } formationYaw = Mathf.MoveTowardsAngle(formationYaw, ((Component)leader.Ai).transform.eulerAngles.y, formationTurnSpeed * 0.2f); Quaternion val = Quaternion.Euler(0f, formationYaw, 0f); foreach (SquadBird bird in birds) { if (bird != leader && bird.ReadyOnGround && (!bird.Fallen || keepWalkingWhileFallen)) { Vector3 val2 = SnapToNavMesh(leader.Position + val * bird.SlotOffset, 6f, leader.Position, -1); SetPace(bird, (FlatDistance(bird.Position, val2) > formationSpacing * 1.5f) ? catchUpSpeed : 1f); MoveTo(bird, val2); } } RollMarchingFalls(); if (groupFlights && Time.time >= nextFlightTime) { TryStartGroupFlight(); } } private void PickWaypoint() { //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_005d: 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_00d3: 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_008e: 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_0071: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) GameObject[] array = NodesFor(leader); hasWaypoint = true; waypointDeadline = Time.time + waypointTimeout; if (array == null || array.Length == 0) { waypoint = leader.Position; return; } for (int i = 0; i < 12; i++) { GameObject val = array[Random.Range(0, array.Length)]; if (!((Object)(object)val == (Object)null)) { Vector3 position = val.transform.position; if ((i >= 9 || !(FlatDistance(position, leader.Position) < minWaypointDistance)) && ((EnemyAI)leader.Ai).SetDestinationToPosition(position, true)) { waypoint = position; return; } } } GameObject val2 = array[Random.Range(0, array.Length)]; waypoint = (((Object)(object)val2 != (Object)null) ? val2.transform.position : leader.Position); } private void TryStartGroupFlight() { //IL_0048: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_011e: 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_012b: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) nextFlightTime = Time.time + Random.Range(minTimeBetweenFlights, Mathf.Max(minTimeBetweenFlights, maxTimeBetweenFlights)); if (!leader.ReadyOnGround || leader.Fallen || !HasOpenSky(leader.Position)) { nextFlightTime = Time.time + 5f; return; } if (!TryPickFlightTarget(out var target)) { nextFlightTime = Time.time + 10f; return; } Vector3 val = target - leader.Position; val.y = 0f; float y; if (!(((Vector3)(ref val)).sqrMagnitude > 1f)) { y = formationYaw; } else { Quaternion val2 = Quaternion.LookRotation(val); y = ((Quaternion)(ref val2)).eulerAngles.y; } flightYaw = y; flightDivedOnPlayer = false; Quaternion val3 = Quaternion.Euler(0f, flightYaw, 0f); int num = 0; foreach (SquadBird bird in birds) { bird.ClearFlight(); bird.Landing = ((bird == leader) ? target : SnapToNavMesh(target + val3 * bird.SlotOffset, 8f, target, -353)); if (bird.ReadyOnGround && !bird.Fallen && HasOpenSky(bird.Position)) { bird.Flying = true; bird.DropDuringFlight = Random.Range(0f, 100f) < fallChancePerFlight; bird.DropDelay = Random.Range(1.5f, 4f); bird.Ai.stepMovementSpeed = bird.BaseStepMovementSpeed; ((EnemyAI)bird.Ai).SwitchToBehaviourState(2); num++; } } SetMode(SquadMode.Flying); Plugin.Log.LogInfo((object)$"Marching Birds: squad taking off ({num} flying)."); } private bool TryPickFlightTarget(out Vector3 target) { //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_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_0066: 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_004d: 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_0088: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b3: Unknown result type (might be due to invalid IL or missing references) GameObject[] array = NodesFor(leader); target = Vector3.zero; if (array == null || array.Length == 0) { return false; } for (int i = 0; i < 15; i++) { GameObject val = array[Random.Range(0, array.Length)]; if ((Object)(object)val == (Object)null) { continue; } Vector3 position = val.transform.position; if ((i >= 12 || !(FlatDistance(position, leader.Position) < minFlightDistance)) && !Physics.Raycast(position, Vector3.up, 15f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(position, default(NavMeshHit), 10f, -353); if (RoundManager.Instance.GotNavMeshPositionResult) { target = navMeshPosition; return true; } } } return false; } private void TickFlying() { //IL_004f: 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_00df: Unknown result type (might be due to invalid IL or missing references) bool flag = false; foreach (SquadBird bird in birds) { if (!bird.Flying) { if (bird.ReadyOnGround && (!bird.Fallen || keepWalkingWhileFallen)) { SetPace(bird, catchUpSpeed); MoveTo(bird, bird.Landing); } continue; } if (((EnemyAI)bird.Ai).currentBehaviourStateIndex != 2) { bird.Flying = false; continue; } flag = true; if (RadMechInternals.InSky(bird.Ai)) { if (bird.InSkySince < 0f) { bird.InSkySince = Time.time; } Vector3 ground; if (!bird.Redirected) { bird.Ai.ChangeFlightLandingPosition(bird.Landing); bird.Redirected = true; } else if (!flightDivedOnPlayer && !bird.Dropped && TrySpotPlayerFromAir(bird, out ground)) { DiveSquadAt(ground); } if (bird.DropDuringFlight && !bird.Dropped && Time.time - bird.InSkySince > bird.DropDelay) { DropOutOfSky(bird); } } } if (!flag || Time.time - modeStartTime > 90f) { formationYaw = flightYaw; EnterMarching(keepFormationYaw: true); } } private static bool TrySpotPlayerFromAir(SquadBird bird, out Vector3 ground) { //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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_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) ground = Vector3.zero; RadMechAI ai = bird.Ai; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; RaycastHit val2 = default(RaycastHit); foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && !val.isPlayerDead && ((EnemyAI)ai).CheckLineOfSightForPosition(((Component)val).transform.position, 35f, 120, -1f, ai.flyingModeEye) && ((IVisibleThreat)val).GetVisibility() >= 0.8f && Physics.Raycast(((Component)val).transform.position, Vector3.down, ref val2, 7f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { ground = ((RaycastHit)(ref val2)).point; return true; } } return false; } private void DiveSquadAt(Vector3 point) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) flightDivedOnPlayer = true; Quaternion val = Quaternion.Euler(0f, flightYaw, 0f); foreach (SquadBird bird in birds) { if (bird.Flying && !bird.Dropped) { bird.Landing = SnapToNavMesh(point + val * (bird.SlotOffset * 0.6f), 8f, point, -353); if (RadMechInternals.InSky(bird.Ai)) { bird.Ai.ChangeFlightLandingPosition(bird.Landing); bird.Redirected = true; } else { bird.Redirected = false; } } } Plugin.Log.LogInfo((object)"Marching Birds: a bird spotted a player from the air - the squad is diving on them."); } private void DropOutOfSky(SquadBird bird) { //IL_0008: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_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_0053: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_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_007c: 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_00a0: Unknown result type (might be due to invalid IL or missing references) bird.Dropped = true; Vector3 val = bird.Position; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(bird.Position + Vector3.up * 2f, Vector3.down, ref val2, 300f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1)) { val = ((RaycastHit)(ref val2)).point; } Vector3 navMeshPosition = RoundManager.Instance.GetNavMeshPosition(val, default(NavMeshHit), 8f, -353); if (RoundManager.Instance.GotNavMeshPositionResult) { bird.Landing = navMeshPosition; bird.Ai.ChangeFlightLandingPosition(navMeshPosition); bird.FallAfterLanding = true; SetBirdFallenClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)bird.Ai).NetworkObject), fallen: true, 0f, walkAnimationSpeed); } } private void RollMarchingFalls() { if (fallChancePerMinute <= 0f) { return; } float num = fallChancePerMinute / 100f * 0.0033333334f; foreach (SquadBird bird in birds) { if (!bird.Fallen && bird.ReadyOnGround && Random.value < num) { StartFall(bird); } } } private void StartFall(SquadBird bird) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) bird.FallAfterLanding = false; if (!bird.Fallen && bird.Alive) { bird.Fallen = true; bird.FallEndTime = Time.time + Random.Range(minFallTime, Mathf.Max(minFallTime, maxFallTime)); bird.FallTilt = fallTiltAngle * ((Random.value < 0.5f) ? (-1f) : 1f); SetBirdFallenClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)bird.Ai).NetworkObject), fallen: true, bird.FallTilt, walkAnimationSpeed); } } private void UpdateFalls() { foreach (SquadBird bird in birds) { if (bird.FallAfterLanding && !bird.Fallen && bird.ReadyOnGround) { StartFall(bird); } if (!bird.Fallen) { continue; } RadMechAI ai = bird.Ai; if (Time.time >= bird.FallEndTime || ((EnemyAI)ai).currentBehaviourStateIndex != 0) { EndFall(bird); continue; } ai.timeToTakeStep = bird.BaseTimeToTakeStep / walkAnimationSpeed; ai.timeBetweenSteps = 0.7f / walkAnimationSpeed; if (keepWalkingWhileFallen) { ai.stepMovementSpeed = bird.BaseStepMovementSpeed; continue; } ai.stepMovementSpeed = 0f; if (bird.ReadyOnGround) { StandStill(bird); } } } private void EndFall(SquadBird bird) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) bool num = bird.Fallen || bird.FallAfterLanding; bird.Fallen = false; bird.FallAfterLanding = false; if (num && bird.Alive) { RadMechAI ai = bird.Ai; ai.timeToTakeStep = bird.BaseTimeToTakeStep; ai.stepMovementSpeed = bird.BaseStepMovementSpeed; if (((EnemyAI)ai).currentBehaviourStateIndex == 0) { ai.timeBetweenSteps = 0.7f; } SetBirdFallenClientRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)ai).NetworkObject), fallen: false, 0f, 1f); } } private static bool IsGone(IVisibleThreat threat) { if (threat != null) { Object val = (Object)(object)((threat is Object) ? threat : null); if (val == null || !(val == (Object)null)) { return threat.IsThreatDead(); } } return true; } private static IVisibleThreat TargetOf(SquadBird bird) { if (bird.Ai.targetedThreat == null) { return null; } return bird.Ai.targetedThreat.threatScript; } private bool TryFindSpotter(out SquadBird spotter) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) spotter = null; foreach (SquadBird bird in birds) { if (((EnemyAI)bird.Ai).currentBehaviourStateIndex != 1) { continue; } IVisibleThreat val = TargetOf(bird); if (!IsGone(val) && (int)val.type == 0) { if (RadMechInternals.HasLineOfSight(bird.Ai)) { spotter = bird; return true; } if (spotter == null) { spotter = bird; } } } return spotter != null; } private void EnterAlert(SquadBird spotter) { //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) sharedThreat = TargetOf(spotter); sharedThreatPosition = sharedThreat.GetThreatTransform().position; lastSquadSightTime = Time.time; foreach (SquadBird bird in birds) { bird.DivertedToThreat = false; EndFall(bird); } SetMode(SquadMode.Alert); Plugin.Log.LogInfo((object)"Marching Birds: a bird spotted a player - the whole squad knows where they are."); } private void TickAlert() { //IL_00b5: 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_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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0183: 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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) if (TryFindSpotter(out var spotter) && RadMechInternals.HasLineOfSight(spotter.Ai)) { sharedThreat = TargetOf(spotter); } if (IsGone(sharedThreat)) { EnterRampage(); return; } Transform threatTransform = sharedThreat.GetThreatTransform(); bool flag = false; foreach (SquadBird bird in birds) { if (((EnemyAI)bird.Ai).currentBehaviourStateIndex == 1 && TargetOf(bird) == sharedThreat && RadMechInternals.HasLineOfSight(bird.Ai)) { flag = true; break; } } if (flag) { lastSquadSightTime = Time.time; sharedThreatPosition = threatTransform.position; } else if (Time.time - lastSquadSightTime > loseSightTime) { EnterRampage(); return; } foreach (SquadBird bird2 in birds) { RadMechAI ai = bird2.Ai; switch (((EnemyAI)ai).currentBehaviourStateIndex) { case 2: if (!bird2.DivertedToThreat && RadMechInternals.InSky(ai)) { Vector2 insideUnitCircle = Random.insideUnitCircle; Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(8f, 16f); Vector3 position = sharedThreatPosition + new Vector3(val.x, 0f, val.y); ai.ChangeFlightLandingPosition(SnapToNavMesh(position, 8f, sharedThreatPosition, -353)); bird2.DivertedToThreat = true; } break; case 0: if (bird2.ReadyOnGround) { PushThreat(bird2, threatTransform); } break; case 1: if (!((EnemyAI)ai).inSpecialAnimation) { if (TargetOf(bird2) != sharedThreat) { PushThreat(bird2, threatTransform); } else if (flag && !RadMechInternals.HasLineOfSight(ai)) { ai.targetedThreat.lastSeenPosition = sharedThreatPosition; RadMechInternals.KeepChasing(ai); } } break; } } } private void PushThreat(SquadBird bird, Transform threatTransform) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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) NetworkObject component = ((Component)threatTransform).GetComponent<NetworkObject>(); if (!((Object)(object)component == (Object)null)) { RadMechAI ai = bird.Ai; ai.stepMovementSpeed = bird.BaseStepMovementSpeed; ai.SetTargetedThreat(sharedThreat, sharedThreatPosition, Vector3.Distance(((EnemyAI)ai).eye.position, threatTransform.position)); ai.focusedThreatTransform = threatTransform; ((EnemyAI)ai).SwitchToBehaviourStateOnLocalClient(1); ai.SetTargetToThreatClientRpc(NetworkObjectReference.op_Implicit(component), sharedThreatPosition); if (alertWholeSquad && !ai.isAlerted) { ai.SetMechAlertedToThreat(); ai.SetMechAlertedClientRpc(); } } } private void EnterRampage() { SetMode(SquadMode.Rampage); rampageEndTime = Time.time + rampageDuration; sharedThreat = null; float num = Random.Range(0f, 360f); for (int i = 0; i < birds.Count; i++) { SquadBird squadBird = birds[i]; squadBird.DivertedToThreat = false; squadBird.HasRampageTarget = false; squadBird.RampageYaw = num + 360f * (float)i / (float)birds.Count + Random.Range(-15f, 15f); squadBird.NextRocketTime = Time.time + Random.Range(0.2f, 1.5f); if (((EnemyAI)squadBird.Ai).currentBehaviourStateIndex == 1 && !((EnemyAI)squadBird.Ai).inSpecialAnimation) { ((EnemyAI)squadBird.Ai).SwitchToBehaviourState(0); } } Plugin.Log.LogInfo((object)"Marching Birds: lost the player - rampage!"); } private void TickRampage() { //IL_004d: 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_0085: Unknown result type (might be due to invalid IL or missing references) if (Time.time >= rampageEndTime) { EnterMarching(keepFormationYaw: false); return; } foreach (SquadBird bird in birds) { if (bird.ReadyOnGround && !bird.Fallen) { if (!bird.HasRampageTarget || FlatDistance(bird.Position, bird.RampageTarget) < 5f || Time.time > bird.RampageRepickTime) { PickRampageTarget(bird); } SetPace(bird, 1f); MoveTo(bird, bird.RampageTarget); if (Time.time >= bird.NextRocketTime) { FireRampageRocket(bird); bird.NextRocketTime = Time.time + Random.Range(minTimeBetweenRockets, Mathf.Max(minTimeBetweenRockets, maxTimeBetweenRockets)); } } } } private void PickRampageTarget(SquadBird bird) { //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_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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Quaternion.Euler(0f, bird.RampageYaw, 0f) * Vector3.forward; Vector3 rampageTarget = RoundManager.Instance.GetNavMeshPosition(bird.Position + val * rampageWalkDistance, default(NavMeshHit), 12f, -1); if (!RoundManager.Instance.GotNavMeshPositionResult) { rampageTarget = BestNodeInDirection(bird, val); } bird.RampageTarget = rampageTarget; bird.HasRampageTarget = true; bird.RampageRepickTime = Time.time + 15f; bird.RampageYaw += Random.Range(-45f, 45f); } private static Vector3 BestNodeInDirection(SquadBird bird, Vector3 direction) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0063: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) Vector3 position = bird.Position; float num = float.MinValue; GameObject[] array = NodesFor(bird); if (array == null) { return position; } GameObject[] array2 = array; foreach (GameObject val in array2) { if ((Object)(object)val == (Object)null) { continue; } Vector3 val2 = val.transform.position - bird.Position; val2.y = 0f; if (!(((Vector3)(ref val2)).magnitude < 10f)) { float num2 = Vector3.Dot(direction, ((Vector3)(ref val2)).normalized); if (num2 > num) { num = num2; position = val.transform.position; } } } return position; } private void FireRampageRocket(SquadBird bird) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_0087: 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) RadMechAI ai = bird.Ai; if (!((Object)(object)ai.gunPoint == (Object)null)) { float num = ((Component)ai).transform.eulerAngles.y + Random.Range(0f - rocketAimSpread, rocketAimSpread); float num2 = Random.Range(Mathf.Min(minRocketDownAngle, maxRocketDownAngle), Mathf.Max(minRocketDownAngle, maxRocketDownAngle)); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(num2, num, 0f); Vector3 position = ai.gunPoint.position; ai.ShootGun(position, val); ai.ShootGunClientRpc(position, val); } } protected override void __initializeVariables() { ((NetworkBehaviour)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 ((NetworkBehaviour)this).__registerRpc(1774542163u, new RpcReceiveHandler(__rpc_handler_1774542163), "SetObjectScaleClientRpc"); ((NetworkBehaviour)this).__registerRpc(1646750089u, new RpcReceiveHandler(__rpc_handler_1646750089), "SetBirdFallenClientRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_1774542163(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_0051: 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_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) { NetworkObjectReference target2 = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref target2, default(ForNetworkSerializable)); Vector3 scale = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref scale); target.__rpc_exec_stage = (__RpcExecStage)1; ((MarchingBirds)(object)target).SetObjectScaleClientRpc(target2, scale); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1646750089(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkObjectReference bird = default(NetworkObjectReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkObjectReference>(ref bird, default(ForNetworkSerializable)); bool fallen = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref fallen, default(ForPrimitives)); float tilt = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref tilt, default(ForPrimitives)); float animationSpeed = default(float); ((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref animationSpeed, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((MarchingBirds)(object)target).SetBirdFallenClientRpc(bird, fallen, tilt, animationSpeed); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "MarchingBirds"; } } internal static class RadMechInternals { private const BindingFlags Flags = BindingFlags.Instance | BindingFlags.NonPublic; private static readonly FieldInfo HasLosField = Find("hasLOS"); private static readonly FieldInfo LosTimerField = Find("losTimer"); private static readonly FieldInfo LostInChaseField = Find("lostCreatureInChase"); private static readonly FieldInfo InSkyField = Find("inSky"); private static readonly FieldInfo InFlyingModeField = Find("inFlyingMode"); private static readonly FieldInfo ChangedDirectionField = Find("changedDirectionInFlight"); private static readonly FieldInfo LandingPositionField = Find("landingPosition"); private static FieldInfo Find(string name) { FieldInfo? field = typeof(RadMechAI).GetField(name, BindingFlags.Instance | BindingFlags.NonPublic); if (field == null) { Debug.LogWarning((object)("[MarchingBirds] RadMechAI." + name + " not found - a game update probably renamed it. The squad will still run, but the behaviour that reads it won't.")); } return field; } private static bool GetBool(FieldInfo field, RadMechAI ai) { if (field != null) { return (bool)field.GetValue(ai); } return false; } internal static bool HasLineOfSight(RadMechAI ai) { return GetBool(HasLosField, ai); } internal static bool InSky(RadMechAI ai) { return GetBool(InSkyField, ai); } internal static bool InFlyingMode(RadMechAI ai) { return GetBool(InFlyingModeField, ai); } internal static bool ChangedDirectionInFlight(RadMechAI ai) { return GetBool(ChangedDirectionField, ai); } internal static Vector3 LandingPosition(RadMechAI ai) { //IL_0024: 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) if (!(LandingPositionField != null)) { return ((Component)ai).transform.position; } return (Vector3)LandingPositionField.GetValue(ai); } internal static void KeepChasing(RadMechAI ai) { LosTimerField?.SetValue(ai, 0f); LostInChaseField?.SetValue(ai, false); } } internal class SquadBird { internal readonly RadMechAI Ai; internal Vector3 SlotOffset; internal readonly float BaseStepMovementSpeed; internal readonly float BaseTimeToTakeStep; internal bool Flying; internal bool Redirected; internal Vector3 Landing; internal float InSkySince = -1f; internal bool DropDuringFlight; internal float DropDelay; internal bool Dropped; internal bool DivertedToThreat; internal bool Fallen; internal bool FallAfterLanding; internal float FallEndTime; internal float FallTilt; internal float RampageYaw; internal bool HasRampageTarget; internal Vector3 RampageTarget; internal float RampageRepickTime; internal float NextRocketTime; internal bool Alive { get { if ((Object)(object)Ai != (Object)null) { return !((EnemyAI)Ai).isEnemyDead; } return false; } } internal Vector3 Position => ((Component)Ai).transform.position; internal bool ReadyOnGround { get { if (Alive && ((EnemyAI)Ai).ventAnimationFinished && !((EnemyAI)Ai).inSpecialAnimation && ((EnemyAI)Ai).currentBehaviourStateIndex == 0) { return !RadMechInternals.InFlyingMode(Ai); } return false; } } internal SquadBird(RadMechAI ai) { Ai = ai; BaseStepMovementSpeed = ai.stepMovementSpeed; BaseTimeToTakeStep = ai.timeToTakeStep; } internal void ClearFlight() { Flying = false; Redirected = false; InSkySince = -1f; DropDuringFlight = false; Dropped = false; } } [BepInPlugin("com.tonysmoons.tazgmondscripts", "TazgmondScripts", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.tonysmoons.tazgmondscripts"; public const string PluginName = "TazgmondScripts"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; InitializeNetcodeRpcs(); LethalBundleManager.OnFinishedProcessing.AddListener((Action)ReplacementApplier.FindAssets); Plugin.onSetupComplete += ReplacementApplier.Apply; Log.LogInfo((object)"TazgmondScripts 1.0.0 loaded."); } private void InitializeNetcodeRpcs() { int num = 0; Type[] types = Assembly.GetExecutingAssembly().GetTypes(); for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); num++; } } } Log.LogInfo((object)$"Netcode patched: initialized {num} runtime-init method(s)."); } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace TazgmondScripts.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }