mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
When a quantum planet is destroyed, only destroy that state (#134)
This commit is contained in:
parent
34c9ecf5aa
commit
d25de13914
@ -1,4 +1,4 @@
|
||||
using NewHorizons.Builder.General;
|
||||
using NewHorizons.Builder.General;
|
||||
using NewHorizons.Builder.Orbital;
|
||||
using NewHorizons.Components.Orbital;
|
||||
using NewHorizons.External.Modules;
|
||||
@ -21,6 +21,8 @@ namespace NewHorizons.Components
|
||||
private AlignWithTargetBody _alignment;
|
||||
private OWRigidbody _rb;
|
||||
|
||||
public int CurrentIndex { get { return _currentIndex; } }
|
||||
|
||||
public override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
35
NewHorizons/Patches/DestructionVolumePatches.cs
Normal file
35
NewHorizons/Patches/DestructionVolumePatches.cs
Normal file
@ -0,0 +1,35 @@
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Components;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace NewHorizons.Patches
|
||||
{
|
||||
[HarmonyPatch]
|
||||
public static class DestructionVolumePatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(DestructionVolume), nameof(DestructionVolume.Vanish))]
|
||||
public static bool DestructionVolume_Vanish(OWRigidbody __0)
|
||||
{
|
||||
var quantumPlanet = __0.gameObject.GetComponent<QuantumPlanet>();
|
||||
|
||||
if (quantumPlanet == null) return true;
|
||||
|
||||
// Allow it to vanish if this is the only state
|
||||
if (quantumPlanet.states.Count <= 1) return true;
|
||||
|
||||
// Force it to change states but if it can't, remove it
|
||||
var oldIndex = quantumPlanet.CurrentIndex;
|
||||
quantumPlanet.ChangeQuantumState(true);
|
||||
if (quantumPlanet.CurrentIndex == oldIndex) return true;
|
||||
|
||||
quantumPlanet.states.RemoveAt(oldIndex);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user