Through Code
Sets
using CrashKonijn.Goap.Behaviours;
using CrashKonijn.Goap.Classes.Builders;
using CrashKonijn.Goap.Configs.Interfaces;
using Demos.Complex.Classes;
using Demos.Complex.Classes.Items;
using Demos.Complex.Factories.Extensions;
using Demos.Complex.Interfaces;
using Demos.Shared;
public class GoapSetConfigFactory : GoapSetFactoryBase
{
public override IGoapSetConfig Create()
{
var builder = new GoapSetBuilder("ComplexSet");
// Goals
builder.AddGoal<WanderGoal>()
.AddCondition<IsWandering>(Comparison.GreaterThanOrEqual, 1);
builder.AddGoal<FixHungerGoal>()
.AddCondition<IsHungry>(Comparison.SmallerThanOrEqual, 0);
// Actions
builder.AddAction<WanderAction>()
.SetTarget<WanderTarget>()
.AddEffect<IsWandering>(true)
.SetBaseCost(1f)
.SetInRange(0.3f);
builder.AddAction<PickupItemAction<IEatable>>()
.SetTarget<ClosestTarget<IEatable>>()
.AddEffect<IsHolding<IEatable>>(true)
.AddCondition<IsInWorld<IEatable>>(Comparison.GreaterThanOrEqual, 1)
.SetBaseCost(1f)
.SetInRange(0.3f);
// Target Sensors
builder.AddTargetSensor<WanderTargetSensor>()
.SetTarget<WanderTarget>();
builder.AddTargetSensor<ClosestItemSensor<IEatable>>()
.SetTarget<ClosestTarget<IEatable>>();
// World Sensors
builder.AddWorldSensor<IsHoldingSensor<IEatable>>()
.SetKey<IsHolding<IEatable>>());
builder.AddWorldSensor<IsInWorldSensor<IEatable>>()
.SetKey<IsInWorld<IEatable>>();
return builder.Build();
}
}Adding the set to GOAP

Adding the set to the agent.
Last updated