Example #1
0
 private InputStateExtended <TS> CreateState(GameTime time, TS state)
 {
     if (_statesForReuse.Count > 0)
     {
         //Reuses the object to fight of the GC
         InputStateExtended <TS> stateExt = _statesForReuse.Pop();
         stateExt.StateTime = time.TotalRealTime();
         stateExt.State     = state;
         return(stateExt);
     }
     return(new InputStateExtended <TS>(time, state));
 }
Example #2
0
        protected void DequeueOldStates(GameTime currentTime)
        {
            InputStateExtended <TS> state = null;

            if (_recordedStates.Count > 0)
            {
                state = _recordedStates.Peek();
            }
            if (state != null && state.StateTime < currentTime.TotalRealTime().Subtract(new TimeSpan(0, 0, 0, 0, InputDeviceConstants.ClickCountTimeMS)))
            {
                _statesForReuse.Push(_recordedStates.Dequeue());
                DequeueOldStates(currentTime);
            }
        }