meat_madness_redux/godot/util.gd

40 lines
1011 B
GDScript3
Raw Normal View History

2022-11-27 13:31:09 -07:00
extends Node
2022-12-27 13:24:35 -07:00
# Updated by player
onready var player = null
2023-01-03 12:20:47 -07:00
onready var meat_sink_parameters = null
2023-01-03 13:19:39 -07:00
signal meat_sink_parameters
2023-01-03 23:20:07 -07:00
var shader = null
2022-11-27 13:31:09 -07:00
2023-01-03 14:35:40 -07:00
func never_called():
emit_signal("meat_sink_parameters")
2022-11-27 13:31:09 -07:00
func vec3_componentwise_clamp(vec: Vector3, lower: float, upper: float) -> Vector3:
return Vector3(
clamp(vec.x, lower, upper),
clamp(vec.y, lower, upper),
clamp(vec.z, lower, upper)
)
func vec2_xz_to_vec3(xz: Vector2, y: float = 0.0) -> Vector3:
return Vector3(xz.x, y, xz.y)
func vec3_xz(vec: Vector3) -> Vector2:
return Vector2(vec.x, vec.z)
func deactivate_node(node: Node):
node.set_process(false)
node.set_physics_process(false)
node.set_process_input(false)
func activate_node(node: Node):
node.set_process(true)
node.set_physics_process(true)
node.set_process_input(true)
2022-12-11 12:23:58 -07:00
func clamped_lerp(src: float, dest: float, weight: float, close_enough: float):
weight = clamp(weight, 0.0, 1.0)
var v = lerp(src, dest, weight)
if abs(dest - v) < close_enough:
return dest
return v