/** * @param Entity $entity * * @throws LevelException */ public function addEntity(Entity $entity) { if ($entity->getLevel() !== $this) { throw new LevelException("Invalid Entity level"); } if ($entity instanceof Player) { $this->players[$entity->getId()] = $entity; } $this->entities[$entity->getId()] = $entity; }