feat: add structured economic events

This commit is contained in:
2026-07-05 18:04:11 +02:00
parent ebf70a711a
commit f9601a67d1
11 changed files with 358 additions and 17 deletions
+8
View File
@@ -12,6 +12,7 @@ const DEBUG_LOGS := true
@export var stuck_timeout := 1.5
@onready var nav_agent: NavigationAgent3D = $NavigationAgent3D
@onready var carried_food_visual: MeshInstance3D = $CarriedFood
var has_reported_arrival := false
var sim_id: int = -1
@@ -41,6 +42,12 @@ func setup_from_sim(npc: SimNPC) -> void:
npc_name = npc.npc_name
profession = npc.profession
name = "NPC_%s_%s" % [sim_id, npc_name]
set_carried_food_visible(
npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD) > 0.0
)
func set_carried_food_visible(is_visible: bool) -> void:
carried_food_visual.visible = is_visible and not is_dead_visual
func set_target_position(pos: Vector3) -> void:
path_request_id += 1
@@ -167,6 +174,7 @@ func _report_navigation_failure_once() -> void:
func apply_dead_visual_state() -> void:
is_dead_visual = true
carried_food_visual.visible = false
path_request_id += 1
velocity = Vector3.ZERO
current_path = PackedVector3Array()
+15 -1
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=6 format=3 uid="uid://dhxxyprqflotq"]
[gd_scene load_steps=8 format=3 uid="uid://dhxxyprqflotq"]
[ext_resource type="Script" uid="uid://bha8uf40p3sa0" path="res://player/npc/NpcVisual.gd" id="1_ixfoq"]
@@ -12,6 +12,15 @@ albedo_color = Color(1, 0.22352941, 1, 1)
[sub_resource type="BoxMesh" id="BoxMesh_d844k"]
material = SubResource("StandardMaterial3D_d844k")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_food"]
albedo_color = Color(0.38, 0.22, 0.08, 1)
roughness = 0.9
[sub_resource type="SphereMesh" id="SphereMesh_food"]
material = SubResource("StandardMaterial3D_food")
radius = 0.28
height = 0.48
[node name="NpcVisual" type="CharacterBody3D"]
collision_layer = 2
collision_mask = 1
@@ -29,6 +38,11 @@ mesh = SubResource("CapsuleMesh_d844k")
transform = Transform3D(0.15, 0, 0, 0, 0.15, 0, 0, 0, 0.35, 0, 1.2, 0.59052056)
mesh = SubResource("BoxMesh_d844k")
[node name="CarriedFood" type="MeshInstance3D" parent="."]
visible = false
transform = Transform3D(0.75, 0, 0, 0, 0.75, 0, 0, 0, 0.75, 0.48, 0.7, 0)
mesh = SubResource("SphereMesh_food")
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="."]
path_desired_distance = 0.3
target_desired_distance = 0.5