Пример #1
0
 def picker_rows_gen(cls, inst, target, context, **kwargs):
     inst_or_cls = inst if inst is not None else cls
     actor = inst_or_cls.get_participant(
         sim=context.sim,
         target=target,
         participant_type=ParticipantType.Actor,
         **kwargs)
     familiar_tracker = actor.sim_info.familiar_tracker
     if familiar_tracker is not None:
         rabbit_hole_service = services.get_rabbit_hole_service()
         current_region = services.current_region()
         sim_info_manager = services.sim_info_manager()
         for familiar_info in familiar_tracker:
             is_enable = True
             row_tooltip = None
             if rabbit_hole_service.is_in_rabbit_hole(
                     familiar_info.pet_familiar_id):
                 is_enable = False
                 row_tooltip = inst_or_cls.rabbit_holed_disabled_tooltip
             else:
                 pet_familiar = sim_info_manager.get(
                     familiar_info.pet_familiar_id)
                 sim_region = region.get_region_instance_from_zone_id(
                     pet_familiar.zone_id)
                 is_enable = False
                 row_tooltip = inst_or_cls.incompatible_region_disabled_tooltip
             row = BasePickerRow(name=familiar_info.name,
                                 icon_info=familiar_info.icon_info,
                                 tag=familiar_info.uid,
                                 is_enable=is_enable,
                                 row_tooltip=row_tooltip)
             yield row
Пример #2
0
 def fishing_data(self):
     if self._fishing_data is self.USE_REGION_TUNING:
         current_region = services.current_region()
         if current_region is not None:
             return current_region.fishing_data
         return
     return self._fishing_data
Пример #3
0
    def get_hangout_zone_id(self, prefer_current=False):
        if self.hangout_setting == ClubHangoutSetting.HANGOUT_NONE:
            return 0
        if self.hangout_setting == ClubHangoutSetting.HANGOUT_VENUE:
            current_region = services.current_region()

            def is_valid_zone_id(zone_id):
                if not self.is_zone_valid_for_gathering(zone_id):
                    return False
                zone_region = get_region_instance_from_zone_id(zone_id)
                if zone_region is None:
                    return False
                elif not current_region.is_region_compatible(zone_region):
                    return False
                return True

            venue_service = services.venue_service()
            available_zone_ids = tuple(
                filter(
                    is_valid_zone_id,
                    venue_service.get_zones_for_venue_type_gen(
                        self.hangout_venue)))
            for venue in self.hangout_venue.included_venues_for_club_gathering:
                included_zone_ids = tuple(
                    filter(is_valid_zone_id,
                           venue_service.get_zones_for_venue_type_gen(venue)))
                available_zone_ids += included_zone_ids
            if not available_zone_ids:
                return 0
            if prefer_current:
                current_zone_id = services.current_zone_id()
                if current_zone_id in available_zone_ids:
                    return current_zone_id
            return random.choice(available_zone_ids)
        return self.hangout_zone_id
Пример #4
0
 def is_sun_out(self):
     region_instance = services.current_region()
     if region_instance is None or not region_instance.provides_sunlight:
         return False
     weather_service = services.weather_service()
     if weather_service is not None and weather_service.is_shady():
         return False
     return self.is_day_time()
Пример #5
0
def request_club_invite(club_id: int, _connection=None):
    sim_info = services.active_sim_info()
    if sim_info is None:
        return
    club_service = services.get_club_service()
    if club_service is None:
        return
    club = club_service.get_club_by_id(club_id)
    if club is None:
        return
    if any(club_member.is_selectable for club_member in club.members):
        club.show_club_notification(
            sim_info,
            ClubTunables.CLUB_GATHERING_DIALOG_REQUEST_INVITE_ACTIVE_SIM)
    elif club in club_service.clubs_to_gatherings_map:
        club.show_club_notification(
            sim_info,
            ClubTunables.CLUB_GATHERING_DIALOG_REQUEST_INVITE_CURRENT_LOT)
    else:
        club_hangout_zone_id = club.get_hangout_zone_id()
        if club.hangout_setting == ClubHangoutSetting.HANGOUT_LOT:
            current_region = services.current_region()
            hangout_region = get_region_instance_from_zone_id(
                club_hangout_zone_id)
            if not current_region.is_region_compatible(hangout_region):
                club.show_club_notification(
                    sim_info,
                    ClubTunables.
                    CLUB_GATHERING_DIALOG_REQUEST_INVITE_UNAVAILABLE,
                    target_sim_id=club.leader.sim_id)
                return
        elif not club_hangout_zone_id:
            if services.active_lot_id() == services.active_household_lot_id():

                def on_response(dialog):
                    if dialog.accepted:
                        club_service.start_gathering(
                            club,
                            host_sim_id=sim_info.sim_id,
                            invited_sims=(sim_info, ),
                            ignore_zone_validity=True)

                club.show_club_notification(
                    sim_info,
                    ClubTunables.CLUB_GATHERING_DIALOG_REQUEST_INVITE_NO_LOT,
                    target_sim_id=club.leader.sim_id,
                    on_response=on_response)
            else:
                club.show_club_notification(
                    sim_info,
                    ClubTunables.
                    CLUB_GATHERING_DIALOG_REQUEST_INVITE_NO_LOT_NOT_HOME,
                    target_sim_id=club.leader.sim_id)
            return
        club.show_club_gathering_dialog(
            sim_info,
            flavor_text=ClubTunables.CLUB_GATHERING_DIALOG_TEXT_REQUEST_INVITE,
            start_source=ClubGatheringStartSource.APPLY_FOR_INVITE)
Пример #6
0
 def _test(cls, *args, sim_info=None, **kwargs):
     if sim_info.zone_id == services.current_zone_id():
         return TestResult(False, 'Cannot bring a sim to a zone that is already the current zone.')
     if cls.check_region_compatibility:
         current_region = services.current_region()
         sim_region = region.get_region_instance_from_zone_id(sim_info.zone_id)
         if sim_region is None or not sim_region.is_region_compatible(current_region):
             return TestResult(False, 'Cannot bring a sim to an incompatible region.')
     return super()._test(*args, **kwargs)
Пример #7
0
 def _setup_regional_seasonal_changes(self):
     region = services.current_region()
     if region is None:
         return
     for param_handler in self._regional_seasonal_parameters_handles.values(
     ):
         param_handler.trigger_hard_stop()
     self._regional_seasonal_parameters_handles.clear()
     for seasonal_parameter in region.seasonal_parameters.keys():
         self._process_regional_season_change_update(seasonal_parameter)
Пример #8
0
 def is_day_time(self, time=None):
     region_instance = services.current_region()
     if region_instance is None:
         return False
     else:
         if time is None:
             time = self.sim_now
         if time.time_between_day_times(region_instance.get_sunrise_time(),
                                        region_instance.get_sunset_time()):
             return True
     return False
Пример #9
0
    def show_club_gathering_dialog(
            self,
            sim_info,
            *,
            flavor_text,
            start_source=ClubGatheringStartSource.DEFAULT,
            sender_sim_info=DEFAULT):
        zone_id = self.get_hangout_zone_id()
        if not zone_id:
            return False
        current_region = services.current_region()
        hangout_region = get_region_instance_from_zone_id(zone_id)
        if not current_region.is_region_compatible(hangout_region):
            return False
        venue_manager = services.get_instance_manager(
            sims4.resources.Types.VENUE)
        venue_tuning = venue_manager.get(build_buy.get_current_venue(zone_id))

        def on_response(dialog):
            if not dialog.accepted:
                return
            persistence_service = services.get_persistence_service()
            if persistence_service.is_save_locked():
                return
            club_service = services.get_club_service()
            if club_service is None:
                return
            club_service.start_gathering(self,
                                         start_source=start_source,
                                         host_sim_id=sim_info.sim_id,
                                         invited_sims=(sim_info, ),
                                         zone_id=zone_id,
                                         spawn_sims_during_zone_spin_up=True)

        zone_data = services.get_persistence_service().get_zone_proto_buff(
            zone_id)
        lot_name = zone_data.name
        sender_sim_info = self.leader if sender_sim_info is DEFAULT else sender_sim_info
        flavor_text = flavor_text(sim_info, sender_sim_info, self)
        additional_tokens = (lot_name, venue_tuning.club_gathering_text(),
                             flavor_text)
        self.show_club_notification(sim_info,
                                    ClubTunables.CLUB_GATHERING_DIALOG,
                                    target_sim_id=sender_sim_info.sim_id,
                                    additional_tokens=additional_tokens,
                                    on_response=on_response)
Пример #10
0
 def _start_welcome_wagon(self, _):
     situation_manager = services.get_zone_situation_manager()
     if situation_manager.is_user_facing_situation_running():
         self._schedule_welcome_wagon()
         return
     active_household = services.active_household()
     for sim_info in active_household.can_live_alone_info_gen():
         if sim_info.is_instanced():
             break
     else:
         self._schedule_welcome_wagon()
         return
     resolver = GlobalResolver()
     if not NPCHostedSituationService.WELCOME_WAGON_TUNING.welcome_wagon_start_tests.run_tests(
             resolver):
         active_household.needs_welcome_wagon = False
         return
     narrative_service = services.narrative_service()
     welcome_wagon_situation = narrative_service.get_possible_replacement_situation(
         NPCHostedSituationService.WELCOME_WAGON_TUNING.situation)
     if welcome_wagon_situation is NPCHostedSituationService.WELCOME_WAGON_TUNING.situation:
         region = services.current_region()
         if region.welcome_wagon_replacement is not None:
             welcome_wagon_situation = region.welcome_wagon_replacement
     guest_list = welcome_wagon_situation.get_predefined_guest_list()
     if guest_list is None:
         active_household.needs_welcome_wagon = False
         return
     game_clock_services = services.game_clock_service()
     if game_clock_services.clock_speed == ClockSpeedMode.SUPER_SPEED3:
         game_clock_services.set_clock_speed(ClockSpeedMode.NORMAL)
     situation_id = situation_manager.create_situation(
         welcome_wagon_situation,
         guest_list=guest_list,
         user_facing=False,
         scoring_enabled=False)
     if not (situation_id is None
             or not welcome_wagon_situation.sets_welcome_wagon_flag):
         active_household.needs_welcome_wagon = False
Пример #11
0
 def _process_regional_season_change_update(self, seasonal_parameter):
     region = services.current_region()
     if region is None:
         return
     current_index = self._regional_seasonal_parameters_index.get(
         seasonal_parameter)
     start_time = services.time_service().sim_now
     if current_index is None:
         (current_value, next_frame, end_time,
          next_index) = self._get_regional_season_change_values(
              seasonal_parameter, start_time, region)
     else:
         changes = region.seasonal_parameters.get(seasonal_parameter)
         current_frame = changes[current_index]
         current_value = current_frame.value
         next_index = (current_index + 1) % len(changes)
         next_frame = changes[next_index]
         current_value = self._get_wrapped_value(seasonal_parameter,
                                                 current_value,
                                                 next_frame.value)
         for (season_type, season_instance) in self.get_seasons_gen():
             if season_type == next_frame.season:
                 next_season_to_use = season_instance
                 break
         end_time = next_season_to_use.get_date_at_season_progress(
             next_frame.time_in_season)
         if end_time < start_time:
             end_time = start_time
     self._regional_seasonal_parameters_index[
         seasonal_parameter] = next_index
     self._send_regional_season_change_update(seasonal_parameter,
                                              current_value, start_time,
                                              next_frame.value, end_time)
     self._regional_seasonal_parameters_handles[
         seasonal_parameter] = self._season_timeline.schedule(
             build_element(
                 (lambda _: self._process_regional_season_change_update(
                     seasonal_parameter), )), end_time)
Пример #12
0
 def travel_player(self):
     sim = self.sim_info.get_sim_instance(allow_hidden_flags=ALL_HIDDEN_REASONS)
     travel_info = InteractionOps_pb2.TravelSimsToZone()
     travel_info.zone_id = self.to_zone_id
     travel_info.sim_ids.append(sim.id)
     self.interaction = None
     if self.is_attend_career:
         self._attend_career()
     travel_group = self.sim_info.travel_group
     if travel_group is not None and not any(sim_info is not self.sim_info and sim_info in self.sim_info.household for sim_info in travel_group):
         dest_region = region.get_region_instance_from_zone_id(self.to_zone_id)
         current_region = services.current_region()
         if not current_region.is_region_compatible(dest_region):
             services.travel_group_manager().destroy_travel_group_and_release_zone(travel_group, last_sim_info=self.sim_info)
     rabbit_hole_service = services.get_rabbit_hole_service()
     if rabbit_hole_service.is_in_rabbit_hole(sim.sim_id):
         rabbit_hole_service.set_ignore_travel_cancel_for_sim_id_in_rabbit_hole(sim.sim_id)
     sim.queue.cancel_all()
     for sim in self.additional_sims:
         sim.queue.cancel_all()
         travel_info.sim_ids.append(sim.sim_id)
     distributor.system.Distributor.instance().add_event(Consts_pb2.MSG_TRAVEL_SIMS_TO_ZONE, travel_info)
     services.game_clock_service().set_clock_speed(ClockSpeedMode.PAUSED)
Пример #13
0
 def get_travel_group_ids_in_region(self, region_id=None):
     region_id = region_id or services.current_region().guid64
     return (group.id for group in self.values()
             if region.get_region_instance_from_zone_id(
                 group.zone_id).guid64 == region_id)
 def situation_meets_starting_requirements(cls, **kwargs):
     if not cls.valid_regions.test_item(services.current_region()):
         return False
     if cls.starting_entitlement is None:
         return True
     return is_available_pack(cls.starting_entitlement)
Пример #15
0
 def has_venue_location(cls):
     compatible_region = services.current_region() if cls.venue_region_must_be_compatible else None
     return services.current_zone().venue_service.has_zone_for_venue_type(cls.compatible_venues, compatible_region=compatible_region)
Пример #16
0
    def set_season(self, season_type, source, interp_time=None):
        if self._season == season_type:
            return
        previous = self._season
        next_season = season_type
        if interp_time is None:
            self._season = season_type
            natural_progression = source == SeasonSetSource.PROGRESSION
            self._set_season_start_time(
                services.time_service().sim_now.start_of_week(),
                reset_region_params=not natural_progression)
            self.handle_season_content_updated(
                setup_regional_params=not natural_progression)
            self._handle_season_screen_slam(source)
        else:
            start_time = services.time_service().sim_now
            end_time = start_time + create_time_span(minutes=interp_time)
            new_season_start_time = services.time_service(
            ).sim_now.start_of_week()
            elapsed_time_into = start_time - self._season_content.start_time
            percent_into_start_season = float(
                elapsed_time_into.in_ticks()) / float(
                    self._season_length_span.in_ticks())
            elapsed_time_into = end_time - new_season_start_time
            percent_into_end_season = float(
                elapsed_time_into.in_ticks()) / float(
                    self._season_length_span.in_ticks())
            op = CrossSeasonInterpolationOp(previous,
                                            percent_into_start_season,
                                            start_time, next_season,
                                            percent_into_end_season, end_time)
            force_loop = op.is_over_half
            Distributor.instance().add_op_with_no_owner(op)
            if services.weather_service().adjust_weather_for_set_season(
                    interp_time):
                start_time = start_time + create_time_span(
                    minutes=interp_time / 2)
            param_to_start_value = {}
            region = services.current_region()
            if region is not None:
                for seasonal_parameter in region.seasonal_parameters.keys():
                    (start_value, _, _,
                     _) = self._get_regional_season_change_values(
                         seasonal_parameter, start_time, region)
                    param_to_start_value[seasonal_parameter] = start_value
            self._season = season_type
            self._set_season_start_time(new_season_start_time)
            self.handle_season_content_updated(delay=True)
            self._handle_season_screen_slam(source)

            def _send_update():
                sync_end_time = None
                for seasonal_parameter in SeasonParameters:
                    if seasonal_parameter not in param_to_start_value:
                        continue
                    start_value = param_to_start_value[seasonal_parameter]
                    new_end_time = end_time
                    (end_value, _, _,
                     _) = self._get_regional_season_change_values(
                         seasonal_parameter, end_time, region)
                    if seasonal_parameter == SeasonParameters.FOLIAGE_REDUCTION:
                        (start_value, end_value, new_end_time
                         ) = self._add_secondary_forward_wraparound_interp(
                             seasonal_parameter, start_time, start_value,
                             end_time, end_value, force_loop)
                        if end_time != new_end_time:
                            sync_end_time = new_end_time
                    if seasonal_parameter == SeasonParameters.FOLIAGE_COLORSHIFT:
                        if SeasonParameters.FOLIAGE_REDUCTION in param_to_start_value:
                            (start_value, end_value, new_end_time
                             ) = self._add_secondary_forward_wraparound_interp(
                                 seasonal_parameter,
                                 start_time,
                                 start_value,
                                 end_time,
                                 end_value,
                                 force_loop,
                                 sync_end_time=sync_end_time)
                    if end_value != start_value:
                        self._send_regional_season_change_update(
                            seasonal_parameter, start_value, start_time,
                            end_value, new_end_time)
                if self._season_change_handler is not None and not self._season_change_handler.is_active:
                    self._season_change_handler.trigger_hard_stop()
                self._season_change_handler = self._season_timeline.schedule(
                    build_element(
                        (lambda _: self._handle_season_content_delayed(
                            trigger_weather=True), )), end_time)

            self._season_change_handler = self._season_timeline.schedule(
                build_element((lambda _: _send_update(), )), start_time)
        self._schedule_season_aware_object_updates()
        services.get_event_manager().process_event(
            TestEvent.SeasonChangedNoSim,
            previous_season=previous,
            current_season=next_season)
        services.get_event_manager().process_events_for_household(
            TestEvent.SeasonChanged,
            services.active_household(),
            previous_season=previous,
            current_season=next_season)
Пример #17
0
def current_region(_connection=None):
    current_region = services.current_region()
    sims4.commands.output(f'Current Region: {current_region}', _connection)
Пример #18
0
def start_gathering_by_club_id(club_id: int, _connection=None):
    club_service = _get_club_service(_connection)
    if club_service is None:
        sims4.commands.automation_output('ClubGatheringStart; Status:Failed',
                                         _connection)
        return
    club = club_service.get_club_by_id(club_id)
    if club is None:
        sims4.commands.output('No Club exists with this ID.', _connection)
        sims4.commands.automation_output('ClubGatheringStart; Status:Failed',
                                         _connection)
        return
    persistence_service = services.get_persistence_service()
    venue_manager = services.get_instance_manager(sims4.resources.Types.VENUE)
    current_zone_id = services.current_zone_id()

    def _start_gathering(zone_id=None):
        start_gathering = functools.partial(
            club_service.start_gathering,
            club,
            invited_sims=(services.active_sim_info(), ))
        if zone_id is None:
            current_venue_tuning = venue_manager.get(
                build_buy.get_current_venue(current_zone_id))
            if current_venue_tuning.is_residential or current_venue_tuning.is_university_housing:
                if not club.is_zone_valid_for_gathering(current_zone_id):
                    club.show_club_notification(
                        services.active_sim_info(), ClubTunables.
                        CLUB_GATHERING_START_RESIDENTIAL_INVALID_DIALOG)
                    return
            elif not club.is_zone_valid_for_gathering(current_zone_id):
                club.show_club_notification(
                    services.active_sim_info(),
                    ClubTunables.CLUB_GATHERING_START_INVALID_DIALOG)
                return
            start_gathering()
        else:
            start_gathering(zone_id=zone_id)

    zone_id = club.get_hangout_zone_id(prefer_current=True)
    if zone_id:
        current_region = services.current_region()
        hangout_region = get_region_instance_from_zone_id(zone_id)
        if not current_region.is_region_compatible(hangout_region):
            zone_id = 0
    if not zone_id or zone_id == current_zone_id or persistence_service.is_save_locked(
    ):
        _start_gathering()
    else:

        def on_response(dialog):
            if dialog.closed:
                return
            if dialog.accepted:
                _start_gathering(zone_id=zone_id)
            else:
                _start_gathering()

        if club.hangout_setting == ClubHangoutSetting.HANGOUT_VENUE:
            venue_name = club.hangout_venue.display_name
        elif club.hangout_setting == ClubHangoutSetting.HANGOUT_LOT:
            zone_data = persistence_service.get_zone_proto_buff(zone_id)
            venue_name = zone_data.name if zone_data is not None else ''
        club.show_club_notification(
            services.active_sim_info(),
            ClubTunables.CLUB_GATHERING_START_SELECT_LOCATION_DIALOG,
            additional_tokens=(venue_name, ),
            on_response=on_response)
    sims4.commands.automation_output('ClubGatheringStart; Status:Success',
                                     _connection)
    return True
Пример #19
0
 def is_venue_location_valid(cls, zone_id):
     compatible_region = services.current_region() if cls.venue_region_must_be_compatible else None
     return services.current_zone().venue_service.is_zone_valid_for_venue_type(zone_id, cls.compatible_venues, compatible_region=compatible_region)
Пример #20
0
 def get_venue_location(cls):
     compatible_region = services.current_region() if cls.venue_region_must_be_compatible else None
     (zone_id, _) = services.current_zone().venue_service.get_zone_and_venue_type_for_venue_types(cls.compatible_venues, compatible_region=compatible_region)
     return zone_id
Пример #21
0
 def get_filter_terms(self):
     region = services.current_region()
     if region in self.region_to_filter_terms:
         return self.region_to_filter_terms[region]
     return self.default_filter_terms