feat: add npc decision inspector
This commit is contained in:
@@ -12,6 +12,9 @@ const DEBUG_LOGS := true
|
||||
@export var stuck_timeout := 1.5
|
||||
|
||||
@onready var nav_agent: NavigationAgent3D = $NavigationAgent3D
|
||||
@onready var body_mesh: MeshInstance3D = $MeshInstance3D
|
||||
@onready var profession_prop: MeshInstance3D = $ProfessionProp
|
||||
@onready var profession_label: Label3D = $ProfessionLabel
|
||||
@onready var carried_food_visual: MeshInstance3D = $CarriedFood
|
||||
|
||||
var has_reported_arrival := false
|
||||
@@ -45,9 +48,66 @@ func setup_from_sim(npc: SimNPC) -> void:
|
||||
npc_name = npc.npc_name
|
||||
profession = npc.profession
|
||||
name = "NPC_%s_%s" % [sim_id, npc_name]
|
||||
_apply_profession_presentation()
|
||||
set_carried_food_visible(npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD) > 0.0)
|
||||
|
||||
|
||||
func _apply_profession_presentation() -> void:
|
||||
var definition := SimulationDefinitions.get_profession(profession)
|
||||
if definition == null:
|
||||
profession_label.text = npc_name
|
||||
profession_prop.visible = false
|
||||
return
|
||||
|
||||
var body_material := StandardMaterial3D.new()
|
||||
body_material.albedo_color = definition.visual_color
|
||||
body_material.roughness = 0.82
|
||||
body_mesh.material_override = body_material
|
||||
|
||||
var prop_material := StandardMaterial3D.new()
|
||||
prop_material.albedo_color = definition.prop_color
|
||||
prop_material.roughness = 0.78
|
||||
profession_prop.material_override = prop_material
|
||||
profession_prop.mesh = _create_profession_prop_mesh()
|
||||
profession_prop.visible = profession_prop.mesh != null
|
||||
profession_label.text = "%s\n%s" % [npc_name, definition.display_name]
|
||||
|
||||
|
||||
func _create_profession_prop_mesh() -> PrimitiveMesh:
|
||||
profession_prop.position = Vector3(0.48, 0.85, 0.0)
|
||||
profession_prop.rotation_degrees = Vector3.ZERO
|
||||
match profession:
|
||||
SimulationIds.PROFESSION_FARMER:
|
||||
var basket := SphereMesh.new()
|
||||
basket.radius = 0.24
|
||||
basket.height = 0.34
|
||||
return basket
|
||||
SimulationIds.PROFESSION_WOODCUTTER:
|
||||
var tool := BoxMesh.new()
|
||||
tool.size = Vector3(0.12, 0.72, 0.16)
|
||||
profession_prop.position = Vector3(0.48, 0.92, 0.0)
|
||||
profession_prop.rotation_degrees.z = -18.0
|
||||
return tool
|
||||
SimulationIds.PROFESSION_GUARD:
|
||||
var shield := CylinderMesh.new()
|
||||
shield.top_radius = 0.3
|
||||
shield.bottom_radius = 0.3
|
||||
shield.height = 0.12
|
||||
profession_prop.rotation_degrees.x = 90.0
|
||||
return shield
|
||||
SimulationIds.PROFESSION_SCHOLAR:
|
||||
var book := BoxMesh.new()
|
||||
book.size = Vector3(0.42, 0.1, 0.3)
|
||||
return book
|
||||
SimulationIds.PROFESSION_WANDERER:
|
||||
var pack := SphereMesh.new()
|
||||
pack.radius = 0.28
|
||||
pack.height = 0.5
|
||||
profession_prop.position = Vector3(-0.42, 0.86, 0.0)
|
||||
return pack
|
||||
return null
|
||||
|
||||
|
||||
func set_carried_food_visible(is_visible: bool) -> void:
|
||||
carried_food_visual.visible = is_visible and not is_dead_visual
|
||||
|
||||
@@ -179,6 +239,7 @@ func _report_navigation_failure_once() -> void:
|
||||
func apply_dead_visual_state() -> void:
|
||||
is_dead_visual = true
|
||||
carried_food_visual.visible = false
|
||||
profession_prop.visible = false
|
||||
path_request_id += 1
|
||||
velocity = Vector3.ZERO
|
||||
current_path = PackedVector3Array()
|
||||
|
||||
Reference in New Issue
Block a user