// $Revision: 1.6 $ //Copyright (C) Taligent, Inc. All rights reserved. #ifndef TaligentSamples_MOVEMENTSUBSYSTEM #include "MovementSubsystem.h" #endif #ifndef TaligentSamples_CONCURRENTACTORS #include "ConcurrentActors.h" #endif //============================================================================== // MMoving MMoving::MMoving() { } MMoving::~MMoving() { } void MMoving::PreMove(const TTime& interval) { } void MMoving::PostMove(const TTime& interval) { } //============================================================================== // TMoverThread static const TSeconds TMoverThread_kDefaultMoveInterval(1.0 / 7.5); const TTime& TMoverThread::kDefaultMoveInterval = TMoverThread_kDefaultMoveInterval; TMoverThread::TMoverThread(const TTime& moveInterval) : TPeriodicThread(), fObjects(), fInterval(moveInterval) { } TMoverThread::~TMoverThread() { fObjects.RemoveAll(); } void TMoverThread::Add(MMoving* object) { fObjects.AddLast(object); CheckInterval(); } MMoving* TMoverThread::Remove(MMoving& object) { MMoving* result = fObjects.Remove(object); CheckInterval(); return result; } void TMoverThread::RemoveAll() { fObjects.RemoveAll(); CheckInterval(); } void TMoverThread::HandleIntervalPassed(const TTime& interval) { TDequeOfIterator iter(&fObjects); MMoving* item = iter.First(); while (item != NIL) { item->PreMove(interval); item->Move(interval); item->PostMove(interval); item = iter.Next(); } } void TMoverThread::GetDelayInterval(TTime& interval) const { if (fObjects.Count() > 0) { interval = fInterval; } else { interval = TTime::kPositiveInfinity; } }