protected override bool Begin(IStateMachine <AIAttributes, object> stateMachine) { item = (IGrabbableItem)Agent.Memory.Get(AIAttributes.HeldItem); if (item == null) { return(false); } if (!(item is ResourceBase resource)) { return(false); } building = GetCraftingPad(resource); if (building == null || !(building is ICraftingStation s)) { return(false); } station = s; var moveState = new MoveState(Agent, movement, building.Transform); stateMachine.Enqueue(moveState); stateMachine.OnComplete += OnTargetReached; return(true); }
protected override bool Begin(IStateMachine <AIAttributes, object> stateMachine) { var deposit = (GatherableDeposit)Agent.Memory.Get(AIAttributes.DepositToGather); if (deposit == null) { return(false); } this.stateMachine = stateMachine; var moveState = new MoveState(Agent, movement, deposit.transform); var gatherState = new GatherState(Agent, gatherer); gatherState.SetTarget(deposit); stateMachine.Enqueue(moveState); stateMachine.Enqueue(gatherState); stateMachine.OnComplete += OnComplete; return(true); }
protected override bool Begin(IStateMachine <AIAttributes, object> stateMachine) { pad = (CraftingPad)Agent.Memory.Get(AIAttributes.TargetBuilding); if (pad == null || !(pad is BuildingBase b)) { return(false); } building = b; var moveState = new MoveState(Agent, movement, building.Transform); stateMachine.Enqueue(moveState); stateMachine.OnComplete += OnTargetReached; return(true); }
protected override bool Begin(IStateMachine <AIAttributes, object> stateMachine) { item = (IGrabbableItem)Agent.Memory.Get(AIAttributes.ItemToGather); if (item == null) { return(false); } isGathering = false; moveState = new MoveState(Agent, movement, item.Transform); stateMachine.Enqueue(moveState); stateMachine.OnComplete += OnTargetReached; return(true); }
protected override bool Begin(IStateMachine <AIAttributes, object> stateMachine) { item = (IGrabbableItem)Agent.Memory.Get(AIAttributes.HeldItem); if (item == null) { return(false); } var type = BuildingTypes.None; if (item is ResourceBase) { type = BuildingTypes.ResourceDepot; } if (type == BuildingTypes.None) { return(false); } var buildingSensor = Agent.Sensors.Get <BuildingSensor>(); if (buildingSensor == null) { return(false); } building = buildingSensor.FindClosestBuilding(type, Agent.Owner.transform.position); if (building == null || !(building is IStorage s)) { return(false); } storage = s; var target = building.pathingPoint == null ? building.Transform : building.pathingPoint; var moveState = new MoveState(Agent, movement, target); stateMachine.Enqueue(moveState); stateMachine.OnComplete += OnTargetReached; return(true); }