using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DSP Star Sector Resource Spreadsheet Generator")]
[assembly: AssemblyDescription("Mod for Dyson Sphere Program will generate a spreadsheet of all resources in a star sector.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DSP Star Sector Resource Spreadsheet Generator")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5f095ce2-57a4-455f-80aa-b1ac483428c8")]
[assembly: AssemblyFileVersion("4.0.2")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("4.0.2.0")]
[module: UnverifiableCode]
namespace StarSectorResourceSpreadsheetGenerator;
[BepInPlugin("greyhak.dysonsphereprogram.resourcespreadsheetgen", "DSP Star Sector Resource Spreadsheet Generator", "4.0.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("DSPGAME.exe")]
[BepInProcess("Dyson Sphere Program.exe")]
public class SpreadsheetGenMod : BaseUnityPlugin
{
public enum DistanceFromTypeEnum
{
[Description("Disable post-generation distance calculations")]
Disabled,
[Description("EXCEL for post-generation distance calculations")]
Excel,
[Description("OPEN CALC for post-generation distance calculations")]
OpenCalc
}
public class ConfigExtraFlags
{
public static ConfigEntry<bool> starAge;
public static ConfigEntry<bool> starColor;
public static ConfigEntry<bool> starLifetime;
public static ConfigEntry<bool> starMass;
public static ConfigEntry<bool> starRadius;
public static ConfigEntry<bool> starMaxSphereRadius;
public static ConfigEntry<bool> starTemperature;
public static ConfigEntry<bool> distanceFromStarClusterCenter;
public static ConfigEntry<bool> planetOrbitalPeriod;
public static ConfigEntry<bool> planetOrbitAround;
public static ConfigEntry<bool> planetOrbitAroundPlanet;
public static ConfigEntry<bool> planetOrbitInclination;
public static ConfigEntry<bool> planetOrbitLongitude;
public static ConfigEntry<bool> planetOrbitPhase;
public static ConfigEntry<bool> planetOrbitRadius;
public static ConfigEntry<bool> planetRealRadius;
public static ConfigEntry<bool> planetRotationPeriod;
public static ConfigEntry<bool> planetRotationPhase;
public static ConfigEntry<bool> planetSunDistance;
public static ConfigEntry<bool> veinCounts;
}
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static Func<CodeInstruction, bool> <>9__29_0;
public static Action<PlanetData> <>9__29_1;
public static UnityAction <>9__36_0;
internal bool <PlanetScanThreadMain_Transpiler>b__29_0(CodeInstruction i)
{
if (i.opcode == OpCodes.Callvirt)
{
return ((MethodInfo)i.operand).Name == "NotifyScanEnded";
}
return false;
}
internal void <PlanetScanThreadMain_Transpiler>b__29_1(PlanetData planet)
{
Monitor.Enter(planetComputeThreadMutexLock);
if (spreadsheetGenRequestFlag && planetsToLoad.Contains(planet))
{
if (stringBuilder == null)
{
stringBuilder = new StringBuilder(8192);
}
CapturePlanetResourceData(planet, stringBuilder);
if (planetResourceData.Count == planetCount)
{
GenerateResourceSpreadsheet();
stringBuilder = null;
}
if (planet.data != null)
{
planet.data.Free();
planet.data = null;
}
planet.modData = null;
planet.aux = null;
planet.scanned = false;
}
Monitor.Exit(planetComputeThreadMutexLock);
}
internal void <GameMain_Begin_Prefix>b__36_0()
{
QueuePlanetLoading();
}
}
public const string pluginGuid = "greyhak.dysonsphereprogram.resourcespreadsheetgen";
public const string pluginName = "DSP Star Sector Resource Spreadsheet Generator";
public const string pluginVersion = "4.0.2";
public static bool spreadsheetGenRequestFlag = false;
public static readonly List<PlanetData> planetsToLoad = new List<PlanetData>();
public static readonly Dictionary<int, string> planetResourceData = new Dictionary<int, string>();
public static bool checkForPlanetsToUnload = false;
public static CultureInfo spreadsheetLocale = CultureInfo.CurrentUICulture;
internal static ManualLogSource Logger;
internal static ConfigFile Config;
public static readonly int[] gases = new int[3] { 1120, 1121, 1011 };
public static int planetCount = 0;
public static long[] veinAmounts = new long[64];
public static StringBuilder stringBuilder;
public static ConfigEntry<bool> enablePlanetLoadingFlag;
public static ConfigEntry<string> spreadsheetFileNameTemplate;
public static ConfigEntry<string> spreadsheetColumnSeparator;
public static ConfigEntry<int> spreadsheetFloatPrecision;
public Harmony harmony;
public static ConfigEntry<DistanceFromTypeEnum> includeDistanceFromCalculations;
private static readonly object planetComputeThreadMutexLock = new object();
public static RectTransform triggerButton;
public static Sprite triggerSprite;
public static Image progressImage;
public void Awake()
{
//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
//IL_03cf: Expected O, but got Unknown
//IL_040e: Unknown result type (might be due to invalid IL or missing references)
//IL_0414: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Config = ((BaseUnityPlugin)this).Config;
string text = "DSP_Star_Sector_Resources_${seed}-${starCount}.csv";
if (Environment.GetFolderPath(Environment.SpecialFolder.Personal) != "")
{
string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
char directorySeparatorChar = Path.DirectorySeparatorChar;
text = folderPath + directorySeparatorChar + text;
}
spreadsheetFileNameTemplate = Config.Bind<string>("Output", "SpreadsheetFileName", text, "Path to the output spreadsheet. You can use ${seed} and ${starCount} as placeholders and the mod will insert them into the filename.");
spreadsheetColumnSeparator = Config.Bind<string>("Output", "SpreadsheetColumnSeparator", ",", "Character to use as Separator in the generated file.");
spreadsheetFloatPrecision = Config.Bind<int>("Output", "SpreadsheetFloatPrecision", -1, "Decimals to use when exporting floating point numbers. Use -1 to disable rounding.");
spreadsheetLocale = new CultureInfo(Config.Bind<string>("Output", "SpreadsheetLocale", spreadsheetLocale.Name, "Locale to use for exporting numbers.").Value, useUserOverride: false);
includeDistanceFromCalculations = Config.Bind<DistanceFromTypeEnum>("Output", "DistanceFrom", DistanceFromTypeEnum.Disabled, "This feature provides the ability to choose any planet, and calculate the distance from that planet to all other planets. This feature supports Microsoft Excel and OpenOffice Calc.");
enablePlanetLoadingFlag = Config.Bind<bool>("Enable", "LoadAllPlanets", true, "Planet loading is needed to get all resource data, but you can skip this step if you want results fast.");
ConfigExtraFlags.starAge = Config.Bind<bool>("ExtraData", "StarAge", false, "Add stars' age to the spreadsheet");
ConfigExtraFlags.starColor = Config.Bind<bool>("ExtraData", "StarColor", false, "Add stars' color to the spreadsheet");
ConfigExtraFlags.starLifetime = Config.Bind<bool>("ExtraData", "StarLifetime", false, "Add stars' lifetime to the spreadsheet");
ConfigExtraFlags.starMass = Config.Bind<bool>("ExtraData", "StarMass", false, "Add stars' mass to the spreadsheet");
ConfigExtraFlags.starRadius = Config.Bind<bool>("ExtraData", "StarRadius", false, "Add stars' radius to the spreadsheet");
ConfigExtraFlags.starMaxSphereRadius = Config.Bind<bool>("ExtraData", "StarMaxSphereRadius", false, "The star's maximum dyson shell layer 'orbit radius'. This is calculated by round(StarData.dysonRadius * 800) * 100.");
ConfigExtraFlags.starTemperature = Config.Bind<bool>("ExtraData", "StarTemperature", false, "Add stars' temperature to the spreadsheet");
ConfigExtraFlags.distanceFromStarClusterCenter = Config.Bind<bool>("ExtraData", "DistanceFromStarClusterCenter", false, "Add star's distance from the center of the star cluster. This is typically the location of the initial planet's star.");
ConfigExtraFlags.planetOrbitalPeriod = Config.Bind<bool>("ExtraData", "PlanetOrbitalPeriod", false, "Add planets' orbital period to the spreadsheet");
ConfigExtraFlags.planetOrbitAround = Config.Bind<bool>("ExtraData", "PlanetOrbitAround", false, "Add type of orbital relationship to the spreadsheet");
ConfigExtraFlags.planetOrbitAroundPlanet = Config.Bind<bool>("ExtraData", "PlanetOrbitAroundPlanet", false, "Add name of planet the planets orbit, if they orbit a planet, to the spreadsheet");
ConfigExtraFlags.planetOrbitInclination = Config.Bind<bool>("ExtraData", "PlanetOrbitInclination", false, "Add planets' orbit inclination to the spreadsheet");
ConfigExtraFlags.planetOrbitLongitude = Config.Bind<bool>("ExtraData", "PlanetOrbitLongitude", false, "Add planets' orbit longitude to the spreadsheet");
ConfigExtraFlags.planetOrbitPhase = Config.Bind<bool>("ExtraData", "PlanetOrbitPhase", false, "Add planets' orbit phase to the spreadsheet");
ConfigExtraFlags.planetOrbitRadius = Config.Bind<bool>("ExtraData", "PlanetOrbitRadius", false, "Add planets' orbit radius to the spreadsheet");
ConfigExtraFlags.planetRealRadius = Config.Bind<bool>("ExtraData", "PlanetRealRadius", false, "Add planets' real radius to the spreadsheet");
ConfigExtraFlags.planetRotationPeriod = Config.Bind<bool>("ExtraData", "PlanetRotationPeriod", false, "Add planets' rotation period to the spreadsheet");
ConfigExtraFlags.planetRotationPhase = Config.Bind<bool>("ExtraData", "PlanetRotationPhase", false, "Add planets' rotation phase to the spreadsheet");
ConfigExtraFlags.planetSunDistance = Config.Bind<bool>("ExtraData", "PlanetSunDistance", false, "Add planets' distance from their star to the spreadsheet");
ConfigExtraFlags.veinCounts = Config.Bind<bool>("ExtraData", "VeinCounts", false, "Add the number of veins for each vein resource in addition to the total number of items.");
Config.SettingChanged += OnConfigSettingChanged;
Logger.LogInfo((object)("Will use spreadsheet path \"" + spreadsheetFileNameTemplate.Value + "\""));
harmony = new Harmony("greyhak.dysonsphereprogram.resourcespreadsheetgen");
harmony.PatchAll(typeof(SpreadsheetGenMod));
if (Chainloader.PluginInfos.TryGetValue("dsp.galactic-scale.2", out var value))
{
try
{
HarmonyMethod val = new HarmonyMethod(typeof(SpreadsheetGenMod).GetMethod("PlanetCalculateThreadMain_Transpiler"));
Type type = ((object)value.Instance).GetType().Assembly.GetType("GalacticScale.Modeler");
harmony.Patch((MethodBase)AccessTools.Method(type, "Calculate", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null);
Logger.LogInfo((object)"GalacticScale compatibility patch success!");
}
catch (Exception ex)
{
Logger.LogError((object)"Fail to patch GalacticScale.Modeler.Calculate");
Logger.LogError((object)ex);
}
}
Logger.LogInfo((object)"Initialization complete.");
}
public void OnDestroy()
{
harmony.UnpatchSelf();
}
public static void OnConfigSettingChanged(object sender, SettingChangedEventArgs e)
{
ConfigDefinition definition = e.ChangedSetting.Definition;
if ((!(definition.Section == "Output") || !(definition.Key == "SpreadsheetFileName")) && (!(definition.Section == "Enable") || !(definition.Key == "LoadAllPlanets")))
{
Monitor.Enter(planetComputeThreadMutexLock);
spreadsheetGenRequestFlag = false;
planetsToLoad.Clear();
planetResourceData.Clear();
if ((Object)(object)progressImage != (Object)null)
{
progressImage.fillAmount = 0f;
}
Monitor.Exit(planetComputeThreadMutexLock);
if (definition.Section == "Output" && definition.Key == "SpreadsheetLocale")
{
spreadsheetLocale = new CultureInfo(Config.Bind<string>("Output", "SpreadsheetLocale", spreadsheetLocale.Name, "Locale to use for exporting numbers.").Value, useUserOverride: false);
}
}
}
public static void QueuePlanetLoading()
{
if (DSPGame.IsMenuDemo)
{
Logger.LogInfo((object)"Ignoring load screen.");
return;
}
Monitor.Enter(planetComputeThreadMutexLock);
bool num = spreadsheetGenRequestFlag;
Monitor.Exit(planetComputeThreadMutexLock);
if (num)
{
Logger.LogInfo((object)"Spreadsheet generation already in progress.");
return;
}
Logger.LogInfo((object)"Scanning planets...");
planetsToLoad.Clear();
StringBuilder sb = new StringBuilder(8192);
StarData[] stars = GameMain.universeSimulator.galaxyData.stars;
for (int i = 0; i < stars.Length; i++)
{
PlanetData[] planets = stars[i].planets;
foreach (PlanetData val in planets)
{
if (!planetResourceData.ContainsKey(val.id))
{
if (val.scanned)
{
CapturePlanetResourceData(val, sb);
}
else if (enablePlanetLoadingFlag.Value)
{
planetsToLoad.Add(val);
}
}
}
}
if (planetsToLoad.Count == 0)
{
Logger.LogInfo((object)"Planet resource data already available. Proceeding with resource spreadsheet generation.");
GenerateResourceSpreadsheet();
return;
}
if (!enablePlanetLoadingFlag.Value)
{
Logger.LogInfo((object)"Skipping planet load. Proceeding with resource spreadsheet generation. Speadsheet will be incomplete.");
GenerateResourceSpreadsheet();
return;
}
Logger.LogInfo((object)(planetsToLoad.Count + " planets to be loaded. Waiting for planets to load."));
Monitor.Enter(planetComputeThreadMutexLock);
spreadsheetGenRequestFlag = true;
foreach (PlanetData item in planetsToLoad)
{
item.RunScanThread();
}
Monitor.Exit(planetComputeThreadMutexLock);
}
public static void QuickPlanetLoad(PlanetData planetData)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
PlanetAlgorithm val = PlanetModelingManager.Algorithm(planetData);
if (val != null)
{
if (planetData.data == null)
{
planetData.data = new PlanetRawData(planetData.precision);
planetData.modData = planetData.data.InitModData(planetData.modData);
planetData.data.CalcVerts();
planetData.aux = new PlanetAuxData(planetData);
val.GenerateTerrain(planetData.mod_x, planetData.mod_y);
val.CalcWaterPercent();
}
if (planetData.factory == null)
{
val.GenerateVeins();
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameMain), "End")]
public static void GameMain_End_Prefix()
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Invalid comparison between Unknown and I4
Monitor.Enter(planetComputeThreadMutexLock);
spreadsheetGenRequestFlag = false;
planetsToLoad.Clear();
planetResourceData.Clear();
Monitor.Exit(planetComputeThreadMutexLock);
if (PlanetModelingManager.genPlanetReqList.Count == 0 && PlanetModelingManager.fctPlanetReqList.Count == 0 && PlanetModelingManager.modPlanetReqList.Count == 0 && PlanetModelingManager.scnPlanetReqList.Count == 0)
{
Logger.LogInfo((object)"Planet modeling reset is not needed.");
return;
}
Logger.LogInfo((object)"Stopping planet modeling thread.");
PlanetModelingManager.EndPlanetComputeThread();
PlanetModelingManager.EndPlanetScanThread();
Thread.Sleep(100);
uint num = 1u;
while ((int)PlanetModelingManager.planetComputeThreadFlag == 2 && ++num < 100)
{
Thread.Sleep(100);
}
Logger.LogInfo((object)"Clearing planet modeling queues.");
PlanetModelingManager.genPlanetReqList.Clear();
PlanetModelingManager.fctPlanetReqList.Clear();
PlanetModelingManager.modPlanetReqList.Clear();
PlanetModelingManager.scnPlanetReqList.Clear();
if (PlanetModelingManager.currentModelingPlanet != null)
{
Logger.LogInfo((object)("Cancelling planet modeling for " + PlanetModelingManager.currentModelingPlanet.name));
PlanetModelingManager.currentModelingPlanet.Unload();
PlanetModelingManager.currentModelingPlanet.factoryLoaded = false;
PlanetModelingManager.currentModelingPlanet = null;
PlanetModelingManager.currentModelingStage = 0;
PlanetModelingManager.currentModelingSeamNormal = 0;
}
if (PlanetModelingManager.currentFactingPlanet != null)
{
Logger.LogInfo((object)("Cancelling planet factory modeling for " + PlanetModelingManager.currentFactingPlanet.name));
PlanetModelingManager.currentFactingPlanet.UnloadFactory();
PlanetModelingManager.currentFactingPlanet.factoryLoaded = false;
PlanetModelingManager.currentFactingPlanet = null;
PlanetModelingManager.currentFactingStage = 0;
}
Logger.LogInfo((object)"Resetting planet modeling manager so we don't get a magenta planet when a new game begins.");
for (int i = 0; i < PlanetModelingManager.tmpMeshList.Count; i++)
{
Object.Destroy((Object)(object)PlanetModelingManager.tmpMeshList[i]);
}
Object.Destroy((Object)(object)PlanetModelingManager.tmpPlanetGameObject);
PlanetModelingManager.tmpPlanetGameObject = null;
PlanetModelingManager.tmpPlanetBodyGameObject = null;
PlanetModelingManager.tmpPlanetReformGameObject = null;
PlanetModelingManager.tmpPlanetReformRenderer = null;
PlanetModelingManager.tmpMeshList.Clear();
PlanetModelingManager.tmpTris.Clear();
PlanetModelingManager.tmpVerts.Clear();
PlanetModelingManager.tmpNorms.Clear();
PlanetModelingManager.tmpTgnts.Clear();
PlanetModelingManager.tmpUvs.Clear();
PlanetModelingManager.tmpUv2s.Clear();
PlanetModelingManager.currentModelingPlanet = null;
PlanetModelingManager.currentModelingStage = 0;
PlanetModelingManager.currentModelingSeamNormal = 0;
Logger.LogInfo((object)"Restarting planet modeling thread.");
PlanetModelingManager.StartPlanetComputeThread();
PlanetModelingManager.StartPlanetScanThread();
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlanetModelingManager), "PlanetScanThreadMain")]
public static IEnumerable<CodeInstruction> PlanetScanThreadMain_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0002: 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_0036: Expected O, but got Unknown
try
{
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null).MatchForward(true, (CodeMatch[])(object)new CodeMatch[1]
{
new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => i.opcode == OpCodes.Callvirt && ((MethodInfo)i.operand).Name == "NotifyScanEnded"), (string)null)
}).Advance(1);
val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
{
val.InstructionAt(-2),
Transpilers.EmitDelegate<Action<PlanetData>>((Action<PlanetData>)delegate(PlanetData planet)
{
Monitor.Enter(planetComputeThreadMutexLock);
if (spreadsheetGenRequestFlag && planetsToLoad.Contains(planet))
{
if (stringBuilder == null)
{
stringBuilder = new StringBuilder(8192);
}
CapturePlanetResourceData(planet, stringBuilder);
if (planetResourceData.Count == planetCount)
{
GenerateResourceSpreadsheet();
stringBuilder = null;
}
if (planet.data != null)
{
planet.data.Free();
planet.data = null;
}
planet.modData = null;
planet.aux = null;
planet.scanned = false;
}
Monitor.Exit(planetComputeThreadMutexLock);
})
});
return val.InstructionEnumeration();
}
catch
{
Logger.LogError((object)"Transpiler PlanetCalculateThreadMain failed. Mod version not compatible with game version.");
return instructions;
}
}
public static void GenerateResourceSpreadsheet()
{
//IL_057e: Unknown result type (might be due to invalid IL or missing references)
//IL_059a: Unknown result type (might be due to invalid IL or missing references)
//IL_059c: Invalid comparison between Unknown and I4
//IL_0617: Unknown result type (might be due to invalid IL or missing references)
//IL_0619: Unknown result type (might be due to invalid IL or missing references)
//IL_061b: Unknown result type (might be due to invalid IL or missing references)
try
{
Logger.LogInfo((object)"Begin resource spreadsheet generation...");
StringBuilder stringBuilder = new StringBuilder(8192);
int num = 1;
if (includeDistanceFromCalculations.Value != 0)
{
stringBuilder.Append("Distance Target").Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append(spreadsheetColumnSeparator.Value);
if (includeDistanceFromCalculations.Value == DistanceFromTypeEnum.OpenCalc)
{
escapeAddValue(stringBuilder, "=VLOOKUP($A$2;$A$4:$H$___HERE_TOTAL_LINE_NUMBER___;6;FALSE)");
escapeAddValue(stringBuilder, "=VLOOKUP($A$2;$A$4:$H$___HERE_TOTAL_LINE_NUMBER___;7;FALSE)");
escapeAddValue(stringBuilder, "=VLOOKUP($A$2;$A$4:$H$___HERE_TOTAL_LINE_NUMBER___;8;FALSE)");
}
else if (includeDistanceFromCalculations.Value == DistanceFromTypeEnum.Excel)
{
escapeAddValue(stringBuilder, "=VLOOKUP($A$2,$A$4:$H$___HERE_TOTAL_LINE_NUMBER___,6,FALSE)");
escapeAddValue(stringBuilder, "=VLOOKUP($A$2,$A$4:$H$___HERE_TOTAL_LINE_NUMBER___,7,FALSE)");
escapeAddValue(stringBuilder, "=VLOOKUP($A$2,$A$4:$H$___HERE_TOTAL_LINE_NUMBER___,8,FALSE)");
}
stringBuilder.Append(Environment.NewLine);
num++;
stringBuilder.Append("!!! Replace this cell with any of the planet names from cells A4 to A___HERE_TOTAL_LINE_NUMBER___").Append(Environment.NewLine);
num++;
}
stringBuilder.Append("Planet Name").Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append("Star Name").Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append("Star Dyson Luminosity").Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append("Star Type").Append(spreadsheetColumnSeparator.Value);
if (includeDistanceFromCalculations.Value != 0)
{
stringBuilder.Append("Distance to target").Append(spreadsheetColumnSeparator.Value);
}
stringBuilder.Append("Star Position X").Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append("Star Position Y").Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append("Star Position Z").Append(spreadsheetColumnSeparator.Value);
if (ConfigExtraFlags.starAge.Value)
{
stringBuilder.Append("Star Age").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.starColor.Value)
{
stringBuilder.Append("Star Color").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.starLifetime.Value)
{
stringBuilder.Append("Star Lifetime").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.starMass.Value)
{
stringBuilder.Append("Star Mass").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.starRadius.Value)
{
stringBuilder.Append("Star Radius").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.starMaxSphereRadius.Value)
{
stringBuilder.Append("Max Sphere Radius").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.starTemperature.Value)
{
stringBuilder.Append("Star Temperature").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.distanceFromStarClusterCenter.Value)
{
stringBuilder.Append("Distance from Cluster Center").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.planetOrbitalPeriod.Value)
{
stringBuilder.Append("Orbital Period").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.planetOrbitAround.Value)
{
stringBuilder.Append("Planet/Moon").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.planetOrbitAroundPlanet.Value)
{
stringBuilder.Append("Orbiting").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.planetOrbitInclination.Value)
{
stringBuilder.Append("Orbit Inclination").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.planetOrbitLongitude.Value)
{
stringBuilder.Append("Orbit Longitude").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.planetOrbitPhase.Value)
{
stringBuilder.Append("Orbit Phase").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.planetOrbitRadius.Value)
{
stringBuilder.Append("Orbit Radius").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.planetRealRadius.Value)
{
stringBuilder.Append("Real Radius").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.planetRotationPeriod.Value)
{
stringBuilder.Append("Rotation Period").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.planetRotationPhase.Value)
{
stringBuilder.Append("Rotation Phase").Append(spreadsheetColumnSeparator.Value);
}
if (ConfigExtraFlags.planetSunDistance.Value)
{
stringBuilder.Append("Distance from Star").Append(spreadsheetColumnSeparator.Value);
}
stringBuilder.Append("Wind Strength").Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append("Luminosity on Planet").Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append("Planet Type").Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append("Land Percent").Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append("Singularity").Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append("Ocean").Append(spreadsheetColumnSeparator.Value);
EVeinType val = (EVeinType)1;
VeinProto[] dataArray = ((ProtoSet<VeinProto>)(object)LDB.veins).dataArray;
foreach (VeinProto val2 in dataArray)
{
if ((int)val == 7 || !ConfigExtraFlags.veinCounts.Value)
{
stringBuilder.Append(((Proto)val2).name).Append(spreadsheetColumnSeparator.Value);
}
else
{
stringBuilder.Append(((Proto)val2).name + " (items)").Append(spreadsheetColumnSeparator.Value);
stringBuilder.Append(((Proto)val2).name + " (veins)").Append(spreadsheetColumnSeparator.Value);
}
val = (EVeinType)(byte)(val + 1);
}
int[] array = gases;
foreach (int num2 in array)
{
stringBuilder.Append(((Proto)((ProtoSet<ItemProto>)(object)LDB.items).Select(num2)).name).Append(spreadsheetColumnSeparator.Value);
}
stringBuilder.Append(Environment.NewLine);
num++;
StarData[] stars = GameMain.universeSimulator.galaxyData.stars;
for (int i = 0; i < stars.Length; i++)
{
PlanetData[] planets = stars[i].planets;
foreach (PlanetData val3 in planets)
{
if (planetResourceData.ContainsKey(val3.id))
{
stringBuilder.Append(planetResourceData[val3.id].Replace("___HERE_CURRENT_LINE_NUMBER___", num.ToString()));
num++;
}
else
{
Logger.LogError((object)("ERROR: Missing resource data for " + val3.displayName));
stringBuilder.AppendFormat("{0}\n", val3.displayName);
num++;
}
}
}
string text = spreadsheetFileNameTemplate.Value.Replace("${seed}", GameMain.galaxy.seed.ToString("D8")).Replace("${starCount}", GameMain.galaxy.starCount.ToString());
new FileInfo(text).Directory.Create();
string text2 = stringBuilder.ToString();
text2 = text2.Replace("___HERE_TOTAL_LINE_NUMBER___", (num - 1).ToString());
File.WriteAllText(text, text2);
Logger.LogInfo((object)"Completed saving resource spreadsheet.");
}
catch (ArgumentNullException ex)
{
Logger.LogInfo((object)("ERROR: ArgumentNullException while generating and saving resource spreadsheet: " + ex.Message + ";" + ex.ToString()));
}
catch (ArgumentException ex2)
{
Logger.LogInfo((object)("ERROR: ArgumentException while generating and saving resource spreadsheet: " + ex2.Message + ";" + ex2.ToString()));
}
catch (PathTooLongException ex3)
{
Logger.LogInfo((object)("ERROR: PathTooLongException while generating and saving resource spreadsheet: " + ex3.Message + ";" + ex3.ToString()));
}
catch (DirectoryNotFoundException ex4)
{
Logger.LogInfo((object)("ERROR: DirectoryNotFoundException while generating and saving resource spreadsheet: " + ex4.Message + ";" + ex4.ToString()));
}
catch (IOException ex5)
{
Logger.LogInfo((object)("ERROR: IOException while generating and saving resource spreadsheet: " + ex5.Message + ";" + ex5.ToString()));
}
catch (UnauthorizedAccessException ex6)
{
Logger.LogInfo((object)("ERROR: UnauthorizedAccessException while generating and saving resource spreadsheet: " + ex6.Message + ";" + ex6.ToString()));
}
catch (NotSupportedException ex7)
{
Logger.LogInfo((object)("ERROR: NotSupportedException while generating and saving resource spreadsheet: " + ex7.Message + ";" + ex7.ToString()));
}
catch (SecurityException ex8)
{
Logger.LogInfo((object)("ERROR: SecurityException while generating and saving resource spreadsheet: " + ex8.Message + ";" + ex8.ToString()));
}
catch (Exception ex9)
{
Logger.LogInfo((object)("ERROR: Exception (catch-all) while generating and saving resource spreadsheet." + ex9.Message + ";" + ex9.ToString()));
}
progressImage.fillAmount = 0f;
spreadsheetGenRequestFlag = false;
}
public static void CapturePlanetResourceData(PlanetData planet, StringBuilder sb)
{
//IL_0615: Unknown result type (might be due to invalid IL or missing references)
//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0636: Unknown result type (might be due to invalid IL or missing references)
//IL_063b: Unknown result type (might be due to invalid IL or missing references)
//IL_063e: Invalid comparison between Unknown and I4
//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
//IL_05cb: Invalid comparison between Unknown and I4
//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
//IL_05e7: Unknown result type (might be due to invalid IL or missing references)
//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
//IL_06d5: Unknown result type (might be due to invalid IL or missing references)
//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
//IL_0693: Unknown result type (might be due to invalid IL or missing references)
//IL_0698: Unknown result type (might be due to invalid IL or missing references)
//IL_069a: Unknown result type (might be due to invalid IL or missing references)
//IL_069c: Unknown result type (might be due to invalid IL or missing references)
//IL_06a1: Unknown result type (might be due to invalid IL or missing references)
//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0448: Unknown result type (might be due to invalid IL or missing references)
//IL_044e: Invalid comparison between Unknown and I4
//IL_045f: Unknown result type (might be due to invalid IL or missing references)
//IL_0483: Unknown result type (might be due to invalid IL or missing references)
//IL_0486: Invalid comparison between Unknown and I4
//IL_049f: Unknown result type (might be due to invalid IL or missing references)
//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
StarData star = planet.star;
string text = "";
if (spreadsheetFloatPrecision.Value >= 0)
{
text = "F" + ((object)spreadsheetFloatPrecision).ToString();
}
sb.Length = 0;
escapeAddValue(sb, planet.displayName);
escapeAddValue(sb, star.displayName);
escapeAddValue(sb, star.dysonLumino.ToString(text, spreadsheetLocale));
escapeAddValue(sb, star.typeString);
if (includeDistanceFromCalculations.Value == DistanceFromTypeEnum.OpenCalc)
{
escapeAddValue(sb, "=SQRT(SUMXMY2($F$1:$H$1;F___HERE_CURRENT_LINE_NUMBER___:H___HERE_CURRENT_LINE_NUMBER___))");
}
else if (includeDistanceFromCalculations.Value == DistanceFromTypeEnum.Excel)
{
escapeAddValue(sb, "=SQRT(SUMXMY2($F$1:$H$1,F___HERE_CURRENT_LINE_NUMBER___:H___HERE_CURRENT_LINE_NUMBER___))");
}
escapeAddValue(sb, star.position.x.ToString(text, spreadsheetLocale));
escapeAddValue(sb, star.position.y.ToString(text, spreadsheetLocale));
escapeAddValue(sb, star.position.z.ToString(text, spreadsheetLocale));
if (ConfigExtraFlags.starAge.Value)
{
escapeAddValue(sb, star.age.ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.starColor.Value)
{
escapeAddValue(sb, star.color.ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.starLifetime.Value)
{
escapeAddValue(sb, star.lifetime.ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.starMass.Value)
{
escapeAddValue(sb, star.mass.ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.starRadius.Value)
{
escapeAddValue(sb, star.radius.ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.starMaxSphereRadius.Value)
{
escapeAddValue(sb, (Math.Round(star.dysonRadius * 800f) * 100.0).ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.starTemperature.Value)
{
escapeAddValue(sb, star.temperature.ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.distanceFromStarClusterCenter.Value)
{
escapeAddValue(sb, Vector3.Distance(VectorLF3.op_Implicit(star.position), new Vector3(0f, 0f, 0f)).ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.planetOrbitalPeriod.Value)
{
escapeAddValue(sb, planet.orbitalPeriod.ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.planetOrbitAround.Value)
{
escapeAddValue(sb, planet.orbitAround.ToString());
}
if (ConfigExtraFlags.planetOrbitAroundPlanet.Value)
{
if (planet.orbitAroundPlanet == null)
{
sb.Append(spreadsheetColumnSeparator.Value);
}
else
{
escapeAddValue(sb, planet.orbitAroundPlanet.displayName);
}
}
if (ConfigExtraFlags.planetOrbitInclination.Value)
{
escapeAddValue(sb, planet.orbitInclination.ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.planetOrbitLongitude.Value)
{
escapeAddValue(sb, planet.orbitLongitude.ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.planetOrbitPhase.Value)
{
escapeAddValue(sb, planet.orbitPhase.ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.planetOrbitRadius.Value)
{
escapeAddValue(sb, planet.orbitRadius.ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.planetRealRadius.Value)
{
escapeAddValue(sb, planet.realRadius.ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.planetRotationPeriod.Value)
{
escapeAddValue(sb, planet.rotationPeriod.ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.planetRotationPhase.Value)
{
escapeAddValue(sb, planet.rotationPhase.ToString(text, spreadsheetLocale));
}
if (ConfigExtraFlags.planetSunDistance.Value)
{
escapeAddValue(sb, planet.sunDistance.ToString(text, spreadsheetLocale));
}
escapeAddValue(sb, planet.windStrength.ToString(text, spreadsheetLocale));
escapeAddValue(sb, planet.luminosity.ToString(text, spreadsheetLocale));
escapeAddValue(sb, planet.typeString);
escapeAddValue(sb, planet.landPercent.ToString(text, spreadsheetLocale));
escapeAddValue(sb, ((object)(EPlanetSingularity)(ref planet.singularity)).ToString());
if ((int)planet.type == 5)
{
escapeAddValue(sb, "None");
EVeinType val = (EVeinType)1;
VeinProto[] dataArray = ((ProtoSet<VeinProto>)(object)LDB.veins).dataArray;
for (int i = 0; i < dataArray.Length; i++)
{
_ = dataArray[i];
escapeAddValue(sb, "0");
if ((int)val != 7 && ConfigExtraFlags.veinCounts.Value)
{
escapeAddValue(sb, "0");
}
val = (EVeinType)(byte)(val + 1);
}
int[] array = gases;
foreach (int value in array)
{
int num = Array.IndexOf(planet.gasItems, value);
if (num == -1)
{
escapeAddValue(sb, "0");
}
else
{
escapeAddValue(sb, planet.gasSpeeds[num].ToString(text, spreadsheetLocale));
}
}
}
else
{
if (planet.waterItemId == 0)
{
escapeAddValue(sb, "None");
}
else if (planet.waterItemId == -1)
{
escapeAddValue(sb, "Lava");
}
else if (planet.waterItemId == -2)
{
escapeAddValue(sb, "Ice");
}
else
{
try
{
ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(planet.waterItemId);
escapeAddValue(sb, ((Proto)val2).name);
}
catch
{
escapeAddValue(sb, $"UNKNOWN ocean type {planet.waterItemId}. Please write a ticket at https://github.com/GreyHak/dsp-csv-gen/issues. Thank you.");
}
}
if (planet.runtimeVeinGroups == null)
{
EVeinType val3 = (EVeinType)1;
VeinProto[] dataArray = ((ProtoSet<VeinProto>)(object)LDB.veins).dataArray;
for (int i = 0; i < dataArray.Length; i++)
{
_ = dataArray[i];
escapeAddValue(sb, "Unloaded");
if ((int)val3 != 7 && ConfigExtraFlags.veinCounts.Value)
{
escapeAddValue(sb, "Unloaded");
}
val3 = (EVeinType)(byte)(val3 + 1);
}
}
else
{
HashSet<int> hashSet = new HashSet<int>();
planet.SummarizeVeinAmountsByFilter(ref veinAmounts, hashSet, 0);
EVeinType val4 = (EVeinType)1;
VeinProto[] dataArray = ((ProtoSet<VeinProto>)(object)LDB.veins).dataArray;
for (int i = 0; i < dataArray.Length; i++)
{
_ = dataArray[i];
long num2 = veinAmounts[val4];
if ((int)val4 == 7)
{
escapeAddValue(sb, ((double)num2 * (double)VeinData.oilSpeedMultiplier).ToString(text, spreadsheetLocale));
}
else
{
escapeAddValue(sb, num2.ToString(spreadsheetLocale));
if (ConfigExtraFlags.veinCounts.Value)
{
long num3 = 0L;
VeinGroup[] runtimeVeinGroups = planet.runtimeVeinGroups;
foreach (VeinGroup val5 in runtimeVeinGroups)
{
if (val5.type == val4)
{
num3 += val5.count;
}
}
escapeAddValue(sb, num3.ToString(spreadsheetLocale));
}
}
val4 = (EVeinType)(byte)(val4 + 1);
}
}
int[] array = gases;
for (int i = 0; i < array.Length; i++)
{
_ = array[i];
escapeAddValue(sb, "0");
}
}
sb.Append(Environment.NewLine);
planetResourceData[planet.id] = sb.ToString();
progressImage.fillAmount = (float)planetResourceData.Count / (float)planetCount;
}
public static void escapeAddValue(StringBuilder sb, string value)
{
bool num = value.Contains(",");
string value2 = value.Replace('"', '_');
if (num)
{
sb.Append('"');
}
sb.Append(value2);
if (num)
{
sb.Append('"');
}
sb.Append(spreadsheetColumnSeparator.Value);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameMain), "Begin")]
public static void GameMain_Begin_Prefix()
{
//IL_00ca: 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_017c: 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_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: 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_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0292: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02ac: 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_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Expected O, but got Unknown
Monitor.Enter(planetComputeThreadMutexLock);
spreadsheetGenRequestFlag = false;
planetsToLoad.Clear();
planetResourceData.Clear();
planetCount = 0;
StarData[] stars = GameMain.universeSimulator.galaxyData.stars;
foreach (StarData val in stars)
{
planetCount += val.planets.Length;
}
Monitor.Exit(planetComputeThreadMutexLock);
if (!((Object)(object)GameMain.instance != (Object)null) || !Object.op_Implicit((Object)(object)GameObject.Find("Game Menu/button-1-bg")))
{
return;
}
if ((Object)(object)progressImage != (Object)null)
{
progressImage.fillAmount = 0f;
return;
}
RectTransform component = GameObject.Find("Game Menu").GetComponent<RectTransform>();
RectTransform component2 = GameObject.Find("Game Menu/button-1-bg").GetComponent<RectTransform>();
Vector3 localPosition = ((Transform)component2).localPosition;
triggerButton = Object.Instantiate<RectTransform>(component2);
((Object)((Component)triggerButton).gameObject).name = "greyhak-csv-trigger-button";
((Component)triggerButton).GetComponent<UIButton>().tips.tipTitle = "Spreadsheet Generation";
((Component)triggerButton).GetComponent<UIButton>().tips.tipText = "Click to generate resource spreadsheet.";
((Component)triggerButton).GetComponent<UIButton>().tips.delay = 0f;
((Component)((Component)triggerButton).transform.Find("button-1/icon")).GetComponent<Image>().sprite = GetSprite();
((Transform)triggerButton).SetParent((Transform)(object)component);
((Transform)triggerButton).localScale = new Vector3(0.35f, 0.35f, 0.35f);
((Transform)triggerButton).localPosition = new Vector3(localPosition.x + 145f, localPosition.y + 87f, localPosition.z);
((Component)triggerButton).GetComponent<UIButton>().OnPointerDown((PointerEventData)null);
((Component)triggerButton).GetComponent<UIButton>().OnPointerEnter((PointerEventData)null);
ButtonClickedEvent onClick = ((Component)triggerButton).GetComponent<UIButton>().button.onClick;
object obj = <>c.<>9__36_0;
if (obj == null)
{
UnityAction val2 = delegate
{
QueuePlanetLoading();
};
<>c.<>9__36_0 = val2;
obj = (object)val2;
}
((UnityEvent)onClick).AddListener((UnityAction)obj);
progressImage = Object.Instantiate<Image>(GameObject.Find("tech-progress").GetComponent<Image>());
((Object)((Component)progressImage).gameObject).name = "greyhak-cvs-trigger-image";
progressImage.fillAmount = 0f;
progressImage.type = (Type)3;
((Transform)((Graphic)progressImage).rectTransform).SetParent((Transform)(object)component);
((Transform)((Graphic)progressImage).rectTransform).localScale = new Vector3(3f, 3f, 3f);
((Transform)((Graphic)progressImage).rectTransform).localPosition = new Vector3(localPosition.x + 145.5f, localPosition.y + 86.6f, localPosition.z);
Sprite val3 = Resources.Load<Sprite>("UI/Textures/Sprites/round-50px-border");
progressImage.sprite = Object.Instantiate<Sprite>(val3);
Logger.LogInfo((object)"Button load complete");
}
public static Sprite GetSprite()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0120: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(48, 48, (TextureFormat)4, false);
Color val2 = default(Color);
((Color)(ref val2))..ctor(1f, 1f, 1f, 1f);
for (int i = 0; i < 48; i++)
{
for (int j = 0; j < 48; j++)
{
if ((i >= 3 && i <= 44 && j >= 3 && j <= 5) || (i >= 3 && i <= 44 && j >= 33 && j <= 36) || (i >= 3 && i <= 44 && j >= 42 && j <= 44) || (i >= 2 && i <= 5 && j >= 3 && j <= 44) || (i >= 12 && i <= 14 && j >= 3 && j <= 44) || (i >= 27 && i <= 29 && j >= 3 && j <= 44) || (i >= 42 && i <= 45 && j >= 3 && j <= 44))
{
val.SetPixel(i, j, val2);
}
else
{
val.SetPixel(i, j, new Color(0f, 0f, 0f, 0f));
}
}
}
((Object)val).name = "greyhak-cvs-trigger-icon";
val.Apply();
return Sprite.Create(val, new Rect(0f, 0f, 48f, 48f), new Vector2(0f, 0f), 1000f);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlanetModelingManager), "ModelingPlanetMain")]
public static bool PlanetModelingManager_ModelingPlanetMain_Prefix(PlanetData planet)
{
if (PlanetModelingManager.currentModelingPlanet != null && PlanetModelingManager.currentModelingStage == 2 && planet.data == null)
{
Logger.LogInfo((object)("PlanetRawData null for planet " + planet.name));
PlanetModelingManager.currentModelingPlanet.Unload();
PlanetModelingManager.currentModelingPlanet.factoryLoaded = false;
PlanetModelingManager.currentModelingPlanet = null;
PlanetModelingManager.currentModelingStage = 0;
PlanetModelingManager.currentModelingSeamNormal = 0;
return false;
}
return true;
}
}