-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fully patch Vessel.SetRotation, patch VesselPrecalculate.SetLandedPos…
…Rot for more perf.
- Loading branch information
1 parent
af831b8
commit 3842fca
Showing
3 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using HarmonyLib; | ||
using UnityEngine; | ||
|
||
namespace RealismOverhaul.Harmony | ||
{ | ||
[HarmonyPatch(typeof(VesselPrecalculate))] | ||
internal class PatchVesselPrecalculate | ||
{ | ||
[HarmonyPrefix] | ||
[HarmonyPatch(nameof(VesselPrecalculate.SetLandedPosRot))] | ||
internal static bool Prefix_SetLandedPosRot(VesselPrecalculate __instance) | ||
{ | ||
Vessel vessel = __instance.vessel; | ||
if (vessel.LandedOrSplashed && vessel.packed && __instance.railsSetPosRot) | ||
{ | ||
__instance.worldSurfaceRot = vessel.mainBody.bodyTransform.rotation * vessel.srfRelRotation; | ||
__instance.worldSurfacePos = vessel.mainBody.GetWorldSurfacePosition(vessel.latitude, vessel.longitude, vessel.altitude); | ||
VesselModuleRotationRO vmr = VesselModuleRotationRO.GetModule(vessel); | ||
if (vmr == null) | ||
{ | ||
vessel.SetRotation(__instance.worldSurfaceRot, false); | ||
vessel.SetPosition(__instance.worldSurfacePos, true); | ||
} | ||
else | ||
{ | ||
vmr.StoreRotAndTime(__instance.worldSurfaceRot); | ||
vmr.SetPosRot(__instance.worldSurfaceRot, __instance.worldSurfacePos); | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters