using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PlanetaryResourceArchitect.Core;
using PlanetaryResourceArchitect.Input;
using PlanetaryResourceArchitect.UI;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Loki Moon Labs")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0")]
[assembly: AssemblyProduct("Planetary Resource Architect")]
[assembly: AssemblyTitle("PlanetaryResourceArchitect")]
[assembly: AssemblyVersion("2.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 PlanetaryResourceArchitect
{
internal static class ModInfo
{
internal const string Guid = "com.lokimoonlabs.planetaryresourcearchitect";
internal const string Name = "Planetary Resource Architect";
internal const string Version = "2.0.0";
internal const string HarmonyId = "com.lokimoonlabs.planetaryresourcearchitect.inputguard";
}
[BepInPlugin("com.lokimoonlabs.planetaryresourcearchitect", "Planetary Resource Architect", "2.0.0")]
[BepInProcess("DSPGAME.exe")]
public sealed class Plugin : BaseUnityPlugin
{
private VeinEditor editor;
private ResourceArchitectWindow window;
private InputGuard inputGuard;
internal bool Visible
{
get
{
if (window != null)
{
return window.Visible;
}
return false;
}
}
internal bool ToolActive
{
get
{
if (Visible && editor != null)
{
return editor.Tool != EditorTool.None;
}
return false;
}
}
internal bool IsMouseOverWindow()
{
if (window != null)
{
return window.IsMouseOver();
}
return false;
}
private void Awake()
{
editor = new VeinEditor();
window = new ResourceArchitectWindow(editor);
inputGuard = new InputGuard(this);
inputGuard.Install();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Planetary Resource Architect v2.0.0 loaded.");
}
private void Update()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown((KeyCode)288))
{
window.Toggle();
}
editor.Tick(window.Visible && window.IsMouseOver());
inputGuard.Update(window.Rect, window.Visible);
}
private void OnGUI()
{
window?.OnGUI();
}
private void OnDestroy()
{
try
{
inputGuard?.Dispose();
}
catch
{
}
try
{
window?.Dispose();
}
catch
{
}
inputGuard = null;
window = null;
editor = null;
}
}
}
namespace PlanetaryResourceArchitect.UI
{
internal sealed class ResourceArchitectWindow
{
private const int WindowId = 47291;
private const float Width = 680f;
private const float Height = 600f;
private const float TitleBarHeight = 42f;
private const float SidebarWidth = 208f;
private readonly VeinEditor editor;
private Rect windowRect;
private bool stylesReady;
private Texture2D panelTexture;
private Texture2D panelAltTexture;
private Texture2D borderTexture;
private Texture2D accentTexture;
private Texture2D selectedTexture;
private GUIStyle titleStyle;
private GUIStyle centeredTitleStyle;
private GUIStyle sectionTitleStyle;
private GUIStyle navStyle;
private GUIStyle navSelectedStyle;
private GUIStyle bodyStyle;
private GUIStyle bodyWrapStyle;
private GUIStyle smallStyle;
private GUIStyle resourceNameStyle;
private GUIStyle buttonStyle;
private GUIStyle closeButtonStyle;
private readonly Dictionary<int, Texture> iconCache = new Dictionary<int, Texture>();
internal bool Visible { get; private set; }
internal Rect Rect => windowRect;
internal ResourceArchitectWindow(VeinEditor editor)
{
//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)
this.editor = editor;
windowRect = CenterRect(680f, 600f);
}
internal void Toggle()
{
//IL_0024: 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)
Visible = !Visible;
if (Visible)
{
editor.ClearSelection();
windowRect = ClampToScreen(windowRect);
}
else
{
editor.DisableTool();
}
}
internal void Close()
{
Visible = false;
editor.DisableTool();
}
internal bool IsMouseOver()
{
//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_0012: 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_0030: Unknown result type (might be due to invalid IL or missing references)
if (!Visible)
{
return false;
}
Vector3 mousePosition = Input.mousePosition;
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(mousePosition.x, (float)Screen.height - mousePosition.y);
return ((Rect)(ref windowRect)).Contains(val);
}
internal void OnGUI()
{
//IL_003f: 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_0064: Expected O, but got Unknown
//IL_005f: 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_006b: 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_0075: 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_001f: Invalid comparison between Unknown and I4
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Invalid comparison between Unknown and I4
if (Visible)
{
EnsureStyles();
Event current = Event.current;
if (current != null && (int)current.type == 4 && (int)current.keyCode == 27)
{
Close();
current.Use();
}
else
{
windowRect = GUI.Window(47291, windowRect, new WindowFunction(DrawWindow), GUIContent.none, GUI.skin.window);
windowRect = ClampToScreen(windowRect);
}
}
}
private void DrawWindow(int id)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, ((Rect)(ref windowRect)).height), (Texture)(object)panelTexture);
DrawTopBar();
DrawSidebar();
DrawMainPanel();
DrawStatusBar();
GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, 1f), (Texture)(object)borderTexture);
GUI.DrawTexture(new Rect(0f, ((Rect)(ref windowRect)).height - 1f, ((Rect)(ref windowRect)).width, 1f), (Texture)(object)borderTexture);
GUI.DrawTexture(new Rect(0f, 0f, 1f, ((Rect)(ref windowRect)).height), (Texture)(object)borderTexture);
GUI.DrawTexture(new Rect(((Rect)(ref windowRect)).width - 1f, 0f, 1f, ((Rect)(ref windowRect)).height), (Texture)(object)borderTexture);
GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref windowRect)).width - 70f, 42f));
}
private void DrawTopBar()
{
//IL_001a: 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_00d1: 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_00e9: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
GUI.DrawTexture(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, 42f), (Texture)(object)panelAltTexture);
GUI.Label(new Rect(20f, 0f, ((Rect)(ref windowRect)).width - 40f, 42f), "Planetary Resource Architect", centeredTitleStyle);
Rect val = default(Rect);
((Rect)(ref val))..ctor(((Rect)(ref windowRect)).width - 62f, 1f, 46f, 40f);
Event current = Event.current;
if (current != null && ((Rect)(ref val)).Contains(current.mousePosition))
{
GUI.color = new Color(0.91f, 0.16f, 0.18f, 1f);
GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture);
GUI.color = Color.white;
}
if (GUI.Button(val, GUIContent.none, GUIStyle.none))
{
Close();
}
GUI.Label(val, "X", closeButtonStyle);
}
private void DrawSidebar()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
GUI.DrawTexture(new Rect(0f, 42f, 208f, ((Rect)(ref windowRect)).height - 42f - 40f), (Texture)(object)panelAltTexture);
DrawSectionTitle("TOOLS", 54f);
float y = 82f;
DrawToolButton(EditorTool.Add, "Add Resource", ref y);
DrawToolButton(EditorTool.MoveSingle, "Move Single", ref y);
DrawToolButton(EditorTool.MoveGroup, "Move Group", ref y);
DrawToolButton(EditorTool.MoveResourceType, "Move Type", ref y);
DrawToolButton(EditorTool.SplitGroup, "Split Group", ref y);
DrawToolButton(EditorTool.MergeGroups, "Merge Groups", ref y);
DrawToolButton(EditorTool.Remove, "Remove Vein", ref y);
DrawResourceSettings(10f, 342f);
}
private void DrawToolButton(EditorTool tool, string label, ref float y)
{
//IL_0036: 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)
Rect val = default(Rect);
((Rect)(ref val))..ctor(7f, y, 194f, 31f);
bool flag = editor.Tool == tool;
if (flag)
{
GUI.DrawTexture(val, (Texture)(object)selectedTexture);
}
if (GUI.Button(val, label, flag ? navSelectedStyle : navStyle))
{
if (flag)
{
editor.DisableTool(closeOwnedConstructMode: false);
}
else
{
editor.ActivateTool(tool);
}
}
y += 35f;
}
private void DrawMainPanel()
{
//IL_0030: 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)
float num = 208f;
GUI.DrawTexture(new Rect(num, 42f, ((Rect)(ref windowRect)).width - num, ((Rect)(ref windowRect)).height - 42f - 40f), (Texture)(object)panelTexture);
GUI.Label(new Rect(num + 12f, 52f, ((Rect)(ref windowRect)).width - num - 24f, 30f), "Planetary Resources", sectionTitleStyle);
DrawResourceGrid(num + 12f, 88f);
}
private void DrawResourceGrid(float x, float y)
{
//IL_0042: 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_0051: 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_0117: 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_00d5: 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)
Rect val = default(Rect);
for (int i = 0; i < ResourceCatalog.All.Length; i++)
{
int num = i / 2;
int num2 = i % 2;
ResourceDefinition resourceDefinition = ResourceCatalog.All[i];
((Rect)(ref val))..ctor(x + (float)num2 * 228f, y + (float)num * 67f, 220f, 64f);
bool flag = editor.SelectedType == resourceDefinition.Type;
GUI.DrawTexture(val, (Texture)(object)(flag ? selectedTexture : panelAltTexture));
if (flag)
{
GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).yMax - 3f, ((Rect)(ref val)).width, 3f), (Texture)(object)accentTexture);
}
Texture resourceIcon = GetResourceIcon(resourceDefinition);
if ((Object)(object)resourceIcon != (Object)null)
{
GUI.DrawTexture(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 15f, 34f, 34f), resourceIcon, (ScaleMode)2, true);
}
GUI.Label(new Rect(((Rect)(ref val)).x + 52f, ((Rect)(ref val)).y + 5f, ((Rect)(ref val)).width - 60f, ((Rect)(ref val)).height - 10f), resourceDefinition.Name, resourceNameStyle);
if (GUI.Button(val, GUIContent.none, GUIStyle.none))
{
editor.ToggleResource(resourceDefinition.Type);
}
}
}
private void DrawResourceSettings(float x, float y)
{
//IL_0006: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Invalid comparison between Unknown and I4
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
ResourceDefinition resourceDefinition = ResourceCatalog.Get(editor.SelectedType);
GUI.Label(new Rect(x, y, 188f, 24f), "RESOURCE SETTINGS", sectionTitleStyle);
string text = ((resourceDefinition != null) ? resourceDefinition.Name : "None");
GUI.Label(new Rect(x, y + 24f, 188f, 40f), "Selected: " + text, smallStyle);
if ((int)editor.SelectedType == 7)
{
GUI.Label(new Rect(x, y + 66f, 188f, 22f), "Oil rate (/s)", smallStyle);
float num = GUI.HorizontalSlider(new Rect(x, y + 90f, 142f, 20f), editor.OilRatePerSecond, 0.1f, 50f);
editor.OilRatePerSecond = Mathf.Round(num * 10f) / 10f;
GUI.Label(new Rect(x + 148f, y + 82f, 40f, 28f), editor.OilRatePerSecond.ToString("0.0"), smallStyle);
}
else
{
GUI.Label(new Rect(x, y + 66f, 188f, 22f), "Vein amount", smallStyle);
DrawAmountPreset(x, y + 88f, 500, "500");
DrawAmountPreset(x + 62f, y + 88f, 1000000, "1M");
DrawAmountPreset(x + 124f, y + 88f, 1000000000, "Infinite");
}
GUI.Label(new Rect(x, y + 126f, 188f, 22f), "Split count", smallStyle);
int num2 = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(x, y + 151f, 142f, 20f), (float)editor.SplitCount, 1f, 72f));
editor.SplitCount = Mathf.Clamp(num2, 1, 72);
GUI.Label(new Rect(x + 148f, y + 143f, 40f, 28f), editor.SplitCount.ToString(), smallStyle);
}
private void DrawAmountPreset(float x, float y, int amount, string label)
{
//IL_0031: 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)
bool flag = editor.VeinAmount == amount;
Rect val = default(Rect);
((Rect)(ref val))..ctor(x, y, 60f, 30f);
if (flag)
{
GUI.DrawTexture(val, (Texture)(object)selectedTexture);
}
if (GUI.Button(val, label, flag ? navSelectedStyle : buttonStyle))
{
editor.VeinAmount = amount;
}
}
private void DrawStatusBar()
{
//IL_0028: 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)
float num = ((Rect)(ref windowRect)).height - 40f;
GUI.DrawTexture(new Rect(0f, num, ((Rect)(ref windowRect)).width, 40f), (Texture)(object)panelAltTexture);
GUI.Label(new Rect(12f, num + 6f, ((Rect)(ref windowRect)).width - 24f, 28f), "Status: " + editor.Status, smallStyle);
}
private Texture GetResourceIcon(ResourceDefinition resource)
{
if (resource == null)
{
return null;
}
if (iconCache.TryGetValue(resource.ItemId, out var value))
{
return value;
}
if ((Object)(object)LDB.items == (Object)null)
{
return null;
}
ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(resource.ItemId);
if (val == null || (Object)(object)val.iconSprite == (Object)null)
{
return null;
}
value = (Texture)(object)val.iconSprite.texture;
if ((Object)(object)value != (Object)null)
{
iconCache[resource.ItemId] = value;
}
return value;
}
private void DrawSectionTitle(string text, float y)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
GUI.Label(new Rect(16f, y, 176f, 24f), text, sectionTitleStyle);
}
private void EnsureStyles()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: 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_008a: 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_00c1: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
//IL_00fb: 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_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Expected O, but got Unknown
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Expected O, but got Unknown
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Expected O, but got Unknown
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Expected O, but got Unknown
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Expected O, but got Unknown
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Expected O, but got Unknown
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
if (!stylesReady)
{
panelTexture = MakeTexture(new Color(0.075f, 0.085f, 0.105f, 1f));
panelAltTexture = MakeTexture(new Color(0.105f, 0.115f, 0.14f, 1f));
borderTexture = MakeTexture(new Color(0.3f, 0.34f, 0.42f, 1f));
accentTexture = MakeTexture(new Color(0.2f, 0.48f, 0.9f, 1f));
selectedTexture = MakeTexture(new Color(0.14f, 0.22f, 0.34f, 1f));
titleStyle = MakeTextStyle(15, (FontStyle)1, Color.white);
centeredTitleStyle = new GUIStyle(titleStyle)
{
alignment = (TextAnchor)4
};
sectionTitleStyle = MakeTextStyle(15, (FontStyle)1, new Color(0.82f, 0.86f, 0.94f));
bodyStyle = MakeTextStyle(15, (FontStyle)1, new Color(0.94f, 0.95f, 0.98f));
bodyWrapStyle = new GUIStyle(bodyStyle)
{
wordWrap = true
};
smallStyle = MakeTextStyle(15, (FontStyle)1, new Color(0.78f, 0.82f, 0.9f));
smallStyle.wordWrap = true;
resourceNameStyle = new GUIStyle(smallStyle)
{
alignment = (TextAnchor)3,
clipping = (TextClipping)1,
fontSize = 15,
fontStyle = (FontStyle)1,
wordWrap = true
};
GUIStyle val = new GUIStyle(GUI.skin.button)
{
alignment = (TextAnchor)3,
fontSize = 15,
fontStyle = (FontStyle)1,
padding = new RectOffset(14, 8, 0, 0)
};
val.normal.textColor = new Color(0.92f, 0.94f, 0.98f);
navStyle = val;
navSelectedStyle = new GUIStyle(navStyle);
navSelectedStyle.normal.textColor = Color.white;
navSelectedStyle.fontStyle = (FontStyle)1;
GUIStyle val2 = new GUIStyle(GUI.skin.button)
{
alignment = (TextAnchor)4,
fontSize = 15,
fontStyle = (FontStyle)1
};
val2.normal.textColor = new Color(0.94f, 0.95f, 0.98f);
buttonStyle = val2;
closeButtonStyle = MakeTextStyle(15, (FontStyle)1, Color.white);
closeButtonStyle.alignment = (TextAnchor)4;
stylesReady = true;
}
}
private static GUIStyle MakeTextStyle(int size, FontStyle style, Color color)
{
//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_0016: 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_0023: 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_0031: Expected O, but got Unknown
GUIStyle val = new GUIStyle(GUI.skin.label)
{
fontSize = size,
fontStyle = style
};
val.normal.textColor = color;
val.clipping = (TextClipping)1;
return val;
}
private static Texture2D MakeTexture(Color color)
{
//IL_0004: 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_000c: 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_0019: Expected O, but got Unknown
Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
val.SetPixel(0, 0, color);
val.Apply();
return val;
}
private static Rect CenterRect(float width, float height)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
return new Rect(Mathf.Max(0f, ((float)Screen.width - width) * 0.5f), Mathf.Max(0f, ((float)Screen.height - height) * 0.5f), width, height);
}
private static Rect ClampToScreen(Rect rect)
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
((Rect)(ref rect)).width = 680f;
((Rect)(ref rect)).height = 600f;
float num = Mathf.Max(0f, (float)Screen.width - ((Rect)(ref rect)).width);
float num2 = Mathf.Max(0f, (float)Screen.height - ((Rect)(ref rect)).height);
((Rect)(ref rect)).x = Mathf.Clamp(((Rect)(ref rect)).x, 0f, num);
((Rect)(ref rect)).y = Mathf.Clamp(((Rect)(ref rect)).y, 0f, num2);
return rect;
}
internal void Dispose()
{
DestroyTexture(ref panelTexture);
DestroyTexture(ref panelAltTexture);
DestroyTexture(ref borderTexture);
DestroyTexture(ref accentTexture);
DestroyTexture(ref selectedTexture);
stylesReady = false;
}
private static void DestroyTexture(ref Texture2D texture)
{
if ((Object)(object)texture != (Object)null)
{
Object.Destroy((Object)(object)texture);
}
texture = null;
}
}
}
namespace PlanetaryResourceArchitect.Input
{
internal sealed class InputGuard
{
private static InputGuard instance;
private readonly Plugin plugin;
private Harmony harmony;
private GameObject canvasObject;
private Canvas canvas;
private GraphicRaycaster raycaster;
private RectTransform blockerRect;
private Image blockerImage;
internal InputGuard(Plugin plugin)
{
this.plugin = plugin;
instance = this;
}
internal void Install()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
harmony = new Harmony("com.lokimoonlabs.planetaryresourcearchitect.inputguard");
MethodInfo methodInfo = AccessTools.Method(typeof(VFInput), "UpdateGameStates", (Type[])null, (Type[])null);
if (methodInfo != null)
{
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(InputGuard), "VFInputPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
EnsureBlocker();
}
internal void Dispose()
{
try
{
Harmony obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
}
catch
{
}
harmony = null;
if ((Object)(object)canvasObject != (Object)null)
{
try
{
Object.Destroy((Object)(object)canvasObject);
}
catch
{
}
}
canvasObject = null;
canvas = null;
raycaster = null;
blockerRect = null;
blockerImage = null;
if (instance == this)
{
instance = null;
}
}
internal void Update(Rect windowRect, bool visible)
{
//IL_0062: 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_00ae: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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_00e1: 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)
if ((Object)(object)canvasObject == (Object)null)
{
EnsureBlocker();
}
if ((Object)(object)canvasObject == (Object)null || (Object)(object)blockerRect == (Object)null || (Object)(object)canvas == (Object)null)
{
return;
}
if (!visible)
{
if (canvasObject.activeSelf)
{
canvasObject.SetActive(false);
}
return;
}
Camera val = (((int)canvas.renderMode == 0) ? null : canvas.worldCamera);
Vector2 val2 = new Vector2(((Rect)(ref windowRect)).x, (float)Screen.height - ((Rect)(ref windowRect)).y);
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor(((Rect)(ref windowRect)).xMax, (float)Screen.height - ((Rect)(ref windowRect)).yMax);
Vector2 val4 = (val2 + val3) * 0.5f;
Transform transform = ((Component)canvas).transform;
Vector2 anchoredPosition = default(Vector2);
if (RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)(object)((transform is RectTransform) ? transform : null), val4, val, ref anchoredPosition))
{
blockerRect.anchoredPosition = anchoredPosition;
blockerRect.sizeDelta = new Vector2(((Rect)(ref windowRect)).width, ((Rect)(ref windowRect)).height);
if (!canvasObject.activeSelf)
{
canvasObject.SetActive(true);
}
}
}
private static void VFInputPostfix()
{
InputGuard inputGuard = instance;
if (inputGuard != null && inputGuard.plugin.Visible && inputGuard.plugin.IsMouseOverWindow())
{
VFInput.onGUI = true;
VFInput.onGUIOperate = true;
VFInput.inScrollView = true;
}
}
private void EnsureBlocker()
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Expected O, but got Unknown
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)canvasObject != (Object)null))
{
canvasObject = new GameObject("Planetary Resource Architect - Input Blocker", new Type[3]
{
typeof(RectTransform),
typeof(Canvas),
typeof(GraphicRaycaster)
});
Object.DontDestroyOnLoad((Object)(object)canvasObject);
canvas = canvasObject.GetComponent<Canvas>();
canvas.renderMode = (RenderMode)0;
canvas.overrideSorting = true;
canvas.sortingOrder = 32767;
raycaster = canvasObject.GetComponent<GraphicRaycaster>();
GameObject val = new GameObject("ResourceArchitectWindowRaycastTarget", new Type[2]
{
typeof(RectTransform),
typeof(Image)
});
val.transform.SetParent(canvasObject.transform, false);
blockerRect = val.GetComponent<RectTransform>();
blockerImage = val.GetComponent<Image>();
((Graphic)blockerImage).color = new Color(1f, 1f, 1f, 0f);
((Graphic)blockerImage).raycastTarget = true;
RectTransform obj = blockerRect;
RectTransform obj2 = blockerRect;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(0.5f, 0.5f);
obj2.anchorMax = val2;
obj.anchorMin = val2;
blockerRect.pivot = new Vector2(0.5f, 0.5f);
((Transform)blockerRect).localScale = Vector3.one;
blockerRect.anchoredPosition = Vector2.zero;
blockerRect.sizeDelta = Vector2.zero;
canvasObject.SetActive(false);
}
}
}
}
namespace PlanetaryResourceArchitect.Core
{
internal sealed class ResourceDefinition
{
internal readonly EVeinType Type;
internal readonly string Name;
internal readonly int ItemId;
internal ResourceDefinition(EVeinType type, string name, int itemId)
{
//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)
Type = type;
Name = name;
ItemId = itemId;
}
}
internal static class ResourceCatalog
{
internal static readonly ResourceDefinition[] All = new ResourceDefinition[14]
{
new ResourceDefinition((EVeinType)1, "Iron", 1001),
new ResourceDefinition((EVeinType)2, "Copper", 1002),
new ResourceDefinition((EVeinType)3, "Silicon", 1003),
new ResourceDefinition((EVeinType)4, "Titanium", 1004),
new ResourceDefinition((EVeinType)5, "Stone", 1005),
new ResourceDefinition((EVeinType)6, "Coal", 1006),
new ResourceDefinition((EVeinType)7, "Crude Oil", 1007),
new ResourceDefinition((EVeinType)8, "Fire Ice", 1011),
new ResourceDefinition((EVeinType)9, "Kimberlite", 1012),
new ResourceDefinition((EVeinType)10, "Fractal Silicon", 1013),
new ResourceDefinition((EVeinType)11, "Organic Crystal", 1117),
new ResourceDefinition((EVeinType)12, "Optical Grating Crystal", 1014),
new ResourceDefinition((EVeinType)13, "Spiniform Stalagmite Crystal", 1015),
new ResourceDefinition((EVeinType)14, "Unipolar Magnet", 1016)
};
internal static ResourceDefinition Get(EVeinType type)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < All.Length; i++)
{
if (All[i].Type == type)
{
return All[i];
}
}
return null;
}
}
internal enum EditorTool
{
None,
Add,
MoveSingle,
MoveGroup,
MoveResourceType,
SplitGroup,
MergeGroups,
Remove
}
internal sealed class VeinEditor
{
private int pendingVeinId;
private int pendingGroupIndex = -1;
private bool ownsConstructMode;
private bool constructModeRequested;
internal EditorTool Tool { get; private set; }
internal EVeinType SelectedType { get; set; } = (EVeinType)1;
internal int VeinAmount { get; set; } = 1000000;
internal float OilRatePerSecond { get; set; } = 1f;
internal int SplitCount { get; set; } = 9;
internal string Status { get; private set; } = "Choose a tool to begin.";
internal bool HasPendingSelection => pendingVeinId > 0;
internal void ToggleResource(EVeinType type)
{
//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_001d: 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)
if (SelectedType == type)
{
SelectedType = (EVeinType)0;
Status = "Resource selection cleared.";
}
else
{
SelectedType = type;
ResourceDefinition resourceDefinition = ResourceCatalog.Get(type);
Status = ((resourceDefinition != null) ? (resourceDefinition.Name + " selected.") : "Resource selected.");
}
}
internal void ActivateTool(EditorTool tool)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
if (tool == EditorTool.Add && (int)SelectedType == 0)
{
Tool = EditorTool.None;
ClearSelection();
Status = "Select a planetary resource before using Add Resource.";
}
else
{
Tool = tool;
ClearSelection();
EnsureConstructMode();
Status = ((tool == EditorTool.Add) ? "Construct Mode active. Left-click to place the selected resource; right-click cancels the resource tool." : "Resource tool active in Construct Mode. Right-click cancels the resource tool.");
}
}
internal void DisableTool(bool closeOwnedConstructMode = true)
{
Tool = EditorTool.None;
ClearSelection();
if (closeOwnedConstructMode)
{
CloseOwnedConstructMode();
}
Status = "Tool disabled.";
}
internal void OnWindowClosed()
{
DisableTool();
}
private void EnsureConstructMode()
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
Player mainPlayer = GameMain.mainPlayer;
PlayerController val = ((mainPlayer != null) ? mainPlayer.controller : null);
PlayerAction_Build val2 = val?.actionBuild;
if (!((Object)(object)val == (Object)null) && val2 != null && !val2.active && VFInput.readyToBuild)
{
if (mainPlayer.inhandItemId > 0)
{
mainPlayer.SetHandItems(0, 0, 0);
}
val.cmd.type = (ECommand)5;
val.cmd.mode = 0;
val.cmd.refId = 0;
val.cmd.stage = 0;
val.cmd.state = 0;
val.actionPick.pickMode = false;
val.actionPick.picking = false;
ownsConstructMode = true;
constructModeRequested = true;
}
}
private void CloseOwnedConstructMode()
{
if (ownsConstructMode)
{
Player mainPlayer = GameMain.mainPlayer;
PlayerAction_Build val = ((mainPlayer == null) ? null : mainPlayer.controller?.actionBuild);
if (val != null && val.active)
{
val.Close();
}
ownsConstructMode = false;
constructModeRequested = false;
}
}
internal void ClearSelection()
{
pendingVeinId = 0;
pendingGroupIndex = -1;
}
internal void Tick(bool uiOwnsMouse)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Invalid comparison between Unknown and I4
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Invalid comparison between Unknown and I4
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: 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_018f: Unknown result type (might be due to invalid IL or missing references)
if (GameMain.mainPlayer == null || GameMain.localPlanet == null || GameMain.localPlanet.factory == null || (int)GameMain.localPlanet.type == 5)
{
return;
}
PlayerAction_Build val = GameMain.mainPlayer.controller?.actionBuild;
if (val != null && val.activeTool is BuildTool_Dismantle)
{
if (Tool != EditorTool.None)
{
Tool = EditorTool.None;
ClearSelection();
}
Status = "DSP Dismantle active. Left-click a resource vein to remove it.";
if (!uiOwnsMouse && Input.GetMouseButtonDown(0) && TryRaycastSurface(out var point))
{
RemoveAt(point, 2f);
}
}
else
{
if (Tool == EditorTool.None)
{
return;
}
if (val != null && val.active)
{
constructModeRequested = false;
}
if (val == null || !val.active)
{
PlayerController controller = GameMain.mainPlayer.controller;
if (constructModeRequested && (Object)(object)controller != (Object)null && (int)controller.cmd.type == 5)
{
Status = "Opening DSP Construct Mode...";
return;
}
Tool = EditorTool.None;
ClearSelection();
ownsConstructMode = false;
constructModeRequested = false;
Status = "Construct Mode closed; resource tool disabled.";
}
else if (Input.GetMouseButtonDown(1))
{
Tool = EditorTool.None;
ClearSelection();
Status = "Resource tool canceled. Construct Mode remains active.";
}
else
{
if (uiOwnsMouse || !Input.GetMouseButtonDown(0))
{
return;
}
if (!TryRaycastSurface(out var point2))
{
Status = "No valid planet surface under the cursor.";
return;
}
switch (Tool)
{
case EditorTool.Add:
AddAt(point2);
break;
case EditorTool.Remove:
RemoveAt(point2);
break;
case EditorTool.MoveSingle:
HandleMoveSingle(point2);
break;
case EditorTool.MoveGroup:
HandleMoveGroup(point2);
break;
case EditorTool.MoveResourceType:
HandleMoveResourceType(point2);
break;
case EditorTool.SplitGroup:
HandleSplitGroup(point2);
break;
case EditorTool.MergeGroups:
HandleMergeGroups(point2);
break;
}
}
}
}
private static bool TryRaycastSurface(out Vector3 point)
{
//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_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_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)
point = Vector3.zero;
Player mainPlayer = GameMain.mainPlayer;
Camera val = ((mainPlayer == null) ? null : mainPlayer.controller?.mainCamera);
if ((Object)(object)val == (Object)null)
{
return false;
}
RaycastHit val2 = default(RaycastHit);
if (!Physics.Raycast(val.ScreenPointToRay(Input.mousePosition), ref val2, 800f, 8720, (QueryTriggerInteraction)2))
{
return false;
}
point = ((RaycastHit)(ref val2)).point;
return true;
}
private static int FindNearestVein(PlanetFactory factory, Vector3 point, float radius)
{
//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_0024: 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_0035: 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_003b: 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_0041: Unknown result type (might be due to invalid IL or missing references)
if (factory == null || factory.veinPool == null)
{
return 0;
}
float num = radius * radius;
int result = 0;
for (int i = 1; i < factory.veinCursor; i++)
{
VeinData val = factory.veinPool[i];
if (val.id == i && (int)val.type != 0)
{
Vector3 val2 = val.pos - point;
float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
if (!(sqrMagnitude >= num))
{
num = sqrMagnitude;
result = i;
}
}
}
return result;
}
private int GetConfiguredAmount(EVeinType type)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Invalid comparison between Unknown and I4
if ((int)type != 7)
{
return Mathf.Clamp(VeinAmount, 1, 1000000000);
}
float num = VeinData.oilSpeedMultiplier;
if (num <= 0f)
{
num = 4E-05f;
}
return Mathf.Max(1, Mathf.RoundToInt(Mathf.Max(0.01f, OilRatePerSecond) / num));
}
private void AddAt(Vector3 point)
{
//IL_0001: 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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Expected I4, but got Unknown
//IL_004e: 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_0065: 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_0072: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: 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_013e: 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_0146: 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_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: 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_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
if ((int)SelectedType == 0)
{
Status = "Select a planetary resource before placing one.";
return;
}
PlanetData localPlanet = GameMain.localPlanet;
PlanetFactory factory = localPlanet.factory;
int configuredAmount = GetConfiguredAmount(SelectedType);
int num = FindNearestVein(factory, point, 1f);
if (num > 0 && factory.veinPool[num].type == SelectedType)
{
VeinData val = factory.veinPool[num];
long num2 = Math.Min(1000000000L, (long)val.amount + (long)configuredAmount);
int num3 = (int)(num2 - val.amount);
if (num3 > 0)
{
factory.veinPool[num].amount = (int)num2;
factory.veinGroups[val.groupIndex].amount += num3;
factory.RefreshVeinMiningDisplay(num, 0, 0);
}
Status = "Resource amount increased.";
return;
}
VeinProto val2 = ((ProtoSet<VeinProto>)(object)LDB.veins).Select((int)SelectedType);
if (val2 == null || val2.prefabDesc == null || val2.prefabDesc.colliders == null || val2.prefabDesc.colliders.Length == 0)
{
Status = "The selected resource is not available in the current game database.";
return;
}
VeinData vein = new VeinData
{
amount = configuredAmount,
type = SelectedType,
pos = point,
productId = val2.MiningItem,
modelIndex = (short)val2.ModelIndex,
minerCount = 0
};
vein.id = factory.AddVeinData(vein);
vein.hashAddress = factory.veinPool[vein.id].hashAddress;
vein.colliderId = localPlanet.physics.AddColliderData(((ColliderData)(ref val2.prefabDesc.colliders[0])).BindToObject(vein.id, 0, (EObjectType)2, vein.pos, Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref vein.pos)).normalized)));
vein.modelId = localPlanet.factoryModel.gpuiManager.AddModel((int)vein.modelIndex, vein.id, vein.pos, Maths.SphericalRotation(vein.pos, Random.value * 360f), true);
AssignGroupForNewVein(factory, ref vein);
factory.RefreshVeinMiningDisplay(vein.id, 0, 0);
Status = "Added " + (ResourceCatalog.Get(SelectedType)?.Name ?? ((object)SelectedType/*cast due to .constrained prefix*/).ToString()) + ".";
}
private static void AssignGroupForNewVein(PlanetFactory factory, ref VeinData vein)
{
//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_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: 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_00a9: 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_0036: 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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: 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_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: 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)
HashSet<short> hashSet = new HashSet<short>();
short num = 0;
float num2 = 100f;
for (int i = 1; i < factory.veinCursor; i++)
{
if (i == vein.id)
{
continue;
}
VeinData val = factory.veinPool[i];
if (val.id != i || val.type != vein.type || val.groupIndex <= 0)
{
continue;
}
Vector3 val2 = val.pos - vein.pos;
float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
if (!(sqrMagnitude >= 100f))
{
hashSet.Add(val.groupIndex);
if (sqrMagnitude < num2)
{
num2 = sqrMagnitude;
num = val.groupIndex;
}
}
}
if (num <= 0)
{
num = (short)factory.AddVeinGroup(vein.type, ((Vector3)(ref vein.pos)).normalized);
}
vein.groupIndex = num;
factory.veinPool[vein.id] = vein;
if (hashSet.Count > 1)
{
for (int j = 1; j < factory.veinCursor; j++)
{
VeinData val3 = factory.veinPool[j];
if (val3.id == j && val3.type == vein.type && val3.groupIndex != num && hashSet.Contains(val3.groupIndex))
{
factory.veinPool[j].groupIndex = num;
}
}
foreach (short item in hashSet)
{
if (item != num)
{
factory.RecalculateVeinGroup((int)item);
if (item > 0 && item < factory.veinGroups.Length && factory.veinGroups[item].count <= 0)
{
((VeinGroup)(ref factory.veinGroups[item])).SetNull();
}
}
}
}
factory.RecalculateVeinGroup((int)num);
if (hashSet.Count > 1)
{
factory.ArrangeVeinGroups();
vein = factory.veinPool[vein.id];
}
}
private void RemoveAt(Vector3 point, float radius = 4f)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
PlanetFactory factory = GameMain.localPlanet.factory;
int num = FindNearestVein(factory, point, radius);
if (num == 0)
{
Status = "No vein close enough to remove.";
return;
}
if (factory.veinPool[num].minerCount > 0)
{
Status = "This vein is connected to a miner. Detach or dismantle the miner first.";
return;
}
short groupIndex = factory.veinPool[num].groupIndex;
factory.RemoveVeinWithComponents(num);
factory.RecalculateVeinGroup((int)groupIndex);
if (groupIndex > 0 && groupIndex < factory.veinGroups.Length && factory.veinGroups[groupIndex].count == 0)
{
((VeinGroup)(ref factory.veinGroups[groupIndex])).SetNull();
factory.ArrangeVeinGroups();
}
ClearSelection();
Status = "Vein removed.";
}
private bool EnsurePendingVein(Vector3 point, string selectedMessage)
{
//IL_006a: 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)
PlanetFactory factory = GameMain.localPlanet.factory;
if (pendingVeinId > 0 && pendingVeinId < factory.veinCursor && factory.veinPool[pendingVeinId].id == pendingVeinId)
{
if (FindNearestVein(factory, point, 4f) == pendingVeinId)
{
ClearSelection();
Status = "Selection cleared.";
return false;
}
return true;
}
int num = FindNearestVein(factory, point, 4f);
if (num == 0)
{
Status = "No vein close enough to select.";
return false;
}
pendingVeinId = num;
pendingGroupIndex = factory.veinPool[num].groupIndex;
Status = selectedMessage;
return false;
}
private void HandleMoveSingle(Vector3 point)
{
//IL_0001: 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)
if (EnsurePendingVein(point, "Vein selected. Click the destination."))
{
int id = pendingVeinId;
ClearSelection();
MoveSingle(id, point);
}
}
private void HandleMoveGroup(Vector3 point)
{
//IL_0001: 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)
if (EnsurePendingVein(point, "Vein group selected. Click the destination."))
{
int anchorId = pendingVeinId;
ClearSelection();
MoveGroup(anchorId, point);
}
}
private void HandleMoveResourceType(Vector3 point)
{
//IL_0001: 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)
if (EnsurePendingVein(point, "Resource type selected. Click the destination."))
{
int anchorId = pendingVeinId;
ClearSelection();
MoveResourceType(anchorId, point);
}
}
private void HandleSplitGroup(Vector3 point)
{
//IL_0001: 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)
if (EnsurePendingVein(point, "Vein group selected. Click where the split group should move."))
{
int anchorId = pendingVeinId;
ClearSelection();
SplitGroup(anchorId, point);
}
}
private void HandleMergeGroups(Vector3 point)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
PlanetFactory factory = GameMain.localPlanet.factory;
if (pendingVeinId <= 0)
{
int num = FindNearestVein(factory, point, 4f);
if (num == 0)
{
Status = "No source vein group close enough to select.";
return;
}
pendingVeinId = num;
pendingGroupIndex = factory.veinPool[num].groupIndex;
Status = "Source group selected. Click a target vein of the same resource type.";
return;
}
int num2 = FindNearestVein(factory, point, 4f);
if (num2 == 0)
{
Status = "No target vein close enough.";
return;
}
if (num2 == pendingVeinId || factory.veinPool[num2].groupIndex == pendingGroupIndex)
{
ClearSelection();
Status = "Selection cleared.";
return;
}
int sourceId = pendingVeinId;
if (MergeGroups(sourceId, num2))
{
ClearSelection();
}
}
private void MoveSingle(int id, Vector3 destination)
{
//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_005b: 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_0064: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
PlanetFactory factory = GameMain.localPlanet.factory;
if (!IsValidVein(factory, id))
{
return;
}
if (factory.veinPool[id].minerCount > 0)
{
Status = "This vein is connected to a miner. Detach or dismantle the miner first.";
return;
}
short groupIndex = factory.veinPool[id].groupIndex;
EVeinType type = factory.veinPool[id].type;
UpdateVeinPosition(factory, id, destination);
int num = FindNearestSameTypeVein(factory, id, type, destination, 10f);
short num2 = groupIndex;
if (num > 0)
{
num2 = factory.veinPool[num].groupIndex;
}
else if (groupIndex > 0 && groupIndex < factory.veinGroups.Length && factory.veinGroups[groupIndex].count > 1)
{
num2 = (short)factory.AddVeinGroup(type, ((Vector3)(ref destination)).normalized);
}
factory.veinPool[id].groupIndex = num2;
factory.RecalculateVeinGroup((int)groupIndex);
if (num2 != groupIndex)
{
factory.RecalculateVeinGroup((int)num2);
}
CleanupGroup(factory, groupIndex);
Status = "Vein moved.";
}
private static int FindNearestSameTypeVein(PlanetFactory factory, int excludeId, EVeinType type, Vector3 point, float radius)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_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_002c: 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_0030: 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_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
float num = radius * radius;
int result = 0;
for (int i = 1; i < factory.veinCursor; i++)
{
VeinData val = factory.veinPool[i];
if (i != excludeId && val.id == i && val.type == type)
{
Vector3 val2 = val.pos - point;
float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
if (!(sqrMagnitude >= num))
{
num = sqrMagnitude;
result = i;
}
}
}
return result;
}
private void MoveGroup(int anchorId, Vector3 destination)
{
//IL_0052: 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)
PlanetFactory factory = GameMain.localPlanet.factory;
if (IsValidVein(factory, anchorId))
{
short groupIndex = factory.veinPool[anchorId].groupIndex;
List<int> list = CollectGroupIds(factory, groupIndex);
if (list.Count != 0 && CanMoveVeins(factory, list))
{
RotateVeins(factory, list, factory.veinPool[anchorId].pos, destination);
factory.RecalculateVeinGroup((int)groupIndex);
Status = "Moved " + list.Count + " veins in the selected group.";
}
}
}
private unsafe void MoveResourceType(int anchorId, Vector3 destination)
{
//IL_0021: 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_0028: 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_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
PlanetFactory factory = GameMain.localPlanet.factory;
if (!IsValidVein(factory, anchorId))
{
return;
}
EVeinType type = factory.veinPool[anchorId].type;
List<int> list = CollectTypeIds(factory, type);
if (list.Count == 0 || !CanMoveVeins(factory, list))
{
return;
}
HashSet<int> hashSet = new HashSet<int>();
for (int i = 0; i < list.Count; i++)
{
hashSet.Add(factory.veinPool[list[i]].groupIndex);
}
RotateVeins(factory, list, factory.veinPool[anchorId].pos, destination);
foreach (int item in hashSet)
{
factory.RecalculateVeinGroup(item);
}
Status = "Moved all " + (ResourceCatalog.Get(type)?.Name ?? ((object)(*(EVeinType*)(&type))/*cast due to .constrained prefix*/).ToString()) + " veins on this planet.";
}
private static List<int> CollectGroupIds(PlanetFactory factory, short group)
{
List<int> list = new List<int>();
for (int i = 1; i < factory.veinCursor; i++)
{
if (factory.veinPool[i].id == i && factory.veinPool[i].groupIndex == group)
{
list.Add(i);
}
}
return list;
}
private static List<int> CollectTypeIds(PlanetFactory factory, EVeinType type)
{
//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)
List<int> list = new List<int>();
for (int i = 1; i < factory.veinCursor; i++)
{
if (factory.veinPool[i].id == i && factory.veinPool[i].type == type)
{
list.Add(i);
}
}
return list;
}
private bool CanMoveVeins(PlanetFactory factory, List<int> ids)
{
for (int i = 0; i < ids.Count; i++)
{
int num = ids[i];
if (IsValidVein(factory, num) && factory.veinPool[num].minerCount > 0)
{
Status = "One or more selected veins are connected to miners. Detach or dismantle those miners first.";
return false;
}
}
return true;
}
private void RotateVeins(PlanetFactory factory, List<int> ids, Vector3 anchor, Vector3 destination)
{
//IL_001f: 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_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: 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_0083: 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_008b: 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_0097: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
if (((Vector3)(ref anchor)).sqrMagnitude < 1f || ((Vector3)(ref destination)).sqrMagnitude < 1f)
{
return;
}
Quaternion val = Quaternion.FromToRotation(((Vector3)(ref anchor)).normalized, ((Vector3)(ref destination)).normalized);
float magnitude = ((Vector3)(ref anchor)).magnitude;
float magnitude2 = ((Vector3)(ref destination)).magnitude;
for (int i = 0; i < ids.Count; i++)
{
int num = ids[i];
if (IsValidVein(factory, num))
{
Vector3 pos = factory.veinPool[num].pos;
float num2 = Mathf.Max(1f, magnitude2 + (((Vector3)(ref pos)).magnitude - magnitude));
Vector3 val2 = val * ((Vector3)(ref pos)).normalized * num2;
if (IsFinite(val2))
{
UpdateVeinPosition(factory, num, val2);
}
}
}
}
private static bool IsFinite(Vector3 value)
{
//IL_0000: 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_001a: 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_0034: 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)
if (!float.IsNaN(value.x) && !float.IsNaN(value.y) && !float.IsNaN(value.z) && !float.IsInfinity(value.x) && !float.IsInfinity(value.y))
{
return !float.IsInfinity(value.z);
}
return false;
}
private void SplitGroup(int anchorId, Vector3 destination)
{
//IL_004d: 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_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_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
PlanetFactory factory = GameMain.localPlanet.factory;
if (!IsValidVein(factory, anchorId))
{
return;
}
short groupIndex = factory.veinPool[anchorId].groupIndex;
EVeinType type = factory.veinPool[anchorId].type;
List<int> list = CollectGroupIds(factory, groupIndex);
if (list.Count < 2)
{
Status = "This group does not contain enough veins to split.";
return;
}
Vector3 anchor = factory.veinPool[anchorId].pos;
list.Sort(delegate(int a, int b)
{
//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_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_004d: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = factory.veinPool[a].pos - anchor;
float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
val = factory.veinPool[b].pos - anchor;
return sqrMagnitude.CompareTo(((Vector3)(ref val)).sqrMagnitude);
});
int count = Mathf.Clamp(SplitCount, 1, list.Count - 1);
List<int> range = list.GetRange(0, count);
if (CanMoveVeins(factory, range))
{
RotateVeins(factory, range, anchor, destination);
short num = (short)factory.AddVeinGroup(type, ((Vector3)(ref destination)).normalized);
for (int num2 = 0; num2 < range.Count; num2++)
{
factory.veinPool[range[num2]].groupIndex = num;
}
factory.RecalculateVeinGroup((int)groupIndex);
factory.RecalculateVeinGroup((int)num);
factory.ArrangeVeinGroups();
Status = "Split " + range.Count + " veins into a new group.";
}
}
private bool MergeGroups(int sourceId, int targetId)
{
//IL_0037: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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_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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: 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_0087: 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_00c0: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
PlanetFactory factory = GameMain.localPlanet.factory;
if (!IsValidVein(factory, sourceId) || !IsValidVein(factory, targetId))
{
Status = "The source or target vein is no longer valid. Select the source again.";
ClearSelection();
return false;
}
VeinData val = factory.veinPool[sourceId];
VeinData val2 = factory.veinPool[targetId];
if (val.type != val2.type)
{
Status = "Target must contain the same resource type. Choose another target or right-click to cancel.";
return false;
}
if (val.groupIndex == val2.groupIndex)
{
Status = "That target is already in the selected source group. Choose a different group.";
return false;
}
short groupIndex = val.groupIndex;
short groupIndex2 = val2.groupIndex;
List<int> list = CollectGroupIds(factory, groupIndex);
if (list.Count == 0)
{
Status = "The selected source group is empty.";
return false;
}
if (!CanMoveVeins(factory, list))
{
return false;
}
RotateVeins(factory, list, val.pos, val2.pos);
for (int i = 0; i < list.Count; i++)
{
factory.veinPool[list[i]].groupIndex = groupIndex2;
}
factory.RecalculateVeinGroup((int)groupIndex);
factory.RecalculateVeinGroup((int)groupIndex2);
CleanupGroup(factory, groupIndex);
Status = "Merged " + list.Count + " veins into the target group.";
return true;
}
private static void UpdateVeinPosition(PlanetFactory factory, int id, Vector3 position)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected I4, but got Unknown
//IL_005f: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: 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_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
if (!IsValidVein(factory, id) || !IsFinite(position))
{
return;
}
PlanetData localPlanet = GameMain.localPlanet;
VeinData val = factory.veinPool[id];
VeinProto val2 = ((ProtoSet<VeinProto>)(object)LDB.veins).Select((int)val.type);
if (val2 != null && val2.prefabDesc != null && val2.prefabDesc.colliders != null && val2.prefabDesc.colliders.Length != 0)
{
val.pos = position;
if (factory.hashSystemStatic != null)
{
val.hashAddress = factory.hashSystemStatic.UpdateObjectHashAddress(id, val.hashAddress, position, (EObjectType)2);
}
if (val.colliderId > 0)
{
localPlanet.physics.RemoveColliderData(val.colliderId);
}
val.colliderId = localPlanet.physics.AddColliderData(((ColliderData)(ref val2.prefabDesc.colliders[0])).BindToObject(id, 0, (EObjectType)2, position, Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref position)).normalized)));
factory.veinPool[id] = val;
localPlanet.factoryModel.gpuiManager.AlterModel((int)val.modelIndex, val.modelId, id, position, Maths.SphericalRotation(position, 90f), true);
factory.RefreshVeinMiningDisplay(id, 0, 0);
}
}
private static void CleanupGroup(PlanetFactory factory, int group)
{
if (group > 0 && group < factory.veinGroups.Length && factory.veinGroups[group].count <= 0)
{
((VeinGroup)(ref factory.veinGroups[group])).SetNull();
factory.ArrangeVeinGroups();
}
}
private static bool IsValidVein(PlanetFactory factory, int id)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Invalid comparison between Unknown and I4
if (factory != null && factory.veinPool != null && id > 0 && id < factory.veinCursor && factory.veinPool[id].id == id)
{
return (int)factory.veinPool[id].type > 0;
}
return false;
}
}
}