예제 #1
0
 def _create_fake_total_time_alive(self):
     age = Age.BABY
     time_alive = TimeSpan.ZERO
     while age != self.age:
         age_time = interval_in_sim_days(AgeTransitions.get_duration(Age(self._base.age)))
         time_alive += age_time
         age = Age.next_age(age)
     setting_multiplier = AgeTransitions.get_speed_multiple(self._age_speed_setting)
     time_alive /= setting_multiplier
     return time_alive
예제 #2
0
 def advance_age_phase(self):
     if self._base.age == Age.ELDER:
         bonus_days = self._get_bonus_days()
     else:
         bonus_days = 0
     age_time = AgeTransitions.get_duration(Age(self._base.age))
     warn_time = age_time - AgeTransitions.get_warning(Age(self._base.age))
     auto_age_time = age_time + AgeTransitions.get_delay(Age(self._base.age)) + bonus_days
     age_progress = self._age_progress.get_value()
     if age_progress <= warn_time:
         age_progress = warn_time
     elif age_progress <= age_time:
         age_progress = age_time
     else:
         age_progress = auto_age_time
     self._age_progress.set_value(age_progress - 0.0001)
     self.update_age_callbacks()
예제 #3
0
 def update_age_callbacks(self):
     self._update_age_trait(self._base.age)
     self._age_time = AgeTransitions.get_duration(Age(self._base.age))
     if not self._auto_aging_enabled:
         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
         if self._walk_on_lot_handle is not None:
             alarms.cancel_alarm(self._walk_on_lot_handle)
             self._walk_on_lot_handle = None
         return
     self._age_progress.decay_enabled = True
     if self.is_elder:
         bonus_days = self._get_bonus_days()
     else:
         bonus_days = 0
     setting_multiplier = AgeTransitions.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 - AgeTransitions.get_warning(Age(self._base.age))/setting_multiplier
     auto_age_time = age_time + (AgeTransitions.get_delay(Age(self._base.age)) + 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, False)
     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, False)
     self._create_auto_age_callback(delay=max(0, auto_age_time))
     self.send_age_progress()
예제 #4
0
 def _get_param_sequences_for_cache(self, actor, actor_name, to_state_name, from_state_name, posture):
     internal_param_sequence_list = self._get_param_sequences(actor.id, to_state_name, from_state_name, None)
     param_sequence_list = []
     posture_key = ('posture', actor_name)
     exact_str = posture.name + '-'
     family_str = posture.family_name
     if family_str is not None:
         family_str = '-' + family_str + '-'
     for param_sequence in internal_param_sequence_list or (None,):
         if param_sequence:
             posture_param_value = param_sequence.get(posture_key)
             if posture_param_value is not None:
                 if not posture_param_value.startswith(exact_str):
                     while not family_str is None:
                         if family_str not in posture_param_value:
                             pass
                         for age in Age.get_ages_for_animation_cache():
                             new_sequence = frozendict(param_sequence, {('age', actor_name): age.animation_age_param})
                             param_sequence_list.append(new_sequence)
         for age in Age.get_ages_for_animation_cache():
             new_sequence = frozendict(param_sequence, {('age', actor_name): age.animation_age_param})
             param_sequence_list.append(new_sequence)
     return param_sequence_list
예제 #5
0
 def __init__(self, agent, **kwargs):
     super().__init__(**kwargs)
     self._agent = agent
     self.agent_id = agent.id
     self.agent_radius = self._agent_radius
     self.agent_extra_clearance_multiplier = self._agent_extra_clearance_modifier
     self.agent_goal_radius = self._agent_goal_radius
     self.footprint_key = agent.definition.get_footprint(0)
     full_keymask = routing.FOOTPRINT_KEY_ON_LOT | routing.FOOTPRINT_KEY_OFF_LOT
     if self._allowed_heights is not None:
         full_keymask |= self._allowed_heights
     self.set_key_mask(full_keymask)
     full_portal_keymask = PortalFlags.DEFAULT
     species = getattr(self._agent, 'extended_species', DEFAULT)
     full_portal_keymask |= SpeciesExtended.get_portal_flag(species)
     age = getattr(self._agent, 'age', DEFAULT)
     full_portal_keymask |= Age.get_portal_flag(age)
     if self._allowed_portal_flags is not None:
         full_portal_keymask |= self._allowed_portal_flags
     self.set_portal_key_mask(full_portal_keymask)
     portal_discouragement_flags = 0
     if self._discouraged_portal_flags is not None:
         portal_discouragement_flags |= self._discouraged_portal_flags
     self.set_portal_discourage_key_mask(portal_discouragement_flags)
예제 #6
0
 def _get_param_sequences_for_cache(self, actor, actor_name, to_state_name, from_state_name, posture, target_name=None):
     internal_param_sequence_list = self._get_param_sequences(actor.id, to_state_name, from_state_name, None)
     internal_param_sequence_list = internal_param_sequence_list or (None,)
     if posture is None:
         return internal_param_sequence_list
     param_sequence_list = []
     posture_key = ('posture', actor_name)
     exact_str = posture.name + '-'
     family_str = posture.family_name
     if family_str is not None:
         family_str = '-' + family_str + '-'
     for param_sequence in internal_param_sequence_list:
         if param_sequence:
             posture_param_value = param_sequence.get(posture_key)
             if not (posture_param_value is not None and (posture_param_value.startswith(exact_str) or family_str is None)):
                 if family_str not in posture_param_value:
                     continue
                 actor_age_param = ('age', actor_name)
                 if param_sequence is not None and actor_age_param in param_sequence:
                     age = Age.get_age_from_animation_param(param_sequence[actor_age_param])
                     actor_available_ages = (age,)
                 else:
                     actor_available_ages = Age.get_ages_for_animation_cache()
                 actor_species_param = ('species', actor_name)
                 if param_sequence is not None and actor_species_param in param_sequence:
                     species = SpeciesExtended.get_species_from_animation_param(param_sequence[actor_species_param])
                     actor_available_species = (species,)
                 else:
                     actor_available_species = SpeciesExtended
                 if target_name is None:
                     target_available_species = ()
                     target_available_ages = ()
                 else:
                     target_age_param = ('age', target_name)
                     if param_sequence is not None and target_age_param in param_sequence:
                         age = Age.get_age_from_animation_param(param_sequence[target_age_param])
                         target_available_ages = (age,)
                     else:
                         target_available_ages = Age.get_ages_for_animation_cache()
                     target_species_param = ('species', target_name)
                     if param_sequence is not None and target_species_param in param_sequence:
                         species = SpeciesExtended.get_species_from_animation_param(param_sequence[target_species_param])
                         target_available_species = (species,)
                     else:
                         target_available_species = SpeciesExtended
                 for age_species_param_sequence in self._get_param_sequences_for_age_species_gen(param_sequence, actor_name, actor_available_species, actor_available_ages, target_name, target_available_species, target_available_ages):
                     param_sequence_list.append(age_species_param_sequence)
         else:
             actor_age_param = ('age', actor_name)
             if param_sequence is not None and actor_age_param in param_sequence:
                 age = Age.get_age_from_animation_param(param_sequence[actor_age_param])
                 actor_available_ages = (age,)
             else:
                 actor_available_ages = Age.get_ages_for_animation_cache()
             actor_species_param = ('species', actor_name)
             if param_sequence is not None and actor_species_param in param_sequence:
                 species = SpeciesExtended.get_species_from_animation_param(param_sequence[actor_species_param])
                 actor_available_species = (species,)
             else:
                 actor_available_species = SpeciesExtended
             if target_name is None:
                 target_available_species = ()
                 target_available_ages = ()
             else:
                 target_age_param = ('age', target_name)
                 if param_sequence is not None and target_age_param in param_sequence:
                     age = Age.get_age_from_animation_param(param_sequence[target_age_param])
                     target_available_ages = (age,)
                 else:
                     target_available_ages = Age.get_ages_for_animation_cache()
                 target_species_param = ('species', target_name)
                 if param_sequence is not None and target_species_param in param_sequence:
                     species = SpeciesExtended.get_species_from_animation_param(param_sequence[target_species_param])
                     target_available_species = (species,)
                 else:
                     target_available_species = SpeciesExtended
             for age_species_param_sequence in self._get_param_sequences_for_age_species_gen(param_sequence, actor_name, actor_available_species, actor_available_ages, target_name, target_available_species, target_available_ages):
                 param_sequence_list.append(age_species_param_sequence)
     return param_sequence_list
예제 #7
0
 def age(self):
     return Age(self._base.age)
예제 #8
0
    def advance_age(self, force_age=None) -> None:
        current_age = Age(self._base.age)
        next_age = Age(force_age) if force_age is not None else Age.next_age(current_age)
        self._relationship_tracker.update_bits_on_age_up(current_age)
        self.age_progress = 0
        self._dirty_flags = sys.maxsize
        self._base.update_for_age(next_age)
        getOutfitsPB = DistributorOps_pb2.SetSimOutfits()
        getOutfitsPB.ParseFromString(self._base.outfits)
        self._outfits.load_sim_outfits_from_cas_proto(getOutfitsPB)
        self.resend_physical_attributes()
        self._update_age_trait(next_age, current_age)
        self._select_age_trait()
        self.age = next_age
        self.init_child_skills()
        if self.is_teen:
            self.remove_child_only_features()
        sim_instance = self.get_sim_instance(allow_hidden_flags=ALL_HIDDEN_REASONS)
        if sim_instance is not None:
            with telemetry_helper.begin_hook(writer_age, TELEMETRY_CHANGE_AGE, sim=sim_instance) as hook:
                hook.write_enum('agef', current_age)
                hook.write_enum('aget', next_age)
                sim_instance.schedule_element(services.time_service().sim_timeline, build_element(sim_instance._update_face_and_posture_gen))
                sim_instance._update_multi_motive_buff_trackers()
            if current_age != Age.BABY:
                self.verify_school(from_age_up=True)
                self.remove_invalid_age_based_careers(current_age)
        self.reset_age_progress()
        if self.is_npc:
            if self.is_child or self.is_teen:
                available_aspirations = []
                aspiration_track_manager = services.get_instance_manager(sims4.resources.Types.ASPIRATION_TRACK)
                for aspiration_track in aspiration_track_manager.types.values():
                    if aspiration_track.is_child_aspiration_track:
                        if self.is_child:
                            available_aspirations.append(aspiration_track.guid64)
                            while self.is_teen:
                                available_aspirations.append(aspiration_track.guid64)
                    else:
                        while self.is_teen:
                            available_aspirations.append(aspiration_track.guid64)
                self.primary_aspiration = random.choice(available_aspirations)
            trait_tracker = self.trait_tracker
            empty_trait_slots = trait_tracker.empty_slot_number
            available_traits = [trait for trait in services.trait_manager().types.values() if trait.is_personality_trait]
            while True:
                while empty_trait_slots > 0 and available_traits:
                    trait = random.choice(available_traits)
                    available_traits.remove(trait)
                    if not trait_tracker.can_add_trait(trait, display_warn=False):
                        continue
                    #ERROR: Unexpected statement:   770 POP_BLOCK  |   771 JUMP_ABSOLUTE 812

                    if trait_tracker.add_trait(trait):
                        empty_trait_slots -= 1
                        continue
                        continue
                    continue
        else:
            self.whim_tracker.validate_goals()
            services.social_service.post_aging_message(self, ready_to_age=False)
        client = services.client_manager().get_client_by_household_id(self._household_id)
        if client is None:
            return
        client.selectable_sims.notify_dirty()
예제 #9
0
 def _select_age_trait(self):
     traits_choices = AgeTransitions.get_trait_list(Age(self._base.age))
     for trait in traits_choices:
         logger.info('AGE UP TRAIT CHOICES: {}', trait.display_name)