Exemplo n.º 1
0
def set_age_speed_option(speed: int, _connection=None):
    if speed is None or speed < 0 or speed > 2:
        sims4.commands.output(
            'Invalid speed setting, valid speeds are 0, 1, or 2.', _connection)
        return False
    sims4.commands.output('Speed setting changed to speed {}'.format(speed),
                          _connection)
    services.get_aging_service().set_aging_speed(speed)
Exemplo n.º 2
0
 def get_lifetime_duration(self, sim_info):
     total_lifetime = sum(
         age_data.transition.get_age_duration(sim_info)
         for age_data in self.ages.values())
     aging_service = services.get_aging_service()
     total_lifetime /= aging_service.get_speed_multiple(
         aging_service.aging_speed)
     return total_lifetime
Exemplo n.º 3
0
def SetLifeSpanMultipliers(
        short: typing.Union[int, float, None] = None,
        normal: typing.Union[int, float, None] = None,
        long: typing.Union[int, float, None] = None) -> None:
    if not isinstance(short, int) and not isinstance(
            short, float) and short is not None:
        raise Exceptions.IncorrectTypeException(short, "short",
                                                (int, float, None))

    if not isinstance(normal, int) and not isinstance(
            normal, float) and normal is not None:
        raise Exceptions.IncorrectTypeException(normal, "normal",
                                                (int, float, None))

    if not isinstance(long, int) and not isinstance(
            long, float) and long is not None:
        raise Exceptions.IncorrectTypeException(long, "long",
                                                (int, float, None))

    currentMultipliers = aging_tuning.AgingTuning.AGE_SPEED_SETTING_MULTIPLIER

    if short is None:
        short = currentMultipliers[aging_tuning.AgeSpeeds.FAST]

    if normal is None:
        normal = currentMultipliers[aging_tuning.AgeSpeeds.NORMAL]

    if long is None:
        long = currentMultipliers[aging_tuning.AgeSpeeds.SLOW]

    if short != currentMultipliers[
            aging_tuning.AgeSpeeds.FAST] and normal != currentMultipliers[
                aging_tuning.AgeSpeeds.NORMAL] and long != currentMultipliers[
                    aging_tuning.AgeSpeeds.SLOW]:
        return

    changingMultipliers = {
        aging_tuning.AgeSpeeds.FAST: short,
        aging_tuning.AgeSpeeds.NORMAL: normal,
        aging_tuning.AgeSpeeds.SLOW: long
    }

    # noinspection PyUnresolvedReferences
    newMultipliers = collections.frozendict(
        currentMultipliers.items(),
        **changingMultipliers)  # TODO way to revert
    aging_tuning.AgingTuning.AGE_SPEED_SETTING_MULTIPLIER = newMultipliers

    agingService = None  # type: typing.Optional[aging_service.AgingService]

    try:
        agingService = services.get_aging_service(
        )  # type: aging_service.AgingService
    except Exception:
        pass

    if agingService is not None:
        agingService.set_aging_speed(agingService.aging_speed)
Exemplo n.º 4
0
 def _create_fake_total_time_alive(self):
     aging_service = services.get_aging_service()
     age = self.get_birth_age()
     time_alive = TimeSpan.ZERO
     while age < self.age:
         age_transition_data = self.get_age_transition_data(age)
         time_alive += interval_in_sim_days(
             age_transition_data.get_age_duration(self))
         age = self.get_next_age(age)
     setting_multiplier = aging_service.get_speed_multiple(
         self._age_speed_setting)
     time_alive /= setting_multiplier
     return time_alive
Exemplo n.º 5
0
 def update_age_callbacks(self):
     age_transition_data = self.get_age_transition_data(self.age)
     if self._is_aging_disabled():
         self._age_time = age_transition_data.get_age_duration(self)
         self._age_progress.decay_enabled = False
         if self._almost_can_age_handle is not None:
             alarms.cancel_alarm(self._almost_can_age_handle)
             self._almost_can_age_handle = None
         if self._can_age_handle is not None:
             alarms.cancel_alarm(self._can_age_handle)
             self._can_age_handle = None
         if self._auto_age_handle is not None:
             alarms.cancel_alarm(self._auto_age_handle)
             self._auto_age_handle = None
         return
     self._update_age_trait(self._base.age)
     self._age_time = age_transition_data.get_age_duration(self)
     self._age_progress.decay_enabled = True
     if self.is_elder:
         bonus_days = self._get_bonus_days()
     else:
         bonus_days = 0
     aging_service = services.get_aging_service()
     setting_multiplier = aging_service.get_speed_multiple(
         self._age_speed_setting)
     self._age_progress.set_modifier(setting_multiplier)
     age_time = self.days_until_ready_to_age()
     warn_time = age_time - age_transition_data.age_transition_warning / setting_multiplier
     auto_age_time = age_time + (age_transition_data.age_transition_delay +
                                 bonus_days) / setting_multiplier
     if self._almost_can_age_handle is not None:
         alarms.cancel_alarm(self._almost_can_age_handle)
     if warn_time >= 0:
         self._almost_can_age_handle = alarms.add_alarm(
             self,
             create_time_span(days=warn_time),
             self.callback_almost_ready_to_age,
             cross_zone=True)
     if self._can_age_handle is not None:
         alarms.cancel_alarm(self._can_age_handle)
     if age_time >= 0:
         self._can_age_handle = alarms.add_alarm(
             self,
             create_time_span(days=age_time),
             self.callback_ready_to_age,
             cross_zone=True)
     self._create_auto_age_callback(delay=max(0, auto_age_time))
     self.send_age_progress()
Exemplo n.º 6
0
def set_aging_unplayed_sims(enabled: bool, _connection=None):
    sims4.commands.output(
        'Auto aging for unplayed household toggled to: {}'.format(enabled),
        _connection)
    services.get_aging_service().set_unplayed_aging_enabled(enabled)
Exemplo n.º 7
0
def set_aging_enabled_option(enabled: int, _connection=None):
    sims4.commands.output(
        'Auto aging for played household set to: {}'.format(enabled),
        _connection)
    services.get_aging_service().set_aging_enabled(enabled)
Exemplo n.º 8
0
 def days_until_ready_to_age(self):
     aging_service = services.get_aging_service()
     setting_multiplier = aging_service.get_speed_multiple(
         self._age_speed_setting)
     return (self._age_time -
             self._age_progress.get_value()) / setting_multiplier