mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2025-01-09 17:53:50 +00:00
Implement effect delay.
This commit is contained in:
parent
4ec772e549
commit
44920579d1
4 changed files with 27 additions and 6 deletions
3
dependencies/astron/dclass/stride.dc
vendored
3
dependencies/astron/dclass/stride.dc
vendored
|
@ -2432,7 +2432,8 @@ dclass DistributedPolarPlaceEffectMgr : DistributedObject {
|
||||||
|
|
||||||
dclass DistributedEffectMgr : DistributedObject {
|
dclass DistributedEffectMgr : DistributedObject {
|
||||||
setHoliday(uint8) required broadcast;
|
setHoliday(uint8) required broadcast;
|
||||||
addEffect() airecv clsend;
|
requestEffect() airecv clsend;
|
||||||
|
effectDone();
|
||||||
};
|
};
|
||||||
|
|
||||||
dclass DistributedResistanceEmoteMgr : DistributedObject {
|
dclass DistributedResistanceEmoteMgr : DistributedObject {
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
from direct.distributed.DistributedObject import DistributedObject
|
from direct.distributed.DistributedObject import DistributedObject
|
||||||
from otp.speedchat import SpeedChatGlobals
|
from otp.speedchat import SpeedChatGlobals
|
||||||
import HolidayGlobals
|
import HolidayGlobals, time
|
||||||
|
|
||||||
class DistributedEffectMgr(DistributedObject):
|
class DistributedEffectMgr(DistributedObject):
|
||||||
|
|
||||||
|
def __init__(self, cr):
|
||||||
|
DistributedObject.__init__(self, cr)
|
||||||
|
self.nextTime = 0
|
||||||
|
|
||||||
def delete(self):
|
def delete(self):
|
||||||
self.ignoreAll()
|
self.ignoreAll()
|
||||||
DistributedObject.delete(self)
|
DistributedObject.delete(self)
|
||||||
|
@ -16,10 +20,20 @@ class DistributedEffectMgr(DistributedObject):
|
||||||
if not self.cr.newsManager.isHolidayRunning(self.holiday):
|
if not self.cr.newsManager.isHolidayRunning(self.holiday):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
currentTime = time.time()
|
||||||
|
|
||||||
|
if self.nextTime > currentTime:
|
||||||
|
return
|
||||||
|
|
||||||
holidayInfo = HolidayGlobals.getHoliday(self.holiday)
|
holidayInfo = HolidayGlobals.getHoliday(self.holiday)
|
||||||
|
|
||||||
if 'speedchatIndexes' not in holidayInfo or phraseId not in holidayInfo['speedchatIndexes']:
|
if 'speedchatIndexes' not in holidayInfo or phraseId not in holidayInfo['speedchatIndexes']:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.sendUpdate('addEffect')
|
if 'effectDelay' in holidayInfo:
|
||||||
|
self.nextTime = currentTime + holidayInfo['effectDelay']
|
||||||
|
|
||||||
|
self.sendUpdate('requestEffect')
|
||||||
|
|
||||||
|
def effectDone(self):
|
||||||
self.cr.newsManager.broadcastHoliday(holidayInfo, 'effectMessage')
|
self.cr.newsManager.broadcastHoliday(holidayInfo, 'effectMessage')
|
|
@ -11,11 +11,12 @@ class DistributedEffectMgrAI(DistributedObjectAI):
|
||||||
def getHoliday(self):
|
def getHoliday(self):
|
||||||
return self.holiday
|
return self.holiday
|
||||||
|
|
||||||
def addEffect(self):
|
def requestEffect(self):
|
||||||
if not self.air.newsManager.isHolidayRunning(self.holiday):
|
if not self.air.newsManager.isHolidayRunning(self.holiday):
|
||||||
return
|
return
|
||||||
|
|
||||||
av = self.air.doId2do.get(self.air.getAvatarIdFromSender())
|
avId = self.air.getAvatarIdFromSender()
|
||||||
|
av = self.air.doId2do.get(avId)
|
||||||
|
|
||||||
if not av:
|
if not av:
|
||||||
return
|
return
|
||||||
|
@ -23,4 +24,8 @@ class DistributedEffectMgrAI(DistributedObjectAI):
|
||||||
holiday = HolidayGlobals.getHoliday(self.holiday)
|
holiday = HolidayGlobals.getHoliday(self.holiday)
|
||||||
expireTime = int(HolidayGlobals.getUnixTime(HolidayGlobals.getEndDate(holiday)) / 60)
|
expireTime = int(HolidayGlobals.getUnixTime(HolidayGlobals.getEndDate(holiday)) / 60)
|
||||||
|
|
||||||
|
self.sendUpdateToAvatarId(avId, 'effectDone')
|
||||||
|
self.doEffect(expireTime)
|
||||||
|
|
||||||
|
def doEffect(self, expireTime):
|
||||||
av.b_setCheesyEffect(self.effectId, 0, expireTime)
|
av.b_setCheesyEffect(self.effectId, 0, expireTime)
|
|
@ -54,7 +54,8 @@ Holidays = {
|
||||||
'ongoingMessage': TTLocalizer.IdesOfMarchStart,
|
'ongoingMessage': TTLocalizer.IdesOfMarchStart,
|
||||||
'endMessage': TTLocalizer.IdesOfMarchEnd,
|
'endMessage': TTLocalizer.IdesOfMarchEnd,
|
||||||
'speedchatIndexes': [30450], # It's easy to be green!
|
'speedchatIndexes': [30450], # It's easy to be green!
|
||||||
'effectMessage': TTLocalizer.GreenToonEffectMsg
|
'effectMessage': TTLocalizer.GreenToonEffectMsg,
|
||||||
|
'effectDelay': 10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue