mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-06 01:00:16 +00:00
Sync model ship crash effects
This commit is contained in:
parent
1fabd2101d
commit
e506a49ad3
16
QSB/ModelShip/Messages/CrashModelShipMessage.cs
Normal file
16
QSB/ModelShip/Messages/CrashModelShipMessage.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
using QSB.Messaging;
|
using QSB.Messaging;
|
||||||
using QSB.ModelShip.Messages;
|
using QSB.ModelShip.Messages;
|
||||||
using QSB.Patches;
|
using QSB.Patches;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace QSB.ModelShip.Patches;
|
namespace QSB.ModelShip.Patches;
|
||||||
|
|
||||||
@ -20,4 +21,14 @@ public class ModelShipPatches : QSBPatch
|
|||||||
|
|
||||||
new RespawnModelShipMessage(playEffects).Send();
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user