ajout d'un terrain infini et la possibilité de planter n'importe où
This commit is contained in:
41
entities/player/inventory/scripts/items/pickaxe.gd
Normal file
41
entities/player/inventory/scripts/items/pickaxe.gd
Normal file
@@ -0,0 +1,41 @@
|
||||
extends Item
|
||||
class_name Pickaxe
|
||||
|
||||
const USE_INTERVAL = 0.15
|
||||
|
||||
func get_item_name() -> String:
|
||||
return tr("PICKAXE")
|
||||
|
||||
func get_description() -> String:
|
||||
return tr("PICKAXE_DESC_TEXT")
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
return preload("res://common/icons/pick.svg")
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 1
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return 50
|
||||
|
||||
func use_text() -> String:
|
||||
return tr("DIG")
|
||||
|
||||
func can_use(_player : Player, zone : Player.ActionZone) -> bool:
|
||||
if zone and zone.area:
|
||||
var bodies = zone.area.get_overlapping_bodies()
|
||||
for body in bodies :
|
||||
if body is RockLayer:
|
||||
return true
|
||||
return false
|
||||
|
||||
func use(_player : Player, zone : Player.ActionZone) -> bool:
|
||||
|
||||
var bodies = zone.area.get_overlapping_bodies()
|
||||
var rock_layer_id = bodies.find_custom(func (b) : return b is RockLayer)
|
||||
if rock_layer_id != -1:
|
||||
var rock_layer : RockLayer = bodies[rock_layer_id]
|
||||
|
||||
return rock_layer.dig_rocks(zone.get_tiles())
|
||||
|
||||
return false
|
||||
Reference in New Issue
Block a user