26 lines
760 B
GDScript
26 lines
760 B
GDScript
extends Node2D
|
|
|
|
@onready var RayCast : RayCast2D = $RayCast2D
|
|
|
|
var uses = 5
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
if RayCast.is_colliding():
|
|
var collisionObject = RayCast.get_collider()
|
|
if collisionObject is TileMapLayer:
|
|
var cell : Vector2i = collisionObject.local_to_map(RayCast.get_collision_point() + Vector2(5,0).rotated(global_rotation))
|
|
|
|
if collisionObject.get_cell_source_id(cell) == 0:
|
|
collisionObject.set_cell(cell,1,Vector2i(0, 0))
|
|
uses -= 1
|
|
get_parent().GUI.remove_item("Drill")
|
|
|
|
if uses == 0:
|
|
queue_free()
|