def _get_arb(self, actor, portal_instance, *, is_mirrored):
     arb = Arb()
     asm = create_asm(self.animation_element.asm_key,
                      context=get_throwaway_animation_context())
     asm.set_actor(self.animation_element.actor_name, actor)
     if is_mirrored:
         entry_location = portal_instance.back_entry
         exit_location = portal_instance.back_exit
     else:
         entry_location = portal_instance.there_entry
         exit_location = portal_instance.there_exit
     asm.set_actor_parameter(self.animation_element.actor_name, actor,
                             animation_constants.ASM_INITIAL_TRANSLATION,
                             entry_location.position)
     asm.set_actor_parameter(self.animation_element.actor_name, actor,
                             animation_constants.ASM_INITIAL_ORIENTATION,
                             entry_location.orientation)
     asm.set_actor_parameter(self.animation_element.actor_name, actor,
                             animation_constants.ASM_TARGET_TRANSLATION,
                             exit_location.position)
     asm.set_actor_parameter(self.animation_element.actor_name, actor,
                             animation_constants.ASM_TARGET_ORIENTATION,
                             entry_location.orientation)
     self.animation_element.append_to_arb(asm, arb)
     return arb
 def get_supported_postures_gen(self):
     for (species, animation_data) in self._actor_species_mapping.items():
         asm = create_asm(animation_data._asm_key,
                          get_throwaway_animation_context())
         supported_postures = asm.get_supported_postures_for_actor(
             animation_data._actor_param_name)
         yield (species, supported_postures, asm)
 def _get_arb(self, actor, portal_instance, *, is_mirrored):
     arb = Arb()
     asm = create_asm(self.animation_element.asm_key,
                      context=get_throwaway_animation_context())
     asm.set_actor(self.animation_element.actor_name, actor)
     slide_end_location = self.slide_end_location(portal_instance.obj)
     if is_mirrored:
         entry_location = slide_end_location
         exit_location = portal_instance.back_exit
     else:
         entry_location = portal_instance.there_entry
         exit_location = slide_end_location
     initial_translation = sims4.math.Vector3(exit_location.position.x,
                                              entry_location.position.y,
                                              exit_location.position.z)
     asm.set_actor_parameter(self.animation_element.actor_name, actor,
                             animation_constants.ASM_INITIAL_TRANSLATION,
                             initial_translation)
     asm.set_actor_parameter(self.animation_element.actor_name, actor,
                             animation_constants.ASM_INITIAL_ORIENTATION,
                             entry_location.orientation)
     asm.set_actor_parameter(self.animation_element.actor_name, actor,
                             animation_constants.ASM_TARGET_TRANSLATION,
                             exit_location.position)
     asm.set_actor_parameter(self.animation_element.actor_name, actor,
                             animation_constants.ASM_TARGET_ORIENTATION,
                             exit_location.orientation)
     asm.set_actor_parameter(
         self.animation_element.actor_name, actor,
         animation_constants.ASM_LADDER_PORTAL_ALIGNMENT,
         PortalAlignment.get_asm_parameter_string(self.portal_alignment))
     self.animation_element.append_to_arb(asm, arb)
     return arb
 def get_provided_postures_gen(self):
     for (species, animation_data) in self._actor_species_mapping.items():
         asm = create_asm(animation_data._asm_key,
                          get_throwaway_animation_context())
         provided_postures = asm.provided_postures
         if not provided_postures:
             continue
         yield (species, provided_postures, asm)
 def get_supported_postures_gen(self):
     asm = create_asm(self._animation_data._asm_key,
                      get_throwaway_animation_context())
     supported_postures = asm.get_supported_postures_for_actor(
         self._animation_data._actor_param_name)
     for species in Species:
         if species == Species.INVALID:
             continue
         yield (species, supported_postures, asm)
 def get_provided_postures_gen(self):
     asm = create_asm(self._animation_data._asm_key,
                      get_throwaway_animation_context())
     provided_postures = asm.provided_postures
     if provided_postures:
         for species in Species:
             if species == Species.INVALID:
                 continue
             yield (species, provided_postures, asm)
 def _get_arb(self, actor, obj, *, is_mirrored):
     arb = Arb()
     asm = create_asm(self.animation_element.asm_key,
                      context=get_throwaway_animation_context())
     asm.set_actor(self.animation_element.actor_name, actor)
     asm.set_actor(self.animation_element.target_name, obj)
     asm.set_parameter('isMirrored', is_mirrored)
     self.animation_element.append_to_arb(asm, arb)
     return arb
Exemplo n.º 8
0
 def create_constraint(self, actor, target, **kwargs):
     if target is None:
         return Nowhere(
             '{} is creating a RoutingSlotConstraint for a None Target.',
             actor)
     slot_constraints = []
     asm_key = self.animation_element.asm_key
     actor_name = self.animation_element.actor_name
     target_name = self.animation_element.target_name
     state_name = self.animation_element.begin_states[0]
     asm = create_asm(asm_key,
                      context=get_throwaway_animation_context())
     asm.set_actor(actor_name, actor)
     asm.add_potentially_virtual_actor(actor_name, actor, target_name,
                                       target)
     asm.dirty_boundary_conditions()
     if actor.is_sim:
         age = actor.age.age_for_animation_cache
     else:
         age = None
     boundary_conditions = asm.get_boundary_conditions_list(
         actor, state_name)
     for (_, slots_to_params_entry) in boundary_conditions:
         if not slots_to_params_entry:
             continue
         slots_to_params_entry_absolute = []
         for (boundary_condition_entry,
              param_sequences_entry) in slots_to_params_entry:
             (routing_transform_entry, containment_transform, _,
              reference_joint_exit
              ) = boundary_condition_entry.get_transforms(asm, target)
             slots_to_params_entry_absolute.append(
                 (routing_transform_entry, reference_joint_exit,
                  param_sequences_entry))
         slot_constraint = RequiredSlotSingle(
             actor,
             target,
             asm,
             asm_key,
             None,
             actor_name,
             target_name,
             state_name,
             containment_transform,
             None,
             tuple(slots_to_params_entry_absolute),
             None,
             asm_name=asm.name,
             age=age)
         slot_constraints.append(slot_constraint)
     return create_constraint_set(slot_constraints)
Exemplo n.º 9
0
    def try_set_current_outfit(self,
                               outfit_category_and_index,
                               do_spin=False,
                               arb=None,
                               interaction=None):
        sim = self.get_sim_instance()
        if sim is None:
            do_spin = False
        if arb is None:
            logger.error('Must pass in a valid ARB for the clothing spin.')
            do_spin = False
        if self.can_switch_to_outfit(outfit_category_and_index):
            if do_spin:
                did_change = False

                def set_ending(*_, **__):
                    nonlocal did_change
                    if not did_change:
                        laundry_service = services.get_laundry_service()
                        if laundry_service is not None:
                            laundry_service.on_spin_outfit_change(
                                sim, outfit_category_and_index, interaction)
                        if self.set_current_outfit(outfit_category_and_index):
                            self._apply_on_outfit_changed_loot()
                        did_change = True

                arb.register_event_handler(set_ending, handler_id=100)
                if sim is not None:
                    animation_element_tuning = OutfitTuning.OUTFIT_CHANGE_ANIMATION
                    clothing_context = get_throwaway_animation_context()
                    clothing_change_asm = create_asm(
                        animation_element_tuning.asm_key,
                        context=clothing_context)
                    clothing_change_asm.update_locked_params(
                        sim.get_transition_asm_params())
                    result = sim.posture.setup_asm_interaction(
                        clothing_change_asm, sim, None,
                        animation_element_tuning.actor_name, None)
                    sim.set_trait_asm_parameters(
                        clothing_change_asm,
                        animation_element_tuning.actor_name)
                    if not result:
                        logger.error(
                            'Could not setup asm for Clothing Change. {}',
                            result)
                    clothing_change_asm.request(
                        animation_element_tuning.begin_states[0], arb)
            elif self.set_current_outfit(outfit_category_and_index):
                self._apply_on_outfit_changed_loot()
Exemplo n.º 10
0
 def on_tunable_loaded_callback(instance_class, tunable_name, source,
                                value):
     animation_element = value.canonical_animation
     asm_key = animation_element.asm_key
     actor_name = animation_element.actor_name
     target_name = animation_element.target_name
     state_name = animation_element.begin_states[0]
     actor = StubActor(1)
     target = StubActor(2)
     animation_context = get_throwaway_animation_context()
     asm = create_asm(asm_key, context=animation_context)
     asm.set_actor(actor_name, actor)
     asm.set_actor(target_name, target)
     for posture_manifest_entry in asm.get_supported_postures_for_actor(
             actor_name).get_constraint_version():
         for posture_type in posture_manifest_entry.posture_types:
             if posture_type.mobile:
                 break
         break
     else:
         posture_type = None
     available_transforms = []
     if posture_type is not None:
         posture = posture_type(actor,
                                None,
                                PostureTrack.BODY,
                                animation_context=animation_context)
         boundary_conditions = asm.get_boundary_conditions_list(
             actor, state_name, posture=posture, target=target)
         for (_, slots_to_params_entry) in boundary_conditions:
             if not slots_to_params_entry:
                 continue
             for (boundary_condition_entry,
                  param_sequences_entry) in slots_to_params_entry:
                 (relative_transform, _, _,
                  _) = boundary_condition_entry.get_transforms(asm, target)
                 available_transforms.append(
                     (param_sequences_entry, relative_transform))
     setattr(value, 'available_transforms', available_transforms)