using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using ABN;
using BepInEx;
using BepInEx.Logging;
using GSSerializer;
using GSSerializer.Internal;
using GSSerializer.Internal.DirectConverters;
using GalacticScale;
using GalacticScale.Generators;
using HarmonyLib;
using NGPT;
using NebulaAPI;
using NebulaAPI.Interfaces;
using NebulaAPI.Networking;
using NebulaAPI.Packets;
using NebulaCompatibility;
using PCGSharp;
using PowerNetworkStructures;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.UI;
using UnityEngine.UI.Extensions;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("GalacticScale")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Galaxy Customization for Dyson Sphere Program")]
[assembly: AssemblyFileVersion("2.77.3.0")]
[assembly: AssemblyInformationalVersion("2.77.3+db03082ab9414b73122c56bf0fed8023699462b9")]
[assembly: AssemblyProduct("GalacticScale")]
[assembly: AssemblyTitle("GalacticScale")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.77.3.0")]
[module: UnverifiableCode]
internal class Program
{
private static void Main()
{
double num = 80.0;
double num2 = 510.0;
int num3 = 1;
int num4 = (int)Math.Ceiling(Math.PI * num2 / (2.0 * num));
Console.WriteLine($"Latitude rings (rCount): {num4}");
num3 += num4;
for (int i = 1; i <= num4; i++)
{
double a = (double)i * Math.PI / (double)num4;
double num5 = num2 * Math.Sin(a);
int num6 = (int)Math.Ceiling(Math.PI * num5 * 2.0 / (2.0 * num));
num3 += num6 - 1;
Console.WriteLine($"Ring {i}: Adding {num6 - 1} generators (radius={num5:F2})");
}
Console.WriteLine($"Total generators needed: {num3}");
}
}
namespace NebulaCompatibility
{
[BepInPlugin("dsp.galactic-scale.2.nebula", "Galactic Scale 2 Nebula Compatibility Plug-In", "1.0.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Ignore_This_Warning_If_Not_Using_Nebula_Multiplayer_Mod : BaseUnityPlugin, IMultiplayerModWithSettings, IMultiplayerMod
{
public static ManualLogSource Logger;
public string Version => GS2.Version;
public void Awake()
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
NebulaModAPI.RegisterPackets(Assembly.GetExecutingAssembly());
BCE.Console.Init();
if (NebulaModAPI.NebulaIsInstalled)
{
NebulaModAPI.OnMultiplayerGameStarted = (Action)Delegate.Combine(NebulaModAPI.OnMultiplayerGameStarted, new Action(NebulaCompat.NebulaStart));
NebulaModAPI.OnMultiplayerGameEnded = (Action)Delegate.Combine(NebulaModAPI.OnMultiplayerGameEnded, new Action(NebulaCompat.NebulaEnd));
}
Logger = new ManualLogSource("GS2DepCheck");
Logger.Sources.Add((ILogSource)(object)Logger);
Logger.Log((LogLevel)8, (object)"Loaded");
}
bool IMultiplayerMod.CheckVersion(string hostVersion, string clientVersion)
{
if (GS2.ActiveGenerator.GUID == "space.customizing.generators.vanilla")
{
GS2.ShowMessage("Cannot Play Multiplayer using the Vanilla Generator", "Warning", Localization.Translate("OK"));
GS2.ShowMessage(GS2.ActiveGenerator.GUID, "Warning", Localization.Translate("OK"));
return false;
}
return hostVersion.Equals(clientVersion);
}
public void Export(BinaryWriter w)
{
string value = GSSettings.Serialize();
w.Write(value);
}
public void Import(BinaryReader r)
{
string json = r.ReadString();
GSSettings.DeSerialize(json);
GS2.ActiveGenerator = GS2.GetGeneratorByID(GSSettings.Instance.generatorGUID);
}
}
public static class NebulaCompat
{
public static bool IsMultiplayerActive;
public static bool IsClient;
public static bool IsMPGameLoaded()
{
return IsMultiplayerActive && NebulaModAPI.MultiplayerSession.IsGameLoaded;
}
public static void NebulaStart()
{
IsMultiplayerActive = NebulaModAPI.IsMultiplayerActive;
IsClient = NebulaModAPI.IsMultiplayerActive && NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient;
GS2.Log($"IsMultiplayerActive:{IsMultiplayerActive} IsClient:{IsClient}", 74);
}
public static void NebulaEnd()
{
IsMultiplayerActive = false;
IsClient = false;
}
public static void SendPacket(LobbyRequestUpdateSolarSystems packet)
{
NebulaModAPI.MultiplayerSession.Network.SendPacket<LobbyRequestUpdateSolarSystems>(packet);
}
}
[RegisterPacketProcessor]
public class LobbyRequestUpdateSolarSystemsProcessor : BasePacketProcessor<LobbyRequestUpdateSolarSystems>
{
public override void ProcessPacket(LobbyRequestUpdateSolarSystems packet, INebulaConnection conn)
{
if (base.IsClient)
{
return;
}
List<string> list = new List<string>();
List<int> list2 = new List<int>();
List<int> list3 = new List<int>();
if (GameMain.galaxy != null)
{
StarData[] stars = GameMain.galaxy.stars;
foreach (StarData val in stars)
{
if (!string.IsNullOrEmpty(val.overrideName))
{
list.Add(val.overrideName);
list2.Add(val.id);
list3.Add(-2);
}
PlanetData[] planets = val.planets;
foreach (PlanetData val2 in planets)
{
if (!string.IsNullOrEmpty(val2.overrideName))
{
list.Add(val2.overrideName);
list2.Add(-1);
list3.Add(val2.id);
}
}
}
}
using MemoryStream memoryStream = new MemoryStream();
using BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
string value = GSSettings.Serialize();
binaryWriter.Write(value);
binaryWriter.Close();
byte[] gssettings = memoryStream.ToArray();
conn.SendPacket<LobbyResponseUpdateSolarSystems>(new LobbyResponseUpdateSolarSystems(gssettings, list.ToArray(), list2.ToArray(), list3.ToArray()));
}
}
[RegisterPacketProcessor]
public class LobbyResponseUpdateSolarSystemsProcessor : BasePacketProcessor<LobbyResponseUpdateSolarSystems>
{
public override void ProcessPacket(LobbyResponseUpdateSolarSystems packet, INebulaConnection conn)
{
if (base.IsHost)
{
return;
}
GameDesc gameDesc = UIRoot.instance.galaxySelect.gameDesc;
GalaxyData galaxyData = UIRoot.instance.galaxySelect.starmap.galaxyData;
if (galaxyData == null)
{
galaxyData = (GS2.Vanilla ? UniverseGen.CreateGalaxy(gameDesc) : GS2.ProcessGalaxy(gameDesc, sketchOnly: true));
UIRoot.instance.galaxySelect.starmap.galaxyData = galaxyData;
}
using (MemoryStream input = new MemoryStream(packet.GSSettings))
{
using BinaryReader binaryReader = new BinaryReader(input);
GSSettings.FromString(binaryReader.ReadString());
}
GSSettings.lobbyReceivedUpdateValues = true;
UIRoot.instance.galaxySelect.SetStarmapGalaxy();
galaxyData = UIRoot.instance.galaxySelect.starmap.galaxyData;
for (int i = 0; i < packet.Names.Length; i++)
{
GS2.Warn($"{packet.Names[i]} {packet.StarIds[i]} {packet.PlanetIds[i]}", 40);
if (packet.StarIds[i] != -1)
{
StarData val = galaxyData.StarById(packet.StarIds[i]);
val.overrideName = packet.Names[i];
}
else
{
PlanetData val2 = galaxyData.PlanetById(packet.PlanetIds[i]);
val2.overrideName = packet.Names[i];
GameMain.gameScenario.NotifyOnPlanetNameChange();
}
}
UIRoot.instance.galaxySelect.starmap.OnGalaxyDataReset();
}
}
}
namespace GalacticScale
{
public static class GS2
{
private class exceptionOutput
{
public string exception;
public string generator;
public string version;
public exceptionOutput(string e)
{
version = Version;
exception = e;
generator = ActiveGenerator?.Name;
}
}
private class ErrorObject
{
public readonly List<string> stack = new List<string>();
public string message;
public string version = Version;
}
public class GSPreferences
{
public readonly Dictionary<string, GSGenPreferences> GeneratorPreferences = new Dictionary<string, GSGenPreferences>();
public readonly Dictionary<string, GSGenPreferences> PluginPreferences = new Dictionary<string, GSGenPreferences>();
public GSGenPreferences MainSettings = new GSGenPreferences();
public int version;
public static bool WriteToDisk(GSPreferences preferences)
{
fsSerializer fsSerializer = new fsSerializer();
fsData data;
fsResult fsResult = fsSerializer.TrySerialize(Preferences, out data);
if (fsResult.Failed)
{
Error(fsResult.FormattedMessages, 113);
return false;
}
string contents = fsJsonPrinter.PrettyJson(data);
if (!Directory.Exists(DataDir))
{
Directory.CreateDirectory(DataDir);
}
if (!Directory.Exists(DataDir))
{
return false;
}
try
{
File.WriteAllText(Path.Combine(DataDir, "Preferences.json"), contents);
}
catch (Exception ex)
{
Error(ex.Message, 126);
return false;
}
return true;
}
public static GSPreferences ReadFromDisk()
{
string text = Path.Combine(DataDir, "Preferences.json");
if (!CheckJsonFileExists(text))
{
Warn("Cannot find Preferences.json. Creating", 139);
GSPreferences gSPreferences = new GSPreferences();
WriteToDisk(gSPreferences);
return gSPreferences;
}
Log("Loading Preferences from " + text, 146);
fsSerializer fsSerializer = new fsSerializer();
string input = File.ReadAllText(text);
GSPreferences instance = new GSPreferences();
fsData data = fsJsonParser.Parse(input);
fsResult fsResult = fsSerializer.TryDeserialize(data, ref instance);
if (fsResult.Failed)
{
Error("Failed to Deserialize Preferences.json", 154);
Warn(fsResult.FormattedMessages, 155);
return new GSPreferences();
}
return instance;
}
public void Save(iConfigurableGenerator generator)
{
GSGenPreferences value = generator.Export();
GeneratorPreferences[generator.GUID] = value;
}
public GSGenPreferences Load(iConfigurableGenerator generator, bool fromFile = false)
{
if (!fromFile)
{
if (GeneratorPreferences.ContainsKey(generator.GUID))
{
return GeneratorPreferences[generator.GUID];
}
Warn("Generator Preferences do not exist, creating new", 185);
return new GSGenPreferences();
}
GSPreferences gSPreferences = ReadFromDisk();
if (gSPreferences.GeneratorPreferences.ContainsKey(generator.GUID))
{
return gSPreferences.GeneratorPreferences[generator.GUID];
}
Warn("Generator Preferences do not exist, creating new", 191);
return new GSGenPreferences();
}
}
public enum Alignment
{
Left,
Right,
Center
}
public static class ExternalThemeProcessor
{
public static void LoadEnabledThemes()
{
externalThemes = new ThemeLibrary();
foreach (string externalThemeName in Config.ExternalThemeNames)
{
string[] array = externalThemeName.Split(new char[1] { '|' });
string text = array[0];
string text2 = array[1];
if (availableExternalThemes.ContainsKey(text) && availableExternalThemes[text].ContainsKey(text2))
{
externalThemes.Add(text2, availableExternalThemes[text][text2]);
Log("Added " + externalThemeName, 23);
}
else
{
Warn("Missing Theme " + text + " - " + text2, 28);
}
}
}
}
public class Random : Pcg
{
private int count;
private int seed = 1;
public int Seed
{
get
{
return seed;
}
set
{
seed = value;
reseed(value);
}
}
public string Id => $"[{seed}=>{count}]";
public Random(int seed)
: base(seed)
{
Seed = seed;
}
public static Random getNewInstance()
{
return new Random(increment++);
}
public bool NextPick(double chance)
{
return NextDouble() < chance;
}
public override uint NextUInt()
{
count++;
return base.NextUInt();
}
public float Normal(float averageValue, float standardDeviation)
{
return averageValue + standardDeviation * (float)(Math.Sqrt(-2.0 * Math.Log(1.0 - NextDouble())) * Math.Sin(Math.PI * 2.0 * NextDouble()));
}
public new float NextFloat(float min, float max)
{
if (Math.Abs(min - max) < float.MinValue)
{
return min;
}
if (min > max)
{
Warn($"{GetCaller()}-NextFloat: Min > Max. {min} {max}", 63);
return max;
}
return base.NextFloat(min, max);
}
public new int Next(int minInclusive, int maxExclusive)
{
if (minInclusive == maxExclusive)
{
return minInclusive;
}
if (minInclusive > maxExclusive)
{
Error($"Next: Min > Max. {minInclusive} {maxExclusive}", 78);
return maxExclusive - 1;
}
if (maxExclusive <= 0)
{
Error($"Max {maxExclusive} <= 0 {GetCaller()}", 84);
return maxExclusive;
}
return base.Next(minInclusive, maxExclusive);
}
public int NextInclusive(int minInclusive, int maxInclusive)
{
if (minInclusive == maxInclusive)
{
return minInclusive;
}
if (minInclusive > maxInclusive)
{
Error($"Next: Min > Max. {minInclusive} {maxInclusive}", 97);
return maxInclusive;
}
return base.Next(minInclusive, maxInclusive + 1);
}
public float ClampedNormal(float min, float max, int bias)
{
float num = max - min;
float num2 = (float)bias / 100f * num + min;
float val = (max - num2) / 3f;
float val2 = (num2 - min) / 3f;
float standardDeviation = Math.Max(val2, val);
float num3 = Normal(num2, standardDeviation);
return Mathf.Clamp(num3, min, max);
}
public VectorLF3 PointOnSphere(double radius)
{
//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_0095: Unknown result type (might be due to invalid IL or missing references)
double num = NextDouble() * 2.0 * radius - radius;
double num2 = NextDouble() * Math.PI * 2.0;
double num3 = Math.Sqrt(Math.Pow(radius, 2.0) - Math.Pow(num, 2.0)) * Math.Cos(num2);
double num4 = Math.Sqrt(Math.Pow(radius, 2.0) - Math.Pow(num, 2.0)) * Math.Sin(num2);
return new VectorLF3(num3, num4, num);
}
public T Item<T>(List<T> items)
{
if (items.Count == 0)
{
Error("Item Length 0 " + GetCaller(), 128);
}
return items[Next(items.Count)];
}
public (int, T) ItemWithIndex<T>(List<T> items)
{
if (items.Count == 0)
{
Error("Item Length 0 " + GetCaller(), 137);
}
int num = Next(items.Count);
return (num, items[num]);
}
public T ItemAndRemove<T>(List<T> items)
{
if (items.Count == 0)
{
Error("Item Length 0 " + GetCaller(), 147);
}
int index = Next(items.Count);
T result = items[index];
items.RemoveAt(index);
return result;
}
public T Item<T>(T[] items)
{
if (items.Length == 0)
{
Error("Item Length 0 " + GetCaller(), 158);
}
return items[Next(items.Length)];
}
public (int, T) ItemWithIndex<T>(T[] items)
{
if (items.Length == 0)
{
Error("Item Length 0 " + GetCaller(), 167);
}
int num = Next(items.Length);
return (num, items[num]);
}
public KeyValuePair<W, X> Item<W, X>(Dictionary<W, X> items)
{
if (items.Count == 0)
{
Error("Item Length 0 " + GetCaller(), 177);
}
W[] array = new W[0];
items.Keys.CopyTo(array, 0);
W key = array[Next(array.Length)];
return new KeyValuePair<W, X>(key, items[key]);
}
}
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__48_0;
public static UnityAction <>9__48_1;
public static Func<KeyValuePair<string, GSTheme>, GSTheme> <>9__49_0;
public static Response <>9__116_0;
internal void <UpdateNebulaSettings>b__48_0()
{
ShowMessage("Cannot Host a GS2 Game using Vanilla Generator", "Warning", Localization.Translate("OK"));
}
internal void <UpdateNebulaSettings>b__48_1()
{
ShowMessage("Cannot Host a GS2 Game using Vanilla Generator", "Warning", Localization.Translate("OK"));
}
internal GSTheme <Init>b__49_0(KeyValuePair<string, GSTheme> t)
{
return t.Value;
}
internal void <AbortGameStart>b__116_0()
{
UIRoot.instance.OpenMainMenuUI();
UIRoot.ClearFatalError();
}
}
public static int PreferencesVersion = 2104;
private static iGenerator _activeGenerator = new Vanilla();
public static List<iGenerator> Generators = new List<iGenerator>
{
new GS2Generator3(),
new GS2Generator2(),
new Sol()
};
public static string Version;
private static readonly string AssemblyPath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(GS2)).Location);
private static readonly string OldDataDir = Path.Combine(AssemblyPath, "config");
public static readonly string DataDir = Path.Combine(Paths.ConfigPath, "GalacticScale2");
public static bool Failed = false;
public static string updateMessage = "";
public static bool ModellingDone = true;
public static Dictionary<string, ThemeLibrary> availableExternalThemes = new Dictionary<string, ThemeLibrary>();
public static bool canvasOverlay = false;
public static Image splashImage;
public static bool SaveOrLoadWindowOpen = false;
public static bool Initialized = false;
public static bool MenuHasLoaded;
public static int increment = 0;
public static DebugTool debugtool;
public static bool ResearchUnlocked = false;
public static List<Sprite> SplashSprites = new List<Sprite>();
public static TeleportComponent TP;
public static InputComponent InputComponent;
public static TerrainAlgorithmLibrary TerrainAlgorithmLibrary = TerrainAlgorithmLibrary.Init();
public static VeinAlgorithmLibrary VeinAlgorithmLibrary = VeinAlgorithmLibrary.Init();
public static VegeAlgorithmLibrary VegeAlgorithmLibrary = VegeAlgorithmLibrary.Init();
public static GS2MainSettings Config = new GS2MainSettings();
public static GalaxyData galaxy;
public static GameDesc gameDesc;
public static Dictionary<int, GSPlanet> gsPlanets = new Dictionary<int, GSPlanet>();
public static Dictionary<int, GSStar> gsStars = new Dictionary<int, GSStar>();
private static AssetBundle bundle;
private static ButtonClickedEvent origHost;
private static ButtonClickedEvent origLoad;
public static List<iConfigurablePlugin> Plugins = new List<iConfigurablePlugin>();
public static GSPreferences Preferences = new GSPreferences();
public static ThemeLibrary externalThemes = new ThemeLibrary();
public static Dictionary<int, int[]> keyedLUTs = new Dictionary<int, int[]>();
public static iGenerator ActiveGenerator
{
get
{
return _activeGenerator;
}
set
{
_activeGenerator = value;
}
}
public static bool IsMenuDemo => DSPGame.IsMenuDemo || !Initialized;
public static bool Vanilla => ActiveGenerator.GUID == "space.customizing.generators.vanilla";
public static AssetBundle Bundle
{
get
{
if ((Object)(object)bundle == (Object)null)
{
string text = Path.Combine(AssemblyPath, "galacticbundle");
string text2 = Path.Combine(AssemblyPath, "galactic.bundle");
if (File.Exists(text))
{
bundle = AssetBundle.LoadFromFile(text);
}
else
{
bundle = AssetBundle.LoadFromFile(text2);
}
}
if ((Object)(object)bundle == (Object)null)
{
Error(Localization.Translate("Failed to load AssetBundle!"), 69);
UIMessageBox.Show("Error", Localization.Translate("Asset Bundle not found. \r\nPlease ensure your directory structure is correct.\r\n Installation instructions can be found at https://centrebra.in/release. \r\nAn error log has been generated in the plugin/ErrorLog Directory"), Localization.Translate("Return"), 0);
return null;
}
return bundle;
}
}
private static bool DebugOn => Config?.DebugMode ?? true;
public static void CreateStarPlanetsAstroPoses(Random random)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: 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_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_0312: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_0335: Unknown result type (might be due to invalid IL or missing references)
//IL_0336: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_033d: Unknown result type (might be due to invalid IL or missing references)
//IL_033f: Unknown result type (might be due to invalid IL or missing references)
HighStopwatch val = new HighStopwatch();
val.Begin();
int num = galaxy.starCount * 1000;
galaxy.astrosData = (AstroData[])(object)new AstroData[num];
galaxy.astrosFactory = (PlanetFactory[])(object)new PlanetFactory[num];
Log("Creating Stars", 14);
for (int i = 0; i < GSSettings.StarCount; i++)
{
galaxy.stars[i] = CreateStar(i, random);
}
if (!GSSettings.Instance.imported)
{
foreach (GSStar star in GSSettings.Stars)
{
if (star.BinaryCompanion != null)
{
GSStar gSStar = GetGSStar(star.BinaryCompanion);
if (gSStar == null)
{
Error("Could not find Binary Companion:" + star.BinaryCompanion, 30);
continue;
}
StarData obj = galaxy.stars[gSStar.assignedIndex];
VectorLF3 position = (gSStar.position = star.position + gSStar.position);
obj.position = position;
galaxy.stars[gSStar.assignedIndex].uPosition = galaxy.stars[gSStar.assignedIndex].position * 2400000.0;
}
}
}
Log($"Stars Created in {val.duration:F5}s", 46);
val.Begin();
Log("Creating Planets", 48);
for (int j = 0; j < GSSettings.StarCount; j++)
{
CreateStarPlanets(ref galaxy.stars[j], gameDesc, random);
}
Log($"Planets Created in {val.duration:F5}s", 52);
val.Begin();
Log("Planets have been created", 54);
galaxy.starCount = galaxy.stars.Length;
AstroData[] astrosData = galaxy.astrosData;
for (int k = 0; k < galaxy.astrosData.Length; k++)
{
astrosData[k].uRot.w = 1f;
astrosData[k].uRotNext.w = 1f;
}
Log($"Astroposes Reset in {val.duration:F5}s", 63);
val.Begin();
for (int l = 0; l < GSSettings.StarCount; l++)
{
int astroId = galaxy.stars[l].astroId;
astrosData[astroId].id = astroId;
astrosData[astroId].type = (EAstroType)1;
astrosData[astroId].uPos = (astrosData[astroId].uPosNext = galaxy.stars[l].uPosition);
astrosData[astroId].uRot = (astrosData[astroId].uRotNext = Quaternion.identity);
astrosData[astroId].uRadius = galaxy.stars[l].physicsRadius;
}
Log($"Astroposes filled in {val.duration:F5}s", 83);
val.Begin();
for (int m = 0; m < galaxy.stars.Length; m++)
{
if (galaxy.stars[m] == null)
{
Error($"GalaxyStars[{m}] null", 92);
}
galaxy.stars[m].planetCount = galaxy.stars[m].planets.Length;
for (int n = 0; n < galaxy.stars[m].planets.Length; n++)
{
if (galaxy.stars[m].planets[n] == null)
{
Error($"GalaxyStars[{m}].planets[{n}] null", 95);
}
else
{
galaxy.stars[m].planets[n].UpdateRuntimePose(0.0);
}
}
}
Log($"Astroposes Initialized in {val.duration:F5}s", 100);
val.Begin();
Log("End", 102);
}
public static GalaxyData ProcessGalaxy(GameDesc desc, bool sketchOnly = false)
{
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Expected O, but got Unknown
//IL_0409: Unknown result type (might be due to invalid IL or missing references)
//IL_0410: Unknown result type (might be due to invalid IL or missing references)
//IL_0415: Unknown result type (might be due to invalid IL or missing references)
//IL_041a: Unknown result type (might be due to invalid IL or missing references)
Log($"Start ProcessGalaxy:{sketchOnly} StarCount:{gameDesc.starCount} Seed:{gameDesc.galaxySeed} Called By{GetCaller()}. Galaxy StarCount : {galaxy?.stars?.Length}", 11);
Random random = new Random(GSSettings.Seed);
try
{
if (Config.ForceRare)
{
GSSettings.GalaxyParams.forceSpecials = true;
}
HighStopwatch val = new HighStopwatch();
val.Begin();
gameDesc = desc;
Log($"Generating Galaxy of {GSSettings.StarCount}|{gameDesc.starCount} stars", 19);
Failed = false;
GameObject startButton = PatchOnUIGalaxySelect.StartButton;
if (startButton != null)
{
startButton.SetActive(true);
}
if (!GSSettings.Instance.imported && sketchOnly)
{
GSSettings.Reset(gameDesc.galaxySeed);
if (((ProtoSet<ThemeProto>)(object)LDB._themes).dataArray != null && ((ProtoSet<ThemeProto>)(object)LDB._themes).dataArray.Length > 128)
{
Array.Resize(ref ((ProtoSet<ThemeProto>)(object)LDB._themes).dataArray, 128);
}
Log("Seed From gameDesc = " + GSSettings.Seed, 33);
gsPlanets.Clear();
gsStars.Clear();
Warn("Loading Data from Generator : " + ActiveGenerator.Name, 38);
ActiveGenerator.Generate(gameDesc.starCount);
GSSettings.Instance.galaxyParams.resourceMulti = gameDesc.resourceMultiplier;
GSSettings.Instance.generatorGUID = ActiveGenerator.GUID;
}
else
{
Log($"Settings Loaded From Save File {GSSettings.BirthPlanet.Name} {GSSettings.Instance.stars.Count} {GSSettings.StarCount}", 49);
gameDesc.resourceMultiplier = GSSettings.Instance.galaxyParams.resourceMulti;
}
LogJson(gameDesc.combatSettings);
Log($"Galaxy Loaded: {val.duration:F5}", 55);
val.Begin();
gameDesc.starCount = GSSettings.StarCount;
int num = StarPositions.GenerateTempPoses(random.Next(), GSSettings.StarCount, GSSettings.GalaxyParams.iterations, GSSettings.GalaxyParams.minDistance, GSSettings.GalaxyParams.minStepLength, GSSettings.GalaxyParams.maxStepLength, GSSettings.GalaxyParams.flatten);
val.Begin();
galaxy = new GalaxyData();
galaxy.seed = GSSettings.Seed;
galaxy.starCount = GSSettings.StarCount;
galaxy.stars = (StarData[])(object)new StarData[GSSettings.StarCount];
if (GSSettings.StarCount <= 0)
{
Log("StarCount <= 0, returning galaxy", 70);
return galaxy;
}
CreateStarPlanetsAstroPoses(random);
StarData val2 = galaxy.stars[galaxy.birthStarId - 1];
Log($"Astroposes Initialized: {val.duration:F5}", 78);
val.Begin();
Warn($"Setting up birthPlanet {GSSettings.BirthPlanetId}", 83);
galaxy.birthPlanetId = GSSettings.BirthPlanetId;
galaxy.birthStarId = GSSettings.BirthStarId;
StarData val3 = galaxy.StarById(galaxy.birthStarId);
AssignStarLevels(GSSettings.BirthStar);
for (int i = 0; i < galaxy.starCount; i++)
{
if (galaxy.starCount <= 1)
{
break;
}
StarData val4 = galaxy.stars[i];
VectorLF3 val5 = val4.position - val3.position;
float num2 = (float)((VectorLF3)(ref val5)).magnitude / 32f;
if ((double)num2 > 1.0)
{
num2 = Mathf.Log(Mathf.Log(Mathf.Log(Mathf.Log(Mathf.Log(num2) + 1f) + 1f) + 1f) + 1f) + 1f;
}
float resourceCoef = Mathf.Pow(7f, num2) * 0.6f;
val4.resourceCoef = resourceCoef;
}
Log($"Resource Coefficients Set: {val.duration:F5}", 102);
val.Begin();
UniverseGen.CreateGalaxyStarGraph(galaxy);
Log($"Stargraph Generated: {val.duration:F5}", 106);
val.Begin();
Log($"Galaxy Created. birthStarid:{galaxy.birthStarId}", 110);
Log($"birthPlanetId:{galaxy.birthPlanetId}", 111);
Log("birthPlanet:" + galaxy.PlanetById(galaxy.birthPlanetId).name, 112);
Log($"birthStarName: {galaxy.stars[galaxy.birthStarId - 1].name} Radius:{galaxy.PlanetById(galaxy.birthPlanetId).radius} Scale:{galaxy.PlanetById(galaxy.birthPlanetId).scale}", 113);
if (Config.Dev)
{
DumpObjectToJson(Path.Combine(DataDir, "ldbthemesPost.json"), ((ProtoSet<ThemeProto>)(object)LDB._themes).dataArray);
}
Log("Galaxy Generated", 115);
Log($"{val2.name} - {val2.initialHiveCount}/{val2.maxHiveCount}", 116);
if (GSSettings.Instance.Preferences == null)
{
GSSettings.Instance.Preferences = Preferences;
}
return galaxy;
}
catch (Exception ex)
{
GameObject.Find("UI Root/Overlay Canvas/Galaxy Select/start-button").gameObject.SetActive(false);
Log(ex.ToString(), 123);
Log(GetCaller(), 124);
Log(GetCaller(1), 125);
UIMessageBox.Show("Error", "There has been a problem creating the galaxy. \nPlease let the Galactic Scale team know in our discord server. An error log has been generated in the plugin/ErrorLog Directory", "Return", 0);
UIRoot.instance.OnGameLoadFailed();
return null;
}
}
public static void AssignStarLevels(GSStar birthStar)
{
//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)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
birthStar.level = 0f;
float num = 0f;
VectorLF3 position;
foreach (GSStar star in GSSettings.Stars)
{
position = star.position;
float num2 = (float)((VectorLF3)(ref position)).magnitude;
position = birthStar.position;
float num3 = num2 - (float)((VectorLF3)(ref position)).magnitude;
if (num3 > num)
{
num = num3;
}
}
foreach (GSStar star2 in GSSettings.Stars)
{
position = star2.position;
float num4 = (float)((VectorLF3)(ref position)).magnitude;
position = birthStar.position;
float num5 = num4 - (float)((VectorLF3)(ref position)).magnitude;
star2.level = num5 / num;
}
}
public static void GenerateVeins(bool SketchOnly)
{
for (int i = 1; i < galaxy.starCount; i++)
{
StarData val = galaxy.stars[i];
for (int j = 0; j < val.planetCount; j++)
{
PlanetModelingManager.Algorithm(val.planets[j]).GenerateVeins();
}
}
}
public static iGenerator GetGeneratorByID(string guid)
{
foreach (iGenerator generator in Generators)
{
if (generator.GUID == guid)
{
return generator;
}
}
return GetGeneratorByID("space.customizing.generators.gs2dev");
}
public static int GetCurrentGeneratorIndex()
{
for (int i = 0; i < Generators.Count; i++)
{
if (Generators[i] == ActiveGenerator)
{
return i;
}
}
return -1;
}
public static void UpdateNebulaSettings()
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//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_00d6: Expected O, but got Unknown
GameObject val = GameObject.Find("UI Root/Overlay Canvas/Main Menu/multiplayer-menu/button-multiplayer/");
GameObject val2 = GameObject.Find("UI Root/Overlay Canvas/Main Menu/multiplayer-menu/button-new/");
if (!((Object)(object)val != (Object)null))
{
return;
}
if (ActiveGenerator.GUID == "space.customizing.generators.vanilla")
{
Button component = val.GetComponent<Button>();
Button component2 = val2.GetComponent<Button>();
origHost = component.onClick;
origLoad = component2.onClick;
component.onClick = new ButtonClickedEvent();
component2.onClick = new ButtonClickedEvent();
ButtonClickedEvent onClick = component.onClick;
object obj = <>c.<>9__48_0;
if (obj == null)
{
UnityAction val3 = delegate
{
ShowMessage("Cannot Host a GS2 Game using Vanilla Generator", "Warning", Localization.Translate("OK"));
};
<>c.<>9__48_0 = val3;
obj = (object)val3;
}
((UnityEvent)onClick).AddListener((UnityAction)obj);
ButtonClickedEvent onClick2 = component2.onClick;
object obj2 = <>c.<>9__48_1;
if (obj2 == null)
{
UnityAction val4 = delegate
{
ShowMessage("Cannot Host a GS2 Game using Vanilla Generator", "Warning", Localization.Translate("OK"));
};
<>c.<>9__48_1 = val4;
obj2 = (object)val4;
}
((UnityEvent)onClick2).AddListener((UnityAction)obj2);
}
else
{
Button component3 = val.GetComponent<Button>();
Button component4 = val2.GetComponent<Button>();
if (origHost != null)
{
component3.onClick = origHost;
}
if (origLoad != null)
{
component4.onClick = origLoad;
}
}
}
public static void Init()
{
Config.Preferences.Set("Debug Log", true);
if (File.Exists(Path.Combine(AssemblyPath, "icon.png")))
{
if (ActiveGenerator != null && ActiveGenerator.GUID == "space.customizing.generators.vanilla")
{
updateMessage += Localization.Translate("BACKUP YOUR SAVES. This version has potentially BREAKING CHANGES.\r\nNote: Settings for this mod are in the settings menu. Make sure to change the Generator to get the full Galactic Scale experience.\r\n");
}
updateMessage += Localization.Translate("Update Detected. Please do not save over existing saves \r\nuntil you are sure you can load saves saved with this version!\r\nPlease Click GS2 Help and click the link to join our community on discord for preview builds and to help shape the mod going forward");
File.Delete(Path.Combine(AssemblyPath, "icon.png"));
updateMessage += Localization.Translate("The latest DSP update has added additional planet themes which are yet to be included in GS2. \r\nI'm working on getting them added to the GS2 themeset, as well as implementing their new subtheme system");
}
if (Directory.Exists(OldDataDir) && !Directory.Exists(DataDir))
{
Warn("Moving Configs from " + OldDataDir + " to " + DataDir, 126);
Directory.Move(OldDataDir, DataDir);
updateMessage += Localization.Translate("Galactic Scale config Directory has changed to \r\n ...\\BepInEx\\config\\GalacticScale \r\nThis is to prevent data being lost when updating using the mod manager.\r\n");
}
if (!Directory.Exists(DataDir))
{
Directory.CreateDirectory(DataDir);
}
if (Directory.Exists(Path.Combine(DataDir, "Splash")))
{
Utils.LoadSplashImagesFromDirectory();
}
CleanErrorLogs();
LoadShaders();
Config.Init();
LoadPreferences(debug: true);
ActiveGenerator = GetGeneratorByID(Config.GeneratorID);
List<GSTheme> list = GSSettings.ThemeLibrary.Select((KeyValuePair<string, GSTheme> t) => t.Value).ToList();
foreach (GSTheme item in list)
{
item.Process();
}
LoadGenerators();
LoadPreferences();
}
public static void ShowMessage(string message, string title = "Galactic Scale", string button = "OK")
{
UIMessageBox.Show(Localization.Translate(title), Localization.Translate(message), Localization.Translate(button), 0);
}
public static void OnMenuLoaded()
{
if (MenuHasLoaded)
{
return;
}
MenuHasLoaded = true;
LoadExternalThemes(Path.Combine(DataDir, "CustomThemes"));
ExternalThemeProcessor.LoadEnabledThemes();
Config.InitThemePanel();
if (Config.Dev)
{
DumpObjectToJson(Path.Combine(DataDir, "ldbthemes.json"), ((ProtoSet<ThemeProto>)(object)LDB._themes).dataArray);
}
((ProtoSet<ThemeProto>)(object)LDB._themes).Select(1);
if (Config.Dev)
{
Utils.DumpProtosToCSharp();
}
if (Config.Dev)
{
VegeProto[] dataArray = ((ProtoSet<VegeProto>)(object)LDB._veges).dataArray;
Dictionary<int, string> dictionary = new Dictionary<int, string>();
VegeProto[] array = dataArray;
foreach (VegeProto val in array)
{
string name = ((Proto)val).Name;
string name2 = ((Proto)val).name;
int iD = ((Proto)val).ID;
dictionary.Add(iD, Localization.Translate(name) + " " + Localization.Translate(name2));
}
DumpObjectToJson(Path.Combine(DataDir, "ldbvege.json"), dictionary);
}
if (updateMessage != "")
{
UIMessageBox.Show("Update Information", updateMessage, "Noted!", 0);
updateMessage = "";
}
UpdateNebulaSettings();
Utils.InitMk2MinerEffectVertices();
}
public static void LoadShaders()
{
string text = "assets/planet_atfield_shape.shader";
Shader val = Bundle.LoadAsset<Shader>(text);
if ((Object)(object)val == (Object)null)
{
Error(text + " not found", 218);
}
else
{
Utils.AddSwapShaderMapping("Unlit/Planet ATField Shape", val);
}
}
public static void LoadExternalThemes(string path)
{
ThemeLibrary themeLibrary = new ThemeLibrary();
availableExternalThemes.Clear();
if (!Directory.Exists(path))
{
Warn("External Theme Directory Not Found. Creating", 17);
Directory.CreateDirectory(path);
return;
}
string[] files = Directory.GetFiles(path);
string[] directories = Directory.GetDirectories(path);
if (files.Length == 0 && directories.Length == 0)
{
return;
}
string[] array = directories;
foreach (string path2 in array)
{
string name = new DirectoryInfo(path2).Name;
if (availableExternalThemes.ContainsKey(name))
{
availableExternalThemes[name] = LoadDirectoryJsonThemes(path2);
}
else
{
availableExternalThemes.Add(name, LoadDirectoryJsonThemes(path2));
}
}
string[] array2 = files;
foreach (string text in array2)
{
if (new FileInfo(text).Extension != ".json")
{
continue;
}
GSTheme gSTheme = LoadJsonTheme(text);
if (gSTheme != null)
{
if (themeLibrary.ContainsKey(gSTheme.Name))
{
themeLibrary[gSTheme.Name] = gSTheme;
}
else
{
themeLibrary.Add(gSTheme.Name, gSTheme);
}
}
}
if (availableExternalThemes.ContainsKey("Root"))
{
availableExternalThemes["Root"] = themeLibrary;
}
else
{
availableExternalThemes.Add("Root", themeLibrary);
}
}
public static ThemeLibrary LoadDirectoryJsonThemes(string path)
{
ThemeLibrary themeLibrary = new ThemeLibrary();
string[] directories = Directory.GetDirectories(path);
string[] files = Directory.GetFiles(path);
string[] array = directories;
foreach (string path2 in array)
{
ThemeLibrary values = LoadDirectoryJsonThemes(path2);
themeLibrary.AddRange(values);
}
string[] array2 = files;
foreach (string filename in array2)
{
GSTheme gSTheme = LoadJsonTheme(filename);
if (gSTheme != null)
{
themeLibrary.Add(gSTheme.Name, gSTheme);
}
}
return themeLibrary;
}
public static GSTheme LoadJsonTheme(string filename)
{
if (new FileInfo(filename).Extension != ".json")
{
return null;
}
string input = File.ReadAllText(filename);
GSTheme instance = new GSTheme();
fsData data;
fsResult fsResult = fsJsonParser.Parse(input, out data);
if (fsResult.Failed)
{
Error("Loading of Json Theme " + filename + " failed. " + fsResult.FormattedMessages, 85);
return null;
}
fsSerializer fsSerializer = new fsSerializer();
fsResult fsResult2 = fsSerializer.TryDeserialize(data, ref instance);
if (fsResult2.Failed)
{
Error("Failed to deserialize " + filename + ": " + fsResult2.FormattedMessages, 94);
return null;
}
return instance;
}
public static bool LoadSettingsFromJson(string path)
{
Log("Start", 103);
if (!CheckJsonFileExists(path))
{
return false;
}
Log("Path = " + path, 106);
fsSerializer fsSerializer = new fsSerializer();
GSSettings.Stars.Clear();
Log("Initializing ThemeLibrary", 109);
GSSettings.ThemeLibrary = ThemeLibrary.Vanilla();
GSSettings.GalaxyParams = new GSGalaxyParams();
Log("Reading JSON", 112);
string input = File.ReadAllText(path);
GSSettings instance = GSSettings.Instance;
Log("Parsing JSON", 115);
fsData data = fsJsonParser.Parse(input);
Log("Trying To Deserialize JSON", 117);
fsSerializer.TryDeserialize(data, ref instance);
LogJson(instance.galaxyParams);
Log("End", 120);
return true;
}
public static void SaveSettingsToJson(string path)
{
fsSerializer fsSerializer = new fsSerializer();
fsSerializer.TrySerialize(GSSettings.Instance, out var data).AssertSuccessWithoutWarnings();
string contents = fsJsonPrinter.PrettyJson(data);
File.WriteAllText(path, contents);
}
public static void DumpObjectToJson(string path, object obj)
{
fsSerializer fsSerializer = new fsSerializer();
fsSerializer.TrySerialize(obj, out var data).AssertSuccessWithoutWarnings();
string contents = fsJsonPrinter.PrettyJson(data);
File.WriteAllText(path, contents);
}
public static void DumpException(Exception e)
{
Error(e.Message + " " + GetCaller(1) + " " + GetCaller(2) + " " + GetCaller(3) + " " + GetCaller(4) + " " + GetCaller(5), 146);
string text = Path.Combine(AssemblyPath, "ErrorLog");
if (!Directory.Exists(text))
{
Directory.CreateDirectory(text);
}
text = Path.Combine(text, DateTime.Now.ToString("yyMMddHHmmss"));
text += ".exceptionlog.json";
if (!File.Exists(text))
{
Log(text, 154);
Log("Logging Error to " + text, 155);
exceptionOutput instance = new exceptionOutput(e.ToString());
fsSerializer fsSerializer = new fsSerializer();
fsSerializer.TrySerialize(instance, out var data).AssertSuccessWithoutWarnings();
string contents = fsJsonPrinter.PrettyJson(data);
File.WriteAllText(text, contents);
Log("End", 161);
}
}
public static void DumpError(string message)
{
string text = Path.Combine(AssemblyPath, "ErrorLog");
if (!Directory.Exists(text))
{
Directory.CreateDirectory(text);
}
text = Path.Combine(text, DateTime.Now.ToString("yyMMddHHmmss"));
text += ".errorlog.json";
Log(text, 170);
Log("Logging Error to " + text, 171);
ErrorObject errorObject = new ErrorObject();
errorObject.message = message;
for (int i = 0; i < 100; i++)
{
string caller = GetCaller(i);
if (caller != "")
{
errorObject.stack.Add(caller);
}
}
fsSerializer fsSerializer = new fsSerializer();
fsSerializer.TrySerialize(errorObject, out var data).AssertSuccessWithoutWarnings();
string contents = fsJsonPrinter.PrettyJson(data);
File.AppendAllText(text, contents);
Log("End", 184);
}
private static void CleanErrorLogs()
{
string path = Path.Combine(AssemblyPath, "ErrorLog");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
string[] files = Directory.GetFiles(path, "*.json");
string[] array = files;
foreach (string fileName in array)
{
FileInfo fileInfo = new FileInfo(fileName);
if (fileInfo.LastAccessTime < DateTime.Now.AddDays(-7.0))
{
fileInfo.Delete();
}
}
}
private static bool CheckJsonFileExists(string path)
{
if (File.Exists(path))
{
return true;
}
Log("Json file does not exist at " + path, 206);
return false;
}
public static void LoadPlugins()
{
Log("Start", 14);
if (!Directory.Exists(Path.Combine(DataDir, "Plugins")))
{
Directory.CreateDirectory(Path.Combine(DataDir, "Plugins"));
}
string[] files = Directory.GetFiles(Path.Combine(DataDir, "Plugins"));
foreach (string text in files)
{
Log(text, 20);
try
{
Assembly assembly = Assembly.LoadFrom(text);
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
Type[] interfaces = type.GetInterfaces();
foreach (Type type2 in interfaces)
{
if (type2.Name == "iConfigurablePlugin" && !type.IsAbstract && !type.IsInterface)
{
Warn("Loading Plugin: " + assembly.GetName().Name, 29);
iConfigurablePlugin iConfigurablePlugin2 = (iConfigurablePlugin)Activator.CreateInstance(type);
Plugins.Add(iConfigurablePlugin2);
iConfigurablePlugin2.Init();
}
}
}
}
catch (Exception ex)
{
Warn("Failed to load plugin:" + ex.Message, 37);
updateMessage = updateMessage + "Failed to load plugin:" + text + "\r\nIf you have recently upgraded GS2, Please check to see if an updated build of the plugin is available, or downgrade GS2 to continue using it\r\n";
}
}
foreach (iGenerator generator in Generators)
{
Log("GalacticScale2|LoadPlugins|Loading Generator:" + generator.Name, 44);
generator.Init();
}
Log("End", 48);
}
public static void LoadGenerators()
{
Log("Start", 54);
if (!Directory.Exists(Path.Combine(DataDir, "Generators")))
{
Directory.CreateDirectory(Path.Combine(DataDir, "Generators"));
}
string[] files = Directory.GetFiles(Path.Combine(DataDir, "Generators"));
foreach (string text in files)
{
Log(text, 60);
try
{
Assembly assembly = Assembly.LoadFrom(text);
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
Type[] interfaces = type.GetInterfaces();
foreach (Type type2 in interfaces)
{
if (type2.Name == "iGenerator" && !type.IsAbstract && !type.IsInterface)
{
Generators.Add((iGenerator)Activator.CreateInstance(type));
}
}
}
}
catch (Exception ex)
{
Warn("Failed to load generator:" + ex.Message, 72);
updateMessage = updateMessage + "Failed to load external generator:" + text + "\r\nIf you have recently upgraded GS2, Please check to see if an updated build of the generator is available, or downgrade GS2 to continue using it\r\n";
}
}
foreach (iGenerator generator in Generators)
{
Log("GalacticScale2|LoadPlugins|Loading Generator:" + generator.Name, 79);
generator.Init();
}
Log("End", 83);
}
public static void SavePreferences()
{
Preferences.version = PreferencesVersion;
Preferences.MainSettings = Config.Export();
foreach (iConfigurablePlugin plugin in Plugins)
{
if (plugin != null)
{
iConfigurablePlugin iConfigurablePlugin2 = plugin;
GSGenPreferences value = iConfigurablePlugin2.Export();
Preferences.PluginPreferences[iConfigurablePlugin2.GUID] = value;
}
}
foreach (iGenerator generator in Generators)
{
Preferences.Save(generator as iConfigurableGenerator);
}
GSPreferences.WriteToDisk(Preferences);
Log("Preferences Saved", 31);
}
public static void LoadPreferences(bool debug = false)
{
Preferences = GSPreferences.ReadFromDisk();
if (!debug)
{
ParsePreferences(Preferences);
}
else
{
Config.Import(Preferences.MainSettings);
}
Log("Preferences loaded", 61);
}
private static void ParsePreferences(GSPreferences p)
{
Config.Import(p.MainSettings);
if (p.GeneratorPreferences != null)
{
foreach (KeyValuePair<string, GSGenPreferences> generatorPreference in p.GeneratorPreferences)
{
Log("Generator Preferences for " + generatorPreference.Key + "found", 72);
if (GetGeneratorByID(generatorPreference.Key) is iConfigurableGenerator iConfigurableGenerator2)
{
Log(iConfigurableGenerator2.Name + "'s preferences exported to generator", 76);
iConfigurableGenerator2.Import(generatorPreference.Value);
}
}
}
if (p.PluginPreferences == null)
{
return;
}
foreach (KeyValuePair<string, GSGenPreferences> pluginPreference in p.PluginPreferences)
{
GetPluginByID(pluginPreference.Key)?.Import(pluginPreference.Value);
}
}
public static void Export(BinaryWriter w)
{
}
public static bool Import(BinaryReader r, string LoadPath = "")
{
Warn("Import", 22);
Log("Importing from Save.", 24);
if (!SaveOrLoadWindowOpen)
{
GSSettings.Reset(0);
}
fsSerializer fsSerializer = new fsSerializer();
long position = r.BaseStream.Position;
Warn($"Initial Stream Position:{position}", 28);
string text = "2";
string text2 = "";
text = r.ReadString();
text2 = r.ReadString();
fsData data;
fsResult fsResult = fsJsonParser.Parse(text2, out data);
if (fsResult.Failed)
{
Warn("DSV Contained No GS2 Data.", 38);
Warn(fsResult.FormattedMessages, 39);
r.BaseStream.Position = position;
if (SaveOrLoadWindowOpen)
{
return true;
}
if (LoadPath == "" || !File.Exists(LoadPath))
{
ActiveGenerator = GetGeneratorByID("space.customizing.generators.vanilla");
return false;
}
}
Warn($"parseResult:{fsResult.Succeeded}", 49);
Warn("Input file : " + LoadPath, 50);
Warn($"After Parse, Stream Position:{r.BaseStream.Position}", 51);
if (SaveOrLoadWindowOpen)
{
return true;
}
GSSettings instance = new GSSettings(0);
if (LoadPath != "")
{
Warn("*** Loading Settings From " + LoadPath, 56);
LoadSettingsFromJson(LoadPath);
Warn($"StarCount : {GSSettings.StarCount}", 58);
}
else
{
try
{
if (fsSerializer.TryDeserialize(data, ref instance).Failed)
{
Warn("Deserialize Failed", 67);
if (LoadPath == "")
{
r.BaseStream.Position = position;
}
if (LoadPath == "")
{
ActiveGenerator = GetGeneratorByID("space.customizing.generators.vanilla");
}
Warn($"After Deserialize Stream Position:{r.BaseStream.Position}", 70);
if (LoadPath == "")
{
return false;
}
}
else
{
GSSettings.Instance = instance;
}
}
catch (Exception ex)
{
Warn(ex.Message ?? "", 80);
}
}
Warn($"StarCount2 : {GSSettings.StarCount}", 84);
if (Vanilla)
{
ActiveGenerator = GetGeneratorByID("space.customizing.generators.gs2dev");
}
Warn($"StarCount3 : {GSSettings.StarCount}", 97);
GSSettings.Instance.imported = true;
Warn($"Final Stream Position:{r.BaseStream.Position}", 99);
return true;
}
public static void ConsoleSplash()
{
//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)
Version gameVersion = GameConfig.gameVersion;
string arg = ((object)(Version)(ref gameVersion)).ToString();
if (!BCE.disabled)
{
BCE.Console.WriteLine("┌─────────────────────────────────────────────────────────────────────────┐", ConsoleColor.Red);
BCE.Console.Write("│", ConsoleColor.Red);
BCE.Console.Write(" ╔═╗┌─┐┬ ┌─┐┌─┐┌┬┐┬┌─┐ ╔═╗┌─┐┌─┐┬ ┌─┐ ", ConsoleColor.White);
BCE.Console.Write("│\n", ConsoleColor.Red);
BCE.Console.Write("│", ConsoleColor.Red);
BCE.Console.Write($" ║ ╦├─┤│ ├─┤│ │ ││ ╚═╗│ ├─┤│ ├┤ DSP Version {arg,17} ", ConsoleColor.Gray);
BCE.Console.Write("│\n", ConsoleColor.Red);
BCE.Console.Write("│", ConsoleColor.Red);
BCE.Console.Write(" ╚═╝┴ ┴┴─┘┴ ┴└─┘ ┴ ┴└─┘ ╚═╝└─┘┴ ┴┴─┘└─┘ ", ConsoleColor.DarkGray);
BCE.Console.Write($"Version {Version,9} Initializing ", ConsoleColor.White);
BCE.Console.Write("│\n", ConsoleColor.Red);
BCE.Console.WriteLine("└─────────────────────────────────────────────────────────────────────────┘", ConsoleColor.Red);
}
else
{
Bootstrap.Debug(" ");
Bootstrap.Debug(".─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─_─.");
Bootstrap.Debug("│ ╔═╗┌─┐┬ ┌─┐┌─┐┌┬┐┬┌─┐ ╔═╗┌─┐┌─┐┬ ┌─┐ │");
Bootstrap.Debug($"│ ║ ╦├─┤│ ├─┤│ │ ││ ╚═╗│ ├─┤│ ├┤ DSP Version {arg,17} │");
Bootstrap.Debug($"│ ╚═╝┴ ┴┴─┘┴ ┴└─┘ ┴ ┴└─┘ ╚═╝└─┘┴ ┴┴─┘└─┘ Version {Version,8} Initializing │");
Bootstrap.Debug("└──────https://discord.gg/NbpBn6gM6d──────────────────────────────────────┘");
}
Bootstrap.Debug("");
}
public static void Log(string s, [CallerLineNumber] int lineNumber = 0)
{
if (DebugOn)
{
Bootstrap.Debug(lineNumber.ToString().PadLeft(4) + ":" + GetCaller() + s);
}
}
public static void LogTop(int width = 80)
{
if (BCE.disabled)
{
Log("-----", 26);
return;
}
int num = width - 21;
int num2 = Mathf.FloorToInt((float)(num / 2)) - 2;
int spaces = num - num2 - 4;
BCE.Console.Write("\r\n╔═", ConsoleColor.White);
BCE.Console.Write("═", ConsoleColor.Gray);
BCE.Console.Write("═", ConsoleColor.DarkGray);
BCE.Console.Write(SpaceString(num2), ConsoleColor.Green);
BCE.Console.Write("*", ConsoleColor.Yellow);
BCE.Console.Write(".·", ConsoleColor.Gray);
BCE.Console.Write(":", ConsoleColor.DarkGray);
BCE.Console.Write("·.", ConsoleColor.Gray);
BCE.Console.Write("✧", ConsoleColor.DarkCyan);
BCE.Console.Write(" ✦ ", ConsoleColor.Cyan);
BCE.Console.Write("✧", ConsoleColor.DarkCyan);
BCE.Console.Write(".·", ConsoleColor.Gray);
BCE.Console.Write(":", ConsoleColor.DarkGray);
BCE.Console.Write("·.", ConsoleColor.Gray);
BCE.Console.Write("*", ConsoleColor.Yellow);
BCE.Console.Write(SpaceString(spaces), ConsoleColor.Green);
BCE.Console.Write("═", ConsoleColor.DarkGray);
BCE.Console.Write("═", ConsoleColor.Gray);
BCE.Console.Write("═╗\r\n", ConsoleColor.White);
}
public static void LogBot(int width = 80)
{
if (BCE.disabled)
{
Log("-----", 58);
return;
}
int num = width - 21;
int num2 = Mathf.FloorToInt((float)(num / 2)) - 2;
int spaces = num - num2 - 4;
BCE.Console.Write("╚═", ConsoleColor.White);
BCE.Console.Write("═", ConsoleColor.Gray);
BCE.Console.Write("═", ConsoleColor.DarkGray);
BCE.Console.Write(SpaceString(num2), ConsoleColor.Green);
BCE.Console.Write("*", ConsoleColor.Yellow);
BCE.Console.Write(".·", ConsoleColor.Gray);
BCE.Console.Write(":", ConsoleColor.DarkGray);
BCE.Console.Write("·.", ConsoleColor.Gray);
BCE.Console.Write("✧", ConsoleColor.DarkCyan);
BCE.Console.Write(" ✦ ", ConsoleColor.Cyan);
BCE.Console.Write("✧", ConsoleColor.DarkCyan);
BCE.Console.Write(".·", ConsoleColor.Gray);
BCE.Console.Write(":", ConsoleColor.DarkGray);
BCE.Console.Write("·.", ConsoleColor.Gray);
BCE.Console.Write("*", ConsoleColor.Yellow);
BCE.Console.Write(SpaceString(spaces), ConsoleColor.Green);
BCE.Console.Write("═", ConsoleColor.DarkGray);
BCE.Console.Write("═", ConsoleColor.Gray);
BCE.Console.WriteLine("═╝", ConsoleColor.White);
}
public static string SpaceString(int spaces)
{
return new string(' ', spaces);
}
public static void LogMid(string text, int width = 80)
{
string[] array = text.Split(new char[1] { '\n' });
if (array.Length > 1)
{
string[] array2 = array;
foreach (string text2 in array2)
{
LogMid(text2, width);
}
}
if (BCE.disabled)
{
Log(text, 107);
return;
}
if (text.Length < width - 4)
{
LogMidLine(text, width);
return;
}
List<string> list = new List<string>();
int startIndex = 0;
while (text.Length > width - 4)
{
LogMidLine(text.Substring(startIndex, width - 4), width);
text = text.Remove(startIndex, width - 4);
}
}
public static void LogMidLine(string text, int width = 80)
{
BCE.Console.Write("║ ", ConsoleColor.White);
BCE.Console.Write(string.Format("{0," + (width - 4) + "}", text), ConsoleColor.Green);
BCE.Console.Write(" ║\r\n", ConsoleColor.White);
}
public static void LogSpace(int lineCount = 1)
{
if (DebugOn)
{
for (int i = 0; i < lineCount; i++)
{
Bootstrap.Debug(" ", (LogLevel)8, isActive: true);
}
}
}
public static void Error(string message, [CallerLineNumber] int lineNumber = 0)
{
Bootstrap.Debug($"{lineNumber,4}:{GetCaller()}{message}", (LogLevel)2, isActive: true);
DumpError(lineNumber + "|" + message);
}
public static void Warn(string message, [CallerLineNumber] int lineNumber = 0)
{
Bootstrap.Debug(lineNumber.ToString().PadLeft(4) + ":" + GetCaller() + message, (LogLevel)4, isActive: true);
}
public static void LogGen(string message, [CallerLineNumber] int lineNumber = 0)
{
if (Config.GenLog)
{
Bootstrap.Debug(lineNumber.ToString().PadLeft(4) + ":" + GetCaller() + message, (LogLevel)4, isActive: true);
}
}
public static void DevLog(string message, [CallerLineNumber] int lineNumber = 0)
{
if (Config.Dev)
{
Bootstrap.Debug(lineNumber.ToString().PadLeft(4) + ":" + GetCaller() + message, (LogLevel)4, isActive: true);
}
}
public static void LogJson(object o, bool force = false)
{
if (DebugOn || force)
{
fsSerializer fsSerializer = new fsSerializer();
fsSerializer.TrySerialize(o, out var data).AssertSuccessWithoutWarnings();
string text = fsJsonPrinter.PrettyJson(data);
Bootstrap.Debug(GetCaller() + text);
}
}
public static void WarnJson(object o)
{
fsSerializer fsSerializer = new fsSerializer();
fsSerializer.TrySerialize(o, out var data).AssertSuccessWithoutWarnings();
string text = fsJsonPrinter.PrettyJson(data);
Bootstrap.Debug(GetCaller() + text, (LogLevel)4, isActive: true);
}
public static string GetCaller(int depth = 0)
{
depth += 2;
StackTrace stackTrace = new StackTrace();
if (stackTrace.FrameCount <= depth)
{
return "";
}
string text = stackTrace.GetFrame(depth).GetMethod().Name;
Type reflectedType = stackTrace.GetFrame(depth).GetMethod().ReflectedType;
if (reflectedType != null)
{
string text2 = reflectedType.ToString().Split(new char[1] { '.' })[^1];
if (text == ".ctor")
{
text = "<Constructor>";
}
return text2 + "|" + text + "|";
}
return "ERROR GETTING CALLER";
}
public static void LogError(object sender, UnhandledExceptionEventArgs e, [CallerLineNumber] int lineNumber = 0)
{
Error($"{lineNumber} {GetCaller()}", 195);
LogException(e.ExceptionObject as Exception);
}
private static void LogException(Exception ex)
{
Error(ex.StackTrace, 201);
}
public static string FormatTableHeader(string[] headers, int[] columnWidths, params Alignment[] alignments)
{
if (headers.Length != columnWidths.Length || headers.Length != alignments.Length)
{
throw new ArgumentException("Input arrays must have the same length.");
}
string format = GenerateFormatString(columnWidths, alignments);
string text = string.Format(format, headers);
return text ?? "";
}
public static string FormatTable(string[] values, int[] columnWidths, params Alignment[] alignments)
{
if (values.Length != columnWidths.Length || values.Length != alignments.Length)
{
throw new ArgumentException("Input arrays must have the same length.");
}
string format = GenerateFormatString(columnWidths, alignments);
string text = string.Format(format, values);
return text ?? "";
}
private static string GenerateFormatString(int[] columnWidths, Alignment[] alignments)
{
if (columnWidths.Length != alignments.Length)
{
throw new ArgumentException("Column widths and alignments must have the same length.");
}
string text = "";
for (int i = 0; i < columnWidths.Length; i++)
{
text += $"{{{i},-{columnWidths[i]}}}";
if (i < columnWidths.Length - 1)
{
text += " ";
}
}
return text;
}
public static IEnumerable<CodeInstruction> LogTranspilerError(IEnumerable<CodeInstruction> instructions, string text)
{
Error(text, 261);
Log(GetCaller(), 262);
LogTop();
foreach (CodeInstruction instruction in instructions)
{
LogMid(((object)instruction).ToString());
}
LogBot();
return instructions;
}
public static iConfigurablePlugin GetPluginByID(string guid)
{
foreach (iConfigurablePlugin plugin in Plugins)
{
if (plugin.GUID == guid)
{
return plugin;
}
}
return null;
}
public static PlanetData CreatePlanet(ref StarData star, GSPlanet gsPlanet, Random random, PlanetData host = null)
{
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_0396: Unknown result type (might be due to invalid IL or missing references)
//IL_039b: Unknown result type (might be due to invalid IL or missing references)
//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0402: Unknown result type (might be due to invalid IL or missing references)
//IL_0408: Invalid comparison between Unknown and I4
//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
//IL_060b: Unknown result type (might be due to invalid IL or missing references)
//IL_0611: Unknown result type (might be due to invalid IL or missing references)
//IL_0612: Unknown result type (might be due to invalid IL or missing references)
//IL_0646: Unknown result type (might be due to invalid IL or missing references)
//IL_064c: Unknown result type (might be due to invalid IL or missing references)
//IL_064d: Unknown result type (might be due to invalid IL or missing references)
//IL_0668: Unknown result type (might be due to invalid IL or missing references)
//IL_066f: Unknown result type (might be due to invalid IL or missing references)
//IL_0670: 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_06a0: 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_06bf: Unknown result type (might be due to invalid IL or missing references)
//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
if (GSSettings.Stars[star.index].counter > 99)
{
Error("Create Planet failed: Star '" + star.name + "' already has 99 bodies", 12);
return null;
}
bool flag = host != null;
if (GSSettings.Stars[star.index] == null)
{
Error($"Star Index {star.index} does not exist in GSSettings.Stars", 22);
}
int counter = GSSettings.Stars[star.index].counter;
PlanetData planetData = new PlanetData();
int counter2 = GSSettings.Stars[star.index].counter;
planetData.index = counter;
planetData.galaxy = galaxy;
planetData.star = star;
PlanetData obj = planetData;
int seed = (gsPlanet.Seed = ((gsPlanet.Seed < 0) ? random.Next() : gsPlanet.Seed));
obj.seed = seed;
if (flag)
{
planetData.orbitAround = host.number;
planetData.orbitAroundPlanet = host;
}
else
{
planetData.orbitAround = 0;
}
planetData.number = counter + 1;
planetData.id = star.id * 100 + counter + 1;
if (!gsPlanets.ContainsKey(planetData.id))
{
gsPlanets.Add(planetData.id, gsPlanet);
}
else
{
gsPlanets[planetData.id] = gsPlanet;
}
string text = "";
if (flag)
{
if (RomanNumbers.roman.Length <= host.number + 1)
{
Error($"Roman Number Conversion Error for {host.number + 1}", 53);
}
text = RomanNumbers.roman[host.number + 1] + " - ";
}
if (RomanNumbers.roman.Length <= counter + 1)
{
Error($"Roman Number Conversion Error for {counter + 1}", 60);
}
text += RomanNumbers.roman[counter + 1];
planetData.name = ((gsPlanet.Name != "") ? gsPlanet.Name : (star.name + " " + text));
planetData.orbitRadius = gsPlanet.OrbitRadius;
if (planetData.orbitRadius < 0f)
{
Warn($"Planet {planetData.name} orbit broken. {star.type} {star.spectr}", 68);
planetData.orbitRadius = random.NextFloat(1f, 50f);
}
planetData.orbitInclination = gsPlanet.OrbitInclination;
planetData.orbitLongitude = gsPlanet.OrbitLongitude;
planetData.orbitalPeriod = gsPlanet.OrbitalPeriod;
planetData.orbitPhase = gsPlanet.OrbitPhase;
planetData.obliquity = gsPlanet.Obliquity;
planetData.rotationPeriod = gsPlanet.RotationPeriod;
planetData.rotationPhase = gsPlanet.RotationPhase;
planetData.sunDistance = GetSunDistance(GSSettings.Stars[star.index], gsPlanet, host);
planetData.radius = gsPlanet.Radius;
planetData.segment = 5;
int num2 = (int)(planetData.radius / 4f + 0.1f) * 4;
if (!PatchOnUIBuildingGrid.LUT512.ContainsKey(num2))
{
SetLuts(num2, planetData.radius);
}
PatchOnUIBuildingGrid.refreshGridRadius = Mathf.RoundToInt(planetData.radius);
planetData.runtimeOrbitRotation = Quaternion.AngleAxis(planetData.orbitLongitude, Vector3.up) * Quaternion.AngleAxis(planetData.orbitInclination, Vector3.forward);
planetData.runtimeSystemRotation = planetData.runtimeOrbitRotation * Quaternion.AngleAxis(planetData.obliquity, Vector3.forward);
planetData.type = GSSettings.ThemeLibrary.Find(gsPlanet.Theme).PlanetType;
planetData.scale = 1f;
if ((int)planetData.type == 5)
{
planetData.scale = 10f;
}
if (gsPlanet.Scale > 0f)
{
planetData.scale = gsPlanet.Scale;
}
planetData.precision = gsPlanet.Radius;
gsPlanet.planetData = planetData;
planetData.luminosity = gsPlanet.Luminosity;
SetPlanetTheme(planetData, gsPlanet);
planetData.temperatureBias = gsPlanet.GsTheme.AtmoHeight;
if (star.galaxy.astrosData == null)
{
Error("Astroposes array does not exist", 119);
}
if (star.galaxy.astrosData.Length <= planetData.id)
{
Error($"Astroposes does not contain index {planetData.id} when trying to set planet uRadius", 122);
}
star.galaxy.astrosData[planetData.id].uRadius = planetData.realRadius;
if (star.planets.Length <= counter2)
{
Error($"star.planets length of {star.planets.Length} <= counter {counter2}", 126);
}
star.planets[counter2] = planetData;
if (GSSettings.Stars.Count <= star.index)
{
Error($"GSSettings.Stars[{star.index}] does not exist", 130);
}
GSSettings.Stars[star.index].counter++;
if (gsPlanet.MoonsCount > 0)
{
CreateMoons(ref planetData, gsPlanet, random);
}
if (Math.Abs(planetData.orbitalPeriod - planetData.rotationPeriod) < 1.0)
{
PlanetData obj2 = planetData;
obj2.singularity = (EPlanetSingularity)(obj2.singularity | 1);
}
if (Math.Abs(planetData.orbitalPeriod - planetData.rotationPeriod * 2.0) < 1.0)
{
PlanetData obj3 = planetData;
obj3.singularity = (EPlanetSingularity)(obj3.singularity | 2);
}
if (Math.Abs(planetData.orbitalPeriod - planetData.rotationPeriod * 4.0) < 1.0)
{
PlanetData obj4 = planetData;
obj4.singularity = (EPlanetSingularity)(obj4.singularity | 4);
}
if (gsPlanet.Bodies.Count > 2)
{
PlanetData obj5 = planetData;
obj5.singularity = (EPlanetSingularity)(obj5.singularity | 0x20);
}
if (planetData.obliquity > 75f || planetData.obliquity < -75f)
{
PlanetData obj6 = planetData;
obj6.singularity = (EPlanetSingularity)(obj6.singularity | 8);
}
if (planetData.rotationPeriod < 0.0)
{
PlanetData obj7 = planetData;
obj7.singularity = (EPlanetSingularity)(obj7.singularity | 0x10);
}
return planetData;
}
public static float GetSunDistance(GSStar star, GSPlanet planet, PlanetData host)
{
if (host == null)
{
return planet.OrbitRadius;
}
if (IsPlanetOfStar(star, GetGSPlanet(host)))
{
return host.orbitRadius;
}
foreach (GSPlanet planet2 in star.Planets)
{
foreach (GSPlanet body in planet2.Bodies)
{
if (planet == body)
{
return planet2.OrbitRadius;
}
}
}
Error("Cannot Get Sun Distance for planet " + planet.Name, 168);
return 100f;
}
public static void CreateMoons(ref PlanetData planetData, GSPlanet planet, Random random)
{
for (int i = 0; i < planet.Moons.Count; i++)
{
if (GSSettings.Stars[planetData.star.index].counter > 99)
{
Error("Create Planet failed: Star '" + planetData.star.name + "' already has 99 bodies", 178);
break;
}
PlanetData val = CreatePlanet(ref planetData.star, planet.Moons[i], random, planetData);
if (val == null)
{
Error("Creating moons for planet '" + planet.Name + "' failed. No moon returned", 185);
break;
}
val.orbitAroundPlanet = planetData;
}
}
public static void DebugPlanet(PlanetData planet)
{
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: 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_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: 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_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_0373: Unknown result type (might be due to invalid IL or missing references)
//IL_0378: Unknown result type (might be due to invalid IL or missing references)
//IL_0399: Unknown result type (might be due to invalid IL or missing references)
//IL_039e: Unknown result type (might be due to invalid IL or missing references)
//IL_056d: Unknown result type (might be due to invalid IL or missing references)
//IL_0572: Unknown result type (might be due to invalid IL or missing references)
//IL_0593: Unknown result type (might be due to invalid IL or missing references)
//IL_0598: Unknown result type (might be due to invalid IL or missing references)
//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
//IL_05be: Unknown result type (might be due to invalid IL or missing references)
BCE.Console.WriteLine("Creating Planet " + planet.id, ConsoleColor.Red);
BCE.Console.WriteLine("Index " + planet.index, ConsoleColor.Green);
BCE.Console.WriteLine("OrbitAround " + planet.orbitAround, ConsoleColor.Green);
BCE.Console.WriteLine("Seed " + planet.seed, ConsoleColor.Green);
BCE.Console.WriteLine("Period " + planet.orbitalPeriod, ConsoleColor.Green);
BCE.Console.WriteLine("Inclination " + planet.orbitInclination, ConsoleColor.Green);
BCE.Console.WriteLine("Orbit Index " + planet.orbitIndex, ConsoleColor.Green);
BCE.Console.WriteLine("Orbit Longitude " + planet.orbitLongitude, ConsoleColor.Green);
BCE.Console.WriteLine("Orbit Phase " + planet.orbitPhase, ConsoleColor.Green);
BCE.Console.WriteLine("Orbit Radius " + planet.orbitRadius, ConsoleColor.Green);
BCE.Console.WriteLine("Precision " + planet.precision, ConsoleColor.Green);
BCE.Console.WriteLine("Radius " + planet.radius, ConsoleColor.Green);
BCE.Console.WriteLine("Rotation Period " + planet.rotationPeriod, ConsoleColor.Green);
BCE.Console.WriteLine("Rotation Phase " + planet.rotationPhase, ConsoleColor.Green);
Vector3 val = planet.runtimeLocalSunDirection;
BCE.Console.WriteLine("RuntimeLocalSunDirection " + ((object)(Vector3)(ref val)).ToString(), ConsoleColor.Green);
BCE.Console.WriteLine("RuntimeOrbitPhase " + planet.runtimeOrbitPhase, ConsoleColor.Green);
Quaternion val2 = planet.runtimeOrbitRotation;
BCE.Console.WriteLine("RuntimeOrbitRotation " + ((object)(Quaternion)(ref val2)).ToString(), ConsoleColor.Green);
VectorLF3 val3 = planet.runtimePosition;
BCE.Console.WriteLine("RuntimePosition " + ((object)(VectorLF3)(ref val3)).ToString(), ConsoleColor.Green);
val3 = planet.runtimePositionNext;
BCE.Console.WriteLine("RuntimePositionNext " + ((object)(VectorLF3)(ref val3)).ToString(), ConsoleColor.Green);
val2 = planet.runtimeRotation;
BCE.Console.WriteLine("RuntimeRotation " + ((object)(Quaternion)(ref val2)).ToString(), ConsoleColor.Green);
val2 = planet.runtimeRotationNext;
BCE.Console.WriteLine("RuntimeRotationNext " + ((object)(Quaternion)(ref val2)).ToString(), ConsoleColor.Green);
BCE.Console.WriteLine("RuntimeRotationPhase " + planet.runtimeRotationPhase, ConsoleColor.Green);
val2 = planet.runtimeSystemRotation;
BCE.Console.WriteLine("RuntimeSystemRotation " + ((object)(Quaternion)(ref val2)).ToString(), ConsoleColor.Green);
BCE.Console.WriteLine("SingularityString " + planet.singularityString, ConsoleColor.Green);
BCE.Console.WriteLine("Sundistance " + planet.sunDistance, ConsoleColor.Green);
BCE.Console.WriteLine("TemperatureBias " + planet.temperatureBias, ConsoleColor.Green);
BCE.Console.WriteLine("Theme " + planet.theme, ConsoleColor.Green);
BCE.Console.WriteLine("Type " + ((object)(EPlanetType)(ref planet.type)).ToString(), ConsoleColor.Green);
val3 = planet.uPosition;
BCE.Console.WriteLine("uPosition " + ((object)(VectorLF3)(ref val3)).ToString(), ConsoleColor.Green);
val3 = planet.uPositionNext;
BCE.Console.WriteLine("uPositionNext " + ((object)(VectorLF3)(ref val3)).ToString(), ConsoleColor.Green);
BCE.Console.WriteLine("Wanted " + planet.wanted, ConsoleColor.Green);
BCE.Console.WriteLine("WaterHeight " + planet.waterHeight, ConsoleColor.Green);
BCE.Console.WriteLine("WaterItemID " + planet.waterItemId, ConsoleColor.Green);
BCE.Console.WriteLine("WindStrength " + planet.windStrength, ConsoleColor.Green);
BCE.Console.WriteLine("Number " + planet.number, ConsoleColor.Green);
BCE.Console.WriteLine("Obliquity " + planet.obliquity, ConsoleColor.Green);
BCE.Console.WriteLine("Name " + planet.name, ConsoleColor.Green);
BCE.Console.WriteLine("mod_y " + planet.mod_y, ConsoleColor.Green);
BCE.Console.WriteLine("mod_x " + planet.mod_x, ConsoleColor.Green);
BCE.Console.WriteLine("Luminosity " + planet.luminosity, ConsoleColor.Green);
BCE.Console.WriteLine("Levelized " + planet.levelized, ConsoleColor.Green);
BCE.Console.WriteLine("Land% " + planet.landPercent, ConsoleColor.Green);
BCE.Console.WriteLine("Ion Height " + planet.ionHeight, ConsoleColor.Green);
BCE.Console.WriteLine("HabitableBias " + planet.habitableBias, ConsoleColor.Green);
BCE.Console.WriteLine("GasTotalHeat " + planet.gasTotalHeat, ConsoleColor.Green);
val = planet.birthResourcePoint1;
BCE.Console.WriteLine("BirthResourcePoint1 " + ((object)(Vector3)(ref val)).ToString(), ConsoleColor.Green);
val = planet.birthResourcePoint0;
BCE.Console.WriteLine("BirthResourcePoint0 " + ((object)(Vector3)(ref val)).ToString(), ConsoleColor.Green);
val = planet.birthPoint;
BCE.Console.WriteLine("BirthPoint " + ((object)(Vector3)(ref val)).ToString(), ConsoleColor.Green);
BCE.Console.WriteLine("Algo ID " + planet.algoId, ConsoleColor.Green);
BCE.Console.WriteLine("---------------------", ConsoleColor.Red);
}
public static void SetLuts(int segments, float planetRadius)
{
if (DSPGame.IsMenuDemo || Vanilla || (keyedLUTs.ContainsKey(segments) && PatchOnUIBuildingGrid.LUT512.ContainsKey(segments)))
{
return;
}
if (segments < 4 || planetRadius < 5f)
{
planetRadius = GameMain.data.localPlanet.realRadius;
segments = Mathf.CeilToInt(GameMain.data.localPlanet.radius / 4f + 0.1f) * 4;
}
int num = segments / 4;
int[] array = new int[num];
float num2 = (float)Math.PI / 2f / (float)num;
float num3 = planetRadius;
int num4 = num * 4;
int[] array2 = new int[512];
array2[0] = 1;
for (int i = 0; i < num; i++)
{
float num5 = Mathf.Cos((float)i * num2) * planetRadius;
int num6 = Mathf.CeilToInt(Mathf.Abs(Mathf.Cos((float)((double)((float)(i + 1) / ((float)segments / 4f)) * Math.PI * 0.5))) * (float)segments);
if ((double)num5 < 0.9 * (double)num3)
{
num3 = num5;
num4 = (int)((double)num5 / 4.0) * 4;
}
array[i] = num4;
if (num6 >= array2.Length)
{
num6 = array2.Length - 1;
}
array2[num6] = num4;
}
int num7 = 1;
for (int j = 1; j < 512; j++)
{
if (array2[j] > num7)
{
int num8 = array2[j];
array2[j] = num7;
num7 = num8;
}
else
{
array2[j] = num7;
}
}
if (segments == 200)
{
array = new int[50]
{
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 160, 160, 160, 160,
160, 160, 160, 160, 160, 160, 120, 120, 120, 120,
120, 100, 100, 100, 100, 100, 80, 80, 80, 60,
60, 60, 40, 40, 32, 32, 20, 16, 8, 4
};
array2 = new int[512]
{
1, 4, 4, 4, 4, 4, 4, 4, 8, 8,
8, 8, 8, 8, 8, 8, 16, 16, 16, 16,
20, 20, 20, 20, 20, 20, 20, 20, 32, 32,
32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
40, 40, 40, 40, 60, 60, 60, 60, 60, 60,
60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
60, 60, 60, 80, 80, 80, 80, 80, 80, 80,
80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
80, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 100, 100, 100, 100, 100, 100,
100, 100, 100, 100, 120, 120, 120, 120, 120, 120,
120, 120, 120, 120, 120, 120, 120, 120, 120, 120,
120, 120, 120, 120, 120, 120, 120, 120, 120, 120,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
160, 160, 160, 160, 160, 160, 160, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 200, 200, 200, 200, 200, 200, 200, 200, 200,
200, 240, 240, 240, 240, 240, 240, 240, 240, 240,
240, 240, 240, 240, 240, 240, 240, 240, 240, 240,
240, 240, 240, 240, 240, 240, 240, 240, 240, 240,
240, 240, 240, 240, 240, 240, 240, 240, 240, 240,
240, 240, 240, 240, 240, 240, 240, 240, 240, 240,
240, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
300, 400, 400, 400, 400, 400, 400, 400, 400, 400,
400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
400, 400, 400, 400, 400, 400, 400, 400, 400, 400,
400, 500, 500, 500, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 500,
500, 500, 500, 500, 500, 500, 500, 500, 500, 500,
500, 500
};
}
if (!keyedLUTs.ContainsKey(segments))
{
keyedLUTs.Add(segments, array);
}
if (!PatchOnUIBuildingGrid.LUT512.ContainsKey(segments))
{
PatchOnUIBuildingGrid.LUT512.Add(segments, array2);
}
}
public static void SetPlanetTheme(PlanetData planet, GSPlanet gsPlanet)
{
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Invalid comparison between Unknown and I4
int seed = 0;
GSTheme gSTheme = GSSettings.ThemeLibrary.Find(gsPlanet.Theme);
int num = gSTheme.AddToThemeProtoSet();
if (gsPlanet.Seed > -1)
{
seed = gsPlanet.Seed;
}
Random random = new Random(seed);
double num2 = random.NextDouble();
double num3 = random.NextDouble();
double num4 = random.NextDouble();
planet.theme = num;
ThemeProto val = ((ProtoSet<ThemeProto>)(object)LDB.themes).Select(num);
Log(gsPlanet.GsTheme.DisplayName + " " + val.EigenBit + " " + planet.briefString, 29);
planet.algoId = gSTheme.Algo;
planet.mod_x = (double)gSTheme.ModX.x + num3 * ((double)gSTheme.ModX.y - (double)gSTheme.ModX.x);
planet.mod_y = (double)gSTheme.ModY.x + num4 * ((double)gSTheme.ModY.y - (double)gSTheme.ModY.x);
planet.type = gSTheme.PlanetType;
planet.ionHeight = gSTheme.IonHeight;
planet.windStrength = gSTheme.Wind;
planet.iceFlag = gSTheme.IceFlag;
planet.waterHeight = gSTheme.WaterHeight;
planet.waterItemId = gSTheme.WaterItemId;
planet.levelized = gSTheme.UseHeightForBuild;
if ((int)planet.type == 5)
{
int num5 = gSTheme.GasItems.Length;
int num6 = gSTheme.GasSpeeds.Length;
int[] array = new int[num5];
float[] array2 = new float[num6];
float[] array3 = new float[num5];
for (int i = 0; i < num5; i++)
{
array[i] = gSTheme.GasItems[i];
}
double num7 = 0.0;
for (int j = 0; j < num6; j++)
{
float num8 = gSTheme.GasSpeeds[j] * (float)(num2 * 0.190909147262573 + 0.909090876579285);
array2[j] = num8 * Mathf.Pow(planet.star.resourceCoef, 0.3f);
ItemProto val2 = ((ProtoSet<ItemProto>)(object)LDB.items).Select(array[j]);
array3[j] = val2.HeatValue;
num7 += (double)array3[j] * (double)array2[j];
}
planet.gasItems = array;
planet.gasSpeeds = array2;
planet.gasHeatValues = array3;
planet.gasTotalHeat = num7;
}
}
public static void ConfigureBirthStarHiveSettings(Random random, StarData starData)
{
starData.hivePatternLevel = 0;
starData.safetyFactor = 0.847f + (float)random.NextDouble() * 0.026f;
float maxDensity = gameDesc.combatSettings.maxDensity;
float initialColonize = gameDesc.combatSettings.initialColonize;
Log($"Setting up Birth Star Hive System for {starData.name} Initial Colonize: {initialColonize} MaxDensity: {gameDesc.combatSettings.maxDensity}", 15);
starData.maxHiveCount = Mathf.RoundToInt(maxDensity * 4f / 3f);
starData.maxHiveCount = Mathf.Clamp(starData.maxHiveCount, 1, 8);
starData.initialHiveCount = Mathf.RoundToInt(initialColonize / 2f * ((float)starData.maxHiveCount - 0.2f));
starData.initialHiveCount = Mathf.Clamp(starData.initialHiveCount, 1, starData.maxHiveCount);
if (initialColonize < 0.015f)
{
Log("Preventing Birth System from having a Hive", 24);
starData.initialHiveCount = 0;
}
Log("Birth System (" + starData.name + ") Hive Settings Applied : " + starData.initialHiveCount + " / " + starData.maxHiveCount, 27);
}
public static void ConfigureStarHiveSettings(Random random, StarData star)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Invalid comparison between Unknown and I4
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Invalid comparison between Unknown and I4
float initialColonize = gameDesc.combatSettings.initialColonize;
float maxDensity = gameDesc.combatSettings.maxDensity;
Log("Generating Hive Settings to " + star.name, 34);
float level = star.level;
bool flag = (int)star.type == 4 || (int)star.type == 3;
star.hivePatternLevel = 0;
star.safetyFactor = 0.847f + (float)random.NextDouble() * 0.026f;
if (flag)
{
star.safetyFactor = 1f;
}
star.safetyFactor *= maxDensity / 3f;
star.safetyFactor = Mathf.Clamp01(star.safetyFactor);
star.maxHiveCount = Mathf.RoundToInt(maxDensity * 4f / 3f);
star.maxHiveCount += Mathf.RoundToInt(4f * level);
if (flag)
{
star.maxHiveCount += 2;
}
if (initialColonize < 0.015f)
{
star.initialHiveCount = 0;
}
else
{
star.initialHiveCount = Mathf.RoundToInt(initialColonize / 2f * ((float)star.maxHiveCount - 0.2f));
star.initialHiveCount += Mathf.RoundToInt(level * 2f);
}
star.maxHiveCount = Mathf.Clamp(star.maxHiveCount, 0, 8);
star.initialHiveCount = Mathf.Clamp(star.initialHiveCount, 0, star.maxHiveCount);
}
public static void CreateDarkFogHive(StarData star, Random random)
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: 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_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
Log("Generating Hive Orbits For " + star.name, 72);
GSStar gSStar = GetGSStar(star);
List<float> items = GeneratePossibleHiveOrbits(gSStar);
int num = 8;
if (gSStar.Decorative || gSStar.PlanetCount == 0)
{
star.initialHiveCount = 0;
star.maxHiveCount = 0;
star.hivePatternLevel = 0;
}
star.hiveAstroOrbits = (AstroOrbitData[])(object)new AstroOrbitData[num];
AstroOrbitData[] hiveAstroOrbits = star.hiveAstroOrbits;
for (int i = 0; i < num; i++)
{
hiveAstroOrbits[i] = new AstroOrbitData();
float orbitRadius = random.ItemAndRemove(items);
hiveAstroOrbits[i].orbitRadius = orbitRadius;
hiveAstroOrbits[i].orbitInclination = random.NextFloat();
hiveAstroOrbits[i].orbitLongitude = random.NextFloat();
hiveAstroOrbits[i].orbitPhase = random.NextFloat();
hiveAstroOrbits[i].orbitalPeriod = Utils.CalculateOrbitPeriod(hiveAstroOrbits[i].orbitRadius);
hiveAstroOrbits[i].orbitRotation = Quaternion.AngleAxis(hiveAstroOrbits[i].orbitLongitude, Vector3.up) * Quaternion.AngleAxis(hiveAstroOrbits[i].orbitInclination, Vector3.forward);
AstroOrbitData obj = hiveAstroOrbits[i];
VectorLF3 val = Maths.QRotateLF(hiveAstroOrbits[i].orbitRotation, new VectorLF3(0f, 1f, 0f));
obj.orbitNormal = ((VectorLF3)(ref val)).normalized;
}
}
public static List<float> GeneratePossibleHiveOrbits(GSStar gsStar, int count = 10, Random random = null)
{
if (gsStar.PlanetCount == 0 || gsStar.Decorative)
{
return new List<float> { 1f, 2f, 3f, 4f, 5f, 6f, 7f, 8f };
}
List<(float, float)> list = new List<(float, float)>();
List<(float, float)> list2 = new List<(float, float)>();
List<float> list3 = new List<float>();
float num = gsStar.SystemRadius;
if (random == null)
{
random = new Random(Mathf.CeilToInt(gsStar.luminosity * gsStar.age * gsStar.SystemRadius));
}
foreach (GSPlanet planet in gsStar.Planets)
{
list.Add((planet.OrbitRadius - planet.SystemRadius, planet.OrbitRadius + planet.SystemRadius));
}
if (list[0].Item1 > gsStar.RadiusAU + 0.1f)
{
list2.Add((gsStar.RadiusAU + 0.1f, list[0].Item1));
}
for (int i = 0; i < list.Count - 1; i++)
{
list2.Add((list[i].Item2, list[i + 1].Item1));
}
if (list[list.Count - 1].Item2 < num)
{
list2.Add((list[list.Count - 1].Item2, num));
}
for (int j = 0; j < count - 1; j++)
{
if (list2.Count == 0)
{
float item = num;
num += 5f;
list2.Add((item, num));
}
(float, float) item2 = random.Item(list2);
float num2 = random.ClampedNormal(item2.Item1, item2.Item2, 50);
list3.Add(num2);
list2.Remove(item2);
(float, float) item3 = (item2.Item1, num2 - 0.05f);
(float, float) item4 = (num2 + 0.05f, item2.Item2);
if (item3.Item2 - item3.Item1 > 0.1f)
{
list2.Add(item3);
}
if (item4.Item2 - item4.Item1 > 0.1f)
{
list2.Add(item4);
}
}
return list3;
}
public static StarData CreateStar(int index, Random random)
{
return CreateStar(galaxy, index + 1, random);
}
public static StarData CreateStar(GalaxyData galaxy, int id, Random random)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: 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_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
StarData val = new StarData();
int num = id - 1;
GSStar gSStar = GSSettings.Stars[num];
gSStar.assignedIndex = num;
if (gSStar.Seed < 0)
{
gSStar.Seed = random.Next();
}
if (!gsStars.ContainsKey(id))
{
gsStars.Add(id, gSStar);
}
else
{
gsStars[id] = gSStar;
}
val.galaxy = galaxy;
val.index = num;
val.level = ((galaxy.starCount > 1) ? ((float)val.index / (float)(galaxy.starCount - 1)) : 0f);
val.id = id;
val.seed = gSStar.Seed;
val.position = gSStar.position;
val.uPosition = val.position * 2400000.0;
val.planetCount = gSStar.bodyCount;
val.resourceCoef = gSStar.resourceCoef;
val.name = gSStar.Name;
val.overrideName = string.Empty;
val.mass = gSStar.mass;
val.age = gSStar.age;
val.lifetime = gSStar.lifetime;
val.temperature = gSStar.temperature;
val.luminosity = gSStar.luminosity;
val.color = gSStar.color;
val.classFactor = gSStar.classFactor;
val.radius = gSStar.radius;
val.acdiskRadius = gSStar.acDiscRadius;
val.habitableRadius = gSStar.habitableRadius;
val.lightBalanceRadius = gSStar.lightBalanceRadius;
val.orbitScaler = gSStar.orbitScaler;
val.dysonRadius = gSStar.dysonRadius;
val.type = gSStar.Type;
val.spectr = gSStar.Spectr;
if (gSStar == GSSettings.BirthStar)
{
galaxy.birthStarId = val.id;
ConfigureBirthStarHiveSettings(random, val);
}
else
{
ConfigureStarHiveSettings(random, val);
}
return val;
}
public static void CreateStarPlanets(ref StarData star, GameDesc gameDesc, Random random)
{
GSStar gSStar = GSSettings.Stars[star.index];
gSStar.counter = 0;
while (gSStar.bodyCount > 99)
{
Log($"Truncating planets for star {star.name} as it has {gSStar.bodyCount}", 15);
gSStar.Planets.RemoveAt(gSStar.Planets.Count - 1);
Warn($"New BodyCount = {gSStar.bodyCount}, existing planetCount was {star.planetCount}", 17);
star.planetCount = gSStar.bodyCount;
}
star.planets = (PlanetData[])(object)new PlanetData[Math.Min(100, gSStar.bodyCount)];
for (int i = 0; i < gSStar.PlanetCount; i++)
{
CreatePlanet(ref star, gSStar.Planets[i], random);
}
star.planetCount = star.planets.Length;
CreateDarkFogHive(star, random);
}
public static bool AbortGameStart(string message)
{
//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_007b: Expected O, but got Unknown
Error("Aborting Game Start|" + message, 7);
Failed = true;
UIRoot.instance.CloseLoadingUI();
UIRoot.instance.CloseGameUI();
UIRoot.instance.launchSplash.Restart();
DSPGame.StartDemoGame(0);
string text = "Cannot Start Game. Possibly reason: " + message;
object obj = <>c.<>9__116_0;
if (obj == null)
{
Response val = delegate
{
UIRoot.instance.OpenMainMenuUI();
UIRoot.ClearFatalError();
};
<>c.<>9__116_0 = val;
obj = (object)val;
}
UIMessageBox.Show("Somewhat Fatal Error", text, "Rats!", 3, (Response)obj);
UIRoot.ClearFatalError();
return false;
}
public static void EndGame()
{
GameMain.End();
}
public static bool IsPlanetOfStar(GSStar star, GSPlanet planet)
{
foreach (GSPlanet planet2 in star.Planets)
{
if (planet == planet2)
{
return true;
}
}
return false;
}
public static bool IsMoonOfPlanet(GSPlanet planet, GSPlanet moon)
{
foreach (GSPlanet moon2 in planet.Moons)
{
if (moon == moon2)
{
return true;
}
}
return false;
}
public static bool IsMoonOfPlanet(GSPlanet planet, GSPlanet moon, bool deep)
{
if (!deep)
{
return IsMoonOfPlanet(planet, moon);
}
foreach (GSPlanet moon2 in planet.Moons)
{
if (moon == moon2)
{
return true;
}
if (IsMoonOfPlanet(moon2, moon, deep: true))
{
return true;
}
}
return false;
}
public static GSStar GetBinaryStarHost(GSStar star)
{
if (star.Decorative)
{
foreach (GSStar star2 in GSSettings.Stars)
{
if (star2.BinaryCompanion == star.Name)
{
return star2;
}
}
}
return null;
}
public static GSStar GetGSStar(StarData star)
{
return GetGSStar(star.id);
}
public static GSStar GetGSStar(int id)
{
GSStar result = null;
if (gsStars.ContainsKey(id))
{
result = gsStars[id];
}
return result;
}
public static GSStar GetGSStar(string name)
{
foreach (KeyValuePair<int, GSStar> gsStar in gsStars)
{
GSStar value = gsStar.Value;
if (value.Name == name)
{
return value;
}
}
Error("Star not found", 68);
return null;
}
public static GSPlanet GetGSPlanet(PlanetData planet)
{
return GetGSPlanet(planet.id);
}
public static GSPlanet GetGSPlanet(string name)
{
foreach (KeyValuePair<int, GSPlanet> gsPlanet in gsPlanets)
{
GSPlanet value = gsPlanet.Value;
if (value.Name == name)
{
return value;
}
}
Error("Planet not found", 87);
return null;
}
public static GSPlanet GetGSPlanet(int vanillaID)
{
if (vanillaID < 0)
{
Warn("Failed to get GSPlanet. ID less than 0. ID:" + vanillaID, 96);
return null;
}
if (!gsPlanets.ContainsKey(vanillaID))
{
Warn("Failed to get GSPlanet. ID does not exist. ID:" + vanillaID + GetCaller(), 103);
return null;
}
if (gsPlanets[vanillaID] == null)
{
Warn("Failed to get GSPlanet. ID exists, but GSPlanet is null. ID:" + vanillaID, 110);
return null;
}
return gsPlanets[vanillaID];
}
public static GSStar GetGSStar(GSPlanet planet)
{
if (planet.planetData != null)
{
return GetGSStar(planet.planetData.star);
}
for (int i = 0; i < GSSettings.StarCount; i++)
{
for (int j = 0; j < GSSettings.Stars[i].Bodies.Count; j++)
{
if (GSSettings.Stars[i].Bodies[j] == planet)
{
return GSSettings.Stars[i];
}
}
}
Error("Failed to get GSStar. Could not find planet in GSSettings.Stars", 124);
return null;
}
}
[BepInPlugin("dsp.galactic-scale.2", "Galactic Scale 2 Plug-In", "2.77.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Bootstrap : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <>c__DisplayClass10_0
{
public TestFunction t;
internal bool <WaitUntilRoutine>b__0()
{
return t();
}
}
[CompilerGenerated]
private sealed class <WaitUntilRoutine>d__10 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public TestFunction t;
public TestThen u;
private <>c__DisplayClass10_0 <>8__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitUntilRoutine>d__10(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose