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 BepInEx;
using BepInEx.Logging;
using EquinoxsDebuggingTools;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("EMUBuilder")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("EMUBuilder")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d4097b30-0838-43cd-bc27-56047d45111e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace EquinoxsModUtils;
[BepInPlugin("com.equinox.EMUBuilder", "EMUBuilder", "1.0.0")]
public class EMUBuilderPlugin : BaseUnityPlugin
{
private const string MyGUID = "com.equinox.EMUBuilder";
private const string PluginName = "EMUBuilder";
private const string VersionString = "1.0.0";
private static readonly Harmony Harmony = new Harmony("com.equinox.EMUBuilder");
public static ManualLogSource Log = new ManualLogSource("EMUBuilder");
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: EMUBuilder, VersionString: 1.0.0 is loading...");
Harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: EMUBuilder, VersionString: 1.0.0 is loaded.");
Log = ((BaseUnityPlugin)this).Logger;
}
}
public static class EMUBuilder
{
public static MachineTypeEnum[] SupportedMachineTypes;
public static void BuildMachine(int resId, GridInfo gridInfo, bool shouldLog = false, int variationIndex = -1, int recipe = -1, ChainData? chainData = null, bool reverseConveyor = false)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
if (!LoadingStates.hasSaveStateLoaded)
{
EMUBuilderPlugin.Log.LogError((object)"BuildMachine() called before SaveState.instance has loaded");
EMUBuilderPlugin.Log.LogWarning((object)"Try using the event ModUtils.SaveStateLoaded or checking with ModUtils.hasSaveStateLoaded");
}
else
{
MachineBuilder.BuildMachine(resId, gridInfo, shouldLog, variationIndex, recipe, chainData, reverseConveyor);
}
}
public static void BuildMachine(string resourceName, GridInfo gridInfo, bool shouldLog = false, int variationIndex = -1, int recipe = -1, ChainData? chainData = null, bool reverseConveyor = false)
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
if (!LoadingStates.hasSaveStateLoaded)
{
EMUBuilderPlugin.Log.LogError((object)"BuildMachine() called before SaveState.instance has loaded");
EMUBuilderPlugin.Log.LogWarning((object)"Try using the event ModUtils.SaveStateLoaded or checking with ModUtils.hasSaveStateLoaded");
return;
}
int resourceIDByName = Resources.GetResourceIDByName(resourceName, false);
if (resourceIDByName == -1)
{
EMUBuilderPlugin.Log.LogError((object)("Could not build machine '" + resourceName + "'. Couldn't find a resource matching this name."));
EMUBuilderPlugin.Log.LogWarning((object)"Try using the ResourceNames class for a perfect match.");
}
else
{
MachineBuilder.BuildMachine(resourceIDByName, gridInfo, shouldLog, variationIndex, recipe, chainData, reverseConveyor);
}
}
static EMUBuilder()
{
MachineTypeEnum[] array = new MachineTypeEnum[19];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
SupportedMachineTypes = (MachineTypeEnum[])(object)array;
}
}
internal static class MachineBuilder
{
private static List<string> flowerNames = new List<string> { "Small Floor Pot", "Wall Pot", "Medium Floor Pot", "Ceiling Plant (1x1)", "Ceiling Plant (3x3)", "Wall Plant (1x1)", "Wall Plant (3x3)" };
internal static void BuildMachine(int resId, GridInfo gridInfo, bool shouldLog, int variationIndex, int recipe, ChainData? chainData, bool reverseConveyor)
{
//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_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Invalid comparison between Unknown and I4
//IL_0050: 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_0053: 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_0057: 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_00ec: Expected I4, but got Unknown
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: 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_013b: 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_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: 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)
MachineTypeEnum machineTypeFromResID = Resources.GetMachineTypeFromResID(resId);
if ((int)machineTypeFromResID == 0)
{
ResourceInfo resInfoFromId = SaveState.GetResInfoFromId(resId);
string arg = (((Object)(object)resInfoFromId == (Object)null) ? "Unknown Resource" : resInfoFromId.displayName);
EMUBuilderPlugin.Log.LogError((object)$"Cannot build machine for invalid resID: {resId} - '{arg}'");
return;
}
MachineTypeEnum val = machineTypeFromResID;
MachineTypeEnum val2 = val;
switch (val2 - 1)
{
case 2:
case 7:
case 9:
case 15:
case 18:
case 20:
case 23:
case 25:
case 31:
case 32:
case 33:
case 34:
DoSimpleBuild(resId, gridInfo, shouldLog);
break;
case 0:
if (recipe == -1)
{
DoSimpleBuild(resId, gridInfo, shouldLog);
}
else
{
DoSimpleBuildWithRecipe(resId, gridInfo, recipe, shouldLog);
}
break;
case 6:
DoSimpleBuildWithRecipe(resId, gridInfo, recipe, shouldLog);
break;
case 3:
DoConveyorBuild(resId, gridInfo, chainData, reverseConveyor);
break;
case 4:
DoDrillBuild(resId, gridInfo);
break;
case 11:
DoResearchCoreBuild(resId, gridInfo);
break;
case 30:
DoStructureBuild(resId, gridInfo, variationIndex);
break;
case 21:
DoMassTransitBuild(resId, gridInfo, variationIndex);
break;
default:
EMUBuilderPlugin.Log.LogError((object)$"Sorry, EMU currently doesn't support building {machineTypeFromResID}");
break;
}
}
private static void DoSimpleBuild(int resID, GridInfo gridInfo, bool shouldLog)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_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_003a: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_0047: 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_006f: Expected O, but got Unknown
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
//IL_0082: 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_008f: Expected O, but got Unknown
//IL_00b7: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
SimpleBuildInfo val = new SimpleBuildInfo
{
machineType = resID,
rotation = gridInfo.yawRot
};
ref Vector3Int minPos = ref gridInfo.minPos;
byte strata = GameState.instance.GetStrata();
val.minGridPos = new GridPos(ref minPos, ref strata);
SimpleBuildInfo val2 = val;
BuilderInfo val3 = (BuilderInfo)SaveState.GetResInfoFromId(resID);
StreamedHologramData hologram = GetHologram(val3, gridInfo);
MachineInstanceDefaultBuilder val4 = (MachineInstanceDefaultBuilder)Player.instance.builder.GetBuilderForType((BuilderType)3);
val4.newBuildInfo = (SimpleBuildInfo)((NetworkBuildInfo)val2).Clone();
val4 = (MachineInstanceDefaultBuilder)SetCommonBuilderFields((ProceduralBuilder)(object)val4, val3, gridInfo, hologram);
SetPlayerBuilderPrivateFields((ProceduralBuilder)(object)val4, val3);
DoBuild((ProceduralBuilder)(object)val4, val3, -1);
if (shouldLog)
{
EMUBuilderPlugin.Log.LogInfo((object)$"Built {((ResourceInfo)val3).displayName} at ({gridInfo.minPos}) with yawRotation {gridInfo.yawRot}");
}
}
private static void DoSimpleBuildWithRecipe(int resID, GridInfo gridInfo, int recipe, bool shouldLog)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Expected O, but got Unknown
//IL_00c8: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
SimpleBuildInfo val = new SimpleBuildInfo
{
machineType = resID,
rotation = gridInfo.yawRot
};
ref Vector3Int minPos = ref gridInfo.minPos;
byte strata = GameState.instance.GetStrata();
val.minGridPos = new GridPos(ref minPos, ref strata);
val.recipeId = recipe;
SimpleBuildInfo newBuildInfo = val;
BuilderInfo val2 = (BuilderInfo)SaveState.GetResInfoFromId(resID);
StreamedHologramData hologram = GetHologram(val2, gridInfo);
MachineInstanceDefaultBuilder val3 = (MachineInstanceDefaultBuilder)Player.instance.builder.GetBuilderForType((BuilderType)3);
val3.newBuildInfo = newBuildInfo;
val3 = (MachineInstanceDefaultBuilder)SetCommonBuilderFields((ProceduralBuilder)(object)val3, val2, gridInfo, hologram);
SetPlayerBuilderPrivateFields((ProceduralBuilder)(object)val3, val2);
DoBuild((ProceduralBuilder)(object)val3, val2, recipe);
if (shouldLog)
{
EMUBuilderPlugin.Log.LogInfo((object)$"Built {((ResourceInfo)val2).displayName} with recipe {recipe} at {gridInfo.minPos} with yawRotation {gridInfo.yawRot}");
}
}
private static void DoConveyorBuild(int resID, GridInfo gridInfo, ChainData? nullableChainData, bool reverseConveyor)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: 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_0068: 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_00a8: 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_00c8: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: 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_010a: 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_011d: 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_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Expected O, but got Unknown
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Expected O, but got Unknown
//IL_0154: 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_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Expected O, but got Unknown
//IL_0184: 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_0192: Expected O, but got Unknown
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
if (!nullableChainData.HasValue)
{
EMUBuilderPlugin.Log.LogError((object)"You cannot build a conveyor with null ChainData. Aborting build attempt.");
return;
}
EDT.Log("Conveyor Building", $"Attempting to build conveyor at {gridInfo.minPos} - S{GameState.instance.GetStrata()}");
ChainData value = nullableChainData.Value;
EDT.Log("Conveyor Building", $"chainData.count: {value.count}");
EDT.Log("Conveyor Building", $"chainData.rotation: {value.rotation}");
EDT.Log("Conveyor Building", $"chainData.shape: {value.shape}");
EDT.Log("Conveyor Building", $"chainData.start: {value.start}");
EDT.Log("Conveyor Building", $"chainData.height: {value.height}");
ConveyorBuildInfo val = new ConveyorBuildInfo
{
machineType = resID,
chainData = new List<ChainData> { value },
isReversed = reverseConveyor,
machineIds = new List<uint>(),
autoHubsEnabled = false,
strata = GameState.instance.GetStrata()
};
BuilderInfo val2 = (BuilderInfo)SaveState.GetResInfoFromId(resID);
StreamedHologramData hologram = GetHologram(val2, gridInfo, -1, value);
ConveyorBuilder val3 = (ConveyorBuilder)Player.instance.builder.GetBuilderForType((BuilderType)0);
val3.beltBuildInfo = val;
val3 = (ConveyorBuilder)SetCommonBuilderFields((ProceduralBuilder)(object)val3, val2, gridInfo, hologram);
SetPlayerBuilderPrivateFields((ProceduralBuilder)(object)val3, val2);
((ProceduralBuilder)val3).BuildFromNetworkData((NetworkBuildInfo)(object)val, false);
((InventoryWrapper)Player.instance.inventory).TryRemoveResources(resID, 1);
EDT.Log("Conveyor Building", $"Built {((ResourceInfo)val2).displayName} at {gridInfo.minPos} with yawRotation {gridInfo.yawRot}");
}
private static void DoDrillBuild(int resID, GridInfo gridInfo)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_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_003a: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_0047: 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_006f: Expected O, but got Unknown
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
SimpleBuildInfo val = new SimpleBuildInfo
{
machineType = resID,
rotation = gridInfo.yawRot
};
ref Vector3Int minPos = ref gridInfo.minPos;
byte strata = GameState.instance.GetStrata();
val.minGridPos = new GridPos(ref minPos, ref strata);
SimpleBuildInfo val2 = val;
BuilderInfo builderInfo = (BuilderInfo)SaveState.GetResInfoFromId(resID);
StreamedHologramData hologram = GetHologram(builderInfo, gridInfo);
DrillBuilder val3 = (DrillBuilder)Player.instance.builder.GetBuilderForType((BuilderType)1);
val3.newBuildInfo = val2;
val3 = (DrillBuilder)SetCommonBuilderFields((ProceduralBuilder)(object)val3, builderInfo, gridInfo, hologram);
SetPlayerBuilderPrivateFields((ProceduralBuilder)(object)val3, builderInfo);
((ProceduralBuilder)val3).BuildFromNetworkData((NetworkBuildInfo)(object)val2, false);
((InventoryWrapper)Player.instance.inventory).TryRemoveResources(resID, 1);
}
private static void DoResearchCoreBuild(int resID, GridInfo gridInfo)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//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_0067: Expected O, but got Unknown
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Expected O, but got Unknown
ResearchCoreBuildInfo val = new ResearchCoreBuildInfo
{
machineType = resID,
startCorner = gridInfo.minPos,
endCorner = gridInfo.minPos,
rotation = gridInfo.yawRot
};
BuilderInfo builderInfo = (BuilderInfo)SaveState.GetResInfoFromId(resID);
StreamedHologramData hologram = GetHologram(builderInfo, gridInfo);
ResearchCoreBuilder val2 = (ResearchCoreBuilder)Player.instance.builder.GetBuilderForType((BuilderType)5);
val2.coreBuildInfo = val;
val2 = (ResearchCoreBuilder)SetCommonBuilderFields((ProceduralBuilder)(object)val2, builderInfo, gridInfo, hologram);
SetPlayerBuilderPrivateFields((ProceduralBuilder)(object)val2, builderInfo);
((ProceduralBuilder)val2).BuildFromNetworkData((NetworkBuildInfo)(object)val, false);
((InventoryWrapper)Player.instance.inventory).TryRemoveResources(resID, 1);
}
private static void DoStructureBuild(int resID, GridInfo gridInfo, int variationIndex)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_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_003a: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_0047: 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_0070: Expected O, but got Unknown
//IL_0080: 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_008d: Expected O, but got Unknown
SimpleBuildInfo val = new SimpleBuildInfo
{
machineType = resID,
rotation = gridInfo.yawRot
};
ref Vector3Int minPos = ref gridInfo.minPos;
byte strata = GameState.instance.GetStrata();
val.minGridPos = new GridPos(ref minPos, ref strata);
SimpleBuildInfo newBuildInfo = val;
BuilderInfo builderInfo = (BuilderInfo)SaveState.GetResInfoFromId(resID);
StreamedHologramData hologram = GetHologram(builderInfo, gridInfo, variationIndex);
StructureBuilder val2 = (StructureBuilder)Player.instance.builder.GetBuilderForType((BuilderType)11);
((MachineInstanceDefaultBuilder)val2).newBuildInfo = newBuildInfo;
((ProceduralBuilder)val2).currentVariationIndex = variationIndex;
val2 = (StructureBuilder)SetCommonBuilderFields((ProceduralBuilder)(object)val2, builderInfo, gridInfo, hologram);
SetPlayerBuilderPrivateFields((ProceduralBuilder)(object)val2, builderInfo);
DoBuild((ProceduralBuilder)(object)val2, builderInfo, -1);
}
private static void DoMassTransitBuild(int resID, GridInfo gridInfo, int variationIndex)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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_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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
//IL_0070: 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_0098: Expected O, but got Unknown
//IL_00ba: 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_00c7: Expected O, but got Unknown
MassTransitBuildInfo val = new MassTransitBuildInfo
{
machineType = resID,
rotation = gridInfo.yawRot
};
ref Vector3Int minPos = ref gridInfo.minPos;
byte strata = GameState.instance.GetStrata();
((SimpleBuildInfo)val).minGridPos = new GridPos(ref minPos, ref strata);
val.overrideHeight = variationIndex + 4;
MassTransitBuildInfo val2 = val;
EDT.Log("Transit Pole Building", $"Building TransitPole with height {val2.overrideHeight}");
BuilderInfo builderInfo = (BuilderInfo)SaveState.GetResInfoFromId(resID);
StreamedHologramData hologram = GetHologram(builderInfo, gridInfo, variationIndex);
MassTransitBuilder val3 = (MassTransitBuilder)Player.instance.builder.GetBuilderForType((BuilderType)4);
EMU.SetPrivateField<MassTransitBuilder>("newBuildInfo", val3, (object)val2);
((ProceduralBuilder)val3).currentVariationIndex = variationIndex;
val3.curPoleHeight = val2.overrideHeight;
val3 = (MassTransitBuilder)SetCommonBuilderFields((ProceduralBuilder)(object)val3, builderInfo, gridInfo, hologram);
SetPlayerBuilderPrivateFields((ProceduralBuilder)(object)val3, builderInfo);
DoBuild((ProceduralBuilder)(object)val3, builderInfo, -1);
}
private static StreamedHologramData GetHologram(BuilderInfo builderInfo, GridInfo gridInfo, int variationIndex = -1, ChainData? nullableChainData = null)
{
//IL_0005: 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_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_0014: Invalid comparison between Unknown and I4
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Invalid comparison between Unknown and I4
//IL_0022: 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_002f: 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_0059: 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_0060: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: 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_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Expected I4, but got Unknown
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: 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_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: 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_026f: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: 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_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02c1: 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_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: 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)
//IL_02f9: 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_0358: Unknown result type (might be due to invalid IL or missing references)
//IL_0364: Unknown result type (might be due to invalid IL or missing references)
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
StreamedHologramData val = null;
Vector3 bottomCenter = ((GridInfo)(ref gridInfo)).BottomCenter;
MachineTypeEnum instanceType = builderInfo.GetInstanceType();
if ((int)instanceType == 4)
{
ChainData value = nullableChainData.Value;
ConveyorInstance val2 = MachineManager.instance.Get<ConveyorInstance, ConveyorDefinition>(0, instanceType);
StreamedHologramData obj = ((BuilderInfo)((ConveyorInstance)(ref val2)).myDef).GenerateUnbuiltHologramData();
ConveyorHologramData val3 = (ConveyorHologramData)(object)((obj is ConveyorHologramData) ? obj : null);
val3.buildBackwards = false;
val3.curShape = value.shape;
val3.numBelts = 1;
bottomCenter.x += (float)((Vector3Int)(ref val2.gridInfo.dims)).x / 2f;
bottomCenter.z += (float)((Vector3Int)(ref val2.gridInfo.dims)).z / 2f;
Quaternion val4 = Quaternion.Euler(0f, (float)gridInfo.yawRot, 0f);
((StreamedHologramData)val3).SetTransform(ref bottomCenter, ref val4, false);
((StreamedHologramData)val3).type = builderInfo;
return (StreamedHologramData)(object)val3;
}
if ((int)instanceType != 7)
{
bottomCenter.x += (float)((Vector3Int)(ref gridInfo.dims)).x / 2f;
bottomCenter.z += (float)((Vector3Int)(ref gridInfo.dims)).z / 2f;
}
MachineTypeEnum val5 = instanceType;
MachineTypeEnum val6 = val5;
switch (val6 - 1)
{
case 0:
val = ((BuilderInfo)(AssemblerDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 2:
val = ((BuilderInfo)(ChestDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 4:
val = ((BuilderInfo)(DrillDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 6:
val = ((BuilderInfo)(InserterDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 7:
val = ((BuilderInfo)(LightStickDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 9:
val = ((BuilderInfo)(PlanterDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 10:
val = ((BuilderInfo)(PowerGeneratorDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 11:
val = ((BuilderInfo)(ResearchCoreDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 15:
val = ((BuilderInfo)(SmelterDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 18:
val = ((BuilderInfo)(ThresherDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 20:
val = ((BuilderInfo)(TransitDepotDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 21:
val = ((BuilderInfo)(TransitPoleDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 22:
val = ((BuilderInfo)(WaterWheelDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 23:
val = ((BuilderInfo)(AccumulatorDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 24:
val = ((BuilderInfo)(HighVoltageCableDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 25:
val = ((BuilderInfo)(VoltageStepperDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 30:
val = ((BuilderInfo)(StructureDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 31:
val = ((BuilderInfo)(BlastSmelterDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 33:
val = ((BuilderInfo)(CrusherDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 34:
val = ((BuilderInfo)(SandPumpDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
case 32:
val = ((BuilderInfo)(NexusDefinition)builderInfo).GenerateUnbuiltHologramData();
break;
default:
EMUBuilderPlugin.Log.LogWarning((object)$"Skipped rendering hologram for unknown type: {instanceType}");
break;
}
if (variationIndex != -1)
{
val.variationNum = variationIndex;
}
Quaternion val7 = Quaternion.Euler(0f, (float)gridInfo.yawRot, 0f);
val.SetTransform(ref bottomCenter, ref val7, false);
val.type = builderInfo;
return val;
}
private static ProceduralBuilder SetCommonBuilderFields(ProceduralBuilder builder, BuilderInfo builderInfo, GridInfo gridInfo, StreamedHologramData hologram)
{
//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)
builder.curBuilderInfo = builderInfo;
builder.myNewGridInfo = gridInfo;
builder.myHolo = hologram;
builder.recentlyBuilt = true;
builder.OnShow();
return builder;
}
private static void SetPlayerBuilderPrivateFields(ProceduralBuilder builder, BuilderInfo builderInfo)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
EMU.SetPrivateField<PlayerBuilder>("_currentBuilder", Player.instance.builder, (object)builder);
EMU.SetPrivateField<PlayerBuilder>("_lastBuilderInfo", Player.instance.builder, (object)builderInfo);
EMU.SetPrivateField<PlayerBuilder>("_lastBuildPos", Player.instance.builder, (object)((GridInfo)(ref builder.curGridPlacement)).MinInt);
}
private static void DoBuild(ProceduralBuilder builder, BuilderInfo builderInfo, int recipeID)
{
BuildMachineAction val = builder.GenerateNetworkData();
val.recipeId = recipeID;
val.resourceCostID = ((UniqueIdScriptableObject)builderInfo).uniqueId;
val.resourceCostAmount = 1;
NetworkMessageRelay.instance.SendNetworkAction((NetworkAction)(object)val);
}
}