def gotAllRooms(self): self.notify.debug('countryClub %s: got all rooms' % self.doId) self.roomWatcher.destroy() self.roomWatcher = None self.geom = render.attachNewNode('countryClub%s' % self.doId) for doId in self.roomDoIds: self.rooms.append(base.cr.doId2do[doId]) self.rooms[-1].setCountryClub(self) self.notify.info('countryClubId %s, floor %s, %s' % (self.countryClubId, self.floorNum, self.rooms[0].avIdList)) rng = self.layout.getRng() numRooms = self.layout.getNumRooms() for i, room in enumerate(self.rooms): if i == 0: room.getGeom().reparentTo(self.geom) else: room.attachTo(self.hallways[i - 1], rng) self.allRooms.append(room) self.listenForFloorEvents(room) if i < numRooms - 1: hallway = CountryClubRoom.CountryClubRoom(self.layout.getHallwayModel(i)) hallway.attachTo(room, rng) hallway.setRoomNum(i * 2 + 1) hallway.initFloorCollisions() hallway.enter() self.hallways.append(hallway) self.allRooms.append(hallway) self.listenForFloorEvents(hallway) def handleCameraRayFloorCollision(collEntry, self = self): name = collEntry.getIntoNode().getName() self.notify.debug('camera floor ray collided with: %s' % name) prefix = CountryClubRoom.CountryClubRoom.FloorCollPrefix prefixLen = len(prefix) if name[:prefixLen] == prefix: try: roomNum = int(name[prefixLen:]) except: DistributedLevel.notify.warning('Invalid zone floor collision node: %s' % name) else: self.camEnterRoom(roomNum) self.accept('on-floor', handleCameraRayFloorCollision) if bboard.has('countryClubRoom'): self.warpToRoom(bboard.get('countryClubRoom')) firstSetZoneDoneEvent = self.cr.getNextSetZoneDoneEvent() def handleFirstSetZoneDone(): self.notify.debug('countryClubHandleFirstSetZoneDone') self.accept('takingScreenshot', self.handleScreenshot) base.transitions.irisIn() bboard.post(DistributedCountryClub.ReadyPost, self) self.acceptOnce(firstSetZoneDoneEvent, handleFirstSetZoneDone) zoneList = [OTPGlobals.UberZone, self.zoneId] for room in self.rooms: zoneList.extend(room.zoneIds) base.cr.sendSetZoneMsg(self.zoneId, zoneList) return
def gotAllRooms(self): self.notify.debug('countryClub %s: got all rooms' % self.doId) if self.roomWatcher: self.roomWatcher.destroy() self.roomWatcher = None self.geom = render.attachNewNode('countryClub%s' % self.doId) for doId in self.roomDoIds: room = base.cr.doId2do.get(doId) if room is None: continue room.setCountryClub(self) roomName = CountryClubRoomSpecs.BossbotCountryClubRoomId2RoomName[ room.roomId] if roomName == 'BossbotCountryClubKartRoom_Battle00': floorNum = self.floorNum signOrigin = room.getGeom().find('**/sign_origin') floorName = TTLocalizer.CountryClubFloorNum2Name[floorNum + 1] text = TextEncoder.upper(floorName) font = ToontownGlobals.getSuitFont() scale = TTLocalizer.BCHQLsignText fg = (0, 0, 0, 1) signText = DirectGui.OnscreenText(text=text, font=font, scale=scale, fg=fg, parent=signOrigin) signText.setPosHpr(signOrigin, -0.675, 0, -0.9, -90, 0, 0) signText.setDepthWrite(0) self.rooms.append(room) self.notify.info( 'countryClubId %s, floor %s, %s' % (self.countryClubId, self.floorNum, self.rooms[0].avIdList)) rng = self.layout.getRng() numRooms = self.layout.getNumRooms() for i, room in enumerate(self.rooms): if i == 0: room.getGeom().reparentTo(self.geom) else: room.attachTo(self.hallways[i - 1], rng) self.allRooms.append(room) self.listenForFloorEvents(room) if i < numRooms - 1: hallway = CountryClubRoom.CountryClubRoom( self.layout.getHallwayModel(i)) hallway.attachTo(room, rng) hallway.setRoomNum(i * 2 + 1) hallway.initFloorCollisions() hallway.enter() self.hallways.append(hallway) self.allRooms.append(hallway) self.listenForFloorEvents(hallway) def handleCameraRayFloorCollision(collEntry, self=self): name = collEntry.getIntoNode().getName() self.notify.debug('camera floor ray collided with: %s' % name) prefix = CountryClubRoom.CountryClubRoom.FloorCollPrefix prefixLen = len(prefix) if name[:prefixLen] == prefix: try: roomNum = int(name[prefixLen:]) except: DistributedLevel.notify.warning( 'Invalid zone floor collision node: %s' % name) else: self.camEnterRoom(roomNum) self.accept('on-floor', handleCameraRayFloorCollision) if bboard.has('countryClubRoom'): self.warpToRoom(bboard.get('countryClubRoom')) firstSetZoneDoneEvent = self.cr.getNextSetZoneDoneEvent() def handleFirstSetZoneDone(): self.notify.debug('countryClubHandleFirstSetZoneDone') self.accept('takingScreenshot', self.handleScreenshot) base.transitions.irisIn() bboard.post(DistributedCountryClub.ReadyPost, self) self.acceptOnce(firstSetZoneDoneEvent, handleFirstSetZoneDone) zoneList = [OTPGlobals.UberZone, self.zoneId] for room in self.rooms: zoneList.extend(room.zoneIds) base.cr.sendSetZoneMsg(self.zoneId, zoneList) return
def gotAllRooms(self): self.notify.debug('countryClub %s: got all rooms' % self.doId) self.roomWatcher.destroy() self.roomWatcher = None self.geom = render.attachNewNode('countryClub%s' % self.doId) # fill out our table of rooms for doId in self.roomDoIds: self.rooms.append(base.cr.doId2do[doId]) self.rooms[-1].setCountryClub(self) self.notify.info( 'countryClubId %s, floor %s, %s' % (self.countryClubId, self.floorNum, self.rooms[0].avIdList)) rng = self.layout.getRng() numRooms = self.layout.getNumRooms() for i, room in enumerate(self.rooms): # there's a hallway between each pair of rooms if i == 0: room.getGeom().reparentTo(self.geom) else: # attach the room to the preceding hallway room.attachTo(self.hallways[i - 1], rng) self.allRooms.append(room) self.listenForFloorEvents(room) if i < (numRooms - 1): # add a hallway leading out of the room hallway = CountryClubRoom.CountryClubRoom( self.layout.getHallwayModel(i)) hallway.attachTo(room, rng) hallway.setRoomNum((i * 2) + 1) hallway.initFloorCollisions() hallway.enter() self.hallways.append(hallway) self.allRooms.append(hallway) self.listenForFloorEvents(hallway) # listen for camera-ray/floor collision events def handleCameraRayFloorCollision(collEntry, self=self): name = collEntry.getIntoNode().getName() self.notify.debug('camera floor ray collided with: %s' % name) prefix = CountryClubRoom.CountryClubRoom.FloorCollPrefix prefixLen = len(prefix) if (name[:prefixLen] == prefix): try: roomNum = int(name[prefixLen:]) except: DistributedLevel.notify.warning( 'Invalid zone floor collision node: %s' % name) else: self.camEnterRoom(roomNum) self.accept('on-floor', handleCameraRayFloorCollision) if bboard.has('countryClubRoom'): self.warpToRoom(bboard.get('countryClubRoom')) # get this event name before we send out our first setZone firstSetZoneDoneEvent = self.cr.getNextSetZoneDoneEvent() # wait until the first viz setZone completes before announcing # that we're ready to go def handleFirstSetZoneDone(): self.notify.debug('countryClubHandleFirstSetZoneDone') self.accept('takingScreenshot', self.handleScreenshot) # do this here; the elevator (which does an iris out) is guaranteed to # be gone by now, so if it's going to do an iris out, it's already done base.transitions.irisIn() # NOW we're ready. bboard.post(DistributedCountryClub.ReadyPost, self) self.acceptOnce(firstSetZoneDoneEvent, handleFirstSetZoneDone) # listen to all of the network zones; no network visibility for now zoneList = [OTPGlobals.UberZone, self.zoneId] for room in self.rooms: zoneList.extend(room.zoneIds) base.cr.sendSetZoneMsg(self.zoneId, zoneList)