Tractor beam
This commit is contained in:
@@ -17,7 +17,10 @@ func _init(size : int = 1):
|
||||
seeds_size = size
|
||||
|
||||
func current_is_tool() -> bool:
|
||||
return current_item_ind < len(tools)
|
||||
return ind_is_tool(current_item_ind)
|
||||
|
||||
func ind_is_tool(ind:int)->bool:
|
||||
return ind < len(tools)
|
||||
|
||||
func set_current_item(new_ind: int):
|
||||
if new_ind < 0:
|
||||
@@ -75,7 +78,7 @@ func update_seeds_size(size = seeds_size):
|
||||
|
||||
func add_item_at(item: Item, item_ind: int) -> bool:
|
||||
if item.type == Item.ItemType.CONSUMABLE_ITEM:
|
||||
return add_seed_at(item, item_ind - tools.size())
|
||||
return add_seed_at(item, item_ind - len(tools))
|
||||
else:
|
||||
return false
|
||||
|
||||
@@ -89,7 +92,7 @@ func add_seed_at(s: Item, seed_ind: int) -> bool:
|
||||
return true
|
||||
|
||||
func get_all_items_size() -> int:
|
||||
return tools.size() + seeds.size()
|
||||
return len(tools) + len(seeds)
|
||||
|
||||
func get_all_items() -> Array[Item]:
|
||||
return tools + seeds
|
||||
|
||||
@@ -48,6 +48,9 @@ func is_action_need_press_time() -> bool:
|
||||
func get_action_press_time() -> float:
|
||||
return DEFAULT_PRESS_TIME
|
||||
|
||||
func get_action_is_hold() -> bool:
|
||||
return false
|
||||
|
||||
func get_usage_object_affected(_i : Area2D) -> bool:
|
||||
return false
|
||||
|
||||
|
||||
49
entities/player/inventory/scripts/items/tractor_beam.gd
Normal file
49
entities/player/inventory/scripts/items/tractor_beam.gd
Normal file
@@ -0,0 +1,49 @@
|
||||
extends Item
|
||||
class_name TractorBeam
|
||||
|
||||
const USE_INTERVAL = 0.15
|
||||
|
||||
func get_item_name() -> String:
|
||||
return tr("TRACTOR_BEAM")
|
||||
|
||||
func get_description() -> String:
|
||||
return tr("TRACTOR_BEAM_DESC_TEXT")
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
# return preload("res://common/icons/tractor_beam.svg")
|
||||
return preload("res://common/icons/alert-triangle.svg")
|
||||
|
||||
func get_item_type() -> ItemType:
|
||||
return Item.ItemType.TOOL_ITEM
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 0
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return 1
|
||||
|
||||
func is_usage_need_proximity() -> bool:
|
||||
return false
|
||||
|
||||
func get_action_is_hold() -> bool:
|
||||
return true
|
||||
|
||||
func use_text() -> String:
|
||||
return tr("MOVE")
|
||||
|
||||
func can_use(_player: Player, _zone: Player.ActionZone) -> bool:
|
||||
return Pointer.inspected != null
|
||||
|
||||
func use(_player: Player, _zone: Player.ActionZone) -> bool:
|
||||
if Pointer.dragging_inspected:
|
||||
Pointer.stop_dragging()
|
||||
if !Pointer.dragging_inspected:
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
else:
|
||||
Pointer.start_dragging()
|
||||
if Pointer.dragging_inspected:
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
@@ -0,0 +1 @@
|
||||
uid://drs03fydfofxx
|
||||
Reference in New Issue
Block a user