33from rcrs_core .entities .area import Area
44from rcrs_core .entities .blockade import Blockade
55from rcrs_core .entities .entity import Entity
6+ from rcrs_core .entities .human import Human
67from rcrs_core .worldmodel .changeSet import ChangeSet
78from rcrs_core .worldmodel .entityID import EntityID
89from rcrs_core .worldmodel .worldmodel import WorldModel
@@ -145,6 +146,36 @@ def get_distance(self, entity_id1: EntityID, entity_id2: EntityID) -> float:
145146
146147 return distance
147148
149+ def get_entity_position (self , entity_id : EntityID ) -> EntityID :
150+ """
151+ Get the entity position
152+
153+ Parameters
154+ ----------
155+ entity_id : EntityID
156+ Entity ID
157+
158+ Returns
159+ -------
160+ EntityID
161+ Entity position
162+
163+ Raises
164+ ------
165+ ValueError
166+ If the entity is invalid
167+ """
168+ entity = self .get_entity (entity_id )
169+ if entity is None :
170+ raise ValueError (f"Invalid entity: entity_id={ entity_id } , entity={ entity } " )
171+ if isinstance (entity , Area ):
172+ return entity .get_id ()
173+ if isinstance (entity , Human ):
174+ return entity .get_position ()
175+ if isinstance (entity , Blockade ):
176+ return entity .get_position ()
177+ raise ValueError (f"Invalid entity type: entity_id={ entity_id } , entity={ entity } " )
178+
148179 def get_change_set (self ) -> ChangeSet :
149180 """
150181 Get the change set
@@ -156,7 +187,7 @@ def get_change_set(self) -> ChangeSet:
156187 """
157188 return self ._change_set
158189
159- def get_bloackades (self , area : Area ) -> set [Blockade ]:
190+ def get_blockades (self , area : Area ) -> set [Blockade ]:
160191 """
161192 Get the blockades in the area
162193
@@ -165,12 +196,12 @@ def get_bloackades(self, area: Area) -> set[Blockade]:
165196 ChangeSet
166197 Blockade
167198 """
168- bloakcades = set ()
199+ blockades = set ()
169200 for blockade_entity_id in area .get_blockades ():
170- bloackde_entity = self .get_entity (blockade_entity_id )
171- if isinstance (bloackde_entity , Blockade ):
172- bloakcades .add (cast (Blockade , bloackde_entity ))
173- return bloakcades
201+ blockades_entity = self .get_entity (blockade_entity_id )
202+ if isinstance (blockades_entity , Blockade ):
203+ blockades .add (cast (Blockade , blockades_entity ))
204+ return blockades
174205
175206 def add_entity (self , entity : Entity ) -> None :
176207 """
0 commit comments