mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Better fixers (#537)
make the InteractVolume fix and etc use a component instead of FireOnNextUpdate so it works with scatter and VR
This commit is contained in:
commit
80e5f0c15e
@ -253,39 +253,41 @@ namespace NewHorizons.Builder.Props
|
|||||||
/// <param name="isTorch"></param>
|
/// <param name="isTorch"></param>
|
||||||
private static void FixSectoredComponent(Component component, Sector sector, bool isTorch = false)
|
private static void FixSectoredComponent(Component component, Sector sector, bool isTorch = false)
|
||||||
{
|
{
|
||||||
if (component is Sector s)
|
|
||||||
{
|
|
||||||
s.SetParentSector(sector);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (component is SectorCullGroup sectorCullGroup)
|
|
||||||
{
|
|
||||||
sectorCullGroup._controllingProxy = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// fix Sector stuff, eg SectorCullGroup (without this, props that have a SectorCullGroup component will become invisible inappropriately)
|
// fix Sector stuff, eg SectorCullGroup (without this, props that have a SectorCullGroup component will become invisible inappropriately)
|
||||||
if (component is ISectorGroup sectorGroup)
|
if (component is ISectorGroup sectorGroup)
|
||||||
{
|
{
|
||||||
sectorGroup.SetSector(sector);
|
sectorGroup.SetSector(sector);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component is SectoredMonoBehaviour behaviour)
|
// Not doing else if here because idk if any of the classes below implement ISectorGroup
|
||||||
|
|
||||||
|
if (component is Sector s)
|
||||||
|
{
|
||||||
|
s.SetParentSector(sector);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (component is SectorCullGroup sectorCullGroup)
|
||||||
|
{
|
||||||
|
sectorCullGroup._controllingProxy = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if(component is SectoredMonoBehaviour behaviour)
|
||||||
{
|
{
|
||||||
behaviour.SetSector(sector);
|
behaviour.SetSector(sector);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component is OWItemSocket socket)
|
else if(component is OWItemSocket socket)
|
||||||
{
|
{
|
||||||
socket._sector = sector;
|
socket._sector = sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix slide reel - Softlocks if this object is a vision torch
|
// Fix slide reel - Softlocks if this object is a vision torch
|
||||||
if (!isTorch && component is SlideCollectionContainer container)
|
else if(!isTorch && component is SlideCollectionContainer container)
|
||||||
{
|
{
|
||||||
sector.OnOccupantEnterSector.AddListener(_ => container.LoadStreamingTextures());
|
sector.OnOccupantEnterSector.AddListener(_ => container.LoadStreamingTextures());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component is NomaiRemoteCameraPlatform remoteCameraPlatform)
|
else if(component is NomaiRemoteCameraPlatform remoteCameraPlatform)
|
||||||
{
|
{
|
||||||
remoteCameraPlatform._visualSector = sector;
|
remoteCameraPlatform._visualSector = sector;
|
||||||
}
|
}
|
||||||
@ -314,22 +316,19 @@ namespace NewHorizons.Builder.Props
|
|||||||
Component.DestroyImmediate(component);
|
Component.DestroyImmediate(component);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (component is DarkMatterVolume)
|
||||||
if (component is DarkMatterVolume)
|
|
||||||
{
|
{
|
||||||
var probeVisuals = component.gameObject.transform.Find("ProbeVisuals");
|
var probeVisuals = component.gameObject.transform.Find("ProbeVisuals");
|
||||||
if (probeVisuals != null) probeVisuals.gameObject.SetActive(true);
|
if (probeVisuals != null) probeVisuals.gameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
|
else if (component is DarkMatterSubmergeController submergeController)
|
||||||
if (component is DarkMatterSubmergeController submergeController)
|
|
||||||
{
|
{
|
||||||
var water = planetGO.GetComponentsInChildren<RadialFluidVolume>().FirstOrDefault(x => x._fluidType == FluidVolume.Type.WATER);
|
var water = planetGO.GetComponentsInChildren<RadialFluidVolume>().FirstOrDefault(x => x._fluidType == FluidVolume.Type.WATER);
|
||||||
if (submergeController._fluidDetector)
|
if (submergeController._fluidDetector)
|
||||||
submergeController._fluidDetector._onlyDetectableFluid = water;
|
submergeController._fluidDetector._onlyDetectableFluid = water;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix anglerfish speed on orbiting planets
|
// Fix anglerfish speed on orbiting planets
|
||||||
if (component is AnglerfishController angler)
|
else if (component is AnglerfishController angler)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -342,41 +341,37 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fix campfires
|
// fix campfires
|
||||||
if (component is InteractVolume interactVolume)
|
else if (component is InteractVolume)
|
||||||
{
|
{
|
||||||
Delay.FireOnNextUpdate(() => interactVolume._playerCam = Locator.GetPlayerCamera());
|
component.gameObject.AddComponent<InteractVolumeFixer>();
|
||||||
}
|
}
|
||||||
if (component is PlayerAttachPoint playerAttachPoint)
|
else if (component is PlayerAttachPoint)
|
||||||
{
|
{
|
||||||
var playerBody = GameObject.Find("Player_Body");
|
component.gameObject.AddComponent<PlayerAttachPointFixer>();
|
||||||
playerAttachPoint._playerController = playerBody.GetComponent<PlayerCharacterController>();
|
|
||||||
playerAttachPoint._playerOWRigidbody = playerBody.GetComponent<OWRigidbody>();
|
|
||||||
playerAttachPoint._playerTransform = playerBody.transform;
|
|
||||||
Delay.FireOnNextUpdate(() => playerAttachPoint._fpsCamController = Locator.GetPlayerCameraController());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component is NomaiInterfaceOrb orb)
|
else if (component is NomaiInterfaceOrb orb)
|
||||||
{
|
{
|
||||||
orb._parentAstroObject = planetGO.GetComponent<AstroObject>();
|
orb._parentAstroObject = planetGO.GetComponent<AstroObject>();
|
||||||
orb._parentBody = planetGO.GetComponent<OWRigidbody>();
|
orb._parentBody = planetGO.GetComponent<OWRigidbody>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component is VisionTorchItem torchItem)
|
else if (component is VisionTorchItem torchItem)
|
||||||
{
|
{
|
||||||
torchItem.enabled = true;
|
torchItem.enabled = true;
|
||||||
torchItem.mindProjectorTrigger.enabled = true;
|
torchItem.mindProjectorTrigger.enabled = true;
|
||||||
Delay.FireOnNextUpdate(() => torchItem.mindSlideProjector._mindProjectorImageEffect = Locator.GetPlayerCamera().GetComponent<MindProjectorImageEffect>());
|
torchItem.gameObject.AddComponent<VisionTorchItemFixer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (component is Animator animator) animator.enabled = true;
|
else if (component is Animator animator) animator.enabled = true;
|
||||||
if (component is Collider collider) collider.enabled = true;
|
else if(component is Collider collider) collider.enabled = true;
|
||||||
// Bug 533 - Don't show the electricity effect renderers
|
// Bug 533 - Don't show the electricity effect renderers
|
||||||
if (component is Renderer renderer && component.gameObject.GetComponent<ElectricityEffect>() == null) renderer.enabled = true;
|
else if (component is Renderer renderer && component.gameObject.GetComponent<ElectricityEffect>() == null) renderer.enabled = true;
|
||||||
if (component is Shape shape) shape.enabled = true;
|
else if(component is Shape shape) shape.enabled = true;
|
||||||
|
|
||||||
// fixes sector cull group deactivating renderers on map view enter and fast foward
|
// fixes sector cull group deactivating renderers on map view enter and fast foward
|
||||||
// TODO: does this actually work? what? how?
|
// TODO: does this actually work? what? how?
|
||||||
if (component is SectorCullGroup sectorCullGroup)
|
else if(component is SectorCullGroup sectorCullGroup)
|
||||||
{
|
{
|
||||||
sectorCullGroup._inMapView = false;
|
sectorCullGroup._inMapView = false;
|
||||||
sectorCullGroup._isFastForwarding = false;
|
sectorCullGroup._isFastForwarding = false;
|
||||||
@ -384,8 +379,10 @@ namespace NewHorizons.Builder.Props
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If it's not a moving anglerfish make sure the anim controller is regular
|
// If it's not a moving anglerfish make sure the anim controller is regular
|
||||||
if (component is AnglerfishAnimController && component.GetComponentInParent<AnglerfishController>() == null)
|
else if(component is AnglerfishAnimController && component.GetComponentInParent<AnglerfishController>() == null)
|
||||||
|
{
|
||||||
component.gameObject.AddComponent<AnglerAnimFixer>();
|
component.gameObject.AddComponent<AnglerAnimFixer>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -416,5 +413,53 @@ namespace NewHorizons.Builder.Props
|
|||||||
Destroy(this);
|
Destroy(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Has to happen after 1 frame to work with VR
|
||||||
|
/// </summary>
|
||||||
|
[RequireComponent(typeof(InteractVolume))]
|
||||||
|
private class InteractVolumeFixer : MonoBehaviour
|
||||||
|
{
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
var interactVolume = GetComponent<InteractVolume>();
|
||||||
|
interactVolume._playerCam = Locator.GetPlayerCamera();
|
||||||
|
|
||||||
|
Destroy(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Has to happen after 1 frame to work with VR
|
||||||
|
/// </summary>
|
||||||
|
[RequireComponent(typeof(PlayerAttachPoint))]
|
||||||
|
private class PlayerAttachPointFixer : MonoBehaviour
|
||||||
|
{
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
var playerAttachPoint = GetComponent<PlayerAttachPoint>();
|
||||||
|
playerAttachPoint._playerController = Locator.GetPlayerController();
|
||||||
|
playerAttachPoint._playerOWRigidbody = Locator.GetPlayerBody();
|
||||||
|
playerAttachPoint._playerTransform = Locator.GetPlayerTransform();
|
||||||
|
playerAttachPoint._fpsCamController = Locator.GetPlayerCameraController();
|
||||||
|
|
||||||
|
Destroy(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Has to happen after 1 frame to work with VR
|
||||||
|
/// </summary>
|
||||||
|
[RequireComponent(typeof(VisionTorchItem))]
|
||||||
|
private class VisionTorchItemFixer : MonoBehaviour
|
||||||
|
{
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
var torchItem = GetComponent<VisionTorchItem>();
|
||||||
|
torchItem.mindSlideProjector._mindProjectorImageEffect = Locator.GetPlayerCamera().GetComponent<MindProjectorImageEffect>();
|
||||||
|
|
||||||
|
Destroy(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user