// Add to a GameObject, then use the component's "Print campfire plan" context menu. // This prints a symbolic plan; it does not perform gameplay actions. using UnityEngine; namespace Wayrex.Notes.Goap { public sealed class CampfireExample : MonoBehaviour { [SerializeField] private bool fallenWoodAvailable = true; [SerializeField] private bool axeAtCamp = true; [SerializeField] private bool carryingWood; [SerializeField] private bool carryingAxe; [SerializeField] private bool campfireLit; [SerializeField, Range(1, 8)] private int gatheringCost = 4; [ContextMenu("Print campfire plan")] public void PrintPlan() { World world = World.None; if (fallenWoodAvailable) world |= World.LooseWood; if (axeAtCamp) world |= World.AxeAtCamp; if (carryingWood) world |= World.Wood; if (carryingAxe) world |= World.Axe; if (campfireLit) world |= World.Fire; var result = GoapPlanner.Plan(world, gatheringCost); if (result.Status != PlanStatus.Found) { Debug.Log($"{result.Status}. Expanded {result.Expanded} states.", this); return; } Debug.Log($"Plan: {result.Steps.Count} actions, total cost {result.Cost}.", this); foreach (var action in result.Steps) Debug.Log($"{action.Name}: cost {action.Cost}", this); } } }