2015-06-26 02:09:27 -05:00
|
|
|
from otp.nametag.NametagConstants import CFSpeech, CFTimeout
|
2015-05-11 11:21:07 -05:00
|
|
|
from toontown.toonbase import TTLocalizer, ToontownGlobals
|
2015-05-11 15:36:31 -05:00
|
|
|
from toontown.toon import NPCToons
|
2015-05-11 11:21:07 -05:00
|
|
|
from DistributedNPCToonBase import DistributedNPCToonBase
|
2015-07-25 01:08:54 -05:00
|
|
|
import LaffRestockGlobals, LaffShopGui, time
|
2015-05-11 11:21:07 -05:00
|
|
|
|
|
|
|
class DistributedNPCLaffRestock(DistributedNPCToonBase):
|
|
|
|
|
|
|
|
def __init__(self, cr):
|
|
|
|
DistributedNPCToonBase.__init__(self, cr)
|
2015-07-25 01:08:54 -05:00
|
|
|
self.lastCollision = 0
|
|
|
|
self.laffDialog = None
|
2015-05-11 11:21:07 -05:00
|
|
|
|
|
|
|
def disable(self):
|
|
|
|
self.ignoreAll()
|
2015-07-25 01:08:54 -05:00
|
|
|
self.destroyDialog()
|
2015-05-11 11:21:07 -05:00
|
|
|
DistributedNPCToonBase.disable(self)
|
|
|
|
|
2015-07-25 01:08:54 -05:00
|
|
|
def destroyDialog(self):
|
|
|
|
self.clearChat()
|
|
|
|
|
|
|
|
if self.laffDialog:
|
|
|
|
self.laffDialog.destroy()
|
|
|
|
self.laffDialog = None
|
|
|
|
|
2015-05-11 15:36:31 -05:00
|
|
|
def initToonState(self):
|
|
|
|
self.setAnimState('neutral', 0.9, None, None)
|
2015-07-25 01:08:54 -05:00
|
|
|
self.putOnSuit(ToontownGlobals.cogHQZoneId2deptIndex(self.zoneId), rental=True)
|
|
|
|
|
2015-05-11 15:36:31 -05:00
|
|
|
if self.name in NPCToons.LaffRestockPositions:
|
|
|
|
pos = NPCToons.LaffRestockPositions[self.name]
|
|
|
|
self.setPos(*pos[0])
|
|
|
|
self.setH(pos[1])
|
2015-05-11 14:05:59 -05:00
|
|
|
|
2015-05-11 11:21:07 -05:00
|
|
|
def getCollSphereRadius(self):
|
2015-07-25 01:08:54 -05:00
|
|
|
return 1.25
|
2015-05-11 11:21:07 -05:00
|
|
|
|
|
|
|
def handleCollisionSphereEnter(self, collEntry):
|
2015-07-25 01:08:54 -05:00
|
|
|
if self.lastCollision > time.time():
|
2015-05-11 11:21:07 -05:00
|
|
|
return
|
2015-07-25 01:08:54 -05:00
|
|
|
|
|
|
|
self.lastCollision = time.time() + ToontownGlobals.NPCCollisionDelay
|
|
|
|
self.lookAt(base.localAvatar)
|
|
|
|
|
|
|
|
if base.localAvatar.getHp() >= base.localAvatar.getMaxHp():
|
2015-05-12 00:06:23 -05:00
|
|
|
self.setChatAbsolute(TTLocalizer.RestockFullLaffMessage, CFSpeech | CFTimeout)
|
2015-07-25 01:08:54 -05:00
|
|
|
return
|
|
|
|
|
|
|
|
base.cr.playGame.getPlace().fsm.request('stopped')
|
|
|
|
base.setCellsAvailable(base.bottomCells, 0)
|
|
|
|
self.destroyDialog()
|
|
|
|
self.acceptOnce('laffShopDone', self.__laffShopDone)
|
|
|
|
self.laffDialog = LaffShopGui.LaffShopGui()
|
|
|
|
|
|
|
|
def freeAvatar(self):
|
|
|
|
base.cr.playGame.getPlace().fsm.request('walk')
|
|
|
|
base.setCellsAvailable(base.bottomCells, 1)
|
|
|
|
|
|
|
|
def __laffShopDone(self, state, laff):
|
|
|
|
self.freeAvatar()
|
2015-05-12 00:06:23 -05:00
|
|
|
|
2015-07-25 01:08:54 -05:00
|
|
|
if state == LaffRestockGlobals.TIMER_END:
|
|
|
|
self.setChatAbsolute(TTLocalizer.STOREOWNER_TOOKTOOLONG, CFSpeech|CFTimeout)
|
|
|
|
elif state == LaffRestockGlobals.USER_CANCEL:
|
|
|
|
self.setChatAbsolute(TTLocalizer.STOREOWNER_GOODBYE, CFSpeech|CFTimeout)
|
|
|
|
elif state == LaffRestockGlobals.RESTOCK:
|
|
|
|
self.sendUpdate('restock', [laff])
|
2015-05-12 00:06:23 -05:00
|
|
|
|
2015-07-25 01:08:54 -05:00
|
|
|
def restockResult(self, state):
|
|
|
|
if state in LaffRestockGlobals.RestockMessages:
|
|
|
|
self.setChatAbsolute(LaffRestockGlobals.RestockMessages[state], CFSpeech | CFTimeout)
|