|
|
@ -7,8 +7,10 @@ const PREFAB: PackedScene = preload("res://scenes/blocks/dropped_block.tscn") |
|
|
|
## The amount of time to wait before PickupArea is set to monitorable[br] |
|
|
|
## This is to ensure that the item isn't picked up immediately after throwing |
|
|
|
@export var pickup_timeout: int = 1 |
|
|
|
@export var lifetime_in_seconds: int = 10 ## Lifetime before despawning |
|
|
|
@export var animation_player: AnimationPlayer |
|
|
|
@export var block_mesh: BlockMesh |
|
|
|
@export var lifetime_timer: Timer |
|
|
|
@export var pickup_area: Area3D |
|
|
|
|
|
|
|
var id: String |
|
|
@ -16,6 +18,8 @@ var impulse: Vector3 = Vector3.ZERO |
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void: |
|
|
|
lifetime_timer.timeout.connect(_on_lifetime_timeout) |
|
|
|
|
|
|
|
## AnimationPlayer handles modifying BlockMesh scale, position, and rotation |
|
|
|
## The scale is NOT applied to any other node, including RigidBody and CollisionShape |
|
|
|
animation_player.play("start_animation") |
|
|
@ -40,6 +44,8 @@ func initialize(block_id: String, start_position: Vector3, drop_direction: Vecto |
|
|
|
impulse = drop_direction * drop_impulse |
|
|
|
apply_central_impulse(impulse) |
|
|
|
|
|
|
|
lifetime_timer.start(lifetime_in_seconds) |
|
|
|
|
|
|
|
func set_id(block_id: String) -> void: |
|
|
|
id = block_id |
|
|
|
if id in DBItems.data: |
|
|
@ -48,6 +54,9 @@ func set_id(block_id: String) -> void: |
|
|
|
printerr("Unknown Block ID: ", id) |
|
|
|
|
|
|
|
|
|
|
|
func _on_lifetime_timeout() -> void: |
|
|
|
call_deferred("queue_free") |
|
|
|
|
|
|
|
func _on_pickup_area_body_entered(body: Node3D) -> void: |
|
|
|
if not body is Player: return |
|
|
|
|
|
|
|