Beispiel #1
0
 def make_constraint_default(cls,
                             actor,
                             target_sim,
                             position,
                             routing_surface,
                             participant_type=ParticipantType.Actor,
                             picked_object=None,
                             participant_slot_overrides=None):
     if participant_type not in (ParticipantType.Actor,
                                 ParticipantType.TargetSim):
         return Anywhere()
     all_transforms = []
     for (actor_transform, target_transform, routing_surface,
          _) in cls._get_jig_transforms_gen(
              actor,
              target_sim,
              picked_object=picked_object,
              participant_slot_overrides=participant_slot_overrides):
         if participant_type == ParticipantType.Actor:
             transform = actor_transform
         else:
             transform = target_transform
         if transform is None:
             continue
         all_transforms.append(
             interactions.constraints.Transform(
                 transform,
                 routing_surface=routing_surface,
                 debug_name='JigGroupConstraint'))
     if not all_transforms:
         return Nowhere('Unable to get constraints from jig.')
     return create_constraint_set(all_transforms)
Beispiel #2
0
 def constraint_gen(cls, inst, sim, target, participant_type, *args, **kwargs):
     if inst is not None and inst._edge_constraint is not None:
         yield inst._edge_constraint
         return
     inst_or_cls = cls if inst is None else inst
     pick_position = inst_or_cls.context.pick
     if pick_position is None:
         pick_position = target.position
     else:
         pick_position = pick_position.location
     pool_block_id = build_buy.get_block_id(sim.zone_id, pick_position, inst_or_cls.context.pick.level - 1)
     if pool_block_id == 0:
         if inst_or_cls.context.pick.routing_surface.type == SurfaceType.SURFACETYPE_POOL:
             if get_water_depth(sim.position.x, sim.position.z, sim.level) > 0:
                 pool_edge_constraints = ANYWHERE
             else:
                 pool_edge_constraints = OceanStartLocationConstraint.create_simple_constraint(WaterDepthIntervals.WET, 1, sim, target)
                 return
         else:
             return
     else:
         pool = pool_utils.get_pool_by_block_id(pool_block_id)
         if pool is None:
             return
         pool_edge_constraints = pool.get_edge_constraint(constraint_width=inst_or_cls.edge_constraint_width, inward_dir=False, return_constraint_list=True, los_reference_point=pick_position)
     constraint_set = create_constraint_set(pool_edge_constraints)
     inst._edge_constraint = constraint_set
     yield constraint_set
def create_put_down_in_slot_type_constraint(sim, target, slot_types_and_costs):
    constraints = []
    for (slot_type, cost) in slot_types_and_costs:
        if cost is None:
            pass
        slot_manifest_entry = SlotManifestEntry(target,
                                                PostureSpecVariable.ANYTHING,
                                                slot_type)
        slot_manifest = SlotManifest((slot_manifest_entry, ))
        posture_state_spec_stand = PostureStateSpec(
            STAND_POSTURE_MANIFEST, slot_manifest,
            PostureSpecVariable.ANYTHING)
        posture_constraint_stand = Constraint(
            debug_name='PutDownInSlotTypeConstraint_Stand',
            posture_state_spec=posture_state_spec_stand,
            cost=cost)
        constraints.append(posture_constraint_stand)
        posture_state_spec_sit = PostureStateSpec(SIT_POSTURE_MANIFEST,
                                                  slot_manifest,
                                                  PostureSpecVariable.ANYTHING)
        posture_constraint_sit = Constraint(
            debug_name='PutDownInSlotTypeConstraint_Sit',
            posture_state_spec=posture_state_spec_sit,
            cost=cost)
        constraints.append(posture_constraint_sit)
    if not constraints:
        return Nowhere()
    final_constraint = create_constraint_set(constraints)
    return final_constraint
 def _get_constraint(self, sim):
     if self._focus is None:
         logger.error(
             'Attempt to get a constraint for a Sim before the group constraint is initialized: {} for {}',
             self,
             sim,
             owner='camilogarcia')
         return Anywhere()
     geometric_constraint = self._constraint
     if geometric_constraint is None:
         logger.error(
             'Attempt to get the constraint from a Social group before it has been initialized. Social Group is {}, Size of group is {}, and minimum number allowed for group is {}',
             self,
             len(self),
             self.minimum_sim_count,
             owner='camilogarcia')
         return Anywhere()
     scoring_constraints = []
     for other_sim in self:
         if other_sim is sim:
             continue
         facing_anchor = self._anchor_object if self._anchor_object is not None else other_sim
         force_readjustment = sim.id in self._pending_adjustments
         if force_readjustment:
             self._pending_adjustments.remove(sim.id)
         scoring_constraint = self.facing_restriction.create_constraint(
             sim,
             facing_anchor,
             scoring_functions=(self.scoring_function(
                 sim, other_sim, force_readjustment), ))
         scoring_constraints.append(scoring_constraint)
     scoring_constraints = create_constraint_set(scoring_constraints)
     geometric_constraint = geometric_constraint.intersect(
         scoring_constraints)
     return geometric_constraint
        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))
 def redraw(self, sim, constraint):
     color = pseudo_random_color(sim.id)
     (r, g, b, a) = sims4.color.to_rgba(color)
     (gr, gg, gb, ga) = sims4.color.to_rgba(Color.GREY)
     semitransparent = sims4.color.from_rgba((gr + r)/2, (gg + g)/2, (gb + b)/2, (ga + a)/2*0.4)
     transparent = sims4.color.from_rgba((gr + r)/2, (gg + g)/2, (gb + b)/2, (ga + a)/2*0.15)
     with Context(self.layer, routing_surface=constraint.routing_surface) as layer:
         direction_constraint = None
         direction_constraints = []
         for sub_constraint in constraint:
             while sub_constraint._geometry is not None and sub_constraint._geometry.polygon is None and sub_constraint._geometry.restrictions is not None:
                 direction_constraints.append(sub_constraint)
         if direction_constraints:
             direction_constraint = create_constraint_set(direction_constraints)
         for si in sim.si_state:
             participant_type = si.get_participant_type(sim)
             for si_constraint in si.constraint_intersection(participant_type=participant_type):
                 if direction_constraint is not None:
                     si_constraint = direction_constraint.intersect(si_constraint)
                 si_color = transparent
                 si_altitude = 0.01
                 if si.is_guaranteed():
                     si_color = semitransparent
                     si_altitude = 0.02
                 _draw_constraint(layer, si_constraint, si_color, altitude_modifier=si_altitude)
         _draw_constraint(layer, constraint, color, altitude_modifier=0.03, anywhere_position=sim.position)
Beispiel #7
0
 def _constraint_gen(cls, inst, sim, target, **kwargs):
     inst_or_cls = inst if inst is not None else cls
     yield from super(__class__,
                      inst_or_cls)._constraint_gen(sim, target, **kwargs)
     if inst is not None:
         inst._slot_constraint = create_put_down_in_slot_type_constraint(
             sim, target, inst._slot_types_and_costs)
         inst._world_constraint = create_put_down_on_ground_constraint(
             sim, target, inst._terrain_transform, cost=inst._world_cost)
         inst._sim_inventory_constraint = create_put_down_in_self_inventory_constraint(
             inst, sim, target, cost=inst._sim_inventory_cost)
         inst._object_inventory_constraint = create_put_down_in_inventory_constraint(
             inst,
             sim,
             target,
             targets_with_inventory=inst._objects_with_inventory,
             cost=inst._object_inventory_cost)
         if inst._slot_constraint.valid or (
                 inst._world_constraint.valid
                 or inst._sim_inventory_constraint.valid
         ) or inst._object_inventory_constraint.valid:
             constraints = [
                 inst._slot_constraint, inst._world_constraint,
                 inst._sim_inventory_constraint,
                 inst._object_inventory_constraint
             ]
             final_constraint = create_constraint_set(constraints)
         else:
             final_constraint = Nowhere(
                 'PutDownAnywhere could not create any valid putdown constraint.'
             )
         yield final_constraint
Beispiel #8
0
def create_put_down_in_inventory_constraint(inst,
                                            sim,
                                            target,
                                            targets_with_inventory,
                                            cost=0):
    if cost is None or not targets_with_inventory:
        return Nowhere(
            'No Cost({}) or No Targets with an inventory of the correct type. Sim: {} Target: {}',
            cost, sim, target)
    carry_constraint = create_carry_constraint(
        target, debug_name='CarryForPutDownInInventory')
    carry_constraint = carry_constraint.generate_constraint_with_cost(cost)
    object_constraints = []
    for target_with_inventory in targets_with_inventory:
        if target_with_inventory.item_location == ItemLocation.SIM_INVENTORY:
            continue
        constraint = target_with_inventory.get_inventory_access_constraint(
            sim, True, target)
        if constraint is None:
            logger.error(
                '{} failed to get inventory access constraint for {}, \n            If you cannot put down objects in this inventory, you should uncheck: Components -> Inventory -> Allow Putdown In Inventory.\n            If you can, you need to properly tune GetPut',
                sim,
                target,
                owner='tastle')
            return Nowhere(
                'Failed Inventory Access Constraint: See Gameplay Console for error.'
            )
        constraint = constraint.apply_posture_state(
            None, inst.get_constraint_resolver(None))
        object_constraints.append(constraint)
    final_constraint = create_constraint_set(object_constraints)
    final_constraint = carry_constraint.intersect(final_constraint)
    return final_constraint
 def get_inventory_access_constraint(self, *args, **kwargs):
     constraint_list = []
     for obj in self.owning_objects_gen():
         constraint_list.append(
             obj.get_inventory_access_constraint(*args, **kwargs))
     return create_constraint_set(constraint_list,
                                  debug_name='Object Inventory Constraints')
 def _create_floor_feature_constraint_set(cls, inst, sim):
     inst_or_cls = inst if inst is not None else cls
     floor_feature_contraints = []
     floor_features_and_surfaces = []
     zone_id = services.current_zone_id()
     floor_features = build_buy.list_floor_features(inst_or_cls.terrain_feature)
     if floor_features is None:
         return Nowhere('No found floor features.')
     radius_object = None
     if inst_or_cls.radius_filter is not None:
         radius_object = inst_or_cls.get_participant(inst_or_cls.radius_filter.radius_actor)
     if inst_or_cls.radius_filter is not None and radius_object is None:
         return Nowhere('Radius filter is enabled but the radius actor has a None value.')
     for floor_feature in floor_features:
         if inst_or_cls.indoors_only and build_buy.is_location_natural_ground(floor_feature[0], floor_feature[1]):
             continue
         routing_surface = routing.SurfaceIdentifier(zone_id, floor_feature[1], routing.SurfaceType.SURFACETYPE_WORLD)
         floor_feature_location = floor_feature[0]
         if inst_or_cls.radius_filter is not None:
             if (radius_object.position - floor_feature_location).magnitude_squared() <= inst_or_cls.radius_filter.radius:
                 floor_features_and_surfaces.append((floor_feature_location, routing_surface))
                 floor_features_and_surfaces.append((floor_feature_location, routing_surface))
         else:
             floor_features_and_surfaces.append((floor_feature_location, routing_surface))
     if floor_features_and_surfaces:
         for floor_feature_and_surface in floor_features_and_surfaces:
             circle_constraint = inst_or_cls.routing_circle_constraint.create_constraint(sim, None, target_position=floor_feature_and_surface[0], routing_surface=floor_feature_and_surface[1])
             facing_constraint = inst_or_cls.routing_facing_constraint.create_constraint(sim, None, target_position=floor_feature_and_surface[0], routing_surface=floor_feature_and_surface[1])
             constraint = circle_constraint.intersect(facing_constraint)
             floor_feature_contraints.append(constraint)
         return create_constraint_set(floor_feature_contraints)
     return Nowhere('With radius filter enabled, no found floor features are within range.')
 def _constraint_gen(cls,
                     inst,
                     sim,
                     target,
                     participant_type=ParticipantType.Actor):
     if inst is not None:
         inst._slot_constraint = create_put_down_in_slot_type_constraint(
             sim, target, inst._slot_types_and_costs)
         inst._world_constraint = create_put_down_on_ground_constraint(
             sim, target, inst._terrain_transform, cost=inst._world_cost)
         inst._sim_inventory_constraint = create_put_down_in_inventory_constraint(
             inst,
             sim,
             target,
             targets_with_inventory=[sim],
             cost=inst._sim_inventory_cost)
         inst._object_inventory_constraint = create_put_down_in_inventory_constraint(
             inst,
             sim,
             target,
             targets_with_inventory=inst._objects_with_inventory,
             cost=inst._object_inventory_cost)
         constraints = [
             inst._slot_constraint, inst._world_constraint,
             inst._sim_inventory_constraint,
             inst._object_inventory_constraint
         ]
         final_constraint = create_constraint_set(constraints)
         yield final_constraint
 def _constraint_gen(cls, inst, sim, target, participant_type=ParticipantType.Actor):
     if inst is not None:
         inst._slot_constraint = create_put_down_in_slot_type_constraint(sim, target, inst._slot_types_and_costs)
         inst._world_constraint = create_put_down_on_ground_constraint(sim, target, inst._terrain_transform, cost=inst._world_cost)
         inst._sim_inventory_constraint = create_put_down_in_inventory_constraint(inst, sim, target, targets_with_inventory=[sim], cost=inst._sim_inventory_cost)
         inst._object_inventory_constraint = create_put_down_in_inventory_constraint(inst, sim, target, targets_with_inventory=inst._objects_with_inventory, cost=inst._object_inventory_cost)
         constraints = [inst._slot_constraint, inst._world_constraint, inst._sim_inventory_constraint, inst._object_inventory_constraint]
         final_constraint = create_constraint_set(constraints)
         yield final_constraint
def routing_debug_generate_routing_goals_from_geometry(
        *args, obj: OptionalTargetParam = None, _connection=None):
    output = sims4.commands.Output(_connection)
    obj = get_optional_target(obj, _connection=_connection)
    if obj is None:
        return False
    routing_component = obj.get_component(ROUTING_COMPONENT)
    if routing_component is None:
        return False
    total_string = ''.join(args)
    polygon_strs = find_substring_in_repr(total_string, POLYGON_STR,
                                          POLYGON_END_PARAM)
    if not polygon_strs:
        output('No valid polygons. must start with {} and end with {}'.format(
            POLYGON_STR, POLYGON_END_PARAM))
        return
    constraints = []
    routing_surface = routing.SurfaceIdentifier(
        services.current_zone_id(), 0, routing.SurfaceType.SURFACETYPE_OBJECT)
    for poly_str in polygon_strs:
        point_list = extract_floats(poly_str)
        if not point_list or len(point_list) % 2 != 0:
            output('Point list is not valid length. Too few or one too many.')
            return
        vertices = []
        for index in range(0, len(point_list), 2):
            vertices.append(
                sims4.math.Vector3(point_list[index], 0.0,
                                   point_list[index + 1]))
        polygon = sims4.geometry.Polygon(vertices)
        geometry = RestrictedPolygon(polygon, [])
        constraints.append(
            Constraint(geometry=geometry, routing_surface=routing_surface))
    constraint_set = create_constraint_set(constraints)
    if not postures.posture_graph.enable_debug_goals_visualization:
        sims4.commands.execute('debugvis.goals.enable', _connection)
    handles = constraint_set.get_connectivity_handles(obj)
    handles_str = 'Handles: {}'.format(len(handles))
    sims4.commands.output(handles_str, _connection)
    all_goals = []
    for handle in handles:
        goal_list = handle.get_goals()
        goals_str = '\tGoals: {}'.format(len(goal_list))
        sims4.commands.output(goals_str, _connection)
        all_goals.extend(goal_list)
    if postures.posture_graph.enable_debug_goals_visualization:
        for constraint in constraints:
            with debugvis.Context(
                    'goal_scoring',
                    routing_surface=constraint.routing_surface) as layer:
                for polygon in constraint.geometry.polygon:
                    layer.add_polygon(
                        polygon, routing_surface=constraint.routing_surface)
                for goal in all_goals:
                    position = goal.location.transform.translation
                    layer.add_point(position,
                                    routing_surface=constraint.routing_surface)
Beispiel #14
0
 def _make_constraint(self, *args, **kwargs):
     all_constraints = [
         self.get_constraint(sim) for sim in self._sim_transform_map
     ]
     if all_constraints:
         self._constraint = create_constraint_set(all_constraints)
     else:
         self._constraint = Anywhere()
     return self._constraint
Beispiel #15
0
 def _make_constraint(self, *args, **kwargs):
     if self._constraint is None:
         constraints = [
             interactions.constraints.Transform(
                 t, routing_surface=self.routing_surface)
             for t in self._sim_transform_map.values()
         ]
         self._constraint = create_constraint_set(
             constraints) if constraints else Anywhere()
     return self._constraint
def create_put_down_in_inventory_constraint(inst, sim, target, targets_with_inventory, cost=0):
    if cost is None or not targets_with_inventory:
        return Nowhere()
    carry_constraint = create_carry_constraint(target, debug_name='CarryForPutDownInInventory')
    carry_constraint = carry_constraint.generate_constraint_with_cost(cost)
    object_constraints = []
    for target_with_inventory in targets_with_inventory:
        constraint = target_with_inventory.get_inventory_access_constraint(sim, True, target)
        constraint = constraint.apply_posture_state(None, inst.get_constraint_resolver(None))
        object_constraints.append(constraint)
    final_constraint = create_constraint_set(object_constraints)
    final_constraint = carry_constraint.intersect(final_constraint)
    return final_constraint
Beispiel #17
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)
Beispiel #18
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     sim = self._context.sim
     self._routing_surface = routing.SurfaceIdentifier(
         self._routing_surface.primary_id,
         self._routing_surface.secondary_id,
         routing.SurfaceType.SURFACETYPE_POOL)
     position = self._target.position if self._target is not None else sim.position
     level = self._routing_surface.secondary_id
     self._start_constraint = None
     self._master_depth_constraint = None
     self._waypoint_constraints = []
     self.keep_away_constraint = None
     self._location_is_pool = build_buy.is_location_pool(position, level)
     if self._location_is_pool:
         pool_block_id = build_buy.get_block_id(sim.zone_id, position,
                                                level - 1)
         pool = pool_utils.get_pool_by_block_id(pool_block_id)
         if pool is not None:
             pool_edge_constraints = pool.get_edge_constraint(
                 constraint_width=self.constraint_width,
                 inward_dir=True,
                 return_constraint_list=True)
             pool_edge_constraints = [
                 constraint.generate_geometry_only_constraint()
                 for constraint in pool_edge_constraints
             ]
             if self.keep_away_from_edges is not None:
                 bb_polys = build_buy.get_pool_polys(
                     pool_block_id, level - 1)
                 if len(bb_polys) > 0:
                     bb_poly = bb_polys[0]
                     _WaypointGeneratorPool._push_poly_inward(
                         bb_poly, self.keep_away_from_edges)
                     bb_poly.reverse()
                     keep_away_geom = sims4.geometry.RestrictedPolygon(
                         sims4.geometry.Polygon(bb_poly), ())
                     self.keep_away_constraint = Constraint(
                         routing_surface=pool.provided_routing_surface,
                         geometry=keep_away_geom)
                 else:
                     logger.error(
                         f'Pool Waypoint Generator: Pool polygon data unexpectedly empty while ${sim} was routing on a pool with id ${pool_block_id}.',
                         owner='jmorrow')
                 for i in range(len(pool_edge_constraints)):
                     pool_edge_constraints[i] = pool_edge_constraints[
                         i].intersect(self.keep_away_constraint)
             self._start_constraint = create_constraint_set(
                 pool_edge_constraints)
             self._waypoint_constraints = pool_edge_constraints
 def redraw(self, sim, constraint):
     routing_surface = None if isinstance(
         constraint, _ConstraintSet) else constraint.routing_surface
     color = pseudo_random_color(sim.id)
     (r, g, b, a) = sims4.color.to_rgba(color)
     (gr, gg, gb, ga) = sims4.color.to_rgba(Color.GREY)
     semitransparent = sims4.color.from_rgba(
         (gr + r) / 2, (gg + g) / 2, (gb + b) / 2, (ga + a) / 2 * 0.4)
     transparent = sims4.color.from_rgba((gr + r) / 2, (gg + g) / 2,
                                         (gb + b) / 2, (ga + a) / 2 * 0.15)
     if isinstance(constraint, _ConstraintSet):
         for sub_constraint in constraint:
             if sub_constraint.routing_surface is not None:
                 routing_surface = sub_constraint.routing_surface
                 break
     else:
         routing_surface = constraint.routing_surface
     with Context(self.layer, routing_surface=routing_surface) as layer:
         direction_constraint = None
         direction_constraints = []
         for sub_constraint in constraint:
             if sub_constraint._geometry is not None:
                 if sub_constraint._geometry.polygon is None:
                     if sub_constraint._geometry.restrictions is not None:
                         direction_constraints.append(sub_constraint)
         if direction_constraints:
             direction_constraint = create_constraint_set(
                 direction_constraints)
         for si in sim.si_state:
             participant_type = si.get_participant_type(sim)
             for si_constraint in si.constraint_intersection(
                     participant_type=participant_type):
                 if direction_constraint is not None:
                     si_constraint = direction_constraint.intersect(
                         si_constraint)
                 si_color = transparent
                 si_altitude = 0.01
                 if si.is_guaranteed():
                     si_color = semitransparent
                     si_altitude = 0.02
                 _draw_constraint(layer,
                                  si_constraint,
                                  si_color,
                                  altitude_modifier=si_altitude)
         _draw_constraint(layer,
                          constraint,
                          color,
                          altitude_modifier=0.03,
                          anywhere_position=sim.position,
                          draw_contours=True)
Beispiel #20
0
 def get_constraint(self, sim):
     transforms = self._sim_transform_map.get(sim, None)
     if transforms is not None:
         all_transforms = [
             interactions.constraints.Transform(
                 transform,
                 routing_surface=self.routing_surface,
                 create_jig_fn=self._set_sim_intended_location)
             for (transform, _) in transforms
         ]
         return create_constraint_set(all_transforms)
     if sim in self._sim_transform_map:
         return Nowhere(
             "JigGroup, Sim is expected to have a transform but we didn't find a good spot for them. Sim: {}",
             sim)
     return Anywhere()
def create_put_down_in_slot_type_constraint(sim, target, slot_types_and_costs):
    constraints = []
    for (slot_type, cost) in slot_types_and_costs:
        if cost is None:
            pass
        slot_manifest_entry = SlotManifestEntry(target, PostureSpecVariable.ANYTHING, slot_type)
        slot_manifest = SlotManifest((slot_manifest_entry,))
        posture_state_spec_stand = PostureStateSpec(STAND_POSTURE_MANIFEST, slot_manifest, PostureSpecVariable.ANYTHING)
        posture_constraint_stand = Constraint(debug_name='PutDownInSlotTypeConstraint_Stand', posture_state_spec=posture_state_spec_stand, cost=cost)
        constraints.append(posture_constraint_stand)
        posture_state_spec_sit = PostureStateSpec(SIT_POSTURE_MANIFEST, slot_manifest, PostureSpecVariable.ANYTHING)
        posture_constraint_sit = Constraint(debug_name='PutDownInSlotTypeConstraint_Sit', posture_state_spec=posture_state_spec_sit, cost=cost)
        constraints.append(posture_constraint_sit)
    if not constraints:
        return Nowhere()
    final_constraint = create_constraint_set(constraints)
    return final_constraint
Beispiel #22
0
 def get_lot_corners_constraint_set(self):
     lot_center = self.lot.center
     lot_corners = services.current_zone().lot.corners
     routing_surface = routing.SurfaceIdentifier(
         services.current_zone().id, 0, routing.SURFACETYPE_WORLD)
     constraint_list = []
     for corner in lot_corners:
         diff = lot_center - corner
         if diff.magnitude_squared() != 0:
             towards_center_vec = sims4.math.vector_normalize(lot_center -
                                                              corner) * 0.1
         else:
             towards_center_vec = sims4.math.Vector3.ZERO()
         new_corner = corner + towards_center_vec
         constraint_list.append(interactions.constraints.Position(
             new_corner, routing_surface=routing_surface))
     return create_constraint_set(constraint_list)
 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)
 def get_waypoint_constraints_gen(self, routing_agent, waypoint_count):
     zone = services.current_zone()
     constraint_set = zone.get_spawn_points_constraint(except_lot_id=self._except_lot_id, sim_spawner_tags=self.spawn_point_tags, generalize=True)
     routing_context = routing_agent.routing_component.pathplan_context
     source_handle = routing.connectivity.Handle(routing_agent.position, routing_agent.routing_surface)
     dest_handles = set()
     for constraint in constraint_set:
         handles = constraint.get_connectivity_handles(routing_agent)
         dest_handles.update(handles)
     connectivity = routing.test_connectivity_batch((source_handle,), dest_handles, routing_context=routing_context, compute_cost=True)
     vehicle_dest_handles = {dest for (_, dest, cost) in connectivity if sims4.math.almost_equal(cost, 0.0)}
     constraint_set = create_constraint_set([handle.constraint for handle in vehicle_dest_handles])
     constraints_weighted = []
     min_score = sims4.math.MAX_FLOAT
     for constraint in constraint_set:
         spawn_point_vector = constraint.average_position - self._sim.position
         score = sims4.math.vector_dot_2d(self._pick_vector, spawn_point_vector)
         min_score = score
         constraints_weighted.append((score, constraint))
     constraints_weighted = [(score - min_score, constraint) for (score, constraint) in constraints_weighted]
     constraints_weighted = sorted(constraints_weighted, key=lambda i: i[0])
     first_constraint = constraints_weighted[-1][1]
     del constraints_weighted[-1]
     first_constraint_circle = Circle(first_constraint.average_position, self.constraint_radius, routing_surface=first_constraint.routing_surface)
     jog_waypoint_constraints = []
     jog_waypoint_constraints.append(first_constraint_circle)
     last_waypoint_position = first_constraint.average_position
     for _ in range(waypoint_count - 1):
         constraints_weighted_next = []
         for (_, constraint) in constraints_weighted:
             average_position = constraint.average_position
             distance_last = (average_position - last_waypoint_position).magnitude_2d()
             distance_home = (average_position - self._origin_position).magnitude_2d()
             constraints_weighted_next.append((distance_last + distance_home, constraint))
         break
         next_constraint = pop_weighted(constraints_weighted_next)
         next_constraint_circle = Circle(next_constraint.average_position, self.constraint_radius, routing_surface=next_constraint.routing_surface)
         jog_waypoint_constraints.append(next_constraint_circle)
         constraints_weighted = constraints_weighted_next
         break
         last_waypoint_position = next_constraint.average_position
     jog_waypoint_constraints = self.apply_water_constraint(jog_waypoint_constraints)
     yield from jog_waypoint_constraints
     yield self._start_constraint
def create_put_down_in_inventory_constraint(inst,
                                            sim,
                                            target,
                                            targets_with_inventory,
                                            cost=0):
    if cost is None or not targets_with_inventory:
        return Nowhere()
    carry_constraint = create_carry_constraint(
        target, debug_name='CarryForPutDownInInventory')
    carry_constraint = carry_constraint.generate_constraint_with_cost(cost)
    object_constraints = []
    for target_with_inventory in targets_with_inventory:
        constraint = target_with_inventory.get_inventory_access_constraint(
            sim, True, target)
        constraint = constraint.apply_posture_state(
            None, inst.get_constraint_resolver(None))
        object_constraints.append(constraint)
    final_constraint = create_constraint_set(object_constraints)
    final_constraint = carry_constraint.intersect(final_constraint)
    return final_constraint
Beispiel #26
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)
Beispiel #27
0
 def _constraint_gen(cls,
                     inst,
                     sim,
                     target,
                     participant_type=ParticipantType.Actor,
                     **kwargs):
     inst_or_cls = cls if inst is None else inst
     yield from super(SuperInteraction, inst_or_cls)._constraint_gen(
         sim, target, participant_type=participant_type, **kwargs)
     if inst_or_cls.use_aggregated_affordance_constraints:
         aggregated_constraints = []
         affordances = []
         affordances = [
             aop.super_affordance for (aop, _) in inst._valid_aops
         ]
         affordances = affordances if not inst is not None or not inst._valid_aops is not None or affordances else [
             affordance_tuple.affordance
             for affordance_tuple in inst_or_cls.aggregated_affordances
         ]
         if not affordances:
             yield Nowhere
         for aggregated_affordance in affordances:
             intersection = ANYWHERE
             constraint_gen = aggregated_affordance.constraint_gen
             constraint_gen = super(SuperInteraction,
                                    aggregated_affordance)._constraint_gen
             for constraint in constraint_gen(
                     sim,
                     inst_or_cls.get_constraint_target(target),
                     participant_type=participant_type,
                     **kwargs):
                 intersection = constraint.intersect(intersection)
                 if not intersection.valid:
                     continue
             aggregated_constraints.append(intersection)
         if aggregated_constraints:
             yield create_constraint_set(
                 aggregated_constraints,
                 debug_name='AggregatedConstraintSet')
 def _create_floor_feature_constraint_set(cls, context):
     floor_feature_contraints = []
     floor_features_and_distances = []
     zone_id = sims4.zone_utils.get_zone_id()
     sim = context.sim
     sim_position = sim.position
     sim_routing_surface = sim.routing_surface
     floor_features = build_buy.list_floor_features(zone_id,
                                                    cls.terrain_feature)
     for floor_feature in floor_features:
         if cls.indoors_only and build_buy.is_location_natural_ground(
                 zone_id, floor_feature[0], floor_feature[1]):
             pass
         routing_surface = routing.SurfaceIdentifier(
             zone_id, floor_feature[1], routing.SURFACETYPE_WORLD)
         distance = estimate_distance_between_points(
             sim_position, sim_routing_surface, floor_feature[0],
             routing_surface)
         while distance is not None:
             floor_features_and_distances.append(
                 [[floor_feature[0], routing_surface], distance])
     if floor_features_and_distances:
         sorted(floor_features_and_distances,
                key=lambda feature: feature[1])
         for floor_feature_and_distance in floor_features_and_distances:
             floor_feature = floor_feature_and_distance[0]
             circle_constraint = cls.routing_circle_constraint.create_constraint(
                 sim,
                 None,
                 target_position=floor_feature[0],
                 routing_surface=floor_feature[1])
             facing_constraint = cls.routing_facing_constraint.create_constraint(
                 sim,
                 None,
                 target_position=floor_feature[0],
                 routing_surface=floor_feature[1])
             constraint = circle_constraint.intersect(facing_constraint)
             floor_feature_contraints.append(constraint)
     return create_constraint_set(floor_feature_contraints)
Beispiel #29
0
def create_put_down_in_slot_type_constraint(sim,
                                            carry_target,
                                            slot_types_and_costs,
                                            target=None):
    constraints = []
    for (slot_type, cost) in slot_types_and_costs:
        if cost is None:
            continue
        if target is not None and target is not carry_target:
            slot_manifest_entry = SlotManifestEntry(
                carry_target, PostureSpecVariable.INTERACTION_TARGET,
                slot_type)
        else:
            slot_manifest_entry = SlotManifestEntry(
                carry_target, PostureSpecVariable.ANYTHING, slot_type)
        slot_manifest = SlotManifest((slot_manifest_entry, ))
        posture_state_spec_stand = PostureStateSpec(
            STAND_POSTURE_MANIFEST, slot_manifest,
            PostureSpecVariable.ANYTHING)
        posture_constraint_stand = Constraint(
            debug_name='PutDownInSlotTypeConstraint_Stand',
            posture_state_spec=posture_state_spec_stand,
            cost=cost)
        constraints.append(posture_constraint_stand)
        posture_state_spec_sit = PostureStateSpec(SIT_POSTURE_MANIFEST,
                                                  slot_manifest,
                                                  PostureSpecVariable.ANYTHING)
        posture_constraint_sit = Constraint(
            debug_name='PutDownInSlotTypeConstraint_Sit',
            posture_state_spec=posture_state_spec_sit,
            cost=cost)
        constraints.append(posture_constraint_sit)
    if not constraints:
        return Nowhere(
            'Carry Target has no slot types or costs tuned for put down: {} Sim:{}',
            carry_target, sim)
    final_constraint = create_constraint_set(constraints)
    return final_constraint
    def combine_constraints(
        constraints: Iterator[Constraint],
        fallback_constraints: Iterator[Constraint] = (),
        debug_name: str = 'Combined'
    ) -> Union[_ConstraintSet, Constraint, Nowhere]:
        """combine_constraints(constraints, fallback_constraints=(), debug_name='Combined')

        Attempt to combine similar constraints into a constraint set.

        :param constraints: A collection of Constraints.
        :type constraints: Iterator[Constraint]
        :param fallback_constraints: A collection of Constraints to choose from as a fallback when the primary constraints fail to combine. Default is an empty collection.
        :type fallback_constraints: Iterator[Constraint], optional
        :param debug_name: The name of the constraint set being created. Default is 'Combined'.
        :type debug_name: str, optional
        :return: A constraint set containing the specified constraints, a Constraint chosen from one of the specified fallback constraints, or Nowhere when everything else fails.
        :rtype: Union[_ConstraintSet, Constraint, Nowhere]
        """
        from interactions.constraints import create_constraint_set
        return create_constraint_set(
            tuple(constraints),
            invalid_constraints=tuple(fallback_constraints),
            debug_name=debug_name)
 def _create_floor_feature_constraint_set(cls, context):
     floor_feature_contraints = []
     floor_features_and_distances = []
     zone_id = sims4.zone_utils.get_zone_id()
     sim = context.sim
     sim_position = sim.position
     sim_routing_surface = sim.routing_surface
     floor_features = build_buy.list_floor_features(zone_id, cls.terrain_feature)
     for floor_feature in floor_features:
         if cls.indoors_only and build_buy.is_location_natural_ground(zone_id, floor_feature[0], floor_feature[1]):
             pass
         routing_surface = routing.SurfaceIdentifier(zone_id, floor_feature[1], routing.SURFACETYPE_WORLD)
         distance = estimate_distance_between_points(sim_position, sim_routing_surface, floor_feature[0], routing_surface)
         while distance is not None:
             floor_features_and_distances.append([[floor_feature[0], routing_surface], distance])
     if floor_features_and_distances:
         sorted(floor_features_and_distances, key=lambda feature: feature[1])
         for floor_feature_and_distance in floor_features_and_distances:
             floor_feature = floor_feature_and_distance[0]
             circle_constraint = cls.routing_circle_constraint.create_constraint(sim, None, target_position=floor_feature[0], routing_surface=floor_feature[1])
             facing_constraint = cls.routing_facing_constraint.create_constraint(sim, None, target_position=floor_feature[0], routing_surface=floor_feature[1])
             constraint = circle_constraint.intersect(facing_constraint)
             floor_feature_contraints.append(constraint)
     return create_constraint_set(floor_feature_contraints)
Beispiel #32
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))
STAND_NO_CARRY_NO_SURFACE_STATE_SPEC = create_body_posture_state_spec(STAND_NO_CARRY_NO_SURFACE_POSTURE_MANIFEST)
STAND_OR_MOVING_STAND_STATE_SPEC = create_body_posture_state_spec(STAND_OR_MOVING_STAND_POSTURE_MANIFEST)
STAND_OR_MOVING_STAND_AT_NONE_STATE_SPEC = create_body_posture_state_spec(STAND_OR_MOVING_STAND_POSTURE_MANIFEST, body_target=None)
STAND_CONSTRAINT = Constraint(debug_name='Stand', posture_state_spec=STAND_POSTURE_STATE_SPEC)
STAND_NO_SURFACE_CONSTRAINT = Constraint(debug_name='Stand-NoSurface', posture_state_spec=STAND_NO_SURFACE_STATE_SPEC)
STAND_NO_CARRY_NO_SURFACE_CONSTRAINT = Constraint(debug_name='Stand-NoCarryNoSurface', posture_state_spec=STAND_NO_CARRY_NO_SURFACE_STATE_SPEC)
STAND_CONSTRAINT_OUTER_PENALTY = Constraint(debug_name='Stand', posture_state_spec=STAND_POSTURE_STATE_SPEC, ignore_outer_penalty_threshold=1.0)
STAND_AT_NONE_CONSTRAINT = Constraint(debug_name='Stand@None', posture_state_spec=STAND_AT_NONE_POSTURE_STATE_SPEC)
STAND_OR_MOVING_STAND_CONSTRAINT = Constraint(debug_name='Stand-Or-MovingStand', posture_state_spec=STAND_OR_MOVING_STAND_STATE_SPEC)
STAND_OR_MOVING_STAND_AT_NONE_CONSTRAINT = Constraint(debug_name='Stand-Or-MovingStand@None', posture_state_spec=STAND_OR_MOVING_STAND_AT_NONE_STATE_SPEC)
SIT_POSTURE_MANIFEST = PostureManifest((PostureManifestEntry(None, '', 'sit', 'FullBody', MATCH_ANY, MATCH_ANY, MATCH_ANY), PostureManifestEntry(None, '', 'sit', 'UpperBody', MATCH_ANY, MATCH_ANY, MATCH_ANY))).intern()
SIT_NO_CARRY_ANY_SURFACE_MANIFEST = PostureManifest((PostureManifestEntry(None, '', 'sit', 'FullBody', MATCH_NONE, MATCH_NONE, MATCH_ANY), PostureManifestEntry(None, '', 'sit', 'UpperBody', MATCH_NONE, MATCH_NONE, MATCH_ANY))).intern()
SIT_POSTURE_STATE_SPEC = create_body_posture_state_spec(SIT_POSTURE_MANIFEST)
SIT_NO_CARRY_ANY_SURFACE_STATE_SPEC = create_body_posture_state_spec(SIT_NO_CARRY_ANY_SURFACE_MANIFEST)
SIT_CONSTRAINT = Constraint(debug_name='Sit', posture_state_spec=SIT_POSTURE_STATE_SPEC)
SIT_NO_CARRY_ANY_SURFACE_CONSTRAINT = Constraint(debug_name='SitNoCarryAnySurface', posture_state_spec=SIT_NO_CARRY_ANY_SURFACE_STATE_SPEC)
SWIM_POSTURE_TYPE = 'swim'
SWIM_POSTURE_MANIFEST = PostureManifest((PostureManifestEntry(None, SWIM_POSTURE_TYPE, '', 'FullBody', None, None, MATCH_ANY), PostureManifestEntry(None, SWIM_POSTURE_TYPE, '', 'UpperBody', None, None, MATCH_ANY))).intern()
SWIM_AT_NONE_POSTURE_STATE_SPEC = create_body_posture_state_spec(SWIM_POSTURE_MANIFEST, body_target=None)
SWIM_AT_NONE_CONSTRAINT = Constraint(debug_name='swim@None', posture_state_spec=SWIM_AT_NONE_POSTURE_STATE_SPEC)

class PostureConstants:
    SIT_POSTURE_TYPE = TunableReference(description='\n        A reference to the sit posture type.\n        ', manager=services.get_instance_manager(sims4.resources.Types.POSTURE))

SIT_INTIMATE_POSTURE_MANIFEST = PostureManifest((PostureManifestEntry(None, 'sitIntimate', '', 'FullBody', MATCH_NONE, MATCH_NONE, MATCH_ANY), PostureManifestEntry(None, 'sitIntimate', '', 'UpperBody', MATCH_NONE, MATCH_NONE, MATCH_ANY), PostureManifestEntry(None, 'sitIntimateBooth', '', 'FullBody', MATCH_NONE, MATCH_NONE, MATCH_ANY), PostureManifestEntry(None, 'sitIntimateBooth', '', 'UpperBody', MATCH_NONE, MATCH_NONE, MATCH_ANY))).intern()
SIT_INTIMATE_POSTURE_STATE_SPEC = create_body_posture_state_spec(SIT_INTIMATE_POSTURE_MANIFEST)
SIT_INTIMATE_CONSTRAINT = Constraint(debug_name='SitIntimate', posture_state_spec=SIT_INTIMATE_POSTURE_STATE_SPEC)
STAND_OR_SIT_POSTURE_MANIFEST = PostureManifest(list(STAND_POSTURE_MANIFEST) + list(SIT_POSTURE_MANIFEST)).intern()
STAND_OR_SIT_CONSTRAINT = create_constraint_set((STAND_CONSTRAINT, SIT_CONSTRAINT), debug_name='Stand-or-Sit')
STAND_SIT_OR_SWIM_CONSTRAINT_OUTER_PENALTY = create_constraint_set((STAND_CONSTRAINT_OUTER_PENALTY, SIT_CONSTRAINT, SWIM_AT_NONE_CONSTRAINT), debug_name='Stand-Sit-Or-Swim-Outer-Penalty')
ADJUSTMENT_CONSTRAINT = create_constraint_set((STAND_OR_MOVING_STAND_CONSTRAINT, SIT_CONSTRAINT), debug_name='Adjustment-Constraint')
Beispiel #34
0
 def get_inventory_access_constraint(self, sim, is_put, carry_target, use_owner_as_target_for_resolver=False):
     constraint_list = []
     for obj in self.owning_objects_gen():
         constraint_list.append(obj.get_inventory_access_constraint(sim, is_put, carry_target, use_owner_as_target_for_resolver=use_owner_as_target_for_resolver))
     return create_constraint_set(constraint_list, debug_name='Object Inventory Constraints')
Beispiel #35
0
from animation.posture_manifest
import MATCH_ANY, MATCH_NONE, PostureManifestEntry, PostureManifest
from interactions.constraints
import Constraint, create_constraint_set
from postures.posture_state_spec
import create_body_posture_state_spec
STAND_POSTURE_MANIFEST = PostureManifest((PostureManifestEntry(None, '', 'stand', 'FullBody', MATCH_ANY, MATCH_ANY, MATCH_ANY), PostureManifestEntry(None, '', 'stand', 'UpperBody', MATCH_ANY, MATCH_ANY, MATCH_ANY))).intern()
STAND_NO_SURFACE_POSTURE_MANIFEST = PostureManifest((PostureManifestEntry(None, '', 'stand', 'FullBody', MATCH_ANY, MATCH_ANY, MATCH_NONE), PostureManifestEntry(None, '', 'stand', 'UpperBody', MATCH_ANY, MATCH_ANY, MATCH_NONE))).intern()
STAND_NO_CARRY_NO_SURFACE_POSTURE_MANIFEST = PostureManifest((PostureManifestEntry(None, '', 'stand', 'FullBody', MATCH_NONE, MATCH_NONE, MATCH_NONE), PostureManifestEntry(None, '', 'stand', 'UpperBody', MATCH_NONE, MATCH_NONE, MATCH_NONE))).intern()
STAND_POSTURE_STATE_SPEC = create_body_posture_state_spec(STAND_POSTURE_MANIFEST)
STAND_NO_SURFACE_STATE_SPEC = create_body_posture_state_spec(STAND_NO_SURFACE_POSTURE_MANIFEST)
STAND_NO_CARRY_NO_SURFACE_STATE_SPEC = create_body_posture_state_spec(STAND_NO_CARRY_NO_SURFACE_POSTURE_MANIFEST)
STAND_CONSTRAINT = Constraint(debug_name = 'Stand', posture_state_spec = STAND_POSTURE_STATE_SPEC)
STAND_NO_SURFACE_CONSTRAINT = Constraint(debug_name = 'Stand-NoSurface', posture_state_spec = STAND_NO_SURFACE_STATE_SPEC)
STAND_NO_CARRY_NO_SURFACE_CONSTRAINT = Constraint(debug_name = 'Stand-NoCarryNoSurface', posture_state_spec = STAND_NO_CARRY_NO_SURFACE_STATE_SPEC)
STAND_CONSTRAINT_OUTER_PENALTY = Constraint(debug_name = 'Stand', posture_state_spec = STAND_POSTURE_STATE_SPEC, ignore_outer_penalty_threshold = 1.0)
STAND_AT_NONE_POSTURE_STATE_SPEC = create_body_posture_state_spec(STAND_POSTURE_MANIFEST, body_target = None)
STAND_AT_NONE_CONSTRAINT = Constraint(debug_name = 'Stand@None', posture_state_spec = STAND_AT_NONE_POSTURE_STATE_SPEC)
SIT_POSTURE_MANIFEST = PostureManifest((PostureManifestEntry(None, '', 'sit', 'FullBody', MATCH_ANY, MATCH_ANY, MATCH_ANY), PostureManifestEntry(None, '', 'sit', 'UpperBody', MATCH_ANY, MATCH_ANY, MATCH_ANY))).intern()
SIT_NO_CARRY_NO_SURFACE_MANIFEST = PostureManifest((PostureManifestEntry(None, '', 'sit', 'FullBody', MATCH_NONE, MATCH_NONE, MATCH_NONE), PostureManifestEntry(None, '', 'sit', 'UpperBody', MATCH_NONE, MATCH_NONE, MATCH_NONE))).intern()
SIT_POSTURE_STATE_SPEC = create_body_posture_state_spec(SIT_POSTURE_MANIFEST)
SIT_NO_CARRY_NO_SURFACE_STATE_SPEC = create_body_posture_state_spec(SIT_NO_CARRY_NO_SURFACE_MANIFEST)
SIT_CONSTRAINT = Constraint(debug_name = 'Sit', posture_state_spec = SIT_POSTURE_STATE_SPEC)
SIT_NO_CARRY_NO_SURFACE_CONSTRAINT = Constraint(debug_name = 'SitNoCarryNoSurface', posture_state_spec = SIT_NO_CARRY_NO_SURFACE_STATE_SPEC)
SIT_INTIMATE_POSTURE_MANIFEST = PostureManifest((PostureManifestEntry(None, 'sitIntimate', '', 'FullBody', MATCH_NONE, MATCH_NONE, MATCH_NONE), PostureManifestEntry(None, 'sitIntimate', '', 'UpperBody', MATCH_NONE, MATCH_NONE, MATCH_NONE))).intern()
SIT_INTIMATE_POSTURE_STATE_SPEC = create_body_posture_state_spec(SIT_INTIMATE_POSTURE_MANIFEST)
SIT_INTIMATE_CONSTRAINT = Constraint(debug_name = 'SitIntimate', posture_state_spec = SIT_INTIMATE_POSTURE_STATE_SPEC)
STAND_OR_SIT_POSTURE_MANIFEST = PostureManifest(list(STAND_POSTURE_MANIFEST) + list(SIT_POSTURE_MANIFEST)).intern()
STAND_OR_SIT_CONSTRAINT = create_constraint_set((STAND_CONSTRAINT, SIT_CONSTRAINT), debug_name = 'Stand-or-Sit')
STAND_OR_SIT_CONSTRAINT_OUTER_PENALTY = create_constraint_set((STAND_CONSTRAINT_OUTER_PENALTY, SIT_CONSTRAINT), debug_name = 'Stand-or-Sit-Outer-Penalty')
Beispiel #36
0
 def create_constraint(self, sim, target=None, **kwargs):
     constraint_list = map(
         lambda c: c.create_constraint(sim, target=target, **kwargs),
         self.constraints)
     return create_constraint_set(constraint_list)