Decompiled source of Galactic Spaghetti v2.12.23

GalacticSpaghetti.dll

Decompiled 10 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("GalacticSpaghetti")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Galactic Spaghetti Generator for GS2")]
[assembly: AssemblyFileVersion("2.12.23.0")]
[assembly: AssemblyInformationalVersion("2.12.23")]
[assembly: AssemblyProduct("GalacticSpaghetti")]
[assembly: AssemblyTitle("GalacticSpaghetti")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.12.23.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace GalacticScale
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "GalacticSpaghetti";

		public const string PLUGIN_NAME = "GalacticSpaghetti";

		public const string PLUGIN_VERSION = "2.12.23";
	}
}
namespace GalacticScale.Generators
{
	[BepInPlugin("dsp.galactic-scale.2.spaghetti", "Galactic Scale 2 Spaghetti Mod", "2.12.23")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Spaghetti : BaseUnityPlugin, iConfigurableGenerator, iGenerator
	{
		public GSOptions options = new GSOptions();

		private GSGenPreferences preferences = new GSGenPreferences();

		private GSGeneratorConfig config = new GSGeneratorConfig(false, false, 1, 1024, 1, false);

		public static ManualLogSource Logger;

		public string Name => "Spaghetti";

		public string Author => "innominata";

		public string Description => "Spaghetti Generator Custom Mission";

		public string Version => "2.12.23";

		public string GUID => "space.customizing.generators.spaghetti";

		public GSGeneratorConfig Config => config;

		public GSOptions Options => options;

		public bool sauce => preferences.GetBool("sauce", true);

		public bool warned
		{
			get
			{
				return preferences.GetBool("warned", false);
			}
			set
			{
				preferences.Set("warned", (object)value);
			}
		}

		public void OnUpdate(string key, Val val)
		{
			preferences.Set(key, (object)val);
		}

		public void Init()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			GS2.Log("Initializing Spaghetti Generator", 34);
			config.MaxStarCount = 1024;
			config.MinStarCount = 1;
			options.Add(GSUI.Checkbox("Sauce?", true, "sauce", (GSOptionCallback)null, "Make the planet look stupid :D"));
			options.Add(GSUI.Button("DeSauce", "I hate sauce", new GSOptionCallback(desauce), (GSOptionPostfix)null, "Make the planet look normal :D"));
		}

		public void desauce(Val o)
		{
			GSPlanet gSPlanet = GS2.GetGSPlanet(GameMain.localPlanet);
			gSPlanet.GsTheme.oceanMaterial = Themes.OceanWorld.oceanMaterial;
			gSPlanet.GsTheme.terrainMaterial = Themes.OceanWorld.terrainMaterial;
			gSPlanet.GsTheme.Process();
		}

		public void Import(GSGenPreferences prefs)
		{
			preferences = prefs;
		}

		public GSGenPreferences Export()
		{
			return preferences;
		}

		public void Generate(int starCount, StarData forcedStar = null)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			CreateThemes();
			Random val = new Random(GSSettings.Seed);
			GSPlanet val2 = new GSPlanet("Polpetta Prime", "Pastabowl", 500, 1f, 0f, 5000f, -1f, 45f, 1000f, 0f, -1f, (GSPlanets)null);
			GSPlanets val3 = new GSPlanets();
			val3.Add(val2);
			GSPlanet val4 = new GSPlanet("Salsa", "GasGiant", 200, 2f, 90f, 5000f, 90f, 0f, 5000f, 0f, -1f, val3);
			GSStars stars = GSSettings.Stars;
			GSPlanets val5 = new GSPlanets();
			val5.Add(val4);
			GSStar val6 = stars.Add(new GSStar(1, "Aglio", (ESpectrType)7, (EStarType)3, val5));
			val6.radius = 3f;
			val6.luminosity = 10f;
			val2.randomizeVeinAmounts = false;
			val2.randomizeVeinCounts = false;
			for (int i = 0; i < starCount - 1; i++)
			{
				GSStar val7 = GSSettings.Stars.Add(new GSStar(1, "Parmesan", (ESpectrType)7, (EStarType)2, new GSPlanets()));
				val7.position = val.PointOnSphere(10.0);
			}
			GSSettings.BirthPlanetName = "Polpetta Prime";
		}

		private void CreateThemes()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00c0: Expected O, but got Unknown
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Expected O, but got Unknown
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Unknown result type (might be due to invalid IL or missing references)
			//IL_063f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0658: Unknown result type (might be due to invalid IL or missing references)
			//IL_068e: 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_06dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0881: Unknown result type (might be due to invalid IL or missing references)
			//IL_0886: Unknown result type (might be due to invalid IL or missing references)
			//IL_08af: Unknown result type (might be due to invalid IL or missing references)
			GSTheme val = new GSTheme("Pastabowl", "Pasta Bowl", "OceanWorld");
			val.Algo = 6;
			val.CustomGeneration = true;
			val.TerrainSettings = new GSTerrainSettings
			{
				Algorithm = "GSTA1",
				BaseHeight = -1.2999999523162842,
				BiomeHeightMulti = 2.0,
				BiomeHeightModifier = 0.0,
				HeightMulti = 1.0,
				LandModifier = -0.699999988079071,
				RandomFactor = 0.30000001192092896
			};
			val.VeinSettings = new GSVeinSettings
			{
				Algorithm = "GS2W",
				VeinPadding = 0.1f,
				VeinTypes = new GSVeinTypes()
			};
			val.VeinSettings.VeinTypes.Add(GSVeinType.Generate((EVeinType)1, 3000, 3000, 3f, 3f, 1, 1, false));
			val.VeinSettings.VeinTypes.Add(GSVeinType.Generate((EVeinType)2, 3000, 3000, 3f, 3f, 1, 1, false));
			val.VeinSettings.VeinTypes.Add(GSVeinType.Generate((EVeinType)6, 1000, 1000, 3f, 3f, 1, 1, false));
			val.VeinSettings.VeinTypes.Add(GSVeinType.Generate((EVeinType)5, 1000, 1000, 3f, 3f, 1, 1, false));
			val.VeinSettings.VeinTypes.Add(GSVeinType.Generate((EVeinType)4, 1000, 1000, 3f, 3f, 1, 1, false));
			val.VeinSettings.VeinTypes.Add(GSVeinType.Generate((EVeinType)3, 1000, 1000, 3f, 3f, 1, 1, false));
			val.VeinSettings.VeinTypes.Add(GSVeinType.Generate((EVeinType)7, 100, 100, 1f, 1f, 1, 1, false));
			val.VeinSettings.VeinTypes.Add(GSVeinType.Generate((EVeinType)13, 200, 200, 3f, 3f, 1, 1, false));
			val.VeinSettings.VeinTypes.Add(GSVeinType.Generate((EVeinType)11, 200, 200, 3f, 3f, 1, 1, false));
			val.VeinSettings.VeinTypes.Add(GSVeinType.Generate((EVeinType)12, 200, 200, 3f, 3f, 1, 1, false));
			val.VeinSettings.VeinTypes.Add(GSVeinType.Generate((EVeinType)14, 200, 200, 3f, 3f, 1, 1, false));
			val.VeinSettings.VeinTypes.Add(GSVeinType.Generate((EVeinType)9, 200, 200, 3f, 3f, 1, 1, false));
			val.VeinSettings.VeinTypes.Add(GSVeinType.Generate((EVeinType)8, 400, 400, 3f, 3f, 1, 1, false));
			val.VeinSettings.VeinTypes.Add(GSVeinType.Generate((EVeinType)10, 200, 200, 3f, 3f, 1, 1, false));
			val.VegeSettings = new GSVegeSettings
			{
				Algorithm = "GS2",
				Group1 = new List<string>(),
				Group2 = new List<string> { "MedStone5", "MedStone4", "MedStone5", "MedStone3", "MedStone4", "MedFragment6", "MedFragment7", "MedFragment8", "MedFragment7", "MedFragment8" },
				Group3 = new List<string>
				{
					"MedStone5", "MedStone5", "MedStone5", "MedStone4", "MedStone5", "MedStone3", "MedStone4", "MedFragment6", "MedFragment7", "MedFragment8",
					"MedFragment7", "MedFragment8"
				},
				Group4 = new List<string> { "RedStoneTree5", "MedFragment6", "MedFragment7", "MedFragment8", "MedFragment7", "MedFragment8" },
				Group5 = new List<string> { "MedFragment6", "MedFragment7", "MedFragment8", "MedFragment7", "MedFragment8" },
				Group6 = new List<string> { "RedStoneTree5", "RedStoneTree5", "RedStoneTree5", "RedStoneTree5", "RedStoneTree5" }
			};
			val.Wind = 2f;
			val.WaterItemId = 1000;
			if (sauce)
			{
				val.oceanMaterial.CopyFrom = "Lava.oceanMat";
				val.terrainMaterial.CopyFrom = "Gobi.terrainMat";
				val.oceanMaterial.Colors["_Color0"] = new Color
				{
					r = 1f,
					g = 0.36f,
					b = 0.2f,
					a = 1f
				};
				val.oceanMaterial.Colors["_Color1"] = new Color
				{
					r = 0.6f,
					g = 0.15f,
					b = 0.06f,
					a = 1f
				};
				val.oceanMaterial.Colors["_Color2"] = new Color
				{
					r = 0.22f,
					g = 0.04f,
					b = 0.02f,
					a = 0.8f
				};
				val.oceanMaterial.Colors["_Color3"] = new Color
				{
					r = 0.6f,
					g = 0.2f,
					b = 0.1f,
					a = 1f
				};
				val.oceanMaterial.Params["_ChaosDistort"] = 0.45f;
				val.oceanMaterial.Params["_ChaosOverlay"] = 0.95f;
				val.oceanMaterial.Params["_ChaosTile"] = 1.5f;
				val.oceanMaterial.Params["_NoiseSpeed"] = 0.25f;
				val.oceanMaterial.Params["_NoiseTile"] = 1200f;
				val.oceanMaterial.Params["_RimPower"] = 4f;
				val.oceanMaterial.Params["_RotSpeed"] = 0.0005f;
				val.oceanMaterial.Params["_SpotIntens"] = 5f;
				val.terrainMaterial.Params["_Multiplier"] = 0.8f;
				val.terrainMaterial.Colors.Add("_SpeclColor", new Color(0f, 0f, 0f, 1f));
				val.terrainMaterial.Textures = new Dictionary<string, string>();
				val.terrainMaterial.Textures.Add("_BioTex0A", "GS2|grey-snow");
				val.terrainMaterial.Textures.Add("_BioTex1A", "GS2|grey-snow");
				val.terrainMaterial.Textures.Add("_BioTex2A", "GS2|grey-snow");
				val.terrainMaterial.Tint = new Color(0.95f, 0.95f, 0.8f, 1f);
				val.oceanMaterial.Colors["_Color"] = new Color(0.8f, 0.4f, 0.4f, 0.8f);
			}
			val.Process();
		}

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			Logger = new ManualLogSource("GS2Spaghetti");
			Logger.Sources.Add((ILogSource)(object)Logger);
			Logger.Log((LogLevel)8, (object)"Loaded");
			GS2.Generators.Add((iGenerator)(object)this);
			GS2.Warn("Test", 231);
			Harmony.CreateAndPatchAll(typeof(Spaghetti), (string)null);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIBuildMenu), "OnVeinBuriedClick")]
		public static void OnVeinBuriedClick(ref UIBuildMenu __instance)
		{
			Spaghetti spaghetti = GS2.GetGeneratorByID("space.customizing.generators.spaghetti") as Spaghetti;
			if (((List<GSStar>)(object)GSSettings.Stars)[0].Name == "Aglio" && GSSettings.Instance.generatorGUID == null)
			{
				GSSettings.Instance.generatorGUID = "space.customizing.generators.spaghetti";
			}
			if (!(GSSettings.Instance.generatorGUID != "space.customizing.generators.spaghetti"))
			{
				__instance.reformTool.buryVeins = false;
				GS2.Log("Click", 245);
				if (!spaghetti.warned)
				{
					UIMessageBox.Show(Localization.Translate("Spaghetti"), Localization.Translate("It would be too easy if you could just bury veins!"), Localization.Translate("I agree!"), 0);
					spaghetti.warned = true;
					GS2.SavePreferences();
				}
				Player mainPlayer = GameMain.mainPlayer;
				mainPlayer.sandCount += 99999;
			}
		}
	}
}