mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix dynamic props from vessel when under parent body
This commit is contained in:
parent
e56a3e6440
commit
3f337a6ad7
29
NewHorizons/Components/FixPhysics.cs
Normal file
29
NewHorizons/Components/FixPhysics.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using NewHorizons.Utility.OuterWilds;
|
||||||
|
using NewHorizons.Utility.OWML;
|
||||||
|
using System.Collections;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace NewHorizons.Components;
|
||||||
|
|
||||||
|
[DisallowMultipleComponent]
|
||||||
|
public class FixPhysics : MonoBehaviour
|
||||||
|
{
|
||||||
|
private OWRigidbody _body;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
_body = GetComponent<OWRigidbody>();
|
||||||
|
_body._lastPosition = transform.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
var parentBody = _body.GetOrigParentBody();
|
||||||
|
if (parentBody == null) return;
|
||||||
|
_body.SetVelocity(parentBody.GetPointVelocity(_body.GetWorldCenterOfMass()));
|
||||||
|
_body.SetAngularVelocity(parentBody.GetAngularVelocity());
|
||||||
|
if (_body._simulateInSector) _body.OnSectorOccupantsUpdated();
|
||||||
|
var gravity = parentBody.GetComponentInChildren<GravityVolume>();
|
||||||
|
if (gravity != null) gravity.GetComponent<OWTriggerVolume>().AddObjectToVolume(_body.GetComponentInChildren<ForceDetector>().gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -166,6 +166,17 @@ namespace NewHorizons.Handlers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasParentBody)
|
||||||
|
{
|
||||||
|
foreach (OWRigidbody dynamicProp in vesselObject.GetComponentsInChildren<OWRigidbody>(true))
|
||||||
|
{
|
||||||
|
if (dynamicProp.GetComponent<NomaiInterfaceOrb>() == null)
|
||||||
|
{
|
||||||
|
dynamicProp.gameObject.AddComponent<FixPhysics>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var attachWarpExitToVessel = system.Config.Vessel?.warpExit?.attachToVessel ?? false;
|
var attachWarpExitToVessel = system.Config.Vessel?.warpExit?.attachToVessel ?? false;
|
||||||
var warpExitParent = vesselWarpController._targetWarpPlatform.transform.parent;
|
var warpExitParent = vesselWarpController._targetWarpPlatform.transform.parent;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user