示例#1
0
 def load(self, **_):
     self._clear()
     save_slot_data_msg = services.get_persistence_service(
     ).get_save_slot_proto_buff()
     if not save_slot_data_msg.gameplay_data.HasField(
             'object_lost_and_found'):
         return
     object_lost_and_found = save_slot_data_msg.gameplay_data.object_lost_and_found
     for object_locators in object_lost_and_found.locators:
         object_data = FileSerialization_pb2.ObjectData()
         object_data.ParseFromString(object_locators.object)
         if object_data is None:
             logger.error(
                 'Trying to load a locator with no object data. \n                zone_id: {}, open_street_id: {}, sim_id: {}, household_id: {}, \n                time_before_lost: {}, time_stamp: {}',
                 object_locators.zone_id, object_locators.open_street_id,
                 object_locators.sim_id, object_locators.household_id,
                 object_locators.time_before_lost,
                 object_locators.time_stamp.absolute_ticks())
         else:
             locator = self._raw_add_object_data(
                 object_locators.zone_id, object_locators.open_street_id,
                 object_data.object_id, object_locators.sim_id,
                 object_locators.household_id,
                 object_locators.time_before_lost,
                 DateAndTime(object_locators.time_stamp))
             locator.object_data = object_data
     for clone in object_lost_and_found.clones_to_delete:
         self.add_clone_id(clone.zone_id, clone.open_street_id,
                           clone.object_id)
 def _create_object_from_raw_inv_data(self, object_id, raw_inv_data):
     object_data = FileSerialization_pb2.ObjectData()
     object_data.ParseFromString(raw_inv_data)
     return self._create_object_from_object_data(object_id, object_data)
示例#3
0
def get_object_in_household_inventory(object_id, household_id):
    def make_object(object_data):
        def_id = get_vetted_object_defn_guid(object_id, object_data.guid)
        definition = services.definition_manager().get(
            def_id, obj_state=object_data.state_index)

        class HouseholdInventoryObject(definition.cls):
            @property
            def persistence_group(self):
                return objects.persistence_groups.PersistenceGroups.NONE

            @persistence_group.setter
            def persistence_group(self, value):
                pass

            def save_object(
                    self,
                    object_list,
                    *args,
                    item_location=objects.object_enums.ItemLocation.ON_LOT,
                    container_id=0,
                    **kwargs):
                pass

            @property
            def is_valid_posture_graph_object(self):
                return False

        try:
            obj = objects.system.create_object(
                object_data.guid,
                cls_override=HouseholdInventoryObject,
                obj_id=object_id,
                obj_state=object_data.state_index,
                loc_type=ItemLocation.HOUSEHOLD_INVENTORY,
                content_source=ContentSource.HOUSEHOLD_INVENTORY_PROXY)
            obj.append_tags(objects.object_manager.ObjectManager.
                            HOUSEHOLD_INVENTORY_OBJECT_TAGS)
            obj.attributes = object_data.SerializeToString()
            obj.set_household_owner_id(household_id)
        except ObjectIDError as exc:
            obj = services.object_manager().get(object_id)
            if obj is None:
                logger.error(
                    'Failed to create or find proxy object for Household Inventory object {}\n{}',
                    object_id, exc)
        return obj

    if is_household_inventory_available(household_id):
        object_data_raw = _buildbuy.get_object_data_in_household_inventory(
            object_id, household_id)
        if object_data_raw is None:
            return
        object_data = FileSerialization_pb2.ObjectData()
        object_data.ParseFromString(object_data_raw)
        if object_data is not None:
            return make_object(object_data)
    else:
        household_msg = services.get_persistence_service(
        ).get_household_proto_buff(household_id)
        if household_msg is not None:
            if household_msg.inventory:
                for object_data in household_msg.inventory:
                    if object_data.object_id == object_id:
                        return make_object(object_data)