2015-06-23 12:27:14 +00:00
|
|
|
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
|
|
|
import HolidayGlobals
|
|
|
|
|
|
|
|
class DistributedEffectMgrAI(DistributedObjectAI):
|
|
|
|
|
|
|
|
def __init__(self, air, holiday, effectId):
|
|
|
|
DistributedObjectAI.__init__(self, air)
|
|
|
|
self.holiday = holiday
|
|
|
|
self.effectId = effectId
|
|
|
|
|
|
|
|
def getHoliday(self):
|
|
|
|
return self.holiday
|
|
|
|
|
2015-06-23 12:55:15 +00:00
|
|
|
def requestEffect(self):
|
2015-06-23 12:27:14 +00:00
|
|
|
if not self.air.newsManager.isHolidayRunning(self.holiday):
|
|
|
|
return
|
|
|
|
|
2015-06-23 12:55:15 +00:00
|
|
|
avId = self.air.getAvatarIdFromSender()
|
|
|
|
av = self.air.doId2do.get(avId)
|
2015-06-23 12:27:14 +00:00
|
|
|
|
|
|
|
if not av:
|
|
|
|
return
|
|
|
|
|
|
|
|
holiday = HolidayGlobals.getHoliday(self.holiday)
|
|
|
|
expireTime = int(HolidayGlobals.getUnixTime(HolidayGlobals.getEndDate(holiday)) / 60)
|
|
|
|
|
2015-06-23 12:55:15 +00:00
|
|
|
self.sendUpdateToAvatarId(avId, 'effectDone')
|
|
|
|
self.doEffect(expireTime)
|
|
|
|
|
|
|
|
def doEffect(self, expireTime):
|
2015-06-23 12:27:14 +00:00
|
|
|
av.b_setCheesyEffect(self.effectId, 0, expireTime)
|