From 0f2b6929b73cd9715528cbb7e184e9969c9a2e3d Mon Sep 17 00:00:00 2001 From: Peter Klooster Date: Wed, 13 Nov 2024 12:24:08 +0100 Subject: [PATCH] Added turn based example --- .../CrashKonijn/GOAP/Demos/TurnBased.meta | 8 + .../GOAP/Demos/TurnBased/Actions.meta | 3 + .../TurnBased/Actions/TurnWanderAction.cs | 26 + .../Actions/TurnWanderAction.cs.meta | 3 + .../Demos/TurnBased/Actions/WanderAction.cs | 68 +++ .../TurnBased/Actions/WanderAction.cs.meta | 11 + .../GOAP/Demos/TurnBased/Behaviours.meta | 3 + .../TurnBased/Behaviours/GameBehaviour.cs | 53 ++ .../Behaviours/GameBehaviour.cs.meta | 3 + .../TurnBased/Behaviours/GridBehaviour.cs | 72 +++ .../Behaviours/GridBehaviour.cs.meta | 11 + .../TurnBased/Behaviours/GridMoveBehaviour.cs | 133 +++++ .../Behaviours/GridMoveBehaviour.cs.meta | 3 + .../TurnBased/Behaviours/InjectBehaviour.cs | 34 ++ .../Behaviours/InjectBehaviour.cs.meta | 3 + .../Behaviours/PathfindingBehaviour.cs | 175 +++++++ .../Behaviours/PathfindingBehaviour.cs.meta | 3 + .../TurnBased/Behaviours/TestBehaviour.cs | 44 ++ .../Behaviours/TestBehaviour.cs.meta | 3 + .../TurnBased/Behaviours/TileBehaviour.cs | 51 ++ .../Behaviours/TileBehaviour.cs.meta | 3 + .../Behaviours/TurnAnimationBehaviour.cs | 66 +++ .../Behaviours/TurnAnimationBehaviour.cs.meta | 3 + .../TurnBased/Behaviours/TurnBehaviour.cs | 87 ++++ .../Behaviours/TurnBehaviour.cs.meta | 3 + .../Behaviours/TurnGoapConfigInitializer.cs | 13 + .../TurnGoapConfigInitializer.cs.meta | 3 + .../GOAP/Demos/TurnBased/Extensions.cs | 26 + .../GOAP/Demos/TurnBased/Extensions.cs.meta | 3 + .../GOAP/Demos/TurnBased/Factories.meta | 3 + .../TurnBased/Factories/TurnGoapSetFactory.cs | 34 ++ .../Factories/TurnGoapSetFactory.cs.meta | 3 + .../GOAP/Demos/TurnBased/GOAP.asset | 15 + .../GOAP/Demos/TurnBased/GOAP.asset.meta | 3 + .../GOAP/Demos/TurnBased/Goals.meta | 8 + .../GOAP/Demos/TurnBased/Goals/WanderGoal.cs | 9 + .../Demos/TurnBased/Goals/WanderGoal.cs.meta | 11 + .../GOAP/Demos/TurnBased/Interfaces.meta | 3 + .../GOAP/Demos/TurnBased/Interfaces/IGrid.cs | 13 + .../Demos/TurnBased/Interfaces/IGrid.cs.meta | 3 + .../Demos/TurnBased/Interfaces/IInjectable.cs | 9 + .../TurnBased/Interfaces/IInjectable.cs.meta | 3 + .../TurnBased/Interfaces/IPathfinding.cs | 9 + .../TurnBased/Interfaces/IPathfinding.cs.meta | 3 + .../GOAP/Demos/TurnBased/Interfaces/ITile.cs | 16 + .../Demos/TurnBased/Interfaces/ITile.cs.meta | 3 + .../GOAP/Demos/TurnBased/Prefabs.meta | 8 + .../GOAP/Demos/TurnBased/Prefabs/Tile.prefab | 100 ++++ .../Demos/TurnBased/Prefabs/Tile.prefab.meta | 7 + .../Demos/TurnBased/Prefabs/TurnAgent.prefab | 455 ++++++++++++++++ .../TurnBased/Prefabs/TurnAgent.prefab.meta | 7 + .../GOAP/Demos/TurnBased/Sensors.meta | 3 + .../GOAP/Demos/TurnBased/Sensors/Target.meta | 3 + .../Sensors/Target/TurnWanderTargetSensor.cs | 30 ++ .../Target/TurnWanderTargetSensor.cs.meta | 3 + .../GOAP/Demos/TurnBased/TargetKeys.meta | 8 + .../TurnBased/TargetKeys/WanderTarget.cs | 7 + .../TurnBased/TargetKeys/WanderTarget.cs.meta | 11 + .../GOAP/Demos/TurnBased/TileTarget.cs | 26 + .../GOAP/Demos/TurnBased/TileTarget.cs.meta | 3 + .../GOAP/Demos/TurnBased/TurnAgentBrain.cs | 21 + .../Demos/TurnBased/TurnAgentBrain.cs.meta | 3 + .../GOAP/Demos/TurnBased/TurnBased.unity | 490 ++++++++++++++++++ .../GOAP/Demos/TurnBased/TurnBased.unity.meta | 7 + .../GOAP/Demos/TurnBased/WorldKeys.meta | 8 + .../Demos/TurnBased/WorldKeys/IsWandering.cs | 7 + .../TurnBased/WorldKeys/IsWandering.cs.meta | 11 + ...m.crashkonijn.goap.demos.turn-based.asmdef | 20 + ...shkonijn.goap.demos.turn-based.asmdef.meta | 3 + ...n.goap.demos.turn-based.csproj.DotSettings | 5 + 70 files changed, 2311 insertions(+) create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/TurnWanderAction.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/TurnWanderAction.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/WanderAction.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/WanderAction.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GameBehaviour.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GameBehaviour.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridBehaviour.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridBehaviour.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridMoveBehaviour.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridMoveBehaviour.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/InjectBehaviour.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/InjectBehaviour.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/PathfindingBehaviour.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/PathfindingBehaviour.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TestBehaviour.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TestBehaviour.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TileBehaviour.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TileBehaviour.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnAnimationBehaviour.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnAnimationBehaviour.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnBehaviour.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnBehaviour.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnGoapConfigInitializer.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnGoapConfigInitializer.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Extensions.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Extensions.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Factories.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Factories/TurnGoapSetFactory.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Factories/TurnGoapSetFactory.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/GOAP.asset create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/GOAP.asset.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Goals.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Goals/WanderGoal.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Goals/WanderGoal.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IGrid.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IGrid.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IInjectable.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IInjectable.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IPathfinding.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IPathfinding.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/ITile.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/ITile.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/Tile.prefab create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/Tile.prefab.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/TurnAgent.prefab create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/TurnAgent.prefab.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors/Target.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors/Target/TurnWanderTargetSensor.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors/Target/TurnWanderTargetSensor.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TargetKeys.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TargetKeys/WanderTarget.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TargetKeys/WanderTarget.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TileTarget.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TileTarget.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnAgentBrain.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnAgentBrain.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnBased.unity create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnBased.unity.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/WorldKeys.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/WorldKeys/IsWandering.cs create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/WorldKeys/IsWandering.cs.meta create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/com.crashkonijn.goap.demos.turn-based.asmdef create mode 100644 Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/com.crashkonijn.goap.demos.turn-based.asmdef.meta create mode 100644 Demo/com.crashkonijn.goap.demos.turn-based.csproj.DotSettings diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased.meta new file mode 100644 index 00000000..a45926b4 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 62dbf37fa1842fc48bd41d88ba942be2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions.meta new file mode 100644 index 00000000..56717925 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 550f9154d25f482fa9934dd1710013cf +timeCreated: 1688378634 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/TurnWanderAction.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/TurnWanderAction.cs new file mode 100644 index 00000000..aed744f3 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/TurnWanderAction.cs @@ -0,0 +1,26 @@ +using CrashKonijn.Agent.Core; +using CrashKonijn.Goap.Runtime; +using UnityEngine; + +namespace TurnBased.Actions +{ + public class TurnWanderAction : GoapActionBase + { + public class Data : IActionData + { + public ITarget Target { get; set; } + } + + public override void Created() { } + + public override void Start(IMonoAgent agent, Data data) { } + + public override IActionRunState Perform(IMonoAgent agent, Data data, IActionContext context) + { + Debug.Log($"Performing wander action for {agent}"); + return ActionRunState.Stop; + } + + public override void End(IMonoAgent agent, Data data) { } + } +} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/TurnWanderAction.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/TurnWanderAction.cs.meta new file mode 100644 index 00000000..28c790df --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/TurnWanderAction.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5beb29ff982547d9ac5932e346f644fb +timeCreated: 1688378634 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/WanderAction.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/WanderAction.cs new file mode 100644 index 00000000..20f64816 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/WanderAction.cs @@ -0,0 +1,68 @@ +using CrashKonijn.Agent.Core; +using CrashKonijn.Goap.Runtime; +using UnityEngine; + +namespace CrashKonijn.Goap.Demos.TurnBased +{ + [GoapId("Wander-9cf982ae-4314-4d83-96c8-e7ff0616a798")] + public class WanderAction : GoapActionBase + { + // This method is called when the action is created + // This method is optional and can be removed + public override void Created() + { + } + + // This method is called every frame before the action is performed + // If this method returns false, the action will be stopped + // This method is optional and can be removed + public override bool IsValid(IActionReceiver agent, Data data) + { + return true; + } + + // This method is called when the action is started + // This method is optional and can be removed + public override void Start(IMonoAgent agent, Data data) + { + } + + // This method is called once before the action is performed + // This method is optional and can be removed + public override void BeforePerform(IMonoAgent agent, Data data) + { + } + + // This method is called every frame while the action is running + // This method is required + public override IActionRunState Perform(IMonoAgent agent, Data data, IActionContext context) + { + return ActionRunState.Completed; + } + + // This method is called when the action is completed + // This method is optional and can be removed + public override void Complete(IMonoAgent agent, Data data) + { + } + + // This method is called when the action is stopped + // This method is optional and can be removed + public override void Stop(IMonoAgent agent, Data data) + { + } + + // This method is called when the action is completed or stopped + // This method is optional and can be removed + public override void End(IMonoAgent agent, Data data) + { + } + + // The action class itself must be stateless! + // All data should be stored in the data class + public class Data : IActionData + { + public ITarget Target { get; set; } + } + } +} \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/WanderAction.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/WanderAction.cs.meta new file mode 100644 index 00000000..f54b5617 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Actions/WanderAction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 68b49d25bbe7c984ba04550cbb8572d3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours.meta new file mode 100644 index 00000000..b1ed163f --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f0a062b40f584e45862b955359446f82 +timeCreated: 1688375803 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GameBehaviour.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GameBehaviour.cs new file mode 100644 index 00000000..5288e785 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GameBehaviour.cs @@ -0,0 +1,53 @@ +using CrashKonijn.Goap.Core; +using CrashKonijn.GOAP.Demos.TurnBased.Interfaces; +using CrashKonijn.Goap.Runtime; +using UnityEngine; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Behaviours +{ + public class GameBehaviour : MonoBehaviour + { + private IGrid grid; + private TurnBehaviour turns; + private IGoap goapRunner; + + [SerializeField] + private GameObject agentPrefab; + + + private void Awake() + { + this.grid = FindObjectOfType(); + this.goapRunner = FindObjectOfType(); + this.turns = this.GetComponent(); + } + + private void Start() + { + this.SpawnAgent("TurnBased", Color.red); + this.SpawnAgent("TurnBased", Color.blue); + } + + private void SpawnAgent(string setId, Color color) + { + var actionProvider = Instantiate(this.agentPrefab, this.GetRandomPosition(), Quaternion.identity).GetComponent(); + + actionProvider.AgentType = this.goapRunner.GetAgentType(setId); + actionProvider.gameObject.SetActive(true); + + actionProvider.gameObject.transform.name = $"agent {actionProvider.GetInstanceID()}"; + + var spriteRenderer = actionProvider.GetComponentInChildren(); + spriteRenderer.color = color; + + this.turns.Register(actionProvider); + } + + private Vector3 GetRandomPosition() + { + var tile = this.grid.GetWalkableTiles().Random(); + + return new Vector3(tile.X, 0.5f, tile.Y); + } + } +} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GameBehaviour.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GameBehaviour.cs.meta new file mode 100644 index 00000000..9fd95338 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GameBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 18cb43c7b9834befa876e5ca760b974f +timeCreated: 1688387070 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridBehaviour.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridBehaviour.cs new file mode 100644 index 00000000..9e1dc2be --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridBehaviour.cs @@ -0,0 +1,72 @@ +using System.Linq; +using CrashKonijn.GOAP.Demos.TurnBased.Interfaces; +using UnityEngine; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Behaviours +{ + public class GridBehaviour : MonoBehaviour, IGrid + { + public Transform tilePrefab; + public int width = 10; + public int height = 10; + private ITile[,] grid; + private ITile[] tiles; + private IPathfinding pathfinding; + + private void Awake() + { + this.grid = new ITile[this.width, this.height]; + this.tiles = new ITile[this.width * this.height]; + this.pathfinding = this.GetComponent(); + + for (var x = 0; x < this.width; x++) + { + for (var y = 0; y < this.height; y++) + { + var tile = this.CreateTile(x, y); + this.grid[x, y] = tile; + this.tiles[x + y * this.width] = tile; + } + } + } + + private ITile CreateTile(int x, int y) + { + var instance = Instantiate(this.tilePrefab, this.transform, true); + instance.name = $"Tile {x} {y}"; + instance.position = new Vector3(x, 0, y); + + var tile = instance.GetComponent(); + + tile.Initialize(x, y, this); + tile.SetWalkable(Random.Range(0, 100) >= 10); + + return tile; + } + + public ITile[,] GetGrid() + { + return this.grid; + } + + public ITile[] GetWalkableTiles() + { + return this.tiles.Where(x => x.IsWalkable).ToArray(); + } + + public ITile GetTile(Vector3 position) + { + return this.grid[Mathf.RoundToInt(position.x), Mathf.RoundToInt(position.z)]; + } + + public ITile[] GetPath(ITile from, ITile to) + { + return this.pathfinding.FindPath(this.grid, from, to); + } + + public ITile[] GetPath(Vector3 from, Vector3 to) + { + return this.pathfinding.FindPath(this.grid, this.GetTile(from), this.GetTile(to)); + } + } +} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridBehaviour.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridBehaviour.cs.meta new file mode 100644 index 00000000..e592fdeb --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d1f070f9bdcb89443800402c17da93c6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridMoveBehaviour.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridMoveBehaviour.cs new file mode 100644 index 00000000..64557f23 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridMoveBehaviour.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using CrashKonijn.Agent.Core; +using CrashKonijn.Agent.Runtime; +using CrashKonijn.GOAP.Demos.TurnBased.Interfaces; +using UnityEngine; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Behaviours +{ + public class GridMoveBehaviour : MonoBehaviour + { + [field: SerializeField] + public bool IsMoving { get; private set; } + + [field: SerializeField] + public Vector3 MovePosition { get; private set; } + + private IMonoAgent agent; + private ITarget target; + + [SerializeField] + private int moveCount; + + [SerializeField] + private int maxMoveCount = 3; + + private Action onComplete; + private IGrid grid; + private Queue path = new(); + + private void Awake() + { + this.agent = this.GetComponent(); + this.grid = FindObjectOfType(); + } + + private void Update() + { + if (!this.IsMoving) + return; + + var targetPos = this.MovePosition + new Vector3(0f, this.transform.position.y, 0f); + + this.transform.position = Vector3.MoveTowards(this.transform.position, targetPos, Time.deltaTime); + + if (Vector3.Distance(this.transform.position, targetPos) >= 0.05f) + return; + + this.transform.position = targetPos; + + this.moveCount++; + + if (this.moveCount >= this.maxMoveCount) + { + this.IsMoving = false; + this.onComplete(false); + return; + } + + this.MovePosition = this.GetMovePosition(); + + targetPos = this.MovePosition + new Vector3(0f, this.transform.position.y, 0f); + + if (this.transform.position == targetPos) + { + this.IsMoving = false; + this.onComplete(true); + } + } + + private void OnEnable() + { + this.agent.Events.OnTargetChanged += this.OnTargetChanged; + } + + private void OnDisable() + { + this.agent.Events.OnTargetChanged -= this.OnTargetChanged; + } + + private void OnTargetChanged(ITarget target, bool inrange) + { + this.target = target; + } + + public void Move(Action onComplete) + { + if (this.target == null) + { + onComplete(false); + return; + } + + this.IsMoving = true; + this.onComplete = onComplete; + this.moveCount = 0; + this.path = new Queue(this.grid.GetPath(this.transform.position, this.target.Position)); + this.MovePosition = this.GetMovePosition(); + } + + private Vector3 GetMovePosition() + { + var currentTile = this.grid.GetTile(this.transform.position); + + if (this.path.Count == 0) + return this.target.Position; + + var nextTile = this.path.Dequeue(); + + if (nextTile == null) + { + return this.transform.position; + } + + if (currentTile == nextTile) + return this.GetMovePosition(); + + return nextTile.Position; + } + + private void OnDrawGizmos() + { + // if (this.path == null) + // return; + // + // foreach (var tile in this.path) + // { + // Gizmos.color = Color.red; + // Gizmos.DrawCube(tile.Position, Vector3.one * 0.5f); + // } + } + } +} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridMoveBehaviour.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridMoveBehaviour.cs.meta new file mode 100644 index 00000000..72bad051 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/GridMoveBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a036d4c62979460ebe1d652029117fbd +timeCreated: 1688547827 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/InjectBehaviour.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/InjectBehaviour.cs new file mode 100644 index 00000000..1cad7408 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/InjectBehaviour.cs @@ -0,0 +1,34 @@ +using CrashKonijn.Agent.Core; +using CrashKonijn.Goap.Core; +using CrashKonijn.GOAP.Demos.TurnBased.Interfaces; +using UnityEngine; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Behaviours +{ + public class InjectBehaviour : MonoBehaviour, IGoapInjector + { + [field: SerializeField] + public GridBehaviour Grid { get; private set; } + + [field: SerializeField] + public PathfindingBehaviour Pathfinding { get; private set; } + + public void Inject(IAction action) + { + if (action is IInjectable injectable) + injectable.Inject(this); + } + + public void Inject(IGoal goal) + { + if (goal is IInjectable injectable) + injectable.Inject(this); + } + + public void Inject(ISensor sensor) + { + if (sensor is IInjectable injectable) + injectable.Inject(this); + } + } +} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/InjectBehaviour.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/InjectBehaviour.cs.meta new file mode 100644 index 00000000..8de0bdb4 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/InjectBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2a227a37d8b74a159de07af6adcf4cf3 +timeCreated: 1688387443 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/PathfindingBehaviour.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/PathfindingBehaviour.cs new file mode 100644 index 00000000..18d36007 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/PathfindingBehaviour.cs @@ -0,0 +1,175 @@ +using System; +using System.Collections.Generic; +using CrashKonijn.GOAP.Demos.TurnBased.Interfaces; +using UnityEngine; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Behaviours +{ + // Note: This is very inefficient. Please use a better pathfinding algorithm in your own projects. + public class PathfindingBehaviour : MonoBehaviour, IPathfinding + { + public ITile[] FindPath(ITile[,] grid, ITile startTile, ITile targetTile) + { + var width = grid.GetLength(0); + var height = grid.GetLength(1); + + // Create a priority queue for open nodes + var openNodes = new PriorityQueue(); + openNodes.Enqueue(startTile, 0); + + // Store the cost to reach each tile from the start tile + var gScore = new Dictionary(); + gScore[startTile] = 0; + + // Store the previous tile in the best-known path + var cameFrom = new Dictionary(); + + // Calculate the heuristic distance between two tiles (Manhattan distance) + float HeuristicDistance(ITile a, ITile b) + { + return Math.Abs(a.X - b.X) + Math.Abs(a.Y - b.Y); + } + + while (openNodes.Count > 0) + { + var currentTile = openNodes.Dequeue(); + + if (currentTile == targetTile) + { + // Found the target tile, reconstruct the path and return it + return ReconstructPath(cameFrom, currentTile); + } + + foreach (var neighbor in GetNeighbors(grid, currentTile, width, height)) + { + // Calculate the tentative gScore from start to the neighbor + var tentativeGScore = gScore[currentTile] + 1; // Assuming tiles have a cost of 1 + + if (!gScore.ContainsKey(neighbor) || tentativeGScore < gScore[neighbor]) + { + // This path to the neighbor is better than any previous one, so record it + cameFrom[neighbor] = currentTile; + gScore[neighbor] = tentativeGScore; + + // Calculate the fScore for the neighbor (fScore = gScore + heuristic) + var fScore = tentativeGScore + HeuristicDistance(neighbor, targetTile); + + if (!openNodes.Contains(neighbor)) + { + // Add the neighbor to the open nodes + openNodes.Enqueue(neighbor, fScore); + } + } + } + } + + // No path found + return null; + } + + private static ITile[] ReconstructPath(Dictionary cameFrom, ITile currentTile) + { + var path = new List() { currentTile }; + + while (cameFrom.ContainsKey(currentTile)) + { + currentTile = cameFrom[currentTile]; + path.Add(currentTile); + } + + path.Reverse(); + return path.ToArray(); + } + + private static IEnumerable GetNeighbors(ITile[,] grid, ITile tile, int width, int height) + { + var neighbors = new List(); + + // Get the adjacent tiles (up, down, left, right) + int[] dx = { 0, 0, -1, 1 }; + int[] dy = { -1, 1, 0, 0 }; + + for (var i = 0; i < dx.Length; i++) + { + var nx = tile.X + dx[i]; + var ny = tile.Y + dy[i]; + + if (nx >= 0 && nx < width && ny >= 0 && ny < height && grid[nx, ny].IsWalkable) + { + neighbors.Add(grid[nx, ny]); + } + } + + return neighbors; + } + } + +// A simple priority queue implementation using a min heap + public class PriorityQueue + { + private List<(T item, float priority)> elements = new List<(T, float)>(); + + public int Count => this.elements.Count; + + public void Enqueue(T item, float priority) + { + this.elements.Add((item, priority)); + var index = this.elements.Count - 1; + + while (index > 0) + { + var parentIndex = (index - 1) / 2; + if (this.elements[parentIndex].priority <= priority) + break; + + (var tempItem, var tempPriority) = this.elements[parentIndex]; + this.elements[parentIndex] = this.elements[index]; + this.elements[index] = (tempItem, tempPriority); + + index = parentIndex; + } + } + + public T Dequeue() + { + var item = this.elements[0].item; + this.elements[0] = this.elements[this.elements.Count - 1]; + this.elements.RemoveAt(this.elements.Count - 1); + + var index = 0; + while (true) + { + var leftChildIndex = 2 * index + 1; + var rightChildIndex = 2 * index + 2; + var smallestChildIndex = index; + + if (leftChildIndex < this.elements.Count && this.elements[leftChildIndex].priority < this.elements[smallestChildIndex].priority) + smallestChildIndex = leftChildIndex; + + if (rightChildIndex < this.elements.Count && this.elements[rightChildIndex].priority < this.elements[smallestChildIndex].priority) + smallestChildIndex = rightChildIndex; + + if (smallestChildIndex == index) + break; + + (var tempItem, var tempPriority) = this.elements[index]; + this.elements[index] = this.elements[smallestChildIndex]; + this.elements[smallestChildIndex] = (tempItem, tempPriority); + + index = smallestChildIndex; + } + + return item; + } + + public bool Contains(T item) + { + foreach ((var currentItem, _) in this.elements) + { + if (currentItem.Equals(item)) + return true; + } + return false; + } + } +} \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/PathfindingBehaviour.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/PathfindingBehaviour.cs.meta new file mode 100644 index 00000000..cc84c1ee --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/PathfindingBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f43307bc896947cd96d4ca85fc2461a2 +timeCreated: 1688376447 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TestBehaviour.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TestBehaviour.cs new file mode 100644 index 00000000..55060abc --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TestBehaviour.cs @@ -0,0 +1,44 @@ +using CrashKonijn.GOAP.Demos.TurnBased.Interfaces; +using UnityEngine; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Behaviours +{ + public class TestBehaviour : MonoBehaviour + { + private IGrid grid; + private IPathfinding pathfinding; + private ITile[] path; + + private void Awake() + { + this.grid = FindObjectOfType(); + this.pathfinding = FindObjectOfType(); + } + + private void Start() + { + this.path = this.GetPath(); + } + + private ITile[] GetPath() + { + var tiles = this.grid.GetWalkableTiles(); + var from = tiles.Random(); + var to = tiles.Random(); + + return this.pathfinding.FindPath(this.grid.GetGrid(), from, to); + } + + private void OnDrawGizmos() + { + if (this.path == null) + return; + + Gizmos.color = Color.blue; + foreach (var tile in this.path) + { + Gizmos.DrawSphere(new Vector3(tile.X, 0, tile.Y), 0.5f); + } + } + } +} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TestBehaviour.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TestBehaviour.cs.meta new file mode 100644 index 00000000..284bd7e1 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TestBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0c16674a94ab4e208c0e50e9eaf9945e +timeCreated: 1688376636 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TileBehaviour.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TileBehaviour.cs new file mode 100644 index 00000000..ec1d6ff2 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TileBehaviour.cs @@ -0,0 +1,51 @@ +using System; +using CrashKonijn.GOAP.Demos.TurnBased.Interfaces; +using UnityEngine; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Behaviours +{ + public class TileBehaviour : MonoBehaviour, ITile + { + public int X { get; private set; } + public int Y { get; private set; } + public bool IsWalkable { get; private set; } + public Vector3 Position { get; private set; } + + private IGrid grid; + private SpriteRenderer spriteRenderer; + + private void Awake() + { + this.spriteRenderer = this.GetComponent(); + } + + public void Initialize(int x, int y, IGrid grid) + { + this.X = x; + this.Y = y; + this.grid = grid; + this.IsWalkable = true; + this.Position = new Vector3(x, 0f, y); + this.UpdateColor(); + } + + public void SetWalkable(bool isWalkable) + { + this.IsWalkable = isWalkable; + this.UpdateColor(); + } + + private void UpdateColor() + { + this.spriteRenderer.color = this.GetColor(); + } + + private Color GetColor() + { + if (!this.IsWalkable) + return Color.red; + + return Color.green; + } + } +} \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TileBehaviour.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TileBehaviour.cs.meta new file mode 100644 index 00000000..bb3701ea --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TileBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 928f275f0c7d487abdd1a375d55c4b00 +timeCreated: 1688375519 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnAnimationBehaviour.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnAnimationBehaviour.cs new file mode 100644 index 00000000..8b350dd3 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnAnimationBehaviour.cs @@ -0,0 +1,66 @@ +using CrashKonijn.Agent.Runtime; +using UnityEngine; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Behaviours +{ + public class TurnAnimationBehaviour : MonoBehaviour + { + private Animator animator; + private AgentBehaviour agent; + private GridMoveBehaviour move; + private static readonly int Walking = Animator.StringToHash("Walking"); + + private bool isWalking; + private bool isMovingLeft; + + private void Awake() + { + this.animator = this.GetComponentInChildren(); + this.agent = this.GetComponent(); + this.move = this.GetComponent(); + + // Random y offset to prevent clipping + this.animator.transform.localPosition = new Vector3(0, Random.Range(-0.1f, 0.1f), 0); + } + + private void Update() + { + this.UpdateAnimation(); + this.UpdateScale(); + } + + private void UpdateAnimation() + { + var isWalking = this.move.IsMoving; + + if (this.isWalking == isWalking) + return; + + this.isWalking = isWalking; + + this.animator.SetBool(Walking, isWalking); + } + + private void UpdateScale() + { + if (!this.isWalking) + return; + + var isMovingLeft = this.IsMovingLeft(); + + if (this.isMovingLeft == isMovingLeft) + return; + + this.isMovingLeft = isMovingLeft; + + this.animator.transform.localScale = new Vector3(isMovingLeft ? -1 : 1, 1, 1); + } + + private bool IsMovingLeft() + { + var target = this.move.MovePosition; + + return this.transform.position.x > target.x; + } + } +} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnAnimationBehaviour.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnAnimationBehaviour.cs.meta new file mode 100644 index 00000000..7abcb0fa --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnAnimationBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: fb101b5c4c8944608e65a8756a119966 +timeCreated: 1688561108 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnBehaviour.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnBehaviour.cs new file mode 100644 index 00000000..c72ec8c4 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnBehaviour.cs @@ -0,0 +1,87 @@ +using System.Collections; +using System.Collections.Generic; +using CrashKonijn.Goap.Runtime; +using UnityEngine; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Behaviours +{ + public class TurnBehaviour : MonoBehaviour + { + private List agents = new(); + private Queue queue = new(); + private GoapActionProvider activeAgent; + + [SerializeField] + private TurnState state = TurnState.Idle; + + public void Register(GoapActionProvider agent) + { + this.agents.Add(agent); + } + + private void Update() + { + if (this.state != TurnState.Idle) + return; + + if (this.activeAgent != null) + return; + + if (this.queue.Count == 0) + this.queue = new Queue(this.agents); + + this.activeAgent = this.queue.Dequeue(); + this.StartTurn(this.activeAgent); + } + + private void StartTurn(GoapActionProvider agent) + { + this.StartMoving(agent); + } + + private void StartMoving(GoapActionProvider agent) + { + this.state = TurnState.Moving; + + var move = agent.GetComponent(); + move.Move((complete) => + { + if (complete) + { + this.StartActing(agent); + return; + } + + this.StopTurn(agent); + }); + } + + private void StartActing(GoapActionProvider agent) + { + this.state = TurnState.Acting; + this.StopTurn(agent); + } + + private void StopTurn(GoapActionProvider agent) + { + this.activeAgent = null; + + this.StartCoroutine(this.Wait()); + } + + private IEnumerator Wait() + { + this.state = TurnState.Waiting; + yield return new WaitForSeconds(1f); + this.state = TurnState.Idle; + } + } + + public enum TurnState + { + Idle, + Moving, + Acting, + Waiting, + } +} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnBehaviour.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnBehaviour.cs.meta new file mode 100644 index 00000000..67ed4df4 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnBehaviour.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b49297aa82e4409894be5d6e1c1237f4 +timeCreated: 1688387001 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnGoapConfigInitializer.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnGoapConfigInitializer.cs new file mode 100644 index 00000000..ae6ce696 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnGoapConfigInitializer.cs @@ -0,0 +1,13 @@ +using CrashKonijn.Goap.Core; +using CrashKonijn.Goap.Runtime; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Behaviours +{ + public class TurnGoapConfigInitializer : GoapConfigInitializerBase + { + public override void InitConfig(IGoapConfig config) + { + config.GoapInjector = this.GetComponent(); + } + } +} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnGoapConfigInitializer.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnGoapConfigInitializer.cs.meta new file mode 100644 index 00000000..8e3c1882 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Behaviours/TurnGoapConfigInitializer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 463d8dde50524e5cb21ce76d94a12a01 +timeCreated: 1688387734 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Extensions.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Extensions.cs new file mode 100644 index 00000000..e68fcc46 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Extensions.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; + +namespace CrashKonijn.GOAP.Demos.TurnBased +{ + public static class Extensions + { + public static T Random(this IEnumerable enumerable) + { + if (enumerable == null) + { + throw new ArgumentNullException(nameof(enumerable)); + } + + var list = new List(enumerable); + + if (list.Count == 0) + { + throw new InvalidOperationException("The collection is empty."); + } + + var randomIndex = UnityEngine.Random.Range(0, list.Count); + return list[randomIndex]; + } + } +} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Extensions.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Extensions.cs.meta new file mode 100644 index 00000000..598abd0d --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ccf3628338a240d6b88ba7b012b10f29 +timeCreated: 1731496319 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Factories.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Factories.meta new file mode 100644 index 00000000..4a59ad11 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Factories.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4c06b9b0cf864667bc828796ee806f2b +timeCreated: 1688378563 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Factories/TurnGoapSetFactory.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Factories/TurnGoapSetFactory.cs new file mode 100644 index 00000000..6f8da559 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Factories/TurnGoapSetFactory.cs @@ -0,0 +1,34 @@ +using CrashKonijn.Goap.Core; +using CrashKonijn.Goap.Demos.TurnBased; +using CrashKonijn.GOAP.Demos.TurnBased.Sensors.Target; +using CrashKonijn.Goap.Runtime; +using TurnBased.Actions; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Factories +{ + public class TurnGoapSetFactory : AgentTypeFactoryBase + { + public override IAgentTypeConfig Create() + { + var builder = new AgentTypeBuilder("TurnBased"); + + builder.CreateCapability("turn-based-capability", (capability) => + { + capability + .AddGoal() + .AddCondition(Comparison.GreaterThanOrEqual, 1); + + capability + .AddAction() + .SetTarget() + .AddEffect(EffectType.Increase); + + capability + .AddTargetSensor() + .SetTarget(); + }); + + return builder.Build(); + } + } +} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Factories/TurnGoapSetFactory.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Factories/TurnGoapSetFactory.cs.meta new file mode 100644 index 00000000..d09764a3 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Factories/TurnGoapSetFactory.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5bade2b7fd12449da879f559366fa0f5 +timeCreated: 1688378563 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/GOAP.asset b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/GOAP.asset new file mode 100644 index 00000000..6450b94c --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/GOAP.asset @@ -0,0 +1,15 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0857b2a53377458ebec6c4b1179e3c5a, type: 3} + m_Name: GOAP + m_EditorClassIdentifier: + nameSpace: CrashKonijn.Goap.Demos.Complex diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/GOAP.asset.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/GOAP.asset.meta new file mode 100644 index 00000000..c5fe817a --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/GOAP.asset.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5524c6583baf45b080ea1304fabb03a9 +timeCreated: 1731496347 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Goals.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Goals.meta new file mode 100644 index 00000000..02174c8e --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Goals.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d1f73b19c0db13848bc9ea4cc138a818 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Goals/WanderGoal.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Goals/WanderGoal.cs new file mode 100644 index 00000000..301792f6 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Goals/WanderGoal.cs @@ -0,0 +1,9 @@ +using CrashKonijn.Goap.Runtime; + +namespace CrashKonijn.Goap.Demos.TurnBased +{ + [GoapId("Wander-19096b96-8c3d-41ba-a1e5-dc56be8ce92e")] + public class WanderGoal : GoalBase + { + } +} \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Goals/WanderGoal.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Goals/WanderGoal.cs.meta new file mode 100644 index 00000000..46897a50 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Goals/WanderGoal.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bfe5238f23b271a418dccffe009a49e5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces.meta new file mode 100644 index 00000000..5654aea4 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 69af651ec1c04705becfe9fa84e4c1c8 +timeCreated: 1688375807 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IGrid.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IGrid.cs new file mode 100644 index 00000000..84ebfce1 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IGrid.cs @@ -0,0 +1,13 @@ +using UnityEngine; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Interfaces +{ + public interface IGrid + { + ITile[,] GetGrid(); + ITile[] GetWalkableTiles(); + ITile GetTile(Vector3 position); + ITile[] GetPath(ITile from, ITile to); + ITile[] GetPath(Vector3 from, Vector3 to); + } +} \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IGrid.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IGrid.cs.meta new file mode 100644 index 00000000..6043881e --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IGrid.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e268d7ccefb24bc1a83b9b6a7c19f2ae +timeCreated: 1688375837 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IInjectable.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IInjectable.cs new file mode 100644 index 00000000..a18fe9c8 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IInjectable.cs @@ -0,0 +1,9 @@ +using CrashKonijn.GOAP.Demos.TurnBased.Behaviours; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Interfaces +{ + public interface IInjectable + { + void Inject(InjectBehaviour data); + } +} \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IInjectable.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IInjectable.cs.meta new file mode 100644 index 00000000..81390cef --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IInjectable.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4244d969d033403d9dd1b46e3cc82722 +timeCreated: 1688387426 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IPathfinding.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IPathfinding.cs new file mode 100644 index 00000000..5f5e8e19 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IPathfinding.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Interfaces +{ + public interface IPathfinding + { + ITile[] FindPath(ITile[,] grid, ITile startTile, ITile targetTile); + } +} \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IPathfinding.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IPathfinding.cs.meta new file mode 100644 index 00000000..5407e5cb --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/IPathfinding.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: eb45c7cdaa4945fbb1c0f9072608fdfd +timeCreated: 1688376548 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/ITile.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/ITile.cs new file mode 100644 index 00000000..dfa3f0e6 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/ITile.cs @@ -0,0 +1,16 @@ +using CrashKonijn.GOAP.Demos.TurnBased.Behaviours; +using UnityEngine; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Interfaces +{ + public interface ITile + { + int X { get; } + int Y { get; } + bool IsWalkable { get; } + Vector3 Position { get; } + + void Initialize(int x, int y, IGrid grid); + void SetWalkable(bool isWalkable); + } +} \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/ITile.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/ITile.cs.meta new file mode 100644 index 00000000..08916a8c --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Interfaces/ITile.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 359c53cc5dd74ecd9a697c347f2234f9 +timeCreated: 1688375519 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs.meta new file mode 100644 index 00000000..ba18ad42 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b207630a78b22e947aa4f6a450fe403a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/Tile.prefab b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/Tile.prefab new file mode 100644 index 00000000..747ac4fc --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/Tile.prefab @@ -0,0 +1,100 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &371604003642856323 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7370730411235180477} + - component: {fileID: 3101166991280314395} + - component: {fileID: 3422763043251194417} + m_Layer: 0 + m_Name: Tile + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7370730411235180477 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 371604003642856323} + m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068} + m_LocalPosition: {x: 1.5397427, y: -0.5858315, z: -0.1487158} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0} +--- !u!212 &3101166991280314395 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 371604003642856323} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 7482667652216324306, guid: 311925a002f4447b3a28927169b83ea6, + type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!114 &3422763043251194417 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 371604003642856323} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 928f275f0c7d487abdd1a375d55c4b00, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/Tile.prefab.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/Tile.prefab.meta new file mode 100644 index 00000000..25a2aeff --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/Tile.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8a14f2a4edc752f48ae25533510f03ab +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/TurnAgent.prefab b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/TurnAgent.prefab new file mode 100644 index 00000000..3d48108d --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/TurnAgent.prefab @@ -0,0 +1,455 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &6602772906603950298 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4808053668070117556} + - component: {fileID: 7552875688808866782} + - component: {fileID: 4696697931437632644} + m_Layer: 5 + m_Name: Text (TMP) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &4808053668070117556 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6602772906603950298} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 4454143011079988569} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 1, y: 1} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7552875688808866782 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6602772906603950298} + m_CullTransparentMesh: 1 +--- !u!114 &4696697931437632644 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6602772906603950298} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: New Text + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 0.3 + m_fontSizeBase: 0.3 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 256 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 0 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: -1.0670482, y: 0, z: -1.0732708, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!1 &7042921910603271452 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 9090141417940585542} + - component: {fileID: -1195567701300851260} + - component: {fileID: 2015339067979990790} + - component: {fileID: 1634778938604141570} + - component: {fileID: 8649320982975687388} + - component: {fileID: -6150666128992256381} + m_Layer: 0 + m_Name: TurnAgent + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!4 &9090141417940585542 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7042921910603271452} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -1.1827358, y: 10.077041, z: -4.3000727} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 6080083766368814547} + - {fileID: 4454143011079988569} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &-1195567701300851260 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7042921910603271452} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 72344165e2cc41da93476bb1aa2cdd4b, type: 3} + m_Name: + m_EditorClassIdentifier: + k__BackingField: + k__BackingField: 1 + k__BackingField: 20 + k__BackingField: {fileID: 0} + k__BackingField: 1 +--- !u!114 &2015339067979990790 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7042921910603271452} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 1cef53d855ccf0b46bcf004b27c4a52a, type: 3} + m_Name: + m_EditorClassIdentifier: + k__BackingField: {fileID: -1195567701300851260} + k__BackingField: + k__BackingField: 1 + k__BackingField: 20 +--- !u!114 &1634778938604141570 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7042921910603271452} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2c2b7ad340c1437887ceaaf7a3de61bd, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &8649320982975687388 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7042921910603271452} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a036d4c62979460ebe1d652029117fbd, type: 3} + m_Name: + m_EditorClassIdentifier: + k__BackingField: 0 + k__BackingField: {x: 0, y: 0, z: 0} + moveCount: 0 + maxMoveCount: 3 +--- !u!114 &-6150666128992256381 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7042921910603271452} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fb101b5c4c8944608e65a8756a119966, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1 &7136932116662994840 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4454143011079988569} + - component: {fileID: 5682532304103803357} + - component: {fileID: 4832325360807236088} + - component: {fileID: 3467602990273146907} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &4454143011079988569 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7136932116662994840} + m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068} + m_LocalPosition: {x: 0, y: 0, z: -1.2} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 4808053668070117556} + m_Father: {fileID: 9090141417940585542} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 1, y: 1} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!223 &5682532304103803357 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7136932116662994840} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 2 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 25 + m_UpdateRectTransformForStandalone: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!114 &4832325360807236088 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7136932116662994840} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 200 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 200 + m_PresetInfoIsWorld: 1 +--- !u!114 &3467602990273146907 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7136932116662994840} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!1 &8202942351555363694 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6080083766368814547} + - component: {fileID: 2375434110285253037} + - component: {fileID: 7404256227601833702} + m_Layer: 0 + m_Name: 00-creature-sheet-front_0 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &6080083766368814547 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8202942351555363694} + m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068} + m_LocalPosition: {x: 1.1827358, y: -10.077041, z: 4.3000727} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 9090141417940585542} + m_RootOrder: -1 + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} +--- !u!212 &2375434110285253037 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8202942351555363694} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: -105014757, guid: 142aa6170bc3def4d8416c097c46b6cb, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 1, y: 1} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!95 &7404256227601833702 +Animator: + serializedVersion: 5 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8202942351555363694} + m_Enabled: 1 + m_Avatar: {fileID: 0} + m_Controller: {fileID: 9100000, guid: 6b5474218fde99a44ac01ae72b1d79ad, type: 2} + m_CullingMode: 0 + m_UpdateMode: 0 + m_ApplyRootMotion: 0 + m_LinearVelocityBlending: 0 + m_StabilizeFeet: 0 + m_WarningMessage: + m_HasTransformHierarchy: 1 + m_AllowConstantClipSamplingOptimization: 1 + m_KeepAnimatorStateOnDisable: 0 diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/TurnAgent.prefab.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/TurnAgent.prefab.meta new file mode 100644 index 00000000..1549bc8f --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Prefabs/TurnAgent.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4b4c14f1d00b7ca40a1e60acb4b2ba85 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors.meta new file mode 100644 index 00000000..3d7bd7db --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5955fe1df0174ac39bb7e7e762e8e58b +timeCreated: 1688387361 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors/Target.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors/Target.meta new file mode 100644 index 00000000..fffd149a --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors/Target.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 22388ccfc042479882785e108119536b +timeCreated: 1688387361 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors/Target/TurnWanderTargetSensor.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors/Target/TurnWanderTargetSensor.cs new file mode 100644 index 00000000..a59dcb91 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors/Target/TurnWanderTargetSensor.cs @@ -0,0 +1,30 @@ +using CrashKonijn.Agent.Core; +using CrashKonijn.GOAP.Demos.TurnBased.Behaviours; +using CrashKonijn.GOAP.Demos.TurnBased.Interfaces; +using CrashKonijn.Goap.Runtime; +using UnityEngine; + +namespace CrashKonijn.GOAP.Demos.TurnBased.Sensors.Target +{ + public class TurnWanderTargetSensor : LocalTargetSensorBase, IInjectable + { + private IGrid grid; + + public override void Created() { } + + public void Inject(InjectBehaviour data) + { + Debug.Log("Inject"); + this.grid = data.Grid; + } + + public override void Update() { } + + public override ITarget Sense(IActionReceiver agent, IComponentReference references, ITarget existingTarget) + { + var tile = this.grid.GetWalkableTiles().Random(); + + return new TileTarget(tile); + } + } +} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors/Target/TurnWanderTargetSensor.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors/Target/TurnWanderTargetSensor.cs.meta new file mode 100644 index 00000000..38e4861a --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/Sensors/Target/TurnWanderTargetSensor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1c5baac529484f47acb2efa7ca5f0ffc +timeCreated: 1688387361 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TargetKeys.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TargetKeys.meta new file mode 100644 index 00000000..5dbb2084 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TargetKeys.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3022aad12add7244e9127d228da6a908 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TargetKeys/WanderTarget.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TargetKeys/WanderTarget.cs new file mode 100644 index 00000000..c17e26d7 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TargetKeys/WanderTarget.cs @@ -0,0 +1,7 @@ +using CrashKonijn.Goap.Runtime; + +namespace CrashKonijn.Goap.Demos.TurnBased +{ + [GoapId("WanderTarget-a7519939-d867-47ae-bd5e-45a611185824")] + public class WanderTarget : TargetKeyBase {} +} \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TargetKeys/WanderTarget.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TargetKeys/WanderTarget.cs.meta new file mode 100644 index 00000000..01dd550c --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TargetKeys/WanderTarget.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 66b36b22f84c95541b6409f6c54a33f7 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TileTarget.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TileTarget.cs new file mode 100644 index 00000000..10fff8e8 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TileTarget.cs @@ -0,0 +1,26 @@ +using CrashKonijn.Agent.Core; +using CrashKonijn.GOAP.Demos.TurnBased.Interfaces; +using CrashKonijn.Goap.Runtime; +using UnityEngine; + +namespace CrashKonijn.GOAP.Demos.TurnBased +{ + public class TileTarget : ITarget + { + public ITile Tile { get; } + public Vector3 Position => this.Tile.Position; + + public bool IsValid() + { + if (this.Tile.IsNull()) + return false; + + return true; + } + + public TileTarget(ITile tile) + { + this.Tile = tile; + } + } +} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TileTarget.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TileTarget.cs.meta new file mode 100644 index 00000000..51fd7a21 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TileTarget.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 32e7bf8e901e46dd91fa7fa9009ec0a6 +timeCreated: 1688387587 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnAgentBrain.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnAgentBrain.cs new file mode 100644 index 00000000..a4106498 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnAgentBrain.cs @@ -0,0 +1,21 @@ +using CrashKonijn.Goap.Demos.TurnBased; +using CrashKonijn.Goap.Runtime; +using UnityEngine; + +namespace CrashKonijn.GOAP.Demos.TurnBased +{ + public class TurnAgentBrain : MonoBehaviour + { + private GoapActionProvider agent; + + private void Awake() + { + this.agent = this.GetComponent(); + } + + private void Start() + { + this.agent.RequestGoal(); + } + } +} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnAgentBrain.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnAgentBrain.cs.meta new file mode 100644 index 00000000..a06b595d --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnAgentBrain.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2c2b7ad340c1437887ceaaf7a3de61bd +timeCreated: 1688546481 \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnBased.unity b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnBased.unity new file mode 100644 index 00000000..44350fb6 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnBased.unity @@ -0,0 +1,490 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 12 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &785049938 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 785049943} + - component: {fileID: 785049942} + - component: {fileID: 785049941} + - component: {fileID: 785049940} + - component: {fileID: 785049939} + m_Layer: 0 + m_Name: GOAP + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &785049939 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 785049938} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2a227a37d8b74a159de07af6adcf4cf3, type: 3} + m_Name: + m_EditorClassIdentifier: + k__BackingField: {fileID: 1435119684} + k__BackingField: {fileID: 1435119683} +--- !u!114 &785049940 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 785049938} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5bade2b7fd12449da879f559366fa0f5, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &785049941 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 785049938} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 463d8dde50524e5cb21ce76d94a12a01, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &785049942 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 785049938} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 19925b6b65787cf439172e5e095b51fe, type: 3} + m_Name: + m_EditorClassIdentifier: + configInitializer: {fileID: 785049941} + setConfigFactories: [] + goapSetConfigFactories: + - {fileID: 785049940} +--- !u!4 &785049943 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 785049938} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 2.4885108, y: -0.9809836, z: 5.0569453} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1010797156 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1010797159} + - component: {fileID: 1010797158} + - component: {fileID: 1010797157} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &1010797157 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1010797156} + m_Enabled: 1 +--- !u!20 &1010797158 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1010797156} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1010797159 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1010797156} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1435119680 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1435119685} + - component: {fileID: 1435119684} + - component: {fileID: 1435119683} + - component: {fileID: 1435119682} + - component: {fileID: 1435119681} + m_Layer: 0 + m_Name: Behaviours + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1435119681 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1435119680} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b49297aa82e4409894be5d6e1c1237f4, type: 3} + m_Name: + m_EditorClassIdentifier: + state: 0 +--- !u!114 &1435119682 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1435119680} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 18cb43c7b9834befa876e5ca760b974f, type: 3} + m_Name: + m_EditorClassIdentifier: + agentPrefab: {fileID: 7042921910603271452, guid: 4b4c14f1d00b7ca40a1e60acb4b2ba85, + type: 3} +--- !u!114 &1435119683 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1435119680} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f43307bc896947cd96d4ca85fc2461a2, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &1435119684 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1435119680} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d1f070f9bdcb89443800402c17da93c6, type: 3} + m_Name: + m_EditorClassIdentifier: + tilePrefab: {fileID: 7370730411235180477, guid: 8a14f2a4edc752f48ae25533510f03ab, + type: 3} + width: 10 + height: 10 +--- !u!4 &1435119685 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1435119680} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1947713301 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1947713303} + - component: {fileID: 1947713302} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &1947713302 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1947713301} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 1 + m_Shape: 0 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &1947713303 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1947713301} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnBased.unity.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnBased.unity.meta new file mode 100644 index 00000000..c009d604 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/TurnBased.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6a5ba788787fd9c438ea1c2694646336 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/WorldKeys.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/WorldKeys.meta new file mode 100644 index 00000000..56ebf695 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/WorldKeys.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ce1aa03f18bcf1f459f2f9bfea9f7bf1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/WorldKeys/IsWandering.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/WorldKeys/IsWandering.cs new file mode 100644 index 00000000..cb8c5c80 --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/WorldKeys/IsWandering.cs @@ -0,0 +1,7 @@ +using CrashKonijn.Goap.Runtime; + +namespace CrashKonijn.Goap.Demos.TurnBased +{ + [GoapId("IsWandering-2eb28024-74be-434e-b185-0d6a987498d2")] + public class IsWandering : WorldKeyBase {} +} \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/WorldKeys/IsWandering.cs.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/WorldKeys/IsWandering.cs.meta new file mode 100644 index 00000000..2920059b --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/WorldKeys/IsWandering.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 837952a0790dd174ea95936461e43484 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/com.crashkonijn.goap.demos.turn-based.asmdef b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/com.crashkonijn.goap.demos.turn-based.asmdef new file mode 100644 index 00000000..521a696d --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/com.crashkonijn.goap.demos.turn-based.asmdef @@ -0,0 +1,20 @@ +{ + "name": "com.crashkonijn.goap.demos.turn-based", + "rootNamespace": "CrashKonijn.Goap.Demos.TurnBased", + "references": [ + "GUID:6eb7f39de256eea4bb8708df2c32e1ba", + "GUID:1492f7fc38ce464dae5c20df05fd22e3", + "GUID:6055be8ebefd69e48b49212b09b47b2f", + "GUID:0d347051544a4880a72466503e27985a", + "GUID:4d9088d80ac84f52b9b07421f95af69c" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/com.crashkonijn.goap.demos.turn-based.asmdef.meta b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/com.crashkonijn.goap.demos.turn-based.asmdef.meta new file mode 100644 index 00000000..1d33f64b --- /dev/null +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/TurnBased/com.crashkonijn.goap.demos.turn-based.asmdef.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0bbcc5cd95754240ba623985e2425956 +timeCreated: 1731495570 \ No newline at end of file diff --git a/Demo/com.crashkonijn.goap.demos.turn-based.csproj.DotSettings b/Demo/com.crashkonijn.goap.demos.turn-based.csproj.DotSettings new file mode 100644 index 00000000..edf3e9c7 --- /dev/null +++ b/Demo/com.crashkonijn.goap.demos.turn-based.csproj.DotSettings @@ -0,0 +1,5 @@ + + True + True + True + True \ No newline at end of file