Ejemplo n.º 1
0
    def createAllEntities(self, priorityTypes=[]):
        """creates all entities in the spec. priorityTypes is an
        optional ordered list of entity types to create first."""
        # this will be filled in as the entities are created and report in
        # this includes distributed objects on the client
        self.entities = {}

        # get list of all entity types we need to create
        entTypes = self.entityCreator.getEntityTypes()

        self.onLevelPreCreate()

        # first create the types in the priority list
        for type in priorityTypes:
            assert type in entTypes
            self.createAllEntitiesOfType(type)
            entTypes.remove(type)

        # create the other entities in any old order
        for type in entTypes:
            self.createAllEntitiesOfType(type)

        assert uniqueElements(self.createdEntIds)

        self.onLevelPostCreate()
Ejemplo n.º 2
0
 def destroyAllEntities(self):
     assert uniqueElements(self.createdEntIds)
     self.nonlocalEntIds = {}
     self.nothingEntIds = {}
     # destroy the entities that we created in reverse order
     if not uniqueElements(self.createdEntIds):
         Level.notify.warning('%s: self.createdEntIds is not unique: %s' %
                              (getattr(self, 'doId', None), self.createdEntIds))
     while len(self.createdEntIds) > 0:
         entId = self.createdEntIds.pop()
         entity = self.getEntity(entId)
         if entity is not None:
             Level.notify.debug('destroying %s %s' % (
                 self.getEntityType(entId), entId))
             entity.destroy()
             assert not entId in self.entities
         else:
             Level.notify.error('trying to destroy entity %s, but '
                                'it is already gone' % entId)
Ejemplo n.º 3
0
    def destroyAllEntities(self):
        self.nonlocalEntIds = {}
        self.nothingEntIds = {}
        if not uniqueElements(self.createdEntIds):
            Level.notify.warning('%s: self.createdEntIds is not unique: %s' % (getattr(self, 'doId', None), self.createdEntIds))
        while len(self.createdEntIds) > 0:
            entId = self.createdEntIds.pop()
            entity = self.getEntity(entId)
            entity is not None and Level.notify.debug('destroying %s %s' % (self.getEntityType(entId), entId))
            entity.destroy()
            continue
            Level.notify.error('trying to destroy entity %s, but it is already gone' % entId)

        return
Ejemplo n.º 4
0
 def destroyAllEntities(self):
     self.nonlocalEntIds = { }
     self.nothingEntIds = { }
     if not uniqueElements(self.createdEntIds):
         Level.notify.warning('%s: self.createdEntIds is not unique: %s' % (getattr(self, 'doId', None), self.createdEntIds))
     
     while len(self.createdEntIds) > 0:
         entId = self.createdEntIds.pop()
         entity = self.getEntity(entId)
         if entity is not None:
             Level.notify.debug('destroying %s %s' % (self.getEntityType(entId), entId))
             entity.destroy()
             continue
         Level.notify.error('trying to destroy entity %s, but it is already gone' % entId)
Ejemplo n.º 5
0
    def setVisibility(self, vizList):
        """
        vizList is a list of visible zone numbers.
        """
        # if we're showing all zones, get all the DOs
        if self.fColorZones and DistributedLevel.ColorZonesAllDOs:
            vizList = list(self.zoneNums)
            vizList.remove(LevelConstants.UberZoneEntId)
        # convert the zone numbers into their actual zoneIds
        # always include Toontown and factory uberZones
        uberZone = self.getZoneId(LevelConstants.UberZoneEntId)
        # the level itself is in the 'level zone'
        visibleZoneIds = [OTPGlobals.UberZone, self.levelZone, uberZone]
        for vz in vizList:
            if vz is not LevelConstants.UberZoneEntId:
                visibleZoneIds.append(self.getZoneId(vz))
        assert uniqueElements(visibleZoneIds)
        DistributedLevel.notify.debug('new viz list: %s' % visibleZoneIds)

        base.cr.sendSetZoneMsg(self.levelZone, visibleZoneIds)
Ejemplo n.º 6
0
        def checkSpecIntegrity(self):
            # make sure there are no duplicate entIds
            entIds = self.getGlobalEntIds()
            assert uniqueElements(entIds)
            entIds = list2dict(entIds)
            for i in range(self.getNumScenarios()):
                for id in self.getScenarioEntIds(i):
                    assert id not in entIds
                    entIds[id] = None

            if self.entTypeReg is not None:
                # check each spec
                allEntIds = entIds
                for entId in allEntIds:
                    spec = self.getEntitySpec(entId)

                    assert 'type' in spec
                    entType = spec['type']
                    typeDesc = self.entTypeReg.getTypeDesc(entType)
                    attribNames = typeDesc.getAttribNames()
                    attribDescs = typeDesc.getAttribDescDict()

                    # are there any unknown attribs in the spec?
                    for attrib in list(spec.keys()):
                        if attrib not in attribNames:
                            LevelSpec.notify.warning(
                                "entId %s (%s): unknown attrib '%s', omitting"
                                % (entId, spec['type'], attrib))
                            del spec[attrib]

                    # does the spec have all of its attributes?
                    for attribName in attribNames:
                        if attribName not in spec:
                            LevelSpec.notify.warning(
                                "entId %s (%s): missing attrib '%s'" %
                                (entId, spec['type'], attribName))
Ejemplo n.º 7
0
EntIdRange = 10000
# Once a range has been assigned to a user, please don't change it.
username2entIdBase = {
    'darren': 1 * EntIdRange,
    'samir': 2 * EntIdRange,
    'skyler': 3 * EntIdRange,
    'joe': 4 * EntIdRange,
    'DrEvil': 5 * EntIdRange,
    'asad': 6 * EntIdRange,
    'drose': 7 * EntIdRange,
    'pappy': 8 * EntIdRange,
    'patricia': 9 * EntIdRange,
    'jloehrle': 10 * EntIdRange,
    'rurbino': 11 * EntIdRange,
}
assert uniqueElements(username2entIdBase.values())

usernameConfigVar = 'level-edit-username'
undefinedUsername = '******'
editUsername = config.GetString(usernameConfigVar, undefinedUsername)


# call this to make sure things have been set up correctly
def checkNotReadyToEdit():
    # returns error string if not ready, None if ready
    if editUsername == undefinedUsername:
        return "you must config '%s'; see %s.py" % (usernameConfigVar,
                                                    __name__)
    # Feel free to add your name to the table if it's not in there
    if editUsername not in username2entIdBase:
        return "unknown editor username '%s'; see %s.py" % (editUsername,