mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
dont spam recenter on spawn (#876)
- [ ] test with mods - [x] evacuation - [x] daylight savings - [ ] whatever the one xen found that flung you off the planet - [ ] other mods with tidally locked body spawn points
This commit is contained in:
commit
a541d5ddce
@ -137,30 +137,39 @@ namespace NewHorizons.Handlers
|
||||
|
||||
private static IEnumerator SpawnCoroutine(int length)
|
||||
{
|
||||
FixPlayerVelocity();
|
||||
for(int i = 0; i < length; i++)
|
||||
{
|
||||
FixPlayerVelocity();
|
||||
FixPlayerVelocity(false); // dont recenter universe here or else it spams and lags game
|
||||
yield return new WaitForEndOfFrame();
|
||||
}
|
||||
FixPlayerVelocity();
|
||||
|
||||
InvulnerabilityHandler.MakeInvulnerable(false);
|
||||
}
|
||||
|
||||
private static void FixPlayerVelocity()
|
||||
private static void FixPlayerVelocity(bool recenter = true)
|
||||
{
|
||||
var playerBody = SearchUtilities.Find("Player_Body").GetAttachedOWRigidbody();
|
||||
var resources = playerBody.GetComponent<PlayerResources>();
|
||||
|
||||
SpawnBody(playerBody, GetDefaultSpawn());
|
||||
SpawnBody(playerBody, GetDefaultSpawn(), recenter: recenter);
|
||||
|
||||
resources._currentHealth = 100f;
|
||||
}
|
||||
|
||||
public static void SpawnBody(OWRigidbody body, SpawnPoint spawn, Vector3? positionOverride = null)
|
||||
public static void SpawnBody(OWRigidbody body, SpawnPoint spawn, Vector3? positionOverride = null, bool recenter = true)
|
||||
{
|
||||
var pos = positionOverride ?? spawn.transform.position;
|
||||
|
||||
body.WarpToPositionRotation(pos, spawn.transform.rotation);
|
||||
if (recenter)
|
||||
{
|
||||
body.WarpToPositionRotation(pos, spawn.transform.rotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
body.transform.SetPositionAndRotation(pos, spawn.transform.rotation);
|
||||
}
|
||||
|
||||
var spawnVelocity = spawn._attachedBody.GetVelocity();
|
||||
var spawnAngularVelocity = spawn._attachedBody.GetPointTangentialVelocity(pos);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user