forked from aly/qstbak
muffin v7.5.12
This commit is contained in:
parent
3102923ce2
commit
911ed68baa
65 changed files with 2356 additions and 1539 deletions
|
|
@ -16,33 +16,85 @@ namespace Questionable.Controller.Steps.Shared;
|
|||
|
||||
internal static class RedeemRewardItems
|
||||
{
|
||||
internal sealed class Factory(QuestData questData, Configuration configuration) : ITaskFactory
|
||||
internal sealed class Factory(QuestData questData, Configuration configuration, ILogger<Factory> logger) : ITaskFactory
|
||||
{
|
||||
public unsafe IEnumerable<ITask> CreateAllTasks(Quest quest, QuestSequence sequence, QuestStep step)
|
||||
public IEnumerable<ITask> CreateAllTasks(Quest quest, QuestSequence sequence, QuestStep step)
|
||||
{
|
||||
if (step.InteractionType != EInteractionType.AcceptQuest)
|
||||
{
|
||||
return Array.Empty<ITask>();
|
||||
}
|
||||
List<ITask> list = new List<ITask>();
|
||||
InventoryManager* ptr = InventoryManager.Instance();
|
||||
if (ptr == null)
|
||||
return CreateTasks(questData, configuration, logger);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class CompletionFactory : ITaskFactory
|
||||
{
|
||||
public IEnumerable<ITask> CreateAllTasks(Quest quest, QuestSequence sequence, QuestStep step)
|
||||
{
|
||||
if (step.InteractionType != EInteractionType.CompleteQuest)
|
||||
{
|
||||
return list;
|
||||
return Array.Empty<ITask>();
|
||||
}
|
||||
bool hasFreeInventorySlot = InventoryHelper.HasFreeInventorySlot();
|
||||
foreach (ItemReward redeemableItem in questData.RedeemableItems)
|
||||
return new global::_003C_003Ez__ReadOnlySingleElementList<ITask>(new ScanAfterQuestCompletion(step.TurnInQuestId ?? quest.Id));
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed record ScanAfterQuestCompletion(ElementId ElementId) : ITask
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return $"ScanRewardsAfterQuestCompletion({ElementId})";
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class ScanAfterQuestCompletionExecutor(QuestFunctions questFunctions, QuestData questData, Configuration configuration, ILogger<ScanAfterQuestCompletionExecutor> logger) : TaskExecutor<ScanAfterQuestCompletion>(), IExtraTaskCreator, ITaskExecutor
|
||||
{
|
||||
private const long InventorySettleDelayMs = 1000L;
|
||||
|
||||
private long? _scanAt;
|
||||
|
||||
private List<ITask> _tasks = new List<ITask>();
|
||||
|
||||
protected override bool Start()
|
||||
{
|
||||
_scanAt = null;
|
||||
_tasks = new List<ITask>();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override ETaskResult Update()
|
||||
{
|
||||
if (!questFunctions.IsQuestComplete(base.Task.ElementId))
|
||||
{
|
||||
if (ptr->GetInventoryItemCount(redeemableItem.ItemId, isHq: false, checkEquipped: true, checkArmory: true, 0) != 0 && !redeemableItem.IsUnlocked() && PassesRedemptionFilters(redeemableItem.Type, redeemableItem.IsUntradable, configuration.General, hasFreeInventorySlot))
|
||||
{
|
||||
list.Add(new Task(redeemableItem));
|
||||
}
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
if (list.Count > 0)
|
||||
long tickCount = Environment.TickCount64;
|
||||
if (!_scanAt.HasValue)
|
||||
{
|
||||
list.Insert(0, new Mount.UnmountTask());
|
||||
_scanAt = tickCount + 1000;
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
return list;
|
||||
if (tickCount < _scanAt)
|
||||
{
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
_tasks = CreateTasks(questData, configuration, logger);
|
||||
if (_tasks.Count <= 0)
|
||||
{
|
||||
return ETaskResult.TaskComplete;
|
||||
}
|
||||
return ETaskResult.CreateNewTasks;
|
||||
}
|
||||
|
||||
public IEnumerable<ITask> CreateExtraTasks()
|
||||
{
|
||||
return _tasks;
|
||||
}
|
||||
|
||||
public override bool ShouldInterruptOnDamage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -182,6 +234,36 @@ internal static class RedeemRewardItems
|
|||
}
|
||||
}
|
||||
|
||||
private unsafe static List<ITask> CreateTasks(QuestData questData, Configuration configuration, ILogger logger)
|
||||
{
|
||||
List<ITask> list = new List<ITask>();
|
||||
InventoryManager* ptr = InventoryManager.Instance();
|
||||
if (ptr == null)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
bool flag = InventoryHelper.HasFreeInventorySlot();
|
||||
foreach (ItemReward redeemableItem in questData.RedeemableItems)
|
||||
{
|
||||
if (ptr->GetInventoryItemCount(redeemableItem.ItemId, isHq: false, checkEquipped: true, checkArmory: true, 0) != 0 && !redeemableItem.IsUnlocked())
|
||||
{
|
||||
if (!PassesRedemptionFilters(redeemableItem.Type, redeemableItem.IsUntradable, configuration.General, flag))
|
||||
{
|
||||
logger.LogDebug("Skipping quest reward {ItemName}: type={RewardType}, untradable={IsUntradable}, freeInventorySlot={HasFreeInventorySlot}", redeemableItem.Name, redeemableItem.Type, redeemableItem.IsUntradable, flag);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(new Task(redeemableItem));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (list.Count > 0)
|
||||
{
|
||||
list.Insert(0, new Mount.UnmountTask());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
internal static bool PassesRedemptionFilters(EItemRewardType type, bool isUntradable, Configuration.GeneralConfiguration general, bool hasFreeInventorySlot)
|
||||
{
|
||||
if (general.DisabledRewardTypes.Contains(type))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue