def c_api_buildbuy_get_save_object_data(zone_id: int, obj_id: int): obj = services.get_zone(zone_id).find_object(obj_id) if obj is None: return object_list = file_serialization.ObjectList() save_data = obj.save_object(object_list.objects, from_bb=True) return save_data
def household_net_worth(self, billable=False): household_inventory_value = build_buy.get_household_inventory_value( self.id) if household_inventory_value is None: household_inventory_value = 0 sim_inventories_value = 0 for sim_info in self.sim_info_gen(): sim_inventories_value += sim_info.inventory_value() final_household_value = self._cached_billable_household_value + household_inventory_value + sim_inventories_value home_zone = services.get_zone(self.home_zone_id) if home_zone is None and billable: return final_household_value if not billable: household_funds = self._funds.money if home_zone is None: return final_household_value + household_funds billable_value = 0 billable_value += home_zone.lot.unfurnished_lot_value for obj in services.object_manager().values(): if obj.get_household_owner_id() != self.id: pass billable_value += obj.current_value obj_inventory = obj.inventory_component while obj_inventory is not None: billable_value += obj_inventory.inventory_value self._cached_billable_household_value = billable_value final_household_value = self._cached_billable_household_value + household_inventory_value + sim_inventories_value if billable: return final_household_value return final_household_value + household_funds
def _place_object (self, created_object, resolver = None, subject = None, placement_override_func = None): subject_to_apply = subject if subject is not None else resolver.get_participant(ParticipantType.Actor) created_object.update_ownership(subject_to_apply, make_sim_owner = self._make_sim_owner) if self._store_sim_info_on_reward is not None: stored_sim_source = resolver.get_participant(self._store_sim_info_on_reward.participant) if self._store_sim_info_on_reward.transfer_from_stored_sim_info: sim_id = stored_sim_source.get_stored_sim_id() else: sim_id = stored_sim_source.id if sim_id is not None: created_object.add_dynamic_component(types.STORED_SIM_INFO_COMPONENT, sim_id = sim_id) if self._store_sim_info_on_reward.transfer_from_stored_sim_info: stored_sim_source.remove_component(types.STORED_SIM_INFO_COMPONENT) created_object.update_object_tooltip() if placement_override_func is not None: placement_override_func(subject_to_apply, created_object) return if self._place_in_mailbox: sim_household = subject_to_apply.household if sim_household is not None: zone = services.get_zone(sim_household.home_zone_id) if zone is not None: lot_hidden_inventory = zone.lot.get_hidden_inventory() if lot_hidden_inventory is not None and lot_hidden_inventory.player_try_add_object(created_object): return if not self._force_family_inventory: instanced_sim = subject_to_apply.get_sim_instance(allow_hidden_flags = ALL_HIDDEN_REASONS) if instanced_sim is not None and instanced_sim.inventory_component.can_add(created_object) and instanced_sim.inventory_component.player_try_add_object(created_object): return if not build_buy.move_object_to_household_inventory(created_object): logger.error('Failed to add object reward {} to household inventory.', created_object, owner = 'rmccord')
def c_api_buildbuy_get_save_object_data(zone_id, obj_id): with sims4.zone_utils.global_zone_lock(zone_id): obj = services.get_zone(zone_id).find_object(obj_id) if obj is None: return object_list = file_serialization.ObjectList() save_data = obj.save_object(object_list.objects) return save_data
def c_api_entitlement_unlocked(zone_id, account_id, guid): raise RuntimeError( '[bhill] This function is believed to be dead code as of 8/6/2014. If you see this exception, remove it because the code is not dead.' ) handlers = services.get_zone(zone_id).entitlement_unlock_handlers call_list = handlers.get(guid) if call_list and call_list(account_id, guid): handlers.pop(guid)
def _place_object_in_mailbox(self, subject_to_apply, created_object): sim_household = subject_to_apply.household if sim_household is not None: zone = services.get_zone(sim_household.home_zone_id) if zone is not None: mailbox_inventory = zone.lot.get_mailbox_inventory( sim_household.id) if mailbox_inventory is not None: mailbox_inventory.player_try_add_object(created_object)
def send_data_to_client(self): zone = services.get_zone(self._zone_id, allow_uninstantiated_zones=True) if zone is None: logger.error('Trying to send the business data to client but the business manager {} has an invalid zone id.', self) return business_data_msg = Business_pb2.SetBusinessData() self.construct_business_message(business_data_msg) business_data_op = GenericProtocolBufferOp(DistributorOps_pb2.Operation.SET_BUSINESS_DATA, business_data_msg) Distributor.instance().add_op_with_no_owner(business_data_op)
def c_api_buildbuy_session_end(zone_id, account_id, pending_navmesh_rebuild: bool = False): with sims4.zone_utils.global_zone_lock(zone_id): zone = services.get_zone(zone_id) fence_id = zone.get_current_fence_id_and_increment() routing.flush_planner(False) routing.add_fence(fence_id) indexed_manager.IndexedManager.remove_gc_collect_disable_reason( BUILD_BUY_OBJECT_LEAK_DISABLED) return True
def c_api_buildbuy_session_end(zone_id, account_id, pending_navmesh_rebuild: bool=False): with sims4.zone_utils.global_zone_lock(zone_id): zone = services.get_zone(zone_id) fence_id = zone.get_current_fence_id_and_increment() routing.flush_planner(False) routing.add_fence(fence_id) indexed_manager.IndexedManager.remove_gc_collect_disable_reason( BUILD_BUY_OBJECT_LEAK_DISABLED) return True
def get_participants(cls, inst, participant_type, *args, **kwargs): if inst: sim_info = inst.sim if participant_type is ParticipantType.Actor: return (sim_info, ) else: if participant_type is ParticipantType.Lot: (services.get_zone(sim_info.zone_id, allow_uninstantiated_zones=True), ) if participant_type is ParticipantType.PickedStatistic: return (inst.picked_skill, )
def c_api_set_object_location_ex(zone_id, obj_id, routing_surface, transform, parent_id, parent_type_info, slot_hash): obj = services.get_zone(zone_id).find_object(obj_id) if obj is None: return parent = services.object_manager().get(parent_id) if parent_id else None obj.parent_type_info = parent_type_info obj.set_parent(parent, transform=transform, slot_hash=slot_hash, routing_surface=routing_surface)
def c_api_buildbuy_session_end(zone_id: int, account_id: int, pending_navmesh_rebuild: bool = False): zone = services.get_zone(zone_id) fence_id = zone.get_current_fence_id_and_increment() routing.flush_planner(False) routing.add_fence(fence_id) object_leak_tracker = services.get_object_leak_tracker() if object_leak_tracker is not None: object_leak_tracker.remove_disable_reason( BUILD_BUY_OBJECT_LEAK_DISABLED) return True
def get_dump_gen(console_output): GsiSchema = sims4.gsi.schema.GsiSchema for zone_id in services._zone_manager: zone = services.get_zone(zone_id) if zone is None or not zone.is_instantiated: logger.warn( "[cgast] Trying to dump GSI Data for zone {} but it's not instantiated.", zone_id) sim_info_manager = services.sim_info_manager(zone_id=zone_id) sim_ids = set() for sim_info in list(sim_info_manager.objects): sim_ids.add(sim_info.sim_id) for (entry, dispatch_data) in sims4.gsi.dispatcher.dispatch_table.items(): schema = dispatch_data[1] if schema is None: pass if isinstance(schema, GsiSchema): schema = schema.output if 'is_global_cheat' in schema and schema['is_global_cheat']: pass if entry == 'command': pass entry_data = [] if 'sim_specific' in schema and schema['sim_specific']: for sim_id in sim_ids: new_entry = _build_dump_entry(entry, schema, { 'sim_id': sim_id, 'zone_id': zone_id }) if new_entry is not None: entry_data.append(new_entry) else: while console_output is not None: try: console_output( 'Failed to collect data for {} on Sim ID {}' .format(entry, sim_id)) except: pass else: new_entry = _build_dump_entry(entry, schema, {'zone_id': zone_id}) if new_entry is not None: entry_data.append(new_entry) elif console_output is not None: try: console_output( 'Failed to collect data for {}'.format(entry)) except: pass yield (entry, schema, entry_data)
def get_zone(zone_id: int, allow_unloaded_zones: bool = False) -> Zone: """get_zone(zone_id, allow_unloaded_zones=False) Retrieve the Zone matching an identifier. :param zone_id: The decimal identifier of a Zone. :type zone_id: int :param allow_unloaded_zones: If set to True, Zones that are currently not loaded (or have not been loaded) will be considered. If set to False, Zones that have yet to be loaded will not be considered. Default is False. :type allow_unloaded_zones: bool, optional :return: The Zone with the specified zone id or None if it was not found. :rtype: Zone """ return services.get_zone( zone_id, allow_uninstantiated_zones=allow_unloaded_zones)
def increment_data(self, data_object, guid, objective_test, resolver): lot_id = services.get_zone(resolver.sim_info.zone_id).lot.lot_id if lot_id is not None: data_object.add_objective_id(guid, lot_id) num_of_iterations = data_object.get_objective_count(guid) if num_of_iterations < self.unique_locations_required_to_pass: return results.TestResultNumeric( False, 'Objective: not enough matching location iterations.', current_value=num_of_iterations, goal_value=self.unique_locations_required_to_pass, is_money=False) data_object.set_objective_complete(guid) return results.TestResult.TRUE
def get_participants(cls, inst, participant_type, sim_info=DEFAULT, target=DEFAULT) -> set: inst_or_cls = inst if inst is not None else cls sim_info = inst.sim_info if sim_info is DEFAULT else sim_info target = inst.target if target is DEFAULT else target if sim_info is None: logger.error('Sim info is None when trying to get participants for Away Action {}.', inst_or_cls, owner='jjacobson') return () results = set() participant_type = int(participant_type) if participant_type & ParticipantType.Actor: results.add(sim_info) if participant_type & ParticipantType.Lot: zone = services.get_zone(sim_info.zone_id, allow_uninstantiated_zones=True) results.add(zone.lot) if participant_type & ParticipantType.TargetSim and target is not None: results.add(target) return tuple(results)
def _try_create_in_mailbox(self, sim_info): if sim_info.household is None: logger.error( 'Trying to add an item [{}] to a mailbox but the provided sim [{}] has no household', self._definition, sim_info, owner='trevor') return False zone = services.get_zone(sim_info.household.home_zone_id) if zone is None: logger.error( 'Trying to add an item [{}] to a mailbox but the provided sim [{}] has no home zone.', self._definition, sim_info, owner='trevor') return False lot_hidden_inventory = zone.lot.get_hidden_inventory() if lot_hidden_inventory is None: logger.error( "Trying to add an item [{}] to the lot's hidden inventory but the provided sim [{}] has no hidden inventory for their lot.", self._definition, sim_info, owner='trevor') return False obj = create_object(self._definition) if obj is None: logger.error( 'Trying to give an object reward to a Sim, {}, and the object created was None. Definition: {}', sim_info, self._definition) return False else: try: lot_hidden_inventory.system_add_object(obj) except: logger.error( 'Could not add object [{}] to the mailbox inventory on the home lot of the Sim [{}].', obj, sim_info, owner='trevor') obj.destroy( source=self, cause='Could not add object to the mailbox inventory') return False return True
def get_dump_gen(console_output): GsiSchema = sims4.gsi.schema.GsiSchema for zone_id in services._zone_manager: zone = services.get_zone(zone_id) if zone is None or not zone.is_instantiated: logger.warn("[cgast] Trying to dump GSI Data for zone {} but it's not instantiated.", zone_id) sim_info_manager = services.sim_info_manager(zone_id=zone_id) sim_ids = set() for sim_info in list(sim_info_manager.objects): sim_ids.add(sim_info.sim_id) for (entry, dispatch_data) in sims4.gsi.dispatcher.dispatch_table.items(): schema = dispatch_data[1] if schema is None: pass if isinstance(schema, GsiSchema): schema = schema.output if 'is_global_cheat' in schema and schema['is_global_cheat']: pass if entry == 'command': pass entry_data = [] if 'sim_specific' in schema and schema['sim_specific']: for sim_id in sim_ids: new_entry = _build_dump_entry(entry, schema, {'sim_id': sim_id, 'zone_id': zone_id}) if new_entry is not None: entry_data.append(new_entry) else: while console_output is not None: try: console_output('Failed to collect data for {} on Sim ID {}'.format(entry, sim_id)) except: pass else: new_entry = _build_dump_entry(entry, schema, {'zone_id': zone_id}) if new_entry is not None: entry_data.append(new_entry) elif console_output is not None: try: console_output('Failed to collect data for {}'.format(entry)) except: pass yield (entry, schema, entry_data)
def set_stolen_from_data(self, stolen_from_text=None, stolen_from_career_guid=None): self.reset_stolen_data() if stolen_from_text is not None: self._stolen_from_text = stolen_from_text elif stolen_from_career_guid is not None: self._stolen_from_career_guid = stolen_from_career_guid else: stolen_from_household_id = self.owner.household_owner_id if not stolen_from_household_id: stolen_from_household_id = services.current_zone( ).lot.owner_household_id household = services.household_manager().get( stolen_from_household_id) if household is not None: self._stolen_from_text = household.name self.stolen_from_household_id = stolen_from_household_id else: lot_name = services.get_zone( self.owner.zone_id).lot.get_lot_name() if lot_name is not None: self._stolen_from_text = lot_name self.update_hovertip()
def c_api_foundation_and_level_height_update(zone_id): with sims4.zone_utils.global_zone_lock(zone_id): services.get_zone( zone_id).foundation_and_level_height_update_callbacks()
def _do_behavior(self): sim = self.interaction.sim target = self.interaction.get_participant(self.participant) if target is None: return False should_fallback = False inventory_participant = sim if target.is_in_inventory(): inventory = target.get_inventory() inventory.try_remove_object_by_id(target.id) if self.inventory.inventory_type == SendToInventory.PARTICIPANT_INVENTORY: inventory_participant = self.interaction.get_participant( self.inventory.participant) if inventory_participant.is_sim: target.update_ownership(inventory_participant, make_sim_owner=self.give_sim_ownership) inventory_component = inventory_participant.inventory_component if not inventory_component.player_try_add_object(target): should_fallback = self.inventory.fallback_to_household else: for interaction in tuple(target.interaction_refs): if not interaction.running: if interaction.is_finishing: continue if inventory_participant.is_sim: if not interaction.allow_from_sim_inventory: interaction.cancel( FinishingType.OBJECT_CHANGED, cancel_reason_msg= 'Object moved to inventory') if not interaction.allow_from_object_inventory: interaction.cancel( FinishingType.OBJECT_CHANGED, cancel_reason_msg= 'Object moved to inventory') elif not interaction.allow_from_object_inventory: interaction.cancel( FinishingType.OBJECT_CHANGED, cancel_reason_msg='Object moved to inventory') if self.inventory.inventory_type == SendToInventory.MAILBOX_INVENTORY: if not inventory_participant.is_sim: logger.error( 'Trying to add an item [{}] to a mailbox but the participant [{}] is not a sim', target.definition, inventory_participant) return False target.set_household_owner_id(inventory_participant.household_id) zone = services.get_zone( inventory_participant.household.home_zone_id) if zone is None: logger.error( 'Trying to add an item [{}] to a mailbox but the provided sim [{}] has no home zone.', target.definition, inventory_participant) return False lot_hidden_inventory = zone.lot.get_hidden_inventory() if lot_hidden_inventory is None: logger.error( "Trying to add an item [{}] to the lot's hidden inventory but the provided sim [{}] has no hidden inventory for their lot.", target.definition, inventory_participant) return False lot_hidden_inventory.system_add_object(target) for interaction in tuple(target.interaction_refs): if not interaction.running: if interaction.is_finishing: continue interaction.cancel( FinishingType.OBJECT_CHANGED, cancel_reason_msg='Object moved to inventory') elif self.inventory.inventory_type == SendToInventory.HOUSEHOLD_INVENTORY or should_fallback: def on_reservation_change(*_, **__): if not target.in_use: target.unregister_on_use_list_changed( on_reservation_change) build_buy.move_object_to_household_inventory(target) if target is self.interaction.target: self.interaction.set_target(None) if inventory_participant is not None and inventory_participant.is_sim: target.set_household_owner_id( inventory_participant.household_id) target.remove_from_client(fade_duration=target.FADE_DURATION) if target.in_use: target.register_on_use_list_changed(on_reservation_change) else: build_buy.move_object_to_household_inventory(target)
def __call__(self, test_target=None): for target in test_target: if isinstance(target, sims.sim_info.SimInfo): target = target.get_sim_instance(allow_hidden_flags=ALL_HIDDEN_REASONS) if target is None: return TestResult(False, 'Testing Location an uninstantiated Sim.', tooltip=self.tooltip) if self.location_tests.is_outside is not None: is_outside = not target.is_hidden() and target.is_outside if self.location_tests.is_outside != is_outside: return TestResult(False, 'Object failed outside location test', tooltip=self.tooltip) if self.location_tests.is_natural_ground is not None and self.location_tests.is_natural_ground != target.is_on_natural_ground(): return TestResult(False, 'Object failed natural ground location test.', tooltip=self.tooltip) if self.location_tests.is_in_slot is not None: (slot_test_passed, slot_test_reason) = self.location_tests.is_in_slot.slot_test_type.run_slot_test(target) if not slot_test_passed: return TestResult(False, slot_test_reason, tooltip=self.tooltip) if self.location_tests.is_venue_type is not None: required_venue_tuning = self.location_tests.is_venue_type.venue_type venue_zone = services.get_zone(target.zone_id) if venue_zone is None: return TestResult(False, 'Object is not in an active zone', tooltip=self.tooltip) if self.location_tests.is_venue_type.use_source_venue: venue = venue_zone.venue_service.source_venue else: venue = venue_zone.venue_service.active_venue if self.location_tests.is_venue_type.negate: if required_venue_tuning is not None and isinstance(venue, required_venue_tuning): return TestResult(False, 'Object failed venue type test.', tooltip=self.tooltip) elif required_venue_tuning is None or not isinstance(venue, self.location_tests.is_venue_type.venue_type): return TestResult(False, 'Object failed venue type test.', tooltip=self.tooltip) if self.location_tests.is_on_active_lot is not None and not self.test_is_on_active_lot(self.location_tests.is_on_active_lot, target.position): return TestResult(False, 'Object failed on active lot test', tooltip=self.tooltip) if self.location_tests.is_fire_allowed is not None: fire_service = services.get_fire_service() allowed = fire_service.is_fire_allowed(target.transform, target.routing_surface) if self.location_tests.is_fire_allowed != allowed: return TestResult(False, 'Object failed is_fire_allowed test', tooltip=self.tooltip) if self.location_tests.in_common_area is not None: plex_service = services.get_plex_service() if self.location_tests.in_common_area != (plex_service.is_active_zone_a_plex() and plex_service.get_plex_zone_at_position(target.position, target.level) is None): return TestResult(False, 'Object failed in common area test.', tooltip=self.tooltip) if self.location_tests.is_on_level is not None: level = target.level if target.is_sim: if target.in_pool: level += 1 if not self.location_tests.is_on_level.compare(level): return TestResult(False, 'Object not on required level.', tooltip=self.tooltip) if self.location_tests.has_terrain_tag is not None: position = target.position is_terrain_tag_at_position = terrain.is_terrain_tag_at_position(position.x, position.z, self.location_tests.has_terrain_tag.terrain_tags, level=target.routing_surface.secondary_id, test_floor_tiles=self.location_tests.has_terrain_tag.test_floor_tiles) if self.location_tests.has_terrain_tag.negate: if is_terrain_tag_at_position: return TestResult(False, 'Object on required terrain tag, but negate is checked', tooltip=self.tooltip) elif not is_terrain_tag_at_position: return TestResult(False, 'Object not on required terrain tag.', tooltip=self.tooltip) if self.location_tests.valid_surface_types is not None: if not target.routing_surface is None: if not self.location_tests.valid_surface_types.test_item(target.routing_surface.type): return TestResult(False, 'Object routing surface is incorrect.', tooltip=self.tooltip) return TestResult(False, 'Object routing surface is incorrect.', tooltip=self.tooltip) return TestResult.TRUE
def generate_object_manager_data(*args, zone_id:int=None, filter=None, **kwargs): lockout_data = {} zone = services.get_zone(zone_id) for sim_info in list(zone.sim_info_manager.objects): sim = sim_info.get_sim_instance() while sim is not None: while True: for (obj, time) in sim.get_lockouts_gen(): lockouts = lockout_data.setdefault(obj, []) lockouts.append((sim, time)) all_object_data = [] for cur_obj in list(itertools.chain(zone.object_manager.objects, zone.prop_manager.objects, zone.inventory_manager.objects)): class_str = gsi_handlers.gsi_utils.format_object_name(cur_obj) on_active_lot = cur_obj.is_on_active_lot() if hasattr(cur_obj, 'is_on_active_lot') else False while (filter is None or filter == 'all_objects' or filter == 'prototype_objects') and (class_str == 'prototype' or filter == 'game_objects') and (class_str != 'prototype' or filter == 'on_active_lot') and on_active_lot: obj_loc = cur_obj.position model_name = _get_model_name(cur_obj) ret_dict = {'mgr': str(cur_obj.manager).replace('_manager', ''), 'objId': hex(cur_obj.id), 'classStr': class_str, 'modelStr': model_name, 'locX': round(obj_loc.x, 3), 'locY': round(obj_loc.y, 3), 'locZ': round(obj_loc.z, 3), 'on_active_lot': str(on_active_lot), 'current_value': cur_obj.current_value, 'is_interactable': 'x' if getattr(cur_obj, 'interactable', False) else '', 'footprint': str(cur_obj.footprint_polygon) if getattr(cur_obj, 'footprint_polygon', None) else ''} ret_dict['additional_data'] = [] parent = cur_obj.parent if parent is not None: ret_dict['parent'] = gsi_handlers.gsi_utils.format_object_name(parent) ret_dict['additional_data'].append({'dataId': 'Parent Id', 'dataValue': hex(parent.id)}) ret_dict['additional_data'].append({'dataId': 'Parent Slot', 'dataValue': cur_obj.parent_slot.slot_name_or_hash}) if cur_obj.state_component: value = cur_obj.get_most_severe_state_value() if value is not None: ret_dict['additional_data'].append({'dataId': 'Severity', 'dataValue': value.__name__}) ret_dict['isSurface'] = cur_obj.is_surface() if cur_obj in lockout_data: lockouts = ('{} ({})'.format(*lockout) for lockout in lockouts) ret_dict['lockouts'] = ', '.join(lockouts) ret_dict['states'] = [] if cur_obj.state_component: for (state_type, state_value) in cur_obj.state_component.items(): state_entry = {'state_type': str(state_type), 'state_value': str(state_value), 'state_severity': str(state_value.severity)} ret_dict['states'].append(state_entry) if cur_obj.in_use: users = cur_obj.get_users() ret_dict['inUseBy'] = gsi_handlers.gsi_utils.format_object_list_names(users) ret_dict['transient'] = cur_obj.transient ret_dict['additional_data'].append({'dataId': 'Category Tags', 'dataValue': gsi_handlers.gsi_utils.format_object_list_names(cur_obj.get_tags())}) name = 'None' house_id = cur_obj.get_household_owner_id() ret_dict['additional_data'].append({'dataId': 'Household Owner Id', 'dataValue': house_id}) if house_id is not None: household = zone.household_manager.get(house_id) if household is not None: name = household.name ret_dict['additional_data'].append({'dataId': 'Household Owner', 'dataValue': name}) sim_name = 'None' sim_id = cur_obj.get_sim_owner_id() if sim_id is not None: sim_info = zone.sim_info_manager.get(sim_id) sim_name = sim_info.full_name ret_dict['additional_data'].append({'dataId': 'Sim Owner', 'dataValue': sim_name}) if cur_obj.is_in_inventory() and cur_obj.inventoryitem_component._last_inventory_owner is not None: ret_dict['inventory_owner_id'] = hex(cur_obj.inventoryitem_component._last_inventory_owner.id) ret_dict['commodities'] = [] for commodity in list(cur_obj.get_all_stats_gen()): com_entry = {'commodity': type(commodity).__name__, 'value': commodity.get_value()} if commodity.continuous: com_entry['convergence_value'] = (commodity.convergence_value,) com_entry['decay_rate'] = (commodity.base_decay_rate,) com_entry['change_rate'] = (commodity.get_change_rate,) ret_dict['commodities'].append(com_entry) ret_dict['postures'] = [] for affordance in list(cur_obj.super_affordances()): while affordance.provided_posture_type is not None: posture_entry = {'interactionName': affordance.__name__, 'providedPosture': affordance.provided_posture_type.__name__} ret_dict['postures'].append(posture_entry) ret_dict['parts'] = [] if cur_obj.parts is not None: for part in cur_obj.parts: part_entry = {'part_group_index': part.part_group_index, 'part_suffix': part.part_suffix, 'subroot_index': part.subroot_index} if part.using_sim is not None: ret_dict['inUseBy'] = 'In Use(See Parts Tab)' part_entry['using_sim'] = part.using_sim.full_name ret_dict['parts'].append(part_entry) ret_dict['slots'] = [] for runtime_slot in cur_obj.get_runtime_slots_gen(): slot_entry = {'slot': str(runtime_slot), 'children': ', '.join(gsi_handlers.gsi_utils.format_object_name(child) for child in runtime_slot.children)} ret_dict['slots'].append(slot_entry) ret_dict['inventory'] = [] inventory = cur_obj.inventory_component if isinstance(cur_obj, GameObject) and inventory is not None: while True: for obj in inventory: inv_entry = {} inv_entry['objId'] = hex(obj.id) inv_entry['classStr'] = gsi_handlers.gsi_utils.format_object_name(obj) inv_entry['stack_count'] = obj.stack_count() inv_entry['stack_sort_order'] = obj.get_stack_sort_order(inspect_only=True) inv_entry['hidden'] = inventory.is_object_hidden(obj) ret_dict['inventory'].append(inv_entry) all_object_data.append(ret_dict) return all_object_data
def generate_object_manager_data(*args, zone_id: int = None, filter=None, **kwargs): lockout_data = {} zone = services.get_zone(zone_id) for sim_info in list(zone.sim_info_manager.objects): sim = sim_info.get_sim_instance() while sim is not None: while True: for (obj, time) in sim.get_lockouts_gen(): lockouts = lockout_data.setdefault(obj, []) lockouts.append((sim, time)) all_object_data = [] for cur_obj in list( itertools.chain(zone.object_manager.objects, zone.prop_manager.objects, zone.inventory_manager.objects)): class_str = gsi_handlers.gsi_utils.format_object_name(cur_obj) on_active_lot = cur_obj.is_on_active_lot() if hasattr( cur_obj, 'is_on_active_lot') else False while (filter is None or filter == 'all_objects' or filter == 'prototype_objects') and ( class_str == 'prototype' or filter == 'game_objects') and ( class_str != 'prototype' or filter == 'on_active_lot') and on_active_lot: obj_loc = cur_obj.position model_name = _get_model_name(cur_obj) ret_dict = { 'mgr': str(cur_obj.manager).replace('_manager', ''), 'objId': hex(cur_obj.id), 'classStr': class_str, 'modelStr': model_name, 'locX': round(obj_loc.x, 3), 'locY': round(obj_loc.y, 3), 'locZ': round(obj_loc.z, 3), 'on_active_lot': str(on_active_lot), 'current_value': cur_obj.current_value, 'is_interactable': 'x' if getattr(cur_obj, 'interactable', False) else '', 'footprint': str(cur_obj.footprint_polygon) if getattr( cur_obj, 'footprint_polygon', None) else '' } ret_dict['additional_data'] = [] parent = cur_obj.parent if parent is not None: ret_dict['parent'] = gsi_handlers.gsi_utils.format_object_name( parent) ret_dict['additional_data'].append({ 'dataId': 'Parent Id', 'dataValue': hex(parent.id) }) ret_dict['additional_data'].append({ 'dataId': 'Parent Slot', 'dataValue': cur_obj.parent_slot.slot_name_or_hash }) if cur_obj.state_component: value = cur_obj.get_most_severe_state_value() if value is not None: ret_dict['additional_data'].append({ 'dataId': 'Severity', 'dataValue': value.__name__ }) ret_dict['isSurface'] = cur_obj.is_surface() if cur_obj in lockout_data: lockouts = ('{} ({})'.format(*lockout) for lockout in lockouts) ret_dict['lockouts'] = ', '.join(lockouts) ret_dict['states'] = [] if cur_obj.state_component: for (state_type, state_value) in cur_obj.state_component.items(): state_entry = { 'state_type': str(state_type), 'state_value': str(state_value), 'state_severity': str(state_value.severity) } ret_dict['states'].append(state_entry) if cur_obj.in_use: users = cur_obj.get_users() ret_dict[ 'inUseBy'] = gsi_handlers.gsi_utils.format_object_list_names( users) ret_dict['transient'] = cur_obj.transient ret_dict['additional_data'].append({ 'dataId': 'Category Tags', 'dataValue': gsi_handlers.gsi_utils.format_object_list_names( cur_obj.get_tags()) }) name = 'None' house_id = cur_obj.get_household_owner_id() ret_dict['additional_data'].append({ 'dataId': 'Household Owner Id', 'dataValue': house_id }) if house_id is not None: household = zone.household_manager.get(house_id) if household is not None: name = household.name ret_dict['additional_data'].append({ 'dataId': 'Household Owner', 'dataValue': name }) sim_name = 'None' sim_id = cur_obj.get_sim_owner_id() if sim_id is not None: sim_info = zone.sim_info_manager.get(sim_id) sim_name = sim_info.full_name ret_dict['additional_data'].append({ 'dataId': 'Sim Owner', 'dataValue': sim_name }) if cur_obj.is_in_inventory( ) and cur_obj.inventoryitem_component._last_inventory_owner is not None: ret_dict['inventory_owner_id'] = hex( cur_obj.inventoryitem_component._last_inventory_owner.id) ret_dict['commodities'] = [] for commodity in list(cur_obj.get_all_stats_gen()): com_entry = { 'commodity': type(commodity).__name__, 'value': commodity.get_value() } if commodity.continuous: com_entry['convergence_value'] = ( commodity.convergence_value, ) com_entry['decay_rate'] = (commodity.base_decay_rate, ) com_entry['change_rate'] = (commodity.get_change_rate, ) ret_dict['commodities'].append(com_entry) ret_dict['postures'] = [] for affordance in list(cur_obj.super_affordances()): while affordance.provided_posture_type is not None: posture_entry = { 'interactionName': affordance.__name__, 'providedPosture': affordance.provided_posture_type.__name__ } ret_dict['postures'].append(posture_entry) ret_dict['parts'] = [] if cur_obj.parts is not None: for part in cur_obj.parts: part_entry = { 'part_group_index': part.part_group_index, 'part_suffix': part.part_suffix, 'subroot_index': part.subroot_index } if part.using_sim is not None: ret_dict['inUseBy'] = 'In Use(See Parts Tab)' part_entry['using_sim'] = part.using_sim.full_name ret_dict['parts'].append(part_entry) ret_dict['slots'] = [] for runtime_slot in cur_obj.get_runtime_slots_gen(): slot_entry = { 'slot': str(runtime_slot), 'children': ', '.join( gsi_handlers.gsi_utils.format_object_name(child) for child in runtime_slot.children) } ret_dict['slots'].append(slot_entry) ret_dict['inventory'] = [] inventory = cur_obj.inventory_component if isinstance(cur_obj, GameObject) and inventory is not None: while True: for obj in inventory: inv_entry = {} inv_entry['objId'] = hex(obj.id) inv_entry[ 'classStr'] = gsi_handlers.gsi_utils.format_object_name( obj) inv_entry['stack_count'] = obj.stack_count() inv_entry[ 'stack_sort_order'] = obj.get_stack_sort_order( inspect_only=True) inv_entry['hidden'] = inventory.is_object_hidden(obj) ret_dict['inventory'].append(inv_entry) all_object_data.append(ret_dict) return all_object_data
def c_api_wall_contour_update(zone_id, wall_type): if wall_type == 0 or wall_type == 2: services.get_zone(zone_id).wall_contour_update_callbacks()
def c_api_wall_contour_update(zone_id, wall_type): with sims4.zone_utils.global_zone_lock(zone_id): while wall_type == 0 or wall_type == 2: services.get_zone(zone_id).wall_contour_update_callbacks()
def _get_lot(self): home_zone = services.get_zone(self._household.home_zone_id) if home_zone is not None: return home_zone.lot
def setup(self, **kwargs): super().setup() services.get_zone(self.zone_id).client_object_managers.add(self)
def c_api_entitlement_unlocked(zone_id, account_id, guid): handlers = services.get_zone(zone_id).entitlement_unlock_handlers call_list = handlers.get(guid) if call_list and call_list(account_id, guid): handlers.pop(guid)
def c_api_foundation_and_level_height_update(zone_id): services.get_zone(zone_id).foundation_and_level_height_update_callbacks()
def c_api_on_lot_clearing_end(zone_id): zone = services.get_zone(zone_id) zone.on_active_lot_clearing_end()