protected void DequeueOldStates(GameTime currentTime) { InputStateExtended <S> state = null; if (m_RecordedStates.Count > 0) { state = m_RecordedStates.Peek(); } if (state != null && state.StateTime < currentTime.TotalRealTime().Subtract(new TimeSpan(0, 0, 0, 0, InputDeviceConstants.ClickCountTimeMS))) { m_StatesForReuse.Push(m_RecordedStates.Dequeue()); DequeueOldStates(currentTime); } }
private InputStateExtended <S> CreateState(GameTime time, S state) { if (m_StatesForReuse.Count > 0) { //Reuses the object to fight of the GC InputStateExtended <S> stateExt = m_StatesForReuse.Pop(); stateExt.StateTime = time.TotalRealTime(); stateExt.State = state; return(stateExt); } else { return(new InputStateExtended <S>(time, state)); } }