diff --git a/GalacticScale2/DSP_Plugins.GalacticScale.csproj b/GalacticScale2/DSP_Plugins.GalacticScale.csproj index c9c8ec86..db526faa 100644 --- a/GalacticScale2/DSP_Plugins.GalacticScale.csproj +++ b/GalacticScale2/DSP_Plugins.GalacticScale.csproj @@ -42,7 +42,6 @@ - 2018.4.12 runtime; build; native; contentfiles; analyzers; buildtransitive @@ -53,8 +52,8 @@ ..\packages\HarmonyX.2.5.5\lib\net45\0Harmony.dll - - ..\packages\DysonSphereProgram.GameLibs.0.8.23.9989-r.0\lib\net45\Assembly-CSharp.dll + + ..\..\..\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\DSPGAME_Data\Managed\publicized_assemblies\Assembly-CSharp_publicized.dll ..\packages\BepInEx.BaseLib.5.4.16\lib\net35\BepInEx.dll diff --git a/GalacticScale2/Scripts/Bootstrap.cs b/GalacticScale2/Scripts/Bootstrap.cs index db019d15..44f07e11 100644 --- a/GalacticScale2/Scripts/Bootstrap.cs +++ b/GalacticScale2/Scripts/Bootstrap.cs @@ -20,7 +20,7 @@ public partial class GS2 [BepInDependency(NebulaAPI.NebulaModAPI.API_GUID)] public class Bootstrap : BaseUnityPlugin { - public const string VERSION = "2.2.0.16"; + public const string VERSION = "2.2.0.23"; public new static ManualLogSource Logger; diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Galaxy Generation/ProcessGalaxy.cs b/GalacticScale2/Scripts/GalacticScale2.0/Galaxy Generation/ProcessGalaxy.cs index 0737acd1..fc8f0619 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Galaxy Generation/ProcessGalaxy.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Galaxy Generation/ProcessGalaxy.cs @@ -9,7 +9,7 @@ public static partial class GS2 { public static GalaxyData ProcessGalaxy(GameDesc desc, bool sketchOnly = false) { - Log($"Start ProcessGalaxy:{sketchOnly} StarCount:{gameDesc.starCount} Seed:{gameDesc.galaxySeed} Called By{GetCaller()}"); + Log($"Start ProcessGalaxy:{sketchOnly} StarCount:{gameDesc.starCount} Seed:{gameDesc.galaxySeed} Called By{GetCaller()}. Galaxy StarCount : {galaxy?.stars?.Length}"); var random = new Random(GSSettings.Seed); try { diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Orbits.cs b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Orbits.cs index b61d21bc..07346783 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Orbits.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Orbits.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using UnityEngine; namespace GalacticScale.Generators @@ -31,24 +32,27 @@ public void NamePlanets(GSStar star) private void AssignPlanetOrbits(GSStar star) { - // GS2.Warn("Start:"+star.Planets.Count); + GS2.Warn($"-------------------------------------------------------------------------------"); + GS2.Warn($"--{star.Name}-----------------------------------------------------------------------------"); + GS2.Warn($"--{star.displayType}-----------------------------------------------------------------------------"); + GS2.Warn($"Assigning Planet Orbits for {star.Name}:{star.Planets.Count} planets to assign"); var r = new GS2.Random(star.Seed); var orbits = new List(); ref var planets = ref star.Planets; var brokenPlanets = new GSPlanets(); planets.Sort(PlanetSortBySystemRadius); - // GS2.WarnJson((from s in planets select s.details).ToList()); + GS2.WarnJson((from s in planets select s.details).ToList()); CalculateHabitableZone(star); var minimumOrbit = CalculateMinimumOrbit(star); var maximumOrbit = CalculateMaximumOrbit(star); + GS2.Warn($"Minimum Orbit:{minimumOrbit} Maximum Orbit:{maximumOrbit}"); var freeOrbitRanges = new List<(float inner, float outer)>(); //Warn("Orbit Count 0"); if (star == birthStar) { var birthRadius = Mathf.Clamp(r.NextFloat(star.genData.Get("minHZ").Float(0f), star.genData.Get("maxHZ").Float(100f)), star.RadiusAU * 1.5f, 100f); - //Warn( - //$"Selected Orbit {birthRadius} for planet {birthPlanet.Name}. Hz:{star.genData.Get("minHZ").Float(0f)}-{star.genData.Get("maxHZ").Float(100f)}"); + GS2.Warn($"Selected Orbit {birthRadius} for planet {birthPlanet.Name}. Hz:{star.genData.Get("minHZ").Float(0f)}-{star.genData.Get("maxHZ").Float(100f)}"); var orbit = new Orbit(birthRadius); orbit.planets.Add(birthPlanet); birthPlanet.OrbitRadius = birthRadius; @@ -65,12 +69,12 @@ private void AssignPlanetOrbits(GSStar star) freeOrbitRanges.Add((minimumOrbit, maximumOrbit)); } - // GS2.Warn("Begin Loop:" + star.Planets.Count); + GS2.Warn("Begin Loop:" + star.Planets.Count); for (var i = 0; i < planets.Count; i++) { Orbit orbit; var planet = planets[i]; - // GS2.Log($"Finding Orbit for planet index {i} - {planet.Name}"); + GS2.Log($"Finding Orbit for planet index {i} - {planet.Name}"); if (planet == birthPlanet) // planet.Name += " BIRTH"; continue; @@ -79,25 +83,31 @@ private void AssignPlanetOrbits(GSStar star) //planet.OrbitInclination = 0f; - // Log($"Orbit Count > 1. Free orbit range count = {freeOrbitRanges.Count}"); + GS2.Log($"Orbit Count > 1. Free orbit range count = {freeOrbitRanges.Count}"); var availableOrbits = new List<(float inner, float outer)>(); foreach (var range in freeOrbitRanges) - // GS2.Log($"Free orbits:{range}. Checking SystemRadius:{planet.SystemRadius}. {(0.05f+ 2 * planet.SystemRadius)}"); + { + GS2.Log($"Free orbits:{range}. Checking SystemRadius:{planet.SystemRadius}. {(0.05f + 2 * planet.SystemRadius)}"); + + if (range.outer - range.inner > 0.05f + 2 * planet.SystemRadius) + { //(1 + 1 * (GetSystemDensityBiasForStar(star) / 50)) * 2*planet.SystemRadius) - // Log($"Adding {range}"); + GS2.Log($"Adding {range}"); availableOrbits.Add(range); + } + } - if (availableOrbits.Count == 0) + if (availableOrbits.Count == 0) { - // Warn("Free Orbit Ranges:"); - // LogJson(freeOrbitRanges); - // Warn($"No Orbit Ranges found for planet {planet.Name} {planet.genData["hosttype"]} {planet.genData["hostname"]} radius:{planet.SystemRadius}"); + GS2.Warn("Free Orbit Ranges:"); + GS2.LogJson(freeOrbitRanges); + GS2.Warn($"No Orbit Ranges found for planet {planet.Name} {planet.genData["hosttype"]} {planet.genData["hostname"]} radius:{planet.SystemRadius}"); var success = false; foreach (var existingOrbit in orbits) if (existingOrbit.hasRoom && existingOrbit.SystemRadius > planet.SystemRadius) { - // Warn($"Existing orbit {existingOrbit.radius} used for planet {planet.Name}"); + GS2.Warn($"Existing orbit {existingOrbit.radius} used for planet {planet.Name}"); existingOrbit.planets.Add(planet); planet.OrbitRadius = existingOrbit.radius; planet.OrbitalPeriod = Utils.CalculateOrbitPeriod(planet.OrbitRadius); @@ -105,7 +115,7 @@ private void AssignPlanetOrbits(GSStar star) break; } - // GS2.Log($"{planet.Name} orbit radius {planet.OrbitRadius}"); + GS2.Log($"{planet.Name} orbit radius {planet.OrbitRadius}"); if (success) continue; GS2.Warn($"After all that, just couldn't find an orbit for {planet.Name} {planet.genData["hosttype"]} {planet.genData["hostname"]} . Throwing planet into the sun."); @@ -118,20 +128,22 @@ private void AssignPlanetOrbits(GSStar star) if (availableOrbits.Count == 0) - // GS2.Log($"No Available Orbits Found for Planet {planet.Name}"); + { + GS2.Log($"No Available Orbits Found for Planet {planet.Name}"); continue; + } var selectedRange = r.Item(availableOrbits); - // GS2.Log($"radius = r.NextFloat({selectedRange.inner + planet.SystemRadius}, {selectedRange.outer - planet.SystemRadius})"); + GS2.Log($"radius = r.NextFloat({selectedRange.inner + planet.SystemRadius}, {selectedRange.outer - planet.SystemRadius})"); var radius = r.NextFloat(selectedRange.inner + planet.SystemRadius, selectedRange.outer - planet.SystemRadius); freeOrbitRanges.Remove(selectedRange); orbit = new Orbit(radius); orbit.planets.Add(planet); planet.OrbitRadius = radius; - // GS2.Log($"-{planet.Name} orbit radius {planet.OrbitRadius}"); + GS2.Log($"-{planet.Name} orbit radius {planet.OrbitRadius}"); planet.OrbitalPeriod = Utils.CalculateOrbitPeriod(planet.OrbitRadius); - // Log( - // $"selected orbit({radius}) for {planet.Name}({planet.SystemRadius}) SelectedRange:{selectedRange.inner}, {selectedRange.outer} New Ranges: {selectedRange.inner},{radius - planet.SystemRadius}({radius - planet.SystemRadius - selectedRange.inner}) | {radius + planet.SystemRadius}, {selectedRange.outer}({selectedRange.outer - radius - planet.SystemRadius})"); + GS2.Warn( + $"selected orbit({radius}) for {planet.Name}({planet.SystemRadius}) SelectedRange:{selectedRange.inner}, {selectedRange.outer} New Ranges: {selectedRange.inner},{radius - planet.SystemRadius}({radius - planet.SystemRadius - selectedRange.inner}) | {radius + planet.SystemRadius}, {selectedRange.outer}({selectedRange.outer - radius - planet.SystemRadius})"); orbits.Add(orbit); var minGap = 0.1f; diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Stars.cs b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Stars.cs index 8a84d98f..8555e4ad 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Stars.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Generators/GS2Dev/Stars.cs @@ -197,6 +197,7 @@ private int ParsePlanetSize(int size) private FloatPair CalculateHabitableZone(GSStar star) { + GS2.Warn($"Calculating Habitable Zone for {star.Name}"); var lum = star.luminosity; var flp = Utils.CalculateHabitableZone(lum); var min = flp.low; @@ -213,22 +214,23 @@ private FloatPair CalculateHabitableZone(GSStar star) if (star.genData.Get("hasBinary", false)) { - // GS2.Warn($"{star.Name} Binary offset : {star.genData.Get("binaryOffset", 1f)}"); - // GS2.Warn($"Increasing by {star.genData.Get("binaryOffset", 1)*60f}"); - // GS2.Warn($"Star RadiusAU:{star.RadiusAU}"); - // GS2.WarnJson(GSSettings.Stars.Select(o=>(o.Name,o.RadiusAU)).ToList()); + GS2.Warn($"{star.Name} Binary offset : {star.genData.Get("binaryOffset", 1f)}"); + GS2.Warn($"Increasing by {star.genData.Get("binaryOffset", 1)*60f}"); + GS2.Warn($"Star RadiusAU:{star.RadiusAU}"); + GS2.WarnJson(GSSettings.Stars.Select(o=>(o.Name,o.RadiusAU)).ToList()); min += star.genData.Get("binaryOffset", 1f) * 60f; max += star.genData.Get("binaryOffset", 1f) * 60f; } star.genData.Set("minHZ", min); star.genData.Set("maxHZ", max); - // GS2.Warn($"HZ of {star.Name} {min}:{max}"); + GS2.Warn($"HZ of {star.Name} {min}:{max}"); return new FloatPair(min, max); } private float CalculateMinimumOrbit(GSStar star) { + Warn($"Calculating Minimum Orbit for {star.Name}"); var sl = GetTypeLetterFromStar(star); var radius = star.RadiusAU; @@ -237,21 +239,27 @@ private float CalculateMinimumOrbit(GSStar star) if (preferences.GetBool($"{sl}orbitOverride")) { + var fp = preferences.GetFloatFloat($"{sl}orbits", new FloatPair(0.02f, 20f)); + Warn($"Using Star Type Override {fp.low}"); min = fp.low; } - if (star.genData.Get("hasBinary", false)) min += star.genData.Get("binaryOffset", 1f) * 60f; + if (star.genData.Get("hasBinary", false)) + { + Warn("Increasing for Binary"); + min += star.genData.Get("binaryOffset", 1f) * 60f; + } min = Clamp(min, radius * 1.1f, 100f); star.genData.Set("minOrbit", min); - // Warn($"Getting Min Orbit for Star {star.Name} Min:{min}"); + Warn($"Getting Min Orbit for Star {star.Name} Min:{min}"); return min; } private float CalculateMaximumOrbit(GSStar star) { var sl = GetTypeLetterFromStar(star); - + Warn($"Calculating Maximum Orbit for {star.Name}"); var minMaxOrbit = 5f; var lum = star.luminosity; var hzMax = star.genData.Get("maxHZ"); @@ -264,12 +272,19 @@ private float CalculateMaximumOrbit(GSStar star) var max = Clamp(Max(maxByPlanetCount, minMaxOrbit, maxOrbitByLuminosity, maxOrbitByRadius, maxOrbitByHabitableZone), star.genData.Get("minOrbit") * 2f, star.MaxOrbit); if (preferences.GetBool($"{sl}orbitOverride")) { + var fp = preferences.GetFloatFloat($"{sl}orbits", new FloatPair(0.02f, 20f)); max = fp.high; + Warn($"Using Star Type Override {fp.high} from {fp} in {sl}orbits"); } - // Warn($"Getting Max Orbit for Star {star.Name} HardCap:{star.MaxOrbit} MaxbyRadius({star.radius}):{maxOrbitByRadius} MaxbyPlanets({star.PlanetCount}):{maxByPlanetCount} MaxbyLum({lum}):{maxOrbitByLuminosity} MaxByHZ({hzMax}):{maxOrbitByHabitableZone} Max({max}):{max} HabitableZone:{star.genData.Get("minHZ")}:{hzMax}"); - if (star.genData.Get("hasBinary", false)) max += star.genData.Get("binaryOffset", 1f) * 60f; + Warn($"Getting Max Orbit for Star {star.Name}\r\n HardCap:{star.MaxOrbit} \r\nMaxbyRadius({star.radius}):{maxOrbitByRadius} \r\nMaxbyPlanets({star.PlanetCount}):{maxByPlanetCount} \r\nMaxbyLum({lum}):{maxOrbitByLuminosity} \r\nMaxByHZ({hzMax}):{maxOrbitByHabitableZone} \r\n HabitableZone:{star.genData.Get("minHZ")}:{hzMax}"); + Warn($"Final Max({max}):{max}"); + if (star.genData.Get("hasBinary", false)) + { + Warn("Increasing Max Orbit for Binary"); + max += star.genData.Get("binaryOffset", 1f) * 60f; + } star.genData.Set("maxOrbit", max); return max; } diff --git a/GalacticScale2/Scripts/GalacticScale2.0/IO/Json.cs b/GalacticScale2/Scripts/GalacticScale2.0/IO/Json.cs index 69212367..044b31f8 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/IO/Json.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/IO/Json.cs @@ -104,24 +104,24 @@ public static GSTheme LoadJsonTheme(string filename) public static bool LoadSettingsFromJson(string path) { - // Log("Start"); + Log("Start"); if (!CheckJsonFileExists(path)) return false; - // Log("Path = " + path); + Log("Path = " + path); var serializer = new fsSerializer(); GSSettings.Stars.Clear(); - // Log("Initializing ThemeLibrary"); + Log("Initializing ThemeLibrary"); GSSettings.ThemeLibrary = ThemeLibrary.Vanilla(); GSSettings.GalaxyParams = new GSGalaxyParams(); - // Log("Reading JSON"); + Log("Reading JSON"); var json = File.ReadAllText(path); var result = GSSettings.Instance; - // Log("Parsing JSON"); + Log("Parsing JSON"); var data = fsJsonParser.Parse(json); - // Log("Trying To Deserialize JSON"); + Log("Trying To Deserialize JSON"); serializer.TryDeserialize(data, ref result); - // LogJson(result.galaxyParams); - // Log("End"); + LogJson(result.galaxyParams); + Log("End"); return true; } diff --git a/GalacticScale2/Scripts/GalacticScale2.0/IO/Save_Load.cs b/GalacticScale2/Scripts/GalacticScale2.0/IO/Save_Load.cs index eb48c4dd..88f3c910 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/IO/Save_Load.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/IO/Save_Load.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using GSSerializer; namespace GalacticScale @@ -15,53 +16,85 @@ public static void Export(BinaryWriter w) // Export Settings to Save Game w.Write(json); } - public static bool Import(BinaryReader r) // Load Settings from Save Game + public static bool Import(BinaryReader r, string Force = "") // Load Settings from Save Game { + Log("Importing from Save"); - GSSettings.Reset(0); + if (!GS2.SaveOrLoadWindowOpen) GSSettings.Reset(0); var serializer = new fsSerializer(); var position = r.BaseStream.Position; - var version = r.ReadString(); - var json = r.ReadString(); - if (Config.Dev) + var version = "2"; + var json = ""; + if (Force == "") { - File.WriteAllText(Path.Combine(GS2.DataDir, "SaveContentsRaw.txt"),json); + version = r.ReadString(); + json = r.ReadString(); + } + else + { + LoadSettingsFromJson(Force); } - var result = GSSettings.Instance; - fsData data2; - var parseResult = fsJsonParser.Parse(json, out data2); - if (parseResult.Failed) + if (GS2.SaveOrLoadWindowOpen) return true; + if (Config.Dev) { - Warn("Parse Failed"); - r.BaseStream.Position = position; - ActiveGenerator = GetGeneratorByID("space.customizing.generators.vanilla"); - return false; + File.WriteAllText(Path.Combine(GS2.DataDir, "SaveContentsRaw.txt"), json); } + GSSettings result = new GSSettings(0); + if (Force == "" && !SaveOrLoadWindowOpen) result = GSSettings.Instance; + fsData data2; + var parseResult = fsJsonParser.Parse(json, out data2); + // if (Force == "") + // { + if (parseResult.Failed) + { + Warn("Parse Failed"); + if (Force == "") r.BaseStream.Position = position; + if (Force == "") ActiveGenerator = GetGeneratorByID("space.customizing.generators.vanilla"); + if (Force == "") return false; + } + // } + if (Config.Dev) { File.WriteAllText(Path.Combine(GS2.DataDir, "SaveContents.json"),json); } - var deserialize = serializer.TryDeserialize(data2, ref result); - if (deserialize.Failed) + + try + { + var deserialize = serializer.TryDeserialize(data2, ref result); + // if (Force == "") + // { + if (deserialize.Failed) + { + Warn("Deserialize Failed"); + if (Force == "")r.BaseStream.Position = position; + if (Force == "")ActiveGenerator = GetGeneratorByID("space.customizing.generators.vanilla"); + if (Force == "")return false; + } + // } + // else + // { + // Warn("Loading Forced Json Settings"); + // LoadSettingsFromJson(Force); + // } + } + catch (Exception e) { - Warn("Deserialize Failed"); - r.BaseStream.Position = position; - ActiveGenerator = GetGeneratorByID("space.customizing.generators.vanilla"); - return false; + GS2.Warn($"{e.Message}"); } if (version != GSSettings.Instance.version) { Warn("Version mismatch: " + GSSettings.Instance.version + " trying to load " + version + " savedata"); - r.BaseStream.Position = position; - ActiveGenerator = GetGeneratorByID("space.customizing.generators.vanilla"); - return false; + if (Force == "") r.BaseStream.Position = position; + if (Force == "" && !SaveOrLoadWindowOpen)ActiveGenerator = GetGeneratorByID("space.customizing.generators.vanilla"); + if (Force == "")return false; } if (Vanilla) ActiveGenerator = GetGeneratorByID("space.customizing.generators.gs2dev"); - GSSettings.Instance = result; + if (Force == "" && !SaveOrLoadWindowOpen) GSSettings.Instance = result; GSSettings.Instance.imported = true; return true; } diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Init.cs b/GalacticScale2/Scripts/GalacticScale2.0/Init.cs index 2dbe1d22..3452cf98 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Init.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Init.cs @@ -21,7 +21,7 @@ public static partial class GS2 public static bool canvasOverlay = false; public static bool ResearchUnlocked = false; public static Image splashImage; - + public static bool SaveOrLoadWindowOpen = false; public static bool NebulaClient = false; // public static bool MinifyJson = false; diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/-Debug/Debug.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/-Debug/Debug.cs index 73902391..cb0075d5 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/-Debug/Debug.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/-Debug/Debug.cs @@ -8,6 +8,51 @@ namespace GalacticScale { public class PatchOnWhatever { + [HarmonyPrefix, HarmonyPatch(typeof(UILoadGameWindow), "_OnOpen")] + public static bool UILoadGameWindow_OnOpen() + { + GS2.Warn("Disabled Import"); + GS2.SaveOrLoadWindowOpen = true; + return true; + + } + + [HarmonyPrefix, HarmonyPatch(typeof(UILoadGameWindow), "LoadSelectedGame")] + public static bool UILoadGameWindow_LoadSelectedGame() + { + GS2.Warn("Enabled Import"); + GS2.SaveOrLoadWindowOpen = false; + return true; + + } + + [HarmonyPrefix, HarmonyPatch(typeof(UILoadGameWindow), "_OnClose")] + public static bool UILoadGameWindow_OnClose() + { + GS2.Warn("Enabled Import"); + + GS2.SaveOrLoadWindowOpen = false; + return true; + } + [HarmonyPrefix, HarmonyPatch(typeof(UISaveGameWindow), "_OnOpen")] + public static bool UISaveGameWindow_OnOpen() + { + GS2.Warn("Disabled Import"); + + GS2.SaveOrLoadWindowOpen = true; + return true; + + } + + + [HarmonyPrefix, HarmonyPatch(typeof(UISaveGameWindow), "_OnClose")] + public static bool UISaveGameWindow_OnClose() + { + GS2.Warn("Enabled Import"); + + GS2.SaveOrLoadWindowOpen = false; + return true; + } [HarmonyPrefix, HarmonyPatch(typeof(UIAchievementPanel), "LoadData")] public static bool LoadData(UIAchievementPanel __instance) { diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/BuildTool_Click/DeterminePreviews.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/BuildTool_Click/DeterminePreviews.cs index ba6bed9c..32e95463 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/BuildTool_Click/DeterminePreviews.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/BuildTool_Click/DeterminePreviews.cs @@ -60,6 +60,8 @@ public static bool DeterminePreviews(ref BuildTool_Click __instance) } var flag = !__instance.multiLevelCovering && __instance.handPrefabDesc.dragBuild; + if (__instance.handPrefabDesc.geothermal && VFInput._ignoreGrid) + flag = false; if (VFInput._buildConfirm.onDown && __instance.controller.cmd.stage != 1) { __instance.controller.cmd.stage = 1; @@ -99,7 +101,7 @@ public static bool DeterminePreviews(ref BuildTool_Click __instance) } } - if (VFInput._ignoreGrid && __instance.handPrefabDesc.minerType == EMinerType.Vein) + if (VFInput._ignoreGrid && __instance.handPrefabDesc.minerType == EMinerType.Vein|| __instance.handPrefabDesc.geothermal) { if (VFInput._rotate) { diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/GameDesc/Export.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/GameDesc/Export.cs index 92e4474f..48a69527 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/GameDesc/Export.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/GameDesc/Export.cs @@ -9,6 +9,7 @@ public static partial class PatchOnGameDesc [HarmonyPatch(typeof(GameDesc), "Export")] public static void Export(BinaryWriter w) { + GS2.Warn("Exporting"); if (GS2.IsMenuDemo || GS2.Vanilla) return; var minify = GS2.Config.MinifyJson; GS2.Config.MinifyJson = false; diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/GameDesc/Import.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/GameDesc/Import.cs index 48757627..a554c0a0 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/GameDesc/Import.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/GameDesc/Import.cs @@ -11,8 +11,14 @@ public static void Import(BinaryReader r, ref GameDesc __instance) { if (!GS2.IsMenuDemo) { + var ForceFile = Path.Combine(GS2.DataDir, "ForceImport.json"); GS2.Log("Not Menu Demo. Importing"); - GS2.Import(r); + if (VFInput.shift && File.Exists(ForceFile)) + { + GS2.Warn("LOADING GALAXY DESC FROM ForceImport.json"); + GS2.Import(r, ForceFile); + } + else GS2.Import(r); GS2.Log("Unsetting Cheatmode"); GS2.Log("Setting option"); if (GS2.Config?.CheatMode != null) GS2.Config.DisableCheatMode(); diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/GameLoader/FixedUpdate.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/GameLoader/FixedUpdate.cs index 4d0e1fc3..c228de25 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/GameLoader/FixedUpdate.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/GameLoader/FixedUpdate.cs @@ -65,7 +65,7 @@ public static bool FixedUpdate(ref GameLoader __instance) if (!GameMain.instance.isMenuDemo) { var str = ""; - for (var index = GameMain.data.patch + 1; index <= 2; ++index) + for (var index = GameMain.data.patch + 1; index <= 3; ++index) str = str + "\r\n" + ("存档补丁提示" + index).Translate(); if (!string.IsNullOrEmpty(str)) diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/StationComponent/InternalTickRemote.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/StationComponent/InternalTickRemote.cs index 665dedf6..e27d7f99 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/StationComponent/InternalTickRemote.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/StationComponent/InternalTickRemote.cs @@ -2,1028 +2,1103 @@ using System.Collections.Generic; using System.Linq; using System.Reflection.Emit; +using System.Runtime.Remoting.Messaging; using HarmonyLib; using UnityEngine; namespace GalacticScale { - public class PatchOnStationComponent - { - // Strategy: find where replace all ldc.i4.s 10 instructions with dynamic references to the relevant star's planetCount - // - // GameMain.galaxy.PlanetById(int) returns null if not a planet, otherwise PlanetData - /* 0x0002D43D 7E05130004 */ // IL_000D: callVirt class GalaxyData GameMain::get_galaxy - // IL_xxxx: See below for how we find the right planet ID - // IL_xxxx: callVirt class PlanetData GalaxyData::PlanetById(int) - // - // From there, PlanetData.star.planetCount gets what we need. - // - // Finding the planetID: - // First, the C# code at this time: - // int num43 = shipData.planetA / 100 * 100; //this is later passed to astroPoses[i] and it basically represents a planet ID. - // int num44 = shipData.planetB / 100 * 100; //this is later passed to astroPoses[i] and it basically represents a planet ID. - // for (int k = num43; k Transpiler(IEnumerable instructions) - // { - // var codes = new List(instructions); - // for (var i = 0; i < codes.Count; i++) - // if (codes[i].opcode == OpCodes.Ldc_I4_S && codes[i].OperandIs(10)) - // { - // var newInstructions = new List(); - // newInstructions.Add(new CodeInstruction(codes[i - 1])); //The line before adding 10 is the line which loads in the planet ID we care about, so copy it - // newInstructions.Add(Transpilers.EmitDelegate(bodyID => - // // We add 1 to the body ID because it was originally an index in the astroPoses array but we need the actual ID of it. - // // We add 1 to the planet count because the loop is <, not <= - // GameMain.galaxy.PlanetById(bodyID + 1).star.planetCount + 1)); - // codes.RemoveAt(i); // Remove the original loading of 10 - // codes.InsertRange(i, newInstructions); //Instead, load the count of planets around the target star (plus one) - // } - // - // return codes.AsEnumerable(); - // } + public class PatchOnStationComponent + { + // Strategy: find where replace all ldc.i4.s 10 instructions with dynamic references to the relevant star's planetCount + // + // GameMain.galaxy.PlanetById(int) returns null if not a planet, otherwise PlanetData + /* 0x0002D43D 7E05130004 */ // IL_000D: callVirt class GalaxyData GameMain::get_galaxy + // IL_xxxx: See below for how we find the right planet ID + // IL_xxxx: callVirt class PlanetData GalaxyData::PlanetById(int) + // + // From there, PlanetData.star.planetCount gets what we need. + // + // Finding the planetID: + // First, the C# code at this time: + // int num43 = shipData.planetA / 100 * 100; //this is later passed to astroPoses[i] and it basically represents a planet ID. + // int num44 = shipData.planetB / 100 * 100; //this is later passed to astroPoses[i] and it basically represents a planet ID. + // for (int k = num43; k Transpiler(IEnumerable instructions) + // { + // var codes = new List(instructions); + // for (var i = 0; i < codes.Count; i++) + // if (codes[i].opcode == OpCodes.Ldc_I4_S && codes[i].OperandIs(10)) + // { + // var newInstructions = new List(); + // newInstructions.Add(new CodeInstruction(codes[i - 1])); //The line before adding 10 is the line which loads in the planet ID we care about, so copy it + // newInstructions.Add(Transpilers.EmitDelegate(bodyID => + // // We add 1 to the body ID because it was originally an index in the astroPoses array but we need the actual ID of it. + // // We add 1 to the planet count because the loop is <, not <= + // GameMain.galaxy.PlanetById(bodyID + 1).star.planetCount + 1)); + // codes.RemoveAt(i); // Remove the original loading of 10 + // codes.InsertRange(i, newInstructions); //Instead, load the count of planets around the target star (plus one) + // } + // + // return codes.AsEnumerable(); + // } - private delegate int Del(int bodyID); - [HarmonyPrefix, HarmonyPatch(typeof(StationComponent), "InternalTickRemote")] - public static bool InternalTickRemote( ref StationComponent __instance, - int timeGene, - double dt, - float shipSailSpeed, - float shipWarpSpeed, - int shipCarries, - StationComponent[] gStationPool, - AstroPose[] astroPoses, - VectorLF3 relativePos, - Quaternion relativeRot, - bool starmap, - int[] consumeRegister) - { - bool canWarp = (double) shipWarpSpeed > (double) shipSailSpeed + 1.0; - __instance.warperFree = DSPGame.IsMenuDemo; - if (__instance.warperCount < __instance.warperMaxCount) + private delegate int Del(int bodyID); + + [HarmonyPrefix, HarmonyPatch(typeof(StationComponent), "InternalTickRemote")] + public static bool InternalTickRemote(StationComponent __instance, PlanetFactory factory, int timeGene, double dt, float shipSailSpeed, float shipWarpSpeed, int shipCarries, StationComponent[] gStationPool, AstroPose[] astroPoses, VectorLF3 relativePos, Quaternion relativeRot, bool starmap, int[] consumeRegister) { - lock (__instance.storage) + bool canWarp = (double)shipWarpSpeed > (double)shipSailSpeed + 1.0; + __instance.warperFree = DSPGame.IsMenuDemo; + if (__instance.warperCount < __instance.warperMaxCount) { - for (int index = 0; index < __instance.storage.Length; ++index) + lock (__instance.storage) { - if (__instance.storage[index].itemId == 1210 && __instance.storage[index].count > 0) + for (int index = 0; index < __instance.storage.Length; ++index) { - ++__instance.warperCount; - --__instance.storage[index].count; - break; + if (__instance.storage[index].itemId == 1210 && __instance.storage[index].count > 0) + { + ++__instance.warperCount; + int num = (int)((double)__instance.storage[index].inc / (double)__instance.storage[index].count + 0.5); + --__instance.storage[index].count; + __instance.storage[index].inc -= num; + break; + } } } } - } - int num1 = 0; - int num2 = 0; - int num3 = 0; - int num4 = 0; - int num5 = 0; - int num6 = 0; - int num7 = 0; - int num8 = 0; - int num9 = 0; - int num10 = 0; - int num11 = 0; - int num12 = 0; - int num13 = 0; - int num14 = 0; - if (timeGene == __instance.gene) - { - ++__instance._tmp_iter_remote; - if (__instance.remotePairCount > 0 && __instance.idleShipCount > 0) + + int num1 = 0; + int num2 = 0; + int num3 = 0; + int num4 = 0; + int num5 = 0; + int num6 = 0; + int num7 = 0; + int num8 = 0; + int num9 = 0; + int num10 = 0; + int num11 = 0; + int num12 = 0; + int num13 = 0; + int num14 = 0; + int num15 = 0; + int num16 = 0; + if (timeGene == __instance.gene) { - __instance.remotePairProcess %= __instance.remotePairCount; - int remotePairProcess1 = __instance.remotePairProcess; - do + ++__instance._tmp_iter_remote; + if (__instance.remotePairCount > 0 && __instance.idleShipCount > 0) { - int num15 = (shipCarries - 1) * __instance.deliveryShips / 100; - SupplyDemandPair remotePair1 = __instance.remotePairs[__instance.remotePairProcess]; - if (remotePair1.supplyId == __instance.gid) + __instance.remotePairProcess %= __instance.remotePairCount; + int remotePairProcess1 = __instance.remotePairProcess; + do { - lock (__instance.storage) + int num17 = (shipCarries - 1) * __instance.deliveryShips / 100; + SupplyDemandPair remotePair1 = __instance.remotePairs[__instance.remotePairProcess]; + if (remotePair1.supplyId == __instance.gid) { - num1 = __instance.storage[remotePair1.supplyIndex].max; - num2 = __instance.storage[remotePair1.supplyIndex].count; - num3 = __instance.storage[remotePair1.supplyIndex].remoteSupplyCount; - num4 = __instance.storage[remotePair1.supplyIndex].totalSupplyCount; - num5 = __instance.storage[remotePair1.supplyIndex].itemId; + lock (__instance.storage) + { + num1 = __instance.storage[remotePair1.supplyIndex].max; + num2 = __instance.storage[remotePair1.supplyIndex].count; + num3 = __instance.storage[remotePair1.supplyIndex].inc; + num4 = __instance.storage[remotePair1.supplyIndex].remoteSupplyCount; + num5 = __instance.storage[remotePair1.supplyIndex].totalSupplyCount; + num6 = __instance.storage[remotePair1.supplyIndex].itemId; + } } - } - if (remotePair1.supplyId == __instance.gid && num1 <= num15) - num15 = num1 - 1; - if (num15 < 0) - num15 = 0; - if (remotePair1.supplyId == __instance.gid && num2 > num15 && (num3 > num15 && num4 > num15)) - { - StationComponent stationComponent = gStationPool[remotePair1.demandId]; - if (stationComponent != null) + + if (remotePair1.supplyId == __instance.gid && num1 <= num17) + num17 = num1 - 1; + if (num17 < 0) + num17 = 0; + if (remotePair1.supplyId == __instance.gid && num2 > num17 && (num4 > num17 && num5 > num17)) { - double trip = (astroPoses[__instance.planetId].uPos - astroPoses[stationComponent.planetId].uPos).magnitude + (double) astroPoses[__instance.planetId].uRadius + (double) astroPoses[stationComponent.planetId].uRadius; - bool flag1 = trip < __instance.tripRangeShips; - bool flag2 = trip >= __instance.warpEnableDist; - if (__instance.warperNecessary & flag2 && (__instance.warperCount < 2 || !canWarp)) - flag1 = false; - if (flag1) + StationComponent stationComponent = gStationPool[remotePair1.demandId]; + if (stationComponent != null) { - lock (stationComponent.storage) + double trip = (astroPoses[__instance.planetId].uPos - astroPoses[stationComponent.planetId].uPos).magnitude + (double)astroPoses[__instance.planetId].uRadius + (double)astroPoses[stationComponent.planetId].uRadius; + bool flag1 = trip < __instance.tripRangeShips; + bool flag2 = trip >= __instance.warpEnableDist; + if (__instance.warperNecessary & flag2 && (__instance.warperCount < 2 || !canWarp)) + flag1 = false; + if (flag1) { - num9 = stationComponent.storage[remotePair1.demandIndex].remoteDemandCount; - num10 = stationComponent.storage[remotePair1.demandIndex].totalDemandCount; + lock (stationComponent.storage) + { + num10 = stationComponent.storage[remotePair1.demandIndex].remoteDemandCount; + num11 = stationComponent.storage[remotePair1.demandIndex].totalDemandCount; + } } - } - if (flag1 && num9 > 0 && num10 > 0) - { - long num16 = __instance.CalcTripEnergyCost(trip, shipSailSpeed, canWarp); - if (__instance.energy >= num16) + + if (flag1 && num10 > 0 && num11 > 0) { - int num17 = shipCarries < num2 ? shipCarries : num2; - int index = __instance.QueryIdleShip(__instance.nextShipIndex); - if (index >= 0) + long num18 = __instance.CalcTripEnergyCost(trip, shipSailSpeed, canWarp); + if (__instance.energy >= num18) { - __instance.nextShipIndex = (index + 1) % __instance.workShipDatas.Length; - __instance.workShipDatas[__instance.workShipCount].stage = -2; - __instance.workShipDatas[__instance.workShipCount].planetA = __instance.planetId; - __instance.workShipDatas[__instance.workShipCount].planetB = stationComponent.planetId; - __instance.workShipDatas[__instance.workShipCount].otherGId = stationComponent.gid; - __instance.workShipDatas[__instance.workShipCount].direction = 1; - __instance.workShipDatas[__instance.workShipCount].t = 0.0f; - __instance.workShipDatas[__instance.workShipCount].itemId = __instance.workShipOrders[__instance.workShipCount].itemId = num5; - __instance.workShipDatas[__instance.workShipCount].itemCount = num17; - __instance.workShipDatas[__instance.workShipCount].gene = __instance._tmp_iter_remote; - __instance.workShipDatas[__instance.workShipCount].shipIndex = index; - __instance.workShipOrders[__instance.workShipCount].otherStationGId = stationComponent.gid; - __instance.workShipOrders[__instance.workShipCount].thisIndex = remotePair1.supplyIndex; - __instance.workShipOrders[__instance.workShipCount].otherIndex = remotePair1.demandIndex; - __instance.workShipOrders[__instance.workShipCount].thisOrdered = 0; - __instance.workShipOrders[__instance.workShipCount].otherOrdered = num17; - if (flag2) + int num19 = shipCarries < num2 ? shipCarries : num2; + int num20 = (int)((double)num3 / (double)num2 * (double)num19 + 0.5); + int index = __instance.QueryIdleShip(__instance.nextShipIndex); + if (index >= 0) { - lock (consumeRegister) + __instance.nextShipIndex = (index + 1) % __instance.workShipDatas.Length; + __instance.workShipDatas[__instance.workShipCount].stage = -2; + __instance.workShipDatas[__instance.workShipCount].planetA = __instance.planetId; + __instance.workShipDatas[__instance.workShipCount].planetB = stationComponent.planetId; + __instance.workShipDatas[__instance.workShipCount].otherGId = stationComponent.gid; + __instance.workShipDatas[__instance.workShipCount].direction = 1; + __instance.workShipDatas[__instance.workShipCount].t = 0.0f; + __instance.workShipDatas[__instance.workShipCount].itemId = __instance.workShipOrders[__instance.workShipCount].itemId = num6; + __instance.workShipDatas[__instance.workShipCount].itemCount = num19; + __instance.workShipDatas[__instance.workShipCount].inc = num20; + __instance.workShipDatas[__instance.workShipCount].gene = __instance._tmp_iter_remote; + __instance.workShipDatas[__instance.workShipCount].shipIndex = index; + __instance.workShipOrders[__instance.workShipCount].otherStationGId = stationComponent.gid; + __instance.workShipOrders[__instance.workShipCount].thisIndex = remotePair1.supplyIndex; + __instance.workShipOrders[__instance.workShipCount].otherIndex = remotePair1.demandIndex; + __instance.workShipOrders[__instance.workShipCount].thisOrdered = 0; + __instance.workShipOrders[__instance.workShipCount].otherOrdered = num19; + if (flag2) { - if (__instance.warperCount >= 2) - { - __instance.workShipDatas[__instance.workShipCount].warperCnt += 2; - __instance.warperCount -= 2; - consumeRegister[1210] += 2; - } - else if (__instance.warperCount >= 1) + lock (consumeRegister) { - ++__instance.workShipDatas[__instance.workShipCount].warperCnt; - --__instance.warperCount; - ++consumeRegister[1210]; + if (__instance.warperCount >= 2) + { + __instance.workShipDatas[__instance.workShipCount].warperCnt += 2; + __instance.warperCount -= 2; + consumeRegister[1210] += 2; + } + else if (__instance.warperCount >= 1) + { + ++__instance.workShipDatas[__instance.workShipCount].warperCnt; + --__instance.warperCount; + ++consumeRegister[1210]; + } + else if (__instance.warperFree) + __instance.workShipDatas[__instance.workShipCount].warperCnt += 2; } - else if (__instance.warperFree) - __instance.workShipDatas[__instance.workShipCount].warperCnt += 2; } + + lock (stationComponent.storage) + stationComponent.storage[remotePair1.demandIndex].remoteOrder += num19; + ++__instance.workShipCount; + --__instance.idleShipCount; + __instance.IdleShipGetToWork(index); + lock (__instance.storage) + { + __instance.storage[remotePair1.supplyIndex].count -= num19; + __instance.storage[remotePair1.supplyIndex].inc -= num20; + } + + __instance.energy -= num18; + break; } - lock (stationComponent.storage) - stationComponent.storage[remotePair1.demandIndex].remoteOrder += num17; - ++__instance.workShipCount; - --__instance.idleShipCount; - __instance.IdleShipGetToWork(index); - lock (__instance.storage) - __instance.storage[remotePair1.supplyIndex].count -= num17; - __instance.energy -= num16; + break; } + break; } - break; } } - } - if (remotePair1.demandId == __instance.gid) - { - lock (__instance.storage) - { - num6 = __instance.storage[remotePair1.demandIndex].remoteDemandCount; - num7 = __instance.storage[remotePair1.demandIndex].totalDemandCount; - } - } - if (remotePair1.demandId == __instance.gid && num6 > 0 && num7 > 0) - { - StationComponent stationComponent = gStationPool[remotePair1.supplyId]; - if (stationComponent != null) + + if (remotePair1.demandId == __instance.gid) { - double trip = (astroPoses[__instance.planetId].uPos - astroPoses[stationComponent.planetId].uPos).magnitude + (double) astroPoses[__instance.planetId].uRadius + (double) astroPoses[stationComponent.planetId].uRadius; - bool flag1 = trip < __instance.tripRangeShips; - if (flag1 && !__instance.includeOrbitCollector && stationComponent.isCollector) - flag1 = false; - bool flag2 = trip >= __instance.warpEnableDist; - if (__instance.warperNecessary & flag2 && (__instance.warperCount < 2 || !canWarp)) - flag1 = false; - lock (stationComponent.storage) + lock (__instance.storage) { - num11 = stationComponent.storage[remotePair1.supplyIndex].max; - num12 = stationComponent.storage[remotePair1.supplyIndex].count; - num13 = stationComponent.storage[remotePair1.supplyIndex].remoteSupplyCount; - num14 = stationComponent.storage[remotePair1.supplyIndex].totalSupplyCount; + num7 = __instance.storage[remotePair1.demandIndex].remoteDemandCount; + num8 = __instance.storage[remotePair1.demandIndex].totalDemandCount; } - if (num11 <= num15) - num15 = num11 - 1; - if (num15 < 0) - num15 = 0; - if (flag1 && num12 > num15 && (num13 > num15 && num14 > num15)) + } + + if (remotePair1.demandId == __instance.gid && num7 > 0 && num8 > 0) + { + StationComponent stationComponent = gStationPool[remotePair1.supplyId]; + if (stationComponent != null) { - long num16 = __instance.CalcTripEnergyCost(trip, shipSailSpeed, canWarp); - if (!stationComponent.isCollector) + double trip = (astroPoses[__instance.planetId].uPos - astroPoses[stationComponent.planetId].uPos).magnitude + (double)astroPoses[__instance.planetId].uRadius + (double)astroPoses[stationComponent.planetId].uRadius; + bool flag1 = trip < __instance.tripRangeShips; + if (flag1 && !__instance.includeOrbitCollector && stationComponent.isCollector) + flag1 = false; + bool flag2 = trip >= __instance.warpEnableDist; + if (__instance.warperNecessary & flag2 && (__instance.warperCount < 2 || !canWarp)) + flag1 = false; + lock (stationComponent.storage) { - bool flag3 = false; - __instance.remotePairProcess %= __instance.remotePairCount; - int num17 = __instance.remotePairProcess + 1; - int remotePairProcess2 = __instance.remotePairProcess; - int index1 = num17 % __instance.remotePairCount; - do + num12 = stationComponent.storage[remotePair1.supplyIndex].max; + num13 = stationComponent.storage[remotePair1.supplyIndex].count; + num14 = stationComponent.storage[remotePair1.supplyIndex].inc; + num15 = stationComponent.storage[remotePair1.supplyIndex].remoteSupplyCount; + num16 = stationComponent.storage[remotePair1.supplyIndex].totalSupplyCount; + } + + if (num12 <= num17) + num17 = num12 - 1; + if (num17 < 0) + num17 = 0; + if (flag1 && num13 > num17 && (num15 > num17 && num16 > num17)) + { + long num18 = __instance.CalcTripEnergyCost(trip, shipSailSpeed, canWarp); + if (!stationComponent.isCollector && !stationComponent.isVeinCollector) { - SupplyDemandPair remotePair2 = __instance.remotePairs[index1]; - if (remotePair2.supplyId == __instance.gid && remotePair2.demandId == stationComponent.gid) + bool flag3 = false; + __instance.remotePairProcess %= __instance.remotePairCount; + int num19 = __instance.remotePairProcess + 1; + int remotePairProcess2 = __instance.remotePairProcess; + int index1 = num19 % __instance.remotePairCount; + do { - lock (__instance.storage) + SupplyDemandPair remotePair2 = __instance.remotePairs[index1]; + if (remotePair2.supplyId == __instance.gid && remotePair2.demandId == stationComponent.gid) { - num2 = __instance.storage[remotePair2.supplyIndex].count; - num3 = __instance.storage[remotePair2.supplyIndex].remoteSupplyCount; - num4 = __instance.storage[remotePair2.supplyIndex].totalSupplyCount; - num5 = __instance.storage[remotePair2.supplyIndex].itemId; + lock (__instance.storage) + { + num2 = __instance.storage[remotePair2.supplyIndex].count; + num3 = __instance.storage[remotePair2.supplyIndex].inc; + num4 = __instance.storage[remotePair2.supplyIndex].remoteSupplyCount; + num5 = __instance.storage[remotePair2.supplyIndex].totalSupplyCount; + num6 = __instance.storage[remotePair2.supplyIndex].itemId; + } } - } - if (remotePair2.supplyId == __instance.gid && remotePair2.demandId == stationComponent.gid) - { - lock (stationComponent.storage) + + if (remotePair2.supplyId == __instance.gid && remotePair2.demandId == stationComponent.gid) { - num9 = stationComponent.storage[remotePair2.demandIndex].remoteDemandCount; - num10 = stationComponent.storage[remotePair2.demandIndex].totalDemandCount; + lock (stationComponent.storage) + { + num10 = stationComponent.storage[remotePair2.demandIndex].remoteDemandCount; + num11 = stationComponent.storage[remotePair2.demandIndex].totalDemandCount; + } } - } - if (remotePair2.supplyId == __instance.gid && remotePair2.demandId == stationComponent.gid && (num2 >= num15 && num3 >= num15) && (num4 >= num15 && num9 > 0 && num10 > 0)) - { - if (__instance.energy >= num16) + + if (remotePair2.supplyId == __instance.gid && remotePair2.demandId == stationComponent.gid && (num2 >= num17 && num4 >= num17) && (num5 >= num17 && num10 > 0 && num11 > 0)) { - int num18 = shipCarries < num2 ? shipCarries : num2; - int index2 = __instance.QueryIdleShip(__instance.nextShipIndex); - if (index2 >= 0) + if (__instance.energy >= num18) { - __instance.nextShipIndex = (index2 + 1) % __instance.workShipDatas.Length; - __instance.workShipDatas[__instance.workShipCount].stage = -2; - __instance.workShipDatas[__instance.workShipCount].planetA = __instance.planetId; - __instance.workShipDatas[__instance.workShipCount].planetB = stationComponent.planetId; - __instance.workShipDatas[__instance.workShipCount].otherGId = stationComponent.gid; - __instance.workShipDatas[__instance.workShipCount].direction = 1; - __instance.workShipDatas[__instance.workShipCount].t = 0.0f; - __instance.workShipDatas[__instance.workShipCount].itemId = __instance.workShipOrders[__instance.workShipCount].itemId = num5; - __instance.workShipDatas[__instance.workShipCount].itemCount = num18; - __instance.workShipDatas[__instance.workShipCount].gene = __instance._tmp_iter_remote; - __instance.workShipDatas[__instance.workShipCount].shipIndex = index2; - __instance.workShipOrders[__instance.workShipCount].otherStationGId = stationComponent.gid; - __instance.workShipOrders[__instance.workShipCount].thisIndex = remotePair2.supplyIndex; - __instance.workShipOrders[__instance.workShipCount].otherIndex = remotePair2.demandIndex; - __instance.workShipOrders[__instance.workShipCount].thisOrdered = 0; - __instance.workShipOrders[__instance.workShipCount].otherOrdered = num18; - if (flag2) + int num20 = shipCarries < num2 ? shipCarries : num2; + int num21 = (int)((double)num3 / (double)num2 * (double)num20 + 0.5); + int index2 = __instance.QueryIdleShip(__instance.nextShipIndex); + if (index2 >= 0) { - lock (consumeRegister) + __instance.nextShipIndex = (index2 + 1) % __instance.workShipDatas.Length; + __instance.workShipDatas[__instance.workShipCount].stage = -2; + __instance.workShipDatas[__instance.workShipCount].planetA = __instance.planetId; + __instance.workShipDatas[__instance.workShipCount].planetB = stationComponent.planetId; + __instance.workShipDatas[__instance.workShipCount].otherGId = stationComponent.gid; + __instance.workShipDatas[__instance.workShipCount].direction = 1; + __instance.workShipDatas[__instance.workShipCount].t = 0.0f; + __instance.workShipDatas[__instance.workShipCount].itemId = __instance.workShipOrders[__instance.workShipCount].itemId = num6; + __instance.workShipDatas[__instance.workShipCount].itemCount = num20; + __instance.workShipDatas[__instance.workShipCount].inc = num21; + __instance.workShipDatas[__instance.workShipCount].gene = __instance._tmp_iter_remote; + __instance.workShipDatas[__instance.workShipCount].shipIndex = index2; + __instance.workShipOrders[__instance.workShipCount].otherStationGId = stationComponent.gid; + __instance.workShipOrders[__instance.workShipCount].thisIndex = remotePair2.supplyIndex; + __instance.workShipOrders[__instance.workShipCount].otherIndex = remotePair2.demandIndex; + __instance.workShipOrders[__instance.workShipCount].thisOrdered = 0; + __instance.workShipOrders[__instance.workShipCount].otherOrdered = num20; + if (flag2) { - if (__instance.warperCount >= 2) + lock (consumeRegister) { - __instance.workShipDatas[__instance.workShipCount].warperCnt += 2; - __instance.warperCount -= 2; - consumeRegister[1210] += 2; + if (__instance.warperCount >= 2) + { + __instance.workShipDatas[__instance.workShipCount].warperCnt += 2; + __instance.warperCount -= 2; + consumeRegister[1210] += 2; + } + else if (__instance.warperCount >= 1) + { + ++__instance.workShipDatas[__instance.workShipCount].warperCnt; + --__instance.warperCount; + ++consumeRegister[1210]; + } + else if (__instance.warperFree) + __instance.workShipDatas[__instance.workShipCount].warperCnt += 2; } - else if (__instance.warperCount >= 1) - { - ++__instance.workShipDatas[__instance.workShipCount].warperCnt; - --__instance.warperCount; - ++consumeRegister[1210]; - } - else if (__instance.warperFree) - __instance.workShipDatas[__instance.workShipCount].warperCnt += 2; } + + lock (stationComponent.storage) + stationComponent.storage[remotePair2.demandIndex].remoteOrder += num20; + ++__instance.workShipCount; + --__instance.idleShipCount; + __instance.IdleShipGetToWork(index2); + lock (__instance.storage) + { + __instance.storage[remotePair2.supplyIndex].count -= num20; + __instance.storage[remotePair2.supplyIndex].inc -= num21; + } + + __instance.energy -= num18; + flag3 = true; + break; } - lock (stationComponent.storage) - stationComponent.storage[remotePair2.demandIndex].remoteOrder += num18; - ++__instance.workShipCount; - --__instance.idleShipCount; - __instance.IdleShipGetToWork(index2); - lock (__instance.storage) - __instance.storage[remotePair2.supplyIndex].count -= num18; - __instance.energy -= num16; - flag3 = true; + break; } + break; } + + index1 = (index1 + 1) % __instance.remotePairCount; + } while (remotePairProcess2 != index1); + + if (flag3) break; - } - index1 = (index1 + 1) % __instance.remotePairCount; } - while (remotePairProcess2 != index1); - if (flag3) - break; - } - if (__instance.energy >= num16) - { - int index = __instance.QueryIdleShip(__instance.nextShipIndex); - if (index >= 0) + + if (__instance.energy >= num18) { - lock (__instance.storage) - num8 = __instance.storage[remotePair1.demandIndex].itemId; - __instance.nextShipIndex = (index + 1) % __instance.workShipDatas.Length; - __instance.workShipDatas[__instance.workShipCount].stage = -2; - __instance.workShipDatas[__instance.workShipCount].planetA = __instance.planetId; - __instance.workShipDatas[__instance.workShipCount].planetB = stationComponent.planetId; - __instance.workShipDatas[__instance.workShipCount].otherGId = stationComponent.gid; - __instance.workShipDatas[__instance.workShipCount].direction = 1; - __instance.workShipDatas[__instance.workShipCount].t = 0.0f; - __instance.workShipDatas[__instance.workShipCount].itemId = __instance.workShipOrders[__instance.workShipCount].itemId = num8; - __instance.workShipDatas[__instance.workShipCount].itemCount = 0; - __instance.workShipDatas[__instance.workShipCount].gene = __instance._tmp_iter_remote; - __instance.workShipDatas[__instance.workShipCount].shipIndex = index; - __instance.workShipOrders[__instance.workShipCount].otherStationGId = stationComponent.gid; - __instance.workShipOrders[__instance.workShipCount].thisIndex = remotePair1.demandIndex; - __instance.workShipOrders[__instance.workShipCount].otherIndex = remotePair1.supplyIndex; - __instance.workShipOrders[__instance.workShipCount].thisOrdered = shipCarries; - __instance.workShipOrders[__instance.workShipCount].otherOrdered = -shipCarries; - if (flag2) + int index = __instance.QueryIdleShip(__instance.nextShipIndex); + if (index >= 0) { - lock (consumeRegister) + lock (__instance.storage) + num9 = __instance.storage[remotePair1.demandIndex].itemId; + __instance.nextShipIndex = (index + 1) % __instance.workShipDatas.Length; + __instance.workShipDatas[__instance.workShipCount].stage = -2; + __instance.workShipDatas[__instance.workShipCount].planetA = __instance.planetId; + __instance.workShipDatas[__instance.workShipCount].planetB = stationComponent.planetId; + __instance.workShipDatas[__instance.workShipCount].otherGId = stationComponent.gid; + __instance.workShipDatas[__instance.workShipCount].direction = 1; + __instance.workShipDatas[__instance.workShipCount].t = 0.0f; + __instance.workShipDatas[__instance.workShipCount].itemId = __instance.workShipOrders[__instance.workShipCount].itemId = num9; + __instance.workShipDatas[__instance.workShipCount].itemCount = 0; + __instance.workShipDatas[__instance.workShipCount].inc = 0; + __instance.workShipDatas[__instance.workShipCount].gene = __instance._tmp_iter_remote; + __instance.workShipDatas[__instance.workShipCount].shipIndex = index; + __instance.workShipOrders[__instance.workShipCount].otherStationGId = stationComponent.gid; + __instance.workShipOrders[__instance.workShipCount].thisIndex = remotePair1.demandIndex; + __instance.workShipOrders[__instance.workShipCount].otherIndex = remotePair1.supplyIndex; + __instance.workShipOrders[__instance.workShipCount].thisOrdered = shipCarries; + __instance.workShipOrders[__instance.workShipCount].otherOrdered = -shipCarries; + if (flag2) { - if (__instance.warperCount >= 2) + lock (consumeRegister) { - __instance.workShipDatas[__instance.workShipCount].warperCnt += 2; - __instance.warperCount -= 2; - consumeRegister[1210] += 2; - } - else if (__instance.warperCount >= 1) - { - ++__instance.workShipDatas[__instance.workShipCount].warperCnt; - --__instance.warperCount; - ++consumeRegister[1210]; + if (__instance.warperCount >= 2) + { + __instance.workShipDatas[__instance.workShipCount].warperCnt += 2; + __instance.warperCount -= 2; + consumeRegister[1210] += 2; + } + else if (__instance.warperCount >= 1) + { + ++__instance.workShipDatas[__instance.workShipCount].warperCnt; + --__instance.warperCount; + ++consumeRegister[1210]; + } + else if (__instance.warperFree) + __instance.workShipDatas[__instance.workShipCount].warperCnt += 2; } - else if (__instance.warperFree) - __instance.workShipDatas[__instance.workShipCount].warperCnt += 2; } + + lock (__instance.storage) + __instance.storage[remotePair1.demandIndex].remoteOrder += shipCarries; + lock (stationComponent.storage) + stationComponent.storage[remotePair1.supplyIndex].remoteOrder -= shipCarries; + ++__instance.workShipCount; + --__instance.idleShipCount; + __instance.IdleShipGetToWork(index); + __instance.energy -= num18; + break; } - lock (__instance.storage) - __instance.storage[remotePair1.demandIndex].remoteOrder += shipCarries; - lock (stationComponent.storage) - stationComponent.storage[remotePair1.supplyIndex].remoteOrder -= shipCarries; - ++__instance.workShipCount; - --__instance.idleShipCount; - __instance.IdleShipGetToWork(index); - __instance.energy -= num16; + break; } + break; } - break; } } - } + + ++__instance.remotePairProcess; + __instance.remotePairProcess %= __instance.remotePairCount; + } while (remotePairProcess1 != __instance.remotePairProcess); + ++__instance.remotePairProcess; __instance.remotePairProcess %= __instance.remotePairCount; } - while (remotePairProcess1 != __instance.remotePairProcess); - ++__instance.remotePairProcess; - __instance.remotePairProcess %= __instance.remotePairCount; } - } - float num19 = Mathf.Sqrt(shipSailSpeed / 600f); - float f = num19; - if ((double) f > 1.0) - f = Mathf.Log(f) + 1f; - AstroPose astroPose1 = astroPoses[__instance.planetId]; - float num20 = shipSailSpeed * 0.03f * f; - float num21 = shipSailSpeed * 0.12f * f; - float num22 = shipSailSpeed * 0.4f * num19; - float num23 = (float) ((double) num19 * (3.0 / 500.0) + 9.99999974737875E-06); - for (int destinationIndex = 0; destinationIndex < __instance.workShipCount; ++destinationIndex) - { - ShipData workShipData = __instance.workShipDatas[destinationIndex]; - bool flag1 = false; - Quaternion urot = Quaternion.identity; - if (workShipData.otherGId <= 0) - { - workShipData.direction = -1; - if (workShipData.stage > 0) - workShipData.stage = 0; - } - VectorLF3 vectorLf3_1; - if (workShipData.stage < -1) + + float num22 = Mathf.Sqrt(shipSailSpeed / 600f); + float f = num22; + if ((double)f > 1.0) + f = Mathf.Log(f) + 1f; + AstroPose astroPose1 = astroPoses[__instance.planetId]; + float num23 = shipSailSpeed * 0.03f * f; + float num24 = shipSailSpeed * 0.12f * f; + float num25 = shipSailSpeed * 0.4f * num22; + float num26 = (float)((double)num22 * (3.0 / 500.0) + 9.99999974737875E-06); + for (int destinationIndex = 0; destinationIndex < __instance.workShipCount; ++destinationIndex) { - if (workShipData.direction > 0) + ShipData workShipData = __instance.workShipDatas[destinationIndex]; + bool flag1 = false; + Quaternion urot = Quaternion.identity; + if (workShipData.otherGId <= 0) { - workShipData.t += 0.03335f; - if ((double) workShipData.t > 1.0) - { - workShipData.t = 0.0f; - workShipData.stage = -1; - } + workShipData.direction = -1; + if (workShipData.stage > 0) + workShipData.stage = 0; } - else + + VectorLF3 vectorLf3_1; + if (workShipData.stage < -1) { - workShipData.t -= 0.03335f; - if ((double) workShipData.t < 0.0) + if (workShipData.direction > 0) { - workShipData.t = 0.0f; - __instance.AddItem(workShipData.itemId, workShipData.itemCount); - if (__instance.workShipOrders[destinationIndex].itemId > 0) + workShipData.t += 0.03335f; + if ((double)workShipData.t > 1.0) { - lock (__instance.storage) + workShipData.t = 0.0f; + workShipData.stage = -1; + } + } + else + { + workShipData.t -= 0.03335f; + if ((double)workShipData.t < 0.0) + { + workShipData.t = 0.0f; + __instance.AddItem(workShipData.itemId, workShipData.itemCount, workShipData.inc); + factory.NotifyShipDelivery(workShipData.planetB, gStationPool[workShipData.otherGId], workShipData.planetA, __instance, workShipData.itemId, workShipData.itemCount); + if (__instance.workShipOrders[destinationIndex].itemId > 0) { - if (__instance.storage[__instance.workShipOrders[destinationIndex].thisIndex].itemId == __instance.workShipOrders[destinationIndex].itemId) - __instance.storage[__instance.workShipOrders[destinationIndex].thisIndex].remoteOrder -= __instance.workShipOrders[destinationIndex].thisOrdered; + lock (__instance.storage) + { + if (__instance.storage[__instance.workShipOrders[destinationIndex].thisIndex].itemId == __instance.workShipOrders[destinationIndex].itemId) + __instance.storage[__instance.workShipOrders[destinationIndex].thisIndex].remoteOrder -= __instance.workShipOrders[destinationIndex].thisOrdered; + } + + __instance.workShipOrders[destinationIndex].ClearThis(); } - __instance.workShipOrders[destinationIndex].ClearThis(); + + Array.Copy((Array)__instance.workShipDatas, destinationIndex + 1, (Array)__instance.workShipDatas, destinationIndex, __instance.workShipDatas.Length - destinationIndex - 1); + Array.Copy((Array)__instance.workShipOrders, destinationIndex + 1, (Array)__instance.workShipOrders, destinationIndex, __instance.workShipOrders.Length - destinationIndex - 1); + --__instance.workShipCount; + ++__instance.idleShipCount; + __instance.WorkShipBackToIdle(workShipData.shipIndex); + Array.Clear((Array)__instance.workShipDatas, __instance.workShipCount, __instance.workShipDatas.Length - __instance.workShipCount); + Array.Clear((Array)__instance.workShipOrders, __instance.workShipCount, __instance.workShipOrders.Length - __instance.workShipCount); + --destinationIndex; + continue; } - Array.Copy((Array) __instance.workShipDatas, destinationIndex + 1, (Array) __instance.workShipDatas, destinationIndex, __instance.workShipDatas.Length - destinationIndex - 1); - Array.Copy((Array) __instance.workShipOrders, destinationIndex + 1, (Array) __instance.workShipOrders, destinationIndex, __instance.workShipOrders.Length - destinationIndex - 1); - --__instance.workShipCount; - ++__instance.idleShipCount; - __instance.WorkShipBackToIdle(workShipData.shipIndex); - Array.Clear((Array) __instance.workShipDatas, __instance.workShipCount, __instance.workShipDatas.Length - __instance.workShipCount); - Array.Clear((Array) __instance.workShipOrders, __instance.workShipCount, __instance.workShipOrders.Length - __instance.workShipCount); - --destinationIndex; - continue; } + + workShipData.uPos = astroPose1.uPos + Maths.QRotateLF(astroPose1.uRot, (VectorLF3)__instance.shipDiskPos[workShipData.shipIndex]); + workShipData.uVel.x = 0.0f; + workShipData.uVel.y = 0.0f; + workShipData.uVel.z = 0.0f; + workShipData.uSpeed = 0.0f; + workShipData.uRot = astroPose1.uRot * __instance.shipDiskRot[workShipData.shipIndex]; + workShipData.uAngularVel.x = 0.0f; + workShipData.uAngularVel.y = 0.0f; + workShipData.uAngularVel.z = 0.0f; + workShipData.uAngularSpeed = 0.0f; + workShipData.pPosTemp = (VectorLF3)Vector3.zero; + workShipData.pRotTemp = Quaternion.identity; + __instance.shipRenderers[workShipData.shipIndex].anim.z = 0.0f; } - workShipData.uPos = astroPose1.uPos + Maths.QRotateLF(astroPose1.uRot, (VectorLF3) __instance.shipDiskPos[workShipData.shipIndex]); - workShipData.uVel.x = 0.0f; - workShipData.uVel.y = 0.0f; - workShipData.uVel.z = 0.0f; - workShipData.uSpeed = 0.0f; - workShipData.uRot = astroPose1.uRot * __instance.shipDiskRot[workShipData.shipIndex]; - workShipData.uAngularVel.x = 0.0f; - workShipData.uAngularVel.y = 0.0f; - workShipData.uAngularVel.z = 0.0f; - workShipData.uAngularSpeed = 0.0f; - workShipData.pPosTemp = (VectorLF3) Vector3.zero; - workShipData.pRotTemp = Quaternion.identity; - __instance.shipRenderers[workShipData.shipIndex].anim.z = 0.0f; - } - else if (workShipData.stage == -1) - { - if (workShipData.direction > 0) + else if (workShipData.stage == -1) { - workShipData.t += num23; - float num15 = workShipData.t; - if ((double) workShipData.t > 1.0) + if (workShipData.direction > 0) { - workShipData.t = 1f; - num15 = 1f; - workShipData.stage = 0; + workShipData.t += num26; + float num17 = workShipData.t; + if ((double)workShipData.t > 1.0) + { + workShipData.t = 1f; + num17 = 1f; + workShipData.stage = 0; + } + + __instance.shipRenderers[workShipData.shipIndex].anim.z = num17; + float num18 = (3f - num17 - num17) * num17 * num17; + workShipData.uPos = astroPose1.uPos + Maths.QRotateLF(astroPose1.uRot, (VectorLF3)(__instance.shipDiskPos[workShipData.shipIndex] + __instance.shipDiskPos[workShipData.shipIndex].normalized * (25f * num18))); + workShipData.uRot = astroPose1.uRot * __instance.shipDiskRot[workShipData.shipIndex]; } - __instance.shipRenderers[workShipData.shipIndex].anim.z = num15; - float num16 = (3f - num15 - num15) * num15 * num15; - workShipData.uPos = astroPose1.uPos + Maths.QRotateLF(astroPose1.uRot, (VectorLF3) (__instance.shipDiskPos[workShipData.shipIndex] + __instance.shipDiskPos[workShipData.shipIndex].normalized * (25f * num16))); - workShipData.uRot = astroPose1.uRot * __instance.shipDiskRot[workShipData.shipIndex]; + else + { + workShipData.t -= num26 * 0.6666667f; + float num17 = workShipData.t; + if ((double)workShipData.t < 0.0) + { + workShipData.t = 1f; + num17 = 0.0f; + workShipData.stage = -2; + } + + __instance.shipRenderers[workShipData.shipIndex].anim.z = num17; + float num18 = (3f - num17 - num17) * num17 * num17; + VectorLF3 vectorLf3_2 = astroPose1.uPos + Maths.QRotateLF(astroPose1.uRot, (VectorLF3)__instance.shipDiskPos[workShipData.shipIndex]); + VectorLF3 vectorLf3_3 = astroPose1.uPos + Maths.QRotateLF(astroPose1.uRot, workShipData.pPosTemp); + workShipData.uPos = vectorLf3_2 * (1.0 - (double)num18) + vectorLf3_3 * (double)num18; + workShipData.uRot = astroPose1.uRot * Quaternion.Slerp(__instance.shipDiskRot[workShipData.shipIndex], workShipData.pRotTemp, (float)((double)num18 * 2.0 - 1.0)); + } + + workShipData.uVel.x = 0.0f; + workShipData.uVel.y = 0.0f; + workShipData.uVel.z = 0.0f; + workShipData.uSpeed = 0.0f; + workShipData.uAngularVel.x = 0.0f; + workShipData.uAngularVel.y = 0.0f; + workShipData.uAngularVel.z = 0.0f; + workShipData.uAngularSpeed = 0.0f; } - else + else if (workShipData.stage == 0) { - workShipData.t -= num23 * 0.6666667f; - float num15 = workShipData.t; - if ((double) workShipData.t < 0.0) + AstroPose astroPose2 = astroPoses[workShipData.planetB]; + VectorLF3 vectorLf3_2 = (workShipData.direction <= 0 ? astroPose1.uPos + Maths.QRotateLF(astroPose1.uRot, (VectorLF3)(__instance.shipDiskPos[workShipData.shipIndex] + __instance.shipDiskPos[workShipData.shipIndex].normalized * 25f)) : astroPose2.uPos + Maths.QRotateLF(astroPose2.uRot, (VectorLF3)(gStationPool[workShipData.otherGId].shipDockPos + gStationPool[workShipData.otherGId].shipDockPos.normalized * 25f))) - workShipData.uPos; + double num17 = Math.Sqrt(vectorLf3_2.x * vectorLf3_2.x + vectorLf3_2.y * vectorLf3_2.y + vectorLf3_2.z * vectorLf3_2.z); + VectorLF3 vectorLf3_3 = workShipData.direction > 0 ? astroPose1.uPos - workShipData.uPos : astroPose2.uPos - workShipData.uPos; + double num18 = vectorLf3_3.x * vectorLf3_3.x + vectorLf3_3.y * vectorLf3_3.y + vectorLf3_3.z * vectorLf3_3.z; + bool flag2 = num18 <= (double)astroPose1.uRadius * (double)astroPose1.uRadius * 2.25; + bool flag3 = false; + if (num17 < 6.0) { workShipData.t = 1f; - num15 = 0.0f; - workShipData.stage = -2; + workShipData.stage = workShipData.direction; + flag3 = true; } - __instance.shipRenderers[workShipData.shipIndex].anim.z = num15; - float num16 = (3f - num15 - num15) * num15 * num15; - VectorLF3 vectorLf3_2 = astroPose1.uPos + Maths.QRotateLF(astroPose1.uRot, (VectorLF3) __instance.shipDiskPos[workShipData.shipIndex]); - VectorLF3 vectorLf3_3 = astroPose1.uPos + Maths.QRotateLF(astroPose1.uRot, workShipData.pPosTemp); - workShipData.uPos = vectorLf3_2 * (1.0 - (double) num16) + vectorLf3_3 * (double) num16; - workShipData.uRot = astroPose1.uRot * Quaternion.Slerp(__instance.shipDiskRot[workShipData.shipIndex], workShipData.pRotTemp, (float) ((double) num16 * 2.0 - 1.0)); - } - workShipData.uVel.x = 0.0f; - workShipData.uVel.y = 0.0f; - workShipData.uVel.z = 0.0f; - workShipData.uSpeed = 0.0f; - workShipData.uAngularVel.x = 0.0f; - workShipData.uAngularVel.y = 0.0f; - workShipData.uAngularVel.z = 0.0f; - workShipData.uAngularSpeed = 0.0f; - } - else if (workShipData.stage == 0) - { - AstroPose astroPose2 = astroPoses[workShipData.planetB]; - VectorLF3 vectorLf3_2 = (workShipData.direction <= 0 ? astroPose1.uPos + Maths.QRotateLF(astroPose1.uRot, (VectorLF3) (__instance.shipDiskPos[workShipData.shipIndex] + __instance.shipDiskPos[workShipData.shipIndex].normalized * 25f)) : astroPose2.uPos + Maths.QRotateLF(astroPose2.uRot, (VectorLF3) (gStationPool[workShipData.otherGId].shipDockPos + gStationPool[workShipData.otherGId].shipDockPos.normalized * 25f))) - workShipData.uPos; - double num15 = Math.Sqrt(vectorLf3_2.x * vectorLf3_2.x + vectorLf3_2.y * vectorLf3_2.y + vectorLf3_2.z * vectorLf3_2.z); - VectorLF3 vectorLf3_3 = workShipData.direction > 0 ? astroPose1.uPos - workShipData.uPos : astroPose2.uPos - workShipData.uPos; - double num16 = vectorLf3_3.x * vectorLf3_3.x + vectorLf3_3.y * vectorLf3_3.y + vectorLf3_3.z * vectorLf3_3.z; - bool flag2 = num16 <= (double) astroPose1.uRadius * (double) astroPose1.uRadius * 2.25; - bool flag3 = false; - if (num15 < 6.0) - { - workShipData.t = 1f; - workShipData.stage = workShipData.direction; - flag3 = true; - } - float num17 = 0.0f; - if (canWarp) - { - vectorLf3_1 = astroPose1.uPos - astroPose2.uPos; - double num18 = vectorLf3_1.magnitude * 2.0; - double num24 = (double) shipWarpSpeed < num18 ? (double) shipWarpSpeed : num18; - double num25 = __instance.warpEnableDist * 0.5; - if ((double) workShipData.warpState <= 0.0) + + float num19 = 0.0f; + if (canWarp) { - workShipData.warpState = 0.0f; - if (num16 > 25000000.0 && num15 > num25 && (double) workShipData.uSpeed >= (double) shipSailSpeed && (workShipData.warperCnt > 0 || __instance.warperFree)) + vectorLf3_1 = astroPose1.uPos - astroPose2.uPos; + double num20 = vectorLf3_1.magnitude * 2.0; + double num21 = (double)shipWarpSpeed < num20 ? (double)shipWarpSpeed : num20; + double num27 = __instance.warpEnableDist * 0.5; + if ((double)workShipData.warpState <= 0.0) { - --workShipData.warperCnt; - workShipData.warpState += (float) dt; + workShipData.warpState = 0.0f; + if (num18 > 25000000.0 && num17 > num27 && (double)workShipData.uSpeed >= (double)shipSailSpeed && (workShipData.warperCnt > 0 || __instance.warperFree)) + { + --workShipData.warperCnt; + workShipData.warpState += (float)dt; + } } - } - else - { - num17 = (float) (num24 * ((Math.Pow(1001.0, (double) workShipData.warpState) - 1.0) / 1000.0)); - double num26 = (double) num17 * 0.0449 + 5000.0 + (double) shipSailSpeed * 0.25; - double num27 = num15 - num26; - if (num27 < 0.0) - num27 = 0.0; - if (num15 < num26) - workShipData.warpState -= (float) (dt * 4.0); else - workShipData.warpState += (float) dt; - if ((double) workShipData.warpState < 0.0) - workShipData.warpState = 0.0f; - else if ((double) workShipData.warpState > 1.0) - workShipData.warpState = 1f; - if ((double) workShipData.warpState > 0.0) { - num17 = (float) (num24 * ((Math.Pow(1001.0, (double) workShipData.warpState) - 1.0) / 1000.0)); - if ((double) num17 * dt > num27) - num17 = (float) (num27 / dt * 1.01); + num19 = (float)(num21 * ((Math.Pow(1001.0, (double)workShipData.warpState) - 1.0) / 1000.0)); + double num28 = (double)num19 * 0.0449 + 5000.0 + (double)shipSailSpeed * 0.25; + double num29 = num17 - num28; + if (num29 < 0.0) + num29 = 0.0; + if (num17 < num28) + workShipData.warpState -= (float)(dt * 4.0); + else + workShipData.warpState += (float)dt; + if ((double)workShipData.warpState < 0.0) + workShipData.warpState = 0.0f; + else if ((double)workShipData.warpState > 1.0) + workShipData.warpState = 1f; + if ((double)workShipData.warpState > 0.0) + { + num19 = (float)(num21 * ((Math.Pow(1001.0, (double)workShipData.warpState) - 1.0) / 1000.0)); + if ((double)num19 * dt > num29) + num19 = (float)(num29 / dt * 1.01); + } } } - } - double num28 = num15 / ((double) workShipData.uSpeed + 0.1) * 0.382 * (double) f; - float num29; - if ((double) workShipData.warpState > 0.0) - { - num29 = workShipData.uSpeed = shipSailSpeed + num17; - if ((double) num29 > (double) shipSailSpeed) - num29 = shipSailSpeed; - } - else - { - float num18 = workShipData.uSpeed * (float) num28 + 6f; - if ((double) num18 > (double) shipSailSpeed) - num18 = shipSailSpeed; - float num24 = (float) (dt * (flag2 ? (double) num20 : (double) num21)); - if ((double) workShipData.uSpeed < (double) num18 - (double) num24) - workShipData.uSpeed += num24; - else if ((double) workShipData.uSpeed > (double) num18 + (double) num22) - workShipData.uSpeed -= num22; + + double num30 = num17 / ((double)workShipData.uSpeed + 0.1) * 0.382 * (double)f; + float num31; + if ((double)workShipData.warpState > 0.0) + { + num31 = workShipData.uSpeed = shipSailSpeed + num19; + if ((double)num31 > (double)shipSailSpeed) + num31 = shipSailSpeed; + } else - workShipData.uSpeed = num18; - num29 = workShipData.uSpeed; - } - int index1 = -1; - double num30 = 0.0; - double d = 1E+40; - int num31 = workShipData.planetA / 100 * 100; - int num32 = workShipData.planetB / 100 * 100; - for (int index2 = num31; index2 < num31 + 99; ++index2) - { - float uRadius = astroPoses[index2].uRadius; - if ((double) uRadius >= 1.0) { - VectorLF3 vectorLf3_4 = workShipData.uPos - astroPoses[index2].uPos; - double num18 = vectorLf3_4.x * vectorLf3_4.x + vectorLf3_4.y * vectorLf3_4.y + vectorLf3_4.z * vectorLf3_4.z; - double num24 = -((double) workShipData.uVel.x * vectorLf3_4.x + (double) workShipData.uVel.y * vectorLf3_4.y + (double) workShipData.uVel.z * vectorLf3_4.z); - if ((num24 > 0.0 || num18 < (double) uRadius * (double) uRadius * 7.0) && num18 < d) - { - num30 = num24 < 0.0 ? 0.0 : num24; - index1 = index2; - d = num18; - } + float num20 = workShipData.uSpeed * (float)num30 + 6f; + if ((double)num20 > (double)shipSailSpeed) + num20 = shipSailSpeed; + float num21 = (float)(dt * (flag2 ? (double)num23 : (double)num24)); + if ((double)workShipData.uSpeed < (double)num20 - (double)num21) + workShipData.uSpeed += num21; + else if ((double)workShipData.uSpeed > (double)num20 + (double)num25) + workShipData.uSpeed -= num25; + else + workShipData.uSpeed = num20; + num31 = workShipData.uSpeed; } - } - if (num32 != num31) - { - for (int index2 = num32; index2 < num32 + 99; ++index2) + + int index1 = -1; + double num32 = 0.0; + double d = 1E+40; + int num33 = workShipData.planetA / 100 * 100; + int num34 = workShipData.planetB / 100 * 100; + for (int index2 = num33; index2 < num33 + 99; ++index2) { float uRadius = astroPoses[index2].uRadius; - if ((double) uRadius >= 1.0) + if ((double)uRadius >= 1.0) { VectorLF3 vectorLf3_4 = workShipData.uPos - astroPoses[index2].uPos; - double num18 = vectorLf3_4.x * vectorLf3_4.x + vectorLf3_4.y * vectorLf3_4.y + vectorLf3_4.z * vectorLf3_4.z; - double num24 = -((double) workShipData.uVel.x * vectorLf3_4.x + (double) workShipData.uVel.y * vectorLf3_4.y + (double) workShipData.uVel.z * vectorLf3_4.z); - if ((num24 > 0.0 || num18 < (double) uRadius * (double) uRadius * 7.0) && num18 < d) + double num20 = vectorLf3_4.x * vectorLf3_4.x + vectorLf3_4.y * vectorLf3_4.y + vectorLf3_4.z * vectorLf3_4.z; + double num21 = -((double)workShipData.uVel.x * vectorLf3_4.x + (double)workShipData.uVel.y * vectorLf3_4.y + (double)workShipData.uVel.z * vectorLf3_4.z); + if ((num21 > 0.0 || num20 < (double)uRadius * (double)uRadius * 7.0) && num20 < d) { - num30 = num24 < 0.0 ? 0.0 : num24; + num32 = num21 < 0.0 ? 0.0 : num21; index1 = index2; - d = num18; + d = num20; } } } - } - VectorLF3 zero = VectorLF3.zero; - VectorLF3 vectorLf3_5 = VectorLF3.zero; - float num33 = 0.0f; - VectorLF3 vectorLf3_6 = (VectorLF3) Vector3.zero; - if (index1 > 0) - { - float uRadius = astroPoses[index1].uRadius; - if (index1 % 100 == 0) - uRadius *= 2.5f; - vectorLf3_1 = astroPoses[index1].uPosNext - astroPoses[index1].uPos; - double num18 = Math.Max(1.0, (vectorLf3_1.magnitude - 0.5) * 0.6); - double num24 = 1.0 + 1600.0 / (double) uRadius; - double num25 = 1.0 + 250.0 / (double) uRadius; - double num26 = num24 * (num18 * num18); - double num27 = index1 == workShipData.planetA || index1 == workShipData.planetB ? 1.25 : 1.5; - double num34 = Math.Sqrt(d); - double num35 = (double) uRadius / num34 * 1.6 - 0.1; - if (num35 > 1.0) - num35 = 1.0; - else if (num35 < 0.0) - num35 = 0.0; - double num36 = num34 - (double) uRadius * 0.82; - if (num36 < 1.0) - num36 = 1.0; - double num37 = ((double) num29 - 6.0) / (num36 * (double) f) * 0.6 - 0.01; - if (num37 > 1.5) - num37 = 1.5; - else if (num37 < 0.0) - num37 = 0.0; - VectorLF3 vectorLf3_4 = workShipData.uPos + (VectorLF3) workShipData.uVel * num30 - astroPoses[index1].uPos; - double num38 = vectorLf3_4.magnitude / (double) uRadius; - if (num38 < num27) + + if (num34 != num33) { - double num39 = (num38 - 1.0) / (num27 - 1.0); - if (num39 < 0.0) - num39 = 0.0; - double num40 = 1.0 - num39 * num39; - vectorLf3_5 = vectorLf3_4.normalized * (num37 * num37 * num40 * 2.0 * (1.0 - (double) workShipData.warpState)); + for (int index2 = num34; index2 < num34 + 99; ++index2) + { + float uRadius = astroPoses[index2].uRadius; + if ((double)uRadius >= 1.0) + { + VectorLF3 vectorLf3_4 = workShipData.uPos - astroPoses[index2].uPos; + double num20 = vectorLf3_4.x * vectorLf3_4.x + vectorLf3_4.y * vectorLf3_4.y + vectorLf3_4.z * vectorLf3_4.z; + double num21 = -((double)workShipData.uVel.x * vectorLf3_4.x + (double)workShipData.uVel.y * vectorLf3_4.y + (double)workShipData.uVel.z * vectorLf3_4.z); + if ((num21 > 0.0 || num20 < (double)uRadius * (double)uRadius * 7.0) && num20 < d) + { + num32 = num21 < 0.0 ? 0.0 : num21; + index1 = index2; + d = num20; + } + } + } } - VectorLF3 v1 = workShipData.uPos - astroPoses[index1].uPos; - VectorLF3 vectorLf3_7 = new VectorLF3(v1.x / num34, v1.y / num34, v1.z / num34); - zero += vectorLf3_7 * num35; - num33 = (float) num35; - double num41 = num34 / (double) uRadius; - double num42 = num41 * num41; - double num43 = (num26 - num42) / (num26 - num25); - if (num43 > 1.0) - num43 = 1.0; - else if (num43 < 0.0) - num43 = 0.0; - if (num43 > 0.0) + + VectorLF3 zero = VectorLF3.zero; + VectorLF3 vectorLf3_5 = VectorLF3.zero; + float num35 = 0.0f; + VectorLF3 vectorLf3_6 = (VectorLF3)Vector3.zero; + if (index1 > 0) { - VectorLF3 v2 = Maths.QInvRotateLF(astroPoses[index1].uRot, v1); - VectorLF3 vectorLf3_8 = Maths.QRotateLF(astroPoses[index1].uRotNext, v2) + astroPoses[index1].uPosNext; - double num39 = (3.0 - num43 - num43) * num43 * num43; - VectorLF3 uPos = workShipData.uPos; - vectorLf3_6 = (vectorLf3_8 - uPos) * num39; + float uRadius = astroPoses[index1].uRadius; + if (index1 % 100 == 0) + uRadius *= 2.5f; + vectorLf3_1 = astroPoses[index1].uPosNext - astroPoses[index1].uPos; + double num20 = Math.Max(1.0, (vectorLf3_1.magnitude - 0.5) * 0.6); + double num21 = 1.0 + 1600.0 / (double)uRadius; + double num27 = 1.0 + 250.0 / (double)uRadius; + double num28 = num21 * (num20 * num20); + double num29 = index1 == workShipData.planetA || index1 == workShipData.planetB ? 1.25 : 1.5; + double num36 = Math.Sqrt(d); + double num37 = (double)uRadius / num36 * 1.6 - 0.1; + if (num37 > 1.0) + num37 = 1.0; + else if (num37 < 0.0) + num37 = 0.0; + double num38 = num36 - (double)uRadius * 0.82; + if (num38 < 1.0) + num38 = 1.0; + double num39 = ((double)num31 - 6.0) / (num38 * (double)f) * 0.6 - 0.01; + if (num39 > 1.5) + num39 = 1.5; + else if (num39 < 0.0) + num39 = 0.0; + VectorLF3 vectorLf3_4 = workShipData.uPos + (VectorLF3)workShipData.uVel * num32 - astroPoses[index1].uPos; + double num40 = vectorLf3_4.magnitude / (double)uRadius; + if (num40 < num29) + { + double num41 = (num40 - 1.0) / (num29 - 1.0); + if (num41 < 0.0) + num41 = 0.0; + double num42 = 1.0 - num41 * num41; + vectorLf3_5 = vectorLf3_4.normalized * (num39 * num39 * num42 * 2.0 * (1.0 - (double)workShipData.warpState)); + } + + VectorLF3 v1 = workShipData.uPos - astroPoses[index1].uPos; + VectorLF3 vectorLf3_7 = new VectorLF3(v1.x / num36, v1.y / num36, v1.z / num36); + zero += vectorLf3_7 * num37; + num35 = (float)num37; + double num43 = num36 / (double)uRadius; + double num44 = num43 * num43; + double num45 = (num28 - num44) / (num28 - num27); + if (num45 > 1.0) + num45 = 1.0; + else if (num45 < 0.0) + num45 = 0.0; + if (num45 > 0.0) + { + VectorLF3 v2 = Maths.QInvRotateLF(astroPoses[index1].uRot, v1); + VectorLF3 vectorLf3_8 = Maths.QRotateLF(astroPoses[index1].uRotNext, v2) + astroPoses[index1].uPosNext; + double num41 = (3.0 - num45 - num45) * num45 * num45; + VectorLF3 uPos = workShipData.uPos; + vectorLf3_6 = (vectorLf3_8 - uPos) * num41; + } } - } - Vector3 up; - workShipData.uRot.ForwardUp(out workShipData.uVel, out up); - Vector3 lhs = up * (1f - num33) + (Vector3) zero * num33; - Vector3 vector3_1 = lhs - Vector3.Dot(lhs, workShipData.uVel) * workShipData.uVel; - vector3_1.Normalize(); - Vector3 vector3_2 = (Vector3) (vectorLf3_2.normalized + vectorLf3_5); - Vector3 vector3_3 = Vector3.Cross(workShipData.uVel, vector3_2); - float num44 = (float) ((double) workShipData.uVel.x * (double) vector3_2.x + (double) workShipData.uVel.y * (double) vector3_2.y + (double) workShipData.uVel.z * (double) vector3_2.z); - Vector3 vector3_4 = Vector3.Cross(up, vector3_1); - double num45 = (double) up.x * (double) vector3_1.x + (double) up.y * (double) vector3_1.y + (double) up.z * (double) vector3_1.z; - if ((double) num44 < 0.0) - vector3_3 = vector3_3.normalized; - if (num45 < 0.0) - vector3_4 = vector3_4.normalized; - float num46 = num28 < 3.0 ? (float) ((3.25 - num28) * 4.0) : (float) ((double) num29 / (double) shipSailSpeed * (flag2 ? 0.200000002980232 : 1.0)); - vector3_3 = vector3_3 * num46 + vector3_4 * 2f; - Vector3 vector3_5 = vector3_3 - workShipData.uAngularVel; - float num47 = (double) vector3_5.sqrMagnitude < 0.100000001490116 ? 1f : 0.05f; - workShipData.uAngularVel += vector3_5 * num47; - double num48 = (double) workShipData.uSpeed * dt; - workShipData.uPos.x = workShipData.uPos.x + (double) workShipData.uVel.x * num48 + vectorLf3_6.x; - workShipData.uPos.y = workShipData.uPos.y + (double) workShipData.uVel.y * num48 + vectorLf3_6.y; - workShipData.uPos.z = workShipData.uPos.z + (double) workShipData.uVel.z * num48 + vectorLf3_6.z; - Vector3 normalized1 = workShipData.uAngularVel.normalized; - double num49 = (double) workShipData.uAngularVel.magnitude * dt * 0.5; - float w = (float) Math.Cos(num49); - float num50 = (float) Math.Sin(num49); - Quaternion quaternion = new Quaternion(normalized1.x * num50, normalized1.y * num50, normalized1.z * num50, w); - workShipData.uRot = quaternion * workShipData.uRot; - if ((double) workShipData.warpState > 0.0) - { - float t = workShipData.warpState * workShipData.warpState * workShipData.warpState; - workShipData.uRot = Quaternion.Slerp(workShipData.uRot, Quaternion.LookRotation(vector3_2, vector3_1), t); - workShipData.uAngularVel *= 1f - t; - } - if (num15 < 100.0) - { - float num18 = (float) (1.0 - num15 / 100.0); - float num24 = (3f - num18 - num18) * num18 * num18; - float t = num24 * num24; - if (workShipData.direction > 0) + + Vector3 up; + workShipData.uRot.ForwardUp(out workShipData.uVel, out up); + Vector3 lhs = up * (1f - num35) + (Vector3)zero * num35; + Vector3 vector3_1 = lhs - Vector3.Dot(lhs, workShipData.uVel) * workShipData.uVel; + vector3_1.Normalize(); + Vector3 vector3_2 = (Vector3)(vectorLf3_2.normalized + vectorLf3_5); + Vector3 vector3_3 = Vector3.Cross(workShipData.uVel, vector3_2); + float num46 = (float)((double)workShipData.uVel.x * (double)vector3_2.x + (double)workShipData.uVel.y * (double)vector3_2.y + (double)workShipData.uVel.z * (double)vector3_2.z); + Vector3 vector3_4 = Vector3.Cross(up, vector3_1); + double num47 = (double)up.x * (double)vector3_1.x + (double)up.y * (double)vector3_1.y + (double)up.z * (double)vector3_1.z; + if ((double)num46 < 0.0) + vector3_3 = vector3_3.normalized; + if (num47 < 0.0) + vector3_4 = vector3_4.normalized; + float num48 = num30 < 3.0 ? (float)((3.25 - num30) * 4.0) : (float)((double)num31 / (double)shipSailSpeed * (flag2 ? 0.200000002980232 : 1.0)); + vector3_3 = vector3_3 * num48 + vector3_4 * 2f; + Vector3 vector3_5 = vector3_3 - workShipData.uAngularVel; + float num49 = (double)vector3_5.sqrMagnitude < 0.100000001490116 ? 1f : 0.05f; + workShipData.uAngularVel += vector3_5 * num49; + double num50 = (double)workShipData.uSpeed * dt; + workShipData.uPos.x = workShipData.uPos.x + (double)workShipData.uVel.x * num50 + vectorLf3_6.x; + workShipData.uPos.y = workShipData.uPos.y + (double)workShipData.uVel.y * num50 + vectorLf3_6.y; + workShipData.uPos.z = workShipData.uPos.z + (double)workShipData.uVel.z * num50 + vectorLf3_6.z; + Vector3 normalized1 = workShipData.uAngularVel.normalized; + double num51 = (double)workShipData.uAngularVel.magnitude * dt * 0.5; + float w = (float)Math.Cos(num51); + float num52 = (float)Math.Sin(num51); + Quaternion quaternion = new Quaternion(normalized1.x * num52, normalized1.y * num52, normalized1.z * num52, w); + workShipData.uRot = quaternion * workShipData.uRot; + if ((double)workShipData.warpState > 0.0) { - urot = Quaternion.Slerp(workShipData.uRot, astroPose2.uRot * (gStationPool[workShipData.otherGId].shipDockRot * new Quaternion(0.7071068f, 0.0f, 0.0f, -0.7071068f)), t); + float t = workShipData.warpState * workShipData.warpState * workShipData.warpState; + workShipData.uRot = Quaternion.Slerp(workShipData.uRot, Quaternion.LookRotation(vector3_2, vector3_1), t); + workShipData.uAngularVel *= 1f - t; } - else + + if (num17 < 100.0) { - vectorLf3_1 = workShipData.uPos - astroPose1.uPos; - Vector3 normalized2 = (Vector3) vectorLf3_1.normalized; - Vector3 normalized3 = (workShipData.uVel - Vector3.Dot(workShipData.uVel, normalized2) * normalized2).normalized; - urot = Quaternion.Slerp(workShipData.uRot, Quaternion.LookRotation(normalized3, normalized2), t); + float num20 = (float)(1.0 - num17 / 100.0); + float num21 = (3f - num20 - num20) * num20 * num20; + float t = num21 * num21; + if (workShipData.direction > 0) + { + urot = Quaternion.Slerp(workShipData.uRot, astroPose2.uRot * (gStationPool[workShipData.otherGId].shipDockRot * new Quaternion(0.7071068f, 0.0f, 0.0f, -0.7071068f)), t); + } + else + { + vectorLf3_1 = workShipData.uPos - astroPose1.uPos; + Vector3 normalized2 = (Vector3)vectorLf3_1.normalized; + Vector3 normalized3 = (workShipData.uVel - Vector3.Dot(workShipData.uVel, normalized2) * normalized2).normalized; + urot = Quaternion.Slerp(workShipData.uRot, Quaternion.LookRotation(normalized3, normalized2), t); + } + + flag1 = true; } - flag1 = true; - } - if (flag3) - { - workShipData.uRot = urot; - if (workShipData.direction > 0) + + if (flag3) { - workShipData.pPosTemp = Maths.QInvRotateLF(astroPose2.uRot, workShipData.uPos - astroPose2.uPos); - workShipData.pRotTemp = Quaternion.Inverse(astroPose2.uRot) * workShipData.uRot; + workShipData.uRot = urot; + if (workShipData.direction > 0) + { + workShipData.pPosTemp = Maths.QInvRotateLF(astroPose2.uRot, workShipData.uPos - astroPose2.uPos); + workShipData.pRotTemp = Quaternion.Inverse(astroPose2.uRot) * workShipData.uRot; + } + else + { + workShipData.pPosTemp = Maths.QInvRotateLF(astroPose1.uRot, workShipData.uPos - astroPose1.uPos); + workShipData.pRotTemp = Quaternion.Inverse(astroPose1.uRot) * workShipData.uRot; + } + + urot = Quaternion.identity; + flag1 = false; } + + if ((double)__instance.shipRenderers[workShipData.shipIndex].anim.z > 1.0) + __instance.shipRenderers[workShipData.shipIndex].anim.z -= (float)dt * 0.3f; else - { - workShipData.pPosTemp = Maths.QInvRotateLF(astroPose1.uRot, workShipData.uPos - astroPose1.uPos); - workShipData.pRotTemp = Quaternion.Inverse(astroPose1.uRot) * workShipData.uRot; - } - urot = Quaternion.identity; - flag1 = false; + __instance.shipRenderers[workShipData.shipIndex].anim.z = 1f; + __instance.shipRenderers[workShipData.shipIndex].anim.w = workShipData.warpState; } - if ((double) __instance.shipRenderers[workShipData.shipIndex].anim.z > 1.0) - __instance.shipRenderers[workShipData.shipIndex].anim.z -= (float) dt * 0.3f; - else - __instance.shipRenderers[workShipData.shipIndex].anim.z = 1f; - __instance.shipRenderers[workShipData.shipIndex].anim.w = workShipData.warpState; - } - else if (workShipData.stage == 1) - { - AstroPose astroPose2 = astroPoses[workShipData.planetB]; - float num15; - if (workShipData.direction > 0) + else if (workShipData.stage == 1) { - workShipData.t -= num23 * 0.6666667f; - float num16 = workShipData.t; - if ((double) workShipData.t < 0.0) - { - workShipData.t = 1f; - num16 = 0.0f; - workShipData.stage = 2; - } - num15 = (3f - num16 - num16) * num16 * num16; - float num17 = num15 * 2f; - float num18 = (float) ((double) num15 * 2.0 - 1.0); - VectorLF3 vectorLf3_2 = astroPose2.uPos + Maths.QRotateLF(astroPose2.uRot, (VectorLF3) (gStationPool[workShipData.otherGId].shipDockPos + gStationPool[workShipData.otherGId].shipDockPos.normalized * 7.27f)); - if ((double) num15 > 0.5) + AstroPose astroPose2 = astroPoses[workShipData.planetB]; + float num17; + if (workShipData.direction > 0) { - VectorLF3 vectorLf3_3 = astroPose2.uPos + Maths.QRotateLF(astroPose2.uRot, workShipData.pPosTemp); - workShipData.uPos = vectorLf3_2 * (1.0 - (double) num18) + vectorLf3_3 * (double) num18; - workShipData.uRot = astroPose2.uRot * Quaternion.Slerp(gStationPool[workShipData.otherGId].shipDockRot * new Quaternion(0.7071068f, 0.0f, 0.0f, -0.7071068f), workShipData.pRotTemp, (float) ((double) num18 * 1.5 - 0.5)); + workShipData.t -= num26 * 0.6666667f; + float num18 = workShipData.t; + if ((double)workShipData.t < 0.0) + { + workShipData.t = 1f; + num18 = 0.0f; + workShipData.stage = 2; + } + + num17 = (3f - num18 - num18) * num18 * num18; + float num19 = num17 * 2f; + float num20 = (float)((double)num17 * 2.0 - 1.0); + VectorLF3 vectorLf3_2 = astroPose2.uPos + Maths.QRotateLF(astroPose2.uRot, (VectorLF3)(gStationPool[workShipData.otherGId].shipDockPos + gStationPool[workShipData.otherGId].shipDockPos.normalized * 7.27f)); + if ((double)num17 > 0.5) + { + VectorLF3 vectorLf3_3 = astroPose2.uPos + Maths.QRotateLF(astroPose2.uRot, workShipData.pPosTemp); + workShipData.uPos = vectorLf3_2 * (1.0 - (double)num20) + vectorLf3_3 * (double)num20; + workShipData.uRot = astroPose2.uRot * Quaternion.Slerp(gStationPool[workShipData.otherGId].shipDockRot * new Quaternion(0.7071068f, 0.0f, 0.0f, -0.7071068f), workShipData.pRotTemp, (float)((double)num20 * 1.5 - 0.5)); + } + else + { + VectorLF3 vectorLf3_3 = astroPose2.uPos + Maths.QRotateLF(astroPose2.uRot, (VectorLF3)(gStationPool[workShipData.otherGId].shipDockPos + gStationPool[workShipData.otherGId].shipDockPos.normalized * -14.4f)); + workShipData.uPos = vectorLf3_3 * (1.0 - (double)num19) + vectorLf3_2 * (double)num19; + workShipData.uRot = astroPose2.uRot * (gStationPool[workShipData.otherGId].shipDockRot * new Quaternion(0.7071068f, 0.0f, 0.0f, -0.7071068f)); + } } else { - VectorLF3 vectorLf3_3 = astroPose2.uPos + Maths.QRotateLF(astroPose2.uRot, (VectorLF3) (gStationPool[workShipData.otherGId].shipDockPos + gStationPool[workShipData.otherGId].shipDockPos.normalized * -14.4f)); - workShipData.uPos = vectorLf3_3 * (1.0 - (double) num17) + vectorLf3_2 * (double) num17; + workShipData.t += num26; + float num18 = workShipData.t; + if ((double)workShipData.t > 1.0) + { + workShipData.t = 1f; + num18 = 1f; + workShipData.stage = 0; + } + + num17 = (3f - num18 - num18) * num18 * num18; + workShipData.uPos = astroPose2.uPos + Maths.QRotateLF(astroPose2.uRot, (VectorLF3)(gStationPool[workShipData.otherGId].shipDockPos + gStationPool[workShipData.otherGId].shipDockPos.normalized * (float)(39.4000015258789 * (double)num17 - 14.3999996185303))); workShipData.uRot = astroPose2.uRot * (gStationPool[workShipData.otherGId].shipDockRot * new Quaternion(0.7071068f, 0.0f, 0.0f, -0.7071068f)); } + + workShipData.uVel.x = 0.0f; + workShipData.uVel.y = 0.0f; + workShipData.uVel.z = 0.0f; + workShipData.uSpeed = 0.0f; + workShipData.uAngularVel.x = 0.0f; + workShipData.uAngularVel.y = 0.0f; + workShipData.uAngularVel.z = 0.0f; + workShipData.uAngularSpeed = 0.0f; + __instance.shipRenderers[workShipData.shipIndex].anim.z = (float)((double)num17 * 1.70000004768372 - 0.699999988079071); } else { - workShipData.t += num23; - float num16 = workShipData.t; - if ((double) workShipData.t > 1.0) - { - workShipData.t = 1f; - num16 = 1f; - workShipData.stage = 0; - } - num15 = (3f - num16 - num16) * num16 * num16; - workShipData.uPos = astroPose2.uPos + Maths.QRotateLF(astroPose2.uRot, (VectorLF3) (gStationPool[workShipData.otherGId].shipDockPos + gStationPool[workShipData.otherGId].shipDockPos.normalized * (float) (39.4000015258789 * (double) num15 - 14.3999996185303))); - workShipData.uRot = astroPose2.uRot * (gStationPool[workShipData.otherGId].shipDockRot * new Quaternion(0.7071068f, 0.0f, 0.0f, -0.7071068f)); - } - workShipData.uVel.x = 0.0f; - workShipData.uVel.y = 0.0f; - workShipData.uVel.z = 0.0f; - workShipData.uSpeed = 0.0f; - workShipData.uAngularVel.x = 0.0f; - workShipData.uAngularVel.y = 0.0f; - workShipData.uAngularVel.z = 0.0f; - workShipData.uAngularSpeed = 0.0f; - __instance.shipRenderers[workShipData.shipIndex].anim.z = (float) ((double) num15 * 1.70000004768372 - 0.699999988079071); - } - else - { - if (workShipData.direction > 0) - { - workShipData.t -= 0.0334f; - if ((double) workShipData.t < 0.0) + if (workShipData.direction > 0) { - workShipData.t = 0.0f; - StationComponent stationComponent = gStationPool[workShipData.otherGId]; - StationStore[] storage = stationComponent.storage; - vectorLf3_1 = astroPoses[workShipData.planetA].uPos - astroPoses[workShipData.planetB].uPos; - if (vectorLf3_1.sqrMagnitude > __instance.warpEnableDist * __instance.warpEnableDist && workShipData.warperCnt == 0 && stationComponent.warperCount > 0) - { - lock (consumeRegister) - { - ++workShipData.warperCnt; - --stationComponent.warperCount; - ++consumeRegister[1210]; - } - } - if (workShipData.itemCount > 0) + workShipData.t -= 0.0334f; + if ((double)workShipData.t < 0.0) { - stationComponent.AddItem(workShipData.itemId, workShipData.itemCount); - workShipData.itemCount = 0; - if (__instance.workShipOrders[destinationIndex].otherStationGId > 0) + workShipData.t = 0.0f; + StationComponent dstStation = gStationPool[workShipData.otherGId]; + StationStore[] storage = dstStation.storage; + vectorLf3_1 = astroPoses[workShipData.planetA].uPos - astroPoses[workShipData.planetB].uPos; + if (vectorLf3_1.sqrMagnitude > __instance.warpEnableDist * __instance.warpEnableDist && workShipData.warperCnt == 0 && dstStation.warperCount > 0) { - lock (storage) + lock (consumeRegister) { - if (storage[__instance.workShipOrders[destinationIndex].otherIndex].itemId == __instance.workShipOrders[destinationIndex].itemId) - storage[__instance.workShipOrders[destinationIndex].otherIndex].remoteOrder -= __instance.workShipOrders[destinationIndex].otherOrdered; + ++workShipData.warperCnt; + --dstStation.warperCount; + ++consumeRegister[1210]; } - __instance.workShipOrders[destinationIndex].ClearOther(); } - if (__instance.remotePairCount > 0) + + if (workShipData.itemCount > 0) { - __instance.remotePairProcess %= __instance.remotePairCount; - int remotePairProcess = __instance.remotePairProcess; - int index = __instance.remotePairProcess; - do + dstStation.AddItem(workShipData.itemId, workShipData.itemCount, workShipData.inc); + factory.NotifyShipDelivery(workShipData.planetA, __instance, workShipData.planetB, dstStation, workShipData.itemId, workShipData.itemCount); + workShipData.itemCount = 0; + workShipData.inc = 0; + if (__instance.workShipOrders[destinationIndex].otherStationGId > 0) { - SupplyDemandPair remotePair = __instance.remotePairs[index]; - if (remotePair.demandId == __instance.gid && remotePair.supplyId == stationComponent.gid) + lock (storage) { - lock (__instance.storage) - { - num6 = __instance.storage[remotePair.demandIndex].remoteDemandCount; - num7 = __instance.storage[remotePair.demandIndex].totalDemandCount; - num8 = __instance.storage[remotePair.demandIndex].itemId; - } + if (storage[__instance.workShipOrders[destinationIndex].otherIndex].itemId == __instance.workShipOrders[destinationIndex].itemId) + storage[__instance.workShipOrders[destinationIndex].otherIndex].remoteOrder -= __instance.workShipOrders[destinationIndex].otherOrdered; } - if (remotePair.demandId == __instance.gid && remotePair.supplyId == stationComponent.gid) + + __instance.workShipOrders[destinationIndex].ClearOther(); + } + + if (__instance.remotePairCount > 0) + { + __instance.remotePairProcess %= __instance.remotePairCount; + int remotePairProcess = __instance.remotePairProcess; + int index = __instance.remotePairProcess; + do { - lock (storage) + SupplyDemandPair remotePair = __instance.remotePairs[index]; + if (remotePair.demandId == __instance.gid && remotePair.supplyId == dstStation.gid) { - num12 = storage[remotePair.supplyIndex].count; - num13 = storage[remotePair.supplyIndex].remoteSupplyCount; - num14 = storage[remotePair.supplyIndex].totalSupplyCount; + lock (__instance.storage) + { + num7 = __instance.storage[remotePair.demandIndex].remoteDemandCount; + num8 = __instance.storage[remotePair.demandIndex].totalDemandCount; + num9 = __instance.storage[remotePair.demandIndex].itemId; + } } - } - if (remotePair.demandId == __instance.gid && remotePair.supplyId == stationComponent.gid && (num6 > 0 && num7 > 0) && (num12 >= shipCarries && num13 >= shipCarries && num14 >= shipCarries)) - { - int num15 = num12; - if (num15 > shipCarries) - num15 = shipCarries; - workShipData.itemId = __instance.workShipOrders[destinationIndex].itemId = num8; - workShipData.itemCount = num15; - lock (storage) - storage[remotePair.supplyIndex].count -= num15; - __instance.workShipOrders[destinationIndex].otherStationGId = stationComponent.gid; - __instance.workShipOrders[destinationIndex].thisIndex = remotePair.demandIndex; - __instance.workShipOrders[destinationIndex].otherIndex = remotePair.supplyIndex; - __instance.workShipOrders[destinationIndex].thisOrdered = num15; - __instance.workShipOrders[destinationIndex].otherOrdered = 0; - lock (__instance.storage) + + if (remotePair.demandId == __instance.gid && remotePair.supplyId == dstStation.gid) { - __instance.storage[remotePair.demandIndex].remoteOrder += num15; - break; + lock (storage) + { + num13 = storage[remotePair.supplyIndex].count; + num14 = storage[remotePair.supplyIndex].inc; + num15 = storage[remotePair.supplyIndex].remoteSupplyCount; + num16 = storage[remotePair.supplyIndex].totalSupplyCount; + } } - } - else - index = (index + 1) % __instance.remotePairCount; + + if (remotePair.demandId == __instance.gid && remotePair.supplyId == dstStation.gid && (num7 > 0 && num8 > 0) && (num13 >= shipCarries && num15 >= shipCarries && num16 >= shipCarries)) + { + int num17 = shipCarries < num13 ? shipCarries : num13; + int num18 = (int)((double)num14 / (double)num13 * (double)num17 + 0.5); + workShipData.itemId = __instance.workShipOrders[destinationIndex].itemId = num9; + workShipData.itemCount = num17; + workShipData.inc = num18; + lock (storage) + { + storage[remotePair.supplyIndex].count -= num17; + storage[remotePair.supplyIndex].inc -= num18; + } + + __instance.workShipOrders[destinationIndex].otherStationGId = dstStation.gid; + __instance.workShipOrders[destinationIndex].thisIndex = remotePair.demandIndex; + __instance.workShipOrders[destinationIndex].otherIndex = remotePair.supplyIndex; + __instance.workShipOrders[destinationIndex].thisOrdered = num17; + __instance.workShipOrders[destinationIndex].otherOrdered = 0; + lock (__instance.storage) + { + __instance.storage[remotePair.demandIndex].remoteOrder += num17; + break; + } + } + else + index = (index + 1) % __instance.remotePairCount; + } while (remotePairProcess != index); } - while (remotePairProcess != index); } - } - else - { - int itemId = workShipData.itemId; - int count = shipCarries; - stationComponent.TakeItem(ref itemId, ref count); - workShipData.itemCount = count; - if (__instance.workShipOrders[destinationIndex].otherStationGId > 0) + else { - lock (storage) + int itemId = workShipData.itemId; + int count = shipCarries; + int inc; + dstStation.TakeItem(ref itemId, ref count, out inc); + workShipData.itemCount = count; + workShipData.inc = inc; + if (__instance.workShipOrders[destinationIndex].otherStationGId > 0) { - if (storage[__instance.workShipOrders[destinationIndex].otherIndex].itemId == __instance.workShipOrders[destinationIndex].itemId) - storage[__instance.workShipOrders[destinationIndex].otherIndex].remoteOrder -= __instance.workShipOrders[destinationIndex].otherOrdered; + lock (storage) + { + if (storage[__instance.workShipOrders[destinationIndex].otherIndex].itemId == __instance.workShipOrders[destinationIndex].itemId) + storage[__instance.workShipOrders[destinationIndex].otherIndex].remoteOrder -= __instance.workShipOrders[destinationIndex].otherOrdered; + } + + __instance.workShipOrders[destinationIndex].ClearOther(); } - __instance.workShipOrders[destinationIndex].ClearOther(); - } - lock (__instance.storage) - { - if (__instance.storage[__instance.workShipOrders[destinationIndex].thisIndex].itemId == __instance.workShipOrders[destinationIndex].itemId) + + lock (__instance.storage) { - if (__instance.workShipOrders[destinationIndex].thisOrdered != count) + if (__instance.storage[__instance.workShipOrders[destinationIndex].thisIndex].itemId == __instance.workShipOrders[destinationIndex].itemId) { - int num15 = count - __instance.workShipOrders[destinationIndex].thisOrdered; - __instance.storage[__instance.workShipOrders[destinationIndex].thisIndex].remoteOrder += num15; - __instance.workShipOrders[destinationIndex].thisOrdered += num15; + if (__instance.workShipOrders[destinationIndex].thisOrdered != count) + { + int num17 = count - __instance.workShipOrders[destinationIndex].thisOrdered; + __instance.storage[__instance.workShipOrders[destinationIndex].thisIndex].remoteOrder += num17; + __instance.workShipOrders[destinationIndex].thisOrdered += num17; + } } } } + + workShipData.direction = -1; } - workShipData.direction = -1; } - } - else - { - workShipData.t += 0.0334f; - if ((double) workShipData.t > 1.0) + else { - workShipData.t = 0.0f; - workShipData.stage = 1; + workShipData.t += 0.0334f; + if ((double)workShipData.t > 1.0) + { + workShipData.t = 0.0f; + workShipData.stage = 1; + } } + + AstroPose astroPose2 = astroPoses[workShipData.planetB]; + workShipData.uPos = astroPose2.uPos + Maths.QRotateLF(astroPose2.uRot, (VectorLF3)(gStationPool[workShipData.otherGId].shipDockPos + gStationPool[workShipData.otherGId].shipDockPos.normalized * -14.4f)); + workShipData.uVel.x = 0.0f; + workShipData.uVel.y = 0.0f; + workShipData.uVel.z = 0.0f; + workShipData.uSpeed = 0.0f; + workShipData.uRot = astroPose2.uRot * (gStationPool[workShipData.otherGId].shipDockRot * new Quaternion(0.7071068f, 0.0f, 0.0f, -0.7071068f)); + workShipData.uAngularVel.x = 0.0f; + workShipData.uAngularVel.y = 0.0f; + workShipData.uAngularVel.z = 0.0f; + workShipData.uAngularSpeed = 0.0f; + workShipData.pPosTemp = (VectorLF3)Vector3.zero; + workShipData.pRotTemp = Quaternion.identity; + __instance.shipRenderers[workShipData.shipIndex].anim.z = 0.0f; } - AstroPose astroPose2 = astroPoses[workShipData.planetB]; - workShipData.uPos = astroPose2.uPos + Maths.QRotateLF(astroPose2.uRot, (VectorLF3) (gStationPool[workShipData.otherGId].shipDockPos + gStationPool[workShipData.otherGId].shipDockPos.normalized * -14.4f)); - workShipData.uVel.x = 0.0f; - workShipData.uVel.y = 0.0f; - workShipData.uVel.z = 0.0f; - workShipData.uSpeed = 0.0f; - workShipData.uRot = astroPose2.uRot * (gStationPool[workShipData.otherGId].shipDockRot * new Quaternion(0.7071068f, 0.0f, 0.0f, -0.7071068f)); - workShipData.uAngularVel.x = 0.0f; - workShipData.uAngularVel.y = 0.0f; - workShipData.uAngularVel.z = 0.0f; - workShipData.uAngularSpeed = 0.0f; - workShipData.pPosTemp = (VectorLF3) Vector3.zero; - workShipData.pRotTemp = Quaternion.identity; - __instance.shipRenderers[workShipData.shipIndex].anim.z = 0.0f; - } - __instance.workShipDatas[destinationIndex] = workShipData; - if (flag1) - { - __instance.shipRenderers[workShipData.shipIndex].SetPose(workShipData.uPos, urot, relativePos, relativeRot, workShipData.uVel * workShipData.uSpeed, workShipData.itemCount > 0 ? workShipData.itemId : 0); - if (starmap) + + __instance.workShipDatas[destinationIndex] = workShipData; + if (flag1) { - ref ShipUIRenderingData local = ref __instance.shipUIRenderers[workShipData.shipIndex]; - VectorLF3 uPos = workShipData.uPos; - Quaternion _urot = urot; - vectorLf3_1 = astroPoses[workShipData.planetA].uPos - astroPoses[workShipData.planetB].uPos; - double magnitude = vectorLf3_1.magnitude; - double uSpeed = (double) workShipData.uSpeed; - int _itemId = workShipData.itemCount > 0 ? workShipData.itemId : 0; - local.SetPose(uPos, _urot, (float) magnitude, (float) uSpeed, _itemId); + __instance.shipRenderers[workShipData.shipIndex].SetPose(workShipData.uPos, urot, relativePos, relativeRot, workShipData.uVel * workShipData.uSpeed, workShipData.itemCount > 0 ? workShipData.itemId : 0); + if (starmap) + { + ref ShipUIRenderingData local = ref __instance.shipUIRenderers[workShipData.shipIndex]; + VectorLF3 uPos = workShipData.uPos; + Quaternion _urot = urot; + vectorLf3_1 = astroPoses[workShipData.planetA].uPos - astroPoses[workShipData.planetB].uPos; + double magnitude = vectorLf3_1.magnitude; + double uSpeed = (double)workShipData.uSpeed; + int _itemId = workShipData.itemCount > 0 ? workShipData.itemId : 0; + local.SetPose(uPos, _urot, (float)magnitude, (float)uSpeed, _itemId); + } } - } - else - { - __instance.shipRenderers[workShipData.shipIndex].SetPose(workShipData.uPos, workShipData.uRot, relativePos, relativeRot, workShipData.uVel * workShipData.uSpeed, workShipData.itemCount > 0 ? workShipData.itemId : 0); - if (starmap) + else { - ref ShipUIRenderingData local = ref __instance.shipUIRenderers[workShipData.shipIndex]; - VectorLF3 uPos = workShipData.uPos; - Quaternion uRot = workShipData.uRot; - vectorLf3_1 = astroPoses[workShipData.planetA].uPos - astroPoses[workShipData.planetB].uPos; - double magnitude = vectorLf3_1.magnitude; - double uSpeed = (double) workShipData.uSpeed; - int _itemId = workShipData.itemCount > 0 ? workShipData.itemId : 0; - local.SetPose(uPos, uRot, (float) magnitude, (float) uSpeed, _itemId); + __instance.shipRenderers[workShipData.shipIndex].SetPose(workShipData.uPos, workShipData.uRot, relativePos, relativeRot, workShipData.uVel * workShipData.uSpeed, workShipData.itemCount > 0 ? workShipData.itemId : 0); + if (starmap) + { + ref ShipUIRenderingData local = ref __instance.shipUIRenderers[workShipData.shipIndex]; + VectorLF3 uPos = workShipData.uPos; + Quaternion uRot = workShipData.uRot; + vectorLf3_1 = astroPoses[workShipData.planetA].uPos - astroPoses[workShipData.planetB].uPos; + double magnitude = vectorLf3_1.magnitude; + double uSpeed = (double)workShipData.uSpeed; + int _itemId = workShipData.itemCount > 0 ? workShipData.itemId : 0; + local.SetPose(uPos, uRot, (float)magnitude, (float)uSpeed, _itemId); + } } + + if ((double)__instance.shipRenderers[workShipData.shipIndex].anim.z < 0.0) + __instance.shipRenderers[workShipData.shipIndex].anim.z = 0.0f; } - if ((double) __instance.shipRenderers[workShipData.shipIndex].anim.z < 0.0) - __instance.shipRenderers[workShipData.shipIndex].anim.z = 0.0f; - } - __instance.ShipRenderersOnTick(astroPoses, relativePos, relativeRot); - return false; - } + __instance.ShipRenderersOnTick(astroPoses, relativePos, relativeRot); + return false; } + + } } \ No newline at end of file diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIGalaxySelect/SetStarMapGalaxy.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIGalaxySelect/SetStarMapGalaxy.cs index 5b7e4410..158e0294 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIGalaxySelect/SetStarMapGalaxy.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIGalaxySelect/SetStarMapGalaxy.cs @@ -14,6 +14,7 @@ public static bool SetStarmapGalaxy(ref UIGalaxySelect __instance) if (NebulaModAPI.MultiplayerSession != null && NebulaModAPI.MultiplayerSession.LocalPlayer.IsClient && !GSSettings.lobbyReceivedUpdateValues) { NebulaModAPI.MultiplayerSession.Network.SendPacket(new LobbyRequestUpdateSolarSystems()); + GS2.Warn("Nebula Requested Update"); return false; } GSSettings.lobbyReceivedUpdateValues = false; @@ -22,24 +23,29 @@ public static bool SetStarmapGalaxy(ref UIGalaxySelect __instance) if (__instance.gameDesc == null) GS2.Warn("GameDesc Null 3"); if (__instance.gameDesc.starCount <= 0) __instance.gameDesc.starCount = 1; - GalaxyData galaxy = __instance.starmap.galaxyData; + GalaxyData galaxy;// = __instance.starmap.galaxyData; if (GS2.Vanilla) galaxy = UniverseGen.CreateGalaxy(__instance.gameDesc); else //GS2.Warn("Processing Galaxy"); - galaxy = GS2.ProcessGalaxy(__instance.gameDesc, true); + galaxy = GS2.ProcessGalaxy(__instance.gameDesc, true); //sp00ktober you probably want to alter this instead //GS2.Warn("Done"); if (__instance.starmap == null) GS2.Warn("Starmap Null"); if (__instance.starmap.galaxyData == null) GS2.Warn("starmapgalaxydata Null"); - if (__instance.starmap.galaxyData != null) __instance.starmap.galaxyData.Free(); + if (__instance.starmap.galaxyData != null) + { + GS2.Warn("Freeing GalaxyData!!!!!!!!!!!!!!!!!!!"); + __instance.starmap.galaxyData.Free(); + } if (galaxy == null) GS2.Warn("galaxy Null"); //else GS2.Warn("Galaxy not null"); __instance.starmap.galaxyData = galaxy; - GameMain.data.galaxy = galaxy; // this line is important to let the client load into the correct galaxy lol + // GameMain.data.galaxy = galaxy; // this line is important to let the client load into the correct galaxy lol - __instance.UpdateUIDisplay(__instance.starmap.galaxyData); + // __instance.UpdateUIDisplay(__instance.starmap.galaxyData); + __instance.UpdateUIDisplay(galaxy); __instance.UpdateParametersUIDisplay(); __instance.autoCameraYaw = true; __instance.lastCameraYaw = __instance.cameraPoser.yawWanted; @@ -51,7 +57,8 @@ public static bool SetStarmapGalaxy(ref UIGalaxySelect __instance) var starCountText = GameObject.Find("GS Star Count"); if (starCountText == null) GS2.Warn("starcounttext null"); if (starCountText == null) starCountText = CreateStarCountText(__instance.starCountSlider); - starCountText.GetComponent().text = __instance.starmap.galaxyData.starCount + " (" + GS2.ActiveGenerator.Name + ")"; + //starCountText.GetComponent().text = __instance.starmap.galaxyData.starCount + " (" + GS2.ActiveGenerator.Name + ")"; + starCountText.GetComponent().text = galaxy.starCount + " (" + GS2.ActiveGenerator.Name + ")"; } else { @@ -90,6 +97,13 @@ public static void SetStarmapGalaxy_Postfix(UIGalaxySelect __instance) // this is needed at least in the nebula lobby, throws index out of bounds if not done. if(GS2.galaxy == null) { + GS2.Log("Galaxy Null, Returning from Postfix"); + return; + } + if (NebulaModAPI.MultiplayerSession == null) + { + GS2.Log("Nebula Null, Returning from Postfix"); + return; } if(GameMain.universeSimulator == null) diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIPlanetDetail/OnPlanetDataSet.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIPlanetDetail/OnPlanetDataSet.cs index d9f626fc..e317ff2e 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIPlanetDetail/OnPlanetDataSet.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIPlanetDetail/OnPlanetDataSet.cs @@ -10,13 +10,16 @@ public partial class PatchOnUIPlanetDetail [HarmonyPatch(typeof(UIPlanetDetail), "OnPlanetDataSet")] public static void OnPlanetDataSet(ref UIPlanetDetail __instance, Text ___obliquityValueText, ref PlanetData ____planet) { + GS2.Warn("Dataset"); + GS2.Warn(___obliquityValueText.transform.parent.transform.parent.childCount.ToString()); // Add the planets radius to the Planet Detail UI - if (___obliquityValueText.transform.parent.transform.parent.childCount == 6) + if (___obliquityValueText.transform.parent.transform.parent.childCount == 7) { GameObject radiusLabel; var obliquityLabel = ___obliquityValueText.transform.parent.gameObject; radiusLabel = Object.Instantiate(obliquityLabel, obliquityLabel.transform.parent.transform); - + var parentRect = obliquityLabel.transform.parent.transform.GetComponent(); + parentRect.sizeDelta = new Vector2(0,40); radiusLabel.transform.localPosition += Vector3.down * 20; var radiusLabelText = radiusLabel.GetComponent(); radiusLabelText.GetComponent().enabled = false; @@ -36,7 +39,7 @@ public static void OnPlanetDataSet(ref UIPlanetDetail __instance, Text ___obliqu radiusValueText.text = __instance.planet.realRadius.ToString(); } - if (___obliquityValueText.transform.parent.transform.parent.childCount == 7) + if (___obliquityValueText.transform.parent.transform.parent.childCount == 8) { var p = ___obliquityValueText.transform.parent.parent; var radiusLabel = p.GetChild(p.childCount - 1).gameObject; @@ -73,6 +76,13 @@ public static bool OnPlanetDataSet(ref UIPlanetDetail __instance, ref UIResAmoun ___orbitRadiusValueTextEx.text = __instance.planet.name; ___orbitPeriodValueText.text = __instance.planet.orbitalPeriod.ToString("#,##0") + "空格秒".Translate(); ___rotationPeriodValueText.text = __instance.planet.rotationPeriod.ToString("#,##0") + "空格秒".Translate(); + float f = __instance.planet.orbitInclination; + float t = 180f - __instance.planet.orbitLongitude; + if ((double) f < 0.0) + { + f = -f; + t = 180f + t; + } var num1 = Mathf.Abs(__instance.planet.orbitInclination); var num2 = (int)num1; var num3 = (int)((num1 - (double)num2) * 60.0); @@ -81,10 +91,13 @@ public static bool OnPlanetDataSet(ref UIPlanetDetail __instance, ref UIResAmoun var num4 = Mathf.Abs(__instance.planet.obliquity); var num5 = (int)num4; var num6 = (int)((num4 - (double)num5) * 60.0); + int numa; + int numb = (int) (((double) (numa = (int) Mathf.Repeat(t, 360f)) - (double) numa) * 60.0); if (__instance.planet.obliquity < 0.0) num5 = -num5; ___inclinationValueText.text = string.Format("{0}° {1}′", num2, num3); ___obliquityValueText.text = string.Format("{0}° {1}′", num5, num6); + __instance.longiAscValueText.text = string.Format("{0}° {1}′", (object) numa, (object) numb); var num7 = 0; if (__instance.planet.type != EPlanetType.Gas) { diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIPlanetDetail/SetResCount.cs b/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIPlanetDetail/SetResCount.cs index 82b1db6b..4902d966 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIPlanetDetail/SetResCount.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Patches/UIPlanetDetail/SetResCount.cs @@ -9,7 +9,7 @@ public partial class PatchOnUIPlanetDetail [HarmonyPatch(typeof(UIPlanetDetail), "SetResCount")] public static bool SetResCount(int count, ref RectTransform ___rectTrans, ref RectTransform ___paramGroup) // Adjust the height of the PlanetDetail UI to allow for Radius Text { - ___rectTrans.sizeDelta = new Vector2(___rectTrans.sizeDelta.x, 190 + count * 20 + 20f); + ___rectTrans.sizeDelta = new Vector2(___rectTrans.sizeDelta.x, 210 + count * 20 + 20f); ___paramGroup.anchoredPosition = new Vector2(___paramGroup.anchoredPosition.x, -90 - count * 20); return false; } diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Planet Generation/Modeler.cs b/GalacticScale2/Scripts/GalacticScale2.0/Planet Generation/Modeler.cs index 796bd009..474a03b4 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Planet Generation/Modeler.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Planet Generation/Modeler.cs @@ -13,6 +13,13 @@ public static class Modeler public static List planetQueue = new List(); public static bool planetQueueSorted; + public static void Reset() + { + planetModQueue = new List(); + planetModQueueSorted = false; + planetQueue = new List(); + planetQueueSorted = false; + } public static int DistanceComparison(PlanetData p1, PlanetData p2) { var d1 = distanceTo(p1); @@ -194,6 +201,7 @@ public static void ModelingCoroutine() if (currentModelingPlanet != null) try { + // GS2.Warn($"Modelling {currentModelingPlanet.name}"); ModelingPlanetMain(currentModelingPlanet); } catch (Exception message) diff --git a/GalacticScale2/Scripts/GalacticScale2.0/Utils/HandleLocalStarPlanets.cs b/GalacticScale2/Scripts/GalacticScale2.0/Utils/HandleLocalStarPlanets.cs index 8f742480..12b10c02 100644 --- a/GalacticScale2/Scripts/GalacticScale2.0/Utils/HandleLocalStarPlanets.cs +++ b/GalacticScale2/Scripts/GalacticScale2.0/Utils/HandleLocalStarPlanets.cs @@ -46,6 +46,12 @@ public static bool Update() var localPlanet = GameMain.data.localPlanet; closestStar = localStar; closestPlanet = localPlanet; + if (localPlanet != null && VFInput.shift && VFInput.alt) + { + var radii = TransitionRadii.ContainsKey(localPlanet) ? TransitionRadii[localPlanet].ToString() : "N/A"; + + Warn($"DistanceTo: {DistanceTo(localPlanet)} / {radii}"); + } var warping = GameMain.mainPlayer.warping; if (localStar != null && !localStar.loaded) @@ -53,6 +59,7 @@ public static bool Update() EnsureStarStillLocal(); if (closestStar == null) { + localStar.Unload(); LogStatus("Left Star...Searching"); SearchStar(); } @@ -116,6 +123,7 @@ public static bool Update() resetCamera = true; LogStatus($"Leaving Planet {localPlanet.name} as it is not closest"); GameMain.data.LeavePlanet(); + GameMain.mainPlayer.NotifyLocalAstroChange(); } } else if (closestPlanet != null) @@ -299,7 +307,7 @@ private static double TransisionDistance(PlanetData planet) if (distanceAU * 20000f - 100f < transitionDistance) { Log($"Changed Transition Distance for {planet.name} from {transitionDistance} to {distanceAU * 20000f - 100f}"); - transitionDistance = (int)distanceAU * 20000 - 100; + transitionDistance = distanceAU * 20000f - 100f; } } else if (planet.orbitAroundPlanet != null) //If this is a moon @@ -394,10 +402,18 @@ private static double TransisionDistance(PlanetData planet) } } - if (transitionDistance < (planet.realRadius + 100)) transitionDistance = planet.realRadius + 100; + if (transitionDistance < 0)//(planet.realRadius + 10)) + { + Warn($"changing {planet.name} transition distance from {transitionDistance} to {planet.realRadius + 10}"); + transitionDistance = planet.realRadius + 10; + } if (!TransitionRadii.ContainsKey(planet)) TransitionRadii.Add(planet, transitionDistance); + else + { + Warn("ALREADY CONTAINS DISTANCE"); + } Log($"Transition Radius: {transitionDistance} for {planet.name} with radius {planet.realRadius}"); return transitionDistance; } } -} \ No newline at end of file +} diff --git a/GalacticScale2/obj/DSP_Plugins.GalacticScale.csproj.nuget.dgspec.json b/GalacticScale2/obj/DSP_Plugins.GalacticScale.csproj.nuget.dgspec.json index f9a13c13..45bdc45a 100644 --- a/GalacticScale2/obj/DSP_Plugins.GalacticScale.csproj.nuget.dgspec.json +++ b/GalacticScale2/obj/DSP_Plugins.GalacticScale.csproj.nuget.dgspec.json @@ -47,12 +47,6 @@ "target": "Package", "version": "[5.*, )" }, - "DysonSphereProgram.GameLibs": { - "include": "Compile", - "suppressParent": "All", - "target": "Package", - "version": "[*-*, )" - }, "UnityEngine.Modules": { "include": "Runtime, Build, Native, ContentFiles, Analyzers, BuildTransitive", "suppressParent": "All", diff --git a/GalacticScale2/obj/project.assets.json b/GalacticScale2/obj/project.assets.json index b63f6d10..46c374ae 100644 --- a/GalacticScale2/obj/project.assets.json +++ b/GalacticScale2/obj/project.assets.json @@ -30,20 +30,6 @@ "build/BepInEx.Core.targets": {} } }, - "DysonSphereProgram.GameLibs/0.8.23.9989-r.0": { - "type": "package", - "compile": { - "lib/net45/Assembly-CSharp.dll": {}, - "lib/net45/Unity.TextMeshPro.dll": {}, - "lib/net45/UnityEngine.Networking.dll": {}, - "lib/net45/UnityEngine.SpatialTracking.dll": {}, - "lib/net45/UnityEngine.Timeline.dll": {}, - "lib/net45/UnityEngine.UI.dll": {} - }, - "runtime": { - "lib/net45/_._": {} - } - }, "HarmonyX/2.5.5": { "type": "package", "dependencies": { @@ -200,20 +186,6 @@ "build/BepInEx.Core.targets": {} } }, - "DysonSphereProgram.GameLibs/0.8.23.9989-r.0": { - "type": "package", - "compile": { - "lib/net45/Assembly-CSharp.dll": {}, - "lib/net45/Unity.TextMeshPro.dll": {}, - "lib/net45/UnityEngine.Networking.dll": {}, - "lib/net45/UnityEngine.SpatialTracking.dll": {}, - "lib/net45/UnityEngine.Timeline.dll": {}, - "lib/net45/UnityEngine.UI.dll": {} - }, - "runtime": { - "lib/net45/_._": {} - } - }, "HarmonyX/2.5.5": { "type": "package", "dependencies": { @@ -370,20 +342,6 @@ "build/BepInEx.Core.targets": {} } }, - "DysonSphereProgram.GameLibs/0.8.23.9989-r.0": { - "type": "package", - "compile": { - "lib/net45/Assembly-CSharp.dll": {}, - "lib/net45/Unity.TextMeshPro.dll": {}, - "lib/net45/UnityEngine.Networking.dll": {}, - "lib/net45/UnityEngine.SpatialTracking.dll": {}, - "lib/net45/UnityEngine.Timeline.dll": {}, - "lib/net45/UnityEngine.UI.dll": {} - }, - "runtime": { - "lib/net45/_._": {} - } - }, "HarmonyX/2.5.5": { "type": "package", "dependencies": { @@ -540,20 +498,6 @@ "build/BepInEx.Core.targets": {} } }, - "DysonSphereProgram.GameLibs/0.8.23.9989-r.0": { - "type": "package", - "compile": { - "lib/net45/Assembly-CSharp.dll": {}, - "lib/net45/Unity.TextMeshPro.dll": {}, - "lib/net45/UnityEngine.Networking.dll": {}, - "lib/net45/UnityEngine.SpatialTracking.dll": {}, - "lib/net45/UnityEngine.Timeline.dll": {}, - "lib/net45/UnityEngine.UI.dll": {} - }, - "runtime": { - "lib/net45/_._": {} - } - }, "HarmonyX/2.5.5": { "type": "package", "dependencies": { @@ -727,28 +671,6 @@ "tools/Install.ps1" ] }, - "DysonSphereProgram.GameLibs/0.8.23.9989-r.0": { - "sha512": "h1d5AdYdDEIcdUay9MV2uGosGW8mKKd2CyxC3t/CMX4gr41Wq/N3O2HJvG7mSTr8PQNEItwwRGX7ioeBKixpHA==", - "type": "package", - "path": "dysonsphereprogram.gamelibs/0.8.23.9989-r.0", - "files": [ - ".nupkg.metadata", - "dysonsphereprogram.gamelibs.0.8.23.9989-r.0.nupkg.sha512", - "dysonsphereprogram.gamelibs.nuspec", - "lib/net45/Assembly-CSharp.dll", - "lib/net45/Unity.TextMeshPro.dll", - "lib/net45/UnityEngine.Networking.dll", - "lib/net45/UnityEngine.SpatialTracking.dll", - "lib/net45/UnityEngine.Timeline.dll", - "lib/net45/UnityEngine.UI.dll", - "lib/netstandard2.0/Assembly-CSharp.dll", - "lib/netstandard2.0/Unity.TextMeshPro.dll", - "lib/netstandard2.0/UnityEngine.Networking.dll", - "lib/netstandard2.0/UnityEngine.SpatialTracking.dll", - "lib/netstandard2.0/UnityEngine.Timeline.dll", - "lib/netstandard2.0/UnityEngine.UI.dll" - ] - }, "HarmonyX/2.5.5": { "sha512": "sQTQhNCwbob8JnnLsJibcorfjQGi2ziseb8uIOtyWrIv/RrbH1bJiwwX6hyLHCrgLMbzBd5Z15SukTXlmfcYLQ==", "type": "package", @@ -1028,7 +950,6 @@ ".NETFramework,Version=v4.8": [ "BepInEx.Analyzers >= 1.*", "BepInEx.Core >= 5.*", - "DysonSphereProgram.GameLibs >= *-*", "UnityEngine.Modules >= 2018.4.12" ] }, @@ -1077,12 +998,6 @@ "target": "Package", "version": "[5.*, )" }, - "DysonSphereProgram.GameLibs": { - "include": "Compile", - "suppressParent": "All", - "target": "Package", - "version": "[*-*, )" - }, "UnityEngine.Modules": { "include": "Runtime, Build, Native, ContentFiles, Analyzers, BuildTransitive", "suppressParent": "All", diff --git a/GalacticScale2/obj/project.nuget.cache b/GalacticScale2/obj/project.nuget.cache index 2d4bb47b..16945120 100644 --- a/GalacticScale2/obj/project.nuget.cache +++ b/GalacticScale2/obj/project.nuget.cache @@ -1,13 +1,12 @@ { "version": 2, - "dgSpecHash": "8IJAu+EzQ6jCExViT/LFA2kSWI1kk0f3keBGkqIYUctOmBDjMRZC2cCqV/Q6c8fpfDhjZONGrAsG9I5KRvM5aw==", + "dgSpecHash": "RoHie/7+NOgRgxEfvbBXNGMgZGZeReJOhNGJJGmaYItHHFoi9H5b1QBvbIej62zrRI9GhupvkHfVX6r0TFw/5A==", "success": true, "projectFilePath": "E:\\code\\GalacticScale2\\GalacticScale2\\DSP_Plugins.GalacticScale.csproj", "expectedPackageFiles": [ "C:\\Users\\inno\\.nuget\\packages\\bepinex.analyzers\\1.0.7\\bepinex.analyzers.1.0.7.nupkg.sha512", "C:\\Users\\inno\\.nuget\\packages\\bepinex.baselib\\5.4.17\\bepinex.baselib.5.4.17.nupkg.sha512", "C:\\Users\\inno\\.nuget\\packages\\bepinex.core\\5.4.17\\bepinex.core.5.4.17.nupkg.sha512", - "C:\\Users\\inno\\.nuget\\packages\\dysonsphereprogram.gamelibs\\0.8.23.9989-r.0\\dysonsphereprogram.gamelibs.0.8.23.9989-r.0.nupkg.sha512", "C:\\Users\\inno\\.nuget\\packages\\harmonyx\\2.5.5\\harmonyx.2.5.5.nupkg.sha512", "C:\\Users\\inno\\.nuget\\packages\\mono.cecil\\0.11.4\\mono.cecil.0.11.4.nupkg.sha512", "C:\\Users\\inno\\.nuget\\packages\\monomod.runtimedetour\\21.8.19.1\\monomod.runtimedetour.21.8.19.1.nupkg.sha512", diff --git a/GalacticScale2/obj/rider.project.restore.info b/GalacticScale2/obj/rider.project.restore.info index e7fee7b9..bbafeb9f 100644 --- a/GalacticScale2/obj/rider.project.restore.info +++ b/GalacticScale2/obj/rider.project.restore.info @@ -1 +1 @@ -16412655882522037 \ No newline at end of file +16427529176811194 \ No newline at end of file diff --git a/Package/README.md b/Package/README.md index bd8787bb..295b053c 100644 --- a/Package/README.md +++ b/Package/README.md @@ -1,5 +1,19 @@ # DSP Galactic Scale 2.0 Mod +- Version 2.2.0.23 - Fixed Planet Detail Panel. Fixed Ghost Planets. Broke Nebula compatibility. (Nebula isn't updated yet afaik so no big deal here) + +- Version 2.2.0.22 - Actually fix landing on planets for real maybe. Readd Radius Text to Planet Detail (not perfect yet) + +- Version 2.2.0.21 - Fix save corruption after clicking a different galaxy's save + +- Version 2.2.0.20 - Actually fix landing on planets + +- Version 2.2.0.19 - (Unreleased) Fix broken stations from DSP Icarus Evolution Update + +- Version 2.2.0.18 - Fix landing on planets + +- Version 2.2.0.17 - Fix Nebula API Dependency + - Version 2.2.0.16 - 2.2.0.14 Save Compatibility Fix - Version 2.2.0.15 - Fix for Blueprint bug caused by latest DSP update. Thanks to Tartarus Music & Raptor for diagnosing this issue. diff --git a/thunderstore.toml b/thunderstore.toml index d9688d6d..a31b5fb5 100644 --- a/thunderstore.toml +++ b/thunderstore.toml @@ -4,8 +4,8 @@ schemaVersion = "0.0.1" [package] namespace = "Galactic_Scale" name = "GalacticScale" -versionNumber = "2.2.16" -description = "v2.2.0.16. Save compatibility fix" +versionNumber = "2.2.23" +description = "v2.2.0.23 Minor Fixes" websiteUrl = "https://github.com/Touhma/DSP_Plugins" containsNsfwContent = false