def notifyHarvesting(self): if self._harvesting: eventType = Event.ENTITY_HARVEST_START else: eventType = Event.ENTITY_HARVEST_STOP e = Event(self._entity._world._time, eventType) e.entity = self._entity e.target = self.target self._entity._em.handleEvent(e)
def execute(self): e = Event(self.entity._world._time, Event.ENTITY_RESEARCH_DUMPED) e.entity = self.entity e.amount = self.rhC.load self.entity._em.handleEvent(e) self.rhC.load = 0 self.rhC.base = None
def notifyVelocityChanged(self, oldV): """Does not check whether velocity has in fact changed.""" if self._v == Vector2(0, 0): eventType = Event.ENTITY_STOPPED else: eventType = Event.ENTITY_MOVING e = Event(self._entity._world._time, eventType) e.entity = self._entity e.oldVelocity = oldV e.newVelocity = self._v self._entity._em.handleEvent(e)
def removeEntity(self, entity): self._entities.remove(entity) for _, system in self._systems.items(): if system.applicable(entity): system.removeEntity(entity) event = Event(self._time, Event.ENTITY_REMOVED) event.entity = entity entity._em.handleEvent(event) self._em.handleEvent(event)
def notifyDepleted(self): e = Event(self._entity._world._time, Event.RESEARCH_DEPLETED) e.entity = self._entity self._entity._em.handleEvent(e)
def notifyPositionChanged(self, oldP): e = Event(self._entity._world._time, Event.ENTITY_MOVED) e.entity = self._entity e.oldPosition = oldP e.newPosition = self._p self._entity._em.handleEvent(e)
def notifyDeath(self): print(str(self._entity) + " died!") e = Event(self._entity._world._time, Event.ENTITY_DIED) e.entity = self._entity self._entity._em.handleEvent(e)
def notifyFacingChanged(self): e = Event(self._entity._world._time, Event.ENTITY_FACING_UPDATED) e.entity = self._entity e.facingLeft = self._facingLeft self._entity._em.handleEvent(e)
def throwEntityCreatedEvent(self, entity): """Signals that entity has been created.""" event = Event(self._time, Event.ENTITY_ADDED) event.entity = entity self._em.handleEvent(event)