many small changes, and few big ones

This commit is contained in:
ChaoticByte 2024-10-16 20:23:53 +02:00
parent e8985f4e79
commit a3ca623258
No known key found for this signature in database
32 changed files with 391 additions and 247 deletions

View file

@ -1,5 +1,5 @@
@tool
extends CollisionPolygon2D
class_name P extends CollisionPolygon2D
@export var color: Color = Color.WHITE:
set(v):
@ -8,18 +8,27 @@ extends CollisionPolygon2D
get():
return color
var polygon_2d: Polygon2D = null
var light_occluder_2d: LightOccluder2D = null
@export var update: bool:
set(v):
update_polygon()
func update_polygon():
# normal polygon
$Polygon2D.polygon = polygon
$Polygon2D.color = color
if polygon_2d == null:
polygon_2d = Polygon2D.new()
self.add_child(polygon_2d)
if light_occluder_2d == null:
light_occluder_2d = LightOccluder2D.new()
self.add_child(light_occluder_2d)
# visible polygon
polygon_2d.polygon = polygon
polygon_2d.color = color
# light occluder
var lo_polygon = OccluderPolygon2D.new()
lo_polygon.polygon = polygon
$LightOccluder2D.occluder = lo_polygon
light_occluder_2d.occluder = lo_polygon
func _ready() -> void:
update_polygon()