using System.Collections.Generic; using Base; using Prefab; using Unity.VisualScripting; using UnityEngine; namespace AI { public abstract class JobBase { public Entity.Entity entity; protected int timeoutTicks = 300; public bool Running => timeoutTicks > 0; protected abstract void UpdateJob(); public virtual void StartJob(Entity.Entity target) { entity = target; } public bool Update() { if (!Running) return false; UpdateJob(); timeoutTicks--; return true; } public virtual void StopJob() { timeoutTicks = 0; } } public class WanderJob : JobBase { public override void StartJob(Entity.Entity target) { base.StartJob(target); Vector3 move = new(Random.Range(-10, 10), Random.Range(-10, 10)); var targetPosition = entity.transform.position + move; entity.SetTarget(targetPosition); entity.IsChase = false; } protected override void UpdateJob() { entity.TryMove(); } override public void StopJob() { base.StopJob(); entity.IsChase = true; } } public class IdleJob : JobBase { override public void StartJob(Entity.Entity target) { base.StartJob(target); timeoutTicks = 500; } protected override void UpdateJob() { } } public class MoveJob : JobBase { protected override void UpdateJob() { entity.TryMove(); } } }