feat: add person history and trust reactions

This commit is contained in:
Rijad Zuzo
2026-07-12 11:42:10 +02:00
parent 99b8146f75
commit 9fcf6a0a58
19 changed files with 543 additions and 90 deletions
+75
View File
@@ -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
+48 -1
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=18 format=3 uid="uid://dhxxyprqflotq"]
[gd_scene load_steps=21 format=3 uid="uid://dhxxyprqflotq"]
[ext_resource type="Script" uid="uid://bha8uf40p3sa0" path="res://player/npc/NpcVisual.gd" id="1_ixfoq"]
@@ -84,6 +84,28 @@ top_radius = 0.09
bottom_radius = 0.11
height = 0.62
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_trust_reaction"]
transparency = 1
shading_mode = 0
albedo_color = Color(1, 0.67, 0.24, 0.9)
emission_enabled = true
emission = Color(1, 0.52, 0.16, 1)
emission_energy_multiplier = 0.45
[sub_resource type="TorusMesh" id="TorusMesh_trust_reaction"]
material = SubResource("StandardMaterial3D_trust_reaction")
inner_radius = 0.17
outer_radius = 0.26
rings = 16
ring_segments = 8
[sub_resource type="SphereMesh" id="SphereMesh_trust_reaction"]
material = SubResource("StandardMaterial3D_trust_reaction")
radius = 0.075
height = 0.14
radial_segments = 8
rings = 4
[node name="NpcVisual" type="CharacterBody3D"]
collision_layer = 2
collision_mask = 1
@@ -183,6 +205,31 @@ position = Vector3(0, 2.35, 0)
[node name="TaskGlyph" type="MeshInstance3D" parent="TaskGlyphRoot"]
[node name="TrustReactionRoot" type="Node3D" parent="."]
visible = false
position = Vector3(0, 2.72, 0)
scale = Vector3(0.24, 0.24, 0.24)
[node name="Halo" type="MeshInstance3D" parent="TrustReactionRoot"]
mesh = SubResource("TorusMesh_trust_reaction")
[node name="MoteLeft" type="MeshInstance3D" parent="TrustReactionRoot"]
position = Vector3(-0.22, 0.08, 0)
rotation = Vector3(0, 0, -0.436332)
scale = Vector3(0.72, 1.25, 0.72)
mesh = SubResource("SphereMesh_trust_reaction")
[node name="MoteCenter" type="MeshInstance3D" parent="TrustReactionRoot"]
position = Vector3(0, 0.19, 0)
scale = Vector3(0.8, 1.35, 0.8)
mesh = SubResource("SphereMesh_trust_reaction")
[node name="MoteRight" type="MeshInstance3D" parent="TrustReactionRoot"]
position = Vector3(0.22, 0.08, 0)
rotation = Vector3(0, 0, 0.436332)
scale = Vector3(0.72, 1.25, 0.72)
mesh = SubResource("SphereMesh_trust_reaction")
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="."]
path_desired_distance = 0.3
target_desired_distance = 0.5