diff --git a/Demo/Assets/CrashKonijn/GOAP/Demos/Complex/Factories/CleanerAgentTypeConfigFactory.cs b/Demo/Assets/CrashKonijn/GOAP/Demos/Complex/Factories/CleanerAgentTypeConfigFactory.cs index af1c1e8b..660fc53a 100644 --- a/Demo/Assets/CrashKonijn/GOAP/Demos/Complex/Factories/CleanerAgentTypeConfigFactory.cs +++ b/Demo/Assets/CrashKonijn/GOAP/Demos/Complex/Factories/CleanerAgentTypeConfigFactory.cs @@ -9,6 +9,7 @@ using CrashKonijn.Goap.Demos.Complex.Targets; using CrashKonijn.Goap.Demos.Complex.WorldKeys; using CrashKonijn.Goap.Runtime; +using UnityEngine; namespace CrashKonijn.Goap.Demos.Complex.Factories { @@ -17,7 +18,7 @@ public class CleanerAgentTypeConfigFactory : AgentTypeFactoryBase public override IAgentTypeConfig Create() { var builder = new AgentTypeBuilder(SetIds.Cleaner); - + builder.AddCapability(); builder.AddCapability(); builder.AddCapability(); @@ -27,13 +28,17 @@ public override IAgentTypeConfig Create() capability.AddGoal() .SetBaseCost(20) .AddCondition(Comparison.SmallerThanOrEqual, 0); - + capability.AddAction() .SetTarget() .AddEffect(EffectType.Decrease) .AddCondition(Comparison.GreaterThanOrEqual, 1) - .SetMoveMode(ActionMoveMode.PerformWhileMoving); - + .SetMoveMode(ActionMoveMode.PerformWhileMoving) + .SetCallback((action) => + { + Debug.Log($"Action callback: {action}"); + }); + capability.AddWorldSensor() .SetKey(); diff --git a/Package/Runtime/CrashKonijn.Goap.Core/Interfaces/IActionConfig.cs b/Package/Runtime/CrashKonijn.Goap.Core/Interfaces/IActionConfig.cs index 12345c0c..a0f64685 100644 --- a/Package/Runtime/CrashKonijn.Goap.Core/Interfaces/IActionConfig.cs +++ b/Package/Runtime/CrashKonijn.Goap.Core/Interfaces/IActionConfig.cs @@ -1,4 +1,5 @@ -using CrashKonijn.Agent.Core; +using System; +using CrashKonijn.Agent.Core; namespace CrashKonijn.Goap.Core { @@ -14,4 +15,9 @@ public interface IActionConfig : IClassConfig public ActionMoveMode MoveMode { get; } public IActionProperties Properties { get; } } -} \ No newline at end of file + + public interface IClassCallbackConfig + { + public Action Callback { get; } + } +} diff --git a/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/AgentTypeFactory.cs b/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/AgentTypeFactory.cs index 2ba86e04..18e5d845 100644 --- a/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/AgentTypeFactory.cs +++ b/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/AgentTypeFactory.cs @@ -64,6 +64,9 @@ private List GetActions(IAgentTypeConfig config) actions.ForEach(x => { + if (x.Config is IClassCallbackConfig classCallbackConfig) + classCallbackConfig.Callback?.Invoke(x); + injector.Inject(x); x.Created(); }); @@ -79,6 +82,9 @@ private List GetGoals(IAgentTypeConfig config) goals.ForEach(x => { + if (x.Config is IClassCallbackConfig classCallbackConfig) + classCallbackConfig.Callback?.Invoke(x); + x.Index = index; index++; @@ -95,6 +101,9 @@ private List GetWorldSensors(IAgentTypeConfig config) worldSensors.ForEach(x => { + if (x.Config is IClassCallbackConfig classCallbackConfig) + classCallbackConfig.Callback?.Invoke(x); + injector.Inject(x); x.Created(); }); @@ -109,6 +118,9 @@ private List GetTargetSensors(IAgentTypeConfig config) targetSensors.ForEach(x => { + if (x.Config is IClassCallbackConfig classCallbackConfig) + classCallbackConfig.Callback?.Invoke(x); + injector.Inject(x); x.Created(); }); @@ -123,6 +135,9 @@ private List GetMultiSensors(IAgentTypeConfig config) multiSensor.ForEach(x => { + if (x.Config is IClassCallbackConfig classCallbackConfig) + classCallbackConfig.Callback?.Invoke(x); + injector.Inject(x); x.Created(); }); diff --git a/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/ActionBuilder.cs b/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/ActionBuilder.cs index cc336b2b..ec0fc286 100644 --- a/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/ActionBuilder.cs +++ b/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/ActionBuilder.cs @@ -6,80 +6,56 @@ namespace CrashKonijn.Goap.Runtime { - public class ActionBuilder + public class ActionBuilder : ActionBuilder + where T : IAction { - private readonly ActionConfig config; - private readonly List conditions = new(); - private readonly List effects = new(); - private readonly WorldKeyBuilder worldKeyBuilder; - private readonly TargetKeyBuilder targetKeyBuilder; - private readonly Type actionType; - - public ActionBuilder(Type actionType, WorldKeyBuilder worldKeyBuilder, TargetKeyBuilder targetKeyBuilder) - { - this.actionType = actionType; - this.worldKeyBuilder = worldKeyBuilder; - this.targetKeyBuilder = targetKeyBuilder; + public ActionBuilder(WorldKeyBuilder worldKeyBuilder, TargetKeyBuilder targetKeyBuilder) : base(typeof(T), worldKeyBuilder, targetKeyBuilder) { } - var propType = this.GetPropertiesType(); - - this.config = new ActionConfig - { - Name = actionType.Name, - ClassType = actionType.AssemblyQualifiedName, - BaseCost = 1, - StoppingDistance = 0.5f, - RequiresTarget = true, - ValidateConditions = true, - Properties = (IActionProperties) Activator.CreateInstance(propType), - }; - } - - public ActionBuilder SetTarget() + public ActionBuilder SetTarget() where TTargetKey : ITargetKey { this.config.Target = this.targetKeyBuilder.GetKey(); return this; } - public ActionBuilder SetBaseCost(float baseCost) + public ActionBuilder SetBaseCost(float baseCost) { this.config.BaseCost = baseCost; return this; } - public ActionBuilder SetRequiresTarget(bool requiresTarget) + public ActionBuilder SetRequiresTarget(bool requiresTarget) { this.config.RequiresTarget = requiresTarget; return this; } - public ActionBuilder SetValidateConditions(bool validate) + public ActionBuilder SetValidateConditions(bool validate) { this.config.ValidateConditions = validate; return this; } - public ActionBuilder SetStoppingDistance(float inRange) + public ActionBuilder SetStoppingDistance(float inRange) { this.config.StoppingDistance = inRange; return this; } [Obsolete("Use `SetStoppingDistance(float inRange)` instead.")] - public ActionBuilder SetInRange(float inRange) + public ActionBuilder SetInRange(float inRange) { this.config.StoppingDistance = inRange; return this; } - public ActionBuilder SetMoveMode(ActionMoveMode moveMode) + public ActionBuilder SetMoveMode(ActionMoveMode moveMode) { this.config.MoveMode = moveMode; return this; } - public ActionBuilder AddCondition(Comparison comparison, int amount) + public ActionBuilder AddCondition(Comparison comparison, int amount) where TWorldKey : IWorldKey { this.conditions.Add(new Condition @@ -93,7 +69,7 @@ public ActionBuilder AddCondition(Comparison comparison, int amount) } [Obsolete("Use `AddEffect(EffectType type)` instead.")] - public ActionBuilder AddEffect(bool increase) + public ActionBuilder AddEffect(bool increase) where TWorldKey : IWorldKey { this.effects.Add(new Effect @@ -105,7 +81,7 @@ public ActionBuilder AddEffect(bool increase) return this; } - public ActionBuilder AddEffect(EffectType type) + public ActionBuilder AddEffect(EffectType type) where TWorldKey : IWorldKey { this.effects.Add(new Effect @@ -117,7 +93,7 @@ public ActionBuilder AddEffect(EffectType type) return this; } - public ActionBuilder SetProperties(IActionProperties properties) + public ActionBuilder SetProperties(IActionProperties properties) { this.ValidateProperties(properties); @@ -125,7 +101,43 @@ public ActionBuilder SetProperties(IActionProperties properties) return this; } - private void ValidateProperties(IActionProperties properties) + public ActionBuilder SetCallback(Action callback) + { + this.config.Callback = (obj) => callback((T) obj); + return this; + } + } + + public class ActionBuilder + { + protected readonly ActionConfig config; + protected readonly List conditions = new(); + protected readonly List effects = new(); + protected readonly WorldKeyBuilder worldKeyBuilder; + protected readonly TargetKeyBuilder targetKeyBuilder; + protected readonly Type actionType; + + public ActionBuilder(Type actionType, WorldKeyBuilder worldKeyBuilder, TargetKeyBuilder targetKeyBuilder) + { + this.actionType = actionType; + this.worldKeyBuilder = worldKeyBuilder; + this.targetKeyBuilder = targetKeyBuilder; + + var propType = this.GetPropertiesType(); + + this.config = new ActionConfig + { + Name = actionType.Name, + ClassType = actionType.AssemblyQualifiedName, + BaseCost = 1, + StoppingDistance = 0.5f, + RequiresTarget = true, + ValidateConditions = true, + Properties = (IActionProperties) Activator.CreateInstance(propType), + }; + } + + protected void ValidateProperties(IActionProperties properties) { var actionPropsType = this.GetPropertiesType(); @@ -135,7 +147,7 @@ private void ValidateProperties(IActionProperties properties) throw new ArgumentException($"The provided properties do not match the expected type '{actionPropsType.Name}'.", nameof(properties)); } - private Type GetPropertiesType() + protected Type GetPropertiesType() { var baseType = this.actionType.BaseType; @@ -161,10 +173,10 @@ public IActionConfig Build() return this.config; } - public static ActionBuilder Create(WorldKeyBuilder worldKeyBuilder, TargetKeyBuilder targetKeyBuilder) + public static ActionBuilder Create(WorldKeyBuilder worldKeyBuilder, TargetKeyBuilder targetKeyBuilder) where TAction : IAction { - return new ActionBuilder(typeof(TAction), worldKeyBuilder, targetKeyBuilder); + return new ActionBuilder(worldKeyBuilder, targetKeyBuilder); } } } diff --git a/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/AgentTypeBuilder.cs b/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/AgentTypeBuilder.cs index 7561b210..956a2406 100644 --- a/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/AgentTypeBuilder.cs +++ b/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/AgentTypeBuilder.cs @@ -97,7 +97,7 @@ public CapabilityBuilder(string name) this.capabilityConfig = new CapabilityConfig(name); } - public ActionBuilder AddAction() + public ActionBuilder AddAction() where TAction : IAction { var actionBuilder = ActionBuilder.Create(this.worldKeyBuilder, this.targetKeyBuilder); @@ -107,7 +107,7 @@ public ActionBuilder AddAction() return actionBuilder; } - public GoalBuilder AddGoal() + public GoalBuilder AddGoal() where TGoal : IGoal { var goalBuilder = GoalBuilder.Create(this.worldKeyBuilder); @@ -117,7 +117,7 @@ public GoalBuilder AddGoal() return goalBuilder; } - public WorldSensorBuilder AddWorldSensor() + public WorldSensorBuilder AddWorldSensor() where TWorldSensor : IWorldSensor { var worldSensorBuilder = WorldSensorBuilder.Create(this.worldKeyBuilder); @@ -127,7 +127,7 @@ public WorldSensorBuilder AddWorldSensor() return worldSensorBuilder; } - public TargetSensorBuilder AddTargetSensor() + public TargetSensorBuilder AddTargetSensor() where TTargetSensor : ITargetSensor { var targetSensorBuilder = TargetSensorBuilder.Create(this.targetKeyBuilder); @@ -137,10 +137,10 @@ public TargetSensorBuilder AddTargetSensor() return targetSensorBuilder; } - public MultiSensorBuilder AddMultiSensor() + public MultiSensorBuilder AddMultiSensor() where TMultiSensor : IMultiSensor { - var multiSensorBuilder = MultiSensorBuilder.Create(this.worldKeyBuilder); + var multiSensorBuilder = MultiSensorBuilder.Create(); this.multiSensorBuilders.Add(multiSensorBuilder); diff --git a/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/GoalBuilder.cs b/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/GoalBuilder.cs index f0c15753..d8c50d76 100644 --- a/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/GoalBuilder.cs +++ b/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/GoalBuilder.cs @@ -4,45 +4,57 @@ namespace CrashKonijn.Goap.Runtime { - public class GoalBuilder + public class GoalBuilder : GoalBuilder + where T : IGoal { - private readonly GoalConfig config; - private readonly List conditions = new(); - private readonly WorldKeyBuilder worldKeyBuilder; + public GoalBuilder(WorldKeyBuilder worldKeyBuilder) : base(typeof(T), worldKeyBuilder) { } - public GoalBuilder(Type type, WorldKeyBuilder worldKeyBuilder) - { - this.worldKeyBuilder = worldKeyBuilder; - this.config = new GoalConfig(type) - { - BaseCost = 1, - ClassType = type.AssemblyQualifiedName, - }; - } - - public GoalBuilder SetBaseCost(float baseCost) + public GoalBuilder SetBaseCost(float baseCost) { this.config.BaseCost = baseCost; return this; } - public GoalBuilder AddCondition(Comparison comparison, int amount) + public GoalBuilder AddCondition(Comparison comparison, int amount) where TWorldKey : IWorldKey { this.conditions.Add(new Condition(this.worldKeyBuilder.GetKey(), comparison, amount)); return this; } + public GoalBuilder SetCallback(Action callback) + { + this.config.Callback = (obj) => callback((T) obj); + return this; + } + } + + public class GoalBuilder + { + protected readonly GoalConfig config; + protected readonly List conditions = new(); + protected readonly WorldKeyBuilder worldKeyBuilder; + + public GoalBuilder(Type type, WorldKeyBuilder worldKeyBuilder) + { + this.worldKeyBuilder = worldKeyBuilder; + this.config = new GoalConfig(type) + { + BaseCost = 1, + ClassType = type.AssemblyQualifiedName, + }; + } + public IGoalConfig Build() { this.config.Conditions = this.conditions; return this.config; } - public static GoalBuilder Create(WorldKeyBuilder worldKeyBuilder) + public static GoalBuilder Create(WorldKeyBuilder worldKeyBuilder) where TGoal : IGoal { - return new GoalBuilder(typeof(TGoal), worldKeyBuilder); + return new GoalBuilder(worldKeyBuilder); } } } diff --git a/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/MultiSensorBuilder.cs b/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/MultiSensorBuilder.cs index 7f354c85..8536d6ed 100644 --- a/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/MultiSensorBuilder.cs +++ b/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/MultiSensorBuilder.cs @@ -3,14 +3,24 @@ namespace CrashKonijn.Goap.Runtime { + public class MultiSensorBuilder : MultiSensorBuilder + where T : IMultiSensor + { + public MultiSensorBuilder() : base(typeof(T)) { } + + public MultiSensorBuilder SetCallback(Action callback) + { + this.config.Callback = (obj) => callback((T) obj); + return this; + } + } + public class MultiSensorBuilder { - private readonly WorldKeyBuilder worldKeyBuilder; - private readonly MultiSensorConfig config; + protected readonly MultiSensorConfig config; - public MultiSensorBuilder(Type type, WorldKeyBuilder worldKeyBuilder) + public MultiSensorBuilder(Type type) { - this.worldKeyBuilder = worldKeyBuilder; this.config = new MultiSensorConfig() { Name = type.Name, @@ -23,10 +33,10 @@ public IMultiSensorConfig Build() return this.config; } - public static MultiSensorBuilder Create(WorldKeyBuilder worldKeyBuilder) + public static MultiSensorBuilder Create() where TMultiSensor : IMultiSensor { - return new MultiSensorBuilder(typeof(TMultiSensor), worldKeyBuilder); + return new MultiSensorBuilder(); } } } diff --git a/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/TargetSensorBuilder.cs b/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/TargetSensorBuilder.cs index 16ff267d..bddd5c28 100644 --- a/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/TargetSensorBuilder.cs +++ b/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/TargetSensorBuilder.cs @@ -3,10 +3,30 @@ namespace CrashKonijn.Goap.Runtime { + public class TargetSensorBuilder : TargetSensorBuilder + where T : ITargetSensor + { + public TargetSensorBuilder(TargetKeyBuilder targetKeyBuilder) : base(typeof(T), targetKeyBuilder) { } + + public TargetSensorBuilder SetTarget() + where TTarget : ITargetKey + { + this.config.Key = this.targetKeyBuilder.GetKey(); + + return this; + } + + public TargetSensorBuilder SetCallback(Action callback) + { + this.config.Callback = (obj) => callback((T) obj); + return this; + } + } + public class TargetSensorBuilder { - private readonly TargetKeyBuilder targetKeyBuilder; - private readonly TargetSensorConfig config; + protected readonly TargetKeyBuilder targetKeyBuilder; + protected readonly TargetSensorConfig config; public TargetSensorBuilder(Type type, TargetKeyBuilder targetKeyBuilder) { @@ -18,22 +38,14 @@ public TargetSensorBuilder(Type type, TargetKeyBuilder targetKeyBuilder) }; } - public TargetSensorBuilder SetTarget() - where TTarget : ITargetKey - { - this.config.Key = this.targetKeyBuilder.GetKey(); - - return this; - } - public ITargetSensorConfig Build() { return this.config; } - public static TargetSensorBuilder Create(TargetKeyBuilder targetKeyBuilder) where TTargetSensor : ITargetSensor + public static TargetSensorBuilder Create(TargetKeyBuilder targetKeyBuilder) where TTargetSensor : ITargetSensor { - return new TargetSensorBuilder(typeof(TTargetSensor), targetKeyBuilder); + return new TargetSensorBuilder(targetKeyBuilder); } } } diff --git a/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/WorldSensorBuilder.cs b/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/WorldSensorBuilder.cs index 8fdc85e8..f44cf586 100644 --- a/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/WorldSensorBuilder.cs +++ b/Package/Runtime/CrashKonijn.Goap.Runtime/Classes/Builders/WorldSensorBuilder.cs @@ -3,10 +3,30 @@ namespace CrashKonijn.Goap.Runtime { + public class WorldSensorBuilder : WorldSensorBuilder + where T : IWorldSensor + { + public WorldSensorBuilder(WorldKeyBuilder worldKeyBuilder) : base(typeof(T), worldKeyBuilder) { } + + public WorldSensorBuilder SetKey() + where TWorldKey : IWorldKey + { + this.config.Key = this.worldKeyBuilder.GetKey(); + + return this; + } + + public WorldSensorBuilder SetCallback(Action callback) + { + this.config.Callback = (obj) => callback((T) obj); + return this; + } + } + public class WorldSensorBuilder { - private readonly WorldKeyBuilder worldKeyBuilder; - private readonly WorldSensorConfig config; + protected readonly WorldKeyBuilder worldKeyBuilder; + protected readonly WorldSensorConfig config; public WorldSensorBuilder(Type type, WorldKeyBuilder worldKeyBuilder) { @@ -18,23 +38,15 @@ public WorldSensorBuilder(Type type, WorldKeyBuilder worldKeyBuilder) }; } - public WorldSensorBuilder SetKey() - where TWorldKey : IWorldKey - { - this.config.Key = this.worldKeyBuilder.GetKey(); - - return this; - } - public IWorldSensorConfig Build() { return this.config; } - public static WorldSensorBuilder Create(WorldKeyBuilder worldKeyBuilder) + public static WorldSensorBuilder Create(WorldKeyBuilder worldKeyBuilder) where TWorldSensor : IWorldSensor { - return new WorldSensorBuilder(typeof(TWorldSensor), worldKeyBuilder); + return new WorldSensorBuilder(worldKeyBuilder); } } } diff --git a/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/ActionConfig.cs b/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/ActionConfig.cs index 748965b8..0208bae4 100644 --- a/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/ActionConfig.cs +++ b/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/ActionConfig.cs @@ -1,9 +1,10 @@ -using CrashKonijn.Agent.Core; +using System; +using CrashKonijn.Agent.Core; using CrashKonijn.Goap.Core; namespace CrashKonijn.Goap.Runtime { - public class ActionConfig : IActionConfig + public class ActionConfig : IActionConfig, IClassCallbackConfig { public string Name { get; set; } public string ClassType { get; set; } @@ -16,5 +17,6 @@ public class ActionConfig : IActionConfig public ICondition[] Conditions { get; set; } public IEffect[] Effects { get; set; } public ActionMoveMode MoveMode { get; set; } = ActionMoveMode.MoveBeforePerforming; + public Action Callback { get; set; } } -} \ No newline at end of file +} diff --git a/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/GoalConfig.cs b/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/GoalConfig.cs index f8960b3f..fe82b410 100644 --- a/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/GoalConfig.cs +++ b/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/GoalConfig.cs @@ -5,7 +5,7 @@ namespace CrashKonijn.Goap.Runtime { [Serializable] - public class GoalConfig : IGoalConfig + public class GoalConfig : IGoalConfig, IClassCallbackConfig { public GoalConfig() { } @@ -19,6 +19,7 @@ public GoalConfig(Type type) public string ClassType { get; set; } public float BaseCost { get; set; } public List Conditions { get; set; } = new(); + public Action Callback { get; set; } public static GoalConfig Create() where TGoal : IGoal diff --git a/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/MultiSensorConfig.cs b/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/MultiSensorConfig.cs index e2edf5fa..3f240537 100644 --- a/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/MultiSensorConfig.cs +++ b/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/MultiSensorConfig.cs @@ -1,10 +1,12 @@ -using CrashKonijn.Goap.Core; +using System; +using CrashKonijn.Goap.Core; namespace CrashKonijn.Goap.Runtime { - public class MultiSensorConfig : IMultiSensorConfig + public class MultiSensorConfig : IMultiSensorConfig, IClassCallbackConfig { public string Name { get; set; } public string ClassType { get; set; } + public Action Callback { get; set; } } } \ No newline at end of file diff --git a/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/TargetSensorConfig.cs b/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/TargetSensorConfig.cs index 0c082bce..875a3ada 100644 --- a/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/TargetSensorConfig.cs +++ b/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/TargetSensorConfig.cs @@ -1,4 +1,5 @@ -using CrashKonijn.Goap.Core; +using System; +using CrashKonijn.Goap.Core; namespace CrashKonijn.Goap.Runtime { @@ -18,10 +19,11 @@ public TargetSensorConfig(string name) } } - public class TargetSensorConfig : ITargetSensorConfig + public class TargetSensorConfig : ITargetSensorConfig, IClassCallbackConfig { public string Name { get; set; } public string ClassType { get; set; } public ITargetKey Key { get; set; } + public Action Callback { get; set; } } } diff --git a/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/WorldSensorConfig.cs b/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/WorldSensorConfig.cs index 576e8251..ec77aed3 100644 --- a/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/WorldSensorConfig.cs +++ b/Package/Runtime/CrashKonijn.Goap.Runtime/Configs/WorldSensorConfig.cs @@ -1,4 +1,5 @@ -using CrashKonijn.Goap.Core; +using System; +using CrashKonijn.Goap.Core; namespace CrashKonijn.Goap.Runtime { @@ -18,10 +19,11 @@ public WorldSensorConfig(string name) } } - public class WorldSensorConfig : IWorldSensorConfig + public class WorldSensorConfig : IWorldSensorConfig, IClassCallbackConfig { public string Name { get; set; } public string ClassType { get; set; } public IWorldKey Key { get; set; } + public Action Callback { get; set; } } }