### Implement Agent Script for AkiGOAP Source: https://github.com/akikurisu/akigoap/blob/main/README.md Example of an agent script that injects dependencies into goals and actions before initializing the planner. ```csharp using UnityEngine; using UnityEngine.AI; using System.Linq; namespace Kurisu.GOAP.Example { public class ExampleAgent : MonoBehaviour { private IPlanner planner; private NavMeshAgent navMeshAgent; public NavMeshAgent NavMeshAgent=>navMeshAgent; [SerializeField] private GOAPSet dataSet; [SerializeField] internal Transform player; public Transform Player=>player; private void Start() { navMeshAgent=GetComponent(); planner=GetComponent(); //You can pass inheritance and use Linq's Cast or OfType to get custom subclasses and perform dependency injection var goals=dataSet.GetGoals(); foreach(var goal in goals.OfType()) { goal.Inject(this); } var actions=dataSet.GetActions(); foreach(var action in actions.OfType()) { action.Inject(this); } //Finally you need to inject Goal and Action into Planner planner.InjectGoals(goals); planner.InjectActions(actions); } } } ``` -------------------------------- ### Registering a Transform Target in an Action Source: https://github.com/akikurisu/akigoap/blob/main/README.md Example of registering a transform bound to a node within a custom GOAP action. ```C# using UnityEngine; namespace Kurisu.GOAP.Example { public class GoToHome : ExampleAction { protected override void SetupDerived() { //Register Transform bound to this node worldState.RegisterNodeTarget(this,agent.Home); } } } ``` -------------------------------- ### Goal 2 Restore Energy Configuration Source: https://github.com/akikurisu/akigoap/blob/main/Samples~/Example/Example.md Defines the goal triggered when the agent has no energy. ```text Goal 2 Restore Energy: This goal requires the Agent to have no energy ``` -------------------------------- ### Goal 1 Follow Player Configuration Source: https://github.com/akikurisu/akigoap/blob/main/Samples~/Example/Example.md Defines the high-priority goal requiring energy, completed when the agent is within a specified range of the player. ```text Goal 1 Follow Player: This goal requires the Agent to have energy. When the distance is less than the specified range, the goal is considered to be completed This target has the highest priority ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.