11from typing import Optional , cast
22
3- from rcrs_core .connection .URN import Entity as EntityURN
4- from rcrs_core .entities .civilian import Civilian
5- from rcrs_core .entities .entity import Entity
6- from rcrs_core .entities .human import Human
7- from rcrs_core .worldmodel .entityID import EntityID
3+ from rcrscore .entities import Civilian , Entity , EntityID , Human
4+ from rcrscore .urn import EntityURN
85
96from adf_core_python .core .agent .develop .develop_data import DevelopData
107from adf_core_python .core .agent .info .agent_info import AgentInfo
@@ -46,7 +43,7 @@ def __init__(
4643 def calculate (self ) -> HumanDetector :
4744 transport_human : Optional [Human ] = self ._agent_info .some_one_on_board ()
4845 if transport_human is not None :
49- self ._result = transport_human .get_id ()
46+ self ._result = transport_human .get_entity_id ()
5047 return self
5148
5249 if self ._result is not None :
@@ -72,44 +69,45 @@ def _select_target(self) -> Optional[EntityID]:
7269 cluster_valid_human_entities : list [Entity ] = [
7370 entity
7471 for entity in cluster_entities
75- if self ._is_valid_human (entity .get_id ()) and isinstance (entity , Civilian )
72+ if self ._is_valid_human (entity .get_entity_id ())
73+ and isinstance (entity , Civilian )
7674 ]
7775 if len (cluster_valid_human_entities ) != 0 :
7876 nearest_human_entity = cluster_valid_human_entities [0 ]
7977 nearest_distance = self ._world_info .get_distance (
8078 self ._agent_info .get_entity_id (),
81- nearest_human_entity .get_id (),
79+ nearest_human_entity .get_entity_id (),
8280 )
8381 for entity in cluster_valid_human_entities :
8482 distance = self ._world_info .get_distance (
8583 self ._agent_info .get_entity_id (),
86- entity .get_id (),
84+ entity .get_entity_id (),
8785 )
8886 if distance < nearest_distance :
8987 nearest_distance = distance
9088 nearest_human_entity = entity
91- return nearest_human_entity .get_id ()
89+ return nearest_human_entity .get_entity_id ()
9290
9391 world_valid_human_entities : list [Entity ] = [
9492 entity
9593 for entity in self ._world_info .get_entities_of_types ([Civilian ])
96- if self ._is_valid_human (entity .get_id ())
94+ if self ._is_valid_human (entity .get_entity_id ())
9795 ]
9896 if len (world_valid_human_entities ) != 0 :
9997 nearest_human_entity = world_valid_human_entities [0 ]
10098 nearest_distance = self ._world_info .get_distance (
10199 self ._agent_info .get_entity_id (),
102- nearest_human_entity .get_id (),
100+ nearest_human_entity .get_entity_id (),
103101 )
104102 for entity in world_valid_human_entities :
105103 distance = self ._world_info .get_distance (
106104 self ._agent_info .get_entity_id (),
107- entity .get_id (),
105+ entity .get_entity_id (),
108106 )
109107 if distance < nearest_distance :
110108 nearest_distance = distance
111109 nearest_human_entity = entity
112- return nearest_human_entity .get_id ()
110+ return nearest_human_entity .get_entity_id ()
113111
114112 return None
115113
@@ -126,6 +124,8 @@ def _is_valid_human(self, target_entity_id: EntityID) -> bool:
126124 if buriedness is None :
127125 return False
128126 myself = self ._agent_info .get_myself ()
127+ if myself is None :
128+ return False
129129 if myself .get_urn () == EntityURN .FIRE_BRIGADE and buriedness == 0 :
130130 return False
131131 if myself .get_urn () == EntityURN .AMBULANCE_TEAM and buriedness > 0 :
0 commit comments