Ejemplo n.º 1
0
    private void InitInputHandlers(IInputService service)
    {
        Abilities.ForEach(ability => {
            service.Bind(ability.Key, ability.Action);
        });

        for (int a = 0; a < Abilities.Count; a++)
        {
            if (Abilities[a].Action == InputAction.None)
            {
                continue;
            }

            int cache = a;
            handlers.Add(Abilities[a].Action, () => {
                TryCast(Abilities[cache]);
            });
        }

        service.InputReceived += (action) => {
            handlers[action]();
        };

        service.MovementReceived += movement.UpdateInput;
    }