Ejemplo n.º 1
0
        public ControllerInputScheme <T> RegisterScheme(S schemeLabel)
        {
            if (_schemes.ContainsKey(schemeLabel))
            {
                throw new System.InvalidOperationException($"Already exists a scheme with label '{schemeLabel.ToString()}'.");
            }

            ControllerInputScheme <T> scheme = new ControllerInputScheme <T>(_commands);

            _schemes.Add(schemeLabel, scheme);

            if (CurrentScheme == null)
            {
                CurrentScheme      = scheme;
                CurrentSchemeLabel = schemeLabel;
                CurrentScheme.Begin();
            }

            return(scheme);
        }
Ejemplo n.º 2
0
        public void SwitchScheme(S schemeLabel)
        {
            if (!_schemes.TryGetValue(schemeLabel, out ControllerInputScheme <T> scheme))
            {
                throw new System.ArgumentException($"There is no scheme registered with label '{schemeLabel}'.", nameof(schemeLabel));
            }

            if (schemeLabel.Equals(CurrentSchemeLabel))
            {
                return;
            }

            if (CurrentScheme != null)
            {
                CurrentScheme.End();
                CurrentScheme = null;
            }

            CurrentScheme      = scheme;
            CurrentSchemeLabel = schemeLabel;
            CurrentScheme.Begin();
            OnSchemeChanged?.Invoke(CurrentSchemeLabel);
        }