many small changes, and few big ones
This commit is contained in:
parent
e8985f4e79
commit
a3ca623258
32 changed files with 391 additions and 247 deletions
|
@ -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()
|
||||
|
|
Reference in a new issue