mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-09 21:59:16 +00:00
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using QSB.Events;
|
|
using QSB.ShipSync.WorldObjects;
|
|
using QSB.WorldSync;
|
|
|
|
namespace QSB.ShipSync.Events.Hull
|
|
{
|
|
internal class HullImpactEvent : QSBEvent<HullImpactMessage>
|
|
{
|
|
public override EventType Type => EventType.HullImpact;
|
|
|
|
public override void SetupListener() => GlobalMessenger<ShipHull, ImpactData, float>.AddListener(EventNames.QSBHullImpact, Handler);
|
|
public override void CloseListener() => GlobalMessenger<ShipHull, ImpactData, float>.RemoveListener(EventNames.QSBHullImpact, Handler);
|
|
|
|
private void Handler(ShipHull hull, ImpactData data, float damage) => SendEvent(CreateMessage(hull, data, damage));
|
|
|
|
private HullImpactMessage CreateMessage(ShipHull hull, ImpactData data, float damage)
|
|
{
|
|
var worldObject = QSBWorldSync.GetWorldFromUnity<QSBShipHull>(hull);
|
|
return new HullImpactMessage
|
|
{
|
|
AboutId = LocalPlayerId,
|
|
ObjectId = worldObject.ObjectId,
|
|
Point = data.point,
|
|
Normal = data.normal,
|
|
Velocity = data.velocity,
|
|
Speed = data.speed,
|
|
Damage = damage
|
|
};
|
|
}
|
|
|
|
public override void OnReceiveRemote(bool server, HullImpactMessage message)
|
|
{
|
|
var worldObject = QSBWorldSync.GetWorldFromId<QSBShipHull>(message.ObjectId);
|
|
}
|
|
}
|
|
}
|