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.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+2b908b0f001bf1813ac29334903e9309d57e09a3")]
[assembly: AssemblyProduct("BattlefieldAnalysisBaseCollectSpaceJunk")]
[assembly: AssemblyTitle("BattlefieldAnalysisBaseCollectSpaceJunk")]
[assembly: AssemblyVersion("1.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.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.1.0")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource? Log;
internal static Plugin? Instance;
private static ConfigEntry<bool>? _enableDebugLog;
internal const int SpaceDropRollCount = 20;
internal const int SpaceDropCountMultiplier = 100;
internal const int SpaceCraftEnemyLevelFallback = 18;
private const float LandOffsetMin = 8f;
private const float LandOffsetMax = 22f;
internal const double FallDurationSeconds = 10.0;
internal const double MinFallSpeed = 30.0;
internal const double HandoffHeightAboveSurface = 10.0;
internal const double DecelStartDistFromLand = 100.0;
internal const double LandingSpeed = 30.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 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
Instance = this;
_enableDebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableDebugLog", false, "为 true 时在日志中输出详细的调试信息,用于排查问题。正常使用时建议设置为 false。\nSetting type: Boolean\nDefault value: false");
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, 100, 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_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: 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_01c0: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: 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_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
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 ((Object)(object)item2 == (Object)null || item < 0 || item >= trashObjPool.Length)
{
DestroyTrailGameObject(item2);
_trashTrails.RemoveAt(num);
}
else if (trashObjPool[item].item == 0)
{
DestroyTrailGameObject(item2);
_trashTrails.RemoveAt(num);
}
else 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_054f: 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_0576: Unknown result type (might be due to invalid IL or missing references)
//IL_057c: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
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 item = trashSystem.container.NewTrash(val15, val12);
_ourSpaceTrashTargets.Add((item, planetWithBattleBase.astroId));
if (_currentPlanetSpawnQuota > 0)
{
_currentPlanetSpawnQuota--;
}
try
{
if ((Object)(object)Instance != (Object)null && ShouldSpawnTrailForDrop(planetWithBattleBase, deathPos))
{
GameObject item2 = Instance.CreateTrailParticle();
Instance._trashTrails.Add((item, item2, -1f, landPosLocal, GameMain.gameTime, deathPos));
}
}
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 *= 100;
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 static void Postfix(TrashSystem __instance)
{
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0154: 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_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: 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_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: 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_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0969: Unknown result type (might be due to invalid IL or missing references)
//IL_0970: Unknown result type (might be due to invalid IL or missing references)
//IL_097a: Unknown result type (might be due to invalid IL or missing references)
//IL_0981: Unknown result type (might be due to invalid IL or missing references)
//IL_098b: Unknown result type (might be due to invalid IL or missing references)
//IL_0992: Unknown result type (might be due to invalid IL or missing references)
//IL_099c: Unknown result type (might be due to invalid IL or missing references)
//IL_09a3: Unknown result type (might be due to invalid IL or missing references)
//IL_09ad: Unknown result type (might be due to invalid IL or missing references)
//IL_09b4: Unknown result type (might be due to invalid IL or missing references)
//IL_09be: Unknown result type (might be due to invalid IL or missing references)
//IL_09c5: Unknown result type (might be due to invalid IL or missing references)
//IL_0a3c: Unknown result type (might be due to invalid IL or missing references)
//IL_0a49: Unknown result type (might be due to invalid IL or missing references)
//IL_0a51: Unknown result type (might be due to invalid IL or missing references)
//IL_0a5e: Unknown result type (might be due to invalid IL or missing references)
//IL_0a68: Unknown result type (might be due to invalid IL or missing references)
//IL_0a75: Unknown result type (might be due to invalid IL or missing references)
//IL_0bea: Unknown result type (might be due to invalid IL or missing references)
//IL_0bfa: Unknown result type (might be due to invalid IL or missing references)
//IL_0c01: Unknown result type (might be due to invalid IL or missing references)
//IL_0c13: Unknown result type (might be due to invalid IL or missing references)
//IL_0c23: Unknown result type (might be due to invalid IL or missing references)
//IL_0c2a: Unknown result type (might be due to invalid IL or missing references)
//IL_0c3c: Unknown result type (might be due to invalid IL or missing references)
//IL_0c4c: Unknown result type (might be due to invalid IL or missing references)
//IL_0c53: Unknown result type (might be due to invalid IL or missing references)
//IL_0c65: Unknown result type (might be due to invalid IL or missing references)
//IL_0c75: Unknown result type (might be due to invalid IL or missing references)
//IL_0c7c: Unknown result type (might be due to invalid IL or missing references)
//IL_0c8e: Unknown result type (might be due to invalid IL or missing references)
//IL_0c9e: Unknown result type (might be due to invalid IL or missing references)
//IL_0ca5: 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_0cc7: Unknown result type (might be due to invalid IL or missing references)
//IL_0cce: Unknown result type (might be due to invalid IL or missing references)
//IL_0ce2: Unknown result type (might be due to invalid IL or missing references)
//IL_0cee: Unknown result type (might be due to invalid IL or missing references)
//IL_0cfa: Unknown result type (might be due to invalid IL or missing references)
//IL_0aec: Unknown result type (might be due to invalid IL or missing references)
//IL_0af3: Unknown result type (might be due to invalid IL or missing references)
//IL_0afd: Unknown result type (might be due to invalid IL or missing references)
//IL_0b04: Unknown result type (might be due to invalid IL or missing references)
//IL_0b0e: Unknown result type (might be due to invalid IL or missing references)
//IL_0b15: Unknown result type (might be due to invalid IL or missing references)
//IL_0b1f: Unknown result type (might be due to invalid IL or missing references)
//IL_0b26: Unknown result type (might be due to invalid IL or missing references)
//IL_0b30: Unknown result type (might be due to invalid IL or missing references)
//IL_0b37: Unknown result type (might be due to invalid IL or missing references)
//IL_0b41: Unknown result type (might be due to invalid IL or missing references)
//IL_0b48: Unknown result type (might be due to invalid IL or missing references)
//IL_0d65: Unknown result type (might be due to invalid IL or missing references)
//IL_0d71: Unknown result type (might be due to invalid IL or missing references)
//IL_0d7d: Unknown result type (might be due to invalid IL or missing references)
//IL_0df1: Unknown result type (might be due to invalid IL or missing references)
//IL_0e07: Unknown result type (might be due to invalid IL or missing references)
//IL_0e1d: Unknown result type (might be due to invalid IL or missing references)
//IL_0e64: 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_0e90: Unknown result type (might be due to invalid IL or missing references)
//IL_0d36: Unknown result type (might be due to invalid IL or missing references)
//IL_0d45: Unknown result type (might be due to invalid IL or missing references)
//IL_0d54: Unknown result type (might be due to invalid IL or missing references)
//IL_0db9: Unknown result type (might be due to invalid IL or missing references)
//IL_0dc8: Unknown result type (might be due to invalid IL or missing references)
//IL_0dd7: Unknown result type (might be due to invalid IL or missing references)
//IL_0f43: Unknown result type (might be due to invalid IL or missing references)
//IL_0f73: Unknown result type (might be due to invalid IL or missing references)
//IL_0f7f: Unknown result type (might be due to invalid IL or missing references)
//IL_0faf: 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_0fea: Unknown result type (might be due to invalid IL or missing references)
//IL_0647: Unknown result type (might be due to invalid IL or missing references)
//IL_0656: Unknown result type (might be due to invalid IL or missing references)
//IL_0665: Unknown result type (might be due to invalid IL or missing references)
//IL_10a6: Unknown result type (might be due to invalid IL or missing references)
//IL_10b0: Unknown result type (might be due to invalid IL or missing references)
//IL_10bc: Unknown result type (might be due to invalid IL or missing references)
//IL_10ea: Unknown result type (might be due to invalid IL or missing references)
//IL_10f6: Unknown result type (might be due to invalid IL or missing references)
//IL_1102: Unknown result type (might be due to invalid IL or missing references)
//IL_0925: Unknown result type (might be due to invalid IL or missing references)
//IL_093a: Unknown result type (might be due to invalid IL or missing references)
//IL_094f: 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;
double gameTime = GameMain.gameTime;
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 = (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 num45;
double num46;
double num47;
double x;
double y;
double z;
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 = 30.0 / ((num10 > 1E-06) ? (num10 * 0.5) : 50.0);
num27 = ((num27 < 0.1) ? 0.1 : ((num27 > 1.0) ? 1.0 : num27));
double num28 = Math.Pow(num2, num27);
double num34;
double num35;
double num36;
if (num28 < 0.5)
{
double num29 = num28 * 2.0;
double val3 = num11 * num24 + num12 * num25 + num13 * num26;
double num30 = Math.Acos(Math.Max(-1.0, Math.Min(1.0, val3)));
double num31 = ((num30 > 1E-08) ? Math.Sin(num30) : 1E-08);
double num32 = Math.Sin((1.0 - num29) * num30) / num31;
double num33 = Math.Sin(num29 * num30) / num31;
num34 = num32 * num11 + num33 * num24;
num35 = num32 * num12 + num33 * num25;
num36 = num32 * num13 + num33 * num26;
}
else
{
double num37 = (num28 - 0.5) * 2.0;
double val4 = num24 * num14 + num25 * num15 + num26 * num16;
double num38 = Math.Acos(Math.Max(-1.0, Math.Min(1.0, val4)));
double num39 = ((num38 > 1E-08) ? Math.Sin(num38) : 1E-08);
double num40 = Math.Sin((1.0 - num37) * num38) / num39;
double num41 = Math.Sin(num37 * num38) / num39;
num34 = num40 * num24 + num41 * num14;
num35 = num40 * num25 + num41 * num15;
num36 = num40 * num26 + num41 * num16;
}
double num42 = Math.Sqrt(num34 * num34 + num35 * num35 + num36 * num36);
if (num42 > 1E-06)
{
num34 /= num42;
num35 /= num42;
num36 /= num42;
}
double val5 = num + 1200.0;
double num43;
if (num28 < 0.8)
{
num43 = Math.Max(num9, val5);
}
else
{
double num44 = (num28 - 0.8) / 0.2;
num44 = num44 * num44 * (3.0 - 2.0 * num44);
num43 = num9 + (num10 - num9) * num44;
}
num45 = uPos.x + num34 * num43;
num46 = uPos.y + num35 * num43;
num47 = uPos.z + num36 * num43;
double num48 = 0.01;
double num49 = Math.Pow(Math.Min(1.0, num2 + num48 / 10.0), num27);
double num53;
double num54;
double num55;
if (num49 < 0.5)
{
double num50 = num49 * 2.0;
double val6 = num11 * num24 + num12 * num25 + num13 * num26;
double num51 = Math.Acos(Math.Max(-1.0, Math.Min(1.0, val6)));
double num52 = ((num51 > 1E-08) ? Math.Sin(num51) : 1E-08);
num53 = (Math.Sin((1.0 - num50) * num51) * num11 + Math.Sin(num50 * num51) * num24) / num52;
num54 = (Math.Sin((1.0 - num50) * num51) * num12 + Math.Sin(num50 * num51) * num25) / num52;
num55 = (Math.Sin((1.0 - num50) * num51) * num13 + Math.Sin(num50 * num51) * num26) / num52;
}
else
{
double num56 = (num49 - 0.5) * 2.0;
double val7 = num24 * num14 + num25 * num15 + num26 * num16;
double num57 = Math.Acos(Math.Max(-1.0, Math.Min(1.0, val7)));
double num58 = ((num57 > 1E-08) ? Math.Sin(num57) : 1E-08);
num53 = (Math.Sin((1.0 - num56) * num57) * num24 + Math.Sin(num56 * num57) * num14) / num58;
num54 = (Math.Sin((1.0 - num56) * num57) * num25 + Math.Sin(num56 * num57) * num15) / num58;
num55 = (Math.Sin((1.0 - num56) * num57) * num26 + Math.Sin(num56 * num57) * num16) / num58;
}
double num59 = Math.Sqrt(num53 * num53 + num54 * num54 + num55 * num55);
if (num59 > 1E-06)
{
num53 /= num59;
num54 /= num59;
num55 /= num59;
}
double num60;
if (num49 < 0.8)
{
num60 = Math.Max(num9, val5);
}
else
{
double num61 = (num49 - 0.8) / 0.2;
num61 = num61 * num61 * (3.0 - 2.0 * num61);
num60 = num9 + (num10 - num9) * num61;
}
x = (uPos.x + num53 * num60 - num45) / num48;
y = (uPos.y + num54 * num60 - num46) / num48;
z = (uPos.z + num55 * num60 - num47) / num48;
}
else
{
double num62 = val2.x - item3.x;
double num63 = val2.y - item3.y;
double num64 = val2.z - item3.z;
double num65 = uPos.x - item3.x;
double num66 = uPos.y - item3.y;
double num67 = uPos.z - item3.z;
double num68 = num62 * num62 + num63 * num63 + num64 * num64;
if (num68 < 1E-10)
{
continue;
}
double num69 = (num62 * num65 + num63 * num66 + num64 * num67) / num68;
num69 = ((num69 < 0.0) ? 0.0 : ((num69 > 1.0) ? 1.0 : num69));
double num70 = item3.x + num69 * num62 - uPos.x;
double num71 = item3.y + num69 * num63 - uPos.y;
double num72 = item3.z + num69 * num64 - uPos.z;
double num73 = Math.Sqrt(num70 * num70 + num71 * num71 + num72 * num72);
double num74 = num + 1200.0;
double num75 = 0.0;
double num76 = 0.0;
double num77 = 0.0;
double num78 = 0.0;
if (num73 < num74)
{
num75 = Math.Max(0.0, num74 - num73);
double num79 = item3.x - uPos.x;
double num80 = item3.y - uPos.y;
double num81 = item3.z - uPos.z;
double num82 = val2.x - uPos.x;
double num83 = val2.y - uPos.y;
double num84 = val2.z - uPos.z;
num76 = num79 + num82;
num77 = num80 + num83;
num78 = num81 + num84;
double num85 = Math.Sqrt(num76 * num76 + num77 * num77 + num78 * num78);
if (num85 > 1E-06)
{
num76 /= num85;
num77 /= num85;
num78 /= num85;
}
else
{
double num86 = Math.Sqrt(num79 * num79 + num80 * num80 + num81 * num81);
if (num86 > 1E-06)
{
num76 = num79 / num86;
num77 = num80 / num86;
num78 = num81 / num86;
}
else
{
num75 = 0.0;
}
}
}
double num87 = item3.x + 0.333 * (val2.x - item3.x) + num76 * num75;
double num88 = item3.y + 0.333 * (val2.y - item3.y) + num77 * num75;
double num89 = item3.z + 0.333 * (val2.z - item3.z) + num78 * num75;
double num90 = item3.x + 0.667 * (val2.x - item3.x) + num76 * num75;
double num91 = item3.y + 0.667 * (val2.y - item3.y) + num77 * num75;
double num92 = item3.z + 0.667 * (val2.z - item3.z) + num78 * num75;
double num93 = num87 - uPos.x;
double num94 = num88 - uPos.y;
double num95 = num89 - uPos.z;
double num96 = Math.Sqrt(num93 * num93 + num94 * num94 + num95 * num95);
if (num96 < num74 && num96 > 1E-06)
{
double num97 = num74 / num96;
num87 = uPos.x + num93 * num97;
num88 = uPos.y + num94 * num97;
num89 = uPos.z + num95 * num97;
}
double num98 = num90 - uPos.x;
double num99 = num91 - uPos.y;
double num100 = num92 - uPos.z;
double num101 = Math.Sqrt(num98 * num98 + num99 * num99 + num100 * num100);
if (num101 < num74 && num101 > 1E-06)
{
double num102 = num74 / num101;
num90 = uPos.x + num98 * num102;
num91 = uPos.y + num99 * num102;
num92 = uPos.z + num100 * num102;
}
double num103 = 3.0 * (num87 - item3.x);
double num104 = 3.0 * (num88 - item3.y);
double num105 = 3.0 * (num89 - item3.z);
double num106 = 3.0 * (num90 - num87);
double num107 = 3.0 * (num91 - num88);
double num108 = 3.0 * (num92 - num89);
double num109 = 3.0 * (val2.x - num90);
double num110 = 3.0 * (val2.y - num91);
double num111 = 3.0 * (val2.z - num92);
double num112 = Math.Sqrt(num109 * num109 + num110 * num110 + num111 * num111);
double num113 = ((num112 > 1E-06) ? (30.0 / num112) : 1.0);
num113 = ((num113 < 0.1) ? 0.1 : ((num113 > 1.0) ? 1.0 : num113));
double num114 = Math.Pow(num2, num113);
double num115 = 1.0 - num114;
double num116 = num115 * num115;
double num117 = num116 * num115;
double num118 = num114 * num114;
double num119 = num118 * num114;
num45 = num117 * item3.x + 3.0 * num116 * num114 * num87 + 3.0 * num115 * num118 * num90 + num119 * val2.x;
num46 = num117 * item3.y + 3.0 * num116 * num114 * num88 + 3.0 * num115 * num118 * num91 + num119 * val2.y;
num47 = num117 * item3.z + 3.0 * num116 * num114 * num89 + 3.0 * num115 * num118 * num92 + num119 * val2.z;
double num120 = num116 * num103 + 2.0 * num115 * num114 * num106 + num118 * num109;
double num121 = num116 * num104 + 2.0 * num115 * num114 * num107 + num118 * num110;
double num122 = num116 * num105 + 2.0 * num115 * num114 * num108 + num118 * num111;
double x2 = ((num2 < 0.001) ? 0.001 : num2);
double num123 = num113 * Math.Pow(x2, num113 - 1.0) / 10.0;
x = num120 * num123;
y = num121 * num123;
z = num122 * num123;
}
double num124 = num45 - uPos.x;
double num125 = num46 - uPos.y;
double num126 = num47 - uPos.z;
if (!(Math.Sqrt(num124 * num124 + num125 * num125 + num126 * num126) - num < 10.0))
{
double num127 = val2.x - num45;
double num128 = val2.y - num46;
double num129 = val2.z - num47;
double num130 = Math.Sqrt(num127 * num127 + num128 * num128 + num129 * num129);
if (num130 <= 100.0 && num130 > 1E-06)
{
double num131 = 30.0 / num130;
x = num127 * num131;
y = num128 * num131;
z = num129 * num131;
}
ref TrashData reference = ref trashDataPool[item];
reference.uPos.x = num45;
reference.uPos.y = num46;
reference.uPos.z = num47;
reference.uVel.x = x;
reference.uVel.y = y;
reference.uVel.z = z;
}
}
}
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.1.0";
}
}