mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-30 12:32:55 +00:00
31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
|
using OWML.Common.Menus;
|
|||
|
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();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|