1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-08 22:53:33 +08:00

minor fixes

This commit is contained in:
2025-11-15 01:02:33 +08:00
parent cacbfd6d5f
commit 269cc3b801
2 changed files with 25 additions and 24 deletions

View File

@@ -130,6 +130,20 @@ public static class PlanetFunctions
planet.audio?.RemoveAudioData(ed.audioId); planet.audio?.RemoveAudioData(ed.audioId);
} }
for (var id = factory.prebuildCursor - 1; id > 0; id--)
{
ref var pb = ref factory.prebuildPool[id];
if (pb.id != id) continue;
if (pb.colliderId != 0)
{
planet.physics.RemoveLinkedColliderData(pb.colliderId);
}
if (pb.modelId != 0)
{
GameMain.gpuiManager.RemovePrebuildModel(pb.modelIndex, pb.modelId);
}
}
var hives = GameMain.spaceSector?.dfHives; var hives = GameMain.spaceSector?.dfHives;
if (hives != null) if (hives != null)
{ {
@@ -202,7 +216,7 @@ public static class PlanetFunctions
factory.PlanetReformRevert(); factory.PlanetReformRevert();
} }
planet.UnloadFactory(); GameMain.data.LeavePlanet();
var index = factory.index; var index = factory.index;
var warningSystem = GameMain.data.warningSystem; var warningSystem = GameMain.data.warningSystem;
var warningPool = warningSystem.warningPool; var warningPool = warningSystem.warningPool;
@@ -275,12 +289,7 @@ public static class PlanetFunctions
factory.digitalSystem = new DigitalSystem(planet); factory.digitalSystem = new DigitalSystem(planet);
//GameMain.data.statistics.production.CreateFactoryStat(index); //GameMain.data.statistics.production.CreateFactoryStat(index);
planet.LoadFactory(); GameMain.data.ArrivePlanet(planet);
while (!planet.factoryLoaded)
{
PlanetModelingManager.Update();
Thread.Sleep(0);
}
} }
public static void BuildOrbitalCollectors() public static void BuildOrbitalCollectors()

View File

@@ -4,6 +4,7 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Reflection.Emit; using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using BepInEx.Configuration; using BepInEx.Configuration;
using CommonAPI.Systems; using CommonAPI.Systems;
using HarmonyLib; using HarmonyLib;
@@ -310,25 +311,13 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
_nightlightInitialized = false; _nightlightInitialized = false;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void UpdateSunlightAngle() public static void UpdateSunlightAngle()
{ {
if (!_sunlight) return; if (!_sunlight) return;
_sunlight.transform.rotation = Quaternion.LookRotation(-GameMain.mainPlayer.transform.up + GameMain.mainPlayer.transform.forward * NightLightAngleX.Value / 10f + _sunlight.transform.rotation =
GameMain.mainPlayer.transform.right * NightLightAngleY.Value / 10f); Quaternion.LookRotation(-GameMain.mainPlayer.transform.up + GameMain.mainPlayer.transform.forward * NightLightAngleX.Value / 10f +
} GameMain.mainPlayer.transform.right * NightLightAngleY.Value / 10f);
[HarmonyPostfix]
[HarmonyPatch(typeof(GameData), nameof(GameData.ArriveStar))]
public static void GameData_ArriveStar_Postfix()
{
_sunlight = GameMain.universeSimulator?.LocalStarSimulator()?.sunLight;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameData), nameof(GameData.LeaveStar))]
public static void GameData_LeaveStar_Prefix()
{
_sunlight = null;
} }
[HarmonyPostfix] [HarmonyPostfix]
@@ -341,7 +330,6 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
{ {
if (!GameMain.mainPlayer.controller.model.gameObject.activeInHierarchy) return; if (!GameMain.mainPlayer.controller.model.gameObject.activeInHierarchy) return;
if (_sail == null) _sail = GameMain.mainPlayer.animator.sails[GameMain.mainPlayer.animator.sailAnimIndex]; if (_sail == null) _sail = GameMain.mainPlayer.animator.sails[GameMain.mainPlayer.animator.sailAnimIndex];
_sunlight = GameMain.universeSimulator?.LocalStarSimulator()?.sunLight;
_nightlightInitialized = true; _nightlightInitialized = true;
} }
@@ -362,6 +350,10 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
if (sailing) return; if (sailing) return;
_mechaOnEarth = true; _mechaOnEarth = true;
if (_sunlight == null)
{
_sunlight = GameMain.universeSimulator?.LocalStarSimulator()?.sunLight;
}
} }
[HarmonyTranspiler] [HarmonyTranspiler]