using QSB.Events; using QSB.Messaging; namespace QSB.Animation { public class AnimTriggerEvent : QSBEvent { public override EventType Type => EventType.AnimTrigger; public override void SetupListener() { GlobalMessenger.AddListener(EventNames.QSBAnimTrigger, Handler); } public override void CloseListener() { GlobalMessenger.RemoveListener(EventNames.QSBAnimTrigger, Handler); } private void Handler(short triggerId, float value) => SendEvent(CreateMessage(triggerId, value)); private AnimTriggerMessage CreateMessage(short triggerId, float value) => new AnimTriggerMessage { AboutId = LocalPlayerId, TriggerId = triggerId, Value = value }; public override void OnReceiveRemote(AnimTriggerMessage message) { var animationSync = PlayerRegistry.GetSyncObject(message.AboutId); if (animationSync == null) { return; } animationSync.HandleTrigger((AnimTrigger)message.TriggerId, message.Value); } } }