def _trigger_podium_call_to_action(self):
     if services.current_zone(
     ).active_household_changed_between_save_and_load(
     ) or services.current_zone().time_has_passed_in_world_since_zone_save(
     ):
         self._cta_disabled = False
     if self._cta_disabled:
         return
     if self._has_cta_been_seen or self._business_manager.is_active_household_and_zone(
     ):
         return
     services.call_to_action_service().begin(self.podium_call_to_action,
                                             self)
     self._has_cta_been_seen = True
Ejemplo n.º 2
0
 def on_add(self):
     super().on_add()
     self._add_to_world()
     self.register_on_location_changed(self._location_changed)
     if self.is_fire_related_object:
         fire_service = services.get_fire_service()
         self.register_on_location_changed(fire_service.flammable_object_location_changed)
     posture_graph_service = services.posture_graph_service()
     if posture_graph.is_object_mobile_posture_compatible(self):
         self.register_on_location_changed(posture_graph_service.mobile_posture_object_location_changed)
     if self.provided_mobile_posture_affordances:
         posture_graph_service.add_mobile_posture_provider(self)
     services.call_to_action_service().object_created(self)
     self.try_mark_as_new_object()
Ejemplo n.º 3
0
 def _start_call_to_actions(self):
     if BaseCivicPolicyProvider.CALL_TO_ACTIONS:
         if self._call_to_actions_needed:
             call_to_action_service = services.call_to_action_service()
             for call_to_action_fact in BaseCivicPolicyProvider.CALL_TO_ACTIONS:
                 call_to_action_service.begin(call_to_action_fact, None)
             self._call_to_actions_needed = False
Ejemplo n.º 4
0
 def on_activate(self, reader=None):
     super().on_activate(reader=reader)
     if reader is not None:
         self._ended_cta_ids = list(reader.read_uint64s(SITUATIONSTATE_ENDED_CTA_TOKEN, ()))
     call_to_action_service = services.call_to_action_service()
     for call_to_action_fact in self._call_to_actions:
         if call_to_action_fact.guid64 not in self._ended_cta_ids:
             call_to_action_service.begin(call_to_action_fact, self)
Ejemplo n.º 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)
Ejemplo n.º 6
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)
Ejemplo n.º 7
0
 def _do_behavior(self):
     participant = self.interaction.get_participant(self._participant)
     if participant is not None and participant.sim_info.is_selectable:
         services.call_to_action_service().abort(self._call_to_action, self._permanent)
Ejemplo n.º 8
0
 def _clean_up(self):
     call_to_action_service = services.call_to_action_service()
     for call_to_action_fact in self._call_to_actions:
         call_to_action_service.end(call_to_action_fact)
     super()._clean_up()
Ejemplo n.º 9
0
 def on_startup(self):
     super().on_startup()
     call_to_action_service = services.call_to_action_service()
     for call_to_action_fact in self._call_to_actions:
         if call_to_action_fact.guid64 not in self._ended_cta_ids:
             call_to_action_service.begin(call_to_action_fact, self)
Ejemplo n.º 10
0
 def on_deactivate(self):
     call_to_action_service = services.call_to_action_service()
     for call_to_action_fact in self._call_to_actions:
         call_to_action_service.end(call_to_action_fact)
     super().on_deactivate()