当前位置: 首页>>代码示例>>Python>>正文


Python services.sim_info_manager函数代码示例

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


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

示例1: load_from_seedling

 def load_from_seedling(self, tracker_seedling):
     if self._has_offered_goals:
         raise AssertionError('Attempting to load goals for situation: {} but goals have already been offered.'.format(self))
     self._has_offered_goals = tracker_seedling.has_offered_goals
     if tracker_seedling.inherited_target_id != 0:
         self._inherited_target_sim_info = services.sim_info_manager().get(tracker_seedling.inherited_target_id)
     self._goal_chains = []
     for chain_seedling in tracker_seedling.chains:
         self._goal_chains.append(_GoalSetChain(chain_seedling.starting_goal_set_type, chain_seedling.chosen_goal_set_type, chain_seedling.chain_id))
     if tracker_seedling.main_goal:
         goal_seedling = tracker_seedling.main_goal
         sim_info = services.sim_info_manager().get(goal_seedling.actor_id)
         self._realized_main_goal = goal_seedling.goal_type(sim_info=sim_info, situation=self._situation, goal_id=self._goal_id_generator(), count=goal_seedling.count, reader=goal_seedling.reader)
         if goal_seedling.completed:
             self._main_goal_completed = True
         else:
             self._realized_main_goal.register_for_on_goal_completed_callback(self._on_goal_completed)
     for goal_seedling in tracker_seedling.minor_goals:
         sim_info = services.sim_info_manager().get(goal_seedling.actor_id)
         while True:
             for chain in self._goal_chains:
                 while chain.chain_id == goal_seedling.chain_id:
                     break
             logger.error('Unable to find chain with chain_id: {} during load of situation: {}', goal_seedling.chain_id, self)
         goal = goal_seedling.goal_type(sim_info=sim_info, situation=self._situation, goal_id=self._goal_id_generator(), count=goal_seedling.count, reader=goal_seedling.reader)
         self._realized_minor_goals[goal] = chain
         goal.register_for_on_goal_completed_callback(self._on_goal_completed)
     self._situation._send_goal_update_to_client()
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:28,代码来源:situation_goal_tracker.py

示例2: get_participants

 def get_participants(self, participant_type, event_key=None):
     result = self._get_participants_base(participant_type, event_key=event_key)
     if result:
         return result
     if participant_type == event_testing.test_events.SIM_INSTANCE:
         return (self.sim_info,)
     if participant_type == event_testing.test_events.FROM_DATA_OBJECT:
         return (self.data_object,)
     if participant_type == event_testing.test_events.OBJECTIVE_GUID64:
         return (self.objective_guid64,)
     if participant_type == event_testing.test_events.FROM_EVENT_DATA:
         if not self.event_kwargs:
             return ()
         return (self.event_kwargs.get(event_key),)
     if self._interaction is not None:
         return tuple(getattr(participant, 'sim_info', participant) for participant in self._interaction.get_participants(participant_type))
     if participant_type == ParticipantType.Actor:
         return (self.sim_info,)
     if participant_type == ParticipantType.AllRelationships:
         sim_mgr = services.sim_info_manager()
         relations = set(sim_mgr.get(relations.relationship_id) for relations in self.sim_info.relationship_tracker)
         return tuple(relations)
     if participant_type == ParticipantType.TargetSim:
         if not self.event_kwargs:
             return ()
         target_sim_id = self.event_kwargs.get(event_testing.test_events.TARGET_SIM_ID)
         if target_sim_id is None:
             return ()
         return (services.sim_info_manager().get(target_sim_id),)
     if self.on_zone_load:
         return ()
     raise ValueError('Trying to use DataResolver with type that is not supported by DataResolver: {}'.format(participant_type))
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:32,代码来源:resolver.py

示例3: _run_interaction_gen

    def _run_interaction_gen(self, timeline):
        services.sim_info_manager()._set_default_genealogy()
        resolver = DataResolver(self.sim.sim_info)
        if not resolver(self.situation_blacklist):
            return True
        if not self.target.is_sim:
            return True
        if self.sim.household_id == self.target.household_id:
            return True

        def on_response(dialog):
            if not dialog.accepted:
                self.cancel_user(cancel_reason_msg='Move-In. Player canceled, or move in together dialog timed out from client.')
                return
            actor = self.get_participant(ParticipantType.Actor)
            src_household_id = actor.sim_info.household.id
            target = self.target
            tgt_household_id = target.sim_info.household.id
            client_manager = services.client_manager()
            if client_manager is not None:
                client = client_manager.get_first_client()
                if client is not None:
                    active_sim_id = client.active_sim.id
            if src_household_id is not None and tgt_household_id is not None and active_sim_id is not None:
                transfer_info = InteractionOps_pb2.SimTransferRequest()
                transfer_info.source_household_id = src_household_id
                transfer_info.target_household_id = tgt_household_id
                transfer_info.active_sim_id = active_sim_id
                system_distributor = distributor.system.Distributor.instance()
                generic_pb_op = GenericProtocolBufferOp(DistributorOps_pb2.Operation.SIM_TRANSFER_REQUEST, transfer_info)
                system_distributor.add_op_with_no_owner(generic_pb_op)

        dialog = self.dialog(self.sim, self.get_resolver())
        dialog.show_dialog(on_response=on_response)
        return True
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:35,代码来源:household_management_interactions.py

示例4: modify_relationship

def modify_relationship(first_name1='', last_name1='', first_name2='', last_name2='', amount:float=0, track_type:TunableInstanceParam(sims4.resources.Types.STATISTIC)=None, _connection=None):
    info1 = services.sim_info_manager().get_sim_info_by_name(first_name1, last_name1)
    info2 = services.sim_info_manager().get_sim_info_by_name(first_name2, last_name2)
    if info1 is not None and info2 is not None:
        info1.relationship_tracker.add_relationship_score(info2.id, amount, track_type)
        return True
    return False
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:7,代码来源:relationship_commands.py

示例5: 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

示例6: _name_and_create_adoptee_gen

 def _name_and_create_adoptee_gen(self, timeline):
     adopted_sim_info = self.get_participant(ParticipantType.PickedSim)
     last_name = SimSpawner.get_family_name_for_gender(self.sim.account, self.sim.last_name, adopted_sim_info.is_female)
     result = yield self._do_renames_gen(timeline, (adopted_sim_info,), additional_tokens=(last_name,))
     if not result:
         return result
     adopted_sim_info = self.get_participant(ParticipantType.PickedSim)
     parent_a = self.sim.sim_info
     parent_b = services.sim_info_manager().get(parent_a.spouse_sim_id)
     adopted_sim_info.relationship_tracker._clear_relationships()
     for relation in FamilyRelationshipIndex:
         relation_id = adopted_sim_info.get_relation(relation)
         relation_info = services.sim_info_manager().get(relation_id)
         if relation_info is not None:
             adopted_sim_info.genealogy.remove_family_link(relation)
             family_relation = relation_info.genealogy.get_family_relationship_bit(adopted_sim_info.sim_id)
             relation_info.genealogy.clear_family_relation(family_relation)
             relation_info.relationship_tracker.destroy_relationship(adopted_sim_info.sim_id)
         adopted_sim_info.genealogy.clear_family_relation(relation)
     if adopted_sim_info.household is not parent_a.household:
         adopted_sim_info.household.remove_sim_info(adopted_sim_info)
     PregnancyTracker.initialize_sim_info(adopted_sim_info, parent_a, parent_b)
     adopted_sim_info.trait_tracker.remove_trait(self.adoption_trait)
     if adopted_sim_info.age == Age.BABY:
         adopted_sim_info.set_zone_on_spawn()
         create_and_place_baby(adopted_sim_info, ignore_daycare=True)
     else:
         SimSpawner.spawn_sim(adopted_sim_info, sim_position=self.sim.position)
     return True
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:29,代码来源:adoption.py

示例7: get_family_relationship_bit

    def get_family_relationship_bit(self, sim_id, output=None):
        sim_x = services.sim_info_manager().get(self._owner_id)
        sim_y = services.sim_info_manager().get(sim_id)
        if sim_y is None:
            if output is not None:
                output('Could not find sim_info for {}.'.format(sim_id))
            return

        def get_index():
            for (pair_x, pair_y) in itertools.product(ancestry_x, ancestry_y):
                while pair_x.sim_id == pair_y.sim_id:
                    return (pair_x.depth, pair_y.depth)
            return (None, None)

        ancestry_x = self.get_ancestor_family_tree()
        ancestry_y = sim_y.genealogy.get_ancestor_family_tree()
        (depth_x, depth_y) = get_index()
        if depth_x is None or depth_y is None:
            if sim_x.spouse_sim_id is not None and sim_x.spouse_sim_id == sim_y.sim_id:
                return FamilyRelationshipTuning.MATRIX[0][0]
            if output is not None:
                output('Sims {} and {} are not related.'.format(sim_x.full_name, sim_y.full_name))
            return
        bit = None
        if FamilyRelationshipTuning.MATRIX is not None:
            bit = FamilyRelationshipTuning.MATRIX[depth_x][depth_y]
        if bit is not None and output is not None:
            output('Sim {} is {} of Sim {}'.format(sim_x.full_name, bit, sim_y.full_name))
        return bit
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:29,代码来源:genealogy_tracker.py

示例8: __init__

 def __init__(self, *args, inherited_target_sim_info=None, reader=None, **kwargs):
     super().__init__(inherited_target_sim_info=inherited_target_sim_info, reader=reader, *args, **kwargs)
     self._required_target_sim_info = None
     self._actual_target_sim_info = None
     if reader is not None:
         required_sim_id = reader.read_uint64(self.REQUIRED_SIM_ID, 0)
         self._required_target_sim_info = services.sim_info_manager().get(required_sim_id)
         actual_sim_id = reader.read_uint64(self.ACTUAL_SIM_ID, 0)
         self._actual_target_sim_info = services.sim_info_manager().get(actual_sim_id)
     if self._required_target_sim_info is not None:
         return
     if self._target_option == SituationGoalSimTargetingOptions.PlayerChoice:
         return
     if self._target_option == SituationGoalSimTargetingOptions.Inherited:
         self._required_target_sim_info = inherited_target_sim_info
         return
     if self._target_option == SituationGoalSimTargetingOptions.DebugChoice:
         self._required_target_sim_info = inherited_target_sim_info
         return
     possible_sim_infos = []
     if self._situation is None or self._select_sims_outside_of_situation:
         for sim_info in services.sim_info_manager().instanced_sim_info_including_baby_gen():
             while self._can_sim_pass_test(sim_info, self._sim_info, inherited_target_sim_info):
                 possible_sim_infos.append(sim_info)
     else:
         for sim in self._situation.all_sims_in_situation_gen():
             while self._can_sim_pass_test(sim.sim_info, self._sim_info, inherited_target_sim_info):
                 possible_sim_infos.append(sim.sim_info)
     self._required_target_sim_info = random.choice(possible_sim_infos)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:29,代码来源:situation_goal_targeted_sim.py

示例9: on_loading_screen_animation_finished

 def on_loading_screen_animation_finished(self):
     logger.debug('on_loading_screen_animation_finished')
     services.game_clock_service().restore_saved_clock_speed()
     services.sim_info_manager().on_loading_screen_animation_finished()
     services.get_event_manager().process_events_for_household(
         test_events.TestEvent.SimTravel,
         services.active_household(),
         zone_id=self.id)
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:8,代码来源:zone.py

示例10: advance_game_time

def advance_game_time(hours:int=0, minutes:int=0, seconds:int=0, _connection=None):
    previous_time = services.time_service().sim_now
    services.game_clock_service().advance_game_time(hours=hours, minutes=minutes, seconds=seconds)
    new_time = services.time_service().sim_now
    services.sim_info_manager().auto_satisfy_sim_motives()
    output = sims4.commands.Output(_connection)
    output('previous time = {}'.format(previous_time))
    output('new time = {}'.format(new_time))
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:8,代码来源:clock_commands.py

示例11: on_enter

 def on_enter(self):
     super().on_enter()
     caches.skip_cache = False
     first_visit_to_zone = services.current_zone().is_first_visit_to_zone
     if services.game_clock_service(
     ).time_has_passed_in_world_since_zone_save() or first_visit_to_zone:
         services.sim_info_manager().run_preroll_autonomy(
             first_time_load_zone=first_visit_to_zone)
     return _ZoneSpinUpStateResult.DONE
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:9,代码来源:zone_spin_up_service.py

示例12: 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

示例13: set_score

def set_score(source_sim_id, target_sim_id, score, track_type, bidirectional:bool=True, _connection=None):
    source_sim_info = services.sim_info_manager().get(source_sim_id)
    if source_sim_info is None:
        sims4.commands.output("Source sim info doesn't exist in relationship.set_score", _connection)
        return False
    source_sim_info.relationship_tracker.set_relationship_score(target_sim_id, score, track_type)
    if bidirectional:
        target_sim_info = services.sim_info_manager().get(target_sim_id)
        if target_sim_info is None:
            sims4.commands.output("Target sim info doesn't exist in relationship.set_score", _connection)
            return False
        target_sim_info.relationship_tracker.set_relationship_score(source_sim_id, score, track_type)
    return True
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:13,代码来源:relationship_commands.py

示例14: create_relationship

def create_relationship(source_sim_id, *sim_id_list, _connection=None):
    if not source_sim_id:
        return False
    source_sim_info = services.sim_info_manager().get(source_sim_id)
    if source_sim_info is None:
        return False
    sim_id_list = _get_sim_ids_from_string_list(sim_id_list, _connection)
    if sim_id_list is None:
        return False
    sim_info_set = {services.sim_info_manager().get(sim_id) for sim_id in sim_id_list}
    for sim_info in sim_info_set:
        source_sim_info.relationship_tracker.create_relationship(sim_info.sim_id)
        sim_info.relationship_tracker.create_relationship(source_sim_info.sim_id)
    return True
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:14,代码来源:relationship_commands.py

示例15: generate_autonomy_timer_view_data

def generate_autonomy_timer_view_data(sim_id:int=None):
    autonomy_timer_data = []
    sim = None
    sim_info_manager = services.sim_info_manager()
    if sim_info_manager is None:
        return autonomy_timer_data
    for sim_info in services.sim_info_manager().objects:
        while sim_id == sim_info.sim_id:
            sim = sim_info.get_sim_instance()
            break
    if sim is not None:
        for timer in sim.debug_get_autonomy_timers_gen():
            entry = {'timer_name': timer[0], 'timer_value': timer[1]}
            autonomy_timer_data.append(entry)
    return autonomy_timer_data
开发者ID:johndpope,项目名称:sims4-ai-engine,代码行数:15,代码来源:sim_handlers.py


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