def callback(cls, fields, source, *, factory, overrides, actor_participant_type=ParticipantType.Actor, target_participant_type=ParticipantType.TargetSim, **kwargs):
            if cls is None:
                return
            participant_constraint_lists = {}
            run_in_sequence = factory.run_in_sequence
            for animation_element_factory in factory.animation_element_gen():
                animation_element = animation_element_factory()
                asm_key = animation_element.asm_key
                actor_name = animation_element.actor_name
                target_name = animation_element.target_name
                carry_target_name = animation_element.carry_target_name
                create_target_name = animation_element.create_target_name
                initial_state = animation_element.initial_state
                begin_states = animation_element.begin_states
                instance_overrides = overrides()
                total_overrides = animation_element.overrides(overrides=instance_overrides)
                cls.register_tuned_animation(interaction_asm_type, asm_key, actor_name, target_name, carry_target_name, create_target_name, total_overrides, actor_participant_type, target_participant_type)
                if animation_element_factory._child_animations:
                    for child_args in animation_element_factory._child_animations:
                        cls.register_tuned_animation(*child_args)
                if should_use_animation_constaint_cache():
                    return
                if animation_element_factory._child_constraints:
                    for child_args in animation_element_factory._child_constraints:
                        cls.add_auto_constraint(*child_args)
                from interactions.utils.animation import InteractionAsmType
                while interaction_asm_type == InteractionAsmType.Interaction or (interaction_asm_type == InteractionAsmType.Canonical or interaction_asm_type == InteractionAsmType.Outcome) or interaction_asm_type == InteractionAsmType.Response:
                    from interactions.constraints import create_animation_constraint

                    def add_participant_constraint(participant_type, animation_constraint):
                        if animation_constraint is not None:
                            if interaction_asm_type == InteractionAsmType.Canonical:
                                is_canonical = True
                            else:
                                is_canonical = False
                            if run_in_sequence:
                                cls.add_auto_constraint(participant_type, animation_constraint, is_canonical=is_canonical)
                            else:
                                if participant_type not in participant_constraint_lists:
                                    participant_constraint_lists[participant_type] = []
                                participant_constraint_lists[participant_type].append(animation_constraint)

                    animation_constraint_actor = None
                    try:
                        animation_constraint_actor = create_animation_constraint(asm_key, actor_name, target_name, carry_target_name, create_target_name, initial_state, begin_states, total_overrides)
                    except:
                        if interaction_asm_type != InteractionAsmType.Outcome:
                            logger.exception('Exception while processing tuning for {}', cls)
                    add_participant_constraint(actor_participant_type, animation_constraint_actor)
                    if target_name is not None:
                        animation_context = get_throwaway_animation_context()
                        asm = animation.asm.Asm(asm_key, animation_context, posture_manifest_overrides=total_overrides.manifests)
                        target_actor_definition = asm.get_actor_definition(target_name)
                        if target_actor_definition.actor_type == ASM_ACTORTYPE_SIM:
                            animation_constraint_target = create_animation_constraint(asm_key, target_name, actor_name, carry_target_name, create_target_name, initial_state, begin_states, total_overrides)
                            add_participant_constraint(target_participant_type, animation_constraint_target)
            if not run_in_sequence and participant_constraint_lists is not None:
                from interactions.constraints import create_constraint_set
                for (participant_type, constraints_list) in participant_constraint_lists.items():
                    cls.add_auto_constraint(participant_type, create_constraint_set(constraints_list))
Esempio n. 2
0
 def get_constraint(self, participant_type=ParticipantType.Actor):
     from interactions.constraints import Anywhere, create_animation_constraint
     if participant_type == ParticipantType.Actor:
         actor_name = self.actor_name
         target_name = self.target_name
     elif participant_type == ParticipantType.TargetSim:
         actor_name = self.target_name
         target_name = self.actor_name
     else:
         return Anywhere()
     return create_animation_constraint(self.asm_key, actor_name,
                                        target_name, self.carry_target_name,
                                        self.create_target_name,
                                        self.initial_state,
                                        self.begin_states, self.end_states,
                                        self.overrides)
 def create_constraint(self, *args, **kwargs):
     animation_constraints = []
     if self._animation_ref:
         for animation_element_factory in self._animation_ref.animation_element_gen():
             animation_element = animation_element_factory()
             asm_key = animation_element.asm_key
             actor_name = animation_element.actor_name
             target_name = animation_element.target_name
             carry_target_name = animation_element.carry_target_name
             create_target_name = animation_element.create_target_name
             initial_state = animation_element.initial_state
             begin_states = animation_element.begin_states
             from interactions.constraints import create_animation_constraint
             animation_constraint = create_animation_constraint(asm_key, actor_name, target_name, carry_target_name, create_target_name, initial_state, begin_states, animation_element.overrides)
             animation_constraints.append(animation_constraint)
     from interactions.constraints import create_constraint_set
     return create_constraint_set(animation_constraints)
Esempio n. 4
0
 def create_constraint(self, *args, **kwargs):
     animation_constraints = []
     if self._animation_ref:
         for animation_element_factory in self._animation_ref.animation_element_gen(
         ):
             animation_element = animation_element_factory()
             asm_key = animation_element.asm_key
             actor_name = animation_element.actor_name
             target_name = animation_element.target_name
             carry_target_name = animation_element.carry_target_name
             create_target_name = animation_element.create_target_name
             initial_state = animation_element.initial_state
             begin_states = animation_element.begin_states
             end_states = animation_element.end_states
             from interactions.constraints import create_animation_constraint
             animation_constraint = create_animation_constraint(
                 asm_key, actor_name, target_name, carry_target_name,
                 create_target_name, initial_state, begin_states,
                 end_states, animation_element.overrides)
             animation_constraints.append(animation_constraint)
     return create_constraint_set(animation_constraints)
Esempio n. 5
0
        def callback(cls,
                     fields,
                     source,
                     *,
                     factory,
                     overrides,
                     actor_participant_type=ParticipantType.Actor,
                     target_participant_type=ParticipantType.TargetSim,
                     **kwargs):
            if cls is None:
                return
            participant_constraint_lists = {}
            run_in_sequence = factory.run_in_sequence
            for animation_element_factory in factory.animation_element_gen():
                animation_element = animation_element_factory()
                asm_key = animation_element.asm_key
                actor_name = animation_element.actor_name
                target_name = animation_element.target_name
                carry_target_name = animation_element.carry_target_name
                create_target_name = animation_element.create_target_name
                initial_state = animation_element.initial_state
                begin_states = animation_element.begin_states
                end_states = animation_element.end_states
                base_object_name = animation_element.base_object_name
                instance_overrides = overrides()
                total_overrides = animation_element.overrides(
                    overrides=instance_overrides)
                cls.register_tuned_animation(
                    interaction_asm_type, asm_key, actor_name, target_name,
                    carry_target_name, create_target_name, total_overrides,
                    actor_participant_type, target_participant_type)
                if animation_element_factory._child_animations:
                    for child_args in animation_element_factory._child_animations:
                        cls.register_tuned_animation(*child_args)
                if not interactions.interaction_instance_manager.BUILD_AC_CACHE and (
                        cls.resource_key
                        not in sims4.resources.localwork_no_groupid
                        and asm_key not in sims4.resources.localwork_no_groupid
                ) and caches.USE_ACC_AND_BCC & caches.AccBccUsage.ACC:
                    return
                if animation_element_factory._child_constraints:
                    for child_args in animation_element_factory._child_constraints:
                        cls.add_auto_constraint(*child_args)
                from animation.animation_constants import InteractionAsmType
                if not interaction_asm_type == InteractionAsmType.Interaction:
                    if not interaction_asm_type == InteractionAsmType.Canonical:
                        if not interaction_asm_type == InteractionAsmType.Outcome:
                            if interaction_asm_type == InteractionAsmType.Response:
                                from interactions.constraints import create_animation_constraint

                                def add_participant_constraint(
                                        participant_type,
                                        animation_constraint):
                                    if animation_constraint is not None:
                                        if interaction_asm_type == InteractionAsmType.Canonical:
                                            is_canonical = True
                                        else:
                                            is_canonical = False
                                        if run_in_sequence:
                                            cls.add_auto_constraint(
                                                participant_type,
                                                animation_constraint,
                                                is_canonical=is_canonical)
                                        else:
                                            if participant_type not in participant_constraint_lists:
                                                participant_constraint_lists[
                                                    participant_type] = []
                                            participant_constraint_lists[
                                                participant_type].append(
                                                    animation_constraint)

                                animation_constraint_actor = None
                                try:
                                    animation_constraint_actor = create_animation_constraint(
                                        asm_key,
                                        actor_name,
                                        target_name,
                                        carry_target_name,
                                        create_target_name,
                                        initial_state,
                                        begin_states,
                                        end_states,
                                        total_overrides,
                                        base_object_name=base_object_name)
                                except:
                                    if interaction_asm_type != InteractionAsmType.Outcome:
                                        logger.exception(
                                            'Exception while processing tuning for {}',
                                            cls)
                                add_participant_constraint(
                                    actor_participant_type,
                                    animation_constraint_actor)
                                if target_name is not None:
                                    animation_context = get_throwaway_animation_context(
                                    )
                                    asm = animation.asm.create_asm(
                                        asm_key,
                                        animation_context,
                                        posture_manifest_overrides=
                                        total_overrides.manifests)
                                    target_actor_definition = asm.get_actor_definition(
                                        target_name)
                                    if target_actor_definition.actor_type == ASM_ACTORTYPE_SIM:
                                        if not target_actor_definition.is_virtual:
                                            animation_constraint_target = create_animation_constraint(
                                                asm_key,
                                                target_name,
                                                actor_name,
                                                carry_target_name,
                                                create_target_name,
                                                initial_state,
                                                begin_states,
                                                end_states,
                                                total_overrides,
                                                base_object_name=
                                                base_object_name)
                                            add_participant_constraint(
                                                target_participant_type,
                                                animation_constraint_target)
                from interactions.constraints import create_animation_constraint

                def add_participant_constraint(participant_type,
                                               animation_constraint):
                    if animation_constraint is not None:
                        if interaction_asm_type == InteractionAsmType.Canonical:
                            is_canonical = True
                        else:
                            is_canonical = False
                        if run_in_sequence:
                            cls.add_auto_constraint(participant_type,
                                                    animation_constraint,
                                                    is_canonical=is_canonical)
                        else:
                            if participant_type not in participant_constraint_lists:
                                participant_constraint_lists[
                                    participant_type] = []
                            participant_constraint_lists[
                                participant_type].append(animation_constraint)

                animation_constraint_actor = None
                try:
                    animation_constraint_actor = create_animation_constraint(
                        asm_key,
                        actor_name,
                        target_name,
                        carry_target_name,
                        create_target_name,
                        initial_state,
                        begin_states,
                        end_states,
                        total_overrides,
                        base_object_name=base_object_name)
                except:
                    if interaction_asm_type != InteractionAsmType.Outcome:
                        logger.exception(
                            'Exception while processing tuning for {}', cls)
                add_participant_constraint(actor_participant_type,
                                           animation_constraint_actor)
                if target_name is not None:
                    animation_context = get_throwaway_animation_context()
                    asm = animation.asm.create_asm(
                        asm_key,
                        animation_context,
                        posture_manifest_overrides=total_overrides.manifests)
                    target_actor_definition = asm.get_actor_definition(
                        target_name)
                    if target_actor_definition.actor_type == ASM_ACTORTYPE_SIM:
                        if not target_actor_definition.is_virtual:
                            animation_constraint_target = create_animation_constraint(
                                asm_key,
                                target_name,
                                actor_name,
                                carry_target_name,
                                create_target_name,
                                initial_state,
                                begin_states,
                                end_states,
                                total_overrides,
                                base_object_name=base_object_name)
                            add_participant_constraint(
                                target_participant_type,
                                animation_constraint_target)
            if not run_in_sequence:
                if participant_constraint_lists is not None:
                    for (participant_type, constraints_list
                         ) in participant_constraint_lists.items():
                        cls.add_auto_constraint(
                            participant_type,
                            create_constraint_set(constraints_list))