def addActor(self, actor): """Add an actor to the world""" # self.log.debug('Adding %s to world %s' % (actor.getNiceName(), self.name)) # # Make sure the actor isn't already here if self.hasActor(actor): raise DuplicateActor('The actor %s is already in the world' % actor.getNiceName()) # # Try to put the actor in the right zone for z in self.zones: if z.wouldContain(actor): z.addActor(actor) break else: # The actor is not in any zones, store for later self.unzoned_actors.add(actor) # # Tell the actor about it actor.addedToWorld(self) # self._actors_need_resorting = True # return actor
def addActor(self, actor): """Add an actor to the world""" # self.log.debug('Adding %s to world %s' % (actor.getNiceName(), self.name)) # # Make sure the actor isn't already here if self.hasActor(actor): raise DuplicateActor('The actor %s is already in the world' % actor.getNiceName()) # # Try to put the actor in the right zone for z in self.zones: if z.isOverlapping(actor): z.addActor(actor) break else: # The actor is not in any zones, store for later self.unzoned_actors.add(actor) # # Tell the actor about it actor.addedToWorld(self) # self._actors_need_resorting = True
def removeActor(self, actor): """Remove the actor from the world""" self.log.debug('Removing "%s" actor (%s)' % (actor.tag, actor.getNiceName())) # # Tell the actor about it actor.removedFromWorld(self) # self._actors_need_resorting = True # # Try to remove from zones for z in self.zones: if z.hasActor(actor): z.removeActor(actor) return # # We didn't find it in the zone - maybe in the unzoned if actor in self.unzoned_actors: self.unzoned_actors.remove(actor) else: raise UnknownActor('The actor %s was not found in the world' % actor)
def removeActor(self, actor): """Remove the actor from the world""" self.log.debug('Removing "%s" actor (%s)' % (actor.tag, actor.getNiceName())) # self._actors_need_resorting = True # # Try to remove from zones for z in self.zones: if z.hasActor(actor): z.removeActor(actor) break else: # # We didn't find it in the zone - maybe in the unzoned if actor in self.unzoned_actors: self.unzoned_actors.remove(actor) else: raise UnknownActor('The actor %s was not found in the world' % actor) # # Tell the actor about it actor.removedFromWorld(self)