Poodletooth-iLand/toontown/ai/DistributedEffectMgr.py
2015-06-23 15:55:15 +03:00

39 lines
No EOL
1.2 KiB
Python

from direct.distributed.DistributedObject import DistributedObject
from otp.speedchat import SpeedChatGlobals
import HolidayGlobals, time
class DistributedEffectMgr(DistributedObject):
def __init__(self, cr):
DistributedObject.__init__(self, cr)
self.nextTime = 0
def delete(self):
self.ignoreAll()
DistributedObject.delete(self)
def setHoliday(self, holiday):
self.holiday = holiday
self.accept(SpeedChatGlobals.SCStaticTextMsgEvent, self.__saidPhrase)
def __saidPhrase(self, phraseId):
if not self.cr.newsManager.isHolidayRunning(self.holiday):
return
currentTime = time.time()
if self.nextTime > currentTime:
return
holidayInfo = HolidayGlobals.getHoliday(self.holiday)
if 'speedchatIndexes' not in holidayInfo or phraseId not in holidayInfo['speedchatIndexes']:
return
if 'effectDelay' in holidayInfo:
self.nextTime = currentTime + holidayInfo['effectDelay']
self.sendUpdate('requestEffect')
def effectDone(self):
self.cr.newsManager.broadcastHoliday(holidayInfo, 'effectMessage')