using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("BattlefieldAnalysisBaseCollectSpaceJunk")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Collect space fleet debris into battlefield analysis bases.")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2+5dff026d59b0dc1bc21c3692e58e55f5b0546f91")]
[assembly: AssemblyProduct("BattlefieldAnalysisBaseCollectSpaceJunk")]
[assembly: AssemblyTitle("BattlefieldAnalysisBaseCollectSpaceJunk")]
[assembly: AssemblyVersion("1.2.2.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[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 BattlefieldAnalysisBaseCollectSpaceJunk
{
[BepInPlugin("un1eagle.battlefieldanalysisbasecollectspacejunk", "战场分析基站收集太空残骸", "1.2.2")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource? Log;
internal static Plugin? Instance;
private static ConfigEntry<bool>? _enableDebugLog;
internal const int SpaceDropRollCount = 20;
private static ConfigEntry<int>? _spaceDropCountMultiplier;
internal const int SpaceCraftEnemyLevelFallback = 18;
private const float LandOffsetMin = 8f;
private const float LandOffsetMax = 22f;
internal const double FallDurationSeconds = 10.0;
internal const double GameTicksPerSecond = 1.0;
internal const double MinFallSpeed = 30.0;
internal const double SpeedLimitHeight = 30.0;
internal const double SpeedAtTargetHeight = 30.0;
internal const double HandoffMaxHeight = 10.0;
internal const double SafeLandingSpeed = 25.0;
internal const double AlphaMin = 1.01;
internal const double AlphaMax = 80.0;
internal const double CurveClearanceMargin = 1200.0;
internal const double PlanetVelBlendHeight = 500.0;
private const int SpaceDropBaseLifeTicks = 2400;
private const double TrailMaxDistFromLocalPlanet = 2000000.0;
internal const int MaxTrashPerPlanet = 2000;
internal static int _currentPlanetSpawnQuota = -1;
private static uint _spaceDropSeed = 12345u;
private bool _hasLoggedEnemyDropTable;
internal static readonly HashSet<int> _everDroppedItemIds = new HashSet<int>();
private static HashSet<int>? _droppableItemIdsCache;
internal readonly List<(int trashIndex, GameObject? trailGo, float landedAt, Vector3 targetLandPosLocal, double spawnGameTime, VectorLF3 spawnPos)> _trashTrails = new List<(int, GameObject, float, Vector3, double, VectorLF3)>();
private const float TrailDestroyDelayAfterLand = 2.5f;
internal static readonly List<(int index, int targetAstroId)> _ourSpaceTrashTargets = new List<(int, int)>();
internal static bool EnableDebugLog => _enableDebugLog?.Value ?? false;
internal static int SpaceDropCountMultiplier => _spaceDropCountMultiplier?.Value ?? 100;
internal static HashSet<int> GetDroppableItemIds()
{
if (_droppableItemIdsCache != null)
{
return _droppableItemIdsCache;
}
HashSet<int> hashSet = new HashSet<int>();
ItemProto[] array = ((ProtoSet<ItemProto>)(object)LDB.items)?.dataArray;
if (array != null)
{
foreach (ItemProto val in array)
{
if (val != null && val.EnemyDropRange.y > 5E-05f)
{
hashSet.Add(((Proto)val).ID);
}
}
}
_droppableItemIdsCache = hashSet;
return hashSet;
}
private void Awake()
{
//IL_0057: 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_006c: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
Instance = this;
_enableDebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableDebugLog", false, "为 true 时在日志中输出详细的调试信息,用于排查问题。正常使用时建议设置为 false。\nSetting type: Boolean\nDefault value: false");
_spaceDropCountMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SpaceDropCountMultiplier", 100, "太空舰船掉落数量倍数(地面为基础值)。默认 100,可调高增加掉落量或调低减少。\nSetting type: Integer\nDefault value: 100");
Harmony val = new Harmony("un1eagle.battlefieldanalysisbasecollectspacejunk");
val.PatchAll(typeof(SpaceCraftDeathPatch));
val.PatchAll(typeof(SpaceEnemyDeathPatch));
val.PatchAll(typeof(TrashSystemGravityPatch));
Log.LogInfo((object)"[战场分析基站收集太空残骸] 加载中 (GUID: un1eagle.battlefieldanalysisbasecollectspacejunk)");
if (EnableDebugLog)
{
Log.LogInfo((object)string.Format("[{0}] 击毁黑雾太空飞船时,按地面掉落表抽选 {1} 次、数量×{2},掉落等级取自巢穴 evolve.level(无巢穴或玩家舰船击毁时用 fallback={3}),从飞船位置坠向战场基站。", "战场分析基站收集太空残骸", 20, SpaceDropCountMultiplier, 18));
}
}
private void Update()
{
if (EnableDebugLog && !_hasLoggedEnemyDropTable && ((ProtoSet<ItemProto>)(object)LDB.items)?.dataArray != null)
{
LogEnemyDropTable();
_hasLoggedEnemyDropTable = true;
}
UpdateTrashTrails();
}
private void OnDestroy()
{
for (int i = 0; i < _trashTrails.Count; i++)
{
DestroyTrailGameObject(_trashTrails[i].trailGo);
}
_trashTrails.Clear();
}
private void LogEnemyDropTable()
{
try
{
ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray;
List<string> list = new List<string>();
foreach (ItemProto val in dataArray)
{
if (val != null && !(val.EnemyDropRange.y <= 5E-05f))
{
string text = ((Proto)val).name ?? $"id={((Proto)val).ID}";
list.Add($"{((Proto)val).ID}|{text}|Range=({val.EnemyDropRange.x:F4},{val.EnemyDropRange.y:F4})|Count={val.EnemyDropCount:F2}|Level={val.EnemyDropLevel}|Mask={val.EnemyDropMask}|MaskRatio={val.EnemyDropMaskRatio:F2}");
}
}
ManualLogSource? log = Log;
if (log != null)
{
log.LogInfo((object)string.Format("[{0}] ====== 地面黑雾敌人掉落表 (EnemyDropRange.y>0) 共 {1} 项 ======", "战场分析基站收集太空残骸", list.Count));
}
ManualLogSource? log2 = Log;
if (log2 != null)
{
log2.LogInfo((object)"[战场分析基站收集太空残骸] 格式: itemId|名称|Range(起点,宽度)|基础数量|等级|Mask|MaskRatio");
}
foreach (string item in list)
{
ManualLogSource? log3 = Log;
if (log3 != null)
{
log3.LogInfo((object)("[战场分析基站收集太空残骸] " + item));
}
}
ManualLogSource? log4 = Log;
if (log4 != null)
{
log4.LogInfo((object)"[战场分析基站收集太空残骸] ====== 掉落表结束 ======");
}
}
catch (Exception ex)
{
ManualLogSource? log5 = Log;
if (log5 != null)
{
log5.LogError((object)("[战场分析基站收集太空残骸] LogEnemyDropTable 异常: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
private void UpdateTrashTrails()
{
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
if (GameMain.data?.trashSystem?.container == null)
{
return;
}
TrashContainer container = GameMain.data.trashSystem.container;
TrashObject[] trashObjPool = container.trashObjPool;
TrashData[] trashDataPool = container.trashDataPool;
GameData data = GameMain.data;
for (int num = _trashTrails.Count - 1; num >= 0; num--)
{
int item = _trashTrails[num].trashIndex;
GameObject item2 = _trashTrails[num].trailGo;
float num2 = _trashTrails[num].landedAt;
if (item < 0 || item >= trashObjPool.Length)
{
DestroyTrailGameObject(item2);
_trashTrails.RemoveAt(num);
}
else if (trashObjPool[item].item == 0)
{
DestroyTrailGameObject(item2);
_trashTrails.RemoveAt(num);
}
else if (!((Object)(object)item2 == (Object)null))
{
if (trashDataPool[item].landPlanetId != 0)
{
if (num2 < 0f)
{
num2 = Time.time;
_trashTrails[num] = (item, item2, num2, _trashTrails[num].targetLandPosLocal, _trashTrails[num].spawnGameTime, _trashTrails[num].spawnPos);
ParticleSystem component = item2.GetComponent<ParticleSystem>();
if ((Object)(object)component != (Object)null)
{
EmissionModule emission = component.emission;
if (((EmissionModule)(ref emission)).enabled)
{
((EmissionModule)(ref emission)).enabled = false;
}
}
}
if (Time.time - num2 >= 2.5f)
{
DestroyTrailGameObject(item2);
_trashTrails.RemoveAt(num);
}
}
else
{
VectorLF3 uPos = trashDataPool[item].uPos;
Vector3 position = VectorLF3.op_Implicit(Maths.QInvRotateLF(data.relativeRot, uPos - data.relativePos));
item2.transform.position = position;
}
}
}
}
private void DestroyTrailGameObject(GameObject? go)
{
if (!((Object)(object)go == (Object)null))
{
ParticleSystemRenderer component = go.GetComponent<ParticleSystemRenderer>();
if ((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).material != (Object)null)
{
Object.Destroy((Object)(object)((Renderer)component).material);
}
Object.Destroy((Object)(object)go);
}
}
private GameObject CreateTrailParticle()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: 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_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Expected O, but got Unknown
//IL_0116: 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_0125: 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_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_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: 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_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: 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)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: 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_0238: Expected O, but got Unknown
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Expected O, but got Unknown
GameObject val = new GameObject("TrashTrail");
if ((Object)(object)VFEffect.effectGroup != (Object)null)
{
val.transform.SetParent(VFEffect.effectGroup, false);
}
val.transform.localPosition = Vector3.zero;
ParticleSystem val2 = val.AddComponent<ParticleSystem>();
MainModule main = val2.main;
((MainModule)(ref main)).loop = true;
((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.55f);
((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.28f);
((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
((MainModule)(ref main)).maxParticles = 1500;
EmissionModule emission = val2.emission;
((EmissionModule)(ref emission)).enabled = true;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(400f);
ShapeModule shape = val2.shape;
((ShapeModule)(ref shape)).enabled = true;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
((ShapeModule)(ref shape)).angle = 15f;
((ShapeModule)(ref shape)).radius = 0.15f;
ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
Gradient val3 = new Gradient();
val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
{
new GradientColorKey(new Color(1f, 0.7f, 0.2f), 0f),
new GradientColorKey(new Color(1f, 0.4f, 0f), 0.4f),
new GradientColorKey(new Color(0.3f, 0.1f, 0f), 1f)
}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
{
new GradientAlphaKey(0.8f, 0f),
new GradientAlphaKey(0.3f, 0.6f),
new GradientAlphaKey(0f, 1f)
});
((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime;
((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
{
new Keyframe(0f, 1f),
new Keyframe(0.5f, 0.6f),
new Keyframe(1f, 0f)
}));
ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
if ((Object)(object)component != (Object)null)
{
((Renderer)component).material = new Material(Shader.Find("Particles/Standard Unlit"));
}
val2.Play();
return val;
}
private static bool ShouldSpawnTrailForDrop(PlanetData planet, VectorLF3 deathPos)
{
//IL_0031: 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_0056: Unknown result type (might be due to invalid IL or missing references)
if (GameMain.localStar == null || planet.star != GameMain.localStar)
{
return false;
}
PlanetData localPlanet = GameMain.localPlanet;
if (localPlanet == null)
{
return true;
}
if (planet.id == localPlanet.id)
{
return true;
}
double num = deathPos.x - localPlanet.uPosition.x;
double num2 = deathPos.y - localPlanet.uPosition.y;
double num3 = deathPos.z - localPlanet.uPosition.z;
return num * num + num2 * num2 + num3 * num3 <= 4000000000000.0;
}
internal static int CountTrashForPlanet(PlanetData planet)
{
if (planet == null)
{
return 0;
}
TrashContainer val = GameMain.data?.trashSystem?.container;
if (val?.trashObjPool == null)
{
return 0;
}
TrashObject[] trashObjPool = val.trashObjPool;
int astroId = planet.astroId;
for (int num = _ourSpaceTrashTargets.Count - 1; num >= 0; num--)
{
int item = _ourSpaceTrashTargets[num].index;
if (item < 0 || item >= trashObjPool.Length || trashObjPool[item].item == 0)
{
_ourSpaceTrashTargets.RemoveAt(num);
}
}
int num2 = 0;
for (int i = 0; i < _ourSpaceTrashTargets.Count; i++)
{
if (_ourSpaceTrashTargets[i].targetAstroId == astroId)
{
num2++;
}
}
return num2;
}
internal static void SpawnTrashAtDeathPosition(VectorLF3 deathPos, int itemId, int count)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_02af: 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_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
//IL_0379: Unknown result type (might be due to invalid IL or missing references)
//IL_0384: Unknown result type (might be due to invalid IL or missing references)
//IL_038b: Unknown result type (might be due to invalid IL or missing references)
//IL_0396: Unknown result type (might be due to invalid IL or missing references)
//IL_039d: Unknown result type (might be due to invalid IL or missing references)
//IL_0401: Unknown result type (might be due to invalid IL or missing references)
//IL_0459: Unknown result type (might be due to invalid IL or missing references)
//IL_045e: Unknown result type (might be due to invalid IL or missing references)
//IL_0465: Unknown result type (might be due to invalid IL or missing references)
//IL_046a: Unknown result type (might be due to invalid IL or missing references)
//IL_0471: Unknown result type (might be due to invalid IL or missing references)
//IL_0472: Unknown result type (might be due to invalid IL or missing references)
//IL_0479: Unknown result type (might be due to invalid IL or missing references)
//IL_047e: Unknown result type (might be due to invalid IL or missing references)
//IL_0482: Unknown result type (might be due to invalid IL or missing references)
//IL_0487: Unknown result type (might be due to invalid IL or missing references)
//IL_048c: Unknown result type (might be due to invalid IL or missing references)
//IL_0493: Unknown result type (might be due to invalid IL or missing references)
//IL_0495: Unknown result type (might be due to invalid IL or missing references)
//IL_049c: Unknown result type (might be due to invalid IL or missing references)
//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
//IL_050a: Unknown result type (might be due to invalid IL or missing references)
//IL_050c: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: 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_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0552: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: 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_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: 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_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0580: Unknown result type (might be due to invalid IL or missing references)
//IL_0586: Unknown result type (might be due to invalid IL or missing references)
//IL_0599: Unknown result type (might be due to invalid IL or missing references)
if (GameMain.data?.trashSystem?.container == null || itemId <= 0 || count <= 0 || (GameMain.data.trashSystem.enemyDropBans != null && GameMain.data.trashSystem.enemyDropBans.Contains(itemId)))
{
return;
}
PlanetData planetWithBattleBase = GetPlanetWithBattleBase(deathPos);
if (planetWithBattleBase == null || _currentPlanetSpawnQuota == 0)
{
return;
}
TrashSystem trashSystem = GameMain.data.trashSystem;
PlanetFactory factoryForPlanet = GetFactoryForPlanet(planetWithBattleBase);
DefenseSystem val = factoryForPlanet?.defenseSystem;
Vector3 landPosLocal;
VectorLF3 val3;
Vector3 val6;
if (val?.battleBases != null && val.battleBases.count > 0 && factoryForPlanet != null)
{
List<BattleBaseComponent> list = new List<BattleBaseComponent>();
int cursor = val.battleBases.cursor;
BattleBaseComponent[] buffer = val.battleBases.buffer;
for (int i = 1; i < cursor; i++)
{
if (buffer[i] != null && buffer[i].id == i && buffer[i].entityId > 0)
{
list.Add(buffer[i]);
}
}
if (list.Count == 0)
{
if (!TryGetFallbackLandPosLocal(planetWithBattleBase, deathPos, out landPosLocal))
{
return;
}
VectorLF3 val2 = default(VectorLF3);
((VectorLF3)(ref val2))..ctor(landPosLocal.x, landPosLocal.y, landPosLocal.z);
val3 = Maths.QRotateLF(planetWithBattleBase.runtimeRotation, val2) + planetWithBattleBase.uPosition;
}
else
{
BattleBaseComponent val4 = list[Random.Range(0, list.Count)];
ref EntityData reference = ref factoryForPlanet.entityPool[val4.entityId];
if (reference.id != val4.entityId)
{
return;
}
Vector3 pos = reference.pos;
float magnitude = ((Vector3)(ref pos)).magnitude;
if (magnitude < 1f)
{
return;
}
Vector3 val5 = pos / magnitude;
val6 = Vector3.Cross(val5, Random.insideUnitSphere);
Vector3 normalized = ((Vector3)(ref val6)).normalized;
if (((Vector3)(ref normalized)).sqrMagnitude < 0.01f)
{
val6 = Vector3.Cross(val5, Vector3.up);
normalized = ((Vector3)(ref val6)).normalized;
}
float num = Random.Range(8f, 22f);
val6 = pos + normalized * num;
landPosLocal = ((Vector3)(ref val6)).normalized * magnitude;
VectorLF3 val7 = default(VectorLF3);
((VectorLF3)(ref val7))..ctor(landPosLocal.x, landPosLocal.y, landPosLocal.z);
val3 = Maths.QRotateLF(planetWithBattleBase.runtimeRotation, val7) + planetWithBattleBase.uPosition;
}
}
else
{
if (!TryGetFallbackLandPosLocal(planetWithBattleBase, deathPos, out landPosLocal))
{
return;
}
VectorLF3 val8 = default(VectorLF3);
((VectorLF3)(ref val8))..ctor(landPosLocal.x, landPosLocal.y, landPosLocal.z);
val3 = Maths.QRotateLF(planetWithBattleBase.runtimeRotation, val8) + planetWithBattleBase.uPosition;
}
VectorLF3 val9 = Maths.QInvRotateLF(planetWithBattleBase.runtimeRotation, deathPos - planetWithBattleBase.uPosition);
VectorLF3 universalVelocityAtLocalPoint = planetWithBattleBase.GetUniversalVelocityAtLocalPoint(GameMain.gameTime, VectorLF3.op_Implicit(val9));
VectorLF3 val10 = val3 - deathPos;
double num2 = Math.Sqrt(val10.x * val10.x + val10.y * val10.y + val10.z * val10.z);
if (num2 < 1.0)
{
return;
}
val10.x /= num2;
val10.y /= num2;
val10.z /= num2;
double num3 = num2 / 10.0;
if (num3 < 30.0)
{
num3 = 30.0;
}
VectorLF3 uVel = default(VectorLF3);
((VectorLF3)(ref uVel))..ctor(universalVelocityAtLocalPoint.x + val10.x * num3, universalVelocityAtLocalPoint.y + val10.y * num3, universalVelocityAtLocalPoint.z + val10.z * num3);
int trashCount = trashSystem.trashCount;
float num4 = (float)(500.0 / (double)(trashCount + 100));
int life = 800 + (int)(2400.0 * (double)num4 * 2.0 / 3.0 + 0.5);
TrashData val11 = default(TrashData);
val11.warningId = 0;
val11.landPlanetId = 0;
val11.nearPlanetId = planetWithBattleBase.id;
val11.nearStarId = planetWithBattleBase.star.astroId;
val11.nearStarGravity = trashSystem.GetStarGravity(planetWithBattleBase.star.id);
val11.life = life;
val11.lPos = Vector3.zero;
val11.lRot = Quaternion.identity;
val11.uPos = deathPos;
val6 = Random.insideUnitSphere;
val11.uRot = Quaternion.LookRotation(((Vector3)(ref val6)).normalized);
val11.uVel = uVel;
val11.uAgl = Random.insideUnitSphere * 0.03f;
TrashData val12 = val11;
GameData data = GameMain.data;
Vector3 val13 = VectorLF3.op_Implicit(Maths.QInvRotateLF(data.relativeRot, deathPos - data.relativePos));
Quaternion val14 = Quaternion.Inverse(data.relativeRot) * val12.uRot;
TrashObject val15 = default(TrashObject);
((TrashObject)(ref val15))..ctor(itemId, count, 0, val13, val14);
int num5 = trashSystem.container.NewTrash(val15, val12);
_ourSpaceTrashTargets.Add((num5, planetWithBattleBase.astroId));
if (_currentPlanetSpawnQuota > 0)
{
_currentPlanetSpawnQuota--;
}
try
{
if (!((Object)(object)Instance != (Object)null))
{
return;
}
bool flag = ShouldSpawnTrailForDrop(planetWithBattleBase, deathPos);
GameObject item = (flag ? Instance.CreateTrailParticle() : null);
Instance._trashTrails.Add((num5, item, -1f, landPosLocal, GameMain.gameTime, deathPos));
if (EnableDebugLog)
{
string item2 = GetPlanetNameAndDistance(planetWithBattleBase, deathPos).planetName;
ManualLogSource? log = Log;
if (log != null)
{
log.LogInfo((object)string.Format("[{0}] 轨迹已登记 idx={1} 目标={2} 尾迹={3}", "战场分析基站收集太空残骸", num5, item2, flag ? "有" : "无(远端)"));
}
}
}
catch
{
}
}
internal static (string planetName, double distanceM) GetPlanetNameAndDistance(PlanetData planet, VectorLF3 pos)
{
//IL_000b: 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_0030: Unknown result type (might be due to invalid IL or missing references)
double num = planet.uPosition.x - pos.x;
double num2 = planet.uPosition.y - pos.y;
double num3 = planet.uPosition.z - pos.z;
double item = Math.Sqrt(num * num + num2 * num2 + num3 * num3);
string text = planet.star?.name ?? "";
string text2 = planet.displayName ?? $"{text} 行星{planet.index + 1}";
if (string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(text))
{
text2 = $"{text} 行星{planet.index + 1}";
}
return (text2, item);
}
internal static string GetEnemyName(int protoId)
{
EnemyProto val = ((ProtoSet<EnemyProto>)(object)LDB.enemies)?.Select(protoId);
if (val == null)
{
return $"id{protoId}";
}
if (((Proto)val).name != null && ((Proto)val).name.Length > 0)
{
return ((Proto)val).name;
}
if (((Proto)val).Name != null)
{
return Localization.Translate(((Proto)val).Name);
}
return $"id{protoId}";
}
internal static string GetItemName(int itemId)
{
ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items)?.Select(itemId);
if (val == null)
{
return $"id{itemId}";
}
if (((Proto)val).name != null && ((Proto)val).name.Length > 0)
{
return ((Proto)val).name;
}
if (((Proto)val).Name != null)
{
return Localization.Translate(((Proto)val).Name);
}
return $"id{itemId}";
}
internal static PlanetData? GetNearestPlanetUnconditional(VectorLF3 pos)
{
//IL_001c: 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_0015: Unknown result type (might be due to invalid IL or missing references)
SpaceSector val = GameMain.data?.spaceSector;
if (val == null)
{
return FallbackGetNearestPlanetUnconditional(pos);
}
VectorLF3 val2 = pos;
double num = default(double);
return val.GetNearestPlanet(ref val2, ref num);
}
private static PlanetData? FallbackGetNearestPlanetUnconditional(VectorLF3 pos)
{
//IL_007c: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
GalaxyData val = GameMain.data?.galaxy;
if (val?.stars == null)
{
return null;
}
PlanetData result = null;
double num = double.MaxValue;
for (int i = 0; i < val.starCount; i++)
{
StarData val2 = val.stars[i];
if (val2?.planets == null)
{
continue;
}
int planetCount = val2.planetCount;
for (int j = 0; j < planetCount; j++)
{
PlanetData val3 = val2.planets[j];
if (val3 != null)
{
double num2 = val3.uPosition.x - pos.x;
double num3 = val3.uPosition.y - pos.y;
double num4 = val3.uPosition.z - pos.z;
double num5 = num2 * num2 + num3 * num3 + num4 * num4;
if (num5 < num)
{
num = num5;
result = val3;
}
}
}
}
return result;
}
internal static PlanetData? GetPlanetWithBattleBase(VectorLF3? nearPosition = null)
{
//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_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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
StarData val;
if (nearPosition.HasValue && GameMain.data?.spaceSector != null)
{
VectorLF3 value = nearPosition.Value;
double num = default(double);
val = GameMain.data.spaceSector.GetNearestStar(ref value, ref num);
if (val?.planets == null)
{
return null;
}
}
else
{
val = GameMain.localStar;
}
if (val?.planets == null)
{
return null;
}
VectorLF3 val2 = (VectorLF3)(((??)nearPosition) ?? ((??)GameMain.localPlanet?.uPosition) ?? default(VectorLF3));
PlanetData val3 = null;
PlanetData val4 = null;
double num2 = double.MaxValue;
double num3 = double.MaxValue;
PlanetData localPlanet = GameMain.localPlanet;
if (localPlanet != null && localPlanet.star == val)
{
double num4 = localPlanet.uPosition.x - val2.x;
double num5 = localPlanet.uPosition.y - val2.y;
double num6 = localPlanet.uPosition.z - val2.z;
double num7 = num4 * num4 + num5 * num5 + num6 * num6;
if (num7 < num3)
{
num3 = num7;
val4 = localPlanet;
}
PlanetFactory factoryForPlanet = GetFactoryForPlanet(localPlanet);
if (factoryForPlanet?.defenseSystem?.battleBases != null && factoryForPlanet.defenseSystem.battleBases.count > 0 && num7 < num2)
{
num2 = num7;
val3 = localPlanet;
}
}
int planetCount = val.planetCount;
for (int i = 0; i < planetCount; i++)
{
PlanetData val5 = val.planets[i];
if (val5 != null)
{
double num8 = val5.uPosition.x - val2.x;
double num9 = val5.uPosition.y - val2.y;
double num10 = val5.uPosition.z - val2.z;
double num11 = num8 * num8 + num9 * num9 + num10 * num10;
if (num11 < num3)
{
num3 = num11;
val4 = val5;
}
PlanetFactory factoryForPlanet2 = GetFactoryForPlanet(val5);
if (factoryForPlanet2?.defenseSystem?.battleBases != null && factoryForPlanet2.defenseSystem.battleBases.count > 0 && num11 < num2)
{
num2 = num11;
val3 = val5;
}
}
}
return val3 ?? val4;
}
internal static PlanetFactory? GetFactoryForPlanet(PlanetData planet)
{
if (planet == null)
{
return null;
}
if (planet.factory != null)
{
return planet.factory;
}
PlanetFactory[] array = GameMain.data?.galaxy?.astrosFactory;
if (array == null)
{
return null;
}
int astroId = planet.astroId;
if (astroId < 0 || astroId >= array.Length)
{
return null;
}
PlanetFactory val = array[astroId];
if (val == null || val.planetId != planet.astroId)
{
return null;
}
return val;
}
internal static bool TryGetFallbackLandPosLocal(PlanetData planet, VectorLF3 deathPos, out Vector3 landPosLocal)
{
//IL_0001: 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_001a: 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_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_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_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
landPosLocal = default(Vector3);
double num = deathPos.x - planet.uPosition.x;
double num2 = deathPos.y - planet.uPosition.y;
double num3 = deathPos.z - planet.uPosition.z;
double num4 = Math.Sqrt(num * num + num2 * num2 + num3 * num3);
if (num4 < 1E-06)
{
return false;
}
double num5 = (((double)planet.realRadius > 1E-06) ? ((double)planet.realRadius) : 200.0);
VectorLF3 val = default(VectorLF3);
((VectorLF3)(ref val))..ctor(planet.uPosition.x + num / num4 * num5, planet.uPosition.y + num2 / num4 * num5, planet.uPosition.z + num3 / num4 * num5);
VectorLF3 val2 = Maths.QInvRotateLF(planet.runtimeRotation, val - planet.uPosition);
landPosLocal = new Vector3((float)val2.x, (float)val2.y, (float)val2.z);
return true;
}
internal static void RandomDropItemForSpace(int enemyLevel, out int itemId, out int count, out int life)
{
_spaceDropSeed = (uint)((int)((ulong)((long)(_spaceDropSeed % 2147483646 + 1) * 48271L) % 2147483647uL) - 1);
double num = (double)_spaceDropSeed / 2147483646.0 * 10000.0;
itemId = ItemProto.enemyDropRangeTable[(int)num];
count = 0;
life = 0;
int num2 = enemyLevel / 3;
if (num2 > 8)
{
num2 = 8;
}
double num3 = 1.0;
if (itemId > 0 && num2 < ItemProto.enemyDropLevelTable[itemId])
{
itemId = 0;
}
double num4 = 0.0;
if (itemId > 0)
{
if (GameMain.data.history.ItemUnlocked(itemId))
{
num4 = 1.0;
}
else if (GameMain.data.history.ItemCanDropByEnemy(itemId))
{
num4 = 0.4;
}
else
{
itemId = 0;
}
}
num4 *= (double)GameMain.data.history.enemyDropScale;
float enemyDropMultiplier = GameMain.data.gameDesc.enemyDropMultiplier;
double num5 = ((itemId >= 5200 && itemId <= 5209) ? 1.0 : ((double)enemyDropMultiplier));
if (itemId > 0)
{
life = 1800;
double num6 = (double)ItemProto.enemyDropCountTable[itemId] * num4 * num3 * num5 * 0.8;
double num7 = num6 * ((double)enemyLevel / 6.0 + 4.0);
double num8 = num6;
_spaceDropSeed = (uint)((int)((ulong)((long)(_spaceDropSeed % 2147483646 + 1) * 48271L) % 2147483647uL) - 1);
double num9 = (double)_spaceDropSeed / 2147483646.0 * (num7 - num8) + num8;
_spaceDropSeed = (uint)((int)((ulong)((long)(_spaceDropSeed % 2147483646 + 1) * 48271L) % 2147483647uL) - 1);
double num10 = (double)_spaceDropSeed / 2147483646.0;
count = (int)(num9 + num10);
count *= SpaceDropCountMultiplier;
if (count > 0)
{
GameMain.data.history.enemyDropItemUnlocked.Add(itemId);
}
}
}
}
[HarmonyPatch(typeof(SpaceSector), "RemoveCraftWithComponents")]
public static class SpaceCraftDeathPatch
{
private static void Prefix(SpaceSector __instance, int id)
{
//IL_0082: 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_00ec: 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_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
try
{
if (id <= 0 || __instance.craftPool == null || id >= __instance.craftPool.Length)
{
return;
}
ref CraftData reference = ref __instance.craftPool[id];
if (reference.id != id)
{
return;
}
int owner = reference.owner;
while (owner > 0 && owner < __instance.craftPool.Length)
{
ref CraftData reference2 = ref __instance.craftPool[owner];
if (reference2.id != owner)
{
break;
}
owner = reference2.owner;
}
if (owner == -1)
{
return;
}
VectorLF3 val = default(VectorLF3);
__instance.TransformFromAstro(reference.astroId, ref val, reference.pos);
GameData data = GameMain.data;
if (data?.trashSystem == null || ItemProto.enemyDropRangeTable == null)
{
return;
}
PlanetData planetWithBattleBase = Plugin.GetPlanetWithBattleBase(val);
Plugin._currentPlanetSpawnQuota = ((planetWithBattleBase != null) ? Math.Max(0, 2000 - Plugin.CountTrashForPlanet(planetWithBattleBase)) : (-1));
if (planetWithBattleBase != null && Plugin._currentPlanetSpawnQuota == 0 && Plugin.EnableDebugLog)
{
string item = Plugin.GetPlanetNameAndDistance(planetWithBattleBase, val).planetName;
ManualLogSource? log = Plugin.Log;
if (log != null)
{
log.LogInfo((object)$"[BattlefieldAnalysisBaseCollectSpaceJunk] 落点行星({item})已达垃圾堆数上限({2000}),本击毁不生成战利品。");
}
}
Dictionary<int, int> dictionary = new Dictionary<int, int>();
for (int i = 0; i < 20; i++)
{
Plugin.RandomDropItemForSpace(18, out var itemId, out var count, out var _);
if (itemId > 0 && count > 0 && (data.trashSystem.enemyDropBans == null || !data.trashSystem.enemyDropBans.Contains(itemId)))
{
if (!dictionary.ContainsKey(itemId))
{
dictionary[itemId] = 0;
}
dictionary[itemId] += count;
}
}
int num = 0;
foreach (KeyValuePair<int, int> item7 in dictionary)
{
if (Plugin._currentPlanetSpawnQuota != 0)
{
Plugin._everDroppedItemIds.Add(item7.Key);
Plugin.SpawnTrashAtDeathPosition(val, item7.Key, item7.Value);
num++;
continue;
}
break;
}
if (Plugin.EnableDebugLog && num > 0 && planetWithBattleBase != null && Plugin._currentPlanetSpawnQuota == 0)
{
string item2 = Plugin.GetPlanetNameAndDistance(planetWithBattleBase, val).planetName;
ManualLogSource? log2 = Plugin.Log;
if (log2 != null)
{
log2.LogInfo((object)$"[BattlefieldAnalysisBaseCollectSpaceJunk] 落点行星({item2})已达垃圾堆数上限,本击毁仅生成 {num} 批战利品。");
}
}
if (Plugin.EnableDebugLog && num > 0)
{
PlanetData nearestPlanetUnconditional = Plugin.GetNearestPlanetUnconditional(val);
PlanetData planetWithBattleBase2 = Plugin.GetPlanetWithBattleBase(val);
object obj;
if (nearestPlanetUnconditional == null)
{
obj = "";
}
else
{
(string planetName, double distanceM) planetNameAndDistance = Plugin.GetPlanetNameAndDistance(nearestPlanetUnconditional, val);
string item3 = planetNameAndDistance.planetName;
double item4 = planetNameAndDistance.distanceM;
obj = $"离击毁位置最近的行星(无条件): {item3},{item4:F0} m";
}
string text = (string)obj;
string text2 = "";
if (planetWithBattleBase2 != null)
{
(string planetName, double distanceM) planetNameAndDistance2 = Plugin.GetPlanetNameAndDistance(planetWithBattleBase2, val);
string item5 = planetNameAndDistance2.planetName;
double item6 = planetNameAndDistance2.distanceM;
PlanetFactory factoryForPlanet = Plugin.GetFactoryForPlanet(planetWithBattleBase2);
text2 = ((factoryForPlanet?.defenseSystem?.battleBases != null && factoryForPlanet.defenseSystem.battleBases.count > 0) ? $"落点行星(带基站): {item5},{item6:F0} m" : $"落点行星(无基站,表面落点): {item5},{item6:F0} m");
}
ManualLogSource? log3 = Plugin.Log;
if (log3 != null)
{
log3.LogInfo((object)string.Format("[BattlefieldAnalysisBaseCollectSpaceJunk] 太空舰船击毁,已生成 {0} 批战利品。{1}{2}{3}", num, text, string.IsNullOrEmpty(text) ? "" : ";", text2));
}
}
}
catch (Exception ex)
{
ManualLogSource? log4 = Plugin.Log;
if (log4 != null)
{
log4.LogError((object)("[BattlefieldAnalysisBaseCollectSpaceJunk] SpaceCraftDeathPatch 异常: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
}
[HarmonyPatch(typeof(SpaceSector), "KillEnemyFinal")]
public static class SpaceEnemyDeathPatch
{
private static void Prefix(SpaceSector __instance, int enemyId, ref CombatStat combatStat)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: 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_02bc: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
try
{
if (enemyId <= 0 || __instance.enemyPool == null || enemyId >= __instance.enemyPool.Length)
{
return;
}
ref EnemyData reference = ref __instance.enemyPool[enemyId];
if (reference.id != enemyId || !reference.isSpace)
{
return;
}
VectorLF3 val = default(VectorLF3);
__instance.TransformFromAstro(reference.astroId, ref val, reference.pos);
GameData data = GameMain.data;
if (data?.trashSystem == null || ItemProto.enemyDropRangeTable == null)
{
return;
}
PlanetData planetWithBattleBase = Plugin.GetPlanetWithBattleBase(val);
Plugin._currentPlanetSpawnQuota = ((planetWithBattleBase != null) ? Math.Max(0, 2000 - Plugin.CountTrashForPlanet(planetWithBattleBase)) : (-1));
if (Plugin.EnableDebugLog && planetWithBattleBase != null && Plugin._currentPlanetSpawnQuota == 0)
{
string item = Plugin.GetPlanetNameAndDistance(planetWithBattleBase, val).planetName;
ManualLogSource? log = Plugin.Log;
if (log != null)
{
log.LogInfo((object)$"[BattlefieldAnalysisBaseCollectSpaceJunk] 落点行星({item})已达垃圾堆数上限({2000}),本击毁不生成战利品。");
}
}
int enemyLevel = 18;
EnemyDFHiveSystem hiveByAstroId = __instance.GetHiveByAstroId(reference.originAstroId);
if (hiveByAstroId != null)
{
enemyLevel = hiveByAstroId.evolve.level;
}
else if (Plugin.EnableDebugLog)
{
ManualLogSource? log2 = Plugin.Log;
if (log2 != null)
{
log2.LogInfo((object)$"[BattlefieldAnalysisBaseCollectSpaceJunk] 掉落等级:无巢穴(originAstroId={reference.originAstroId}),使用 fallback={18}");
}
}
Dictionary<int, int> dictionary = new Dictionary<int, int>();
for (int i = 0; i < 20; i++)
{
Plugin.RandomDropItemForSpace(enemyLevel, out var itemId, out var count, out var _);
if (itemId > 0 && count > 0 && (data.trashSystem.enemyDropBans == null || !data.trashSystem.enemyDropBans.Contains(itemId)))
{
if (!dictionary.ContainsKey(itemId))
{
dictionary[itemId] = 0;
}
dictionary[itemId] += count;
}
}
int num = 0;
foreach (KeyValuePair<int, int> item7 in dictionary)
{
if (Plugin._currentPlanetSpawnQuota != 0)
{
Plugin.SpawnTrashAtDeathPosition(val, item7.Key, item7.Value);
num++;
continue;
}
break;
}
if (Plugin.EnableDebugLog && num > 0 && planetWithBattleBase != null && Plugin._currentPlanetSpawnQuota == 0)
{
string item2 = Plugin.GetPlanetNameAndDistance(planetWithBattleBase, val).planetName;
ManualLogSource? log3 = Plugin.Log;
if (log3 != null)
{
log3.LogInfo((object)$"[BattlefieldAnalysisBaseCollectSpaceJunk] 落点行星({item2})已达垃圾堆数上限,本击毁仅生成 {num} 批战利品。");
}
}
if (num > 0)
{
foreach (int key in dictionary.Keys)
{
Plugin._everDroppedItemIds.Add(key);
}
}
if (!Plugin.EnableDebugLog || num <= 0)
{
return;
}
string enemyName = Plugin.GetEnemyName(reference.protoId);
PlanetData nearestPlanetUnconditional = Plugin.GetNearestPlanetUnconditional(val);
PlanetData planetWithBattleBase2 = Plugin.GetPlanetWithBattleBase(val);
object obj;
if (nearestPlanetUnconditional == null)
{
obj = "";
}
else
{
(string planetName, double distanceM) planetNameAndDistance = Plugin.GetPlanetNameAndDistance(nearestPlanetUnconditional, val);
string item3 = planetNameAndDistance.planetName;
double item4 = planetNameAndDistance.distanceM;
obj = $"离击毁位置最近的行星(无条件): {item3},{item4:F0} m";
}
string text = (string)obj;
string text2 = "";
if (planetWithBattleBase2 != null)
{
(string planetName, double distanceM) planetNameAndDistance2 = Plugin.GetPlanetNameAndDistance(planetWithBattleBase2, val);
string item5 = planetNameAndDistance2.planetName;
double item6 = planetNameAndDistance2.distanceM;
PlanetFactory factoryForPlanet = Plugin.GetFactoryForPlanet(planetWithBattleBase2);
text2 = ((factoryForPlanet?.defenseSystem?.battleBases != null && factoryForPlanet.defenseSystem.battleBases.count > 0) ? $"落点行星(带基站): {item5},{item6:F0} m" : $"落点行星(无基站,表面落点): {item5},{item6:F0} m");
}
int count2 = dictionary.Count;
ManualLogSource? log4 = Plugin.Log;
if (log4 != null)
{
log4.LogInfo((object)string.Format("[BattlefieldAnalysisBaseCollectSpaceJunk] 黑雾太空敌舰击毁,已生成 {0} 批({1} 种)战利品。被击毁: {2}。{3}{4}{5}", num, count2, enemyName, text, string.IsNullOrEmpty(text) ? "" : ";", text2));
}
if (dictionary.Count <= 0)
{
return;
}
string text3 = string.Join(",", dictionary.Select((KeyValuePair<int, int> kv) => $"{Plugin.GetItemName(kv.Key)}-{kv.Value}"));
ManualLogSource? log5 = Plugin.Log;
if (log5 != null)
{
log5.LogInfo((object)("[BattlefieldAnalysisBaseCollectSpaceJunk] 战利品明细: " + text3));
}
List<int> list = Plugin.GetDroppableItemIds().Except(Plugin._everDroppedItemIds).ToList();
ManualLogSource? log6 = Plugin.Log;
if (log6 != null)
{
log6.LogInfo((object)$"[BattlefieldAnalysisBaseCollectSpaceJunk] 掉落表中从未掉落过的物品种类数: {list.Count}");
}
if (list.Count > 0 && list.Count < 10)
{
string text4 = string.Join(",", list.Select((int id) => Plugin.GetItemName(id)));
ManualLogSource? log7 = Plugin.Log;
if (log7 != null)
{
log7.LogInfo((object)("[BattlefieldAnalysisBaseCollectSpaceJunk] 从未掉落的物品: " + text4));
}
}
}
catch (Exception ex)
{
ManualLogSource? log8 = Plugin.Log;
if (log8 != null)
{
log8.LogError((object)("[BattlefieldAnalysisBaseCollectSpaceJunk] SpaceEnemyDeathPatch 异常: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
}
[HarmonyPatch(typeof(TrashSystem), "GameTick")]
public static class TrashSystemGravityPatch
{
private const int S30SampleCount = 32;
private const double S30Delta = 1E-06;
private const int AlphaBisectIter = 35;
private static void EvalArcPath(double s, double planetPosX, double planetPosY, double planetPosZ, double u0x, double u0y, double u0z, double u1x, double u1y, double u1z, double umx, double umy, double umz, double r0, double r3, double minR, out double px, out double py, out double pz)
{
double num6;
double num7;
double num8;
if (s < 0.5)
{
double num = s * 2.0;
double val = u0x * umx + u0y * umy + u0z * umz;
double num2 = Math.Acos(Math.Max(-1.0, Math.Min(1.0, val)));
double num3 = ((num2 > 1E-08) ? Math.Sin(num2) : 1E-08);
double num4 = Math.Sin((1.0 - num) * num2) / num3;
double num5 = Math.Sin(num * num2) / num3;
num6 = num4 * u0x + num5 * umx;
num7 = num4 * u0y + num5 * umy;
num8 = num4 * u0z + num5 * umz;
}
else
{
double num9 = (s - 0.5) * 2.0;
double val2 = umx * u1x + umy * u1y + umz * u1z;
double num10 = Math.Acos(Math.Max(-1.0, Math.Min(1.0, val2)));
double num11 = ((num10 > 1E-08) ? Math.Sin(num10) : 1E-08);
double num12 = Math.Sin((1.0 - num9) * num10) / num11;
double num13 = Math.Sin(num9 * num10) / num11;
num6 = num12 * umx + num13 * u1x;
num7 = num12 * umy + num13 * u1y;
num8 = num12 * umz + num13 * u1z;
}
double num14 = Math.Sqrt(num6 * num6 + num7 * num7 + num8 * num8);
if (num14 > 1E-06)
{
num6 /= num14;
num7 /= num14;
num8 /= num14;
}
double num15;
if (s < 0.8)
{
num15 = Math.Max(r0, minR);
}
else
{
double num16 = (s - 0.8) / 0.2;
num16 = num16 * num16 * (3.0 - 2.0 * num16);
num15 = r0 + (r3 - r0) * num16;
}
px = planetPosX + num6 * num15;
py = planetPosY + num7 * num15;
pz = planetPosZ + num8 * num15;
}
private static void EvalBezierPath(double s, double P0x, double P0y, double P0z, double p1x, double p1y, double p1z, double p2x, double p2y, double p2z, double P3x, double P3y, double P3z, double dp1x, double dp1y, double dp1z, double dp2x, double dp2y, double dp2z, double dp3x, double dp3y, double dp3z, out double px, out double py, out double pz, out double dPdsx, out double dPdsy, out double dPdsz)
{
double num = 1.0 - s;
double num2 = num * num;
double num3 = num2 * num;
double num4 = s * s;
double num5 = num4 * s;
px = num3 * P0x + 3.0 * num2 * s * p1x + 3.0 * num * num4 * p2x + num5 * P3x;
py = num3 * P0y + 3.0 * num2 * s * p1y + 3.0 * num * num4 * p2y + num5 * P3y;
pz = num3 * P0z + 3.0 * num2 * s * p1z + 3.0 * num * num4 * p2z + num5 * P3z;
dPdsx = num2 * dp1x + 2.0 * num * s * dp2x + num4 * dp3x;
dPdsy = num2 * dp1y + 2.0 * num * s * dp2y + num4 * dp3y;
dPdsz = num2 * dp1z + 2.0 * num * s * dp2z + num4 * dp3z;
}
private static double SolveAlpha(double s30, double R)
{
if (R <= 0.0 || s30 >= 0.999999999)
{
return 80.0;
}
double num = Math.Max(1.0 - s30, 1E-09);
double num2 = Math.Max(1.01, Math.Min(80.0, 0.0 - Math.Log(num)));
double num3 = num2 * Math.Pow(num, 1.0 - 1.0 / num2);
if (R <= num3)
{
return num2;
}
double num4 = 1.01;
double num5 = 80.0;
for (int i = 0; i < 35; i++)
{
double num6 = (num4 + num5) * 0.5;
double y = (num6 - 1.0) / num6;
if (num6 * Math.Pow(num, y) < R)
{
num4 = num6;
}
else
{
num5 = num6;
}
}
return (num4 + num5) * 0.5;
}
private static void Postfix(TrashSystem __instance)
{
//IL_009a: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: 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_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: 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_01a4: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_0b1c: Unknown result type (might be due to invalid IL or missing references)
//IL_0b23: Unknown result type (might be due to invalid IL or missing references)
//IL_0b2d: Unknown result type (might be due to invalid IL or missing references)
//IL_0b34: Unknown result type (might be due to invalid IL or missing references)
//IL_0b3e: Unknown result type (might be due to invalid IL or missing references)
//IL_0b45: Unknown result type (might be due to invalid IL or missing references)
//IL_0b4f: Unknown result type (might be due to invalid IL or missing references)
//IL_0b56: Unknown result type (might be due to invalid IL or missing references)
//IL_0b60: Unknown result type (might be due to invalid IL or missing references)
//IL_0b67: Unknown result type (might be due to invalid IL or missing references)
//IL_0b71: Unknown result type (might be due to invalid IL or missing references)
//IL_0b78: Unknown result type (might be due to invalid IL or missing references)
//IL_0bef: Unknown result type (might be due to invalid IL or missing references)
//IL_0bfc: Unknown result type (might be due to invalid IL or missing references)
//IL_0c04: Unknown result type (might be due to invalid IL or missing references)
//IL_0c11: Unknown result type (might be due to invalid IL or missing references)
//IL_0c1b: Unknown result type (might be due to invalid IL or missing references)
//IL_0c28: Unknown result type (might be due to invalid IL or missing references)
//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
//IL_042c: Unknown result type (might be due to invalid IL or missing references)
//IL_0436: Unknown result type (might be due to invalid IL or missing references)
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
//IL_044b: Unknown result type (might be due to invalid IL or missing references)
//IL_0457: Unknown result type (might be due to invalid IL or missing references)
//IL_0461: Unknown result type (might be due to invalid IL or missing references)
//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
//IL_0502: Unknown result type (might be due to invalid IL or missing references)
//IL_0509: Unknown result type (might be due to invalid IL or missing references)
//IL_0510: Unknown result type (might be due to invalid IL or missing references)
//IL_0d9d: Unknown result type (might be due to invalid IL or missing references)
//IL_0dad: Unknown result type (might be due to invalid IL or missing references)
//IL_0db4: Unknown result type (might be due to invalid IL or missing references)
//IL_0dc6: Unknown result type (might be due to invalid IL or missing references)
//IL_0dd6: Unknown result type (might be due to invalid IL or missing references)
//IL_0ddd: Unknown result type (might be due to invalid IL or missing references)
//IL_0def: Unknown result type (might be due to invalid IL or missing references)
//IL_0dff: Unknown result type (might be due to invalid IL or missing references)
//IL_0e06: Unknown result type (might be due to invalid IL or missing references)
//IL_0e18: Unknown result type (might be due to invalid IL or missing references)
//IL_0e28: Unknown result type (might be due to invalid IL or missing references)
//IL_0e2f: Unknown result type (might be due to invalid IL or missing references)
//IL_0e41: Unknown result type (might be due to invalid IL or missing references)
//IL_0e51: Unknown result type (might be due to invalid IL or missing references)
//IL_0e58: Unknown result type (might be due to invalid IL or missing references)
//IL_0e6a: Unknown result type (might be due to invalid IL or missing references)
//IL_0e7a: Unknown result type (might be due to invalid IL or missing references)
//IL_0e81: Unknown result type (might be due to invalid IL or missing references)
//IL_0e95: Unknown result type (might be due to invalid IL or missing references)
//IL_0ea1: Unknown result type (might be due to invalid IL or missing references)
//IL_0ead: Unknown result type (might be due to invalid IL or missing references)
//IL_0c9f: Unknown result type (might be due to invalid IL or missing references)
//IL_0ca6: Unknown result type (might be due to invalid IL or missing references)
//IL_0cb0: Unknown result type (might be due to invalid IL or missing references)
//IL_0cb7: Unknown result type (might be due to invalid IL or missing references)
//IL_0cc1: Unknown result type (might be due to invalid IL or missing references)
//IL_0cc8: Unknown result type (might be due to invalid IL or missing references)
//IL_0cd2: Unknown result type (might be due to invalid IL or missing references)
//IL_0cd9: Unknown result type (might be due to invalid IL or missing references)
//IL_0ce3: Unknown result type (might be due to invalid IL or missing references)
//IL_0cea: Unknown result type (might be due to invalid IL or missing references)
//IL_0cf4: Unknown result type (might be due to invalid IL or missing references)
//IL_0cfb: Unknown result type (might be due to invalid IL or missing references)
//IL_0f18: Unknown result type (might be due to invalid IL or missing references)
//IL_0f24: Unknown result type (might be due to invalid IL or missing references)
//IL_0f30: Unknown result type (might be due to invalid IL or missing references)
//IL_0fa4: Unknown result type (might be due to invalid IL or missing references)
//IL_0fba: Unknown result type (might be due to invalid IL or missing references)
//IL_0fd0: Unknown result type (might be due to invalid IL or missing references)
//IL_1017: Unknown result type (might be due to invalid IL or missing references)
//IL_102d: Unknown result type (might be due to invalid IL or missing references)
//IL_1043: Unknown result type (might be due to invalid IL or missing references)
//IL_0ee9: Unknown result type (might be due to invalid IL or missing references)
//IL_0ef8: Unknown result type (might be due to invalid IL or missing references)
//IL_0f07: Unknown result type (might be due to invalid IL or missing references)
//IL_0f6c: Unknown result type (might be due to invalid IL or missing references)
//IL_0f7b: Unknown result type (might be due to invalid IL or missing references)
//IL_0f8a: Unknown result type (might be due to invalid IL or missing references)
//IL_10a3: Unknown result type (might be due to invalid IL or missing references)
//IL_10aa: Unknown result type (might be due to invalid IL or missing references)
//IL_10b1: Unknown result type (might be due to invalid IL or missing references)
//IL_10c4: Unknown result type (might be due to invalid IL or missing references)
//IL_10cb: Unknown result type (might be due to invalid IL or missing references)
//IL_10d2: Unknown result type (might be due to invalid IL or missing references)
//IL_10fe: Unknown result type (might be due to invalid IL or missing references)
//IL_1108: Unknown result type (might be due to invalid IL or missing references)
//IL_1113: Unknown result type (might be due to invalid IL or missing references)
//IL_111d: Unknown result type (might be due to invalid IL or missing references)
//IL_1129: Unknown result type (might be due to invalid IL or missing references)
//IL_1133: Unknown result type (might be due to invalid IL or missing references)
//IL_117c: Unknown result type (might be due to invalid IL or missing references)
//IL_1183: Unknown result type (might be due to invalid IL or missing references)
//IL_118a: Unknown result type (might be due to invalid IL or missing references)
//IL_119d: Unknown result type (might be due to invalid IL or missing references)
//IL_11a4: Unknown result type (might be due to invalid IL or missing references)
//IL_11ab: Unknown result type (might be due to invalid IL or missing references)
//IL_125c: Unknown result type (might be due to invalid IL or missing references)
//IL_128c: Unknown result type (might be due to invalid IL or missing references)
//IL_1298: Unknown result type (might be due to invalid IL or missing references)
//IL_12c8: Unknown result type (might be due to invalid IL or missing references)
//IL_12d3: Unknown result type (might be due to invalid IL or missing references)
//IL_1303: Unknown result type (might be due to invalid IL or missing references)
//IL_13bf: Unknown result type (might be due to invalid IL or missing references)
//IL_13c9: Unknown result type (might be due to invalid IL or missing references)
//IL_13d5: Unknown result type (might be due to invalid IL or missing references)
//IL_07e2: Unknown result type (might be due to invalid IL or missing references)
//IL_07f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0800: Unknown result type (might be due to invalid IL or missing references)
//IL_144b: Unknown result type (might be due to invalid IL or missing references)
//IL_144d: Unknown result type (might be due to invalid IL or missing references)
//IL_1452: Unknown result type (might be due to invalid IL or missing references)
//IL_1457: Unknown result type (might be due to invalid IL or missing references)
//IL_145b: Unknown result type (might be due to invalid IL or missing references)
//IL_1467: Unknown result type (might be due to invalid IL or missing references)
//IL_1473: Unknown result type (might be due to invalid IL or missing references)
//IL_0ad8: Unknown result type (might be due to invalid IL or missing references)
//IL_0aed: Unknown result type (might be due to invalid IL or missing references)
//IL_0b02: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)Plugin.Instance == (Object)null || __instance.gameData?.galaxy?.astrosData == null)
{
return;
}
AstroData[] astrosData = __instance.gameData.galaxy.astrosData;
TrashData[] trashDataPool = __instance.container.trashDataPool;
List<(int, GameObject, float, Vector3, double, VectorLF3)> trashTrails = Plugin.Instance._trashTrails;
VectorLF3 val = default(VectorLF3);
for (int i = 0; i < trashTrails.Count; i++)
{
int item = trashTrails[i].Item1;
if (item < 0 || item >= trashDataPool.Length || trashDataPool[item].landPlanetId != 0)
{
continue;
}
PlanetData planetWithBattleBase = Plugin.GetPlanetWithBattleBase(trashTrails[i].Item6);
if (planetWithBattleBase == null)
{
continue;
}
int astroId = planetWithBattleBase.astroId;
if (astroId <= 0 || astroId >= astrosData.Length)
{
continue;
}
double num = astrosData[astroId].uRadius;
VectorLF3 uPos = astrosData[astroId].uPos;
double item2 = trashTrails[i].Item5;
double num2 = (GameMain.gameTime - item2) / 10.0;
if (num2 >= 1.0 || num2 < 0.0)
{
continue;
}
VectorLF3 item3 = trashTrails[i].Item6;
Vector3 item4 = trashTrails[i].Item4;
((VectorLF3)(ref val))..ctor(item4.x, item4.y, item4.z);
VectorLF3 val2 = Maths.QRotateLF(planetWithBattleBase.runtimeRotation, val) + planetWithBattleBase.uPosition;
double num3 = item3.x - uPos.x;
double num4 = item3.y - uPos.y;
double num5 = item3.z - uPos.z;
double num6 = val2.x - uPos.x;
double num7 = val2.y - uPos.y;
double num8 = val2.z - uPos.z;
double num9 = Math.Sqrt(num3 * num3 + num4 * num4 + num5 * num5);
double num10 = Math.Sqrt(num6 * num6 + num7 * num7 + num8 * num8);
if (num9 < 1E-06 || num10 < 1E-06)
{
continue;
}
double num11 = num3 / num9;
double num12 = num4 / num9;
double num13 = num5 / num9;
double num14 = num6 / num10;
double num15 = num7 / num10;
double num16 = num8 / num10;
double num47;
double num48;
double num49;
double num65;
double num66;
double num67;
if (num11 * num14 + num12 * num15 + num13 * num16 < -0.2)
{
double num17 = num12 * num16 - num13 * num15;
double num18 = num13 * num14 - num11 * num16;
double num19 = num11 * num15 - num12 * num14;
double num20 = Math.Sqrt(num17 * num17 + num18 * num18 + num19 * num19);
if (num20 < 1E-06)
{
double num21 = 0.0;
double num22 = 0.0;
double num23 = 0.0;
if (Math.Abs(num11) <= Math.Abs(num12) && Math.Abs(num11) <= Math.Abs(num13))
{
num21 = 1.0;
}
else if (Math.Abs(num12) <= Math.Abs(num13))
{
num22 = 1.0;
}
else
{
num23 = 1.0;
}
num17 = num12 * num23 - num13 * num22;
num18 = num13 * num21 - num11 * num23;
num19 = num11 * num22 - num12 * num21;
num20 = Math.Sqrt(num17 * num17 + num18 * num18 + num19 * num19);
if (num20 < 1E-06)
{
continue;
}
}
double num24 = num17 / num20;
double num25 = num18 / num20;
double num26 = num19 / num20;
double num27 = 0.5;
double num28 = 0.01;
double num29 = 0.99;
for (int j = 0; j < 32; j++)
{
num27 = (num28 + num29) * 0.5;
EvalArcPath(num27, uPos.x, uPos.y, uPos.z, num11, num12, num13, num14, num15, num16, num24, num25, num26, num9, num10, num + 1200.0, out var px, out var py, out var pz);
if (Math.Sqrt((px - uPos.x) * (px - uPos.x) + (py - uPos.y) * (py - uPos.y) + (pz - uPos.z) * (pz - uPos.z)) - num > 30.0)
{
num28 = num27;
}
else
{
num29 = num27;
}
}
num27 = (num28 + num29) * 0.5;
EvalArcPath(num27 + 1E-06, uPos.x, uPos.y, uPos.z, num11, num12, num13, num14, num15, num16, num24, num25, num26, num9, num10, num + 1200.0, out var px2, out var py2, out var pz2);
EvalArcPath(num27 - 1E-06, uPos.x, uPos.y, uPos.z, num11, num12, num13, num14, num15, num16, num24, num25, num26, num9, num10, num + 1200.0, out var px3, out var py3, out var pz3);
double val3 = Math.Sqrt((px2 - px3) * (px2 - px3) + (py2 - py3) * (py2 - py3) + (pz2 - pz3) * (pz2 - pz3)) / 2E-06;
double r = 300.0 / Math.Max(val3, 1E-06);
double y = SolveAlpha(num27, r);
double num30 = 1.0 - Math.Pow(1.0 - num2, y);
double num36;
double num37;
double num38;
if (num30 < 0.5)
{
double num31 = num30 * 2.0;
double val4 = num11 * num24 + num12 * num25 + num13 * num26;
double num32 = Math.Acos(Math.Max(-1.0, Math.Min(1.0, val4)));
double num33 = ((num32 > 1E-08) ? Math.Sin(num32) : 1E-08);
double num34 = Math.Sin((1.0 - num31) * num32) / num33;
double num35 = Math.Sin(num31 * num32) / num33;
num36 = num34 * num11 + num35 * num24;
num37 = num34 * num12 + num35 * num25;
num38 = num34 * num13 + num35 * num26;
}
else
{
double num39 = (num30 - 0.5) * 2.0;
double val5 = num24 * num14 + num25 * num15 + num26 * num16;
double num40 = Math.Acos(Math.Max(-1.0, Math.Min(1.0, val5)));
double num41 = ((num40 > 1E-08) ? Math.Sin(num40) : 1E-08);
double num42 = Math.Sin((1.0 - num39) * num40) / num41;
double num43 = Math.Sin(num39 * num40) / num41;
num36 = num42 * num24 + num43 * num14;
num37 = num42 * num25 + num43 * num15;
num38 = num42 * num26 + num43 * num16;
}
double num44 = Math.Sqrt(num36 * num36 + num37 * num37 + num38 * num38);
if (num44 > 1E-06)
{
num36 /= num44;
num37 /= num44;
num38 /= num44;
}
double val6 = num + 1200.0;
double num45;
if (num30 < 0.8)
{
num45 = Math.Max(num9, val6);
}
else
{
double num46 = (num30 - 0.8) / 0.2;
num46 = num46 * num46 * (3.0 - 2.0 * num46);
num45 = num9 + (num10 - num9) * num46;
}
num47 = uPos.x + num36 * num45;
num48 = uPos.y + num37 * num45;
num49 = uPos.z + num38 * num45;
double num50 = 0.01;
double num51 = Math.Min(1.0, num2 + num50 / 10.0);
double num52 = 1.0 - Math.Pow(1.0 - num51, y);
double num56;
double num57;
double num58;
if (num52 < 0.5)
{
double num53 = num52 * 2.0;
double val7 = num11 * num24 + num12 * num25 + num13 * num26;
double num54 = Math.Acos(Math.Max(-1.0, Math.Min(1.0, val7)));
double num55 = ((num54 > 1E-08) ? Math.Sin(num54) : 1E-08);
num56 = (Math.Sin((1.0 - num53) * num54) * num11 + Math.Sin(num53 * num54) * num24) / num55;
num57 = (Math.Sin((1.0 - num53) * num54) * num12 + Math.Sin(num53 * num54) * num25) / num55;
num58 = (Math.Sin((1.0 - num53) * num54) * num13 + Math.Sin(num53 * num54) * num26) / num55;
}
else
{
double num59 = (num52 - 0.5) * 2.0;
double val8 = num24 * num14 + num25 * num15 + num26 * num16;
double num60 = Math.Acos(Math.Max(-1.0, Math.Min(1.0, val8)));
double num61 = ((num60 > 1E-08) ? Math.Sin(num60) : 1E-08);
num56 = (Math.Sin((1.0 - num59) * num60) * num24 + Math.Sin(num59 * num60) * num14) / num61;
num57 = (Math.Sin((1.0 - num59) * num60) * num25 + Math.Sin(num59 * num60) * num15) / num61;
num58 = (Math.Sin((1.0 - num59) * num60) * num26 + Math.Sin(num59 * num60) * num16) / num61;
}
double num62 = Math.Sqrt(num56 * num56 + num57 * num57 + num58 * num58);
if (num62 > 1E-06)
{
num56 /= num62;
num57 /= num62;
num58 /= num62;
}
double num63;
if (num52 < 0.8)
{
num63 = Math.Max(num9, val6);
}
else
{
double num64 = (num52 - 0.8) / 0.2;
num64 = num64 * num64 * (3.0 - 2.0 * num64);
num63 = num9 + (num10 - num9) * num64;
}
num65 = (uPos.x + num56 * num63 - num47) / num50;
num66 = (uPos.y + num57 * num63 - num48) / num50;
num67 = (uPos.z + num58 * num63 - num49) / num50;
}
else
{
double num68 = val2.x - item3.x;
double num69 = val2.y - item3.y;
double num70 = val2.z - item3.z;
double num71 = uPos.x - item3.x;
double num72 = uPos.y - item3.y;
double num73 = uPos.z - item3.z;
double num74 = num68 * num68 + num69 * num69 + num70 * num70;
if (num74 < 1E-10)
{
continue;
}
double num75 = (num68 * num71 + num69 * num72 + num70 * num73) / num74;
num75 = ((num75 < 0.0) ? 0.0 : ((num75 > 1.0) ? 1.0 : num75));
double num76 = item3.x + num75 * num68 - uPos.x;
double num77 = item3.y + num75 * num69 - uPos.y;
double num78 = item3.z + num75 * num70 - uPos.z;
double num79 = Math.Sqrt(num76 * num76 + num77 * num77 + num78 * num78);
double num80 = num + 1200.0;
double num81 = 0.0;
double num82 = 0.0;
double num83 = 0.0;
double num84 = 0.0;
if (num79 < num80)
{
num81 = Math.Max(0.0, num80 - num79);
double num85 = item3.x - uPos.x;
double num86 = item3.y - uPos.y;
double num87 = item3.z - uPos.z;
double num88 = val2.x - uPos.x;
double num89 = val2.y - uPos.y;
double num90 = val2.z - uPos.z;
num82 = num85 + num88;
num83 = num86 + num89;
num84 = num87 + num90;
double num91 = Math.Sqrt(num82 * num82 + num83 * num83 + num84 * num84);
if (num91 > 1E-06)
{
num82 /= num91;
num83 /= num91;
num84 /= num91;
}
else
{
double num92 = Math.Sqrt(num85 * num85 + num86 * num86 + num87 * num87);
if (num92 > 1E-06)
{
num82 = num85 / num92;
num83 = num86 / num92;
num84 = num87 / num92;
}
else
{
num81 = 0.0;
}
}
}
double num93 = item3.x + 0.333 * (val2.x - item3.x) + num82 * num81;
double num94 = item3.y + 0.333 * (val2.y - item3.y) + num83 * num81;
double num95 = item3.z + 0.333 * (val2.z - item3.z) + num84 * num81;
double num96 = item3.x + 0.667 * (val2.x - item3.x) + num82 * num81;
double num97 = item3.y + 0.667 * (val2.y - item3.y) + num83 * num81;
double num98 = item3.z + 0.667 * (val2.z - item3.z) + num84 * num81;
double num99 = num93 - uPos.x;
double num100 = num94 - uPos.y;
double num101 = num95 - uPos.z;
double num102 = Math.Sqrt(num99 * num99 + num100 * num100 + num101 * num101);
if (num102 < num80 && num102 > 1E-06)
{
double num103 = num80 / num102;
num93 = uPos.x + num99 * num103;
num94 = uPos.y + num100 * num103;
num95 = uPos.z + num101 * num103;
}
double num104 = num96 - uPos.x;
double num105 = num97 - uPos.y;
double num106 = num98 - uPos.z;
double num107 = Math.Sqrt(num104 * num104 + num105 * num105 + num106 * num106);
if (num107 < num80 && num107 > 1E-06)
{
double num108 = num80 / num107;
num96 = uPos.x + num104 * num108;
num97 = uPos.y + num105 * num108;
num98 = uPos.z + num106 * num108;
}
double num109 = 3.0 * (num93 - item3.x);
double num110 = 3.0 * (num94 - item3.y);
double num111 = 3.0 * (num95 - item3.z);
double num112 = 3.0 * (num96 - num93);
double num113 = 3.0 * (num97 - num94);
double num114 = 3.0 * (num98 - num95);
double num115 = 3.0 * (val2.x - num96);
double num116 = 3.0 * (val2.y - num97);
double num117 = 3.0 * (val2.z - num98);
Math.Sqrt(num115 * num115 + num116 * num116 + num117 * num117);
double num118 = 0.5;
double num119 = 0.01;
double num120 = 0.99;
double dPdsx;
double dPdsy;
double dPdsz;
for (int k = 0; k < 32; k++)
{
num118 = (num119 + num120) * 0.5;
EvalBezierPath(num118, item3.x, item3.y, item3.z, num93, num94, num95, num96, num97, num98, val2.x, val2.y, val2.z, num109, num110, num111, num112, num113, num114, num115, num116, num117, out var px4, out var py4, out var pz4, out dPdsx, out dPdsy, out dPdsz);
if (Math.Sqrt((px4 - uPos.x) * (px4 - uPos.x) + (py4 - uPos.y) * (py4 - uPos.y) + (pz4 - uPos.z) * (pz4 - uPos.z)) - num > 30.0)
{
num119 = num118;
}
else
{
num120 = num118;
}
}
num118 = (num119 + num120) * 0.5;
EvalBezierPath(num118, item3.x, item3.y, item3.z, num93, num94, num95, num96, num97, num98, val2.x, val2.y, val2.z, num109, num110, num111, num112, num113, num114, num115, num116, num117, out dPdsz, out dPdsy, out dPdsx, out var dPdsx2, out var dPdsy2, out var dPdsz2);
double val9 = Math.Sqrt(dPdsx2 * dPdsx2 + dPdsy2 * dPdsy2 + dPdsz2 * dPdsz2);
double r2 = 300.0 / Math.Max(val9, 1E-06);
double num121 = SolveAlpha(num118, r2);
double num122 = 1.0 - Math.Pow(1.0 - num2, num121);
double num123 = 1.0 - num122;
double num124 = num123 * num123;
double num125 = num124 * num123;
double num126 = num122 * num122;
double num127 = num126 * num122;
num47 = num125 * item3.x + 3.0 * num124 * num122 * num93 + 3.0 * num123 * num126 * num96 + num127 * val2.x;
num48 = num125 * item3.y + 3.0 * num124 * num122 * num94 + 3.0 * num123 * num126 * num97 + num127 * val2.y;
num49 = num125 * item3.z + 3.0 * num124 * num122 * num95 + 3.0 * num123 * num126 * num98 + num127 * val2.z;
double num128 = num124 * num109 + 2.0 * num123 * num122 * num112 + num126 * num115;
double num129 = num124 * num110 + 2.0 * num123 * num122 * num113 + num126 * num116;
double num130 = num124 * num111 + 2.0 * num123 * num122 * num114 + num126 * num117;
double x = Math.Max(1.0 - num2, 0.001);
double num131 = num121 * Math.Pow(x, num121 - 1.0) / 10.0;
num65 = num128 * num131;
num66 = num129 * num131;
num67 = num130 * num131;
}
double num132 = num47 - uPos.x;
double num133 = num48 - uPos.y;
double num134 = num49 - uPos.z;
double num135 = Math.Sqrt(num132 * num132 + num133 * num133 + num134 * num134) - num;
double num136 = Math.Sqrt(num65 * num65 + num66 * num66 + num67 * num67);
if (!(num135 <= 0.0) && (!(num135 < 10.0) || !(num136 <= 25.0)))
{
VectorLF3 universalVelocityAtLocalPoint = planetWithBattleBase.GetUniversalVelocityAtLocalPoint(GameMain.gameTime, VectorLF3.op_Implicit(val));
num65 += universalVelocityAtLocalPoint.x;
num66 += universalVelocityAtLocalPoint.y;
num67 += universalVelocityAtLocalPoint.z;
ref TrashData reference = ref trashDataPool[item];
reference.uPos.x = num47;
reference.uPos.y = num48;
reference.uPos.z = num49;
reference.uVel.x = num65;
reference.uVel.y = num66;
reference.uVel.z = num67;
}
}
}
catch (Exception ex)
{
ManualLogSource? log = Plugin.Log;
if (log != null)
{
log.LogError((object)("[BattlefieldAnalysisBaseCollectSpaceJunk] TrashSystemGravityPatch 异常: " + ex.Message + "\n" + ex.StackTrace));
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "un1eagle.battlefieldanalysisbasecollectspacejunk";
public const string PLUGIN_NAME = "战场分析基站收集太空残骸";
public const string PLUGIN_VERSION = "1.2.2";
}
}