using Unity.Mathematics; namespace DanieleMarotta.RiversongCodeShowcase { public struct AgentIntent { public static readonly AgentIntent None = new() { Type = AgentIntentType.None }; public AgentIntentType Type; public TileRect Rect; public int TargetId; public PathTraversalRules PathTraversalRules; public ushort PathMaxDistance; public byte StopBeforeGoalStepCount; public int StorageId; public byte ProductHandle; public byte ProductAmount; public float GenericFloatParam0; public static AgentIntent MakeLive() { return new AgentIntent { Type = AgentIntentType.MakeLive }; } public static AgentIntent WaitSeconds(float time) { return new AgentIntent { Type = AgentIntentType.WaitSeconds, GenericFloatParam0 = time }; } public static AgentIntent WaitForever() { return new AgentIntent { Type = AgentIntentType.WaitForever }; } public static AgentIntent FindPath(TileRect rect, int targetId = Entity.InvalidId, PathTraversalRules traversalRules = PathTraversalRules.None) { return new AgentIntent { Type = AgentIntentType.FindPath, Rect = rect, TargetId = targetId, PathTraversalRules = traversalRules }; } public static AgentIntent SearchResourceNode(int targetId, PathTraversalRules traversalRules = PathTraversalRules.None, int maxDistance = 0) { var intent = new AgentIntent { Type = AgentIntentType.SearchResourceNode }; SetupSearchTargetIntent(ref intent, targetId, traversalRules, maxDistance); return intent; } public static AgentIntent SearchFertileTile(PathTraversalRules traversalRules = PathTraversalRules.None, int maxDistance = 0) { var intent = new AgentIntent { Type = AgentIntentType.SearchFertileTile }; SetupSearchTargetIntent(ref intent, Entity.InvalidId, traversalRules, maxDistance); return intent; } public static AgentIntent SearchCritter(int targetId, PathTraversalRules traversalRules = PathTraversalRules.None, int maxDistance = 0) { var intent = new AgentIntent { Type = AgentIntentType.SearchCritter }; SetupSearchTargetIntent(ref intent, targetId, traversalRules, maxDistance); return intent; } private static void SetupSearchTargetIntent(ref AgentIntent intent, int targetId, PathTraversalRules traversalRules, int maxDistance) { intent.TargetId = targetId; intent.PathTraversalRules = traversalRules; intent.PathMaxDistance = (ushort)maxDistance; } public static AgentIntent FollowPath(int stopBeforeGoalStepCount = 0) { return new AgentIntent { Type = AgentIntentType.FollowPath, StopBeforeGoalStepCount = (byte)stopBeforeGoalStepCount }; } public static AgentIntent MoveToHarvestPosition(float positionOffset) { return new AgentIntent { Type = AgentIntentType.MoveToHarvestPosition, GenericFloatParam0 = positionOffset }; } public static AgentIntent HarvestResource() { return new AgentIntent { Type = AgentIntentType.HarvestResource }; } public static AgentIntent HarvestFertileTile() { return new AgentIntent { Type = AgentIntentType.HarvestFertileTile }; } public static AgentIntent SetFertileTileLockState(int lockId) { return new AgentIntent { Type = AgentIntentType.SetFertileTileLockState, TargetId = lockId }; } public static AgentIntent FireProjectile(int targetId) { return new AgentIntent { Type = AgentIntentType.FireProjectile, TargetId = targetId }; } public static AgentIntent Take(int storageId, int productHandle, int productAmount) { return new AgentIntent { Type = AgentIntentType.TakeProduct, StorageId = storageId, ProductHandle = (byte)productHandle, ProductAmount = (byte)productAmount }; } public static AgentIntent Put(int storageId, int productHandle, int productAmount) { return new AgentIntent { Type = AgentIntentType.PutProduct, StorageId = storageId, ProductHandle = (byte)productHandle, ProductAmount = (byte)productAmount }; } public static AgentIntent Wander() { return new AgentIntent { Type = AgentIntentType.Wander }; } public static AgentIntent LoopWandering() { return new AgentIntent { Type = AgentIntentType.LoopWandering }; } public static AgentIntent LookAt(int2 tile) { return new AgentIntent { Type = AgentIntentType.LookAt, Rect = TileRect.OneTile(tile) }; } public static AgentIntent PlayAnimation(AgentAnimation animation) { return new AgentIntent { Type = AgentIntentType.PlayAnimation, TargetId = (int)animation }; } } }