-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make rally point settable to units, closes #102
Co-authored-by: dyachan <[email protected]>
- Loading branch information
Showing
4 changed files
with
91 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,45 @@ | ||
extends Node3D | ||
|
||
var target_unit = null: | ||
set(a_target_unit): | ||
if target_unit == null and a_target_unit != null: | ||
a_target_unit.tree_exited.connect(_on_target_unit_tree_exited) | ||
hide() | ||
elif target_unit != null and a_target_unit == null: | ||
target_unit.tree_exited.disconnect(_on_target_unit_tree_exited) | ||
_reset_position_to_parent() | ||
if _unit.is_in_group("selected_units"): | ||
show() | ||
target_unit = a_target_unit | ||
|
||
@onready var _unit = get_parent() | ||
@onready var _animation_player = find_child("AnimationPlayer") | ||
|
||
|
||
func _ready(): | ||
_animation_player.play("idle") | ||
visible = _unit.is_in_group("selected_units") | ||
_unit.selected.connect(show) | ||
_unit.selected.connect(_show) | ||
_unit.deselected.connect(hide) | ||
|
||
|
||
func _physics_process(_delta): | ||
if target_unit != null: | ||
global_position = target_unit.global_position | ||
|
||
|
||
func _show(): | ||
if target_unit == null: | ||
show() | ||
else: | ||
var targetability = target_unit.find_child("Targetability") | ||
if targetability != null: | ||
targetability.animate() | ||
|
||
|
||
func _reset_position_to_parent(): | ||
global_position = _unit.global_position | ||
|
||
|
||
func _on_target_unit_tree_exited(): | ||
target_unit = null |