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

Python services.client_manager函数代码示例

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

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



在下文中一共展示了client_manager函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: debug_create_baby

def debug_create_baby(actor_sim, position, gender, routing_surface=None):
    baby = None
    try:
        actor_sim_info = actor_sim.sim_info
        account = actor_sim.sim_info.account
        sim_creator = SimCreator(gender=gender, age=Age.BABY, first_name=SimSpawner.get_random_first_name(account, gender == Gender.FEMALE), last_name=SimSpawner.get_family_name_for_gender(account, actor_sim.last_name, gender == Gender.FEMALE))
        (sim_info_list, _) = SimSpawner.create_sim_infos((sim_creator,), household=actor_sim_info.household, account=account, zone_id=actor_sim_info.zone_id, creation_source='cheat: debug_create_baby')
        sim_info = sim_info_list[0]
        baby_def = Baby.get_default_baby_def()
        baby = create_object(baby_def, sim_info.sim_id)
        baby.set_sim_info(sim_info)
        fgl_context = placement.FindGoodLocationContext(starting_position=position, object_id=baby.id, search_flags=placement.FGLSearchFlagsDefault, object_footprints=(baby.get_footprint(),))
        (trans, orient) = placement.find_good_location(fgl_context)
        if trans is not None:
            baby.location = sims4.math.Location(sims4.math.Transform(trans, orient), routing_surface)
        client = services.client_manager().get_client_by_household_id(sim_info.household_id)
        while client is not None:
            client.selectable_sims.add_selectable_sim_info(sim_info)
    except Exception as e:
        logger.exception('Create baby fail', e)
        if actor_sim_info.household.sim_in_household(sim_info.sim_id):
            actor_sim_info.household.remove_sim_info(sim_info)
        client = services.client_manager().get_client_by_household_id(sim_info.household_id)
        if client is not None:
            client.selectable_sims.remove_selectable_sim_info(sim_info)
        while baby is not None:
            baby.destroy(source=actor_sim, cause='Create baby fail')
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:27,代码来源:baby.py


示例2: _try_start_special_event

    def _try_start_special_event(self, scheduler, alarm_data, extra_data):
        entry = alarm_data.entry
        situation = entry.situation
        situation_manager = services.get_zone_situation_manager()
        if self._active_special_event_id is None:
            client_manager = services.client_manager()
            client = next(iter(client_manager.values()))
            invited_sim = client.active_sim
            active_sim_available = situation.is_situation_available(invited_sim)

            def _start_special_event(dialog):
                guest_list = None
                if dialog.accepted:
                    start_user_facing = True
                    guest_list = SituationGuestList()
                    guest_info = SituationGuestInfo.construct_from_purpose(invited_sim.id, situation.venue_situation_player_job, SituationInvitationPurpose.INVITED)
                    guest_list.add_guest_info(guest_info)
                else:
                    start_user_facing = False
                situation_id = situation_manager.create_situation(situation, guest_list=guest_list, user_facing=start_user_facing)
                self._active_special_event_id = situation_id

            if not situation_manager.is_user_facing_situation_running() and active_sim_available:
                dialog = situation.venue_invitation_message(invited_sim, SingleSimResolver(invited_sim))
                dialog.show_dialog(on_response=_start_special_event, additional_tokens=(situation.display_name, situation.venue_situation_player_job.display_name))
            else:
                situation_id = situation_manager.create_situation(situation, user_facing=False)
                self._active_special_event_id = situation_id
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:28,代码来源:venue_tuning.py


示例3: add

 def add(self, amount, reason, sim, tags=None, count_as_earnings=True):
     amount = round(amount)
     if amount < 0:
         logger.error('Attempt to add negative amount of money to Family Funds.', owner='mduke')
         return
     if sim is None:
         for client in services.client_manager().objects:
             while client.household_id == self._household.id:
                 self._update_money(amount, reason, client.account.id, tags=tags, count_as_earnings=count_as_earnings)
                 return
         logger.callstack('Attempt to raise household funds on a house with no client connected.', owner='nbaker', level=sims4.log.LEVEL_WARN)
     else:
         if sim.household != self._household:
             logger.error('Attempt to add funds to the wrong household.', owner='mduke')
             return
         status = sim.account_connection
         if status == AccountConnection.OFFLINE:
             return
         if status == AccountConnection.DIFFERENT_LOT:
             sim.sim_info.add_to_personal_funds(amount)
             with telemetry_helper.begin_hook(writer, TELEMETRY_HOOK_POCKET, sim=sim) as hook:
                 hook.write_int(TELEMETRY_AMOUNT, amount)
                 hook.write_int(TELEMETRY_REASON, reason)
         else:
             self._update_money(amount, reason, sim.account_id, sim, tags=tags, count_as_earnings=count_as_earnings)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:25,代码来源:funds.py


示例4: _trigger_phone_call_gen

 def _trigger_phone_call_gen(self, timeline):
     client = services.client_manager().get_first_client()
     if client is None:
         return
     client_household = client.household
     if client_household is None:
         return
     sims_to_check = [sim for sim in client_household.instanced_sims_gen()]
     random.shuffle(sims_to_check)
     for sim in sims_to_check:
         call_types = []
         ask_to_come_over_phone_call = HouseholdManager.PHONE_CALL_INFO.ask_to_come_over(sim)
         call_types.append((ask_to_come_over_phone_call.weight, ask_to_come_over_phone_call))
         chat_phone_call = HouseholdManager.PHONE_CALL_INFO.chat(sim)
         call_types.append((chat_phone_call.weight, chat_phone_call))
         invite_over_phone_call = HouseholdManager.PHONE_CALL_INFO.invite_over(sim)
         call_types.append((invite_over_phone_call.weight, invite_over_phone_call))
         while call_types:
             call_type = pop_weighted(call_types)
             if call_type.try_and_setup():
                 call_type.execute()
                 self._phone_call_element = None
                 return
             yield element_utils.run_child(timeline, element_utils.sleep_until_next_tick_element())
     self._phone_call_element = None
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:25,代码来源:household_manager.py


示例5: debugvis_test

def debugvis_test(name, _connection=None):
    client = services.client_manager().get(_connection)
    sim = client.active_sim
    time = services.time_service().sim_now
    hour = time.hour() % 12*sims4.math.TWO_PI/12
    minute = time.minute()*sims4.math.TWO_PI/60
    a = sim.position + sims4.math.Vector3(0, 1, 0)
    b = a + sims4.math.Vector3(math.cos(hour), 0, math.sin(hour))*3
    c = a + sims4.math.Vector3(math.cos(minute), 0, math.sin(minute))*4
    with Context(name, routing_surface=sim.routing_surface) as layer:
        layer.set_color(Color.YELLOW)
        layer.add_segment(a, b, color=Color.CYAN)
        layer.add_segment(a, c, color=Color.RED)
        layer.add_point(a, size=0.2)
        layer.add_point(b, size=0.1, color=Color.BLUE)
        layer.add_point(c, size=0.1, color=Color.MAGENTA)
        layer.add_circle(a, 5, color=Color.GREEN)
        for i in range(12):
            theta = i*sims4.math.TWO_PI/12
            x = sims4.math.Vector3(4.75*math.cos(theta), 0, 4.75*math.sin(theta))
            color = sims4.color.interpolate(Color.YELLOW, Color.BLUE, i/11)
            layer.add_arrow(a + x, 0.5*sims4.math.PI - theta, end_arrow=False, color=color)
            layer.add_text_world(a + x, str(i), color_foreground=pseudo_random_color(i))
        layer.add_text_screen(sims4.math.Vector2(4, 32), 'Displaying debug visualization tests.')
        for i in range(200):
            layer.add_text_object(sim, sims4.math.Vector3.ZERO(), str(i), bone_index=i)
    return 1
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:27,代码来源:visualization_commands.py


示例6: invoke_command

def invoke_command(command=None, zone_id:int=None):
    ready = False
    output_accum = ''
    response = ''

    def _callback(result):
        nonlocal response, ready
        if result:
            response = 'Success<br>' + output_accum
        else:
            response = 'Failure<br>' + output_accum
        ready = True

    if command is not None:

        def _fake_output(s, context=None):
            nonlocal response
            response += '<br>' + s

        connection = services.client_manager().get_first_client()
        sims4.core_services.command_buffer_service().add_command(command, _callback, _fake_output, zone_id, connection.id)
    timeout_counter = 0
    while not ready:
        time.sleep(SLEEP_TIME)
        timeout_counter += 1
        while timeout_counter > TIMEOUT:
            ready = True
            continue
    return {'response': response}
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:29,代码来源:command_handlers.py


示例7: check_collection_complete

 def check_collection_complete(self, collection_id):
     collection_data = ObjectCollectionData.get_collection_data(collection_id)
     collection_count = len(collection_data.object_list)
     collected_count = sum(1 for collection in self._collections.values() if collection == collection_id)
     if not collection_count or not collected_count:
         return
     client = services.client_manager().get_client_by_household(self._owner)
     if client is not None and client.active_sim is not None:
         message_owner_info = client.active_sim.sim_info
     else:
         message_owner_info = None
     if collection_data.first_collected_notification is not None and message_owner_info is not None and collected_count == 1:
         dialog = collection_data.first_collected_notification(message_owner_info, None)
         dialog.show_dialog()
     if collection_count == collected_count:
         if client is not None:
             with telemetry_helper.begin_hook(collection_telemetry_writer, TELEMETRY_HOOK_COLLECTION_COMPLETE, household=client.household) as hook:
                 hook.write_int(TELEMETRY_COLLECTION_ID, collection_id)
             _sting = ObjectCollectionData.COLLECTION_COMPLETED_STING(client.active_sim)
             _sting.start()
         if message_owner_info is not None:
             dialog = collection_data.completed_award_notification(message_owner_info, None)
             dialog.show_dialog()
             if collection_data.screen_slam is not None:
                 collection_data.screen_slam.send_screen_slam_message(message_owner_info, collection_data.collection_name)
         lot = services.active_lot()
         if lot is not None:
             lot.create_object_in_hidden_inventory(collection_data.completed_award)
         household = services.household_manager().get(self._owner.id)
         if household is not None:
             household.funds.add(collection_data.completed_award_money, Consts_pb2.TELEMETRY_MONEY_ASPIRATION_REWARD, None)
     elif client is not None:
         _sting = ObjectCollectionData.COLLECTION_COLLECTED_STING(client.active_sim)
         _sting.start()
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:34,代码来源:collection_manager.py


示例8: purchase_to_inventory

def purchase_to_inventory(inventory_obj, def_id:str=None, mailman_purchase:bool=False, _connection=None):
    definition_manager = services.definition_manager()
    definition = definition_manager.get(def_id)
    if definition is None:
        return False
    client = services.client_manager().get(_connection)
    if client is None:
        return False
    household = client.household
    price = definition.price
    if household.funds.money < price:
        return False
    if mailman_purchase:
        obj = services.active_lot().create_object_in_hidden_inventory(definition)
    else:
        inventory = inventory_obj.get_target().inventory_component
        if inventory is None:
            return False
        obj = create_object(definition)
        if obj is None:
            return False
        if not inventory.player_try_add_object(obj):
            obj.destroy(source=inventory, cause='Failed to purchase object into inventory')
            return False
    obj.set_household_owner_id(household.id)
    obj.try_post_bb_fixup(force_fixup=True, active_household_id=services.active_household_id())
    household.funds.remove(price, Consts_pb2.TELEMETRY_OBJECT_BUY)
    return True
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:28,代码来源:inventory_commands.py


示例9: display_outcomes

def display_outcomes(sim_id:int=None, _connection=None):
    sim = services.object_manager().get(sim_id)
    client = services.client_manager().get(_connection)
    if not sim:
        sim = _active_sim(client)
    for si in sim.si_state.sis_actor_gen():
        sims4.commands.output('Outcome for {} = {}'.format(si.affordance, si.outcome_result), _connection)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:interaction_commands.py


示例10: set_interaction_mode

def set_interaction_mode(mode:InteractionModes=None, source:int=None, priority:interactions.priority.Priority=None, _connection=None):
    output = sims4.commands.Output(_connection)
    client = services.client_manager().get(_connection)
    if client is None:
        return 0
    sources = {}
    for (key, val) in vars(interactions.context.InteractionContext).items():
        while key.startswith('SOURCE'):
            sources[val] = key
    if mode is None and source is None and priority is None:
        output('Source options:')
        for val in sources.values():
            output('    {}'.format(val))
        output('Priority options:')
        for val in interactions.priority.Priority:
            output('    {}'.format(val.name))
    if mode is InteractionModes.default:
        client.interaction_source = None
        client.interaction_priority = None
    elif mode is InteractionModes.autonomous:
        client.interaction_source = interactions.context.InteractionContext.SOURCE_AUTONOMY
        client.interaction_priority = interactions.priority.Priority.Low
    if source is not None:
        client.interaction_source = source
    if priority is not None:
        client.interaction_priority = priority
    source = sources.get(client.interaction_source, client.interaction_source)
    output('Client interaction mode: source={} priority={}'.format(source, client.interaction_priority.name))
    return 1
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:29,代码来源:interaction_commands.py


示例11: push_walk_away

def push_walk_away(sim_id:int=None, _connection=None):
    if sim_id is None:
        client = services.client_manager().get(_connection)
        sim = _active_sim(client)
    else:
        sim = services.object_manager().get(sim_id)
    push_backoff(sim)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:interaction_commands.py


示例12: cancel_mixer_interaction

def cancel_mixer_interaction(interaction_id, mixer_id, server_ref, context_handle:int=None, _connection=None):
    logger.debug('cancel_sub_interaction {0}', interaction_id)
    client = services.client_manager().get(_connection)
    sim = _active_sim(client)
    interaction = sim.find_sub_interaction_by_aop_id(interaction_id, mixer_id)
    if interaction is not None and sim.queue.running != interaction:
        return interaction.cancel_user(cancel_reason_msg='Command interactions.cancel')
    return False
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:8,代码来源:interaction_commands.py


示例13: get_active_sim_home_zone_id

 def get_active_sim_home_zone_id():
     client = services.client_manager().get_first_client()
     if client is not None:
         active_sim = client.active_sim
         if active_sim is not None:
             household = active_sim.household
             if household is not None:
                 return household.home_zone_id
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:8,代码来源:household_manager.py


示例14: _award_insurance_money

 def _award_insurance_money(self):
     client = services.client_manager().get_first_client()
     active_sim = client.active_sim
     if self._insurance_value > 0 and active_sim is not None:
         services.active_household().funds.add(self._insurance_value, Consts_pb2.TELEMETRY_INTERACTION_COST, None)
         dialog = self.FIRE_INSURANCE_CLAIM_NOTIFICATION(active_sim, SingleSimResolver(active_sim))
         dialog.show_dialog(additional_tokens=(self._insurance_value,))
         self._insurance_value = 0
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:8,代码来源:fire_service.py


示例15: initialize_sim_info

 def initialize_sim_info(sim_info, parent_a, parent_b):
     sim_info.add_parent_relations(parent_a, parent_b)
     if sim_info.household is not parent_a.household:
         parent_a.household.add_sim_info_to_household(sim_info)
     services.sim_info_manager()._set_default_genealogy()
     sim_info.set_default_relationships(reciprocal=True)
     client = services.client_manager().get_client_by_household_id(sim_info.household_id)
     if client is not None:
         client.selectable_sims.add_selectable_sim_info(sim_info)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:9,代码来源:pregnancy.py


示例16: get_optional_target

def get_optional_target(opt_target:OptionalTargetParam=None, _connection=None):
    if opt_target is not None:
        target = opt_target._get_target(_connection)
        if target is None:
            sims4.commands.output('Object ID not in the object manager: {}.'.format(opt_target._target_id), _connection)
        return target
    tgt_client = services.client_manager().get(_connection)
    if tgt_client is not None:
        return tgt_client.active_sim
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:9,代码来源:argument_helpers.py


示例17: automation_test_cheats

def automation_test_cheats(enable:bool=False, _connection=None):
    tgt_client = services.client_manager().get(_connection)
    output = sims4.commands.CheatOutput(_connection)
    household = tgt_client.household
    household.cheats_enabled = enable
    if enable:
        output('Cheats are enabled.')
    else:
        output('Cheats are disabled.')
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:9,代码来源:cheat_commands.py


示例18: ui_dialog_notification_test

def ui_dialog_notification_test(*all_text, _connection=None):
    client = services.client_manager().get(_connection)
    all_text_str = ' '.join(all_text)
    if '/' in all_text:
        (title, text) = all_text_str.split('/')
        notification = UiDialogNotification.TunableFactory().default(client.active_sim, text=lambda **_: LocalizationHelperTuning.get_raw_text(text), title=lambda **_: LocalizationHelperTuning.get_raw_text(title))
    else:
        notification = UiDialogNotification.TunableFactory().default(client.active_sim, text=lambda **_: LocalizationHelperTuning.get_raw_text(all_text_str))
    notification.show_dialog(icon_override=(None, client.active_sim))
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:9,代码来源:ui_commands.py


示例19: _classify_sim

def _classify_sim(sim, household):
    if household.is_persistent_npc:
        return 4
    if household.is_npc_household:
        return 3
    client = services.client_manager().get_client_by_household_id(household.id)
    if sim == client.active_sim:
        return 1
    return 2
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:9,代码来源:telemetry_helper.py


示例20: _get_target

 def _get_target(self, _connection):
     if self._target_id is None:
         tgt_client = services.client_manager().get(_connection)
         if tgt_client is not None:
             return tgt_client.active_sim
         return
     if self._target_id == self.TARGET_ID_ACTIVE_LOT:
         return services.active_lot()
     return services.object_manager().get(self._target_id)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:9,代码来源:argument_helpers.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python services.current_zone函数代码示例发布时间:2022-05-27
下一篇:
Python servicemigration.require函数代码示例发布时间: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