Most of prototype! yay
This commit is contained in:
23
entities/energy_flow/energy_flow_line.gd
Normal file
23
entities/energy_flow/energy_flow_line.gd
Normal file
@@ -0,0 +1,23 @@
|
||||
extends Node2D
|
||||
|
||||
@onready var energy_line: Line2D = %EnergyLine
|
||||
@onready var ray_cast: RayCast2D = %RayCast
|
||||
|
||||
@export_range(1,999,8) var maximum_flow_distance: float
|
||||
|
||||
func _ready() -> void:
|
||||
var target_position := Vector2(maximum_flow_distance, 0)
|
||||
|
||||
energy_line.add_point(Vector2.ZERO)
|
||||
energy_line.add_point(target_position)
|
||||
|
||||
ray_cast.target_position = target_position
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
energy_line.clear_points()
|
||||
if ray_cast.is_colliding():
|
||||
energy_line.add_point(Vector2.ZERO)
|
||||
energy_line.add_point(ray_cast.get_collision_point() - global_position)
|
||||
else :
|
||||
energy_line.add_point(Vector2.ZERO)
|
||||
energy_line.add_point(Vector2(maximum_flow_distance, 0))
|
||||
1
entities/energy_flow/energy_flow_line.gd.uid
Normal file
1
entities/energy_flow/energy_flow_line.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dtbeaqn2f6anq
|
||||
15
entities/energy_flow/energy_flow_line.tscn
Normal file
15
entities/energy_flow/energy_flow_line.tscn
Normal file
@@ -0,0 +1,15 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dpgncxhv41apt"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dtbeaqn2f6anq" path="res://entities/energy_flow/energy_flow_line.gd" id="1_fx3ax"]
|
||||
|
||||
[node name="EnergyFlowLine" type="Node2D"]
|
||||
script = ExtResource("1_fx3ax")
|
||||
maximum_flow_distance = 305.0
|
||||
|
||||
[node name="EnergyLine" type="Line2D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
width = 3.0
|
||||
default_color = Color(0.705901, 0.0965751, 0.690904, 1)
|
||||
|
||||
[node name="RayCast" type="RayCast2D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
Reference in New Issue
Block a user