/// <summary> /// Returns actions based on targets for current location. /// </summary> /// /// <param name="targets">List of applicable targets for query.</param> /// <returns>List of actions</returns> public Queue <IAction> GetActions(IList <ITarget> targets, CallOrder type) { bool isStart = this._current == 0; bool startInList = this._locations.Contains(this.GetGameLocation(this._ordered[this._current].GetName())); bool currVisited = this._ordered[this._current].GetVisited(); bool isAtLocationStart = type == CallOrder.AtLocationStart; bool itemsInPath = this._path.Count > 0; if (this._path.Count > 1) { return(this.ActionToWarp()); } if ((isStart && !startInList) || (currVisited && isAtLocationStart) || itemsInPath) { if (this._path.Count == 1) { this._path.Dequeue(); } else { return(this.ActionToWarp()); } } if (isAtLocationStart) { this._ordered[this._current].SetVisited(true); } return(this._ordered[this._current].GetActions(targets)); }
/// <summary> /// Instantiates an ObjectTarget, used to specify the query method and selection of objects and the corresponding action to be performed. /// </summary> /// /// <param name="name">Unique name of the Target type</param> /// <param name="validator">Delegate method used to verify items fit this target's selection</param> /// <param name="action">Delegate method called when target is found and navigated to by the Bot</param> /// <param name="callOrder">Order by which the bot finds and focuses on targets. Within call order types, order by which the targets are passed into the Bot is upheld.</param> /// <param name="query">Method by which targets should be found.</param> /// <param name="selectors"></param> public TargetObject( string name, Validator <StardewValley.Object> validator, Condition <StardewValley.Object> condition, Action <StardewValley.Object> action, CallOrder callOrder = CallOrder.AtLocationStart, QueryBehavior query = QueryBehavior.DoForAll, IList <PostQuerySelector> selectors = null, int actionableRange = 1, int doForClosestLimit = 1, int withinRangeLimit = 1 ) : base( name, validator, condition, action, callOrder, query, selectors, actionableRange, doForClosestLimit, withinRangeLimit ) { }
/// <summary> /// Instantiates a Target. /// </summary> /// <remarks> /// Used to specify the query method and selection of targets and the corresponding action to be performed. /// </remarks> /// /// <param name="name">Unique name of the Target type</param> /// <param name="validator">Delegate method used to verify items fit this target's selection</param> /// <param name="condition">Delegate method used to confirm whether target should be found</param> /// <param name="action">Delegate method called when target is found and navigated to by the Bot</param> /// <param name="callOrder">Order by which the bot finds and focuses on targets. Within call order types, order by which the targets are passed into the Bot is upheld</param> /// <param name="query">Method by which targets should be found</param> /// <param name="selectors">Post query selectors. Used to select tiles spacially related to the target</param> /// <param name="actionableRange">Range by which target should perform action</param> /// <param name="doForClosestLimit">Only applies to <see cref="QueryBehavior.DoForClosest">QueryBehavior.DoForClosest</see>. Used to extend functionality to: Do for closest {{doForClosestLimit}}</param> /// <param name="withinRangeLimit">Only applies to <see cref="QueryBehavior.WithinRange">QueryBehavior.WithinRange</see>. Clarifies what range to search for targets</param> public Target( string name, Validator <T> validator, Condition <T> condition, Action <T> action, CallOrder callOrder = CallOrder.AtLocationStart, QueryBehavior query = QueryBehavior.DoForAll, IList <PostQuerySelector> selectors = null, int actionableRange = 1, int doForClosestLimit = 1, int withinRangeLimit = 1 ) { this._index = numTargets; numTargets = numTargets + 1; this._name = name; this._validator = validator; this._condition = condition; this._action = action; this._callOrder = callOrder; this._query = query; this._selectors = selectors; this._actionableRange = actionableRange; this._doForClosestLimit = doForClosestLimit; this._withinRangeLimit = withinRangeLimit; if (this._selectors == null) { this._selectors = new List <PostQuerySelector>(); this._selectors.Add(PostQuerySelector.TileOf); } }
private void InstantiateActionQueues() { this._lastCallOrderType = CallOrder.AfterEach; this._beforeEachQueue = new Queue <IAction>(); this._atLocationStartQueue = new Queue <IAction>(); this._afterEachQueue = new Queue <IAction>(); }
public void AddCallTick(object instance) { if (!CallTicks.ContainsKey(instance)) { CallTicks.Add(instance, 0); } CallTicks[instance]++; CallOrder.Add(instance.GetType()); }
public void TestProbeResolver_ResolveChild_ResolvesChildInStoreBeforeResolvingChildInWaiter() { //arrange CreateTestProbeResolver(); //act ResolveActor(typeof(BlackHoleActor)); //assert CallOrder.Should().ContainInOrder(nameof(IResolvedTestProbeStore.ResolveProbe), nameof(IChildWaiter.ResolvedChild)); }
public void SutCreator_Create_CreatesChildBeforeWaitingForChildrenUsingTheChildWaiter() { //arrange SutCreator sut = CreateSutCreator(); //act sut.Create <DummyActor>(ChildWaiter, this, Props, ExpectedChildCount, Supervisor); //assert CallOrder.Should().ContainInOrder("callback", nameof(IChildWaiter.Wait)); }
public void SutCreator_Create_CreatesChildAfterStartingChildWaiter() { //arrange SutCreator sut = CreateSutCreator(); //act sut.Create <DummyActor>(ChildWaiter, this, Props, ExpectedChildCount, Supervisor); //assert CallOrder.Should().ContainInOrder(nameof(IChildWaiter.Start), "callback"); }
public void ChildTeller_TellMessageWithNoSender_WaitsForChildrenAfterTellingRecipient() { //arrange ChildTeller sut = CreateChildTeller(); //act sut.TellMessage(ChildWaiter, this, Recipient, Message, ExpectedChildrenCount); //assert CallOrder.Should().ContainInOrder(nameof(IActorRef.Tell), nameof(IChildWaiter.Wait)); }
public void ChildTeller_TellMessage_StartsWaitingForChildrenBeforeTellingRecipient() { //arrange ChildTeller sut = CreateChildTeller(); //act sut.TellMessage(ChildWaiter, this, Recipient, Message, ExpectedChildrenCount, Sender); //assert CallOrder.Should().ContainInOrder(nameof(IChildWaiter.Start), nameof(IActorRef.Tell) + "Sender"); }
public void TellWaiter_TellMessageWithNoSender_WaitsForEventAfterTellingRecipient() { //arrange TellWaiter sut = CreateTellWaiter(); //act sut.TellMessage(Waiter, this, Recipient, Message, ExpectedEventCount); //assert CallOrder.Should().ContainInOrder( nameof(IActorRef.Tell), nameof(IWaiter.Wait)); }
public IAction GetNextAction() { // If all actions are complete, retrieve new if (this._beforeEachQueue.Count == 0 && this._afterEachQueue.Count == 0 && this._atLocationStartQueue.Count == 0) { this.RetrieveAtLocationStartAction(); } // Retrieve new BeforeEach and AfterEach if necessary if (this._lastCallOrderType == CallOrder.AtLocationStart) { this._lastCallOrderType = CallOrder.AfterEach; this.RetrieveAfterEachActions(); } if (this._lastCallOrderType == CallOrder.AfterEach && this._afterEachQueue.Count == 0) { this._lastCallOrderType = CallOrder.BeforeEach; this.RetrieveBeforeEachActions(); } // If BeforeEach or AfterEach in queue, return dequeue. if (this._afterEachQueue.Count > 0) { LogProxy.Log("Brain.GetNextAction: Dequeued Action of type CallOrder.AfterEach.", true); this._lastCallOrderType = CallOrder.AfterEach; return(this._afterEachQueue.Dequeue()); } else if (this._beforeEachQueue.Count > 0) { LogProxy.Log("Brain.GetNextAction: Dequeued Action of type CallOrder.BeforeEach.", true); this._lastCallOrderType = CallOrder.BeforeEach; return(this._beforeEachQueue.Dequeue()); } // If items are in the AtLocationStart queue if (this._atLocationStartQueue.Count > 0) { LogProxy.Log("Brain.GetNextAction: Dequeued Action of type CallOrder.AtLocationStart.", true); this._lastCallOrderType = CallOrder.AtLocationStart; return(this._atLocationStartQueue.Dequeue()); } // Bot is finished return(null); }
public void ConcreteResolver_ResolveChildInSettings_ResolvesChildInWaiterAfterCallingFactory() { //arrange CreateConcreteResolver(ImmutableDictionary <Type, Func <ActorBase> > .Empty .Add(typeof(BlackHoleActor), () => { CallOrder.Add("Resolver"); return(CreatedActor.UnderlyingActor); })); //act ResolveActor(typeof(BlackHoleActor)); //assert CallOrder.Should().ContainInOrder("Resolver", nameof(IChildWaiter.ResolvedChild)); }
public void TestProbeDependencyResolverAdder_Add_AddedFactoryStoresChildInStoreBeforeResolvingInWaiterWhenCalledWithoutHandlers() { //arrange TestProbeDependencyResolverAdder sut = CreateTestProbeDependencyResolverAdder(); //act sut.Add( DependencyResolverAdder, TestProbeActorCreator, TestProbeCreator, ResolvedTestProbeStore, ChildWaiter, this, Handlers); //assert ActorFactory(ActorWithoutHandlersType); CallOrder.Should().Equal( nameof(IResolvedTestProbeStore.ResolveProbe), nameof(IChildWaiter.ResolvedChild)); }
internal void AddDrawCall(GLDrawCall drawCall, CallOrder callOrder = CallOrder.Default) { _backBuffer.Enqueue(new BatchedDrawCall((int)callOrder, drawCall)); }