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()
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://cbynoofsjcl45"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://c7cflclgotwsr"]
|
||||
|
||||
[ext_resource type="Script" path="res://core/polygon/polygon.gd" id="1_ga37f"]
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id="OccluderPolygon2D_2cqf3"]
|
||||
[sub_resource type="OccluderPolygon2D" id="OccluderPolygon2D_b1ir8"]
|
||||
|
||||
[node name="Polygon" type="CollisionPolygon2D"]
|
||||
script = ExtResource("1_ga37f")
|
||||
|
@ -11,4 +11,4 @@ script = ExtResource("1_ga37f")
|
|||
|
||||
[node name="LightOccluder2D" type="LightOccluder2D" parent="."]
|
||||
editor_description = "For particle collisions"
|
||||
occluder = SubResource("OccluderPolygon2D_2cqf3")
|
||||
occluder = SubResource("OccluderPolygon2D_b1ir8")
|
||||
|
|
Reference in a new issue