def notify_in_use(self, user, portal_instance, portal_object): if self.supports_landing_shoo: routing_surface = None exit_location = portal_instance.there_exit if exit_location.routing_surface.type == SurfaceType.SURFACETYPE_OBJECT: exit_height = terrain.get_terrain_height( exit_location.position.x, exit_location.position.z, routing_surface=exit_location.routing_surface) routing_surface = exit_location.routing_surface landing_points = [] for (there_start, there_end, back_start, back_end, _) in self.get_portal_locations(portal_object): for portal_location in (there_start, there_end, back_start, back_end): if portal_location.routing_surface.type == SurfaceType.SURFACETYPE_OBJECT: portal_height = terrain.get_terrain_height( portal_location.position.x, portal_location.position.z, routing_surface=portal_location.routing_surface ) if math.isclose(portal_height, exit_height): landing_points.append(portal_location.position) polygon = Polygon(landing_points) polygon = polygon.get_convex_hull() polygon = inflate_polygon( polygon, _PortalTypeDataStairs.STAIR_SHOO_POLYGON_PADDING) UserFootprintHelper.force_move_sims_in_polygon( polygon, routing_surface, exclude=(user, ))
def _get_cluster_polygon(self, position, objects): hull_points = [position] for obj in objects: if obj.parts: for part in obj.parts: hull_points.append(part.position) else: hull_points.append(obj.position) else: hull_points.append(obj.position) polygon = Polygon(hull_points) polygon = polygon.get_convex_hull() if len(polygon) == 2 or polygon.too_thin or polygon.too_small: sorted_x = sorted(hull_points, key=lambda p: p.x) sorted_z = sorted(hull_points, key=lambda p: p.z) delta_x = sorted_x[-1].x - sorted_x[0].x delta_z = sorted_z[-1].z - sorted_z[0].z extents = sorted_x if delta_x > delta_z else sorted_z a = extents[0] b = extents[-1] polygon = build_rectangle_from_two_points_and_radius(a, b, self.radius_buffer) else: polygon = sims4.geometry.inflate_polygon(polygon, self.radius_buffer) compound_polygon = sims4.geometry.CompoundPolygon([polygon]) return compound_polygon