2020-02-02 13:59:16 +01:00

48 lines
1.0 KiB
GDScript

extends Spatial
class_name BodyPart
# Must be the direct child of an AttachmentPoint of the BodyBase
onready var base = get_parent().get_parent().get_parent()
onready var physics_shape = get_node("PartCollider")
onready var action_sound = get_node("ActionSound")
var setup_done = false
export(float) var cost
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
assert(base is BodyBase)
func _process(delta: float) -> void:
# We do this here because we want the whole tree to really be done instancing
if not setup_done:
var translation = physics_shape.global_transform
print(translation)
var attach_id = get_parent().get_parent().id
remove_child(physics_shape)
physics_shape.name = "LimbCollider" + str(attach_id)
base.add_child(physics_shape)
physics_shape.global_transform = translation
setup_done = true
func action_wrapper():
if not action_sound.playing:
action_sound.play()
action()
# Do something with the base
func action():
pass