Esempio n. 1
0
    def __init__(self, node):
        AnimatedProp.AnimatedProp.__init__(self, node)
        self.origAnimNameToSound = {}
        code = node.getTag('DNACode')
        if code.startswith('interactive_prop_'):
            pathStr = code[len('interactive_prop_'):].split('__')[0]
        elif code.startswith('animated_prop_generic_'):
            pathStr = code[len('animated_prop_generic_'):].split('__')[0]
        elif code.startswith('animated_prop_'):
            tempStr = code[len('animated_prop_'):]
            nextUnderscore = tempStr.find('_')
            finalStr = tempStr[nextUnderscore + 1:]
            pathStr = finalStr.split('__')[0]
        elif code.startswith('animated_building_'):
            pathStr = code[len('animated_building_'):].split('__')[0]

        phaseDelimeter = len('phase_') + pathStr[len('phase_'):].find('_')
        phaseStr = pathStr[:phaseDelimeter]
        pathTokens = pathStr[phaseDelimeter + 1:].split('_')
        self.path = phaseStr
        for path in pathTokens:
            self.path += '/'
            self.path += path

        self.notify.debug('self.path=%s' % self.path)
        self.calcHoodId(node)
        self.propType = HoodUtil.calcPropType(node)
        self.setupActor(node)
        self.code = code
Esempio n. 2
0
    def __init__(self, node):
        AnimatedProp.AnimatedProp.__init__(self, node)
        self.origAnimNameToSound = {}
        code = node.getTag('DNACode')
        if code.startswith('interactive_prop_'):
            pathStr = code[len('interactive_prop_'):].split('__')[0]
        elif code.startswith('animated_prop_generic_'):
            pathStr = code[len('animated_prop_generic_'):].split('__')[0]
        elif code.startswith('animated_prop_'):
            tempStr = code[len('animated_prop_'):]
            nextUnderscore = tempStr.find('_')
            finalStr = tempStr[nextUnderscore + 1:]
            pathStr = finalStr.split('__')[0]
        elif code.startswith('animated_building_'):
            pathStr = code[len('animated_building_'):].split('__')[0]
        phaseDelimeter = len('phase_') + pathStr[len('phase_'):].find('_')
        phaseStr = pathStr[:phaseDelimeter]
        pathTokens = pathStr[phaseDelimeter + 1:].split('_')
        self.path = phaseStr
        for path in pathTokens:
            self.path += '/'
            self.path += path

        self.notify.debug('self.path=%s' % self.path)
        self.calcHoodId(node)
        self.propType = HoodUtil.calcPropType(node)
        self.setupActor(node)
        self.code = code
    def initDNAInfo(self):
        numGraphs = self.dnaStore.discoverContinuity()
        if numGraphs != 1:
            self.notify.info('zone %s has %s disconnected suit paths.' % (self.zoneId, numGraphs))
        self.battlePosDict = {}
        self.cellToGagBonusDict = {}
        for i in range(self.dnaStore.getNumDNAVisGroupsAI()):
            vg = self.dnaStore.getDNAVisGroupAI(i)
            zoneId = int(self.extractGroupName(vg.getName()))
            if vg.getNumBattleCells() == 1:
                battleCell = vg.getBattleCell(0)
                self.battlePosDict[zoneId] = vg.getBattleCell(0).getPos()
            elif vg.getNumBattleCells() > 1:
                self.notify.warning('multiple battle cells for zone: %d' % zoneId)
                self.battlePosDict[zoneId] = vg.getBattleCell(0).getPos()
            if True:
                for i in range(vg.getNumChildren()):
                    childDnaGroup = vg.at(i)
                    if isinstance(childDnaGroup, DNAInteractiveProp):
                        self.notify.debug('got interactive prop %s' % childDnaGroup)
                        battleCellId = childDnaGroup.getCellId()
                        if battleCellId == -1:
                            self.notify.warning('interactive prop %s  at %s not associated with a a battle' % (childDnaGroup, zoneId))
                        elif battleCellId == 0:
                            if self.cellToGagBonusDict.has_key(zoneId):
                                self.notify.error('FIXME battle cell at zone %s has two props %s %s linked to it' % (zoneId, self.cellToGagBonusDict[zoneId], childDnaGroup))
                            else:
                                name = childDnaGroup.getName()
                                propType = HoodUtil.calcPropType(name)
                                if propType in ToontownBattleGlobals.PropTypeToTrackBonus:
                                    trackBonus = ToontownBattleGlobals.PropTypeToTrackBonus[propType]
                                    self.cellToGagBonusDict[zoneId] = trackBonus

        self.dnaStore.resetDNAGroups()
        self.dnaStore.resetDNAVisGroups()
        self.dnaStore.resetDNAVisGroupsAI()
        self.streetPointList = []
        self.frontdoorPointList = []
        self.sidedoorPointList = []
        self.cogHQDoorPointList = []
        numPoints = self.dnaStore.getNumSuitPoints()
        for i in range(numPoints):
            point = self.dnaStore.getSuitPointAtIndex(i)
            
            if point.getPointType() == 1:#DNASuitPoint.FRONTDOORPOINT:
                self.frontdoorPointList.append(point)
                
            elif point.getPointType() == 2:#DNASuitPoint.SIDEDOORPOINT:
                self.sidedoorPointList.append(point)
                
            elif point.getPointType() >= 3:#== DNASuitPoint.COGHQINPOINT or point.getPointType() == DNASuitPoint.COGHQOUTPOINT:
                self.cogHQDoorPointList.append(point)
                
            else:
                self.streetPointList.append(point)
                
            self.pointIndexes[point.getIndex()] = point

        return None
    def initDNAInfo(self):
        numGraphs = self.dnaStore.discoverContinuity()
        if numGraphs != 1:
            self.notify.info('zone %s has %s disconnected suit paths.' % (self.zoneId, numGraphs))
        self.battlePosDict = {}
        self.cellToGagBonusDict = {}
        for i in range(self.dnaStore.getNumDNAVisGroupsAI()):
            vg = self.dnaStore.getDNAVisGroupAI(i)
            zoneId = int(self.extractGroupName(vg.getName()))
            if vg.getNumBattleCells() == 1:
                battleCell = vg.getBattleCell(0)
                self.battlePosDict[zoneId] = vg.getBattleCell(0).getPos()
            elif vg.getNumBattleCells() > 1:
                self.notify.warning('multiple battle cells for zone: %d' % zoneId)
                self.battlePosDict[zoneId] = vg.getBattleCell(0).getPos()
            if True:
                for i in range(vg.getNumChildren()):
                    childDnaGroup = vg.at(i)
                    if isinstance(childDnaGroup, DNAInteractiveProp):
                        self.notify.debug('got interactive prop %s' % childDnaGroup)
                        battleCellId = childDnaGroup.getCellId()
                        if battleCellId == -1:
                            self.notify.warning('interactive prop %s  at %s not associated with a a battle' % (childDnaGroup, zoneId))
                        elif battleCellId == 0:
                            if self.cellToGagBonusDict.has_key(zoneId):
                                self.notify.error('FIXME battle cell at zone %s has two props %s %s linked to it' % (zoneId, self.cellToGagBonusDict[zoneId], childDnaGroup))
                            else:
                                name = childDnaGroup.getName()
                                propType = HoodUtil.calcPropType(name)
                                if propType in ToontownBattleGlobals.PropTypeToTrackBonus:
                                    trackBonus = ToontownBattleGlobals.PropTypeToTrackBonus[propType]
                                    self.cellToGagBonusDict[zoneId] = trackBonus

        self.dnaStore.resetDNAGroups()
        self.dnaStore.resetDNAVisGroups()
        self.dnaStore.resetDNAVisGroupsAI()
        self.streetPointList = []
        self.frontdoorPointList = []
        self.sidedoorPointList = []
        self.cogHQDoorPointList = []
        numPoints = self.dnaStore.getNumSuitPoints()
        for i in range(numPoints):
            point = self.dnaStore.getSuitPointAtIndex(i)
            
            if point.getPointType() == 1:#DNASuitPoint.FRONTDOORPOINT:
                self.frontdoorPointList.append(point)
                
            elif point.getPointType() == 2:#DNASuitPoint.SIDEDOORPOINT:
                self.sidedoorPointList.append(point)
                
            elif point.getPointType() >= 3:#== DNASuitPoint.COGHQINPOINT or point.getPointType() == DNASuitPoint.COGHQOUTPOINT:
                self.cogHQDoorPointList.append(point)
                
            else:
                self.streetPointList.append(point)
                
            self.pointIndexes[point.getIndex()] = point

        return None
Esempio n. 5
0
    def initDNAInfo(self):
        self.battlePosDict = {}
        self.cellToGagBonusDict = {}
        vgs = DNAUtil.getVisGroups(self.dnaStore)
        for vg in vgs:
            zoneId = int(self.extractGroupName(vg.zone))
            bcs = DNAUtil.getChildrenOfType(vg, DNABattleCell.DNABattleCell)
            if len(bcs) == 1:
                battleCell = bcs[0]
                self.battlePosDict[zoneId] = bcs[0].getPos()
            elif len(bcs) > 1:
                self.notify.warning('multiple battle cells for zone: %d' %
                                    zoneId)
                self.battlePosDict[zoneId] = bcs[0].getPos()
            if True:
                for childDnaGroup in vg.children:
                    if isinstance(childDnaGroup,
                                  DNAInteractiveProp.DNAInteractiveProp):
                        self.notify.debug('got interactive prop %s' %
                                          childDnaGroup)
                        battleCellId = childDnaGroup.getCellId()
                        if battleCellId == -1:
                            self.notify.warning(
                                'interactive prop %s  at %s not associated with a a battle'
                                % (childDnaGroup, zoneId))
                        elif battleCellId == 0:
                            if self.cellToGagBonusDict.has_key(zoneId):
                                self.notify.error(
                                    'FIXME battle cell at zone %s has two props %s %s linked to it'
                                    % (zoneId, self.cellToGagBonusDict[zoneId],
                                       childDnaGroup))
                            else:
                                name = childDnaGroup.getName()
                                propType = HoodUtil.calcPropType(name)
                                if propType in ToontownBattleGlobals.PropTypeToTrackBonus:
                                    trackBonus = ToontownBattleGlobals.PropTypeToTrackBonus[
                                        propType]
                                    self.cellToGagBonusDict[
                                        zoneId] = trackBonus
        self.streetPointList = []
        self.frontdoorPointList = []
        self.sidedoorPointList = []
        self.cogHQDoorPointList = []
        for point in self.dnaData.suitPoints:
            if point.getPointType() == DNAStoreSuitPoint.FRONTDOORPOINT:
                self.frontdoorPointList.append(point)
            elif point.getPointType() == DNAStoreSuitPoint.SIDEDOORPOINT:
                self.sidedoorPointList.append(point)
            elif point.getPointType(
            ) == DNAStoreSuitPoint.COGHQINPOINT or point.getPointType(
            ) == DNAStoreSuitPoint.COGHQOUTPOINT:
                self.cogHQDoorPointList.append(point)
            else:
                self.streetPointList.append(point)
            self.pointIndexes[point.getIndex()] = point

        return None
    def initDNAInfo(self):
        self.battlePosDict = {}
        self.cellToGagBonusDict = {}
        vgs = DNAUtil.getVisGroups(self.dnaStore)
        for vg in vgs:
            zoneId = int(self.extractGroupName(vg.zone))
            bcs = DNAUtil.getChildrenOfType(vg, DNABattleCell.DNABattleCell)
            if len(bcs) == 1:
                battleCell = bcs[0]
                self.battlePosDict[zoneId] = bcs[0].getPos()
            elif len(bcs) > 1:
                self.notify.warning(
                    'multiple battle cells for zone: %d' %
                    zoneId)
                self.battlePosDict[zoneId] = bcs[0].getPos()
            if True:
                for childDnaGroup in vg.children:
                    if isinstance(
                            childDnaGroup,
                            DNAInteractiveProp.DNAInteractiveProp):
                        self.notify.debug(
                            'got interactive prop %s' %
                            childDnaGroup)
                        battleCellId = childDnaGroup.getCellId()
                        if battleCellId == -1:
                            self.notify.warning(
                                'interactive prop %s  at %s not associated with a a battle' %
                                (childDnaGroup, zoneId))
                        elif battleCellId == 0:
                            if zoneId in self.cellToGagBonusDict:
                                self.notify.error(
                                    'FIXME battle cell at zone %s has two props %s %s linked to it' %
                                    (zoneId, self.cellToGagBonusDict[zoneId], childDnaGroup))
                            else:
                                name = childDnaGroup.getName()
                                propType = HoodUtil.calcPropType(name)
                                if propType in ToontownBattleGlobals.PropTypeToTrackBonus:
                                    trackBonus = ToontownBattleGlobals.PropTypeToTrackBonus[
                                        propType]
                                    self.cellToGagBonusDict[
                                        zoneId] = trackBonus
        self.streetPointList = []
        self.frontdoorPointList = []
        self.sidedoorPointList = []
        self.cogHQDoorPointList = []
        for point in self.dnaData.suitPoints:
            if point.getPointType() == DNAStoreSuitPoint.FRONTDOORPOINT:
                self.frontdoorPointList.append(point)
            elif point.getPointType() == DNAStoreSuitPoint.SIDEDOORPOINT:
                self.sidedoorPointList.append(point)
            elif point.getPointType() == DNAStoreSuitPoint.COGHQINPOINT or point.getPointType() == DNAStoreSuitPoint.COGHQOUTPOINT:
                self.cogHQDoorPointList.append(point)
            else:
                self.streetPointList.append(point)
            self.pointIndexes[point.getIndex()] = point

        return None
    def initDNAInfo(self):
        numGraphs = self.dnaStore.discoverContinuity()
        if numGraphs != 1:
            self.notify.info('zone %s has %s disconnected suit paths.' % (self.zoneId, numGraphs))
        self.battlePosDict = {}
        self.cellToGagBonusDict = {}

        for i in xrange(self.dnaStore.getNumDNAVisGroupsAI()):
            vg = self.dnaStore.getDNAVisGroupAI(i)
            zoneId = int(self.extractGroupName(vg.getName()))
            
            if vg.getNumBattleCells() >= 1:
                battleCell = vg.getBattleCell(0)
                self.battlePosDict[zoneId] = battleCell.getPos()
            
            for i in xrange(vg.getNumChildren()):
                childDnaGroup = vg.at(i)
                
                if isinstance(childDnaGroup, DNAInteractiveProp) and not zoneId in self.cellToGagBonusDict:
                    propType = HoodUtil.calcPropType(childDnaGroup.getName())
                            
                    if propType in ToontownBattleGlobals.PropTypeToTrackBonus:
                        self.cellToGagBonusDict[zoneId] = ToontownBattleGlobals.PropTypeToTrackBonus[propType]

        self.dnaStore.resetDNAGroups()
        self.dnaStore.resetDNAVisGroups()
        self.dnaStore.resetDNAVisGroupsAI()
        self.streetPointList = []
        self.frontdoorPointList = []
        self.sidedoorPointList = []
        self.cogHQDoorPointList = []
        numPoints = self.dnaStore.getNumSuitPoints()
        for i in xrange(numPoints):
            point = self.dnaStore.getSuitPointAtIndex(i)
            if point.getPointType() == DNASuitPoint.FRONT_DOOR_POINT:
                self.frontdoorPointList.append(point)
            elif point.getPointType() == DNASuitPoint.SIDE_DOOR_POINT:
                self.sidedoorPointList.append(point)
            elif (point.getPointType() == DNASuitPoint.COGHQ_IN_POINT) or (point.getPointType() == DNASuitPoint.COGHQ_OUT_POINT):
                self.cogHQDoorPointList.append(point)
            else:
                self.streetPointList.append(point)
            self.pointIndexes[point.getIndex()] = point
Esempio n. 8
0
    def initDNAInfo(self):
        """
        ////////////////////////////////////////////////////////////////////
        // Function:    load up vis group information into a dictionary
        //              copied from HoodMgr.py
        // Parameters:  dnaStore, the dna storage structure to use
        // Changes:
        ////////////////////////////////////////////////////////////////////
        """
        numGraphs = self.dnaStore.discoverContinuity()
        if numGraphs != 1:
            self.notify.info("zone %s has %s disconnected suit paths." %
                             (self.zoneId, numGraphs))

        # Construct a dictionary of zone ids to battle cell center points
        self.battlePosDict = {}
        self.cellToGagBonusDict = {}
        #self.dnaStore.printSuitPointStorage()
        for i in range(self.dnaStore.getNumDNAVisGroupsAI()):
            vg = self.dnaStore.getDNAVisGroupAI(i)
            zoneId = int(self.extractGroupName(vg.getName()))
            # There is only 1 battle cell per zone
            if (vg.getNumBattleCells() == 1):
                battleCell = vg.getBattleCell(0)
                self.battlePosDict[zoneId] = vg.getBattleCell(0).getPos()
            elif (vg.getNumBattleCells() > 1):
                self.notify.warning('multiple battle cells for zone: %d' %
                                    zoneId)
                # Just pick the first one
                self.battlePosDict[zoneId] = vg.getBattleCell(0).getPos()
            if True:
                # lets find the interactive props connected to this battle cell
                for i in range(vg.getNumChildren()):
                    childDnaGroup = vg.at(i)
                    if (isinstance(childDnaGroup, DNAInteractiveProp)):
                        self.notify.debug("got interactive prop %s" %
                                          childDnaGroup)
                        battleCellId = childDnaGroup.getCellId()
                        if battleCellId == -1:
                            self.notify.warning(
                                "interactive prop %s  at %s not associated with a a battle"
                                % (childDnaGroup, zoneId))
                        elif battleCellId == 0:
                            if zoneId in self.cellToGagBonusDict:
                                self.notify.error(
                                    "FIXME battle cell at zone %s has two props %s %s linked to it"
                                    % (zoneId, self.cellToGagBonusDict[zoneId],
                                       childDnaGroup))
                            else:
                                # based on the name of the prop, figure out which gag track bonus
                                name = childDnaGroup.getName()
                                propType = HoodUtil.calcPropType(name)
                                if propType in ToontownBattleGlobals.PropTypeToTrackBonus:
                                    trackBonus = ToontownBattleGlobals.PropTypeToTrackBonus[
                                        propType]
                                    self.cellToGagBonusDict[
                                        zoneId] = trackBonus

        # Now that we have extracted the vis groups we do not need
        # the dnaStore to keep them around
        self.dnaStore.resetDNAGroups()
        self.dnaStore.resetDNAVisGroups()
        self.dnaStore.resetDNAVisGroupsAI()

        # now load up the suit path points, separate them into types
        #
        self.streetPointList = []
        self.frontdoorPointList = []
        self.sidedoorPointList = []
        self.cogHQDoorPointList = []

        numPoints = self.dnaStore.getNumSuitPoints()
        for i in range(numPoints):
            point = self.dnaStore.getSuitPointAtIndex(i)
            if (point.getPointType() == DNASuitPoint.FRONTDOORPOINT):
                self.frontdoorPointList.append(point)
            elif (point.getPointType() == DNASuitPoint.SIDEDOORPOINT):
                self.sidedoorPointList.append(point)
            elif (point.getPointType() == DNASuitPoint.COGHQINPOINT or \
                  point.getPointType() == DNASuitPoint.COGHQOUTPOINT):
                self.cogHQDoorPointList.append(point)
            else:
                self.streetPointList.append(point)

            self.pointIndexes[point.getIndex()] = point

        # perform a simple path test to make sure we can properly
        # generate a path from two points given to us by the DNAStorage
        #
#        self.performPathTest()

        return None