feat: add person history and trust reactions
This commit is contained in:
@@ -4,6 +4,9 @@ signal arrived_at_target(sim_id: int)
|
||||
signal navigation_failed(sim_id: int)
|
||||
signal position_changed(sim_id: int, active_position: Vector3)
|
||||
|
||||
const TRUST_REACTION_BASE_POSITION := Vector3(0.0, 2.72, 0.0)
|
||||
const TRUST_REACTION_START_SCALE := Vector3(0.24, 0.24, 0.24)
|
||||
|
||||
@export var debug_logs := false
|
||||
|
||||
@export var move_speed := 3.0
|
||||
@@ -25,6 +28,13 @@ signal position_changed(sim_id: int, active_position: Vector3)
|
||||
@onready var carried_wood_visual: Node3D = $CarriedWood
|
||||
@onready var task_glyph_root: Node3D = $TaskGlyphRoot
|
||||
@onready var task_glyph: MeshInstance3D = $TaskGlyphRoot/TaskGlyph
|
||||
@onready var trust_reaction_root: Node3D = $TrustReactionRoot
|
||||
@onready var trust_reaction_visuals: Array[MeshInstance3D] = [
|
||||
$TrustReactionRoot/Halo,
|
||||
$TrustReactionRoot/MoteLeft,
|
||||
$TrustReactionRoot/MoteCenter,
|
||||
$TrustReactionRoot/MoteRight,
|
||||
]
|
||||
|
||||
var has_reported_arrival := false
|
||||
var sim_id: int = -1
|
||||
@@ -44,6 +54,7 @@ var dead_material := StandardMaterial3D.new()
|
||||
var debug_overlay_visible := true
|
||||
var walk_phase := 0.0
|
||||
var glyph_phase := 0.0
|
||||
var trust_reaction_tween: Tween
|
||||
|
||||
|
||||
func debug_log(message: String) -> void:
|
||||
@@ -53,6 +64,7 @@ func debug_log(message: String) -> void:
|
||||
|
||||
func _ready() -> void:
|
||||
dead_material.albedo_color = Color(0.25, 0.25, 0.25, 1.0)
|
||||
_stop_trust_gain_reaction()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
@@ -91,6 +103,7 @@ func setup_from_sim(npc: SimNPC) -> void:
|
||||
npc_name = npc.npc_name
|
||||
profession = npc.profession
|
||||
name = "NPC_%s_%s" % [sim_id, npc_name]
|
||||
_stop_trust_gain_reaction()
|
||||
_apply_personal_details()
|
||||
_apply_profession_presentation()
|
||||
set_carried_food_visible(npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD) > 0.0)
|
||||
@@ -196,6 +209,67 @@ func set_debug_overlay_visible(is_visible: bool) -> void:
|
||||
profession_label.visible = is_visible and not is_dead_visual
|
||||
|
||||
|
||||
func play_trust_gain_reaction() -> void:
|
||||
if is_dead_visual or trust_reaction_root == null:
|
||||
return
|
||||
_stop_trust_gain_reaction()
|
||||
trust_reaction_root.visible = true
|
||||
trust_reaction_root.position = TRUST_REACTION_BASE_POSITION
|
||||
trust_reaction_root.rotation = Vector3.ZERO
|
||||
trust_reaction_root.scale = TRUST_REACTION_START_SCALE
|
||||
_set_trust_reaction_transparency(1.0)
|
||||
|
||||
trust_reaction_tween = create_tween()
|
||||
trust_reaction_tween.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
|
||||
trust_reaction_tween.tween_property(trust_reaction_root, "scale", Vector3.ONE, 0.22)
|
||||
trust_reaction_tween.parallel().tween_method(_set_trust_reaction_transparency, 1.0, 0.0, 0.22)
|
||||
trust_reaction_tween.tween_property(
|
||||
trust_reaction_root,
|
||||
"position",
|
||||
TRUST_REACTION_BASE_POSITION + Vector3(0.0, 0.16, 0.0),
|
||||
0.68
|
||||
)
|
||||
trust_reaction_tween.parallel().tween_property(trust_reaction_root, "rotation:y", 0.32, 0.68)
|
||||
trust_reaction_tween.tween_property(
|
||||
trust_reaction_root,
|
||||
"position",
|
||||
TRUST_REACTION_BASE_POSITION + Vector3(0.0, 0.44, 0.0),
|
||||
0.55
|
||||
)
|
||||
trust_reaction_tween.parallel().tween_property(
|
||||
trust_reaction_root, "scale", Vector3.ONE * 1.16, 0.55
|
||||
)
|
||||
trust_reaction_tween.parallel().tween_method(_set_trust_reaction_transparency, 0.0, 1.0, 0.55)
|
||||
trust_reaction_tween.tween_callback(_finish_trust_gain_reaction)
|
||||
|
||||
|
||||
func _set_trust_reaction_transparency(value: float) -> void:
|
||||
for visual in trust_reaction_visuals:
|
||||
visual.transparency = clampf(value, 0.0, 1.0)
|
||||
|
||||
|
||||
func _finish_trust_gain_reaction() -> void:
|
||||
trust_reaction_root.visible = false
|
||||
trust_reaction_root.position = TRUST_REACTION_BASE_POSITION
|
||||
trust_reaction_root.rotation = Vector3.ZERO
|
||||
trust_reaction_root.scale = TRUST_REACTION_START_SCALE
|
||||
_set_trust_reaction_transparency(1.0)
|
||||
trust_reaction_tween = null
|
||||
|
||||
|
||||
func _stop_trust_gain_reaction() -> void:
|
||||
if trust_reaction_tween != null:
|
||||
trust_reaction_tween.kill()
|
||||
trust_reaction_tween = null
|
||||
if trust_reaction_root == null:
|
||||
return
|
||||
trust_reaction_root.visible = false
|
||||
trust_reaction_root.position = TRUST_REACTION_BASE_POSITION
|
||||
trust_reaction_root.rotation = Vector3.ZERO
|
||||
trust_reaction_root.scale = TRUST_REACTION_START_SCALE
|
||||
_set_trust_reaction_transparency(1.0)
|
||||
|
||||
|
||||
func set_target_position(pos: Vector3) -> void:
|
||||
path_request_id += 1
|
||||
var request_id := path_request_id
|
||||
@@ -324,6 +398,7 @@ func _report_navigation_failure_once() -> void:
|
||||
|
||||
func apply_dead_visual_state() -> void:
|
||||
is_dead_visual = true
|
||||
_stop_trust_gain_reaction()
|
||||
carried_food_visual.visible = false
|
||||
carried_wood_visual.visible = false
|
||||
profession_prop.visible = false
|
||||
|
||||
Reference in New Issue
Block a user