|
5 | 5 | from rcrscore.entities.blockade import Blockade |
6 | 6 | from rcrscore.entities.entity import Entity |
7 | 7 | from rcrscore.entities.human import Human |
| 8 | +from rcrscore.urn import EntityURN |
8 | 9 | from rcrscore.worldmodel import ChangeSet, WorldModel |
9 | 10 |
|
10 | 11 |
|
@@ -54,6 +55,28 @@ def get_entity(self, entity_id: EntityID) -> Optional[Entity]: |
54 | 55 | """ |
55 | 56 | return self._world_model.get_entity(entity_id) |
56 | 57 |
|
| 58 | + def get_entities(self) -> list[Entity]: |
| 59 | + """ |
| 60 | + Get all entities |
| 61 | +
|
| 62 | + Returns |
| 63 | + ------- |
| 64 | + list[Entity] |
| 65 | + Entities |
| 66 | + """ |
| 67 | + return self._world_model.get_entities() |
| 68 | + |
| 69 | + def get_entity_ids(self) -> list[EntityID]: |
| 70 | + """ |
| 71 | + Get all entity IDs |
| 72 | +
|
| 73 | + Returns |
| 74 | + ------- |
| 75 | + list[EntityID] |
| 76 | + Entity IDs |
| 77 | + """ |
| 78 | + return [entity.get_entity_id() for entity in self._world_model.get_entities()] |
| 79 | + |
57 | 80 | def get_entity_ids_of_types(self, entity_types: list[type[Entity]]) -> list[EntityID]: |
58 | 81 | """ |
59 | 82 | Get the entity IDs of the specified types |
@@ -96,6 +119,45 @@ def get_entities_of_types(self, entity_types: list[type[Entity]]) -> list[Entity |
96 | 119 |
|
97 | 120 | return entities |
98 | 121 |
|
| 122 | + def get_entity_ids_of_urns(self, urns: list[EntityURN]) -> list[EntityID]: |
| 123 | + """ |
| 124 | + Get the entity IDs of the specified URNs |
| 125 | +
|
| 126 | + Parameters |
| 127 | + ---------- |
| 128 | + urns : list[EntityURN] |
| 129 | + List of entity URNs |
| 130 | +
|
| 131 | + Returns |
| 132 | + ------- |
| 133 | + list[EntityID] |
| 134 | + Entity IDs |
| 135 | + """ |
| 136 | + entity_ids: list[EntityID] = [] |
| 137 | + for entity in self._world_model.get_entities(): |
| 138 | + if entity.get_urn() in urns: |
| 139 | + entity_ids.append(entity.get_entity_id()) |
| 140 | + |
| 141 | + return entity_ids |
| 142 | + |
| 143 | + def get_entities_of_urns(self, urns: list[EntityURN]) -> list[Entity]: |
| 144 | + """ |
| 145 | + Get the entities of the specified URNs |
| 146 | + Parameters |
| 147 | + ---------- |
| 148 | + urns : list[EntityURN] |
| 149 | + List of entity URNs |
| 150 | + Returns |
| 151 | + ------- |
| 152 | + list[Entity] |
| 153 | + Entities |
| 154 | + """ |
| 155 | + entities: list[Entity] = [] |
| 156 | + for entity in self._world_model.get_entities(): |
| 157 | + if entity.get_urn() in urns: |
| 158 | + entities.append(entity) |
| 159 | + return entities |
| 160 | + |
99 | 161 | def get_distance(self, entity_id1: EntityID, entity_id2: EntityID) -> float: |
100 | 162 | """ |
101 | 163 | Get the distance between two entities |
|
0 commit comments