Sync model ship crash effects

This commit is contained in:
Nick 2022-08-28 00:56:28 -04:00
parent 1fabd2101d
commit e506a49ad3
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,16 @@
using QSB.Messaging;
using QSB.WorldSync;
namespace QSB.ModelShip.Messages;
internal class CrashModelShipMessage : QSBMessage
{
public CrashModelShipMessage() { }
public override void OnReceiveRemote()
{
var crashBehaviour = QSBWorldSync.GetUnityObject<ModelShipCrashBehavior>();
crashBehaviour._crashEffect.Play();
crashBehaviour.gameObject.GetComponent<OWAudioSource>().PlayOneShot(AudioType.TH_ModelShipCrash);
}
}

View File

@ -2,6 +2,7 @@
using QSB.Messaging;
using QSB.ModelShip.Messages;
using QSB.Patches;
using UnityEngine;
namespace QSB.ModelShip.Patches;
@ -20,4 +21,14 @@ public class ModelShipPatches : QSBPatch
new RespawnModelShipMessage(playEffects).Send();
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ModelShipCrashBehavior), nameof(ModelShipCrashBehavior.OnImpact))]
private static void ModelShipCrashBehavior_OnImpact(ModelShipCrashBehavior __instance, ImpactData impactData)
{
if (impactData.speed > 10f && Time.time > __instance._lastCrashTime + 1f)
{
new CrashModelShipMessage().Send();
}
}
}