public void FireActions(Gui.Root Gui, Action <Gui.InputEvents, Gui.InputEventArgs> externalHandler) { if (!GameState.Game.IsActive) { return; } var queue = Mapper.GetInputQueue(); foreach (var @event in queue) { if (Gui != null) { Gui.HandleInput(@event.Message, @event.Args); } if ([email protected]) { if (externalHandler != null) { externalHandler(@event.Message, @event.Args); } } } }
public void FireActions(Gui.Root Gui, Action <Gui.InputEvents, Gui.InputEventArgs> externalHandler) { if (!GameState.Game.IsActive) { return; } var queue = Mapper.GetInputQueue(); foreach (var @event in queue) { if (Gui != null) { Gui.HandleInput(@event.Message, @event.Args); } if ([email protected]) { if (externalHandler != null) { externalHandler(@event.Message, @event.Args); } if ([email protected] && @event.Message == global::DwarfCorp.Gui.InputEvents.KeyUp) { GumInputMapper.QueuedInput localevent = @event; foreach (var binding in InputActions.Where((KeyValuePair <string, InputAction> ia) => ia.Value.Keys.Contains((Keys)localevent.Args.KeyValue) && ia.Value.Type == KeyBindingType.Pressed)) { if (binding.Value.Handler != null) { binding.Value.Handler(); } } } } } // Check 'Held' actions var kbState = Keyboard.GetState(); foreach (var binding in InputActions.Where(ia => ia.Value.Type == KeyBindingType.Held)) { if (binding.Value.Keys.Count(k => kbState.IsKeyDown(k)) > 0 && binding.Value.Handler != null) { binding.Value.Handler(); } } }