punish v6.8.18.0
This commit is contained in:
commit
e786325cda
322 changed files with 554232 additions and 0 deletions
|
@ -0,0 +1,124 @@
|
|||
using System;
|
||||
using Dalamud.Game.ClientState.Conditions;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
using FFXIVClientStructs.FFXIV.Client.UI.Misc;
|
||||
using FFXIVClientStructs.Interop;
|
||||
using Questionable.Model;
|
||||
using Questionable.Model.Questing;
|
||||
|
||||
namespace Questionable.Controller.Steps.Interactions;
|
||||
|
||||
internal static class EquipRecommended
|
||||
{
|
||||
internal sealed class Factory : SimpleTaskFactory
|
||||
{
|
||||
public override ITask? CreateTask(Quest quest, QuestSequence sequence, QuestStep step)
|
||||
{
|
||||
if (step.InteractionType != EInteractionType.EquipRecommended)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new EquipTask();
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class BeforeDutyOrInstance : SimpleTaskFactory
|
||||
{
|
||||
public override ITask? CreateTask(Quest quest, QuestSequence sequence, QuestStep step)
|
||||
{
|
||||
if (step.InteractionType != EInteractionType.Duty && step.InteractionType != EInteractionType.SinglePlayerDuty && step.InteractionType != EInteractionType.Combat)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new EquipTask();
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class EquipTask : ITask
|
||||
{
|
||||
public override string ToString()
|
||||
{
|
||||
return "EquipRecommended";
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class DoEquipRecommended(IClientState clientState, IChatGui chatGui, ICondition condition) : TaskExecutor<EquipTask>()
|
||||
{
|
||||
private bool _checkedOrTriggeredEquipmentUpdate;
|
||||
|
||||
private DateTime _continueAt = DateTime.MinValue;
|
||||
|
||||
protected unsafe override bool Start()
|
||||
{
|
||||
if (condition[ConditionFlag.InCombat])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
RecommendEquipModule.Instance()->SetupForClassJob((byte)clientState.LocalPlayer.ClassJob.RowId);
|
||||
return true;
|
||||
}
|
||||
|
||||
public unsafe override ETaskResult Update()
|
||||
{
|
||||
RecommendEquipModule* ptr = RecommendEquipModule.Instance();
|
||||
if (ptr->IsUpdating)
|
||||
{
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
if (!_checkedOrTriggeredEquipmentUpdate)
|
||||
{
|
||||
if (!IsAllRecommendeGearEquipped())
|
||||
{
|
||||
chatGui.Print("Equipping recommended gear.", "Questionable", 576);
|
||||
ptr->EquipRecommendedGear();
|
||||
_continueAt = DateTime.Now.AddSeconds(1.0);
|
||||
}
|
||||
_checkedOrTriggeredEquipmentUpdate = true;
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
if (!(DateTime.Now >= _continueAt))
|
||||
{
|
||||
return ETaskResult.StillRunning;
|
||||
}
|
||||
return ETaskResult.TaskComplete;
|
||||
}
|
||||
|
||||
private unsafe bool IsAllRecommendeGearEquipped()
|
||||
{
|
||||
RecommendEquipModule* intPtr = RecommendEquipModule.Instance();
|
||||
InventoryContainer* inventoryContainer = InventoryManager.Instance()->GetInventoryContainer(InventoryType.EquippedItems);
|
||||
bool result = true;
|
||||
Span<Pointer<InventoryItem>> recommendedItems = intPtr->RecommendedItems;
|
||||
for (int i = 0; i < recommendedItems.Length; i++)
|
||||
{
|
||||
Pointer<InventoryItem> pointer = recommendedItems[i];
|
||||
InventoryItem* value = pointer.Value;
|
||||
if (value == null || value->ItemId == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bool flag = false;
|
||||
for (int j = 0; j < inventoryContainer->Size; j++)
|
||||
{
|
||||
InventoryItem inventoryItem = inventoryContainer->Items[j];
|
||||
if (inventoryItem.ItemId != 0 && inventoryItem.ItemId == value->ItemId)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public override bool ShouldInterruptOnDamage()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue