public void Reset() { for (int indexCommand = 0; indexCommand < this.commands.Count; indexCommand++) { InputCommand command = this.commands[indexCommand]; command.Reset(); } }
override public void Sync() { for (int indexCommand = 0; indexCommand < this.commands.Count; indexCommand++) { InputCommand command = this.commands[indexCommand]; command.Sync(); } }
public void Remove(CommandMap map) { for (int indexCommand = 0; indexCommand < map.commands.Count; indexCommand++) { InputCommand command = map.commands[indexCommand]; this.commands.Remove(command); } }
public void Add(CommandMap map) { for (int indexCommand = 0; indexCommand < map.commands.Count; indexCommand++) { InputCommand command = map.commands[indexCommand]; Debug.Assert(command != null); this.commands.Add(command); } }
public void Update() { for (int indexCommand = 0; indexCommand < this.commands.Count; indexCommand++) { InputCommand command = this.commands[indexCommand]; if (CommandStack.Constraint == null || CommandStack.Constraint.UsableCommand(command.id)) { command.Update(); } } }
/// <summary> /// Called on every update by the root game object /// This will update keyboard and gamepad states and /// then update the top command map input commands /// </summary> public static void Update() { if (commandOverride != null) { // update static state InputCommand.UpdateState(); commandOverride.Update(); } else if (commandMaps.Count > 0) { // update static state InputCommand.UpdateState(); // now update all commands in the top map collection CommandMap activeMap = commandMaps[commandMaps.Count - 1]; activeMap.Update(); } }
public void Sync(CommandMap prevMap) { for (int indexCommand = 0; indexCommand < this.commands.Count; indexCommand++) { bool clone = false; InputCommand command = this.commands[indexCommand]; if (prevMap != null) { // if we have a previous active map // check if this inputCommand was in it already clone = prevMap.commands.Contains(command); } // do not call sync on an inputCommand that was just active if (!clone && (command != null)) { command.Sync(); } } }
protected void LateBindEvents() { #if NETFX_CORE Debug.Assert(false, "Is any of this actually used???"); #else for (int indexCommand = 0; indexCommand < this.commands.Count; indexCommand++) { InputCommand command = this.commands[indexCommand]; if (command != null) { Type type = command.GetType(); Type matchType = Type.GetType("System.String"); FieldInfo[] fieldinfos = type.GetFields(); for (int indexFields = 0; indexFields < fieldinfos.Length; indexFields++) { FieldInfo field = fieldinfos[indexFields]; Type fieldType = field.FieldType; if (fieldType == matchType && field.Name.StartsWith(BindToken)) { string eventMethodName = (string)field.GetValue(command); if (eventMethodName != null) { Type eventTargetType = this.eventTarget.GetType(); // helpful to see what the methods are // MethodInfo[] methodTargetInfos = eventTargetType.GetMethods(); MethodInfo methodTarget = eventTargetType.GetMethod(eventMethodName); if (methodTarget != null) { string eventName = field.Name.Substring(BindToken.Length); EventInfo eventSource = type.GetEvent(eventName); if (eventSource != null) { Type eventSourceType = eventSource.EventHandlerType; #if !false Delegate eventHandler = Delegate.CreateDelegate(eventSourceType, this.eventTarget, methodTarget); #else // This seems to work with the latest release (GS2.0). // Due to Compact Framework not supporting Delegate.CreateDelegate // we have to instance a shim delegate class too provide the functionality // based upon the event type Delegate eventHandler; switch (eventSourceType.Name) { case "InputCommandChangeVector2Event": eventHandler = DelegateBindShimVector2.CreateDelegate(methodTarget, this.eventTarget); break; case "InputCommandChangeFloatEvent": eventHandler = DelegateBindShimFloat.CreateDelegate(methodTarget, this.eventTarget); break; case "InputCommandEvent": eventHandler = DelegateBindShim.CreateDelegate(methodTarget, this.eventTarget); break; case "InputKeyCommandEvent": eventHandler = DelegateBindShimKey.CreateDelegate(methodTarget, this.eventTarget); break; case "InputCharCommandEvent": eventHandler = DelegateBindShimChar.CreateDelegate(methodTarget, this.eventTarget); break; default: throw new System.Exception("event source type not supported"); } #endif MethodInfo addHandler = eventSource.GetAddMethod(); Object[] invokeParams = { eventHandler }; addHandler.Invoke(command, invokeParams); } } } } } } } #endif }
public void Remove(InputCommand command) { this.commands.Remove(command); }
public void Add(InputCommand command) { Debug.Assert(command.id.Length != 0); this.commands.Add(command); }
public void Add(string id, InputCommand command) { command.id = id; this.commands.Add(command); }