2020-02-01 10:27:48 +01:00
|
|
|
extends Spatial
|
|
|
|
class_name BodyPart
|
|
|
|
|
2020-02-01 12:02:39 +01:00
|
|
|
# Must be the direct child of an AttachmentPoint of the BodyBase
|
2020-02-01 10:27:48 +01:00
|
|
|
|
|
|
|
|
2020-02-01 15:47:56 +01:00
|
|
|
onready var base = get_parent().get_parent().get_parent()
|
2020-02-01 10:49:43 +01:00
|
|
|
onready var physics_shape = get_node("PartCollider")
|
|
|
|
|
2020-02-01 11:09:06 +01:00
|
|
|
var setup_done = false
|
|
|
|
|
2020-02-02 11:34:16 +01:00
|
|
|
export(float) var cost
|
|
|
|
|
2020-02-01 10:27:48 +01:00
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready() -> void:
|
|
|
|
assert(base is BodyBase)
|
2020-02-01 11:09:06 +01:00
|
|
|
|
|
|
|
|
|
|
|
func _process(delta: float) -> void:
|
2020-02-01 11:16:15 +01:00
|
|
|
# We do this here because we want the whole tree to really be done instancing
|
2020-02-01 11:09:06 +01:00
|
|
|
if not setup_done:
|
2020-02-01 13:00:25 +01:00
|
|
|
var translation = physics_shape.global_transform
|
2020-02-01 12:46:35 +01:00
|
|
|
print(translation)
|
2020-02-01 11:09:06 +01:00
|
|
|
|
|
|
|
remove_child(physics_shape)
|
|
|
|
base.add_child(physics_shape)
|
|
|
|
|
2020-02-01 13:00:25 +01:00
|
|
|
physics_shape.global_transform = translation
|
2020-02-01 11:16:15 +01:00
|
|
|
|
2020-02-01 11:09:06 +01:00
|
|
|
setup_done = true
|
2020-02-01 10:49:43 +01:00
|
|
|
|
|
|
|
|
2020-02-01 10:27:48 +01:00
|
|
|
# Do something with the base
|
|
|
|
func action():
|
|
|
|
pass
|