feat: make pantry crises visible in the world

This commit is contained in:
Rijad Zuzo
2026-07-14 23:54:22 +02:00
parent c722e32a88
commit c23f6887c8
21 changed files with 800 additions and 73 deletions
+22
View File
@@ -6,6 +6,7 @@ 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)
const CONCERN_BASE_POSITION := Vector3(-0.4, 2.72, 0.0)
@export var debug_logs := false
@@ -28,6 +29,7 @@ const TRUST_REACTION_START_SCALE := Vector3(0.24, 0.24, 0.24)
@onready var carried_wood_visual: Node3D = $CarriedWood
@onready var task_glyph_root: Node3D = $TaskGlyphRoot
@onready var task_glyph: MeshInstance3D = $TaskGlyphRoot/TaskGlyph
@onready var opportunity_concern_root: Node3D = $OpportunityConcernRoot
@onready var trust_reaction_root: Node3D = $TrustReactionRoot
@onready var trust_reaction_visuals: Array[MeshInstance3D] = [
$TrustReactionRoot/Halo,
@@ -54,6 +56,7 @@ var dead_material := StandardMaterial3D.new()
var debug_overlay_visible := true
var walk_phase := 0.0
var glyph_phase := 0.0
var concern_phase := 0.0
var trust_reaction_tween: Tween
@@ -74,6 +77,12 @@ func _process(delta: float) -> void:
if task_glyph_root.visible:
task_glyph_root.position.y = 2.35 + sin(glyph_phase) * 0.045
task_glyph_root.rotation.y = glyph_phase * 0.35
if opportunity_concern_root.visible:
concern_phase = fmod(concern_phase + delta * 1.65, TAU)
opportunity_concern_root.position.y = (CONCERN_BASE_POSITION.y + sin(concern_phase) * 0.045)
opportunity_concern_root.rotation.y = sin(concern_phase * 0.7) * 0.16
var concern_scale := 0.96 + sin(concern_phase) * 0.04
opportunity_concern_root.scale = Vector3.ONE * concern_scale
var horizontal_speed := Vector2(velocity.x, velocity.z).length()
var blend := minf(delta * 9.0, 1.0)
@@ -104,6 +113,7 @@ func setup_from_sim(npc: SimNPC) -> void:
profession = npc.profession
name = "NPC_%s_%s" % [sim_id, npc_name]
_stop_trust_gain_reaction()
set_opportunity_concern_visible(false)
_apply_personal_details()
_apply_profession_presentation()
set_carried_food_visible(npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD) > 0.0)
@@ -203,6 +213,17 @@ func set_task_presentation(action_id: StringName, task_state: StringName) -> voi
task_glyph_root.visible = task_glyph.mesh != null
func set_opportunity_concern_visible(is_visible: bool) -> void:
if opportunity_concern_root == null:
return
opportunity_concern_root.visible = is_visible and not is_dead_visual
opportunity_concern_root.position = CONCERN_BASE_POSITION
opportunity_concern_root.rotation = Vector3.ZERO
opportunity_concern_root.scale = Vector3.ONE
if is_visible:
concern_phase = 0.0
func set_debug_overlay_visible(is_visible: bool) -> void:
debug_overlay_visible = is_visible
if profession_label != null:
@@ -399,6 +420,7 @@ func _report_navigation_failure_once() -> void:
func apply_dead_visual_state() -> void:
is_dead_visual = true
_stop_trust_gain_reaction()
set_opportunity_concern_visible(false)
carried_food_visual.visible = false
carried_wood_visual.visible = false
profession_prop.visible = false
+44 -1
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=21 format=3 uid="uid://dhxxyprqflotq"]
[gd_scene load_steps=24 format=3 uid="uid://dhxxyprqflotq"]
[ext_resource type="Script" uid="uid://bha8uf40p3sa0" path="res://player/npc/NpcVisual.gd" id="1_ixfoq"]
@@ -106,6 +106,28 @@ height = 0.14
radial_segments = 8
rings = 4
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_concern"]
transparency = 1
shading_mode = 0
albedo_color = Color(0.74, 0.42, 0.3, 0.82)
emission_enabled = true
emission = Color(0.66, 0.24, 0.18, 1)
emission_energy_multiplier = 0.28
[sub_resource type="TorusMesh" id="TorusMesh_concern"]
material = SubResource("StandardMaterial3D_concern")
inner_radius = 0.13
outer_radius = 0.22
rings = 14
ring_segments = 8
[sub_resource type="SphereMesh" id="SphereMesh_concern"]
material = SubResource("StandardMaterial3D_concern")
radius = 0.06
height = 0.12
radial_segments = 8
rings = 4
[node name="NpcVisual" type="CharacterBody3D"]
collision_layer = 2
collision_mask = 1
@@ -205,6 +227,27 @@ position = Vector3(0, 2.35, 0)
[node name="TaskGlyph" type="MeshInstance3D" parent="TaskGlyphRoot"]
[node name="OpportunityConcernRoot" type="Node3D" parent="."]
visible = false
position = Vector3(-0.4, 2.72, 0)
[node name="EmptyBowl" type="MeshInstance3D" parent="OpportunityConcernRoot"]
rotation_degrees = Vector3(72, 0, 0)
scale = Vector3(1.15, 0.72, 1.15)
mesh = SubResource("TorusMesh_concern")
[node name="BreathLeft" type="MeshInstance3D" parent="OpportunityConcernRoot"]
position = Vector3(-0.14, 0.18, 0)
rotation_degrees = Vector3(0, 0, -24)
scale = Vector3(0.7, 1.3, 0.7)
mesh = SubResource("SphereMesh_concern")
[node name="BreathRight" type="MeshInstance3D" parent="OpportunityConcernRoot"]
position = Vector3(0.08, 0.26, 0)
rotation_degrees = Vector3(0, 0, 18)
scale = Vector3(0.55, 1.05, 0.55)
mesh = SubResource("SphereMesh_concern")
[node name="TrustReactionRoot" type="Node3D" parent="."]
visible = false
position = Vector3(0, 2.72, 0)