49 lines
1.4 KiB
GDScript
49 lines
1.4 KiB
GDScript
extends CSGBox3D
|
|
|
|
@onready var player: CharacterBody3D = get_tree().get_first_node_in_group("player")
|
|
@onready var player_ray: RayCast3D = get_tree().get_first_node_in_group("player_ray")
|
|
|
|
@export_flags("Slope", "Offset", "Base") var mode
|
|
@export_range(-1,1) var math_sign: int
|
|
@export var delta: float = 0.1
|
|
@export var base: int = 10
|
|
|
|
var control_num: int
|
|
|
|
func _ready() -> void:
|
|
control_num = self.name.right(self.name.length() - 12).to_int()
|
|
|
|
match mode:
|
|
1:
|
|
$InteractLabel.text = "[E] Slope"
|
|
2:
|
|
$InteractLabel.text = "[E] Offset"
|
|
4:
|
|
$InteractLabel.text = "[E] Base"
|
|
|
|
func _process(_delta: float) -> void:
|
|
|
|
if has_node("InteractLabel"):
|
|
if player_ray.is_colliding() and player_ray.get_collider() == self:
|
|
$InteractLabel.show()
|
|
else:
|
|
$InteractLabel.hide()
|
|
|
|
if player_ray.is_colliding() and player_ray.get_collider() == self:
|
|
pass
|
|
|
|
func interact():
|
|
##TODO Make it so self.name extracts the button number and matches it to the path number
|
|
match mode:
|
|
0:
|
|
assert(mode != 0, "ERROR: Mode must be set")
|
|
1:
|
|
##Change the slope of the paired curve function
|
|
get_parent().get_node("FunctionPath" + str(control_num)).slope += delta * math_sign
|
|
2:
|
|
##Change the offset of the paired curve function
|
|
get_parent().get_node("FunctionPath" + str(control_num)).offset += delta * math_sign
|
|
4:
|
|
##Change the offset of the paired curve function
|
|
get_parent().get_node("FunctionPath" + str(control_num)).log_base += base * math_sign
|