def findRacingPads(self, dnaGroup, zoneId, area, padType='racing_pad'): racingPads = [] racingPadGroups = [] if isinstance(dnaGroup, DNAGroup) and (padType in dnaGroup.getName()): racingPadGroups.append(dnaGroup) if padType == 'racing_pad': nameInfo = dnaGroup.getName().split('_') racingPad = DistributedRacePadAI(simbase.air) racingPad.setArea(zoneId) racingPad.nameType = nameInfo[3] racingPad.index = int(nameInfo[2]) nextRaceInfo = RaceGlobals.getNextRaceInfo( -1, racingPad.nameType, racingPad.index) racingPad.setTrackInfo([nextRaceInfo[0], nextRaceInfo[1]]) racingPad.generateWithRequired(zoneId) elif padType == 'viewing_pad': racingPad = DistributedViewPadAI(simbase.air) racingPad.setArea(zoneId) racingPad.generateWithRequired(zoneId) else: self.notify.error('Invalid racing pad type: ' + padType) racingPads.append(racingPad) elif isinstance(dnaGroup, DNAVisGroup): zoneId = int(dnaGroup.getName().split(':')[0]) for i in xrange(dnaGroup.getNumChildren()): (foundRacingPads, foundRacingPadGroups) = self.findRacingPads(dnaGroup.at(i), zoneId, area, padType=padType) racingPads.extend(foundRacingPads) racingPadGroups.extend(foundRacingPadGroups) return (racingPads, racingPadGroups)
def findRacingPads(self, dnaGroup, zoneId, area, padType='racing_pad'): racingPads = [] racingPadGroups = [] if isinstance(dnaGroup, DNAGroup) and (padType in dnaGroup.getName()): racingPadGroups.append(dnaGroup) if padType == 'racing_pad': nameInfo = dnaGroup.getName().split('_') racingPad = DistributedRacePadAI(simbase.air) racingPad.setArea(zoneId) racingPad.nameType = nameInfo[3] racingPad.index = int(nameInfo[2]) nextRaceInfo = RaceGlobals.getNextRaceInfo(-1, racingPad.nameType, racingPad.index) racingPad.setTrackInfo([nextRaceInfo[0], nextRaceInfo[1]]) racingPad.generateWithRequired(zoneId) elif padType == 'viewing_pad': racingPad = DistributedViewPadAI(simbase.air) racingPad.setArea(zoneId) racingPad.generateWithRequired(zoneId) else: self.notify.error('Invalid racing pad type: ' + padType) racingPads.append(racingPad) elif isinstance(dnaGroup, DNAVisGroup): zoneId = int(dnaGroup.getName().split(':')[0]) for i in xrange(dnaGroup.getNumChildren()): (foundRacingPads, foundRacingPadGroups) = self.findRacingPads(dnaGroup.at(i), zoneId, area, padType=padType) racingPads.extend(foundRacingPads) racingPadGroups.extend(foundRacingPadGroups) return (racingPads, racingPadGroups)
def changeTrack(self): nri = RaceGlobals.getNextRaceInfo(self.trackId, self.nameType, self.index) self.b_setTrackInfo([nri[0], nri[1]]) taskMgr.doMethodLater(30, DistributedRacePadAI.changeTrack, 'changeTrack%i' % self.doId, [self])