using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("MyGlobalSignalTower")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7248128407647e44ab6bc212ed8d9d298e2ee4b2")]
[assembly: AssemblyProduct("MyGlobalSignalTower")]
[assembly: AssemblyTitle("MyGlobalSignalTower")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MyGlobalSignalTower;
[BepInPlugin("com.myself.globalsignaltower", "Global Signal Tower Ultimate", "1.5.1")]
public class GlobalSignalTowerMod : BaseUnityPlugin
{
[HarmonyPatch(typeof(GameMain), "Begin")]
private class Patch_GameStart
{
[HarmonyPostfix]
private static void Postfix()
{
planetHashSystems.Clear();
lastStarId = -1;
}
}
[HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")]
private class Patch_Init
{
[HarmonyPostfix]
public static void Postfix()
{
ApplySettings();
}
}
[HarmonyPatch(typeof(CombatGroundSystem), "GameTick")]
public static class Patch_UpdateGlobalHash
{
[HarmonyPostfix]
public static void Postfix(long tick, bool isActive, CombatGroundSystem __instance)
{
if (__instance.factory != null && planetHashSystems.TryGetValue(__instance.factory.planetId, out var value))
{
value.GameTick();
MarkAllEnemies(__instance.factory);
}
}
}
[HarmonyPatch(typeof(TurretComponent), "Shoot_Plasma")]
public static class Patch_ExtendBulletLife
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
FieldInfo fieldInfo = AccessTools.Field(typeof(GeneralProjectile), "life");
FieldInfo fieldInfo2 = AccessTools.Field(typeof(GeneralProjectile), "lifemax");
int num = 300;
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Stfld, (object)fieldInfo, (string)null)
});
if (val.IsValid)
{
val.Advance(-1);
if (val.Opcode == OpCodes.Ldc_I4_S || val.Opcode == OpCodes.Ldc_I4)
{
val.SetAndAdvance(OpCodes.Ldc_I4, (object)num);
}
}
val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Stfld, (object)fieldInfo2, (string)null)
});
if (val.IsValid)
{
val.Advance(-1);
if (val.Opcode == OpCodes.Ldc_I4_S || val.Opcode == OpCodes.Ldc_I4)
{
val.SetAndAdvance(OpCodes.Ldc_I4, (object)num);
}
}
return val.InstructionEnumeration();
}
}
[HarmonyPatch(typeof(TurretComponent), "Shoot_Plasma")]
public static class Patch_IncreasePlasmaSpeed
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
while (val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((OpCode?)OpCodes.Ldc_R8, (object)20000.0, (string)null)
}).IsValid)
{
val.SetOperandAndAdvance((object)(double)Cfg_PlasmaMaxSpeed);
}
return val.InstructionEnumeration();
}
}
[HarmonyPatch(typeof(TurretComponent), "Search_Plasma")]
public static class Patch_PlasmaSearch
{
[HarmonyPostfix]
public static void Postfix(ref TurretComponent __instance, PlanetFactory factory, PrefabDesc pdesc)
{
//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_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_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: 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_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected I4, but got Unknown
//IL_006c: 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_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected I4, but got Unknown
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: 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)
if (!Cfg_EnablePlasmaTurretPatch.Value || __instance.target.id > 0 || !planetHashSystems.TryGetValue(factory.planetId, out var value))
{
return;
}
VSLayerMask vsCaps = __instance.vsCaps;
VSLayerMask vsSettings = __instance.vsSettings;
int num = (vsCaps & vsSettings & 0x30) >> 4;
int num2 = (vsCaps & vsSettings & 0xC0) >> 6;
if (num != 0 || num2 != 0)
{
Vector3 pos = factory.entityPool[__instance.entityId].pos;
double pDown = Math.Cos((double)(90f - pdesc.turretPitchDownMax) * 0.01745329238474369);
double pUp = Math.Cos((double)(90f + pdesc.turretPitchUpMax) * 0.01745329238474369);
IDPOS_Ex iDPOS_Ex = value.FindNearestSpaceEnemyFast(pos, pdesc.turretSpaceAttackRange, pDown, pUp, num > 0, num2 > 0);
if (iDPOS_Ex.id > 0)
{
Vector3 val = iDPOS_Ex.pos - pos;
float magnitude = ((Vector3)(ref val)).magnitude;
__instance.target.id = iDPOS_Ex.id;
__instance.target.astroId = iDPOS_Ex.originAstroId;
__instance.target.type = (ETargetType)4;
}
}
}
}
public static readonly object markLock = new object();
public static ConfigEntry<float> Cfg_PowerConnect;
public static ConfigEntry<float> Cfg_PowerCover;
public static ConfigEntry<float> Cfg_GroundSignalRange;
public static ConfigEntry<float> Cfg_SpaceSignalRange;
public static ConfigEntry<float> Cfg_BattleBasePickRange;
public static ConfigEntry<float> Cfg_BattleBaseConstructRange;
public static ConfigEntry<float> Cfg_GaussTurretAttackRange;
public static float Cfg_PlasmaMaxSpeed;
public static ConfigEntry<bool> Cfg_EnableMarkAll;
public static ConfigEntry<bool> Cfg_EnablePlasmaTurretPatch;
private static int lastStarId = -1;
private static int update_frame_counter = 0;
private const int REFRESH_INTERVAL = 60;
private const int LIFE_TICK = 120;
public static Dictionary<int, GlobalEnemyHashSystem> planetHashSystems = new Dictionary<int, GlobalEnemyHashSystem>();
public static ConfigEntry<bool> Cfg_LockInsideLoop;
private void Awake()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Expected O, but got Unknown
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Expected O, but got Unknown
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Expected O, but got Unknown
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Expected O, but got Unknown
//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
Cfg_PowerConnect = ((BaseUnityPlugin)this).Config.Bind<float>("1. 信号塔", "电力连接距离", 60f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(100f, 700f), Array.Empty<object>()));
Cfg_PowerCover = ((BaseUnityPlugin)this).Config.Bind<float>("1. 信号塔", "电力覆盖半径", 60f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(100f, 700f), Array.Empty<object>()));
Cfg_GroundSignalRange = ((BaseUnityPlugin)this).Config.Bind<float>("1. 信号塔", "地面信号范围", 600f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(50f, 700f), Array.Empty<object>()));
Cfg_SpaceSignalRange = ((BaseUnityPlugin)this).Config.Bind<float>("1. 信号塔", "太空信号范围", 7000f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(50f, 7000f), Array.Empty<object>()));
Cfg_BattleBasePickRange = ((BaseUnityPlugin)this).Config.Bind<float>("2. 战场基站", "拾取范围", 600f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(100f, 700f), Array.Empty<object>()));
Cfg_BattleBaseConstructRange = ((BaseUnityPlugin)this).Config.Bind<float>("2. 战场基站", "建造范围", 600f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(50f, 700f), Array.Empty<object>()));
Cfg_GaussTurretAttackRange = ((BaseUnityPlugin)this).Config.Bind<float>("3. 炮塔增强", "通用攻击范围", 100000f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10000f, 100000f), Array.Empty<object>()));
Cfg_PlasmaMaxSpeed = Cfg_GaussTurretAttackRange.Value / 5f;
Cfg_EnableMarkAll = ((BaseUnityPlugin)this).Config.Bind<bool>("4. 开关", "启用全局标记", true, "");
Cfg_EnablePlasmaTurretPatch = ((BaseUnityPlugin)this).Config.Bind<bool>("4. 开关", "启用电浆炮增强", true, "");
Cfg_LockInsideLoop = ((BaseUnityPlugin)this).Config.Bind<bool>("5. 性能优化", "标记逻辑使用内层锁", false, "false: 循环外加锁(推荐,性能高); true: 循环内加锁(兼容性好)");
Cfg_PowerConnect.SettingChanged += delegate
{
ApplySettings();
};
Cfg_PowerCover.SettingChanged += delegate
{
ApplySettings();
};
Cfg_GroundSignalRange.SettingChanged += delegate
{
ApplySettings();
};
Cfg_SpaceSignalRange.SettingChanged += delegate
{
ApplySettings();
};
Cfg_BattleBasePickRange.SettingChanged += delegate
{
ApplySettings();
};
Cfg_BattleBaseConstructRange.SettingChanged += delegate
{
ApplySettings();
};
Cfg_GaussTurretAttackRange.SettingChanged += delegate
{
ApplySettings();
};
Cfg_EnableMarkAll.SettingChanged += delegate
{
ApplyMarkAllSettings();
};
Cfg_EnablePlasmaTurretPatch.SettingChanged += delegate
{
ApplyPlasmaPatchSettings();
};
Cfg_LockInsideLoop.SettingChanged += delegate
{
};
new Harmony("com.myself.globalsignaltower").PatchAll();
}
private void Update()
{
if (!((Object)(object)GameMain.instance == (Object)null) && !GameMain.isPaused && GameMain.isRunning)
{
ManageHashSystems();
update_frame_counter++;
if (update_frame_counter >= 60)
{
update_frame_counter = 0;
RefreshBattleBaseRanges();
}
}
}
private void ManageHashSystems()
{
int num = GameMain.localStar?.id ?? (-1);
if (num == -1 || num == lastStarId)
{
return;
}
lastStarId = num;
planetHashSystems.Clear();
GameData data = GameMain.data;
if (data == null || data.factoryCount <= 0)
{
return;
}
for (int i = 0; i < GameMain.data.factoryCount; i++)
{
PlanetFactory val = GameMain.data.factories[i];
if (val != null && val.planet?.star?.id == num)
{
planetHashSystems[val.planetId] = new GlobalEnemyHashSystem(val);
}
}
}
public static void MarkAllEnemies(PlanetFactory factory)
{
if (!Cfg_EnableMarkAll.Value || factory == null || !TryGetBeaconPosition(factory, out var _) || !planetHashSystems.TryGetValue(factory.planetId, out var value))
{
return;
}
DefenseSystem defenseSystem = factory.defenseSystem;
if (defenseSystem == null)
{
return;
}
if (!Cfg_LockInsideLoop.Value)
{
lock (markLock)
{
value.MarkAllEnemiesSpliced(defenseSystem, 120, useInternalLock: false);
return;
}
}
value.MarkAllEnemiesSpliced(defenseSystem, 120, useInternalLock: true);
}
public static bool TryGetBeaconPosition(PlanetFactory factory, out Vector3 beaconPos)
{
//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_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)
beaconPos = Vector3.zero;
if (factory.defenseSystem?.beacons?.buffer == null)
{
return false;
}
BeaconComponent[] buffer = factory.defenseSystem.beacons.buffer;
int cursor = factory.defenseSystem.beacons.cursor;
for (int i = 1; i < cursor; i++)
{
if (buffer[i].id == i && buffer[i].entityId > 0)
{
beaconPos = factory.entityPool[buffer[i].entityId].pos;
return true;
}
}
return false;
}
public static void ApplySettings()
{
ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(3007);
if (val?.prefabDesc != null)
{
val.prefabDesc.powerConnectDistance = Cfg_PowerConnect.Value;
val.prefabDesc.powerCoverRadius = Cfg_PowerCover.Value;
val.prefabDesc.beaconSignalRadius = Cfg_GroundSignalRange.Value;
}
ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(3008);
if (val2?.prefabDesc != null)
{
val2.prefabDesc.powerConnectDistance = Cfg_PowerConnect.Value;
val2.prefabDesc.powerCoverRadius = Cfg_PowerCover.Value;
val2.prefabDesc.beaconSignalRadius = Cfg_SpaceSignalRange.Value;
}
ItemProto val3 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(3009);
if (val3?.prefabDesc != null)
{
val3.prefabDesc.battleBasePickRange = Cfg_BattleBasePickRange.Value;
val3.prefabDesc.constructionRange = Cfg_BattleBaseConstructRange.Value;
}
ItemProto val4 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(3004);
if (val4?.prefabDesc != null)
{
val4.prefabDesc.turretSpaceAttackRange = Cfg_GaussTurretAttackRange.Value;
val4.prefabDesc.turretMaxAttackRange = Cfg_GaussTurretAttackRange.Value;
val4.prefabDesc.turretPitchUpMax = 89f;
val4.prefabDesc.turretPitchDownMax = 0f;
}
}
private static void ApplyMarkAllSettings()
{
}
private static void ApplyPlasmaPatchSettings()
{
}
private void RefreshBattleBaseRanges()
{
PlanetFactory val = GameMain.localPlanet?.factory;
if (val?.defenseSystem?.battleBases?.buffer == null)
{
return;
}
BattleBaseComponent[] buffer = val.defenseSystem.battleBases.buffer;
int cursor = val.defenseSystem.battleBases.cursor;
for (int i = 1; i < cursor; i++)
{
if (buffer[i].id == i)
{
buffer[i].pickRange = Cfg_BattleBasePickRange.Value;
buffer[i].constructRange = Cfg_BattleBaseConstructRange.Value;
}
}
}
}
public struct IDPOS_Ex
{
public int id;
public int originAstroId;
public Vector3 pos;
public bool isSpaceUnit;
public IDPOS_Ex(int id, int originAstroId, Vector3 pos, bool isSpace)
{
//IL_0010: 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)
this.id = id;
this.originAstroId = originAstroId;
this.pos = pos;
isSpaceUnit = isSpace;
}
}
public class GlobalEnemyHashSystem
{
private PlanetFactory factory;
private SpaceSector sector;
private PlanetData planetData;
private const int LEVEL_COUNT = 9;
public static readonly double[] LEVEL_OFFSETS_SQR = new double[9] { 0.0, 4000000.0, 9000000.0, 25000000.0, 49000000.0, 196000000.0, 784000000.0, 3136000000.0, 10000000000.0 };
private const double MAX_DIST_SQR = 10000000000.0;
private IDPOS_Ex[] hashDatas;
private IDPOS_Ex[] tmp_datas;
private int[] dataCursors;
private int[] tmp_cursors;
private bool[] old_ids_space;
private bool[] old_ids_ground;
private int currentMarkLevel = 0;
private int currentMarkIndex = 0;
private int capacityPerLevel = 4096;
private int groundScanCursor = 1;
private int spaceScanCursor = 1;
private VectorLF3 cachedPlanetUPos;
private Quaternion cachedPlanetURot;
public GlobalEnemyHashSystem(PlanetFactory factory)
{
this.factory = factory;
sector = factory.sector;
planetData = factory.planet;
int num = capacityPerLevel * 9;
hashDatas = new IDPOS_Ex[num];
tmp_datas = new IDPOS_Ex[num];
dataCursors = new int[9];
tmp_cursors = new int[9];
old_ids_space = new bool[65536];
old_ids_ground = new bool[65536];
}
public void GameTick()
{
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
if (factory == null || sector == null)
{
return;
}
IDPOS_Ex[] array = tmp_datas;
tmp_datas = hashDatas;
hashDatas = array;
int[] array2 = tmp_cursors;
tmp_cursors = dataCursors;
dataCursors = array2;
Array.Clear(hashDatas, 0, hashDatas.Length);
Array.Clear(dataCursors, 0, dataCursors.Length);
Array.Clear(old_ids_space, 0, 65536);
Array.Clear(old_ids_ground, 0, 65536);
cachedPlanetUPos = planetData.uPosition;
cachedPlanetURot = planetData.runtimeRotation;
int astroId = planetData.astroId;
for (int i = 0; i < 9; i++)
{
int num = i * capacityPerLevel;
int num2 = num + tmp_cursors[i];
for (int j = num; j < num2; j++)
{
IDPOS_Ex iDPOS_Ex = tmp_datas[j];
if (iDPOS_Ex.id != 0 && TryAddEnemy(iDPOS_Ex.id, iDPOS_Ex.originAstroId, astroId, iDPOS_Ex.isSpaceUnit))
{
if (iDPOS_Ex.isSpaceUnit)
{
old_ids_space[iDPOS_Ex.id] = true;
}
else
{
old_ids_ground[iDPOS_Ex.id] = true;
}
}
}
}
ScanNewGroundEnemies(astroId);
ScanNewSpaceEnemies(astroId);
}
private bool TryAddEnemy(int id, int originAstroId, int currentAstroId, bool isSpace)
{
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
EnemyData[] array = (isSpace ? sector.enemyPool : factory.enemyPool);
if (array == null || id < 0 || id >= array.Length)
{
return false;
}
ref EnemyData reference = ref array[id];
if (reference.id != id || ((EnemyData)(ref reference)).isInvincible)
{
return false;
}
if (reference.combatStatId > 0 && factory.skillSystem.combatStats.buffer[reference.combatStatId].hp <= 0)
{
return false;
}
VectorLF3 val = default(VectorLF3);
if (reference.astroId == 0)
{
val = reference.pos;
}
else if (reference.astroId == currentAstroId)
{
val = cachedPlanetUPos + Maths.QRotateLF(cachedPlanetURot, reference.pos);
}
else
{
sector.TransformFromAstro_ref(reference.astroId, ref val, ref reference.pos);
}
VectorLF3 val2 = val - cachedPlanetUPos;
double sqrMagnitude = ((VectorLF3)(ref val2)).sqrMagnitude;
if (sqrMagnitude > 10000000000.0)
{
return false;
}
int num = 0;
for (int num2 = 8; num2 >= 0; num2--)
{
if (sqrMagnitude >= LEVEL_OFFSETS_SQR[num2])
{
num = num2;
break;
}
}
if (dataCursors[num] < capacityPerLevel)
{
VectorLF3 val3 = default(VectorLF3);
sector.InverseTransformToAstro_ref(currentAstroId, ref val, ref val3);
int num3 = num * capacityPerLevel + dataCursors[num];
hashDatas[num3] = new IDPOS_Ex(id, originAstroId, VectorLF3.op_Implicit(val3), reference.isSpace);
dataCursors[num]++;
return true;
}
return false;
}
private void ScanNewGroundEnemies(int currentAstroId)
{
EnemyData[] enemyPool = factory.enemyPool;
int enemyCursor = factory.enemyCursor;
if (enemyCursor <= 1)
{
return;
}
for (int i = 0; i < 500; i++)
{
groundScanCursor++;
if (groundScanCursor >= enemyCursor)
{
groundScanCursor = 1;
}
if (!old_ids_ground[groundScanCursor])
{
ref EnemyData reference = ref enemyPool[groundScanCursor];
if (reference.id == groundScanCursor && reference.id != 0)
{
TryAddEnemy(reference.id, reference.originAstroId, currentAstroId, isSpace: false);
}
}
}
}
private void ScanNewSpaceEnemies(int currentAstroId)
{
EnemyData[] enemyPool = sector.enemyPool;
int enemyCursor = sector.enemyCursor;
if (enemyCursor <= 1)
{
return;
}
for (int i = 0; i < 500; i++)
{
spaceScanCursor++;
if (spaceScanCursor >= enemyCursor)
{
spaceScanCursor = 1;
}
if (!old_ids_space[spaceScanCursor])
{
ref EnemyData reference = ref enemyPool[spaceScanCursor];
if (reference.id == spaceScanCursor && reference.id != 0)
{
TryAddEnemy(reference.id, reference.originAstroId, currentAstroId, isSpace: true);
}
}
}
}
public void MarkAllEnemiesSpliced(DefenseSystem ds, int lifeTick, bool useInternalLock)
{
//IL_00fc: 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)
int num = 1;
int num2 = 0;
for (int i = 0; i <= num; i++)
{
num2 += dataCursors[i];
}
if (num2 == 0)
{
return;
}
int num3 = num2 / 600 + 1;
for (int j = 0; j < num3; j++)
{
if (currentMarkIndex >= dataCursors[currentMarkLevel])
{
currentMarkIndex = 0;
currentMarkLevel++;
if (currentMarkLevel > num)
{
currentMarkLevel = 0;
}
continue;
}
int num4 = currentMarkLevel * capacityPerLevel + currentMarkIndex;
IDPOS_Ex iDPOS_Ex = hashDatas[num4];
if (iDPOS_Ex.id != 0 && (iDPOS_Ex.isSpaceUnit ? (currentMarkLevel <= 3) : (currentMarkLevel == 0)))
{
TimedSkillTarget val = default(TimedSkillTarget);
val.id = iDPOS_Ex.id;
val.astroId = iDPOS_Ex.originAstroId;
val.type = (ETargetType)4;
val.lifeTick = lifeTick;
if (useInternalLock)
{
lock (GlobalSignalTowerMod.markLock)
{
ds.AddGlobalTargets(ref val);
}
}
else
{
ds.AddGlobalTargets(ref val);
}
}
currentMarkIndex++;
}
}
public IDPOS_Ex FindNearestSpaceEnemyFast(Vector3 muzzlePos, float maxRange, double pDown, double pUp, bool relay, bool space)
{
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
float num = maxRange * maxRange;
EnemyData[] enemyPool = sector.enemyPool;
CombatStat[] buffer = factory.skillSystem.combatStats.buffer;
for (int i = 0; i < 8; i++)
{
int num2 = i * capacityPerLevel;
int num3 = num2 + dataCursors[i];
for (int j = num2; j < num3; j++)
{
IDPOS_Ex result = hashDatas[j];
if (!result.isSpaceUnit)
{
continue;
}
ref EnemyData reference = ref enemyPool[result.id];
if ((reference.combatStatId > 0 && (float)(buffer[reference.combatStatId].hp + buffer[reference.combatStatId].hpIncoming) / (float)buffer[reference.combatStatId].hpMax < -0.01f) || reference.id != result.id || ((EnemyData)(ref reference)).isInvincible)
{
continue;
}
bool flag = !reference.isSpace;
if ((!flag || relay) && (flag || space))
{
Vector3 val = result.pos - muzzlePos;
float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
if (!(sqrMagnitude > num) && InternalCheckPitch(result.pos, muzzlePos, pDown, pUp))
{
return result;
}
}
}
}
return default(IDPOS_Ex);
}
private bool InternalCheckPitch(Vector3 enemyPos, Vector3 muzzlePos, double pDown, double pUp)
{
//IL_0001: 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_0019: 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_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
float num = 0f - muzzlePos.x;
float num2 = 0f - muzzlePos.y;
float num3 = 0f - muzzlePos.z;
float num4 = enemyPos.x - muzzlePos.x;
float num5 = enemyPos.y - muzzlePos.y;
float num6 = enemyPos.z - muzzlePos.z;
float num7 = (float)Math.Sqrt(num * num + num2 * num2 + num3 * num3);
float num8 = (float)Math.Sqrt(num4 * num4 + num5 * num5 + num6 * num6);
double num9 = (num * num4 + num2 * num5 + num3 * num6) / (num7 * num8);
if (num9 < -1.0)
{
num9 = -1.0;
}
else if (num9 > 1.0)
{
num9 = 1.0;
}
return num9 <= pDown - 1E-06 && num9 >= pUp + 1E-06;
}
public IDPOS_Ex[] GetHashDatas()
{
return hashDatas;
}
public int[] GetDataCursors()
{
return dataCursors;
}
public int GetCapacityPerLevel()
{
return capacityPerLevel;
}
public int GetTotalCount()
{
int num = 0;
for (int i = 0; i < 9; i++)
{
num += dataCursors[i];
}
return num;
}
}