コード例 #1
0
 def _on_quadtree_changed(self):
     quadtree = services.sim_quadtree()
     if quadtree is None:
         return
     zone = services.current_zone()
     pos = sims4.math.Vector2(0, 0)
     bounds = sims4.geometry.QtCircle(pos, 10000)
     all_sims_positions = quadtree.query(bounds=bounds, level=self.ALL_LEVELS, filter=placement.ItemType.SIM_POSITION, flags=sims4.geometry.ObjectQuadTreeQueryFlag.IGNORE_LEVEL)
     all_intended = quadtree.query(bounds=bounds, level=self.ALL_LEVELS, filter=placement.ItemType.SIM_INTENDED_POSITION, flags=sims4.geometry.ObjectQuadTreeQueryFlag.IGNORE_LEVEL)
     all_suppressors = quadtree.query(bounds=bounds, level=self.ALL_LEVELS, filter=placement.ItemType.ROUTE_GOAL_SUPPRESSOR, flags=sims4.geometry.ObjectQuadTreeQueryFlag.IGNORE_LEVEL)
     with Context(self.layer) as layer:
         layer.set_color(Color.GREEN)
         for o in all_sims_positions:
             height = terrain.get_lot_level_height(o[2].center.x, o[2].center.y, o[3], zone.id) + 0.1
             pos = sims4.math.Vector3(o[2].center.x, height, o[2].center.y)
             layer.add_circle(pos, o[2].radius, altitude=KEEP_ALTITUDE)
         layer.set_color(Color.YELLOW)
         for o in all_intended:
             if isinstance(o[2], Polygon):
                 routing_surface = routing.SurfaceIdentifier(zone.id, o[3], routing.SURFACETYPE_WORLD)
                 layer.add_polygon(o[2], altitude=0.1, routing_surface=routing_surface)
             else:
                 height = terrain.get_lot_level_height(o[2].center.x, o[2].center.y, o[3], zone.id) + 0.1
                 pos = sims4.math.Vector3(o[2].center.x, height, o[2].center.y)
                 layer.add_circle(pos, o[2].radius, altitude=KEEP_ALTITUDE)
         layer.set_color(Color.RED)
         for o in all_suppressors:
             if isinstance(o[2], Polygon):
                 routing_surface = routing.SurfaceIdentifier(zone.id, o[3], routing.SURFACETYPE_WORLD)
                 layer.add_polygon(o[2], altitude=0.1, routing_surface=routing_surface)
             else:
                 height = terrain.get_lot_level_height(o[2].center.x, o[2].center.y, o[3], zone.id) + 0.1
                 pos = sims4.math.Vector3(o[2].center.x, height, o[2].center.y)
                 layer.add_circle(pos, o[2].radius, altitude=KEEP_ALTITUDE)
コード例 #2
0
 def _on_quadtree_changed(self):
     quadtree = services.sim_quadtree()
     if quadtree is None:
         return
     zone = services.current_zone()
     pos = sims4.math.Vector2(0, 0)
     bounds = sims4.geometry.QtCircle(pos, 10000)
     all_sims_positions = quadtree.query(
         bounds=bounds,
         level=self.ALL_LEVELS,
         filter=placement.ItemType.SIM_POSITION,
         flags=sims4.geometry.ObjectQuadTreeQueryFlag.IGNORE_LEVEL)
     all_intended = quadtree.query(
         bounds=bounds,
         level=self.ALL_LEVELS,
         filter=placement.ItemType.SIM_INTENDED_POSITION,
         flags=sims4.geometry.ObjectQuadTreeQueryFlag.IGNORE_LEVEL)
     all_suppressors = quadtree.query(
         bounds=bounds,
         level=self.ALL_LEVELS,
         filter=placement.ItemType.ROUTE_GOAL_SUPPRESSOR,
         flags=sims4.geometry.ObjectQuadTreeQueryFlag.IGNORE_LEVEL)
     with Context(self.layer) as layer:
         layer.set_color(Color.GREEN)
         for o in all_sims_positions:
             height = terrain.get_lot_level_height(
                 o[2].center.x, o[2].center.y, o[3], zone.id) + 0.1
             pos = sims4.math.Vector3(o[2].center.x, height, o[2].center.y)
             layer.add_circle(pos, o[2].radius, altitude=KEEP_ALTITUDE)
         layer.set_color(Color.YELLOW)
         for o in all_intended:
             if isinstance(o[2], Polygon):
                 routing_surface = routing.SurfaceIdentifier(
                     zone.id, o[3], routing.SURFACETYPE_WORLD)
                 layer.add_polygon(o[2],
                                   altitude=0.1,
                                   routing_surface=routing_surface)
             else:
                 height = terrain.get_lot_level_height(
                     o[2].center.x, o[2].center.y, o[3], zone.id) + 0.1
                 pos = sims4.math.Vector3(o[2].center.x, height,
                                          o[2].center.y)
                 layer.add_circle(pos, o[2].radius, altitude=KEEP_ALTITUDE)
         layer.set_color(Color.RED)
         for o in all_suppressors:
             if isinstance(o[2], Polygon):
                 routing_surface = routing.SurfaceIdentifier(
                     zone.id, o[3], routing.SURFACETYPE_WORLD)
                 layer.add_polygon(o[2],
                                   altitude=0.1,
                                   routing_surface=routing_surface)
             else:
                 height = terrain.get_lot_level_height(
                     o[2].center.x, o[2].center.y, o[3], zone.id) + 0.1
                 pos = sims4.math.Vector3(o[2].center.x, height,
                                          o[2].center.y)
                 layer.add_circle(pos, o[2].radius, altitude=KEEP_ALTITUDE)
コード例 #3
0
ファイル: terrain.py プロジェクト: johndpope/sims4-ai-engine
 def get_routing_surface_height_at(self, x, z, routing_surface):
     if routing_surface is None:
         return 0
     if routing_surface.type == routing.SURFACETYPE_WORLD:
         return terrain.get_lot_level_height(x, z, routing_surface.secondary_id, routing_surface.primary_id)
     if routing_surface.type == routing.SURFACETYPE_OBJECT:
         height = terrain.get_lot_level_height(x, z, routing_surface.secondary_id, services.current_zone().id)
         height = height + 1.0
         return height
コード例 #4
0
 def _get_positions(self):
     pos = self.transform.translation
     orient = self.transform.orientation
     offset = orient.transform_vector(sims4.math.Vector3(0.0, 0.0, 0.3))
     cross = orient.transform_vector(sims4.math.Vector3(0.05, 0.0, 0.0))
     p0 = pos + offset
     p1 = pos - offset
     p0.y = terrain.get_lot_level_height(p0.x, p0.z, self.routing_surface.secondary_id, self.routing_surface.primary_id)
     p1.y = terrain.get_lot_level_height(p1.x, p1.z, self.routing_surface.secondary_id, self.routing_surface.primary_id)
     return (p0, p1, cross)
コード例 #5
0
 def _on_quadtree_changed(self):
     fire_service = services.get_fire_service()
     fire_quadtree = fire_service.fire_quadtree
     flammable_quadtree = fire_service.flammable_objects_quadtree
     zone = services.current_zone()
     pos = sims4.math.Vector2(0, 0)
     bounds = sims4.geometry.QtCircle(pos, 10000)
     if fire_quadtree is not None:
         fire_objects = fire_quadtree.query(bounds)
     else:
         fire_objects = []
     if flammable_quadtree is not None:
         flammable_objects = flammable_quadtree.query(bounds)
     else:
         flammable_objects = []
     with Context(self.layer) as layer:
         layer.set_color(Color.RED)
         for obj in fire_objects:
             level = obj.location.level
             height = terrain.get_lot_level_height(
                 obj.position.x, obj.position.z, level, zone.id) + 0.1
             radius = FireService.FIRE_QUADTREE_RADIUS
             pos = sims4.math.Vector3(obj.position.x, height,
                                      obj.position.z)
             layer.add_circle(pos, radius, altitude=KEEP_ALTITUDE)
         layer.set_color(Color.YELLOW)
         for obj in flammable_objects:
             if obj.location.world_routing_surface is None:
                 pass
             level = obj.location.level
             height = terrain.get_lot_level_height(
                 obj.position.x, obj.position.z, level, zone.id) + 0.1
             radius = obj.object_radius
             if obj.fire_retardant:
                 radius += FireService.FIRE_RETARDANT_EXTRA_OBJECT_RADIUS
             location = sims4.math.Vector2(obj.position.x, obj.position.z)
             object_bounds = obj.object_bounds_for_flammable_object(
                 location=location,
                 fire_retardant_bonus=FireService.
                 FIRE_RETARDANT_EXTRA_OBJECT_RADIUS)
             if isinstance(object_bounds, QtCircle):
                 pos = sims4.math.Vector3(obj.position.x, height,
                                          obj.position.z)
                 layer.add_circle(pos, radius, altitude=KEEP_ALTITUDE)
             else:
                 while isinstance(object_bounds, QtRect):
                     v0 = sims4.math.Vector3(object_bounds.a.x, height,
                                             object_bounds.a.y)
                     v2 = sims4.math.Vector3(object_bounds.b.x, height,
                                             object_bounds.b.y)
                     delta = v2 - v0
                     v1 = v0 + sims4.math.Vector3(delta.x, 0, 0)
                     v3 = v0 + sims4.math.Vector3(0, 0, delta.z)
                     vertices = [v0, v1, v2, v3]
                     layer.add_polygon(vertices, altitude=KEEP_ALTITUDE)
コード例 #6
0
 def get_routing_surface_height_at(self, x, z, routing_surface):
     if routing_surface is None:
         return 0
     if routing_surface.type == routing.SURFACETYPE_WORLD:
         return terrain.get_lot_level_height(x, z,
                                             routing_surface.secondary_id,
                                             routing_surface.primary_id)
     if routing_surface.type == routing.SURFACETYPE_OBJECT:
         height = terrain.get_lot_level_height(x, z,
                                               routing_surface.secondary_id,
                                               services.current_zone().id)
         height = height + 1.0
         return height
コード例 #7
0
 def _on_quadtree_changed(self):
     fire_service = services.get_fire_service()
     fire_quadtree = fire_service.fire_quadtree
     flammable_quadtree = fire_service.flammable_objects_quadtree
     zone = services.current_zone()
     pos = sims4.math.Vector2(0, 0)
     bounds = sims4.geometry.QtCircle(pos, 10000)
     if fire_quadtree is not None:
         fire_objects = fire_quadtree.query(bounds)
     else:
         fire_objects = []
     if flammable_quadtree is not None:
         flammable_objects = flammable_quadtree.query(bounds)
     else:
         flammable_objects = []
     with Context(self.layer) as layer:
         layer.set_color(Color.RED)
         for obj in fire_objects:
             level = obj.location.level
             height = terrain.get_lot_level_height(obj.position.x, obj.position.z, level, zone.id) + 0.1
             radius = FireService.FIRE_QUADTREE_RADIUS
             pos = sims4.math.Vector3(obj.position.x, height, obj.position.z)
             layer.add_circle(pos, radius, altitude=KEEP_ALTITUDE)
         layer.set_color(Color.YELLOW)
         for obj in flammable_objects:
             if obj.location.world_routing_surface is None:
                 pass
             level = obj.location.level
             height = terrain.get_lot_level_height(obj.position.x, obj.position.z, level, zone.id) + 0.1
             radius = obj.object_radius
             if obj.fire_retardant:
                 radius += FireService.FIRE_RETARDANT_EXTRA_OBJECT_RADIUS
             location = sims4.math.Vector2(obj.position.x, obj.position.z)
             object_bounds = obj.object_bounds_for_flammable_object(location=location, fire_retardant_bonus=FireService.FIRE_RETARDANT_EXTRA_OBJECT_RADIUS)
             if isinstance(object_bounds, QtCircle):
                 pos = sims4.math.Vector3(obj.position.x, height, obj.position.z)
                 layer.add_circle(pos, radius, altitude=KEEP_ALTITUDE)
             else:
                 while isinstance(object_bounds, QtRect):
                     v0 = sims4.math.Vector3(object_bounds.a.x, height, object_bounds.a.y)
                     v2 = sims4.math.Vector3(object_bounds.b.x, height, object_bounds.b.y)
                     delta = v2 - v0
                     v1 = v0 + sims4.math.Vector3(delta.x, 0, 0)
                     v3 = v0 + sims4.math.Vector3(0, 0, delta.z)
                     vertices = [v0, v1, v2, v3]
                     layer.add_polygon(vertices, altitude=KEEP_ALTITUDE)
コード例 #8
0
 def _is_offset_from_object(self, portal_position, obj):
     if self._height_tolerance is None:
         return False
     if portal_position.routing_surface.type != SurfaceType.SURFACETYPE_WORLD:
         return False
     portal_height = terrain.get_lot_level_height(
         portal_position.position.x, portal_position.position.z,
         portal_position.routing_surface.secondary_id,
         portal_position.routing_surface.primary_id)
     portal_height_difference = abs(obj.position.y - portal_height)
     return portal_height_difference > self._height_tolerance
コード例 #9
0
 def _on_quadtree_changed(self):
     quadtree = services.sim_quadtree()
     if quadtree is None:
         return
     bounds = QtCircle(Vector2(0, 0), 10000)
     with Context(self.layer) as layer:
         filter_visualizers = ((placement.ItemType.SIM_POSITION, Color.GREEN), (placement.ItemType.SIM_INTENDED_POSITION, Color.YELLOW), (placement.ItemType.ROUTE_GOAL_SUPPRESSOR, Color.RED), (placement.ItemType.ROUTABLE_OBJECT_SURFACE, Color.CYAN))
         for (quadtree_filter, color) in filter_visualizers:
             layer.set_color(color)
             for o in quadtree.query(bounds=bounds, surface_id=routing.SurfaceIdentifier(0, 0, 0), filter=quadtree_filter, flags=ObjectQuadTreeQueryFlag.IGNORE_SURFACE):
                 if isinstance(o[2], Polygon):
                     layer.add_polygon(o[2], altitude=0.1, routing_surface=o[3])
                 else:
                     height = terrain.get_lot_level_height(o[2].center.x, o[2].center.y, o[3].secondary_id, services.current_zone_id()) + 0.1
                     layer.add_circle(sims4.math.Vector3(o[2].center.x, height, o[2].center.y), o[2].radius, altitude=KEEP_ALTITUDE)
コード例 #10
0
 def _spawn_sprinkler(self, fire):
     zone_id = sims4.zone_utils.get_zone_id()
     new_level = fire.location.level + 1
     if not build_buy.has_floor_at_location(zone_id, fire.position, new_level):
         return
     sprinkler_object = system.create_object(self.SPRINKLER_HEAD_OBJECT_DEF)
     sprinkler_location = fire.location.duplicate()
     new_translation = sims4.math.Vector3(*fire.position)
     height = terrain.get_lot_level_height(sprinkler_location.transform.translation.x, sprinkler_location.transform.translation.z, new_level, zone_id)
     new_translation.y = height - self.SPRINKLER_HEAD_CEILING_OFFSET
     sprinkler_location.transform = sims4.math.Transform(new_translation, sprinkler_location.transform.orientation)
     sprinkler_object.set_location(location=sprinkler_location)
     self._sprinkler_objects.add(sprinkler_object)
     sprinkler_object.vfx = FireService.SPRINKLER_EFFECT(sprinkler_object)
     sprinkler_object.vfx.start()
     return sprinkler_object
コード例 #11
0
ファイル: terrain.py プロジェクト: NeonOcean/Environment
 def get_routing_surface_height_at(self, x, z, routing_surface):
     if routing_surface is None:
         return 0
     return terrain.get_lot_level_height(x, z, routing_surface.secondary_id,
                                         routing_surface.primary_id,
                                         routing_surface.type)