mirror of
https://github.com/Relintai/broken_seals.git
synced 2025-01-22 02:17:18 +01:00
The trainer window will now close itself if the player gets too far.
This commit is contained in:
parent
6c7f8625b5
commit
78af5acc8a
@ -41,6 +41,7 @@ var _spell_description_label : Label
|
||||
var _spell_requirements_label : Label
|
||||
|
||||
var _player : Entity
|
||||
var _trainer : Entity
|
||||
|
||||
var _entity_data : EntityData
|
||||
var _character_class : EntityClassData
|
||||
@ -49,6 +50,8 @@ var _spells : Array
|
||||
|
||||
var _spell_button_group : ButtonGroup
|
||||
|
||||
var _timer : float = 0
|
||||
|
||||
func _ready() -> void:
|
||||
_spell_button_group = ButtonGroup.new()
|
||||
|
||||
@ -65,6 +68,25 @@ func _ready() -> void:
|
||||
_learn_button.connect("pressed", self, "learn")
|
||||
|
||||
connect("visibility_changed", self, "_visibility_changed")
|
||||
|
||||
set_process(false)
|
||||
|
||||
func _process(delta):
|
||||
_timer += delta
|
||||
|
||||
if _timer > 1:
|
||||
_timer = 0
|
||||
|
||||
if _player == null:
|
||||
return
|
||||
|
||||
var target : Entity = _player.getc_target()
|
||||
|
||||
if target != _trainer:
|
||||
hide()
|
||||
|
||||
if (_player.get_body_3d().translation - target.get_body_3d().translation).length_squared() > 16:#INTERACT_RANGE_SQUARED:
|
||||
hide()
|
||||
|
||||
func learn() -> void:
|
||||
if _character_class == null:
|
||||
@ -128,6 +150,10 @@ func refresh_all() -> void:
|
||||
func _visibility_changed() -> void:
|
||||
if visible:
|
||||
refresh_all()
|
||||
else:
|
||||
_trainer = null
|
||||
|
||||
set_process(visible)
|
||||
|
||||
func set_player(p_player: Entity) -> void:
|
||||
if _player != null:
|
||||
@ -221,6 +247,8 @@ func onc_open_winow_request(window_id : int) -> void:
|
||||
if window_id != EntityEnums.ENTITY_WINDOW_TRAINER:
|
||||
return
|
||||
|
||||
_trainer = _player.getc_target()
|
||||
|
||||
show()
|
||||
|
||||
# if player.has_signal("player_moved") && !player.is_connected("player_moved", self, "on_player_moved"):
|
||||
|
@ -11,6 +11,9 @@ size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme = ExtResource( 2 )
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
spell_entry_container_path = NodePath("PanelContainer/VBoxContainer/PanelContainer3/ScrollContainer/Spells")
|
||||
learn_button_path = NodePath("PanelContainer/VBoxContainer/HBoxContainer/Train")
|
||||
cost_label_path = NodePath("PanelContainer/VBoxContainer/PanelContainer2/VBoxContainer/HBoxContainer2/Price")
|
||||
@ -154,4 +157,5 @@ margin_right = 379.0
|
||||
margin_bottom = 26.5702
|
||||
rect_min_size = Vector2( 100, 0 )
|
||||
text = "Learn"
|
||||
|
||||
[connection signal="pressed" from="PanelContainer/VBoxContainer/HBoxContainer2/Button" to="." method="hide"]
|
||||
|
Loading…
Reference in New Issue
Block a user