Пример #1
0
 def copy(self):
     new_entity_id_list_prop = EntityIDListProperty(self.urn)
     new_entity_id_list_prop.value = []
     for entity_id in self.value:
         new_entity_id_list_prop.value.append(
             wm.EntityID(entity_id.get_value()))
     return new_entity_id_list_prop
Пример #2
0
 def read(self, input_stream):
     self.ids = []
     count = et.read_int32(input_stream)
     for i in range(count):
         eid = wm.EntityID(et.read_int32(input_stream))
         self.ids.append(eid)
     return
Пример #3
0
 def copy(self):
     new_edge_list_prop = EdgeListProperty(self.urn)
     new_edge_list_prop.value = []
     for edge in self.value:
         new_edge_list_prop.append(wm.Edge(edge.get_start_x(), edge.get_start_y(),
                                           edge.get_end_x(), edge.get_end_y(),
                                           wm.EntityID(edge.get_neighbor().get_value())))
     return new_edge_list_prop
Пример #4
0
def read_entity(input_stream):
    urn = read_str(input_stream)
    if urn == "" or urn is None:
        return None
    eid = wm.EntityID(read_int32(input_stream))
    entity_size = read_int32(input_stream)
    entity = entity_factory.create_entity(eid, urn)
    entity.read(input_stream)
    return entity
Пример #5
0
    def read(self, input_stream):
        self.changed.clear()
        self.deleted.clear()
        self.entity_urns.clear()

        entity_count = et.read_int32(input_stream)
        for i in range(entity_count):
            entity_id = wm.EntityID(et.read_int32(input_stream))
            entity_urn = et.read_str(input_stream)
            property_count = et.read_int32(input_stream)
            for j in range(property_count):
                property = et.read_property(input_stream)
                if property is not None:
                    self.add_change(entity_id, entity_urn, property)

        deleted_count = et.read_int32(input_stream)
        for i in range(deleted_count):
            entity_id = wm.EntityID(et.read_int32(input_stream))
            self.entity_deleted(entity_id)
Пример #6
0
 def read(self, input_stream):
     count = et.read_int32(input_stream)
     self.value = []
     for i in range(count):
         start_x = et.read_int32(input_stream)
         start_y = et.read_int32(input_stream)
         end_x = et.read_int32(input_stream)
         end_y = et.read_int32(input_stream)
         n_id = et.read_int32(input_stream)
         neighbor = None
         if n_id != 0:
             neighbor = wm.EntityID(n_id)
         self.value.append(wm.Edge(start_x, start_y, end_x, end_y, neighbor))
Пример #7
0
 def read(self, input_stream):
     self.value = wm.EntityID(et.read_int32(input_stream))
Пример #8
0
 def read(self, input_stream):
     self.value = []
     count = et.read_int32(input_stream)
     for i in range(count):
         e_id = wm.EntityID(et.read_int32(input_stream))
         self.value.append(e_id)
Пример #9
0
 def copy(self):
     new_entity_id_prop = EntityIDProperty(self.urn)
     new_entity_id_prop.value = wm.EntityID(self.value.get_value())
     return new_entity_id_prop
Пример #10
0

class AmbulanceTeamEntity(Human):
    urn = urn.ambulance_team_urn

    def __init__(self, entity_id):
        Human.__init__(self, entity_id)


class PoliceForceEntity(Human):
    urn = urn.police_force_urn

    def __init__(self, entity_id):
        Human.__init__(self, entity_id)


if __name__ == '__main__':
    id1 = wm.EntityID(10)
    id2 = wm.EntityID(20)
    id3 = wm.EntityID(10)
    id4 = wm.EntityID(10)
    my_dict = {}
    my_dict[id1] = id1
    my_dict[id2] = id2

    print('id1:' + str(id1) + ' id2:' + str(id2) + ' id3:' + str(id3))
    print('id3 from dict:' + str(my_dict[id4]))

    for my_key in my_dict:
        print(str(type(my_key.get_value())))