StationObscurum/Assets/Scripts/Enemies/AI/AIV2/Strips/StripsActionResolver.cs
2024-02-12 02:23:19 -05:00

90 lines
2.6 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace STRIPS
{
public class StripsActionResolver : MonoBehaviour
{
[SerializeField]
private List<StripsGoal> goals;
private StripsGoal activeGoal;
[SerializeField]
private AStripsActionResolver chosenResolver;
[SerializeField]
private StripsVariableMapping variableMapping;
private StripsVariableMapping.PackageMapping updatedStats;
private void PerformAction(AStripsActionResolver.StripsActionResolverAction action)
{
switch(action)
{
case AStripsActionResolver.StripsActionResolverAction.Attack:
chosenResolver.Attack();
break;
case AStripsActionResolver.StripsActionResolverAction.Hide:
chosenResolver.Hide();
break;
case AStripsActionResolver.StripsActionResolverAction.LookAt:
chosenResolver.LookAt();
break;
case AStripsActionResolver.StripsActionResolverAction.Roar:
chosenResolver.Roar();
break;
case AStripsActionResolver.StripsActionResolverAction.MoveTo:
chosenResolver.MoveTo();
break;
default:
chosenResolver.Idle();
break;
}
}
public void Selector()
{
foreach (StripsGoal goal in goals)
{
goal.UpdateActionConditionals(updatedStats);
if (goal.Available.Count > 0)
{
activeGoal = goal;
break;
}
}
if(activeGoal != null)
{
AStripsActionResolver.StripsActionResolverAction[] functs = activeGoal.Available[0].functions;
foreach(AStripsActionResolver.StripsActionResolverAction action in functs)
{
PerformAction(action);
}
}
}
// Start is called before the first frame update
void Start()
{
updatedStats = variableMapping.CreateCopy();
InvokeRepeating("Selector", 1, 1);
}
// Update is called once per frame
void Update()
{
if (chosenResolver.Collect(ref updatedStats))
{
//all good
}
print("Current Action:" + activeGoal.name);
}
}
}