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
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
class_name PlayerStatusHud
|
||||
extends Control
|
||||
|
||||
const REFRESH_INTERVAL_SECONDS := 0.2
|
||||
|
||||
@export var simulation_manager: Node
|
||||
|
||||
@onready var status_label: Label = $StatusLabel
|
||||
|
||||
var cached_text := ""
|
||||
var _refresh_elapsed := 0.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -13,7 +16,11 @@ func _ready() -> void:
|
||||
_refresh(true)
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
func _process(delta: float) -> void:
|
||||
_refresh_elapsed += delta
|
||||
if _refresh_elapsed < REFRESH_INTERVAL_SECONDS:
|
||||
return
|
||||
_refresh_elapsed = fmod(_refresh_elapsed, REFRESH_INTERVAL_SECONDS)
|
||||
_refresh(false)
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ const SIZE_DIAL := 60.0
|
||||
const RING_RADIUS := 24.0
|
||||
const RING_THICKNESS := 4.0
|
||||
const GLOW_RADIUS := 2.5
|
||||
const REFRESH_INTERVAL_SECONDS := 0.1
|
||||
|
||||
const COLOR_NIGHT := Color(0.12, 0.16, 0.42, 1)
|
||||
const COLOR_DAWN := Color(0.95, 0.5, 0.2, 1)
|
||||
@@ -14,9 +15,14 @@ const COLOR_DUSK := Color(0.9, 0.35, 0.2, 1)
|
||||
const COLOR_BG := Color(0.06, 0.06, 0.08, 0.65)
|
||||
|
||||
var _last_fraction := -1.0
|
||||
var _refresh_elapsed := 0.0
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
func _process(delta: float) -> void:
|
||||
_refresh_elapsed += delta
|
||||
if _refresh_elapsed < REFRESH_INTERVAL_SECONDS:
|
||||
return
|
||||
_refresh_elapsed = fmod(_refresh_elapsed, REFRESH_INTERVAL_SECONDS)
|
||||
var fraction := _cycle_fraction()
|
||||
if not is_equal_approx(fraction, _last_fraction):
|
||||
_last_fraction = fraction
|
||||
|
||||
@@ -3,6 +3,7 @@ extends Control
|
||||
|
||||
const ENTER_OFFSET := 9.0
|
||||
const EXIT_OFFSET := 4.0
|
||||
const PROBE_INTERVAL_SECONDS := 0.1
|
||||
|
||||
@export var player: Node
|
||||
@export var simulation_manager: Node
|
||||
@@ -21,6 +22,7 @@ var current_context_key := ""
|
||||
var motion_tween: Tween
|
||||
var motion_version := 0
|
||||
var is_hiding := false
|
||||
var _probe_elapsed := 0.0
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -32,11 +34,17 @@ func _ready() -> void:
|
||||
call_deferred("refresh_note", true)
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
func _process(delta: float) -> void:
|
||||
_probe_elapsed += delta
|
||||
if _probe_elapsed < PROBE_INTERVAL_SECONDS:
|
||||
return
|
||||
_probe_elapsed = fmod(_probe_elapsed, PROBE_INTERVAL_SECONDS)
|
||||
refresh_note()
|
||||
|
||||
|
||||
func refresh_note(force: bool = false) -> void:
|
||||
if force:
|
||||
_probe_elapsed = 0.0
|
||||
if player == null or not player.has_method("get_nearby_villager_inspection"):
|
||||
current_context_key = ""
|
||||
_hide_note()
|
||||
|
||||
Reference in New Issue
Block a user