コード例 #1
0
ファイル: client.py プロジェクト: NeonOcean/Environment
 def _get_selector_visual_type(self, sim_info):
     if sim_info.is_baby:
         return (Sims_pb2.SimPB.BABY, None)
     if sim_info.is_toddler and services.daycare_service(
     ).is_sim_info_at_daycare(sim_info):
         return (Sims_pb2.SimPB.AT_DAYCARE, None)
     if sim_info.household.missing_pet_tracker.is_pet_missing(sim_info):
         return (Sims_pb2.SimPB.PET_MISSING, None)
     sim = sim_info.get_sim_instance(allow_hidden_flags=ALL_HIDDEN_REASONS)
     for career in sim_info.careers.values():
         if career.currently_at_work:
             if career.is_at_active_event and sim is None:
                 return (Sims_pb2.SimPB.MISSING_ACTIVE_WORK,
                         career.career_category)
             return (Sims_pb2.SimPB.AT_WORK, career.career_category)
         if career.is_late:
             if not career.taking_day_off:
                 return (Sims_pb2.SimPB.LATE_FOR_WORK,
                         career.career_category)
     if services.get_rabbit_hole_service(
     ).should_override_selector_visual_type(sim_info.id):
         return (Sims_pb2.SimPB.OTHER, None)
     if sim is not None and sim.has_hidden_flags(
             HiddenReasonFlag.RABBIT_HOLE):
         return (Sims_pb2.SimPB.OTHER, None)
     if services.hidden_sim_service().is_hidden(sim_info.id):
         return (Sims_pb2.SimPB.OTHER, None)
     tutorial_service = services.get_tutorial_service()
     if tutorial_service is not None and tutorial_service.is_sim_unselectable(
             sim_info):
         return (Sims_pb2.SimPB.OTHER, None)
     return (Sims_pb2.SimPB.NORMAL, None)
コード例 #2
0
 def _get_appropriate_autonomy_setting(self, setting_class):
     autonomy_service = services.autonomy_service()
     setting = autonomy_service.global_autonomy_settings.get_setting(
         setting_class, self.get_autonomy_settings_group())
     if setting != setting_class.UNDEFINED:
         return setting
     if self._role_tracker is not None:
         setting = self._role_tracker.get_autonomy_state()
         if setting != setting_class.UNDEFINED:
             return setting
     if services.current_zone().is_zone_running:
         tutorial_service = services.get_tutorial_service()
         if tutorial_service is not None and tutorial_service.is_tutorial_running(
         ):
             return autonomy.settings.AutonomyState.FULL
     setting = self._autonomy_settings.get_setting(
         setting_class, self.get_autonomy_settings_group())
     if setting != setting_class.UNDEFINED:
         return setting
     household = self.owner.household
     if household:
         setting = household.autonomy_settings.get_setting(
             setting_class, self.get_autonomy_settings_group())
         if setting != setting_class.UNDEFINED:
             return setting
     setting = autonomy_service.default_autonomy_settings.get_setting(
         setting_class, self.get_autonomy_settings_group())
     if setting == setting_class.UNDEFINED:
         logger.error('Sim {} has an UNDEFINED autonomy setting!',
                      self.owner,
                      owner='rez')
     return setting
コード例 #3
0
 def complete_milestone(self, achievement, sim_info):
     super().complete_milestone(achievement, sim_info)
     if paths.IS_DESKTOP:
         tutorial_service = services.get_tutorial_service()
         if tutorial_service is None or not tutorial_service.is_tutorial_running():
             if achievement.screen_slam is not None:
                 achievement.screen_slam.send_screen_slam_message(sim_info, achievement.display_name)
             achievement.show_achievement_notification(sim_info)
     if achievement.reward is not None:
         achievement.reward.give_reward(sim_info)
     services.get_event_manager().process_event(test_events.TestEvent.UnlockEvent, sim_info=sim_info, unlocked=achievement)
コード例 #4
0
ファイル: skill.py プロジェクト: NeonOcean/Environment
 def _show_level_notification(self, skill_level, ignore_npc_check=False):
     sim_info = self._tracker._owner
     if not (ignore_npc_check or not sim_info.is_npc):
         if skill_level == 1:
             tutorial_service = services.get_tutorial_service()
             if tutorial_service is not None and tutorial_service.is_tutorial_running():
                 return
         level_data = self._get_level_data_for_skill_level(skill_level)
         if level_data is not None:
             tutorial_id = None
             if self.tutorial is not None:
                 if skill_level == 1:
                     tutorial_id = self.tutorial.guid64
             notification = level_data.level_up_notification(sim_info, resolver=SingleSimResolver(sim_info))
             notification.show_dialog(icon_override=IconInfoData(icon_resource=self.icon), secondary_icon_override=IconInfoData(obj_instance=sim_info), additional_tokens=(skill_level,), tutorial_id=tutorial_id)
             if level_data.level_up_screen_slam is not None:
                 level_data.level_up_screen_slam.send_screen_slam_message(sim_info, sim_info, self.stat_name, skill_level)
コード例 #5
0
 def deactivate(cls):
     tutorial_service = services.get_tutorial_service()
     client = services.client_manager().get_first_client()
     if cls.gameplay_test is not None:
         services.get_event_manager().unregister_tests(
             cls, (cls.gameplay_test, ))
     if cls.satisfy_on_active_sim_change and client is not None:
         client.unregister_active_sim_changed(cls._on_active_sim_change)
     if cls.restricted_affordances is not None and tutorial_service is not None:
         tutorial_service.clear_restricted_affordances()
     if cls.call_to_actions is not None:
         call_to_action_service = services.call_to_action_service()
         for call_to_action_fact in cls.call_to_actions:
             call_to_action_service.end(call_to_action_fact)
     if cls.buffs_removed_on_deactivate:
         actor_sim_info = None
         if client is not None:
             actor_sim_info = client.active_sim.sim_info
         drama_scheduler = services.drama_scheduler_service()
         if drama_scheduler is not None:
             drama_nodes = drama_scheduler.get_running_nodes_by_drama_node_type(
                 DramaNodeType.TUTORIAL)
             if drama_nodes:
                 tutorial_drama_node = drama_nodes[0]
                 if cls.sim_actor == TutorialTipActorOption.PLAYER_SIM:
                     actor_sim_info = tutorial_drama_node.get_player_sim_info(
                     )
                 elif cls.sim_actor == TutorialTipActorOption.HOUSEMATE_SIM:
                     actor_sim_info = tutorial_drama_node.get_housemate_sim_info(
                     )
         if actor_sim_info is not None:
             for buff_ref in cls.buffs:
                 actor_sim_info.remove_buff_by_type(buff_ref.buff_type)
     if cls.time_of_day is not None and tutorial_service is not None:
         tutorial_service.remove_tutorial_alarm(cls)
     if cls.make_housemate_unselectable and tutorial_service is not None:
         tutorial_service.set_unselectable_sim(None)
コード例 #6
0
def set_tutorial_mode(mode: int = 0, _connection=None):
    tutorial_service = services.get_tutorial_service()
    if tutorial_service is not None:
        tutorial_service.set_tutorial_mode(mode)
    return True
コード例 #7
0
ファイル: aspirations.py プロジェクト: NeonOcean/Environment
 def complete_milestone(self, aspiration, sim_info):
     aspiration_type = aspiration.aspiration_type
     if aspiration_type == AspriationType.FULL_ASPIRATION:
         if aspiration.is_child_aspiration and not sim_info.is_child:
             return
         super().complete_milestone(aspiration, sim_info)
         if aspiration.reward is not None:
             aspiration.reward.give_reward(sim_info)
         track = self.active_track
         if track is None:
             if not sim_info.is_toddler:
                 logger.error(
                     'Active track is None when completing full aspiration {} for sim {}.',
                     aspiration, sim_info)
             return
         if aspiration.screen_slam is not None:
             if aspiration in track.aspirations.values():
                 aspiration.screen_slam.send_screen_slam_message(
                     sim_info, sim_info, aspiration.display_name,
                     track.display_text)
             else:
                 aspiration.screen_slam.send_screen_slam_message(
                     sim_info, sim_info, aspiration.display_name)
         if aspiration in track.aspirations.values():
             self._check_and_complete_aspiration_track(
                 track, aspiration, sim_info)
             aspiration.apply_on_complete_loot_actions(sim_info)
             next_aspiration = track.get_next_aspriation(aspiration)
             if next_aspiration is not None:
                 for objective in next_aspiration.objectives:
                     if objective.set_starting_point(self.data_object):
                         self.update_objective(
                             objective, 0, objective.goal_value(),
                             objective.is_goal_value_money)
                 self._activate_aspiration(next_aspiration)
             else:
                 self._active_aspiration = None
             with telemetry_helper.begin_hook(
                     writer,
                     TELEMETRY_HOOK_COMPLETE_MILESTONE,
                     sim=sim_info.get_sim_instance()) as hook:
                 hook.write_enum('type', aspiration.aspiration_type)
                 hook.write_guid('guid', aspiration.guid64)
         services.get_event_manager().process_event(
             test_events.TestEvent.UnlockEvent,
             sim_info=sim_info,
             unlocked=aspiration)
     elif aspiration_type == AspriationType.FAMILIAL:
         super().complete_milestone(aspiration, sim_info)
         for relationship in aspiration.target_family_relationships:
             family_member_sim_id = sim_info.get_relation(relationship)
             family_member_sim_info = services.sim_info_manager().get(
                 family_member_sim_id)
             if family_member_sim_info is not None:
                 services.get_event_manager().process_event(
                     test_events.TestEvent.FamilyTrigger,
                     sim_info=family_member_sim_info,
                     trigger=aspiration)
     elif aspiration_type == AspriationType.WHIM_SET:
         self._whimsets_to_reset.add(aspiration)
         super().complete_milestone(aspiration, sim_info)
         whim_tracker = sim_info.whim_tracker
         if whim_tracker is not None:
             whim_tracker.activate_whimset_from_objective_completion(
                 aspiration)
     elif aspiration_type == AspriationType.NOTIFICATION:
         tutorial_service = services.get_tutorial_service()
         if tutorial_service is None or not tutorial_service.is_tutorial_running(
         ):
             dialog = aspiration.notification(sim_info,
                                              SingleSimResolver(sim_info))
             dialog.show_dialog(event_id=aspiration.guid64)
         super().complete_milestone(aspiration, sim_info)
     elif aspiration_type == AspriationType.ASSIGNMENT:
         super().complete_milestone(aspiration, sim_info)
         aspiration.satisfy_assignment(sim_info)
     elif aspiration_type == AspriationType.GIG:
         super().complete_milestone(aspiration, sim_info)
         aspiration.satisfy_assignment(sim_info)
     elif aspiration_type == AspriationType.ZONE_DIRECTOR:
         super().complete_milestone(aspiration, sim_info)
         zone_director = services.venue_service().get_zone_director()
         zone_director.on_zone_director_aspiration_completed(
             aspiration, sim_info)
     elif aspiration_type == AspriationType.TIMED_ASPIRATION:
         super().complete_milestone(aspiration, sim_info)
         self._timed_aspirations[aspiration].complete()
     elif aspiration_type == AspriationType.CAREER:
         super().complete_milestone(aspiration, sim_info)
         if aspiration.screen_slam is not None:
             aspiration.screen_slam.send_screen_slam_message(
                 sim_info, sim_info)
     else:
         super().complete_milestone(aspiration, sim_info)
コード例 #8
0
 def activate(cls):
     tutorial_service = services.get_tutorial_service()
     client = services.client_manager().get_first_client()
     actor_sim_info = client.active_sim.sim_info
     target_sim_info = actor_sim_info
     housemate_sim_info = None
     tutorial_drama_node = None
     drama_scheduler = services.drama_scheduler_service()
     if drama_scheduler is not None:
         drama_nodes = drama_scheduler.get_running_nodes_by_drama_node_type(
             DramaNodeType.TUTORIAL)
         if drama_nodes:
             tutorial_drama_node = drama_nodes[0]
             housemate_sim_info = tutorial_drama_node.get_housemate_sim_info(
             )
             player_sim_info = tutorial_drama_node.get_player_sim_info()
             if cls.sim_actor == TutorialTipActorOption.PLAYER_SIM:
                 actor_sim_info = player_sim_info
             elif cls.sim_actor == TutorialTipActorOption.HOUSEMATE_SIM:
                 actor_sim_info = housemate_sim_info
             if cls.sim_target == TutorialTipActorOption.PLAYER_SIM:
                 target_sim_info = player_sim_info
             elif cls.sim_target == TutorialTipActorOption.HOUSEMATE_SIM:
                 target_sim_info = housemate_sim_info
     if cls.gameplay_immediate_test is not None:
         resolver = event_testing.resolver.SingleSimResolver(actor_sim_info)
         if resolver(cls.gameplay_immediate_test):
             cls.satisfy()
         else:
             return
     for buff_ref in cls.buffs:
         actor_sim_info.add_buff_from_op(buff_ref.buff_type,
                                         buff_reason=buff_ref.buff_reason)
     if cls.gameplay_test is not None:
         services.get_event_manager().register_tests(
             cls, [cls.gameplay_test])
     if cls.satisfy_on_active_sim_change:
         client = services.client_manager().get_first_client()
         if client is not None:
             client.register_active_sim_changed(cls._on_active_sim_change)
     if cls.commodities_to_solve:
         actor_sim = actor_sim_info.get_sim_instance()
         if actor_sim is not None:
             context = InteractionContext(
                 actor_sim,
                 InteractionContext.SOURCE_SCRIPT_WITH_USER_INTENT,
                 priority.Priority.High,
                 bucket=InteractionBucketType.DEFAULT)
             for commodity in cls.commodities_to_solve:
                 if not actor_sim.queue.can_queue_visible_interaction():
                     break
                 autonomy_request = autonomy.autonomy_request.AutonomyRequest(
                     actor_sim,
                     autonomy_mode=autonomy.autonomy_modes.FullAutonomy,
                     commodity_list=(commodity, ),
                     context=context,
                     consider_scores_of_zero=True,
                     posture_behavior=AutonomyPostureBehavior.
                     IGNORE_SI_STATE,
                     distance_estimation_behavior=
                     AutonomyDistanceEstimationBehavior.
                     ALLOW_UNREACHABLE_LOCATIONS,
                     allow_opportunity_cost=False,
                     autonomy_mode_label_override='Tutorial')
                 selected_interaction = services.autonomy_service(
                 ).find_best_action(autonomy_request)
                 AffordanceObjectPair.execute_interaction(
                     selected_interaction)
     if cls.gameplay_loots:
         resolver = DoubleSimResolver(actor_sim_info, target_sim_info)
         for loot_action in cls.gameplay_loots:
             loot_action.apply_to_resolver(resolver)
     if cls.restricted_affordances is not None and tutorial_service is not None:
         tutorial_service.set_restricted_affordances(
             cls.restricted_affordances.visible_affordances,
             cls.restricted_affordances.tooltip,
             cls.restricted_affordances.enabled_affordances)
     if cls.call_to_actions is not None:
         call_to_action_service = services.call_to_action_service()
         for call_to_action_fact in cls.call_to_actions:
             call_to_action_service.begin(call_to_action_fact, None)
     if cls.add_target_to_actor_household:
         household_manager = services.household_manager()
         household_manager.switch_sim_household(target_sim_info)
     if cls.make_housemate_unselectable and tutorial_service is not None:
         tutorial_service.set_unselectable_sim(housemate_sim_info)
     if cls.end_drama_node and tutorial_drama_node is not None:
         tutorial_drama_node.end()
     if cls.time_of_day is not None and tutorial_service is not None:
         tutorial_service.add_tutorial_alarm(cls, lambda _: cls.satisfy(),
                                             cls.time_of_day)