perf: harden runtime for weaker hardware
This commit is contained in:
@@ -2,6 +2,7 @@ class_name PlayerInteractionHud
|
||||
extends Control
|
||||
|
||||
const FEEDBACK_SECONDS := 2.0
|
||||
const PROBE_INTERVAL_SECONDS := 0.1
|
||||
const ENTER_OFFSET := 7.0
|
||||
const ACCENT_READY := Color(0.9, 0.63, 0.28, 0.95)
|
||||
const ACCENT_SUCCESS := Color(0.55, 0.78, 0.38, 0.95)
|
||||
@@ -20,6 +21,7 @@ var current_context_key := ""
|
||||
var feedback_version := 0
|
||||
var feedback_active := false
|
||||
var feedback_succeeded := false
|
||||
var _probe_elapsed := 0.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -34,12 +36,19 @@ func _ready() -> void:
|
||||
call_deferred("refresh_prompt", true)
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if not feedback_active:
|
||||
refresh_prompt()
|
||||
func _process(delta: float) -> void:
|
||||
if feedback_active:
|
||||
return
|
||||
_probe_elapsed += delta
|
||||
if _probe_elapsed < PROBE_INTERVAL_SECONDS:
|
||||
return
|
||||
_probe_elapsed = fmod(_probe_elapsed, PROBE_INTERVAL_SECONDS)
|
||||
refresh_prompt()
|
||||
|
||||
|
||||
func refresh_prompt(force: bool = false) -> void:
|
||||
if force:
|
||||
_probe_elapsed = 0.0
|
||||
if player == null or not player.has_method("get_interaction_context"):
|
||||
_hide_prompt()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user