• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python services.object_manager函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中services.object_manager函数的典型用法代码示例。如果您正苦于以下问题:Python object_manager函数的具体用法?Python object_manager怎么用?Python object_manager使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了object_manager函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:posture_specs.py


示例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.')
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:29,代码来源:self_interactions.py


示例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
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:8,代码来源:crafting_station_component.py


示例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
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:8,代码来源:crafting_station_component.py


示例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)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:9,代码来源:inventory.py


示例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)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:14,代码来源:inventory_interactions.py


示例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)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:30,代码来源:career_commands.py


示例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)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:zone.py


示例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)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:front_door.py


示例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()
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:front_door.py


示例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
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:zone_spin_up_service.py


示例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)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:25,代码来源:crafting_process.py


示例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
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:28,代码来源:autonomy_request.py


示例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
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:29,代码来源:areaserver.py


示例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
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:28,代码来源:lot_tuning.py


示例16: on_role_activate

 def on_role_activate(self, role_affordance_target=None):
     if self.portal_disallowance_tags:
         object_manager = services.object_manager()
         for portal in object_manager.portal_cache_gen():
             while portal.state_component and portal.get_state(FrontDoorTuning.FRONT_DOOR_ENABLED_STATE.state) == FrontDoorTuning.FRONT_DOOR_ENABLED_STATE:
                 self._add_disallowed_portal(portal)
         object_manager.register_portal_added_callback(self._add_disallowed_portal)
         object_manager.register_front_door_candidates_changed_callback(self._on_front_door_candidates_changed)
     for buff_ref in self.buffs:
         if buff_ref is None:
             logger.warn('{} has empty buff in buff list. Please fix tuning.', self)
         if buff_ref.buff_type is None:
             logger.warn('{} has an buff type not set. Please fix tuning.', self)
         self._buff_handles.append(self.sim.add_buff(buff_ref.buff_type, buff_reason=buff_ref.buff_reason))
     if self.off_lot_autonomy_buff is not None and self.off_lot_autonomy_buff.buff_type is not None:
         self._off_lot_autonomy_buff_handle = self.sim.add_buff(self.off_lot_autonomy_buff.buff_type, buff_reason=self.off_lot_autonomy_buff.buff_reason)
     flags = set()
     for affordance in self.role_specific_affordances:
         flags |= affordance.commodity_flags
     if flags:
         self.sim.add_dynamic_commodity_flags(self, flags)
     if self.on_activate is not None:
         self.on_activate(self, role_affordance_target)
     if not self.allow_npc_routing_on_active_lot:
         self.sim.inc_lot_routing_restriction_ref_count()
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:25,代码来源:role_state_base.py


示例17: get_sims_for_job

def get_sims_for_job(session_id, sim_id, situation_type, job_type, *job_assignments, _connection=None):
    sim = get_optional_target(sim_id, _connection)
    situation_start_time = services.time_service().sim_now
    duration = situation_type.duration
    if duration > 0:
        situation_end_time = situation_start_time + date_and_time.create_time_span(0, 0, duration)
    else:
        situation_start_time = date_and_time.INVALID_DATE_AND_TIME
        situation_end_time = date_and_time.INVALID_DATE_AND_TIME
    results = services.sim_filter_service().submit_filter(job_type.filter, None, requesting_sim_info=sim.sim_info, start_time=situation_start_time, end_time=situation_end_time, allow_yielding=False)
    if job_type.additional_filter_for_user_selection:
        sim_constraints = {result.sim_info.id for result in results}
        results = services.sim_filter_service().submit_filter(job_type.additional_filter_for_user_selection, None, requesting_sim_info=sim.sim_info, start_time=situation_start_time, end_time=situation_end_time, sim_constraints=sim_constraints, allow_yielding=False)
    msg = Situations_pb2.SituationJobSims()
    msg.situation_session_id = session_id
    msg.job_resource_id = job_type.guid
    msg.requirements = job_type.requirement_text
    results.sort(key=lambda x: (x.sim_info.is_npc, x.sim_info.last_name))
    for result in results:
        msg.sim_ids.append(result.sim_info.id)
        with ProtocolBufferRollback(msg.sims) as situation_job_sim:
            situation_job_sim.sim_id = result.sim_info.id
            if result.sim_info.household.id == services.active_household_id():
                situation_job_sim.account_id = result.sim_info.account_id
            while result.conflicting_career_track_id:
                situation_job_sim.career_track_id = result.conflicting_career_track_id
    shared_messages.add_message_if_selectable(services.object_manager().get(sim.id), Consts_pb2.MSG_SITUATION_JOB_SIMS, msg, True)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:27,代码来源:situation_commands.py


示例18: _check_bring_baby_back_from_daycare

def _check_bring_baby_back_from_daycare(household, travel_sim_infos, current_zone):
    if household.is_npc_household:
        return
    if not household.number_of_babies:
        return
    for sim_info in household.teen_or_older_info_gen():
        while sim_info not in travel_sim_infos and sim_info.zone_id == household.home_zone_id:
            sim = sim_info.get_sim_instance()
            if sim is not None and not sim.is_hidden():
                return
    returned_babies = []
    obj_mgr = services.object_manager()
    for baby_info in household.baby_info_gen():
        bassinet = obj_mgr.get(baby_info.sim_id)
        while bassinet is not None:
            if not bassinet._ignore_daycare:
                bassinet.enable_baby_state()
                returned_babies.append(bassinet)
            else:
                bassinet._ignore_daycare = False
    if returned_babies:
        if len(returned_babies) == 1:
            dialog = Baby.BRING_BABY_BACK_FROM_DAYCARE_NOTIFICATION_SINGLE_BABY(sim_info, SingleSimResolver(returned_babies[0]))
        else:
            dialog = Baby.BRING_BABY_BACK_FROM_DAYCARE_NOTIFICATION_MULTIPLE_BABIES(sim_info, SingleSimResolver(sim_info))
        dialog.show_dialog()
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:26,代码来源:baby.py


示例19: on_client_connect

 def on_client_connect(self, client):
     for created_obj_id in self._spawned_object_ids:
         spawned_object = services.object_manager().get(created_obj_id)
         while spawned_object is not None:
             self._spawned_objects.add(spawned_object)
     self._spawned_object_ids = []
     SpawnerInitializer.create(client.zone_id)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:spawner_component.py


示例20: _assign_to_bassinet

def _assign_to_bassinet(sim_info):
    object_manager = services.object_manager()
    bassinet = object_manager.get(sim_info.sim_id)
    if assign_bassinet_for_baby(sim_info):
        return
    if not (bassinet is None and build_buy.object_exists_in_household_inventory(sim_info.id, sim_info.household_id)):
        create_and_place_baby(sim_info)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:baby.py



注:本文中的services.object_manager函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python services.sim_info_manager函数代码示例发布时间:2022-05-27
下一篇:
Python services.get_zone_situation_manager函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap