feat: add location-based food storage loop
This commit is contained in:
+13
-5
@@ -28,6 +28,7 @@ var task_complete := true
|
||||
var target_id: StringName = &""
|
||||
var travel_target_position: Vector3
|
||||
var has_travel_target := false
|
||||
var inventory: Dictionary = {}
|
||||
var last_task: StringName
|
||||
var random_source: RandomNumberGenerator
|
||||
var debug_logs := true
|
||||
@@ -69,12 +70,19 @@ func die_from_starvation() -> void:
|
||||
if debug_logs:
|
||||
print("[SimNPC] ", npc_name, " died from starvation.")
|
||||
|
||||
func should_eat_immediately_after_task() -> bool:
|
||||
return (
|
||||
current_task == SimulationIds.ACTION_GATHER_FOOD
|
||||
and is_starving
|
||||
and not is_dead
|
||||
func get_inventory_amount(item_id: StringName) -> float:
|
||||
return float(inventory.get(String(item_id), 0.0))
|
||||
|
||||
func add_inventory(item_id: StringName, amount: float) -> void:
|
||||
inventory[String(item_id)] = get_inventory_amount(item_id) + maxf(amount, 0.0)
|
||||
|
||||
func remove_inventory(item_id: StringName, requested_amount: float) -> float:
|
||||
var removed := minf(
|
||||
maxf(requested_amount, 0.0),
|
||||
get_inventory_amount(item_id)
|
||||
)
|
||||
inventory[String(item_id)] = get_inventory_amount(item_id) - removed
|
||||
return removed
|
||||
|
||||
func set_task(action_id: StringName, duration: float = -1.0) -> void:
|
||||
var definition := SimulationDefinitions.get_action(action_id)
|
||||
|
||||
Reference in New Issue
Block a user