using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AutoPlaceMiner")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+cdcf76260bac6c63a00d1a533736b68db0e6965d")]
[assembly: AssemblyProduct("AutoPlaceMiner")]
[assembly: AssemblyTitle("AutoPlaceMiner")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AutoPlaceMiner;
[BepInPlugin("Satroki.dsp.AutoPlaceMiner", "AutoPlaceMiner", "1.0.0")]
[BepInProcess("DSPGAME.exe")]
public sealed class AutoPlaceMinerPlugin : BaseUnityPlugin
{
public const string PluginGuid = "Satroki.dsp.AutoPlaceMiner";
public const string PluginName = "AutoPlaceMiner";
public const string PluginVersion = "1.0.0";
internal static ManualLogSource Log;
internal static ConfigEntry<KeyCode> Hotkey;
internal static ConfigEntry<bool> SuppressCameraRoll;
internal static ConfigEntry<bool> ShowResult;
private Harmony _harmony;
private void Awake()
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
Hotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Hotkey", (KeyCode)113, "按下此键时,自动搜索大型采矿机覆盖矿脉最多的位置和角度并放置。");
SuppressCameraRoll = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SuppressCameraRoll", true, "手持大型采矿机时,拦截 Q 的相机横滚功能,避免自动摆放时相机同时滚动。");
ShowResult = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowResult", true, "在屏幕上显示自动摆放结果提示。");
_harmony = new Harmony("Satroki.dsp.AutoPlaceMiner");
try
{
_harmony.PatchAll(typeof(CameraRollPatch));
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("无法拦截相机横滚键,Q 可能同时滚动相机:" + ex.Message));
}
((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} v{1} 已加载,快捷键:{2}", "AutoPlaceMiner", "1.0.0", Hotkey.Value));
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
if ((int)Hotkey.Value == 0 || !Input.GetKeyDown(Hotkey.Value) || !Application.isFocused || VFInput.onGUI || VFInput.inputing)
{
return;
}
try
{
MinerPlacer.TryPlace();
}
catch (Exception arg)
{
((BaseUnityPlugin)this).Logger.LogError((object)$"自动摆放大型采矿机失败:{arg}");
Tip("自动摆放失败,请查看 BepInEx 日志");
}
}
internal static void Tip(string message)
{
if (message != null && ShowResult != null && ShowResult.Value)
{
UIRealtimeTip.Popup(message, true, 0);
}
}
internal static bool IsAmmBuildMode()
{
Player mainPlayer = GameMain.mainPlayer;
if (mainPlayer == null || (Object)(object)mainPlayer.controller == (Object)null || mainPlayer.inhandItemId <= 0)
{
return false;
}
PrefabDesc val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(mainPlayer.inhandItemId)?.prefabDesc;
if (val != null && val.veinMiner)
{
return val.isVeinCollector;
}
return false;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
internal static class CameraRollPatch
{
private static bool Prefix(ref InputValue __result)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Invalid comparison between Unknown and I4
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
if (AutoPlaceMinerPlugin.SuppressCameraRoll == null || !AutoPlaceMinerPlugin.SuppressCameraRoll.Value || AutoPlaceMinerPlugin.Hotkey == null || (int)AutoPlaceMinerPlugin.Hotkey.Value != 113 || !AutoPlaceMinerPlugin.IsAmmBuildMode())
{
return true;
}
__result = default(InputValue);
return false;
}
}
internal static class MinerPlacer
{
private readonly struct NearbyVein
{
public readonly Vector3 Normalized;
public readonly int Group;
public readonly EVeinType Type;
public NearbyVein(VeinData vein)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
Normalized = ((Vector3)(ref vein.pos)).normalized * 200f;
Group = vein.groupIndex;
Type = vein.type;
}
}
private sealed class Candidate
{
public Vector3 FieldCenter;
public Vector3 Position;
public float Yaw;
public int TargetCount;
public int TotalCount;
}
private const float CoarseAngleStep = 10f;
private const float FineAngleStep = 0.5f;
private const float CoarseCenterStep = 2f;
private const float FineCenterStep = 0.5f;
private const float RefineCenterRadius = 2.5f;
private const float RefineAngleRadius = 5f;
private const int RefineSeedCount = 8;
private const int ExtendedSeedCount = 12;
private const float ExtendedCenterRadius = 3f;
private const float ExtendedCenterStep = 1f;
private const float ExtendedAngleRadius = 10f;
private const float ExtendedAngleStep = 1f;
private const float NearbyRadius = 24f;
private const float TargetGroupRadius = 35f;
private const int MaxNativeChecks = 512;
private const int MaxSampledChecks = 256;
private const int VeinParameterOffset = 2048;
private static readonly FieldInfo TmpPackageField = typeof(BuildTool).GetField("tmpPackage", BindingFlags.Instance | BindingFlags.NonPublic);
private static readonly FieldInfo TmpInhandIdField = typeof(BuildTool).GetField("tmpInhandId", BindingFlags.Instance | BindingFlags.NonPublic);
private static readonly FieldInfo TmpInhandCountField = typeof(BuildTool).GetField("tmpInhandCount", BindingFlags.Instance | BindingFlags.NonPublic);
private static readonly FieldInfo PreviewModelsField = typeof(BuildModel).GetField("previewModels", BindingFlags.Instance | BindingFlags.NonPublic);
internal static void TryPlace()
{
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: 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_014c: 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_0154: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
if (!GameMain.isRunning || GameMain.isPaused || DSPGame.IsMenuDemo)
{
return;
}
Player mainPlayer = GameMain.mainPlayer;
PlanetData localPlanet = GameMain.localPlanet;
if (mainPlayer == null || localPlanet == null || !localPlanet.factoryLoaded)
{
return;
}
PlanetFactory factory = localPlanet.factory;
PlanetPhysics physics = localPlanet.physics;
if (factory == null || physics == null || physics.nearColliderLogic == null)
{
return;
}
PlayerAction_Build val = mainPlayer.controller?.actionBuild;
if (val == null || !val.active || (object)val.activeTool != val.clickTool)
{
return;
}
BuildTool_Click clickTool = val.clickTool;
if (!clickTool.cursorValid)
{
return;
}
ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(mainPlayer.inhandItemId);
if (val2 == null)
{
return;
}
PrefabDesc val3 = clickTool.handPrefabDesc ?? val2.prefabDesc;
if (val3 == null || !val3.veinMiner || !val3.isVeinCollector)
{
return;
}
Vector3 val4 = clickTool.castGroundPosSnapped;
if (((Vector3)(ref val4)).sqrMagnitude < 1f)
{
val4 = mainPlayer.buildTarget.position;
}
if (((Vector3)(ref val4)).sqrMagnitude < 1f)
{
return;
}
if (!HasItem(mainPlayer, ((Proto)val2).ID))
{
AutoPlaceMinerPlugin.Tip("背包中没有大型采矿机");
return;
}
if (!FindTargetGroup(factory, val4, localPlanet.realRadius, out var group, out var type, out var center, out var radius, out var veinCount))
{
AutoPlaceMinerPlugin.Tip("附近没有可开采的固体矿脉");
return;
}
List<Candidate> list = BuildQuickCandidates(factory, localPlanet, mainPlayer, group, type, center, radius, veinCount, val4, clickTool.yaw);
if (list.Count > 0 && Place(mainPlayer, localPlanet, factory, physics, clickTool, val2, val3, list, center, radius, veinCount, reportFailure: false))
{
ManualLogSource log = AutoPlaceMinerPlugin.Log;
if (log != null)
{
log.LogInfo((object)"大型采矿机使用中心快速候选完成放置");
}
return;
}
Stopwatch stopwatch = Stopwatch.StartNew();
List<Candidate> list2 = BuildCandidates(factory, localPlanet, mainPlayer, group, type, center, radius, veinCount, val4, clickTool.yaw);
stopwatch.Stop();
if (list2.Count == 0)
{
AutoPlaceMinerPlugin.Tip("当前矿脉附近没有可覆盖的建造位置");
return;
}
ManualLogSource log2 = AutoPlaceMinerPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)($"目标矿脉群 {group}({type}),共 {veinCount} 条,中心 {center},半径 {radius:0.0}m," + $"候选最大覆盖 {list2[0].TargetCount}/{veinCount} 条," + $"{list2.Count} 个位置/角度候选(搜索 {stopwatch.ElapsedMilliseconds}ms),开始原生建造校验"));
}
Place(mainPlayer, localPlanet, factory, physics, clickTool, val2, val3, list2, center, radius, veinCount, reportFailure: true);
}
private static bool Place(Player player, PlanetData planet, PlanetFactory factory, PlanetPhysics physics, BuildTool_Click click, ItemProto item, PrefabDesc desc, List<Candidate> candidates, Vector3 searchCenter, float searchRadius, int groupVeinCount, bool reportFailure)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//IL_0484: Unknown result type (might be due to invalid IL or missing references)
//IL_0485: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: 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_03b2: Unknown result type (might be due to invalid IL or missing references)
//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_042b: Unknown result type (might be due to invalid IL or missing references)
BuildTool_Click val = new BuildTool_Click();
((BuildTool)val)._Init(GameMain.data);
try
{
((BuildTool)val).planet = planet;
((BuildTool)val).factory = factory;
val.handItem = item;
val.handPrefabDesc = desc;
val.castGroundPosSnapped = candidates[0].Position;
if (!PrepareValidator((BuildTool)(object)val))
{
if (reportFailure)
{
AutoPlaceMinerPlugin.Tip("无法初始化建造校验器,请查看日志");
}
return false;
}
BuildPreview val2 = new BuildPreview();
((BuildTool)val).buildPreviews.Add(val2);
int livePreviewIndex = ((((BuildTool)click).buildPreviews != null && ((BuildTool)click).buildPreviews.Count > 0) ? ((BuildTool)click).buildPreviews[0].previewIndex : (-1));
if (((BuildTool)click).buildPreviews != null && ((BuildTool)click).buildPreviews.Count > 0)
{
_ = ((BuildTool)click).buildPreviews[0].condition;
}
Vector3 test = player.controller.cmd.test;
List<GameObject> hidden = HideLivePreviewModels(((BuildTool)click).actionBuild.model);
try
{
physics.RefreshColliders();
physics.nearColliderLogic.ActiveCollidersInArea(searchCenter, Mathf.Max(64f, searchRadius + 52f));
Physics.SyncTransforms();
Candidate candidate = null;
int total = 0;
Dictionary<EBuildCondition, int> dictionary = new Dictionary<EBuildCondition, int>();
int num = 0;
foreach (Candidate candidate3 in candidates)
{
if ((candidate != null && (candidate3.TargetCount < candidate.TargetCount || (candidate3.TargetCount == candidate.TargetCount && candidate3.TotalCount <= total))) || num++ >= 512)
{
break;
}
if (!Validate(val, val2, item, desc, candidate3, livePreviewIndex, out var total2, out var condition))
{
dictionary[condition] = ((!dictionary.TryGetValue(condition, out var value)) ? 1 : (value + 1));
}
else if (candidate == null || candidate3.TargetCount > candidate.TargetCount || (candidate3.TargetCount == candidate.TargetCount && total2 > total))
{
candidate = candidate3;
total = total2;
}
}
if (candidate == null && candidates.Count > 512)
{
int num2 = Mathf.Max(1, candidates.Count / 256);
for (int i = 512; i < candidates.Count; i += num2)
{
Candidate candidate2 = candidates[i];
if (!Validate(val, val2, item, desc, candidate2, livePreviewIndex, out var total3, out var condition2))
{
dictionary[condition2] = ((!dictionary.TryGetValue(condition2, out var value2)) ? 1 : (value2 + 1));
}
else if (candidate == null || candidate2.TargetCount > candidate.TargetCount || (candidate2.TargetCount == candidate.TargetCount && total3 > total))
{
candidate = candidate2;
total = total3;
}
}
}
if (candidate == null)
{
List<string> list = new List<string>();
foreach (KeyValuePair<EBuildCondition, int> item2 in dictionary)
{
list.Add($"{item2.Key}×{item2.Value}");
}
ManualLogSource log = AutoPlaceMinerPlugin.Log;
if (log != null)
{
log.LogWarning((object)("大型采矿机候选位置被原生规则拒绝:" + string.Join(", ", list) + (reportFailure ? "" : "(快速候选,接着做完整搜索)")));
}
if (reportFailure)
{
AutoPlaceMinerPlugin.Tip("未找到无碰撞的摆放位置");
}
return false;
}
if (!Validate(val, val2, item, desc, candidate, livePreviewIndex, out total, out var _))
{
if (reportFailure)
{
AutoPlaceMinerPlugin.Tip("选中的位置已失效,请重试");
}
return false;
}
click.yaw = candidate.Yaw;
click.castGroundPosSnapped = candidate.Position;
((BuildTool)click).actionBuild.buildTargetPositionWanted = candidate.Position;
val.castGroundPosSnapped = candidate.Position;
val.CreatePrebuilds();
int num3 = ((val2.objId < 0) ? (-val2.objId) : 0);
if (num3 <= 0)
{
if (reportFailure)
{
AutoPlaceMinerPlugin.Tip("放置失败:物品不足或位置无效");
}
return false;
}
ManualLogSource log2 = AutoPlaceMinerPlugin.Log;
if (log2 != null)
{
log2.LogInfo((object)($"已放置大型采矿机:预建造 {num3},位置 {candidate.Position},角度 {candidate.Yaw:0.0}°," + $"矿脉群共 {groupVeinCount} 条,本机覆盖当前群 {candidate.TargetCount} 条,同类型总覆盖 {total} 条"));
}
return true;
}
finally
{
player.controller.cmd.test = test;
RestoreLivePreviewModels(hidden);
}
}
finally
{
((BuildTool)val)._Free();
}
}
private static bool PrepareValidator(BuildTool validator)
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
if (TmpPackageField == null || TmpInhandIdField == null || TmpInhandCountField == null)
{
ManualLogSource log = AutoPlaceMinerPlugin.Log;
if (log != null)
{
log.LogError((object)"找不到 BuildTool 的 tmpPackage/tmpInhandId/tmpInhandCount 字段,游戏版本可能已变更");
}
AutoPlaceMinerPlugin.Tip("游戏版本不兼容:找不到建造校验字段");
return false;
}
if (TmpPackageField.GetValue(validator) == null)
{
TmpPackageField.SetValue(validator, (object?)new StorageComponent(1));
}
return true;
}
private static bool Validate(BuildTool_Click validator, BuildPreview preview, ItemProto item, PrefabDesc desc, Candidate candidate, int livePreviewIndex, out int total, out EBuildCondition condition)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Expected I4, but got Unknown
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Expected I4, but got Unknown
total = 0;
condition = (EBuildCondition)1;
Vector3 position = candidate.Position;
preview.ResetAll();
preview.item = item;
preview.desc = desc;
preview.lpos = (preview.lpos2 = position);
preview.lrot = (preview.lrot2 = Maths.SphericalRotation(position, candidate.Yaw));
preview.previewIndex = livePreviewIndex;
preview.condition = (EBuildCondition)0;
validator.castGroundPosSnapped = position;
((BuildTool)validator).controller.cmd.test = position;
TmpInhandIdField.SetValue(validator, ((Proto)item).ID);
TmpInhandCountField.SetValue(validator, 1);
if (!validator.CheckBuildConditions())
{
condition = (EBuildCondition)(int)preview.condition;
return false;
}
condition = (EBuildCondition)(int)preview.condition;
if ((int)preview.condition != 0 || preview.coverObjId != 0)
{
return false;
}
if (preview.parameters == null || preview.paramCount <= 2048)
{
return false;
}
for (int i = 2048; i < preview.paramCount; i++)
{
if (preview.parameters[i] > 0)
{
total++;
}
}
return total > 0;
}
private static List<Candidate> BuildQuickCandidates(PlanetFactory factory, PlanetData planet, Player player, int targetGroup, EVeinType targetType, Vector3 groupCenter, float groupRadius, int groupVeinCount, Vector3 currentPosition, float currentYaw)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: 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_00e2: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
List<Candidate> list = new List<Candidate>();
if (groupVeinCount <= 0)
{
return list;
}
float num = Mathf.Clamp(groupRadius + 8f, 8f, 32f);
List<NearbyVein> nearby = CollectNearbyVeins(factory, groupCenter, num + 24f, planet.realRadius);
Quaternion val = Maths.SphericalRotation(groupCenter, 0f);
Vector3 val2 = val * Vector3.right;
Vector3 val3 = val * Vector3.forward;
float num2 = player.mecha.buildArea + 1f;
float maxDistanceSquared = num2 * num2;
for (float num3 = -2f; num3 <= 2f; num3 += 2f)
{
for (float num4 = -2f; num4 <= 2f; num4 += 2f)
{
Vector3 val4 = groupCenter + val2 * num3 + val3 * num4;
Vector3 normalized = ((Vector3)(ref val4)).normalized;
Vector3 fieldCenter = normalized * QueryHeight(planet, normalized, ((Vector3)(ref groupCenter)).magnitude);
for (float num5 = 0f; num5 < 360f; num5 += 10f)
{
Candidate candidate = Evaluate(planet, fieldCenter, num5, nearby, targetGroup, targetType, player.position, maxDistanceSquared);
if (candidate != null && candidate.TargetCount >= groupVeinCount)
{
list.Add(candidate);
}
}
}
}
list.Sort((Candidate a, Candidate b) => Compare(a, b, currentPosition, currentYaw));
return list;
}
private static List<Candidate> BuildCandidates(PlanetFactory factory, PlanetData planet, Player player, int targetGroup, EVeinType targetType, Vector3 groupCenter, float groupRadius, int groupVeinCount, Vector3 currentPosition, float currentYaw)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: 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_0142: 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_0223: 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_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: 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_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_0313: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_040c: Unknown result type (might be due to invalid IL or missing references)
//IL_0413: Unknown result type (might be due to invalid IL or missing references)
//IL_0418: Unknown result type (might be due to invalid IL or missing references)
//IL_041d: Unknown result type (might be due to invalid IL or missing references)
//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
//IL_04af: 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_04b7: Unknown result type (might be due to invalid IL or missing references)
//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
//IL_04c1: 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_04cc: 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_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_04f3: 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_0505: Unknown result type (might be due to invalid IL or missing references)
Quaternion val = Maths.SphericalRotation(groupCenter, 0f);
Vector3 val2 = val * Vector3.right;
Vector3 val3 = val * Vector3.forward;
float num = Mathf.Clamp(groupRadius + 8f, 8f, 32f);
List<NearbyVein> nearby = CollectNearbyVeins(factory, groupCenter, num + 24f, planet.realRadius);
float num2 = player.mecha.buildArea + 1f;
float maxDistanceSquared = num2 * num2;
List<Candidate> list = new List<Candidate>();
Vector3 val4 = Maths.SphericalRotation(currentPosition, currentYaw) * Vector3.forward;
Candidate candidate = Evaluate(planet, currentPosition - val4 * 10f, currentYaw, nearby, targetGroup, targetType, player.position, maxDistanceSquared);
if (candidate != null)
{
list.Add(candidate);
}
Vector3 val5;
for (float num3 = 0f - num; num3 <= num; num3 += 2f)
{
for (float num4 = 0f - num; num4 <= num; num4 += 2f)
{
val5 = groupCenter + val2 * num3 + val3 * num4;
Vector3 normalized = ((Vector3)(ref val5)).normalized;
Vector3 fieldCenter = normalized * QueryHeight(planet, normalized, ((Vector3)(ref groupCenter)).magnitude);
for (float num5 = 0f; num5 < 360f; num5 += 10f)
{
Candidate candidate2 = Evaluate(planet, fieldCenter, num5, nearby, targetGroup, targetType, player.position, maxDistanceSquared);
if (candidate2 != null)
{
list.Add(candidate2);
}
}
}
}
list.Sort((Candidate a, Candidate b) => Compare(a, b, currentPosition, currentYaw));
foreach (Candidate item in list)
{
if (item.TargetCount >= groupVeinCount)
{
return list;
}
}
List<Candidate> list2 = new List<Candidate>();
foreach (Candidate item2 in list)
{
if (list2.Count >= 8)
{
break;
}
bool flag = false;
foreach (Candidate item3 in list2)
{
val5 = item3.FieldCenter - item2.FieldCenter;
if (((Vector3)(ref val5)).sqrMagnitude < 9f)
{
flag = true;
break;
}
}
if (!flag)
{
list2.Add(item2);
}
}
List<Candidate> list3 = new List<Candidate>(list);
foreach (Candidate item4 in list2)
{
for (float num6 = -2.5f; num6 <= 2.5f; num6 += 0.5f)
{
for (float num7 = -2.5f; num7 <= 2.5f; num7 += 0.5f)
{
val5 = item4.FieldCenter + val2 * num6 + val3 * num7;
Vector3 normalized2 = ((Vector3)(ref val5)).normalized;
Vector3 fieldCenter2 = normalized2 * QueryHeight(planet, normalized2, ((Vector3)(ref item4.FieldCenter)).magnitude);
for (float num8 = -5f; num8 <= 5f; num8 += 0.5f)
{
Candidate candidate3 = Evaluate(planet, fieldCenter2, item4.Yaw + num8, nearby, targetGroup, targetType, player.position, maxDistanceSquared);
if (candidate3 != null)
{
list3.Add(candidate3);
}
}
}
}
}
list3.Sort((Candidate a, Candidate b) => Compare(a, b, currentPosition, currentYaw));
if (list3.Count > 0 && list3[0].TargetCount < groupVeinCount)
{
List<Candidate> list4 = new List<Candidate>();
foreach (Candidate item5 in list3)
{
if (list4.Count >= 12)
{
break;
}
bool flag2 = false;
foreach (Candidate item6 in list4)
{
val5 = item6.FieldCenter - item5.FieldCenter;
if (((Vector3)(ref val5)).sqrMagnitude < 25f)
{
flag2 = true;
break;
}
}
if (!flag2)
{
list4.Add(item5);
}
}
foreach (Candidate item7 in list4)
{
for (float num9 = -3f; num9 <= 3f; num9 += 1f)
{
for (float num10 = -3f; num10 <= 3f; num10 += 1f)
{
val5 = item7.FieldCenter + val2 * num9 + val3 * num10;
Vector3 normalized3 = ((Vector3)(ref val5)).normalized;
Vector3 fieldCenter3 = normalized3 * QueryHeight(planet, normalized3, ((Vector3)(ref item7.FieldCenter)).magnitude);
for (float num11 = -10f; num11 <= 10f; num11 += 1f)
{
Candidate candidate4 = Evaluate(planet, fieldCenter3, item7.Yaw + num11, nearby, targetGroup, targetType, player.position, maxDistanceSquared);
if (candidate4 != null)
{
list3.Add(candidate4);
}
}
}
}
}
list3.Sort((Candidate a, Candidate b) => Compare(a, b, currentPosition, currentYaw));
}
return list3;
}
private static Candidate Evaluate(PlanetData planet, Vector3 fieldCenter, float yaw, List<NearbyVein> nearby, int targetGroup, EVeinType targetType, Vector3 playerPosition, float maxDistanceSquared)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: 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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: 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_0097: Invalid comparison between Unknown and I4
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: 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_0143: 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_0147: 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_00e2: 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_0161: 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_0168: 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)
Vector3 val = Maths.SphericalRotation(fieldCenter, yaw) * Vector3.forward;
Vector3 val2 = fieldCenter + val * 10f;
Vector3 normalized = ((Vector3)(ref val2)).normalized;
Quaternion val3 = Maths.SphericalRotation(normalized, yaw);
Vector3 val4 = val3 * Vector3.right;
Vector3 val5 = val3 * Vector3.forward;
Vector3 val6 = normalized * 200f - val5 * 10f;
Vector3 val7 = -val5;
int num = 0;
int num2 = 0;
bool flag = false;
foreach (NearbyVein item in nearby)
{
if ((int)item.Type == 7)
{
continue;
}
Vector3 val8 = item.Normalized - val6;
if (!(((Vector3)(ref val8)).sqrMagnitude > 100f) && !(Mathf.Abs(Vector3.Dot(val8, val7)) > 7.75f) && !(Mathf.Abs(Vector3.Dot(val8, val4)) > 6.25f))
{
if (item.Type != targetType)
{
flag = true;
break;
}
num2++;
if (item.Group == targetGroup)
{
num++;
}
}
}
if (flag || num == 0)
{
return null;
}
Vector3 val9 = normalized * QueryHeight(planet, normalized, ((Vector3)(ref fieldCenter)).magnitude);
val2 = val9 - playerPosition;
if (((Vector3)(ref val2)).sqrMagnitude > maxDistanceSquared)
{
return null;
}
return new Candidate
{
FieldCenter = fieldCenter,
Position = val9,
Yaw = yaw,
TargetCount = num,
TotalCount = num2
};
}
private static List<NearbyVein> CollectNearbyVeins(PlanetFactory factory, Vector3 center, float radius, float realRadius)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
List<NearbyVein> list = new List<NearbyVein>();
VeinData[] veinPool = factory.veinPool;
float num = radius * radius;
float num2 = realRadius - 40f;
for (int i = 1; i < factory.veinCursor && i < veinPool.Length; i++)
{
ref VeinData reference = ref veinPool[i];
if (reference.id == i && reference.amount > 0 && (int)reference.type != 0 && reference.colliderId > 0 && !(((Vector3)(ref reference.pos)).magnitude < num2))
{
Vector3 val = reference.pos - center;
if (!(((Vector3)(ref val)).sqrMagnitude > num))
{
list.Add(new NearbyVein(reference));
}
}
}
return list;
}
private static bool FindTargetGroup(PlanetFactory factory, Vector3 position, float realRadius, out int group, out EVeinType type, out Vector3 center, out float radius, out int veinCount)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Invalid comparison between Unknown and I4
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Invalid comparison between Unknown and I4
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected I4, but got Unknown
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Invalid comparison between Unknown and I4
//IL_0137: 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_0140: 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_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_01eb: 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)
group = 0;
type = (EVeinType)0;
center = position;
radius = 0f;
veinCount = 0;
bool flag = false;
float num = 1225f;
float num2 = realRadius - 40f;
VeinData[] veinPool = factory.veinPool;
Vector3 val;
for (int i = 1; i < factory.veinCursor && i < veinPool.Length; i++)
{
ref VeinData reference = ref veinPool[i];
if (reference.id == i && reference.amount > 0 && (int)reference.type != 0 && (int)reference.type != 7 && reference.colliderId > 0 && !(((Vector3)(ref reference.pos)).magnitude < num2))
{
val = reference.pos - position;
float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
if (!(sqrMagnitude >= num))
{
num = sqrMagnitude;
group = reference.groupIndex;
type = (EVeinType)(int)reference.type;
flag = true;
}
}
}
if (!flag)
{
return false;
}
Vector3 val2 = Vector3.zero;
int num3 = 0;
for (int j = 1; j < factory.veinCursor && j < veinPool.Length; j++)
{
ref VeinData reference2 = ref veinPool[j];
if (reference2.id == j && reference2.amount > 0 && reference2.groupIndex == group && (int)reference2.type == (int)type && reference2.colliderId > 0 && !(((Vector3)(ref reference2.pos)).magnitude < num2))
{
val2 += reference2.pos;
num3++;
}
}
if (num3 == 0)
{
return false;
}
center = val2 / (float)num3;
veinCount = num3;
float num4 = 0f;
for (int k = 1; k < factory.veinCursor && k < veinPool.Length; k++)
{
ref VeinData reference3 = ref veinPool[k];
if (reference3.id == k && reference3.amount > 0 && reference3.groupIndex == group && (int)reference3.type == (int)type && reference3.colliderId > 0 && !(((Vector3)(ref reference3.pos)).magnitude < num2))
{
float num5 = num4;
val = reference3.pos - center;
num4 = Mathf.Max(num5, ((Vector3)(ref val)).sqrMagnitude);
}
}
radius = Mathf.Sqrt(num4);
return true;
}
private static float QueryHeight(PlanetData planet, Vector3 direction, float fallback)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (planet?.data != null)
{
float num = planet.data.QueryModifiedHeight(direction);
if (num > 1f)
{
return num + 0.1f;
}
}
return fallback + 0.1f;
}
private static int Compare(Candidate a, Candidate b, Vector3 currentPosition, float currentYaw)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
int num = b.TargetCount.CompareTo(a.TargetCount);
if (num != 0)
{
return num;
}
num = b.TotalCount.CompareTo(a.TotalCount);
if (num != 0)
{
return num;
}
Vector3 val = a.Position - currentPosition;
float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
val = b.Position - currentPosition;
num = sqrMagnitude.CompareTo(((Vector3)(ref val)).sqrMagnitude);
if (num != 0)
{
return num;
}
num = YawDistance(a.Yaw, currentYaw).CompareTo(YawDistance(b.Yaw, currentYaw));
if (num == 0)
{
return a.Yaw.CompareTo(b.Yaw);
}
return num;
}
private static bool HasItem(Player player, int itemId)
{
if (player.inhandItemId == itemId && player.inhandItemCount > 0)
{
return true;
}
if (player.package != null)
{
return player.package.GetItemCount(itemId) > 0;
}
return false;
}
private static float YawDistance(float a, float b)
{
float num = Mathf.Abs(Mathf.Repeat(a - b, 360f));
return Mathf.Min(num, 360f - num);
}
private static List<GameObject> HideLivePreviewModels(BuildModel model)
{
List<GameObject> list = new List<GameObject>();
if (model == null || PreviewModelsField == null)
{
return list;
}
try
{
if (!(PreviewModelsField.GetValue(model) is List<BuildPreviewModel> list2))
{
return list;
}
foreach (BuildPreviewModel item in list2)
{
if (!((Object)(object)item == (Object)null) && !((Object)(object)((Component)item).gameObject == (Object)null) && ((Component)item).gameObject.activeSelf)
{
((Component)item).gameObject.SetActive(false);
list.Add(((Component)item).gameObject);
}
}
}
catch (Exception ex)
{
ManualLogSource log = AutoPlaceMinerPlugin.Log;
if (log != null)
{
log.LogWarning((object)("隐藏建造预览模型失败:" + ex.Message));
}
}
return list;
}
private static void RestoreLivePreviewModels(List<GameObject> hidden)
{
foreach (GameObject item in hidden)
{
if ((Object)(object)item == (Object)null)
{
continue;
}
try
{
item.SetActive(true);
}
catch (Exception ex)
{
ManualLogSource log = AutoPlaceMinerPlugin.Log;
if (log != null)
{
log.LogWarning((object)("恢复建造预览模型失败:" + ex.Message));
}
}
}
}
}