2019-11-08 22:55:55 -06:00
|
|
|
from direct.directnotify import DirectNotifyGlobal
|
2019-12-05 21:42:29 -06:00
|
|
|
from direct.distributed.ClockDelta import globalClockDelta
|
2019-11-08 22:55:55 -06:00
|
|
|
|
2019-12-05 21:42:29 -06:00
|
|
|
from toontown.racing.DistributedKartPadAI import DistributedKartPadAI
|
2020-01-02 13:19:22 -06:00
|
|
|
from toontown.racing.KartShopGlobals import KartGlobals
|
2019-12-05 21:42:29 -06:00
|
|
|
|
|
|
|
|
|
|
|
class DistributedViewPadAI(DistributedKartPadAI):
|
2019-11-08 22:55:55 -06:00
|
|
|
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedViewPadAI')
|
2019-12-05 21:42:29 -06:00
|
|
|
|
|
|
|
def __init__(self, air):
|
|
|
|
DistributedKartPadAI.__init__(self, air)
|
|
|
|
self.lastEntered = 0
|
|
|
|
|
|
|
|
def announceGenerate(self):
|
|
|
|
DistributedKartPadAI.announceGenerate(self)
|
|
|
|
self.lastEntered = globalClockDelta.getRealNetworkTime()
|
|
|
|
|
2020-01-02 13:19:22 -06:00
|
|
|
def setLastEntered(self, lastEntered):
|
|
|
|
self.lastEntered = lastEntered
|
|
|
|
|
|
|
|
def d_setLastEntered(self, lastEntered):
|
|
|
|
self.sendUpdate('setLastEntered', [lastEntered])
|
|
|
|
|
|
|
|
def b_setLastEntered(self, lastEntered):
|
|
|
|
self.setLastEntered(lastEntered)
|
|
|
|
self.d_setLastEntered(lastEntered)
|
|
|
|
|
2019-12-05 21:42:29 -06:00
|
|
|
def getLastEntered(self):
|
|
|
|
return self.lastEntered
|
2020-01-02 13:19:22 -06:00
|
|
|
|
|
|
|
def addAvBlock(self, avId, startingBlock, paid):
|
|
|
|
av = self.air.doId2do.get(avId)
|
|
|
|
if not av:
|
|
|
|
return
|
|
|
|
|
|
|
|
if not av.hasKart():
|
|
|
|
return KartGlobals.ERROR_CODE.eNoKart
|
|
|
|
|
|
|
|
if not startingBlock.avId:
|
|
|
|
self.b_setLastEntered(globalClockDelta.getRealNetworkTime())
|
|
|
|
taskMgr.doMethodLater(KartGlobals.COUNTDOWN_TIME, self.kickAvatar,
|
|
|
|
startingBlock.uniqueName('viewTimer'),
|
|
|
|
extraArgs=[avId, startingBlock])
|
|
|
|
return KartGlobals.ERROR_CODE.success
|
|
|
|
else:
|
|
|
|
return KartGlobals.ERROR_CODE.eOccupied
|
|
|
|
|
|
|
|
def removeAvBlock(self, avId, startingBlock):
|
|
|
|
if avId == startingBlock.avId:
|
|
|
|
taskMgr.remove(startingBlock.uniqueName('viewTimer'))
|
|
|
|
|
|
|
|
def kickAvatar(self, avId, startingBlock):
|
|
|
|
if avId == startingBlock.avId and not startingBlock.currentMovie:
|
|
|
|
startingBlock.normalExit()
|