コード例 #1
0
 def _on_sim_return(self, canceled=False):
     receiver_sim_info = self._receiver_sim_info
     resolver = SingleSimResolver(receiver_sim_info)
     weights = []
     failure_outcomes = []
     for outcome in self.audition_outcomes:
         if canceled:
             if not outcome.is_success:
                 failure_outcomes.append(outcome)
                 weight = outcome.weight.get_multiplier(resolver)
                 if weight > 0:
                     weights.append((weight, outcome))
         else:
             weight = outcome.weight.get_multiplier(resolver)
             if weight > 0:
                 weights.append((weight, outcome))
     if failure_outcomes:
         selected_outcome = random.choice(failure_outcomes)
     else:
         selected_outcome = sims4.random.weighted_random_item(weights)
     if not selected_outcome:
         logger.error(
             'No valid outcome is tuned on this audition. Verify weights in audition_outcome for {}.',
             self.guid64)
         services.drama_scheduler_service().complete_node(self.uid)
         return
     if selected_outcome.is_success:
         receiver_sim_info.career_tracker.set_gig(self.gig,
                                                  self._calculated_gig_time)
     for loot in selected_outcome.loot_list:
         loot.apply_to_resolver(resolver)
     services.drama_scheduler_service().complete_node(self.uid)
コード例 #2
0
 def _disable_non_tutorial_functionality(self):
     services.drama_scheduler_service().set_enabled_state(False)
     npc_hosted_situation_service = services.npc_hosted_situation_service()
     if npc_hosted_situation_service is not None:
         npc_hosted_situation_service.suspend_welcome_wagon()
     if self._receiver_sim_info is not None:
         household = self._receiver_sim_info.household
         if household is not None:
             household.bills_manager.autopay_bills = True
         if self._sender_sim_info is not None:
             if self._receiver_sim_info.age == self._sender_sim_info.age:
                 receiver_age_progress = self._receiver_sim_info.age_progress
                 if receiver_age_progress <= self._sender_sim_info.age_progress:
                     if receiver_age_progress == 0:
                         self._receiver_sim_info.age_progress = 0.1
                     else:
                         self._sender_sim_info.age_progress = 0
             relationship_tracker = self._receiver_sim_info.relationship_tracker
             sender_id = self._sender_sim_info.sim_id
             relationship = services.relationship_service().create_relationship(self._receiver_sim_info.sim_id, sender_id)
             relationship_tracker.add_relationship_score(sender_id, self.friendship_value, RelationshipTrack.FRIENDSHIP_TRACK)
             relationship_tracker.add_relationship_score(sender_id, self.romance_value, RelationshipTrack.ROMANCE_TRACK)
             relationship.relationship_track_tracker.set_longterm_tracks_locked(True)
     weather_service = services.weather_service()
     if weather_service is not None:
         weather_service.force_start_weather_event(self.weather_to_force, None)
         weather_service.update_weather_type(during_load=True)
     fire_service = services.fire_service
     if fire_service is not None:
         fire_service.fire_enabled = False
コード例 #3
0
 def _handle_picker_dialog(self, dialog):
     if not dialog.accepted:
         with telemetry_helper.begin_hook(telemetry_writer, TELEMETRY_HOOK_SITUATION_REJECTED, sim_info=self._receiver_sim_info) as hook:
             hook.write_guid('type', self._situation_to_run.guid64)
     else:
         picked_sims = dialog.get_result_tags()
         self._create_situation(additional_sims_to_bring=picked_sims)
     services.drama_scheduler_service().complete_node(self.uid)
コード例 #4
0
 def on_shutdown(self):
     self._current_state.on_state_deactivated()
     self._current_state = None
     if self._drama_node_uid is not None:
         services.drama_scheduler_service().complete_node(
             self._drama_node_uid, from_shutdown=True)
     situation_manager = services.get_zone_situation_manager()
     for situation_id in self._festival_situations:
         situation_manager.destroy_situation_by_id(situation_id)
     for situation in situation_manager.get_situations_by_tags(
             self.cleanup_situation_tags):
         situation_manager.destroy_situation_by_id(situation.id)
コード例 #5
0
 def on_enter(self):
     super().on_enter()
     venue_service = services.venue_service()
     venue_service.setup_lot_premade_status()
     venue_service.make_venue_type_zone_director_request()
     situation_manager = services.get_zone_situation_manager()
     situation_manager.create_seeds_during_zone_spin_up()
     situation_manager.make_situation_seed_zone_director_requests()
     services.drama_scheduler_service().make_zone_director_requests()
     venue_service._select_zone_director()
     venue_service.determine_which_situations_to_load()
     return _ZoneSpinUpStateResult.DONE
コード例 #6
0
ファイル: club.py プロジェクト: NeonOcean/Environment
 def on_remove(self, from_stop=False):
     for member in list(self.members):
         self.remove_member(member,
                            distribute=False,
                            can_reassign_leader=False,
                            from_stop=from_stop)
     for criteria in list(self.membership_criteria):
         self.remove_membership_criteria(criteria)
     for rule in list(self.rules):
         self.remove_rule(rule)
     services.get_club_service().update_affordance_cache()
     for drama_node_id in self.club_joined_drama_node_ids:
         services.drama_scheduler_service().cancel_scheduled_node(
             drama_node_id)
     self.club_joined_drama_node_ids.clear()
コード例 #7
0
 def response(dialog):
     cleanup_node = True
     if dialog.response is not None and dialog.response == ButtonType.DIALOG_RESPONSE_OK:
         cleanup_node = False
         if situation_seed.zone_id == services.current_zone_id():
             situation_manager.create_situation_from_seed(
                 situation_seed)
             situation_manager.register_for_callback(
                 situation_seed.situation_id,
                 SituationCallbackOption.END_OF_SITUATION,
                 self._on_planned_drama_node_ended)
         else:
             situation_manager.travel_seed(situation_seed)
     if cleanup_node:
         services.drama_scheduler_service().complete_node(self.uid)
コード例 #8
0
 def activate_holiday(self, from_load=False, from_customization=False):
     if self._state >= HolidayState.RUNNING:
         logger.error(
             'Tradition {} is trying to be put into the Running state, but is already in {} which is farther along.',
             self, self._state)
         return
     self._deactivate_pre_holiday()
     self._state = HolidayState.RUNNING
     if self.holiday_buffs:
         services.sim_spawner_service().register_sim_spawned_callback(
             self.on_sim_spawned)
         for sim_info in services.sim_info_manager().instanced_sims_gen():
             for buff in self.holiday_buffs:
                 buff_handle = sim_info.add_buff(
                     buff, buff_reason=self.holiday_buff_reason)
                 if buff_handle is not None:
                     self._buffs_added[sim_info.sim_id].append(buff_handle)
     for (key, event) in enumerate(self.events):
         self._create_event_alarm(key, event)
     if not from_load:
         resolver = GlobalResolver()
         for actions in self.lifecycle_actions:
             actions.try_perform(
                 resolver, TraditionActivationEvent.TRADITION_ADD
                 if from_customization else
                 TraditionActivationEvent.HOLIDAY_ACTIVATE)
         if self.drama_nodes_to_score:
             sim_timeline = services.time_service().sim_timeline
             self._drama_node_processor = sim_timeline.schedule(
                 elements.GeneratorElement(self._process_scoring_gen))
         drama_scheduler = services.drama_scheduler_service()
         for drama_node in self.drama_nodes_to_run:
             drama_scheduler.run_node(drama_node, resolver)
コード例 #9
0
 def on_season_content_changed(self):
     drama_scheduler = services.drama_scheduler_service()
     drama_scheduler.cancel_scheduled_nodes_with_types(
         (HolidayService.CUSTOM_HOLIDAY_DRAMA_NODE, ))
     for drama_node in tuple(
             drama_scheduler.get_running_nodes_by_class(
                 HolidayService.CUSTOM_HOLIDAY_DRAMA_NODE)):
         if drama_node.is_running:
             continue
         drama_scheduler.complete_node(drama_node.uid)
     self._schedule_all_holidays()
     holidays = {}
     for drama_node in tuple(drama_scheduler.scheduled_nodes_gen()):
         if drama_node.drama_node_type != DramaNodeType.HOLIDAY:
             continue
         day = drama_node.day
         existing_node = holidays.get(day)
         if existing_node is None:
             holidays[day] = drama_node
         elif type(
                 existing_node) is HolidayService.CUSTOM_HOLIDAY_DRAMA_NODE:
             drama_scheduler.cancel_scheduled_node(drama_node.uid)
         else:
             drama_scheduler.cancel_scheduled_node(existing_node.uid)
             holidays[day] = drama_node
コード例 #10
0
 def cleanup_scheduled_or_active_events(self):
     drama_scheduler = services.drama_scheduler_service()
     persistence_service = services.get_persistence_service()
     for uid in self._organization_festival_events.keys():
         drama_scheduler.add_complete_callback(
             uid, self._reschedule_festival_org_event)
     cancelled_venue_event_nodes_uids = []
     for uid in self._organization_venue_events.keys():
         drama_node_inst = drama_scheduler.get_scheduled_node_by_uid(uid)
         if drama_node_inst is not None:
             zone_data = persistence_service.get_zone_proto_buff(
                 drama_node_inst.zone_id)
             if zone_data is None:
                 drama_scheduler.cancel_scheduled_node(uid)
                 cancelled_venue_event_nodes_uids.append(uid)
             else:
                 venue_tuning = services.venue_service().get_venue_tuning(
                     drama_node_inst.zone_id)
                 if venue_tuning is not self.get_organization_venue_tuning(
                         type(drama_node_inst)):
                     drama_scheduler.cancel_scheduled_node(uid)
                     cancelled_venue_event_nodes_uids.append(uid)
                 else:
                     drama_scheduler.add_complete_callback(
                         uid, self._reschedule_venue_org_event)
         else:
             drama_scheduler.add_complete_callback(
                 uid, self._reschedule_venue_org_event)
     for cancelled_node_uid in cancelled_venue_event_nodes_uids:
         if cancelled_node_uid in self._organization_venue_events:
             del self._organization_venue_events[cancelled_node_uid]
         self.remove_event_update(cancelled_node_uid)
コード例 #11
0
 def __call__(self):
     drama_scheduler = services.drama_scheduler_service()
     best_time = None
     best_nodes = [type(node) for node in drama_scheduler.active_nodes_gen() if node.drama_node_type == DramaNodeType.FESTIVAL]
     if not best_nodes:
         for node in drama_scheduler.scheduled_nodes_gen():
             if node.drama_node_type != DramaNodeType.FESTIVAL:
                 continue
             new_time = node._selected_time - services.time_service().sim_now
             if best_time is None or new_time < best_time:
                 best_nodes = [type(node)]
                 best_time = new_time
             elif new_time == best_time:
                 best_nodes.append(type(node))
     if not best_nodes:
         if self.negate:
             return TestResult.TRUE
         return TestResult(False, 'No scheduled Festivals.')
     if self.drama_node is None or self.drama_node in best_nodes:
         if self.negate:
             return TestResult(False, 'Next scheduled Festival matches requested.')
         return TestResult.TRUE
     if self.negate:
         return TestResult.TRUE
     return TestResult(False, "Next scheduled Festival doesn't match requested.")
コード例 #12
0
 def on_enter(self):
     super().on_enter()
     situation_manager = services.get_zone_situation_manager()
     situation_manager.create_situations_during_zone_spin_up()
     venue_service = services.current_zone().venue_service
     venue_service.create_situations_during_zone_spin_up()
     zone_director = venue_service.get_zone_director()
     if zone_director.open_street_director is not None:
         zone_director.open_street_director.create_situations_during_zone_spin_up(
         )
     services.get_career_service(
     ).create_career_event_situations_during_zone_spin_up()
     situation_manager.on_all_situations_created_during_zone_spin_up()
     services.drama_scheduler_service(
     ).on_situation_creation_during_zone_spin_up()
     return _ZoneSpinUpStateResult.DONE
コード例 #13
0
 def picker_rows_gen(cls, inst, target, context, **kwargs):
     inst_or_cls = inst if inst is not None else cls
     if inst_or_cls.use_only_scheduled:
         drama_nodes = iter(services.drama_scheduler_service().all_nodes_gen())
     else:
         drama_node_manager = services.get_instance_manager(sims4.resources.Types.DRAMA_NODE)
         drama_nodes = (drama_node() for drama_node in drama_node_manager.get_ordered_types())
     if inst_or_cls.buckets:
         picker_rows_by_bucket = defaultdict(list)
     else:
         picker_rows = list()
     for drama_node in drama_nodes:
         if drama_node.drama_node_type == DramaNodeType.PICKER:
             if inst_or_cls.buckets and drama_node.scoring and drama_node.scoring.bucket not in inst_or_cls.buckets:
                 continue
             result = drama_node.create_picker_row(owner=target, run_visibility_tests=inst_or_cls.run_visibility_tests, disable_row_if_visibily_tests_fail=inst_or_cls.disable_row_if_visibily_tests_fail)
             if result is not None:
                 if inst_or_cls.buckets:
                     picker_rows_by_bucket[drama_node.scoring.bucket].append(result)
                 else:
                     picker_rows.append(result)
     if inst_or_cls.buckets:
         for bucket in inst_or_cls.buckets:
             yield from picker_rows_by_bucket[bucket]
     else:
         yield from picker_rows
コード例 #14
0
def schedule_node(drama_node: TunableInstanceParam(
    sims4.resources.Types.DRAMA_NODE),
                  actor_sim_id: OptionalSimInfoParam = None,
                  target_sim_id: OptionalSimInfoParam = None,
                  days_from_now: int = None,
                  _connection=None):
    actor_sim_info = get_optional_target(actor_sim_id, _connection,
                                         OptionalSimInfoParam)
    if target_sim_id is not None:
        target_sim_info = get_optional_target(target_sim_id, _connection,
                                              OptionalSimInfoParam)
    else:
        target_sim_info = None
    specific_time = None
    if days_from_now is not None:
        scheduled_day = int(
            services.time_service().sim_now.absolute_days()) + days_from_now
        specific_time = create_date_and_time(days=scheduled_day)
    resolver = DoubleSimResolver(actor_sim_info, target_sim_info)
    uid = services.drama_scheduler_service().schedule_node(
        drama_node, resolver, specific_time=specific_time)
    if uid is not None:
        sims4.commands.output(
            'Successfully scheduled drama node: {}'.format(
                drama_node.__name__), _connection)
    else:
        sims4.commands.output(
            'Failed to scheduled drama node: {}'.format(drama_node.__name__),
            _connection)
コード例 #15
0
 def __call__(self):
     drama_scheduler = services.drama_scheduler_service()
     best_time = None
     for node in drama_scheduler.scheduled_nodes_gen():
         if node.drama_node_type != DramaNodeType.FESTIVAL:
             continue
         if not self.drama_node is None:
             if self.drama_node is type(node):
                 new_time = node.get_time_remaining()
                 if not best_time is None:
                     if new_time < best_time:
                         best_time = new_time
                 best_time = new_time
         new_time = node.get_time_remaining()
         if not best_time is None:
             if new_time < best_time:
                 best_time = new_time
         best_time = new_time
     if best_time is None:
         if not self.negate:
             return TestResult(False, 'No scheduled Festivals of type {}.', self.drama_node, tooltip=self.tooltip)
     elif best_time.in_hours() < self.max_time:
         if self.negate:
             return TestResult(False, 'Next scheduled Festival is within specified time', tooltip=self.tooltip)
     elif not self.negate:
         return TestResult(False, "Next scheduled Festival isn't within specified time", tooltip=self.tooltip)
     return TestResult.TRUE
コード例 #16
0
 def show_festival_info(cls):
     if cls.festival_dynamic_sign_info is None:
         return
     ui_info = cls.festival_dynamic_sign_info
     festival_info = UI_pb2.DynamicSignView()
     festival_info.drama_node_guid = cls.guid64
     festival_info.name = ui_info.festival_name
     lot_id = cls.get_travel_lot_id()
     persistence_service = services.get_persistence_service()
     zone_id = persistence_service.resolve_lot_id_into_zone_id(lot_id, ignore_neighborhood_id=True)
     zone_protobuff = persistence_service.get_zone_proto_buff(zone_id)
     if zone_protobuff is not None:
         festival_info.venue = LocalizationHelperTuning.get_raw_text(zone_protobuff.name)
     festival_info.time = ui_info.festival_time
     festival_info.image = sims4.resources.get_protobuff_for_key(ui_info.display_image)
     festival_info.background_image = sims4.resources.get_protobuff_for_key(ui_info.background_image)
     festival_info.action_label = ui_info.travel_to_festival_text
     running_nodes = services.drama_scheduler_service().get_running_nodes_by_class(cls)
     active_sim_info = services.active_sim_info()
     if all(active_node.is_during_pre_festival() for active_node in running_nodes):
         festival_info.disabled_tooltip = ui_info.festival_not_started_tooltip
     elif any(active_node.is_on_festival_street() for active_node in running_nodes):
         festival_info.disabled_tooltip = ui_info.on_street_tooltip
     elif active_sim_info.is_in_travel_group():
         festival_info.disabled_tooltip = ui_info.on_vacation_tooltip
     for activity in ui_info.activity_info:
         with ProtocolBufferRollback(festival_info.activities) as activity_msg:
             activity_msg.name = activity.activity_name
             activity_msg.description = activity.activity_description
             activity_msg.icon = create_icon_info_msg(IconInfoData(activity.icon))
     distributor = Distributor.instance()
     distributor.add_op(active_sim_info, GenericProtocolBufferOp(Operation.DYNAMIC_SIGN_VIEW, festival_info))
コード例 #17
0
 def _handle_dialog(self, dialog):
     if not dialog.accepted and dialog.response != NPCHostedSituationDialog.BRING_OTHER_SIMS_RESPONSE_ID:
         with telemetry_helper.begin_hook(telemetry_writer, TELEMETRY_HOOK_SITUATION_REJECTED, sim_info=self._receiver_sim_info) as hook:
             hook.write_guid(TELEMETRY_SITUATION_TYPE_ID, self._situation_to_run.guid64)
         services.drama_scheduler_service().complete_node(self.uid)
         return
     if dialog.response == NPCHostedSituationDialog.BRING_OTHER_SIMS_RESPONSE_ID:
         bring_other_sims_data = self._chosen_dialog.bring_other_sims
         picker_dialog = bring_other_sims_data.picker_dialog(self._receiver_sim_info, resolver=self._get_resolver())
         blacklist = {sim_info.id for sim_info in self._sender_sim_info.household.sim_info_gen()}
         blacklist.add(self._receiver_sim_info.id)
         results = services.sim_filter_service().submit_filter(bring_other_sims_data.travel_with_filter, callback=None, requesting_sim_info=self._receiver_sim_info, blacklist_sim_ids=blacklist, allow_yielding=False, gsi_source_fn=self.get_sim_filter_gsi_name)
         for result in results:
             picker_dialog.add_row(SimPickerRow(result.sim_info.sim_id, tag=result.sim_info))
         picker_dialog.show_dialog(on_response=self._handle_picker_dialog)
         return
     self._create_situation()
     services.drama_scheduler_service().complete_node(self.uid)
コード例 #18
0
 def _process_scoring_gen(self, timeline):
     try:
         yield from services.drama_scheduler_service().score_and_schedule_nodes_gen(self.additional_drama_nodes, 1, street_override=self.street, timeline=timeline)
     except GeneratorExit:
         raise
     except Exception as exception:
         logger.exception('Exception while scoring DramaNodes: ', exc=exception, level=sims4.log.LEVEL_ERROR)
     finally:
         self._additional_nodes_processor = None
コード例 #19
0
 def on_all_households_and_sim_infos_loaded(self, client):
     save_slot_data_msg = services.get_persistence_service().get_save_slot_proto_buff()
     if save_slot_data_msg.trigger_tutorial_drama_node:
         save_slot_data_msg.trigger_tutorial_drama_node = False
         drama_scheduler = services.drama_scheduler_service()
         if drama_scheduler is not None:
             resolver = SingleSimResolver(services.active_sim_info())
             drama_scheduler.run_node(self.TUTORIAL_DRAMA_NODE, resolver)
     self._tutorial_mode = save_slot_data_msg.tutorial_mode
コード例 #20
0
 def set_tutorial_mode(self, mode):
     save_slot_data_msg = services.get_persistence_service().get_save_slot_proto_buff()
     save_slot_data_msg.tutorial_mode = mode
     self._tutorial_mode = mode
     if mode != TutorialMode.FTUE:
         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:
                 drama_nodes[0].end()
コード例 #21
0
 def on_sim_added(self, sim_info):
     if self._active_holiday_id is None:
         return
     drama_scheduler = services.drama_scheduler_service()
     for drama_node in drama_scheduler.active_nodes_gen():
         if drama_node.drama_node_type != DramaNodeType.HOLIDAY:
             continue
         if drama_node.holiday_id != self._active_holiday_id:
             continue
         drama_node.on_sim_added(sim_info)
コード例 #22
0
def cancel_scheduled_node(drama_node_uid: int, _connection=None):
    success = services.drama_scheduler_service().cancel_scheduled_node(
        drama_node_uid)
    if success:
        sims4.commands.output(
            'Successfully cancelled scheduled drama node id: {}'.format(
                drama_node_uid), _connection)
    else:
        sims4.commands.output(
            'Failed to cancel scheduled drama node id: {}'.format(
                drama_node_uid), _connection)
コード例 #23
0
 def _reschedule_org_event(self, drama_node, **setup_kwargs):
     drama_scheduler = services.drama_scheduler_service()
     if drama_scheduler is None:
         return
     resolver = drama_node._get_resolver()
     next_time = self.verify_valid_time(drama_node)
     uid = drama_scheduler.schedule_node(type(drama_node),
                                         resolver,
                                         specific_time=next_time,
                                         update_org_panel_immediately=True,
                                         setup_kwargs=setup_kwargs)
     return uid
コード例 #24
0
 def _apply_to_subject_and_target(self, subject, target, resolver):
     receiver = resolver.get_participant(self._receiver_type)
     sender = resolver.get_participant(
         self._sender_type) if self._sender_type is not None else None
     dss = services.drama_scheduler_service()
     for node in tuple(dss.scheduled_nodes_gen()):
         sender_passed = self._sender_type is None or node.get_sender_sim_info(
         ) is sender
         if type(node) in self._drama_nodes:
             if node.get_receiver_sim_info() is receiver:
                 if sender_passed:
                     dss.cancel_scheduled_node(node.uid)
コード例 #25
0
 def _end_lottery(self, _):
     try:
         if not self._lottery_sims:
             return
         lottery_candidates = []
         active_household_candidates = []
         sim_info_manager = services.sim_info_manager()
         for sim_id in self._lottery_sims:
             sim_info = sim_info_manager.get(sim_id)
             if sim_info is None:
                 continue
             lottery_candidates.append(sim_info)
             if sim_info.is_selectable:
                 active_household_candidates.append(sim_info)
         if len(lottery_candidates) < self.minimum_sims:
             sims_to_get = self.minimum_sims - len(lottery_candidates)
             additional_candidates = [
                 sim_info for sim_info in sim_info_manager.values()
                 if self._check_lottery_sim_criteria(sim_info)
             ]
             if len(additional_candidates) < sims_to_get:
                 lottery_candidates.extend(additional_candidates)
             else:
                 lottery_candidates.extend(
                     random.sample(additional_candidates, sims_to_get))
         winning_sim_info = random.choice(lottery_candidates)
         winning_sim_info.household.funds.add(
             self.payout, Consts_pb2.FUNDS_HOLIDAY_LOTTERY)
         notification = self.notification(services.active_sim_info())
         notification.show_dialog(additional_tokens=(winning_sim_info, ))
         if winning_sim_info.is_selectable:
             resolver = SingleSimResolver(winning_sim_info)
             self.winning_sim_loot.apply_to_resolver(resolver)
         else:
             for sim_info in active_household_candidates:
                 resolver = SingleSimResolver(sim_info)
                 self.losing_sim_loot.apply_to_resolver(resolver)
     finally:
         services.drama_scheduler_service().complete_node(self.uid)
コード例 #26
0
 def _run_interaction_gen(self, timeline):
     if self.to_zone_id == services.current_zone_id():
         yield
     additional_sims = list(self._care_dependents)
     if self.sim.is_selectable:
         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(
                 )
                 housemate_sim = housemate_sim_info.get_sim_instance(
                     allow_hidden_flags=ALL_HIDDEN_REASONS)
                 if housemate_sim is not None and housemate_sim is not self.sim:
                     additional_sims.append(housemate_sim)
     selectable_sim_infos = services.get_selectable_sims()
     selectable_sims = selectable_sim_infos.get_instanced_sims(
         allow_hidden_flags=ALL_HIDDEN_REASONS)
     if self.sim.is_human:
         if sum(1 for sim in selectable_sims if sim.is_human
                if sim.sim_info.is_child_or_older) == 1:
             additional_sims.extend(
                 [sim for sim in selectable_sims if sim.is_pet])
         familiar_tracker = self.sim.sim_info.familiar_tracker
         if familiar_tracker is not None:
             active_familiar = familiar_tracker.get_active_familiar()
             if active_familiar is not None and active_familiar.is_sim:
                 additional_sims.append(active_familiar)
     travel_liability = TravelSimLiability(
         self,
         self.sim.sim_info,
         self.to_zone_id,
         is_attend_career=self.attend_career,
         additional_sims=additional_sims)
     for next_sim_info in selectable_sim_infos:
         next_sim = next_sim_info.get_sim_instance(
             allow_hidden_flags=ALL_HIDDEN_REASONS)
         if next_sim is None:
             continue
         if next_sim is self.sim:
             continue
         if next_sim in additional_sims:
             continue
         self.add_liability(TRAVEL_SIM_LIABILITY, travel_liability)
         break
     else:
         travel_liability.travel_player()
コード例 #27
0
def travel_to_event_zone(drama_node:TunableInstanceParam(sims4.resources.Types.DRAMA_NODE), _connection=None):
    if drama_node.drama_node_type == DramaNodeType.FESTIVAL:
        drama_node.travel_to_festival()
        return
    if drama_node.drama_node_type == DramaNodeType.VENUE_EVENT:
        drama_scheduler = services.drama_scheduler_service()
        if drama_scheduler is None:
            logger.error("Failed to run 'travel_to_event_zone' for ({}) because drama scheduler is not initiated.", str(drama_node))
        active_drama_nodes = [node for node in drama_scheduler.active_nodes_gen() if node.guid64 == drama_node.guid64]
        if not active_drama_nodes:
            logger.error("Failed to run 'travel_to_event_zone' for ({}), there is no event of that type active.")
            return
        active_drama_nodes[0].travel_to_venue()
        return
    logger.error("Unsupported drama node type({}) for 'travel to event zone. Travel cancelled for ({})", str(drama_node.drama_node_type), str(drama_node))
コード例 #28
0
 def _apply_to_subject_and_target(self, subject, target, resolver):
     running_contests = services.drama_scheduler_service(
     ).get_running_nodes_by_drama_node_type(DramaNodeType.FESTIVAL)
     for contest in running_contests:
         if hasattr(contest, 'festival_contest_tuning'):
             if contest.festival_contest_tuning is None:
                 continue
             if contest.is_during_pre_festival():
                 continue
             show_fallback_dialog = contest.has_user_submitted_entry(
             ) if self._skip_if_no_entry else True
             contest.award_winners(
                 show_fallback_dialog=show_fallback_dialog)
             return
     logger.error(
         'No festival contest is currently running, cannot award winners')
コード例 #29
0
 def remove_a_holiday(self, holiday_id):
     drama_scheduler_service = services.drama_scheduler_service()
     for drama_node in tuple(drama_scheduler_service.scheduled_nodes_gen()):
         if drama_node.drama_node_type != DramaNodeType.HOLIDAY:
             continue
         if drama_node.holiday_id != holiday_id:
             continue
         drama_scheduler_service.cancel_scheduled_node(drama_node.uid)
     for drama_node in tuple(drama_scheduler_service.active_nodes_gen()):
         if drama_node.drama_node_type != DramaNodeType.HOLIDAY:
             continue
         if drama_node.holiday_id != holiday_id:
             continue
         drama_scheduler_service.complete_node(drama_node.uid)
     for holiday_year_data in self._holiday_times.values():
         holiday_year_data.remove_holiday(holiday_id)
     if holiday_id in self._holidays:
         del self._holidays[holiday_id]
コード例 #30
0
 def on_all_households_and_sim_infos_loaded(self, client):
     holiday_ids_to_ignore = {
         drama_node.holiday_id
         for drama_node in
         services.drama_scheduler_service().all_nodes_gen()
         if type(drama_node) is HolidayService.CUSTOM_HOLIDAY_DRAMA_NODE
     }
     if not self._holiday_times:
         for season_length in SeasonLength:
             self._holiday_times[season_length] = YearOfHolidays(
                 season_length)
         for (season_type, season_content
              ) in services.season_service().get_four_seasons():
             for (season_length, holiday,
                  day_of_season) in season_content.get_all_holiday_data():
                 self._holiday_times[season_length].add_holiday(
                     season_type, day_of_season, holiday.guid64)
     self._schedule_all_holidays(holiday_ids_to_ignore)