Skip to content

Commit

Permalink
Merge pull request #179 from oorzkws/idleteleportfix
Browse files Browse the repository at this point in the history
Fix idle teleporting from inside estate
  • Loading branch information
NostraThomas99 authored Aug 19, 2024
2 parents 7815248 + 8199718 commit 335eb7a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
11 changes: 3 additions & 8 deletions GatherBuddy/AutoGather/AutoGather.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using GatherBuddy.Enums;
using GatherBuddy.Interfaces;
using Lumina.Excel.GeneratedSheets;
using HousingManager = GatherBuddy.SeFunctions.HousingManager;

namespace GatherBuddy.AutoGather
{
Expand All @@ -32,11 +33,6 @@ public AutoGather(GatherBuddy plugin)
_movementController = new OverrideMovement();
_soundHelper = new SoundHelper();
GatherBuddy.UptimeManager.UptimeChange += UptimeChange;
var territories = Svc.Data.GetExcelSheet<TerritoryType>().Where(t => t.Unknown13);
foreach (var territory in territories)
{
_homeTerritories.Add(territory.RowId);
}
}

private void UptimeChange(IGatherable obj)
Expand All @@ -49,8 +45,7 @@ private void UptimeChange(IGatherable obj)

private readonly GatherBuddy _plugin;
private readonly SoundHelper _soundHelper;

private readonly List<uint> _homeTerritories = new List<uint>();

public TaskManager TaskManager { get; }

private bool _enabled { get; set; } = false;
Expand Down Expand Up @@ -92,7 +87,7 @@ public void GoHome()
if (!GatherBuddy.Config.AutoGatherConfig.GoHomeWhenIdle || !CanAct)
return;

if (_homeTerritories.Contains(Svc.ClientState.TerritoryType) || Lifestream_IPCSubscriber.IsBusy())
if (HousingManager.IsInHousing() || Lifestream_IPCSubscriber.IsBusy())
{
if (SpiritBondMax > 0 && GatherBuddy.Config.AutoGatherConfig.DoMaterialize)
{
Expand Down
19 changes: 19 additions & 0 deletions GatherBuddy/SeFunctions/HousingManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using SeHousingManager = FFXIVClientStructs.FFXIV.Client.Game.HousingManager;

namespace GatherBuddy.SeFunctions;

public static unsafe class HousingManager
{
public static bool IsInHousing()
{
var housingManager = SeHousingManager.Instance();
if (housingManager == null)
return false;

ref var housingTerritory = ref housingManager->CurrentTerritory;
if (housingTerritory == null)
return false;

return true;
}
}

0 comments on commit 335eb7a

Please sign in to comment.