mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
33 lines
1.0 KiB
C#
33 lines
1.0 KiB
C#
using HarmonyLib;
|
|
using QSB.ModelShip.TransformSync;
|
|
using QSB.Patches;
|
|
using QSB.Player;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
|
|
namespace QSB.ModelShip.Patches;
|
|
|
|
public class ModelShipThrusterPatches : QSBPatch
|
|
{
|
|
public override QSBPatchTypes Type => QSBPatchTypes.OnClientConnect;
|
|
|
|
[HarmonyPrefix]
|
|
[HarmonyPatch(typeof(ThrusterFlameController), nameof(ThrusterFlameController.GetThrustFraction))]
|
|
public static bool GetThrustFraction(ThrusterFlameController __instance, ref float __result)
|
|
{
|
|
var modelShipThrusters = ModelShipTransformSync.LocalInstance?.ThrusterVariableSyncer;
|
|
|
|
if (ModelShipThrusterManager.ThrusterFlameControllers == null) return true;
|
|
|
|
if (ModelShipThrusterManager.ThrusterFlameControllers.Contains(__instance) && !QSBPlayerManager.LocalPlayer.FlyingModelShip)
|
|
{
|
|
if(__instance._thrusterModel.IsThrusterBankEnabled(OWUtilities.GetShipThrusterBank(__instance._thruster)))
|
|
{
|
|
__result = Vector3.Dot(modelShipThrusters.AccelerationSyncer.Value, __instance._thrusterFilter);
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|