Refactor player animation and collision based entrances
This commit is contained in:
26
Scripts/Utility/child_node_appender.gd
Normal file
26
Scripts/Utility/child_node_appender.gd
Normal file
@@ -0,0 +1,26 @@
|
||||
extends Node
|
||||
|
||||
# child_node_appender.gd
|
||||
|
||||
# All children of this node will be moved onto the node that is specified by
|
||||
# provided path relative to the parent of this node
|
||||
|
||||
@export var relative_path: String
|
||||
|
||||
func _ready() -> void:
|
||||
var parent := get_parent()
|
||||
|
||||
if parent == null:
|
||||
push_error("Child Node Appender has no parent")
|
||||
return
|
||||
|
||||
var node := parent.get_node_or_null(relative_path)
|
||||
|
||||
if node == null:
|
||||
push_error("Provided path does not resolve to a node")
|
||||
return
|
||||
|
||||
var children := get_children()
|
||||
for child in children:
|
||||
remove_child(child)
|
||||
node.add_child(child)
|
||||
1
Scripts/Utility/child_node_appender.gd.uid
Normal file
1
Scripts/Utility/child_node_appender.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dtwxia7rlu5xt
|
||||
13
Scripts/vector2_utils.gd
Normal file
13
Scripts/vector2_utils.gd
Normal file
@@ -0,0 +1,13 @@
|
||||
extends Node
|
||||
class_name Vector2Utils
|
||||
|
||||
static func GetClosestDirectionVector(dv: Vector2) -> Vector2:
|
||||
if dv == Vector2.ZERO:
|
||||
return dv
|
||||
if dv.y < 0:
|
||||
return Vector2.UP
|
||||
if dv.y > 0:
|
||||
return Vector2.DOWN
|
||||
if dv.x < 0:
|
||||
return Vector2.LEFT
|
||||
return Vector2.RIGHT
|
||||
1
Scripts/vector2_utils.gd.uid
Normal file
1
Scripts/vector2_utils.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b7tucdfjejupa
|
||||
Reference in New Issue
Block a user