Ejemplo n.º 1
0
        /// <summary>
        /// Clear and apply the current layout to the <see cref="InputSystem"/>.
        /// </summary>
        public void Apply(InputSystem inputSystem)
        {
            inputSystem.Clear();

            foreach (var setting in this.settingsProperties)
            {
                var value       = (InputKeys)setting.GetValue(this);
                var triggerAttr = setting.GetCustomAttribute <TriggerAttribute>();

                if (triggerAttr is ActionTriggerAttribute actionAttr)
                {
                    foreach (var key in value.Keys)
                    {
                        inputSystem.Actions.Add(new InputAction(actionAttr.Name, key));
                    }
                }

                if (triggerAttr is AxisTriggerAttribute axisAttr)
                {
                    foreach (var key in value.Keys)
                    {
                        inputSystem.Axis.Add(new InputAxis(axisAttr.Name, key, axisAttr.Value));
                    }
                }
            }
        }