oldschool-toontown/libotp/movement/CMoverGroup.py
2019-11-02 19:49:34 -04:00

42 lines
1.1 KiB
Python

from direct.directnotify import DirectNotifyGlobal
class CMoverGroup:
notify = DirectNotifyGlobal.directNotify.newCategory('CMoverGroup')
def __init__(self):
self.dt = 1.0
self.dtClock = globalClock.getFrameTime()
self.cMovers = {}
def setDt(self, dt):
self.dt = dt
if self.dt == -1.0:
clockDelta = globalClock.getFrameTime()
self.dt = clockDelta - self.dtClock
self.dtClock = clockDelta
def resetDt(self):
self.dt = 1.0
self.dtClock = globalClock.getFrameTime()
def addCMover(self, name, cMover):
if not cMover:
return
self.removeCMover(name)
self.cMovers[name] = cMover
def removeCMover(self, name):
if name in self.cMovers:
del self.cMovers[name]
def processCImpulsesAndIntegrate(self):
if self.dt == -1.0:
clockDelta = globalClock.getFrameTime()
self.dt = clockDelta - self.dtClock
self.dtClock = clockDelta
for cMover in self.cMovers.values():
cMover.processCImpulses(self.dt)
cMover.integrate()