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 _constraint_gen(cls, inst, sim, target, **kwargs): for constraint in super(SuperInteraction, cls)._constraint_gen(sim, target, **kwargs): yield constraint yield create_carry_constraint(target, debug_name='CarryForPutDown') if inst is not None: yield inst._carry_system_target.get_constraint(sim)
def _get_posture_constraint(self, strict=False): posture_state_constraint = self.body_posture_state_constraint posture_state_constraint = posture_state_constraint.get_holster_version( ) if posture_state_constraint.valid: if not self.body_state_spec_only: carry_left_constraint = create_carry_constraint( self.left.target, Hand.LEFT, strict=strict) posture_state_constraint = posture_state_constraint.intersect( carry_left_constraint) if posture_state_constraint.valid: carry_right_constraint = create_carry_constraint( self.right.target, Hand.RIGHT, strict=strict) posture_state_constraint = posture_state_constraint.intersect( carry_right_constraint) return posture_state_constraint
def _constraint_gen(cls, inst, sim, target, **kwargs): for constraint in super(SuperInteraction, cls)._constraint_gen(sim, target, **kwargs): yield constraint carry_constraint = create_carry_constraint( target, debug_name='CarryForAddInWorld') total_constraint = carry_constraint.intersect(STAND_OR_SIT_CONSTRAINT) yield total_constraint yield from put_down_geometry_constraint_gen(sim, target)
def _constraint_gen(cls, inst, sim, target, **kwargs): for constraint in super(SuperInteraction, cls)._constraint_gen(sim, target, **kwargs): yield constraint obj = cls.object_to_put_down(inst, sim=sim, target=target) yield create_carry_constraint(obj, debug_name='CarryForPutDown') yield Circle(sim.position, PUT_DOWN_GEOMETRY_RADIUS, routing_surface=sim.routing_surface)
def _constraint_gen(cls, inst, sim, target, **kwargs): for constraint in super(TerrainSuperInteraction, cls)._constraint_gen(sim, target, **kwargs): yield constraint carry_target = inst.carry_target if inst is not None else None if carry_target is not None: yield create_carry_constraint(carry_target, debug_name='CarryForPutDown') if not carry_target.transient and inst._carry_system_target.transform is not None: yield carry_target.get_carry_transition_constraint( sim, inst._carry_system_target.transform.translation, sim.routing_surface)
def _constraint_gen(cls, inst, sim, target, *args, to_zone_id=DEFAULT, **kwargs): yield from super(__class__, inst if inst is not None else cls)._constraint_gen( sim, target, *args, **kwargs) if inst is not None: care_dependent = inst._get_primary_care_dependent() if care_dependent is not None: yield create_carry_constraint(care_dependent)
def create_put_down_in_self_inventory_constraint(inst, sim, target, cost=0): if cost is None: return Nowhere('No Cost({}). Sim: {} Target: {}', cost, sim, target) carry_constraint = create_carry_constraint( target, debug_name='CarryForPutDownInSimInventory') carry_constraint = carry_constraint.generate_constraint_with_cost(cost) constraint = sim.get_inventory_access_constraint(sim, True, target) constraint = constraint.apply_posture_state( None, inst.get_constraint_resolver(None)) posture_slot_constraint = sim.posture.slot_constraint if posture_slot_constraint: if not sim.parent_may_move: constraint = constraint.intersect(posture_slot_constraint) else: constraint = constraint.intersect( Circle(sim.position, PUT_DOWN_GEOMETRY_RADIUS, sim.routing_surface)) final_constraint = carry_constraint.intersect(constraint) return final_constraint
def create_put_down_on_ground_constraint(sim, target, terrain_transform, routing_surface=DEFAULT, cost=0): if cost is None or terrain_transform is None: return Nowhere( 'Put Down On Ground with either no Cost({}) or Transform({}) Sim:{} Target:{}', cost, terrain_transform, sim, target) routing_surface = sim.routing_surface if routing_surface is DEFAULT else routing_surface swipe_constraint = target.get_carry_transition_constraint( sim, terrain_transform.translation, routing_surface) if target.is_sim: if target.should_be_swimming_at_position(terrain_transform.translation, routing_surface.secondary_id, check_can_swim=False): DEFAULT_SIM_PUT_DOWN_OCEAN_CONSTRAINT_RADIUS = 10.0 DEFAULT_SIM_PUT_DOWN_OCEAN_INTERVAL = WaterDepthIntervals.WET start_constraint = OceanStartLocationConstraint.create_simple_constraint( DEFAULT_SIM_PUT_DOWN_OCEAN_INTERVAL, DEFAULT_SIM_PUT_DOWN_OCEAN_CONSTRAINT_RADIUS, target, target_position=terrain_transform.translation, routing_surface=routing_surface) depth_constraint = WaterDepthIntervalConstraint.create_water_depth_interval_constraint( target, DEFAULT_SIM_PUT_DOWN_OCEAN_INTERVAL) swipe_constraint = swipe_constraint.generate_alternate_geometry_constraint( start_constraint.geometry) swipe_constraint = swipe_constraint.generate_alternate_water_depth_constraint( depth_constraint.get_min_water_depth(), depth_constraint.get_max_water_depth()) swipe_constraint = swipe_constraint._copy(_multi_surface=False) carry_constraint = create_carry_constraint( target, debug_name='CarryForPutDownOnGround') final_constraint = swipe_constraint.intersect(carry_constraint).intersect( STAND_AT_NONE_CONSTRAINT) return final_constraint.generate_constraint_with_cost(cost)
def _constraint_gen(cls, inst, sim, target, **kwargs): for constraint in super(SuperInteraction, cls)._constraint_gen(sim, target, **kwargs): yield constraint yield create_carry_constraint(target, debug_name='CarryForPutDown') yield from put_down_geometry_constraint_gen(sim, target)