Ejemplo n.º 1
0
 def _on_detach(self):
     del self._garbage_pulse
     for mobile_list in self.mobiles.values():
         for mobile in mobile_list:
             if mobile.env != self:
                 mobile.change_env(self)
     call_each(self.contents, 'detach')
Ejemplo n.º 2
0
 def entity_enters(self, entity, enter_action, entry_msg=None):
     self.attach()
     self.receive_broadcast(entry_msg)
     entity.env = self
     self.denizens.append(entity)
     entity.pulse_stamp = ev.current_pulse
     self.current_actions.add(entity)
     call_each(self.contents, "entity_enter_env", entity, enter_action)
Ejemplo n.º 3
0
 def _on_attach(self):
     self.denizens = []
     self.inven = []
     self.mobiles = defaultdict(set)
     self._garbage_pulse = ev.register_p(self.check_garbage, seconds=room_reset_time + 1)
     self.current_actions = ActionCache()
     self.current_actions.add(self.instance_providers)
     self.current_actions.add(self.features)
     self.current_actions.add(self.exits)
     self.reset()
     call_each(self.contents, 'attach')
Ejemplo n.º 4
0
 def examine(self, source):
     source.display_line(self.name, 'room_title')
     source.display_line('HRT', 'room')
     source.display_line(self.long_desc(), 'room')
     source.display_line('HRB', 'room')
     if self.exits:
         for my_exit in self.exits:
             my_exit.examine(source)
     else:
         source.display_line("No obvious exits", 'exit')
     call_each([x for x in self.contents if x != source], 'glance', source)
Ejemplo n.º 5
0
 def receive_broadcast(self, broadcast, **_):
     if not broadcast:
         return
     if getattr(broadcast, 'target', None) == self:
         broadcast.target = None
     call_each(self.contents, "receive_broadcast", broadcast)
Ejemplo n.º 6
0
 def entity_leaves(self, entity, exit_action, exit_msg=None):
     self.receive_broadcast(exit_msg)
     self.denizens.remove(entity)
     self.current_actions.remove(entity)
     call_each(self.contents, "entity_leave_env", entity, exit_action)