Add new test file for phase 19 scenery with unique identifier
This commit is contained in:
@@ -16,6 +16,8 @@ extends StaticBody2D
|
||||
const POLYGON_NODE_NAME := "Polygon2D"
|
||||
const OUTLINE_NODE_NAME := "Outline"
|
||||
const COLLISION_NODE_NAME := "CollisionPolygon2D"
|
||||
const STAGE_SURFACE_RENDERER := preload("res://scripts/stage/scenery/stage_surface_renderer.gd")
|
||||
const STAGE_DRAW_ORDER := preload("res://scripts/stage/stage_draw_order.gd")
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Exported properties
|
||||
@@ -55,6 +57,9 @@ const COLLISION_NODE_NAME := "CollisionPolygon2D"
|
||||
## overlaps. Plain var (not inspector-editable).
|
||||
var spawn_id: String = ""
|
||||
|
||||
## Appearance-only identifier for Ground. Empty preserves the legacy vector fill.
|
||||
var finish_id: StringName = &""
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Internal node references (built in _ready, @tool-safe)
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -71,6 +76,15 @@ func _ready() -> void:
|
||||
_ensure_children()
|
||||
_apply_points()
|
||||
_apply_style()
|
||||
if spawn_id == "ground":
|
||||
STAGE_DRAW_ORDER.apply_terrain(self)
|
||||
|
||||
|
||||
func set_finish(id: StringName) -> void:
|
||||
finish_id = id if STAGE_SURFACE_RENDERER.is_ground_finish(id) else &""
|
||||
if _polygon != null:
|
||||
_polygon.visible = finish_id.is_empty()
|
||||
queue_redraw()
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Internal build / apply
|
||||
@@ -120,3 +134,14 @@ func _apply_style() -> void:
|
||||
if _outline != null:
|
||||
_outline.default_color = outline_color
|
||||
_outline.width = outline_width
|
||||
if _polygon != null:
|
||||
_polygon.visible = finish_id.is_empty()
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
if spawn_id != "ground" or finish_id.is_empty() or polygon_points.is_empty():
|
||||
return
|
||||
var rect := Rect2(polygon_points[0], Vector2.ZERO)
|
||||
for point: Vector2 in polygon_points:
|
||||
rect = rect.expand(point)
|
||||
STAGE_SURFACE_RENDERER.draw_ground(self, rect, finish_id, fill_color, global_position, global_scale)
|
||||
|
||||
Reference in New Issue
Block a user