mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-18 04:10:36 +00:00
30 lines
1.0 KiB
C#
30 lines
1.0 KiB
C#
using QSB.Events;
|
|
using QSB.EyeOfTheUniverse.InstrumentSync.WorldObjects;
|
|
using QSB.WorldSync;
|
|
using QSB.WorldSync.Events;
|
|
|
|
namespace QSB.EyeOfTheUniverse.InstrumentSync.Event
|
|
{
|
|
internal class GatherInstrumentEvent : QSBEvent<WorldObjectMessage>
|
|
{
|
|
public override bool RequireWorldObjectsReady => true;
|
|
|
|
public override void SetupListener() => GlobalMessenger<QSBQuantumInstrument>.AddListener(EventNames.QSBGatherInstrument, Handler);
|
|
public override void CloseListener() => GlobalMessenger<QSBQuantumInstrument>.RemoveListener(EventNames.QSBGatherInstrument, Handler);
|
|
|
|
private void Handler(QSBQuantumInstrument instrument) => SendEvent(CreateMessage(instrument));
|
|
|
|
private BoolWorldObjectMessage CreateMessage(QSBQuantumInstrument instrument) => new()
|
|
{
|
|
AboutId = LocalPlayerId,
|
|
ObjectId = instrument.ObjectId
|
|
};
|
|
|
|
public override void OnReceiveRemote(bool isHost, WorldObjectMessage message)
|
|
{
|
|
var qsbObj = QSBWorldSync.GetWorldFromId<QSBQuantumInstrument>(message.ObjectId);
|
|
qsbObj.AttachedObject.Gather();
|
|
}
|
|
}
|
|
}
|