Initialize AI Scripts

This commit is contained in:
Nico 2025-06-28 14:49:54 -07:00
parent a52bbb0849
commit 576a2d3e99
17 changed files with 143 additions and 126782 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 964a04e7fca6b3143a441e08dadb0579
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,17 @@
using UnityEngine;
namespace AI.Base {
public abstract class AgentController : MonoBehaviour {
protected IState currentState;
protected virtual void Update() {
currentState?.Tick();
IState next = currentState?.CheckTransitions();
if (next != null && next != currentState) {
currentState.OnExit();
currentState = next;
currentState.OnEnter();
}
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 6297ec95b1219e9418a9025265733745

View File

@ -0,0 +1,8 @@
namespace AI.Base {
public interface IState {
void OnEnter();
void Tick();
void OnExit();
IState CheckTransitions();
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 967d629cb6eb5914baeef87e8d71f614

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 25ebfdde91f6f5d42a04209ffeb5ff50
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,6 @@
namespace AI.BehaviorTrees {
public abstract class BTNode {
// Returns true on success, false if failed
public abstract bool Tick();
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2488a298ffb7f694c81f4bc8c4556416

View File

@ -0,0 +1,20 @@
using System.Collections.Generic;
namespace AI.BehaviorTrees {
public class CompositeNode : BTNode {
protected readonly List<BTNode> children = new List<BTNode>();
public override bool Tick() {
foreach (BTNode child in children) {
if (!child.Tick())
return false;
}
return true;
}
public void AddChild(BTNode child) {
if (child != null)
children.Add(child);
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9d2e6460215009149a2ce3676a5bb827

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d23211d0455243e4bb0eee95a7104962
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,13 @@
using UnityEngine;
using System.Collections.Generic;
namespace AI.Pathfinding {
public class AStarPathfinder {
// Example pathfinding method — replace with actual implementation
public List<Vector2> FindPath(Vector2 start, Vector2 goal) {
var path = new List<Vector2>();
// TODO: Implement A* algorithm here.
return path;
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9cbae134355a5c84392588e5f7904de9

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 266a8f8b490dc6449ad625710b64ef7d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@
using AI.Base;
using UnityEngine;
namespace AI.StateMachines {
public class EnemyStateMachine : AgentController {
public IState IdleState;
public IState ChaseState;
protected override void Start() {
base.Start();
currentState = IdleState;
currentState?.OnEnter();
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 71ab834a15cf8184ca8a951d8ea332bb