public override async Task<bool> Gather(ExGatherTag tag)
		{
			tag.StatusText = "Gathering collectable items";

			var rarity = CurrentRarity;
			var selectYesNoItem = new SelectYesNoItem();
			while (tag.Node.CanGather && GatheringManager.SwingsRemaining > tag.SwingsRemaining && rarity > 0 && Behaviors.ShouldContinue)
			{

				while (!selectYesNoItem.IsValid && tag.Node.CanGather && GatheringManager.SwingsRemaining > tag.SwingsRemaining && rarity > 0
						&& Behaviors.ShouldContinue)
				{
					if (!MasterpieceWindow.IsValid)
					{
						await MasterpieceWindow.Refresh(3000);
					}

					if (MasterpieceWindow.IsValid)
					{
						MasterpieceWindow.Collect();
					}

					await selectYesNoItem.Refresh(500);
				}

				await Coroutine.Yield();
				var swingsRemaining = GatheringManager.SwingsRemaining - 1;

				while (selectYesNoItem.IsValid && rarity > 0 && Behaviors.ShouldContinue)
				{
					tag.Logger.Info(
						"Collected item: {0}, value: {1} at {2} ET",
						tag.GatherItem.ItemData.EnglishName,
						selectYesNoItem.CollectabilityValue,
						WorldManager.EorzaTime);

					selectYesNoItem.Yes();
					await selectYesNoItem.Refresh(2000, false);
				}

				var ticks = 0;
				while (swingsRemaining != GatheringManager.SwingsRemaining && ticks++ < 60 && Behaviors.ShouldContinue)
				{
					await Coroutine.Yield();
				}
			}

			tag.StatusText = "Gathering collectable items complete";

			return true;
		}
Example #2
0
		private async Task<bool> HandleCollectable()
		{
			if (Collectables == null)
			{
				//we are not collecting
				return false;
			}

			if (FishingManager.State != FishingState.Waitin)
			{
				// we are not waitin yet!
				return false;
			}

			var selectYesNoItem = new SelectYesNoItem();
			if (!selectYesNoItem.IsValid || !await selectYesNoItem.Refresh(5000))
			{
				// window didn't open, continue.
				return false;
			}

			var required = CollectabilityValue;
			var itemName = string.Empty;
			if (!string.IsNullOrWhiteSpace(Collectables.First().Name))
			{
				var item = selectYesNoItem.Item;
				if (item == null
					|| !Collectables.Any(c => string.Equals(c.Name, item.EnglishName, StringComparison.InvariantCultureIgnoreCase)))
				{
					var ticks = 0;
					while ((item == null
							|| !Collectables.Any(c => string.Equals(c.Name, item.EnglishName, StringComparison.InvariantCultureIgnoreCase)))
							&& ticks++ < 60 && Behaviors.ShouldContinue)
					{
						item = selectYesNoItem.Item;
						await Coroutine.Yield();
					}

					// handle timeout
					if (ticks > 60)
					{
						required = (uint)Collectables.Select(c => c.Value).Max();
					}
				}

				if (item != null)
				{
					// handle normal
					itemName = item.EnglishName;
					var collectable = Collectables.FirstOrDefault(c => string.Equals(c.Name, item.EnglishName));

					if (collectable != null)
					{
						required = (uint)collectable.Value;
					}
				}
			}

			// handle

			var value = selectYesNoItem.CollectabilityValue;

			if (value >= required)
			{
				Logger.Info("Collecting {0} -> Value: {1}, Required: {2}", itemName, value, required);
				selectYesNoItem.Yes();
			}
			else
			{
				Logger.Info("Declining {0} -> Value: {1}, Required: {2}", itemName, value, required);
				selectYesNoItem.No();
			}

			await Coroutine.Wait(3000, () => !selectYesNoItem.IsValid && FishingManager.State != FishingState.Waitin);

			return true;
		}