using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using DM; using HarmonyLib; using InControl; using Landfall.TABS; using Landfall.TABS.AI.Components; using Landfall.TABS.AI.Components.Modifiers; using Landfall.TABS.AI.Components.Tags; using Landfall.TABS.AI.Systems; using Landfall.TABS.GameMode; using Landfall.TABS.GameState; using Landfall.TABS.TeamEdge; using Landfall.TABS.UI; using Landfall.TABS.UI.UIGroups.Attributes; using Landfall.TABS.UI.Widgets.Fields; using Landfall.TABS.UI.Widgets.List; using Landfall.TABS.UI.WinConditions; using Landfall.TABS.UnitEditor; using Landfall.TABS.WinConditions; using Landfall.TABS.Workshop; using Landfall.TABS_Input; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using StayCombatFix; using TFBGames; using TabsUnlimited.CustomVoices; using TabsUnlimited.TeamLine; using TabsUnlimited.WinConditions; using Unity.Entities; using Unity.Mathematics; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 TabsUnlimited { internal static class BattleStateHelper { private static int _checkFrame = -1; private static bool _cachedBattleActive; internal static bool IsBattleActive() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 if (Time.frameCount == _checkFrame) { return _cachedBattleActive; } _checkFrame = Time.frameCount; GameStateManager service = ServiceLocator.GetService(); _cachedBattleActive = service != null && (int)service.GameState == 1; return _cachedBattleActive; } internal static void InvalidateCache() { _checkFrame = -1; } } internal enum CustomEnemyTargetingMode { MostExpensive, LowestHealth, RangedMixedOnly } internal static class CustomEnemyTargetingSystem { private struct TeamEnemySnapshot { internal Entity Entity; internal Unit Unit; internal Vector3 Position; internal float Cost; internal float CurrentHealth; internal bool? IsRanged; internal float TargetPriority; internal float BeingTargetedBy; } private struct HunterState { internal Unit Unit; internal Entity Entity; internal Team Team; internal float AttackRange; internal Vector3 Position; internal CustomEnemyTargetingMode Mode; } private struct RangeScanResult { internal bool AnyInNear; internal bool AnyInApproach; internal bool FoundCurrentTarget; internal bool CurrentTargetAlive; internal float CurrentTargetSqrDistance; } private const float MinTargetPriority = 0.1f; private const float OvercrowdingFactor = 0.05f; private const int InitialSnapshotCapacity = 128; private const int InitialHunterCapacity = 32; private const int MaxCustomTargetingRetargetsPerFrame = 32; private static readonly List[] TeamSnapshots = new List[2] { new List(128), new List(128) }; private static readonly List Hunters = new List(32); private static readonly Dictionary LastRetargetTime = new Dictionary(); private static readonly Dictionary SnapshotLookupByEntity = new Dictionary(); private static readonly Dictionary BlueprintCostCache = new Dictionary(); private static float _lastSnapshotTime = -1f; private static int _lastSnapshotUnitCount = -1; private static int _retargetBudgetFrame = -1; private static int _retargetBudgetRemaining; private static readonly HashSet IdleCustomHunterEntities = new HashSet(); private static readonly Dictionary IdleCustomHunterUnits = new Dictionary(); internal static void InvalidateCaches() { _lastSnapshotTime = -1f; _lastSnapshotUnitCount = -1; TeamSnapshots[0].Clear(); TeamSnapshots[1].Clear(); SnapshotLookupByEntity.Clear(); Hunters.Clear(); LastRetargetTime.Clear(); BlueprintCostCache.Clear(); IdleCustomHunterEntities.Clear(); IdleCustomHunterUnits.Clear(); UnitBlueprintCombatHelper.InvalidateRangedCache(); } internal static void PreUpdateBarrier_OnUpdate_Postfix() { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Expected I4, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) if (!UnitEditorConfig.CustomTargetingTypesEnabled || !BattleStateHelper.IsBattleActive() || !EcsComponentHelper.IsAvailable) { return; } TeamSystem existingManager = EcsComponentHelper.GetExistingManager(); if (existingManager == null) { return; } List allUnits = existingManager.GetAllUnits(); if (allUnits == null || allUnits.Count == 0) { return; } EntityManager entityManager = null; Entity entity; for (int i = 0; i < allUnits.Count && !EcsComponentHelper.TryGetEntityManager((Component)(object)allUnits[i], out entity, out entityManager); i++) { } if (!entityManager.IsCreated) { return; } IdleCustomHunterEntities.Clear(); IdleCustomHunterUnits.Clear(); CollectHunters(allUnits, entityManager); if (Hunters.Count == 0) { return; } EnsureSnapshotsFresh(existingManager, entityManager, allUnits.Count); float time = Time.time; float retargetInterval = 0.25f; EnsureRetargetBudget(); for (int j = 0; j < Hunters.Count; j++) { HunterState hunter = Hunters[j]; if (FleeDistanceInterop.IsAiEnabled && entityManager.HasComponent(hunter.Entity) && (FleeDistanceInterop.IsFleeManaged(hunter.Entity) || FleeDistanceInterop.ShouldFlee(entityManager, hunter.Entity))) { continue; } int num = (int)TeamUtlity.GetOtherTeam(hunter.Team); List list = TeamSnapshots[num]; if (list.Count == 0) { ForceIdleCustomHunter(entityManager, hunter); continue; } float inRangeCutoffSq = ComputeInRangeCutoffSq(hunter); float farMaxSq = ComputeFarMaxSq(hunter); Entity val = Entity.Null; if (EcsComponentHelper.TryGetComponentData(entityManager, hunter.Entity, out HasTargetTag data)) { val = data.Target; } RangeScanResult rangeScan = ScanEnemyRanges(list, hunter.Position, inRangeCutoffSq, farMaxSq, val); if (!rangeScan.AnyInNear && !rangeScan.AnyInApproach) { ForceIdleCustomHunter(entityManager, hunter); LastRetargetTime[hunter.Entity] = time; } else { if (ShouldSkipRetarget(hunter.Entity, val, rangeScan, inRangeCutoffSq, farMaxSq, time, retargetInterval)) { continue; } bool flag = IsUrgentRetarget(val, rangeScan, inRangeCutoffSq, farMaxSq); if (!flag && _retargetBudgetRemaining <= 0) { continue; } if (!TryPickTargetSinglePass(hunter.Mode, hunter.Position, hunter.AttackRange, inRangeCutoffSq, farMaxSq, list, rangeScan.AnyInNear, out var targetEntity, out var usedNearMode)) { ForceIdleCustomHunter(entityManager, hunter); continue; } if (!flag) { _retargetBudgetRemaining--; } if (targetEntity == val) { LastRetargetTime[hunter.Entity] = time; continue; } ApplyTarget(entityManager, hunter.Entity, targetEntity, usedNearMode); LastRetargetTime[hunter.Entity] = time; } } } internal static void UnitECSToMonoSyncSystem_OnUpdate_Postfix() { if (!UnitEditorConfig.CustomTargetingTypesEnabled || !BattleStateHelper.IsBattleActive() || IdleCustomHunterUnits.Count == 0) { return; } foreach (KeyValuePair idleCustomHunterUnit in IdleCustomHunterUnits) { Unit value = idleCustomHunterUnit.Value; if (!((Object)(object)value == (Object)null) && !value.dead && !((Object)(object)value.api == (Object)null)) { value.api.SetMovementSpeed(0f, true); } } } private static float ComputeInRangeCutoffSq(HunterState hunter) { float item = GetRangeProfile(hunter.Mode, hunter.AttackRange).nearFraction; float num = hunter.AttackRange * item; return num * num; } private static float ComputeFarMaxSq(HunterState hunter) { float item = GetRangeProfile(hunter.Mode, hunter.AttackRange).approachMultiplier; float num = hunter.AttackRange * item; return num * num; } private static RangeScanResult ScanEnemyRanges(List enemies, Vector3 hunterPosition, float inRangeCutoffSq, float farMaxSq, Entity currentTarget) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_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) RangeScanResult rangeScanResult = default(RangeScanResult); rangeScanResult.CurrentTargetSqrDistance = float.MaxValue; RangeScanResult result = rangeScanResult; Vector3 val; if (currentTarget != Entity.Null && SnapshotLookupByEntity.TryGetValue(currentTarget, out var value)) { result.FoundCurrentTarget = true; result.CurrentTargetAlive = (Object)(object)value.Unit != (Object)null && !value.Unit.dead; val = value.Position - hunterPosition; result.CurrentTargetSqrDistance = ((Vector3)(ref val)).sqrMagnitude; } for (int i = 0; i < enemies.Count; i++) { val = enemies[i].Position - hunterPosition; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude <= inRangeCutoffSq) { result.AnyInNear = true; } if (sqrMagnitude <= farMaxSq) { result.AnyInApproach = true; } if (result.AnyInNear && result.AnyInApproach) { break; } } return result; } private static bool ShouldSkipRetarget(Entity hunterEntity, Entity currentTarget, RangeScanResult rangeScan, float inRangeCutoffSq, float farMaxSq, float now, float retargetInterval) { //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_005e: Unknown result type (might be due to invalid IL or missing references) if (currentTarget == Entity.Null) { return false; } if (!rangeScan.FoundCurrentTarget || !rangeScan.CurrentTargetAlive) { return false; } if (rangeScan.AnyInNear && rangeScan.CurrentTargetSqrDistance > inRangeCutoffSq) { return false; } if (!rangeScan.AnyInNear && rangeScan.AnyInApproach && rangeScan.CurrentTargetSqrDistance > farMaxSq) { return false; } if (retargetInterval <= 0f || !LastRetargetTime.TryGetValue(hunterEntity, out var value) || now - value >= retargetInterval) { return false; } if (!rangeScan.AnyInNear && !rangeScan.AnyInApproach && rangeScan.CurrentTargetSqrDistance <= farMaxSq) { return false; } return true; } private static bool IsUrgentRetarget(Entity currentTarget, RangeScanResult rangeScan, float inRangeCutoffSq, float farMaxSq) { //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) if (currentTarget == Entity.Null) { return true; } if (!rangeScan.FoundCurrentTarget || !rangeScan.CurrentTargetAlive) { return true; } if (rangeScan.AnyInNear && rangeScan.CurrentTargetSqrDistance > inRangeCutoffSq) { return true; } if (!rangeScan.AnyInNear && rangeScan.AnyInApproach && rangeScan.CurrentTargetSqrDistance > farMaxSq) { return true; } return false; } private static void ForceIdleCustomHunter(EntityManager entityManager, HunterState hunter) { //IL_0002: 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_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_001b: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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) entityManager.SetComponentData(hunter.Entity, new HasTargetTag { Target = Entity.Null }); if (entityManager.HasComponent(hunter.Entity)) { entityManager.SetComponentData(hunter.Entity, TargetData.Null); } if (entityManager.HasComponent(hunter.Entity)) { entityManager.SetComponentData(hunter.Entity, new Velocity { Value = float3.zero }); } IdleCustomHunterEntities.Add(hunter.Entity); if ((Object)(object)hunter.Unit != (Object)null) { IdleCustomHunterUnits[hunter.Entity] = hunter.Unit; } } private static void EnsureRetargetBudget() { if (Time.frameCount != _retargetBudgetFrame) { _retargetBudgetFrame = Time.frameCount; _retargetBudgetRemaining = 32; } } private static void EnsureSnapshotsFresh(TeamSystem teamSystem, EntityManager entityManager, int liveUnitCount) { float time = Time.time; float num = 0.25f; int num2 = TeamSnapshots[0].Count + TeamSnapshots[1].Count; if (!(_lastSnapshotTime >= 0f) || !(time - _lastSnapshotTime < num) || _lastSnapshotUnitCount != liveUnitCount || num2 <= 0) { BuildTeamSnapshots(teamSystem, entityManager); RebuildSnapshotLookup(); _lastSnapshotTime = time; _lastSnapshotUnitCount = liveUnitCount; } } private static void RebuildSnapshotLookup() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) SnapshotLookupByEntity.Clear(); for (int i = 0; i < TeamSnapshots.Length; i++) { List list = TeamSnapshots[i]; for (int j = 0; j < list.Count; j++) { SnapshotLookupByEntity[list[j].Entity] = list[j]; } } } private static void BuildTeamSnapshots(TeamSystem teamSystem, EntityManager entityManager) { TeamSnapshots[0].Clear(); TeamSnapshots[1].Clear(); AddTeamSnapshot(teamSystem, entityManager, (Team)0, TeamSnapshots[0]); AddTeamSnapshot(teamSystem, entityManager, (Team)1, TeamSnapshots[1]); } private static void AddTeamSnapshot(TeamSystem teamSystem, EntityManager entityManager, Team team, List snapshot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_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_00c5: 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) List teamUnits = teamSystem.GetTeamUnits(team); if (teamUnits == null) { return; } for (int i = 0; i < teamUnits.Count; i++) { Unit val = teamUnits[i]; if (!((Object)(object)val == (Object)null) && !val.dead && EcsComponentHelper.TryGetEntityManager((Component)(object)val, out var entity, out var _)) { float targetPriority = 0.1f; if (EcsComponentHelper.TryGetComponentData(entityManager, entity, out TargetPriority data)) { targetPriority = Mathf.Max(data.Value, 0.1f); } float beingTargetedBy = 0f; if (EcsComponentHelper.TryGetComponentData(entityManager, entity, out BeingTargetedBy data2)) { beingTargetedBy = data2.Value; } float currentHealth = float.MaxValue; if (EcsComponentHelper.TryGetComponentData(entityManager, entity, out Health data3)) { currentHealth = data3.CurrentHealth; } snapshot.Add(new TeamEnemySnapshot { Entity = entity, Unit = val, Position = GetUnitPosition(val), Cost = GetUnitCost(entityManager, entity, val), CurrentHealth = currentHealth, IsRanged = UnitBlueprintCombatHelper.ClassifyIsRanged(val.unitBlueprint), TargetPriority = targetPriority, BeingTargetedBy = beingTargetedBy }); } } } private static void CollectHunters(List allUnits, EntityManager entityManager) { //IL_003b: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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) Hunters.Clear(); if (allUnits == null) { return; } for (int i = 0; i < allUnits.Count; i++) { Unit val = allUnits[i]; if (!((Object)(object)val == (Object)null) && !val.dead && EcsComponentHelper.TryGetEntityManager((Component)(object)val, out var entity, out var _) && TryGetTargetingMode(entityManager, entity, out var mode)) { Hunters.Add(new HunterState { Unit = val, Entity = entity, Team = val.Team, AttackRange = GetAttackRange(val, entityManager, entity), Position = GetUnitPosition(val), Mode = mode }); } } } private static bool TryGetTargetingMode(EntityManager entityManager, Entity entity, out CustomEnemyTargetingMode mode) { //IL_0001: 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_001d: Unknown result type (might be due to invalid IL or missing references) if (entityManager.HasComponent(entity)) { mode = CustomEnemyTargetingMode.MostExpensive; return true; } if (entityManager.HasComponent(entity)) { mode = CustomEnemyTargetingMode.LowestHealth; return true; } if (entityManager.HasComponent(entity)) { mode = CustomEnemyTargetingMode.RangedMixedOnly; return true; } mode = CustomEnemyTargetingMode.MostExpensive; return false; } private static bool TryPickTargetSinglePass(CustomEnemyTargetingMode mode, Vector3 hunterPosition, float attackRange, float inRangeCutoffSq, float farMaxSq, List enemies, bool anyInNear, out Entity targetEntity, out bool usedNearMode) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0207: 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_01a4: 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_018b: 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_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_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_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) targetEntity = Entity.Null; usedNearMode = anyInNear; Entity val = Entity.Null; float num = float.MinValue; Entity val2 = Entity.Null; float num2 = float.MinValue; Entity bestEntity = Entity.Null; float bestCost = float.MinValue; float bestSqrDistance = float.MaxValue; Entity bestEntity2 = Entity.Null; float bestHealth = float.MaxValue; float bestSqrDistance2 = float.MaxValue; Entity val3 = Entity.Null; float num3 = float.MaxValue; Entity val4 = Entity.Null; float num4 = float.MaxValue; for (int i = 0; i < enemies.Count; i++) { TeamEnemySnapshot candidate = enemies[i]; Vector3 val5 = candidate.Position - hunterPosition; float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude; if (sqrMagnitude <= inRangeCutoffSq) { float num5 = (0f - Mathf.Sqrt(sqrMagnitude)) / candidate.TargetPriority - candidate.BeingTargetedBy * attackRange * 0.05f; if (num5 > num) { num = num5; val = candidate.Entity; } if (candidate.IsRanged == false && num5 > num2) { num2 = num5; val2 = candidate.Entity; } } if (sqrMagnitude <= farMaxSq) { ConsiderHighestCost(candidate, sqrMagnitude, ref bestEntity, ref bestCost, ref bestSqrDistance); ConsiderLowestHealth(candidate, sqrMagnitude, ref bestEntity2, ref bestHealth, ref bestSqrDistance2); if (candidate.IsRanged != false && sqrMagnitude < num3) { num3 = sqrMagnitude; val3 = candidate.Entity; } if (sqrMagnitude < num4) { num4 = sqrMagnitude; val4 = candidate.Entity; } } } if (usedNearMode) { if (mode == CustomEnemyTargetingMode.RangedMixedOnly && val2 != Entity.Null) { targetEntity = val2; } else { targetEntity = val; } return targetEntity != Entity.Null; } switch (mode) { case CustomEnemyTargetingMode.MostExpensive: if (bestEntity != Entity.Null) { targetEntity = bestEntity; return true; } return false; case CustomEnemyTargetingMode.LowestHealth: if (bestEntity2 != Entity.Null) { targetEntity = bestEntity2; return true; } return false; case CustomEnemyTargetingMode.RangedMixedOnly: if (val3 != Entity.Null) { targetEntity = val3; return true; } if (val4 != Entity.Null) { targetEntity = val4; return true; } return false; default: return false; } } private static void ConsiderHighestCost(TeamEnemySnapshot candidate, float sqrDistance, ref Entity bestEntity, ref float bestCost, ref float bestSqrDistance) { //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) if (!(candidate.Cost < bestCost) && (!Mathf.Approximately(candidate.Cost, bestCost) || !(sqrDistance >= bestSqrDistance))) { bestCost = candidate.Cost; bestSqrDistance = sqrDistance; bestEntity = candidate.Entity; } } private static void ConsiderLowestHealth(TeamEnemySnapshot candidate, float sqrDistance, ref Entity bestEntity, ref float bestHealth, ref float bestSqrDistance) { //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) if (!(candidate.CurrentHealth > bestHealth) && (!Mathf.Approximately(candidate.CurrentHealth, bestHealth) || !(sqrDistance >= bestSqrDistance))) { bestHealth = candidate.CurrentHealth; bestSqrDistance = sqrDistance; bestEntity = candidate.Entity; } } private static void ApplyTarget(EntityManager entityManager, Entity hunterEntity, Entity targetEntity, bool usedNearMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0019: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_0046: 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_006b: 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) entityManager.SetComponentData(hunterEntity, new HasTargetTag { Target = targetEntity }); entityManager.SetComponentData(targetEntity, new IsTarget { Targetee = hunterEntity }); entityManager.SetComponentData(hunterEntity, new AttackThickness { Value = 0f }); if (usedNearMode && EcsComponentHelper.TryGetComponentData(entityManager, targetEntity, out BeingTargetedBy data)) { data.Value += 1f; entityManager.SetComponentData(targetEntity, data); } } private static (float nearFraction, float approachMultiplier) GetRangeProfile(CustomEnemyTargetingMode mode, float attackRange) { bool flag = attackRange <= 15f; if (mode == CustomEnemyTargetingMode.RangedMixedOnly) { if (!flag) { return (0.25f, 1.5f); } return (0.5f, 2.5f); } if (!flag) { return (0.5f, 1.5f); } return (0.75f, 2.5f); } private static float GetAttackRange(Unit hunter, EntityManager entityManager, Entity hunterEntity) { //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) if (EcsComponentHelper.TryGetComponentData(entityManager, hunterEntity, out Range data)) { return data.AttackRange; } if (!((Object)(object)hunter != (Object)null)) { return 1f; } return hunter.m_AttackDistance; } private static float GetUnitCost(EntityManager entityManager, Entity entity, Unit unit) { //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) if (EcsComponentHelper.TryGetComponentData(entityManager, entity, out UnitCost data)) { return data.Value; } UnitBlueprint val = unit?.unitBlueprint; if ((Object)(object)val == (Object)null) { return 0f; } if (BlueprintCostCache.TryGetValue(val, out var value)) { return value; } value = val.GetUnitCost(true); BlueprintCostCache[val] = value; return value; } private static Vector3 GetUnitPosition(Unit unit) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)unit?.data?.mainRig != (Object)null) { return unit.data.mainRig.position; } if (!((Object)(object)unit != (Object)null)) { return Vector3.zero; } return ((Component)unit).transform.position; } } internal enum CustomVoiceOverlayView { Hub, OggEditor } internal static class CustomVoiceEditorOverlay { private sealed class OggRowUi { internal string FileName; internal Button NormalButton; internal Button DeathButton; internal Text NormalLabel; internal Text DeathLabel; } [CompilerGenerated] private static class <>O { public static Action <0>__UpdateSummary; public static UnityAction <1>__ShowHub; public static UnityAction <2>__SavePack; public static UnityAction <3>__DeleteEditingPack; public static UnityAction <4>__ShowOggEditorNew; public static UnityAction <5>__Close; public static UnityAction <6>__OpenSourcesFolder; } private const float RowHeight = 48f; private const float HubHeaderHeight = 148f; private const float EditorHeaderHeight = 200f; private const float FooterHeight = 52f; private static readonly Color RowEven = new Color(0.11f, 0.11f, 0.11f, 0.92f); private static readonly Color RowOdd = new Color(0.145f, 0.145f, 0.145f, 0.92f); private static readonly Color ToggleOn = new Color(0.2f, 0.48f, 0.28f, 0.98f); private static readonly Color ToggleOff = new Color(0.18f, 0.18f, 0.18f, 0.96f); private static GameObject _canvasRoot; private static GameObject _panel; private static RectTransform _headerRect; private static RectTransform _scrollHostRect; private static Text _titleText; private static Text _instructionsText; private static Text _summaryText; private static InputField _searchField; private static RectTransform _searchRect; private static GameObject _packNameContainer; private static InputField _packNameField; private static Button _openFolderButton; private static Transform _listContent; private static ScrollRect _scrollRect; private static GameObject _footer; private static Button _footerPrimary; private static Button _footerSecondary; private static Button _footerDelete; private static Text _footerPrimaryLabel; private static Text _footerSecondaryLabel; private static CustomVoiceOverlayView _view = CustomVoiceOverlayView.Hub; private static string _search = string.Empty; private static string _editingPackId; private static readonly Dictionary NormalByFile = new Dictionary(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary DeathByFile = new Dictionary(StringComparer.OrdinalIgnoreCase); private static readonly List OggRows = new List(); internal static bool IsOpen { get { if ((Object)(object)_panel != (Object)null) { return _panel.activeSelf; } return false; } } internal static void Open() { if (UnitEditorConfig.CustomVoicesEnabled) { CustomVoiceStore.LoadAll(); EnsureBuilt(); _search = string.Empty; _editingPackId = null; if ((Object)(object)_searchField != (Object)null) { _searchField.text = string.Empty; } _canvasRoot.SetActive(true); _panel.SetActive(true); UpdateInstructions(); UpdateTabTitle(); ShowHub(); CustomVoiceOggCatalog.BeginRefresh(UpdateSummary); } } internal static void Close() { if ((Object)(object)_panel != (Object)null) { _panel.SetActive(false); } if ((Object)(object)_canvasRoot != (Object)null) { _canvasRoot.SetActive(false); } _editingPackId = null; NormalByFile.Clear(); DeathByFile.Clear(); } private static void ShowHub() { _view = CustomVoiceOverlayView.Hub; _editingPackId = null; NormalByFile.Clear(); DeathByFile.Clear(); RefreshUi(); } private static void ShowOggEditorNew() { _view = CustomVoiceOverlayView.OggEditor; _editingPackId = null; NormalByFile.Clear(); DeathByFile.Clear(); if ((Object)(object)_packNameField != (Object)null) { _packNameField.text = string.Empty; } BeginCatalogRefreshForEditor(); } private static void ShowOggEditorForEdit(CustomVoicePack pack) { if (pack == null) { return; } _view = CustomVoiceOverlayView.OggEditor; _editingPackId = pack.id; NormalByFile.Clear(); DeathByFile.Clear(); if (pack.vocalFiles != null) { for (int i = 0; i < pack.vocalFiles.Count; i++) { NormalByFile[pack.vocalFiles[i]] = true; } } if (pack.deathFiles != null) { for (int j = 0; j < pack.deathFiles.Count; j++) { DeathByFile[pack.deathFiles[j]] = true; } } if ((Object)(object)_packNameField != (Object)null) { _packNameField.text = pack.name ?? "Custom Voice"; } BeginCatalogRefreshForEditor(); } private static void BeginCatalogRefreshForEditor() { UpdateHeaderLayout(); UpdateInstructions(); ConfigureFooter(); ClearListRows(); UpdateSummary(); CustomVoiceOggCatalog.BeginRefresh(delegate { PruneIneligibleSelections(); RefreshUi(); }); } private static void PruneIneligibleSelections() { foreach (string item in NormalByFile.Keys.ToList()) { if (!CustomVoiceOggCatalog.IsFileEligible(item)) { NormalByFile[item] = false; } } foreach (string item2 in DeathByFile.Keys.ToList()) { if (!CustomVoiceOggCatalog.IsFileEligible(item2)) { DeathByFile[item2] = false; } } } private static void RefreshUi() { UpdateHeaderLayout(); UpdateInstructions(); ConfigureFooter(); ClearListRows(); UpdateSummary(); if (_view == CustomVoiceOverlayView.Hub) { BuildHubRows(); } else { BuildOggRows(); } if ((Object)(object)_scrollRect != (Object)null) { _scrollRect.verticalNormalizedPosition = 1f; } } private static void UpdateHeaderLayout() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) bool flag = _view == CustomVoiceOverlayView.OggEditor; float num = (flag ? 200f : 148f); if ((Object)(object)_headerRect != (Object)null) { _headerRect.sizeDelta = new Vector2(0f, num); } if ((Object)(object)_scrollHostRect != (Object)null) { _scrollHostRect.offsetMax = new Vector2(-8f, 0f - (num + 4f)); } if ((Object)(object)_packNameContainer != (Object)null) { _packNameContainer.SetActive(flag); } UpdateTabTitle(); UpdateInstructions(); if ((Object)(object)_openFolderButton != (Object)null) { ((Component)_openFolderButton).gameObject.SetActive(flag); } if ((Object)(object)_searchRect != (Object)null) { if (flag) { _searchRect.anchorMin = new Vector2(0f, 0f); _searchRect.anchorMax = new Vector2(0f, 0f); _searchRect.pivot = new Vector2(0f, 0f); _searchRect.anchoredPosition = new Vector2(16f, 12f); _searchRect.sizeDelta = new Vector2(360f, 32f); } else { _searchRect.anchorMin = new Vector2(0f, 0f); _searchRect.anchorMax = new Vector2(0f, 0f); _searchRect.pivot = new Vector2(0f, 0f); _searchRect.anchoredPosition = new Vector2(16f, 12f); _searchRect.sizeDelta = new Vector2(360f, 32f); } } if ((Object)(object)_instructionsText != (Object)null) { RectTransform component = ((Component)_instructionsText).GetComponent(); if (flag) { component.offsetMin = new Vector2(16f, -108f); component.offsetMax = new Vector2(-120f, -32f); } else { component.offsetMin = new Vector2(16f, -88f); component.offsetMax = new Vector2(-16f, -32f); } } if ((Object)(object)_titleText != (Object)null) { RectTransform component2 = ((Component)_titleText).GetComponent(); component2.offsetMin = new Vector2(16f, -8f); component2.offsetMax = new Vector2(-120f, -28f); } if ((Object)(object)_packNameContainer != (Object)null && flag) { RectTransform component3 = _packNameContainer.GetComponent(); component3.anchorMin = new Vector2(0f, 1f); component3.anchorMax = new Vector2(0f, 1f); component3.pivot = new Vector2(0f, 1f); component3.anchoredPosition = new Vector2(16f, -114f); component3.sizeDelta = new Vector2(280f, 24f); } if ((Object)(object)_summaryText != (Object)null) { RectTransform component4 = ((Component)_summaryText).GetComponent(); component4.anchorMin = new Vector2(0f, 0f); component4.anchorMax = new Vector2(0f, 0f); component4.pivot = new Vector2(0f, 0f); component4.anchoredPosition = new Vector2(392f, 12f); component4.sizeDelta = new Vector2(flag ? 280f : 360f, 32f); _summaryText.alignment = (TextAnchor)3; ((Component)_summaryText).gameObject.SetActive(true); } } private static void UpdateTabTitle() { if (!((Object)(object)_titleText == (Object)null)) { if (_view == CustomVoiceOverlayView.Hub) { _titleText.text = "CUSTOM VOICES"; } else if (!string.IsNullOrEmpty(_editingPackId)) { _titleText.text = "EDIT VOICE"; } else { _titleText.text = "MAKE NEW VOICE"; } } } private static void UpdateInstructions() { if (!((Object)(object)_instructionsText == (Object)null)) { if (_view == CustomVoiceOverlayView.Hub) { _instructionsText.text = "Make New Voice to create a pack. Equip applies a pack to your unit; Edit changes its sounds. Voice files live in CustomContent/voices — use Open File in the editor to add .ogg files."; } else { _instructionsText.text = "Type a name, then assign sounds below. Only .ogg files up to " + 7f.ToString("0.#") + " seconds appear here. Open File opens CustomContent/voices — copy .ogg files there, then press Back and re-enter to refresh. Delete removes a file from disk and all packs. Preview plays a file. Pick at least one Normal and one Death line before Save."; } } } private static void ConfigureFooter() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown if ((Object)(object)_footer == (Object)null) { return; } if (_view == CustomVoiceOverlayView.Hub) { _footer.SetActive(false); return; } _footer.SetActive(true); ((Component)_footerSecondary).gameObject.SetActive(true); ((Component)_footerPrimary).gameObject.SetActive(true); _footerSecondaryLabel.text = "Back"; _footerPrimaryLabel.text = "Save"; Button footerSecondary = _footerSecondary; object obj = <>O.<1>__ShowHub; if (obj == null) { UnityAction val = ShowHub; <>O.<1>__ShowHub = val; obj = (object)val; } UnitEditorUiText.ReplaceButtonClick(footerSecondary, (UnityAction)obj); Button footerPrimary = _footerPrimary; object obj2 = <>O.<2>__SavePack; if (obj2 == null) { UnityAction val2 = SavePack; <>O.<2>__SavePack = val2; obj2 = (object)val2; } UnitEditorUiText.ReplaceButtonClick(footerPrimary, (UnityAction)obj2); if (!((Object)(object)_footerDelete != (Object)null)) { return; } bool flag = !string.IsNullOrEmpty(_editingPackId); ((Component)_footerDelete).gameObject.SetActive(flag); if (flag) { Button footerDelete = _footerDelete; object obj3 = <>O.<3>__DeleteEditingPack; if (obj3 == null) { UnityAction val3 = DeleteEditingPack; <>O.<3>__DeleteEditingPack = val3; obj3 = (object)val3; } UnitEditorUiText.ReplaceButtonClick(footerDelete, (UnityAction)obj3); } } private static void BuildHubRows() { if (MatchesSearch("Make New Voice")) { CreateMakeNewHubRow(); } IReadOnlyList allPacks = CustomVoiceStore.AllPacks; for (int i = 0; i < allPacks.Count; i++) { CustomVoicePack customVoicePack = allPacks[i]; if (customVoicePack != null && MatchesSearch(customVoicePack.name)) { CreatePackHubRow(customVoicePack); } } } private static void CreateMakeNewHubRow() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown GameObject obj = CreateRowShell("MakeNew".GetHashCode()); Image component = obj.GetComponent(); ((Graphic)component).color = new Color(0.16f, 0.32f, 0.18f, 0.95f); CreateRowLabel(obj.transform, "Make New Voice", 16f, new Vector2(12f, 0f), new Vector2(-12f, 0f)); Button obj2 = obj.AddComponent