mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Try to fix Eye ship movement
This commit is contained in:
parent
6ba4a217c8
commit
bf88a362c6
@ -197,26 +197,15 @@ namespace NewHorizons
|
||||
if(scene.name == "EyeOfTheUniverse" && IsWarping)
|
||||
{
|
||||
if(_ship != null) SceneManager.MoveGameObjectToScene(_ship, SceneManager.GetActiveScene());
|
||||
|
||||
// Don't do this for now
|
||||
IsWarping = false;
|
||||
|
||||
Instance.ModHelper.Events.Unity.RunWhen(
|
||||
() => GameObject.Find("Ship_Body") != null && GameObject.Find("Player_Body") != null,
|
||||
() => _ship.transform.position = GameObject.Find("Player_Body").transform.position
|
||||
);
|
||||
Instance.ModHelper.Events.Unity.RunWhen(
|
||||
() => Locator.GetDeathManager() != null && Locator.GetPlayerTransform() != null,
|
||||
() => {
|
||||
Locator.GetDeathManager()._invincible = true;
|
||||
Locator.GetPlayerTransform().GetComponent<PlayerResources>()._invincible = true;
|
||||
});
|
||||
|
||||
_ship = null;
|
||||
_ship.transform.position = new Vector3(50, 0, 0);
|
||||
_ship.SetActive(true);
|
||||
}
|
||||
|
||||
if(scene.name == "SolarSystem")
|
||||
{
|
||||
_ship = GameObject.Find("Ship_Body").InstantiateInactive();
|
||||
DontDestroyOnLoad(_ship);
|
||||
|
||||
IsSystemReady = false;
|
||||
|
||||
HeavenlyBodyBuilder.Reset();
|
||||
@ -374,11 +363,7 @@ namespace NewHorizons
|
||||
|
||||
if(newStarSystem == "EyeOfTheUniverse")
|
||||
{
|
||||
// Else it drops us in the observator
|
||||
PlayerData.SaveWarpedToTheEye(60);
|
||||
// This is jank look out
|
||||
_ship = Locator.GetShipBody().gameObject;
|
||||
DontDestroyOnLoad(_ship);
|
||||
LoadManager.LoadSceneAsync(OWScene.EyeOfTheUniverse, true, LoadManager.FadeType.ToBlack, 0.1f, true);
|
||||
}
|
||||
else
|
||||
|
||||
@ -60,6 +60,7 @@ namespace NewHorizons.Tools
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<PlayerSpawner>("SpawnPlayer", typeof(Patches), nameof(Patches.OnPlayerSpawnerSpawnPlayerPreFix));
|
||||
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<DeathManager>("KillPlayer", typeof(Patches), nameof(Patches.OnDeathManagerKillPlayer));
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPrefix<ShipThrusterController>("ReadTranslationalInput", typeof(Patches), nameof(Patches.OnShipThrusterControllerReadTranslationalInput));
|
||||
|
||||
// Postfixes
|
||||
Main.Instance.ModHelper.HarmonyHelper.AddPostfix<MapController>("Awake", typeof(Patches), nameof(Patches.OnMapControllerAwake));
|
||||
@ -367,5 +368,90 @@ namespace NewHorizons.Tools
|
||||
{
|
||||
return (Main.Instance.CurrentStarSystem != "EyeOfTheUniverse");
|
||||
}
|
||||
|
||||
public static bool OnShipThrusterControllerReadTranslationalInput(ShipThrusterController __instance, Vector3 __result)
|
||||
{
|
||||
float value = OWInput.GetValue(InputLibrary.thrustX, InputMode.All);
|
||||
float value2 = OWInput.GetValue(InputLibrary.thrustZ, InputMode.All);
|
||||
float value3 = OWInput.GetValue(InputLibrary.thrustUp, InputMode.All);
|
||||
float value4 = OWInput.GetValue(InputLibrary.thrustDown, InputMode.All);
|
||||
if (!OWInput.IsInputMode(InputMode.ShipCockpit | InputMode.LandingCam))
|
||||
{
|
||||
__result = Vector3.zero;
|
||||
return false;
|
||||
}
|
||||
if (!__instance._shipResources.AreThrustersUsable())
|
||||
{
|
||||
__result = Vector3.zero;
|
||||
return false;
|
||||
}
|
||||
if (__instance._autopilot.IsFlyingToDestination())
|
||||
{
|
||||
__result = Vector3.zero;
|
||||
return false;
|
||||
}
|
||||
Vector3 vector = new Vector3(value, 0f, value2);
|
||||
if (vector.sqrMagnitude > 1f)
|
||||
{
|
||||
vector.Normalize();
|
||||
}
|
||||
vector.y = value3 - value4;
|
||||
if (__instance._requireIgnition && __instance._landingManager.IsLanded())
|
||||
{
|
||||
vector.x = 0f;
|
||||
vector.z = 0f;
|
||||
vector.y = Mathf.Clamp01(vector.y);
|
||||
if (!__instance._isIgniting && __instance._lastTranslationalInput.y <= 0f && vector.y > 0f)
|
||||
{
|
||||
__instance._isIgniting = true;
|
||||
__instance._ignitionTime = Time.time;
|
||||
GlobalMessenger.FireEvent("StartShipIgnition");
|
||||
}
|
||||
if (__instance._isIgniting)
|
||||
{
|
||||
if (vector.y <= 0f)
|
||||
{
|
||||
__instance._isIgniting = false;
|
||||
GlobalMessenger.FireEvent("CancelShipIgnition");
|
||||
}
|
||||
if (Time.time < __instance._ignitionTime + __instance._ignitionDuration)
|
||||
{
|
||||
vector.y = 0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance._isIgniting = false;
|
||||
__instance._requireIgnition = false;
|
||||
GlobalMessenger.FireEvent("CompleteShipIgnition");
|
||||
RumbleManager.PlayShipIgnition();
|
||||
}
|
||||
}
|
||||
}
|
||||
float d = __instance._thrusterModel.GetMaxTranslationalThrust() / __instance._thrusterModel.GetMaxTranslationalThrust();
|
||||
Vector3 vector2 = vector * d;
|
||||
if (__instance._limitOrbitSpeed && vector2.magnitude > 0f)
|
||||
{
|
||||
Vector3 vector3 = __instance._landingRF.GetOWRigidBody().GetWorldCenterOfMass() - __instance._shipBody.GetWorldCenterOfMass();
|
||||
Vector3 vector4 = __instance._shipBody.GetVelocity() - __instance._landingRF.GetVelocity();
|
||||
Vector3 vector5 = vector4 - Vector3.Project(vector4, vector3);
|
||||
Vector3 vector6 = Quaternion.FromToRotation(-__instance._shipBody.transform.up, vector3) * __instance._shipBody.transform.TransformDirection(vector2 * __instance._thrusterModel.GetMaxTranslationalThrust());
|
||||
Vector3 vector7 = Vector3.Project(vector6, vector3);
|
||||
Vector3 vector8 = vector6 - vector7;
|
||||
Vector3 a = vector5 + vector8 * Time.deltaTime;
|
||||
float magnitude = a.magnitude;
|
||||
float orbitSpeed = __instance._landingRF.GetOrbitSpeed(vector3.magnitude);
|
||||
if (magnitude > orbitSpeed)
|
||||
{
|
||||
a = a.normalized * orbitSpeed;
|
||||
vector8 = (a - vector5) / Time.deltaTime;
|
||||
vector6 = vector7 + vector8;
|
||||
vector2 = __instance._shipBody.transform.InverseTransformDirection(vector6 / __instance._thrusterModel.GetMaxTranslationalThrust());
|
||||
}
|
||||
}
|
||||
__instance._lastTranslationalInput = vector;
|
||||
__result = vector2;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user