本文整理汇总了Python中services.object_manager函数的典型用法代码示例。如果您正苦于以下问题:Python object_manager函数的具体用法?Python object_manager怎么用?Python object_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了object_manager函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: object_manager
def object_manager():
global _cached_object_manager
if _enable_cache_count:
if _cached_object_manager is None:
_cached_object_manager = services.object_manager()
return _cached_object_manager
return services.object_manager()
示例2: save_and_destroy_sim
def save_and_destroy_sim(self, on_reset, sim_info):
if services.current_zone().is_zone_shutting_down:
return
from_zone_id = self.from_zone_id
to_zone_id = self.to_zone_id
callback = self.on_complete_callback
context = self.on_complete_context
def notify_travel_service():
if services.travel_service().has_pending_travel(sim_info.account):
travel_service.on_travel_interaction_succeeded(sim_info, from_zone_id, to_zone_id, callback, context)
if not sim_info.is_npc:
services.client_manager().get_first_client().send_selectable_sims_update()
try:
logger.debug('Saving sim during TravelInteraction for {}', sim_info)
sim_info.inject_into_inactive_zone(self.to_zone_id)
save_success = sim_info.save_sim()
while not save_success:
logger.error('Failure saving during TravelInteraction for {}', sim_info)
finally:
logger.debug('Destroying sim {}', sim_info)
self.force_save_and_destroy_sim = False
if on_reset:
if self.sim is not None:
services.object_manager().remove(self.sim)
notify_travel_service()
elif self.sim is not None:
self.sim.schedule_destroy_asap(source=self, cause='Destroying sim on travel.')
示例3: _remove_from_cache
def _remove_from_cache(self, user_directed=True, autonomy=True):
user_directed &= self._cached
autonomy &= self._cached_for_autonomy
services.object_manager().crafting_cache.remove_type(self.crafting_station_type, user_directed=user_directed, autonomy=autonomy)
if autonomy:
self._cached_for_autonomy = False
if user_directed:
self._cached = False
示例4: _add_to_cache
def _add_to_cache(self, user_directed=True, autonomy=True):
user_directed &= not self._cached
autonomy &= not self._cached_for_autonomy
services.object_manager().crafting_cache.add_type(self.crafting_station_type, user_directed=user_directed, autonomy=autonomy)
if autonomy:
self._cached_for_autonomy = True
if user_directed:
self._cached = True
示例5: _added
def _added(self, obj, send_ui=True, object_with_inventory=None):
obj.inventoryitem_component.set_inventory_type(self._inventory_type, object_with_inventory)
if obj.id in services.object_manager():
services.object_manager().move_to_inventory(obj, self.inventory_manager)
obj.clear_parent(self.INVENTORY_TRANSFORM, None)
for state_trigger in self._inventory_state_triggers:
state_trigger.on_object_added(obj)
if send_ui:
self._added_ui_update(obj)
示例6: clone_obj_to_inv
def clone_obj_to_inv(obj_id, inventory_owner_id, count:int=1, _connection=None):
obj_to_create = services.object_manager().get(obj_id)
target_object = services.object_manager().get(inventory_owner_id)
if obj_to_create is None or target_object is None:
sims4.commands.output('{} or {} not found in object manager'.format(obj_id, inventory_owner_id), _connection)
return
inventory = target_object.inventory_component
if inventory is None:
sims4.commands.output("{} doesn't have an inventory".format(str(target_object)), _connection)
return
for _ in range(count):
obj_instance = objects.system.create_object(obj_to_create.definition)
while obj_instance:
inventory.player_try_add_object(obj_instance)
示例7: select_career
def select_career(sim_id:int=None, career_instance_id:int=None, track_id:int=None, level:int=None, company_name_hash:int=None, reason:int=CareerOps.JOIN_CAREER, _connection=None):
if sim_id is None or (career_instance_id is None or track_id is None) or level is None:
logger.error('Not all of the data needed for the careers.select command was passed.')
return False
career_manager = services.get_instance_manager(sims4.resources.Types.CAREER)
career_type = career_manager.get(career_instance_id)
if career_type is None:
logger.error('invalid career Id sent to careers.select')
return False
sim = services.object_manager().get(sim_id)
if sim_id is None:
logger.error('invalid sim Id passed to careers.select')
return False
career_track_manager = services.get_instance_manager(sims4.resources.Types.CAREER_TRACK)
career_track = career_track_manager.get(track_id)
if career_track is None:
logger.error('invalid career track Id passed to careers.select')
return False
if reason is None:
logger.error('invalid career selection reason passed to careers.select')
return False
career_tracker = sim.sim_info.career_tracker
if reason == CareerOps.JOIN_CAREER:
current_career = career_tracker.get_career_by_uid(career_instance_id)
if current_career is not None:
current_career.set_new_career_track(track_id)
else:
career_tracker.add_career(career_type(sim.sim_info, company_name=company_name_hash), show_confirmation_dialog=True)
if reason == CareerOps.QUIT_CAREER:
career_tracker.remove_career(career_instance_id)
示例8: _set_zone_objects_household_owner_id
def _set_zone_objects_household_owner_id(self, household_id):
for obj in services.object_manager(self.id).get_all():
while obj.is_on_active_lot():
obj.set_household_owner_id(household_id)
for (_, inventory) in self.lot.get_all_object_inventories_gen():
for inv_obj in inventory:
inv_obj.set_household_owner_id(household_id)
示例9: set_front_door
def set_front_door(obj_id, _connection=None):
door = services.object_manager().get(obj_id)
if door is not None and isinstance(door, objects.doors.door.Door) and door.is_door_portal:
door.set_as_front_door()
sims4.commands.output('Object {} set as front door'.format(str(door)), _connection)
else:
sims4.commands.output('Object {} is not a door, no door will be set'.format(str(door)), _connection)
示例10: load_front_door
def load_front_door(front_door_id):
front_door = services.object_manager().get(front_door_id)
if front_door is not None:
front_door.set_as_front_door()
else:
logger.warn('Front door object id saved was not found in manager, finding a new front door')
find_and_set_front_door()
示例11: on_enter
def on_enter(self):
super().on_enter()
services.current_zone().lot.publish_shared_inventory_items()
active_household_id = services.active_household_id()
for script_object in services.object_manager().get_all():
script_object.finalize(active_household_id=active_household_id)
return _ZoneSpinUpStateResult.DONE
示例12: load
def load(self, crafting_process_message):
recipe_manager = services.get_instance_manager(sims4.resources.Types.RECIPE)
self.recipe = recipe_manager.get(crafting_process_message.recipe_id)
for phase in self.recipe.phases.values():
if phase.id == crafting_process_message.phase_id:
self.phase = phase
else:
while phase.id == crafting_process_message.previous_phase_id:
self._previous_phase = phase
current_ico = services.object_manager().get(crafting_process_message.current_ico)
if current_ico is None:
current_ico = services.inventory_manager().get(crafting_process_message.current_ico)
if current_ico is not None:
self._current_ico_ref = current_ico.ref()
if crafting_process_message.crafter_sim_id != 0:
self._crafter_sim_id = crafting_process_message.crafter_sim_id
self.add_order(self._crafter_sim_id, self.recipe)
if crafting_process_message.HasField('inscription'):
self.inscription = crafting_process_message.inscription
if crafting_process_message.HasField('crafted_value'):
self.crafted_value = crafting_process_message.crafted_value
statistic_component = self.get_component(objects.components.types.STATISTIC_COMPONENT)
statistic_tracker = statistic_component.get_statistic_tracker()
if statistic_tracker is not None:
statistic_tracker.load(crafting_process_message.statistic_tracker.statistics)
示例13: objects_to_score_gen
def objects_to_score_gen(self, motives:set=singletons.DEFAULT):
if motives is singletons.DEFAULT:
motives = self.all_commodities
if not self.object_list:
autonomy_rule = self.sim.get_off_lot_autonomy_rule_type() if self.off_lot_autonomy_rule_override is None else self.off_lot_autonomy_rule_override
off_lot_radius = self.sim.get_off_lot_autonomy_radius()
sim_is_on_active_lot = self.sim.is_on_active_lot(tolerance=self.sim.get_off_lot_autonomy_tolerance())
for obj in services.object_manager().advertising_objects_gen(motives):
if self.ignored_object_list and obj in self.ignored_object_list:
pass
if not self.sim.autonomy_component.get_autonomous_availability_of_object(obj, autonomy_rule, off_lot_radius, sim_is_on_active_lot):
pass
yield obj
for obj in self.sim.inventory_component:
if self.ignored_object_list and obj in self.ignored_object_list:
pass
yield obj
elif not motives:
for obj in self.object_list:
if self.ignored_object_list and obj in self.ignored_object_list:
pass
yield obj
else:
for obj in self.object_list:
while obj.commodity_flags & motives:
if self.ignored_object_list and obj in self.ignored_object_list:
pass
yield obj
示例14: c_api_add_sims
def c_api_add_sims(session_id, zone_id, sim_ids, callback, add_to_skewer):
zone = services._zone_manager.get(zone_id)
if zone is None:
return LOADSIMS_FAILED_ERROR_CODE
client = zone.client_manager.get(session_id)
load_sims_on_client_connect = True
if client is None and load_sims_on_client_connect:
services.sim_info_manager().add_sims_to_zone(sim_ids)
else:
object_manager = services.object_manager()
for sim_id in sim_ids:
if sim_id in object_manager:
logger.error(
'Attempt to add a sim who is already in the zone. Native likely has a logic error.',
owner='mduke')
ret = sims.sim_spawner.SimSpawner.load_sim(sim_id)
while not ret:
logger.error(
'Sim failed to load while spinning up sim_id: {}.',
sim_id,
owner='mduke')
return LOADSIMS_FAILED_ERROR_CODE
if add_to_skewer:
for sim_id in sim_ids:
sim_info = services.sim_info_manager(zone_id).get(sim_id)
while sim_info is not None:
if client.household_id == sim_info.household_id:
client.add_selectable_sim_info(sim_info)
return SUCCESS_CODE
示例15: cleanup_objects
def cleanup_objects(cls, lot=None):
if lot is None:
logger.error('Lot is None when trying to run lot cleanup.', owner='jjacobson')
return
cls.objects_to_destroy = set()
for cleanup in GlobalLotTuningAndCleanup.OBJECT_CLEANUP_TUNING:
items_to_cleanup = cleanup.count(lot)
if items_to_cleanup == 0:
pass
items_cleaned_up = 0
for obj in services.object_manager().values():
if items_cleaned_up >= items_to_cleanup:
break
if obj.is_sim:
pass
resolver = SingleObjectResolver(obj)
run_action = False
for possible_action in cleanup.possible_actions:
while possible_action.tests.run_tests(resolver):
while True:
for action in possible_action.actions:
action(obj, lot)
run_action = True
while run_action:
items_cleaned_up += 1
for obj in cls.objects_to_destroy:
obj.destroy(source=lot, cause='Cleaning up the lot')
cls.objects_to_destroy = None