using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SplitterOverBelt")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SplitterOverBelt")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("01fb7e35-252b-4bbd-b99e-c28d4e7819cf")]
[assembly: AssemblyFileVersion("1.1.7.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.7.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace SplitterOverBelt
{
[BepInPlugin("com.hetima.dsp.SplitterOverBelt", "SplitterOverBelt", "1.1.7")]
public class SplitterOverBelt : BaseUnityPlugin
{
public struct BeltData
{
public bool validBelt;
public int splitterSlot;
public Vector3 slotPos;
public Quaternion slotRot;
public bool isOutput;
public EntityData entityData;
}
private static class Patch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(BuildTool_Click), "CheckBuildConditions")]
[HarmonyAfter(new string[] { "dsp.nebula-multiplayer" })]
public static void BuildTool_Click_CheckBuildConditions_Postfix(BuildTool_Click __instance, ref bool __result)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Invalid comparison between Unknown and I4
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
_doMod = false;
_warningString = null;
if (((BuildTool)__instance).buildPreviews.Count != 1)
{
return;
}
BuildPreview val = ((BuildTool)__instance).buildPreviews[0];
if (!val.desc.isSplitter && !val.desc.isPiler)
{
return;
}
if ((int)val.condition == 0)
{
_doMod = true;
}
else if ((int)val.condition == 34 && CanBuildSplitter(__instance, val))
{
__result = true;
val.condition = (EBuildCondition)0;
((BuildTool)__instance).actionBuild.model.cursorText = val.conditionText;
((BuildTool)__instance).actionBuild.model.cursorState = 0;
if (!VFInput.onGUI)
{
UICursor.SetCursor((ECursor)0);
}
_doMod = true;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(BuildTool_Click), "CreatePrebuilds")]
[HarmonyBefore(new string[] { "dsp.nebula-multiplayer" })]
public static void BuildTool_Click_CreatePrebuilds_Prefix(BuildTool_Click __instance)
{
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
if (!_doMod || ((BuildTool)__instance).buildPreviews.Count != 1)
{
return;
}
_doMod = false;
BuildPreview val = ((BuildTool)__instance).buildPreviews[0];
if ((val.desc.isSplitter || val.desc.isPiler) && GatherNearBelts(__instance, val))
{
DeleteConfusedBelts(__instance, val);
}
if (_beltEntities.Count > 0)
{
if ((val.desc.isSplitter || val.desc.isPiler) && (int)val.condition == 0)
{
ConnectBelts(__instance, ((BuildTool)__instance).buildPreviews);
}
_beltEntities.Clear();
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(BuildTool_Click), "ConfirmOperation")]
public static void BuildTool_Click_ConfirmOperation_Postfix(BuildTool_Click __instance, ref bool __result)
{
if (!__result && _doMod)
{
if (_warningString != null)
{
BuildModel model = ((BuildTool)__instance).actionBuild.model;
model.cursorText = model.cursorText + " <color=#fbce32ff>" + _warningString + "</color>";
_warningString = null;
}
_doMod = false;
}
}
}
public class BuildToolAccess : BuildTool
{
public static Collider[] TmpCols => BuildTool._tmp_cols;
public static int[] nearObjectIds => BuildTool._nearObjectIds;
public static int nearObjectCount
{
get
{
return BuildTool._nearObjectCount;
}
set
{
BuildTool._nearObjectCount = value;
}
}
public static int TmpColsLength()
{
int num = 0;
for (int i = 0; i < BuildTool._tmp_cols.Length && (Object)(object)BuildTool._tmp_cols[i] != (Object)null; i++)
{
num++;
}
return num;
}
}
public const string __NAME__ = "SplitterOverBelt";
public const string __GUID__ = "com.hetima.dsp.SplitterOverBelt";
protected static List<EntityData> _beltEntities = new List<EntityData>(20);
protected static bool _doMod = false;
protected static string _warningString;
internal static ManualLogSource Logger;
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
new Harmony("com.hetima.dsp.SplitterOverBelt").PatchAll(typeof(Patch));
}
public static void Log(string str)
{
Logger.LogInfo((object)str);
}
private static void AddBeltEntity(EntityData e)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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)
bool flag = true;
for (int num = _beltEntities.Count - 1; num >= 0; num--)
{
if (_beltEntities[num].beltId == e.beltId)
{
flag = false;
break;
}
}
if (flag)
{
_beltEntities.Add(e);
}
}
private static void ValidateBelt(BuildTool_Click tool, BuildPreview buildPreview, Pose slotPose, EntityData entityData, out bool validBelt, out bool isOutput)
{
//IL_0009: 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_0014: 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_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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_0052: 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_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_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
isOutput = false;
validBelt = false;
Vector3 val = new Pose(buildPreview.lpos, buildPreview.lrot).rotation * ((Pose)(ref slotPose)).forward;
BeltComponent val2 = ((BuildTool)tool).factory.cargoTraffic.beltPool[entityData.beltId];
CargoPath cargoPath = ((BuildTool)tool).factory.cargoTraffic.GetCargoPath(val2.segPathId);
Quaternion val3 = cargoPath.pointRot[val2.segIndex];
Quaternion val4 = cargoPath.pointRot[val2.segIndex + val2.segLength - 1];
if ((double)Vector3.Dot(val3 * Vector3.forward, val4 * Vector3.forward) > 0.5)
{
float num = Vector3.Dot(val3 * Vector3.forward, val);
if (Math.Abs(num) > 0.5f)
{
validBelt = true;
isOutput = num > 0.5f;
}
}
else if (Vector3.Dot(val3 * Vector3.forward, val) > 0.5f)
{
validBelt = true;
isOutput = true;
}
else if (Vector3.Dot(val4 * Vector3.forward, val) < -0.5f)
{
validBelt = true;
isOutput = false;
}
}
private static void ValidateBelt2(BuildTool_Click tool, BuildPreview buildPreview, Pose slotPose, EntityData entityData, out bool validBelt, out bool isOutput)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
isOutput = false;
validBelt = false;
int id = entityData.id;
bool flag = false;
bool flag2 = false;
bool flag3 = default(bool);
int num = default(int);
int num2 = default(int);
for (int i = 0; i < 4; i++)
{
((BuildTool)tool).factory.ReadObjectConn(id, i, ref flag3, ref num, ref num2);
if (num != 0)
{
if (flag3)
{
flag2 = true;
}
else
{
flag = true;
}
}
}
if (flag2 == flag)
{
validBelt = false;
}
else if (flag2)
{
isOutput = true;
validBelt = true;
}
else if (flag)
{
isOutput = false;
validBelt = true;
}
}
public static void ConnectBelts(BuildTool_Click tool, List<BuildPreview> buildPreviews)
{
//IL_003b: 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_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: 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_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: 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_00d3: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: 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_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0292: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Expected O, but got Unknown
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: 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_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0303: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_030f: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
//IL_032b: Unknown result type (might be due to invalid IL or missing references)
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_0337: Unknown result type (might be due to invalid IL or missing references)
//IL_033c: Unknown result type (might be due to invalid IL or missing references)
BuildPreview val = buildPreviews[0];
Pose[] portPoses = val.desc.portPoses;
Vector3[] array = (Vector3[])(object)new Vector3[portPoses.Length];
Vector3[] array2 = (Vector3[])(object)new Vector3[portPoses.Length];
BeltData[] array3 = new BeltData[portPoses.Length];
float[] array4 = new float[portPoses.Length];
Quaternion val2 = val.lrot;
if (val.isConnNode)
{
val2 = Maths.SphericalRotation(val.lpos, 0f);
}
for (int i = 0; i < portPoses.Length; i++)
{
array4[i] = ((BuildTool)tool).actionBuild.planetAux.activeGrid.CalcLocalGridSize(val.lpos, val2 * ((Pose)(ref portPoses[i])).forward);
Vector3 val3 = val.lpos + val2 * (portPoses[i].position + ((Pose)(ref portPoses[i])).forward * array4[i]);
array[i] = ((BuildTool)tool).actionBuild.planetAux.Snap(val3, false);
array2[i] = val.lpos + val2 * portPoses[i].position;
}
for (int num = _beltEntities.Count - 1; num >= 0; num--)
{
EntityData val4 = _beltEntities[num];
for (int j = 0; j < array.Length; j++)
{
Vector3 val5 = ((BuildTool)tool).actionBuild.planetAux.Snap(val4.pos, false) - array[j];
float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude;
float num2 = array4[j] * 0.17f;
if (!(sqrMagnitude < num2 * num2))
{
continue;
}
if (array3[j].validBelt)
{
((BuildTool)tool).actionBuild.DoDismantleObject(val4.id);
_beltEntities.RemoveAt(num);
break;
}
Quaternion rotation = portPoses[j].rotation;
ValidateBelt2(tool, val, portPoses[j], val4, out var validBelt, out var isOutput);
if (validBelt)
{
array3[j].splitterSlot = j;
array3[j].slotPos = array2[j];
array3[j].slotRot = rotation;
array3[j].entityData = val4;
array3[j].validBelt = validBelt;
array3[j].isOutput = isOutput;
}
break;
}
}
bool flag = default(bool);
int num4 = default(int);
int num5 = default(int);
for (int k = 0; k < array.Length; k++)
{
if (!array3[k].validBelt)
{
continue;
}
BuildPreview val6 = new BuildPreview();
PrefabDesc desc = ((ProtoSet<ModelProto>)(object)LDB.models).Select((int)array3[k].entityData.modelIndex)?.prefabDesc;
val6.ResetAll();
val6.item = ((ProtoSet<ItemProto>)(object)LDB.items).Select((int)array3[k].entityData.protoId);
val6.desc = desc;
val6.lpos = array3[k].slotPos;
val6.lpos2 = Vector3.zero;
val6.lrot = val2 * array3[k].slotRot;
val6.lrot2 = Quaternion.identity;
val6.needModel = false;
val6.isConnNode = false;
val6.outputOffset = 0;
int num3 = 1;
if (!array3[k].isOutput)
{
num3 = 0;
}
else
{
for (int l = 1; l < 4; l++)
{
((BuildTool)tool).factory.ReadObjectConn(array3[k].entityData.id, l, ref flag, ref num4, ref num5);
if (num4 == 0)
{
num3 = l;
break;
}
}
}
if (array3[k].isOutput)
{
val6.output = null;
val6.outputObjId = array3[k].entityData.id;
val6.outputFromSlot = 0;
val6.outputToSlot = num3;
val6.input = val;
val6.inputObjId = 0;
val6.inputToSlot = 1;
val6.inputFromSlot = array3[k].splitterSlot;
}
else
{
val6.output = val;
val6.outputObjId = 0;
val6.outputFromSlot = 0;
val6.outputToSlot = array3[k].splitterSlot;
val6.input = null;
val6.inputObjId = array3[k].entityData.id;
val6.inputToSlot = 1;
val6.inputFromSlot = num3;
}
buildPreviews.Add(val6);
}
}
public static void DeleteConfusedBelts(BuildTool_Click tool, BuildPreview buildPreview)
{
//IL_0021: 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_0031: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: 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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: 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_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: 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_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
if (_beltEntities.Count <= 0)
{
return;
}
float num = ((BuildTool)tool).actionBuild.planetAux.activeGrid.CalcLocalGridSize(buildPreview.lpos, buildPreview.lrot * Vector3.up);
Vector3 val = buildPreview.lpos + buildPreview.lrot * (Vector3.up * num);
float num2 = 0.4f * 0.4f;
for (int num3 = _beltEntities.Count - 1; num3 >= 0; num3--)
{
EntityData val2 = _beltEntities[num3];
if (val2.beltId > 0)
{
Vector3 val3 = ((BuildTool)tool).actionBuild.planetAux.Snap(val2.pos, false);
Vector3 val4 = val3 - buildPreview.lpos;
float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude;
val4 = val3 - val;
float sqrMagnitude2 = ((Vector3)(ref val4)).sqrMagnitude;
if (sqrMagnitude < num2 || sqrMagnitude2 < num2)
{
((BuildTool)tool).actionBuild.DoDismantleObject(val2.id);
_beltEntities.RemoveAt(num3);
}
}
else
{
_beltEntities.RemoveAt(num3);
}
}
BeltComponent[] beltPool = ((BuildTool)tool).factory.cargoTraffic.beltPool;
for (int num4 = _beltEntities.Count - 1; num4 >= 0; num4--)
{
EntityData val5 = _beltEntities[num4];
BeltComponent val6 = beltPool[val5.beltId];
if (val6.id == val5.beltId && ((BuildTool)tool).factory.cargoTraffic.GetCargoPath(val6.segPathId).belts.Count == 1)
{
((BuildTool)tool).actionBuild.DoDismantleObject(val5.id);
_beltEntities.RemoveAt(num4);
}
}
}
public static bool CanBuildSplitter(BuildTool_Click tool, BuildPreview buildPreview)
{
//IL_0011: 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_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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_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_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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: 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_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_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_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: 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_00f1: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: 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_019f: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: 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_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_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: 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_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: 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_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
float num = ((BuildTool)tool).actionBuild.planetAux.activeGrid.CalcLocalGridSize(buildPreview.lpos, buildPreview.lrot * Vector3.up);
Vector3 val = buildPreview.lpos + buildPreview.lrot * (Vector3.up * num);
float num2 = num * 0.3f;
float num3 = num2 * num2;
Vector3[] array = (Vector3[])(object)new Vector3[buildPreview.desc.portPoses.Length];
float[] array2 = new float[buildPreview.desc.portPoses.Length];
Quaternion val2 = buildPreview.lrot;
if (buildPreview.isConnNode)
{
val2 = Maths.SphericalRotation(buildPreview.lpos, 0f);
}
for (int i = 0; i < buildPreview.desc.portPoses.Length; i++)
{
Pose val3 = buildPreview.desc.portPoses[i];
array2[i] = ((BuildTool)tool).actionBuild.planetAux.activeGrid.CalcLocalGridSize(buildPreview.lpos, val2 * ((Pose)(ref val3)).forward);
Vector3 val4 = buildPreview.lpos + val2 * (val3.position + ((Pose)(ref val3)).forward * num);
array[i] = ((BuildTool)tool).actionBuild.planetAux.Snap(val4, false);
}
ColliderData val6 = default(ColliderData);
for (int j = 0; j < BuildToolAccess.TmpColsLength(); j++)
{
Collider val5 = BuildToolAccess.TmpCols[j];
if (!((BuildTool)tool).planet.physics.GetColliderData(val5, ref val6))
{
continue;
}
if ((int)((ColliderData)(ref val6)).objType == 0)
{
int objId = ((ColliderData)(ref val6)).objId;
EntityData val7 = ((BuildTool)tool).planet.factory.entityPool[objId];
if (val7.beltId == 0)
{
return false;
}
Vector3 val8 = ((BuildTool)tool).actionBuild.planetAux.Snap(val7.pos, false);
Vector3 val9 = val8 - buildPreview.lpos;
float sqrMagnitude = ((Vector3)(ref val9)).sqrMagnitude;
val9 = val8 - val;
float sqrMagnitude2 = ((Vector3)(ref val9)).sqrMagnitude;
if (sqrMagnitude < num3)
{
continue;
}
if (sqrMagnitude2 < num3)
{
if (buildPreview.item.ModelCount > 0 && tool.modelOffset % buildPreview.item.ModelCount == 0)
{
return false;
}
continue;
}
bool validBelt = false;
for (int k = 0; k < buildPreview.desc.portPoses.Length; k++)
{
val9 = val8 - array[k];
float sqrMagnitude3 = ((Vector3)(ref val9)).sqrMagnitude;
float num4 = array2[k] * 0.17f;
if (!(sqrMagnitude3 < num4 * num4))
{
continue;
}
ValidateBelt(tool, buildPreview, buildPreview.desc.portPoses[k], val7, out validBelt, out var isOutput);
if (validBelt)
{
if (buildPreview.desc.isPiler && ((k == 0 && !isOutput) || (k == 1 && isOutput)))
{
isOutput.ToString();
_warningString = "(Piler is facing the wrong way)";
}
break;
}
}
if (!validBelt)
{
_warningString = null;
return false;
}
continue;
}
return false;
}
return true;
}
public static bool GatherNearBelts(BuildTool_Click tool, BuildPreview buildPreview)
{
//IL_0061: 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_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: 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_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: 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_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_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: 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)
bool result = false;
_beltEntities.Clear();
if (buildPreview?.desc != null)
{
PlayerAction_Build actionBuild = ((BuildTool)tool).actionBuild;
object obj;
if (actionBuild == null)
{
obj = null;
}
else
{
PlanetAuxData planetAux = actionBuild.planetAux;
obj = ((planetAux != null) ? planetAux.activeGrid : null);
}
if (obj != null && ((BuildTool)tool).actionBuild?.nearcdLogic != null)
{
float num = ((BuildTool)tool).actionBuild.planetAux.activeGrid.CalcLocalGridSize(buildPreview.lpos, buildPreview.lrot * ((Pose)(ref buildPreview.desc.portPoses[0])).forward);
Vector3 val = buildPreview.lpos + buildPreview.lrot * (Vector3.up * num / 2f);
BuildToolAccess.nearObjectCount = ((BuildTool)tool).actionBuild.nearcdLogic.GetBuildingsInAreaNonAlloc(val, num * 1.4f, ref BuildTool._nearObjectIds, false);
for (int i = 0; i < BuildToolAccess.nearObjectCount; i++)
{
int num2 = BuildToolAccess.nearObjectIds[i];
if (num2 > 0)
{
EntityData val2 = ((BuildTool)tool).planet.factory.entityPool[num2];
if (val2.beltId != 0)
{
result = true;
AddBeltEntity(val2);
}
}
}
return result;
}
}
return false;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "SplitterOverBelt";
public const string PLUGIN_NAME = "SplitterOverBelt";
public const string PLUGIN_VERSION = "1.0.0";
}
}