using QSB.Events; using QSB.JellyfishSync.WorldObjects; using QSB.WorldSync; using QSB.WorldSync.Events; namespace QSB.JellyfishSync.Events { public class JellyfishRisingEvent : QSBEvent { public override bool RequireWorldObjectsReady => true; public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBJellyfishRising, Handler); public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBJellyfishRising, Handler); private void Handler(QSBJellyfish qsbJellyfish) => SendEvent(CreateMessage(qsbJellyfish)); private BoolWorldObjectMessage CreateMessage(QSBJellyfish qsbJellyfish) => new() { ObjectId = qsbJellyfish.ObjectId, State = qsbJellyfish.IsRising }; public override void OnReceiveRemote(bool isHost, BoolWorldObjectMessage message) { var qsbJellyfish = QSBWorldSync.GetWorldFromId(message.ObjectId); qsbJellyfish.IsRising = message.State; } } }