Fix workshops not in Lavender Beds
This commit is contained in:
parent
2dbbf8a16c
commit
3c3d144158
@ -94,8 +94,7 @@ internal sealed class MainWindow : Window
|
|||||||
$"Hold CTRL to remove this as craft. You have to manually use the fabrication station to cancel or finish this craft before you can continue using the queue.");
|
$"Hold CTRL to remove this as craft. You have to manually use the fabrication station to cancel or finish this craft before you can continue using the queue.");
|
||||||
ImGui.EndDisabled();
|
ImGui.EndDisabled();
|
||||||
|
|
||||||
if (!IsDiscipleOfHand)
|
ShowErrorConditions();
|
||||||
ImGui.TextColored(ImGuiColors.DalamudRed, "You need to be a Disciple of the Hand to start crafting.");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -119,8 +118,7 @@ internal sealed class MainWindow : Window
|
|||||||
State = ButtonState.Start;
|
State = ButtonState.Start;
|
||||||
ImGui.EndDisabled();
|
ImGui.EndDisabled();
|
||||||
|
|
||||||
if (!IsDiscipleOfHand)
|
ShowErrorConditions();
|
||||||
ImGui.TextColored(ImGuiColors.DalamudRed, "You need to be a Disciple of the Hand to start crafting.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui.BeginPopup(nameof(CheckMaterial)))
|
if (ImGui.BeginPopup(nameof(CheckMaterial)))
|
||||||
@ -262,6 +260,18 @@ internal sealed class MainWindow : Window
|
|||||||
completedForCurrentCraft[itemId] = quantity;
|
completedForCurrentCraft[itemId] = quantity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ShowErrorConditions()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!_plugin.WorkshopTerritories.Contains(_clientState.TerritoryType))
|
||||||
|
ImGui.TextColored(ImGuiColors.DalamudRed, "You are not in the Company Workshop.");
|
||||||
|
else if (!NearFabricationStation)
|
||||||
|
ImGui.TextColored(ImGuiColors.DalamudRed, "You are not near a Farbrication Station.");
|
||||||
|
|
||||||
|
if (!IsDiscipleOfHand)
|
||||||
|
ImGui.TextColored(ImGuiColors.DalamudRed, "You need to be a Disciple of the Hand to start crafting.");
|
||||||
|
}
|
||||||
|
|
||||||
public enum ButtonState
|
public enum ButtonState
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using Dalamud.Game.ClientState.Objects.Enums;
|
using Dalamud.Game.ClientState.Objects.Enums;
|
||||||
using Dalamud.Game.ClientState.Objects.Types;
|
using Dalamud.Game.ClientState.Objects.Types;
|
||||||
using Dalamud.Memory;
|
using Dalamud.Memory;
|
||||||
@ -30,13 +29,13 @@ partial class WorkshopPlugin
|
|||||||
(FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)obj.Address, false);
|
(FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)obj.Address, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float GetDistanceToEventObject(int npcId, out GameObject? o)
|
private float GetDistanceToEventObject(IReadOnlyList<uint> npcIds, out GameObject? o)
|
||||||
{
|
{
|
||||||
foreach (var obj in _objectTable)
|
foreach (var obj in _objectTable)
|
||||||
{
|
{
|
||||||
if (obj.ObjectKind == ObjectKind.EventObj)
|
if (obj.ObjectKind == ObjectKind.EventObj)
|
||||||
{
|
{
|
||||||
if (GetNpcId(obj) == npcId)
|
if (npcIds.Contains(GetNpcId(obj)))
|
||||||
{
|
{
|
||||||
o = obj;
|
o = obj;
|
||||||
return Vector3.Distance(_clientState.LocalPlayer!.Position, obj.Position);
|
return Vector3.Distance(_clientState.LocalPlayer!.Position, obj.Position);
|
||||||
@ -48,9 +47,9 @@ partial class WorkshopPlugin
|
|||||||
return float.MaxValue;
|
return float.MaxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetNpcId(GameObject obj)
|
private unsafe uint GetNpcId(GameObject obj)
|
||||||
{
|
{
|
||||||
return Marshal.ReadInt32(obj.Address + 128);
|
return ((FFXIVClientStructs.FFXIV.Client.Game.Object.GameObject*)obj.Address)->GetNpcID();
|
||||||
}
|
}
|
||||||
|
|
||||||
private unsafe bool TryGetAddonByName<T>(string addonName, out T* addonPtr)
|
private unsafe bool TryGetAddonByName<T>(string addonName, out T* addonPtr)
|
||||||
|
@ -16,8 +16,8 @@ namespace Workshoppa;
|
|||||||
[SuppressMessage("ReSharper", "UnusedType.Global")]
|
[SuppressMessage("ReSharper", "UnusedType.Global")]
|
||||||
public sealed partial class WorkshopPlugin : IDalamudPlugin
|
public sealed partial class WorkshopPlugin : IDalamudPlugin
|
||||||
{
|
{
|
||||||
private const int FabricationStationId = 0x1E98F4;
|
private readonly IReadOnlyList<uint> FabricationStationIds = new uint[] { 2005236, 2005238, 2005240, 2007821, 2011588 }.AsReadOnly();
|
||||||
private readonly IReadOnlyList<ushort> _workshopTerritories = new ushort[] { 423, 424, 425, 653, 984 }.AsReadOnly();
|
internal readonly IReadOnlyList<ushort> WorkshopTerritories = new ushort[] { 423, 424, 425, 653, 984 }.AsReadOnly();
|
||||||
private readonly WindowSystem _windowSystem = new WindowSystem(nameof(WorkshopPlugin));
|
private readonly WindowSystem _windowSystem = new WindowSystem(nameof(WorkshopPlugin));
|
||||||
|
|
||||||
private readonly DalamudPluginInterface _pluginInterface;
|
private readonly DalamudPluginInterface _pluginInterface;
|
||||||
@ -84,9 +84,9 @@ public sealed partial class WorkshopPlugin : IDalamudPlugin
|
|||||||
private void FrameworkUpdate(IFramework framework)
|
private void FrameworkUpdate(IFramework framework)
|
||||||
{
|
{
|
||||||
if (!_clientState.IsLoggedIn ||
|
if (!_clientState.IsLoggedIn ||
|
||||||
!_workshopTerritories.Contains(_clientState.TerritoryType) ||
|
!WorkshopTerritories.Contains(_clientState.TerritoryType) ||
|
||||||
_condition[ConditionFlag.BoundByDuty] ||
|
_condition[ConditionFlag.BoundByDuty] ||
|
||||||
GetDistanceToEventObject(FabricationStationId, out var fabricationStation) >= 5f)
|
GetDistanceToEventObject(FabricationStationIds, out var fabricationStation) >= 5f)
|
||||||
{
|
{
|
||||||
_mainWindow.NearFabricationStation = false;
|
_mainWindow.NearFabricationStation = false;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net7.0-windows</TargetFramework>
|
<TargetFramework>net7.0-windows</TargetFramework>
|
||||||
<Version>2.0</Version>
|
<Version>2.1</Version>
|
||||||
<LangVersion>11.0</LangVersion>
|
<LangVersion>11.0</LangVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
|
Loading…
Reference in New Issue
Block a user