Réparation de bug, paufinnage du rayon tracteur et insert de l'outil dans l'histoire
This commit is contained in:
@@ -33,6 +33,12 @@ func get_icon() -> Texture2D:
|
||||
func get_pointer() -> Texture2D:
|
||||
return null
|
||||
|
||||
func get_clicked_pointer() -> Texture2D:
|
||||
return null
|
||||
|
||||
func is_pointer_center() -> bool:
|
||||
return false
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return energy_usage
|
||||
|
||||
@@ -48,11 +54,11 @@ func is_action_need_press_time() -> bool:
|
||||
func get_action_press_time() -> float:
|
||||
return DEFAULT_PRESS_TIME
|
||||
|
||||
func get_action_is_hold() -> bool:
|
||||
func deactivate_interactable() -> bool:
|
||||
return false
|
||||
|
||||
func get_usage_object_affected(_i : Area2D) -> bool:
|
||||
return false
|
||||
func get_usage_objects_affected(_areas : Array[Area2D], _zone : Player.ActionZone) -> Array[Area2D]:
|
||||
return []
|
||||
|
||||
func is_one_time_use():
|
||||
return false
|
||||
|
||||
@@ -27,26 +27,32 @@ func get_energy_used() -> int:
|
||||
func get_usage_zone_radius() -> int:
|
||||
return 10
|
||||
|
||||
func get_usage_object_affected(i : Area2D) -> bool:
|
||||
return i is Plant and Pointer.inspected == i
|
||||
func get_usage_objects_affected(areas : Array[Area2D], zone : Player.ActionZone) -> Array[Area2D]:
|
||||
areas = areas.filter(
|
||||
func (a): return a is Plant and a.position.distance_to(zone.area.position) < 5
|
||||
)
|
||||
if len(areas) == 0:
|
||||
return []
|
||||
else:
|
||||
return [areas[0]]
|
||||
|
||||
func use_text() -> String:
|
||||
return tr("HARVEST")
|
||||
|
||||
func can_use(_player : Player, zone : Player.ActionZone) -> bool:
|
||||
var areas = zone.get_affected_areas()
|
||||
for area in areas :
|
||||
if area is Plant and Pointer.inspected == area:
|
||||
return true
|
||||
print(zone)
|
||||
var areas = get_usage_objects_affected(zone.get_affected_areas(), zone)
|
||||
if len(areas) > 0:
|
||||
return true
|
||||
print("nope")
|
||||
return false
|
||||
|
||||
func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
var has_plant = false
|
||||
for area in zone.get_affected_areas():
|
||||
if area and area is Plant and Pointer.inspected == area:
|
||||
harvest(area, player)
|
||||
await player.get_tree().create_timer(USE_INTERVAL).timeout
|
||||
has_plant = true
|
||||
var areas = get_usage_objects_affected(zone.get_affected_areas(), zone)
|
||||
if len(areas) > 0:
|
||||
harvest(areas[0], player)
|
||||
has_plant = true
|
||||
return has_plant
|
||||
|
||||
func harvest(p : Plant, _player: Player):
|
||||
|
||||
@@ -74,8 +74,10 @@ func get_energy_used() -> int:
|
||||
func get_usage_zone_radius() -> int:
|
||||
return 10
|
||||
|
||||
func get_usage_object_affected(i : Area2D) -> bool:
|
||||
return i is PlantSprite
|
||||
func get_usage_objects_affected(areas : Array[Area2D], _zone : Player.ActionZone) -> Array[Area2D]:
|
||||
return areas.filter(
|
||||
func(a): return a is PlantSprite
|
||||
)
|
||||
|
||||
func snap_usage_to_grid():
|
||||
return true
|
||||
|
||||
@@ -17,8 +17,14 @@ func get_icon() -> Texture2D:
|
||||
func get_usage_zone_radius() -> int:
|
||||
return SHOVEL_ZONE_RADIUS
|
||||
|
||||
func get_usage_object_affected(i : Area2D) -> bool:
|
||||
return i is Plant
|
||||
func get_usage_objects_affected(areas : Array[Area2D], zone : Player.ActionZone) -> Array[Area2D]:
|
||||
areas.sort_custom(
|
||||
func (a1,a2): return a1.position.distance_to(zone.area.position) - a2.position.distance_to(zone.area.position)
|
||||
)
|
||||
if len(areas) == 0:
|
||||
return []
|
||||
else:
|
||||
return [areas[0]]
|
||||
|
||||
func use_text() -> String:
|
||||
return tr("DIG")
|
||||
|
||||
@@ -10,8 +10,16 @@ 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")
|
||||
return preload("res://common/icons/tractor-beam.svg")
|
||||
|
||||
func get_pointer() -> Texture2D:
|
||||
return preload("res://gui/pointer/assets/cursors/pointer-hand.svg")
|
||||
|
||||
func get_clicked_pointer() -> Texture2D:
|
||||
return preload("res://gui/pointer/assets/cursors/pointer-grab.svg")
|
||||
|
||||
func is_pointer_center() -> bool:
|
||||
return true
|
||||
|
||||
func get_item_type() -> ItemType:
|
||||
return Item.ItemType.TOOL_ITEM
|
||||
@@ -20,16 +28,16 @@ func get_energy_used() -> int:
|
||||
return 0
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
func is_usage_need_proximity() -> bool:
|
||||
return false
|
||||
|
||||
func get_action_is_hold() -> bool:
|
||||
func deactivate_interactable() -> bool:
|
||||
return true
|
||||
|
||||
func use_text() -> String:
|
||||
return tr("MOVE")
|
||||
return tr("")
|
||||
|
||||
func can_use(_player: Player, _zone: Player.ActionZone) -> bool:
|
||||
return Pointer.inspected != null
|
||||
@@ -38,12 +46,14 @@ func use(_player: Player, _zone: Player.ActionZone) -> bool:
|
||||
if Pointer.dragging_inspected:
|
||||
Pointer.stop_dragging()
|
||||
if !Pointer.dragging_inspected:
|
||||
AudioManager.play_sfx("TractorBeamDrop")
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
else:
|
||||
Pointer.start_dragging()
|
||||
if Pointer.dragging_inspected:
|
||||
AudioManager.play_sfx("TractorBeamTake")
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user