using FFXIVClientStructs.FFXIV.Client.Game; namespace OrangeGuidanceTomestone.Util; /// /// Information about a player's current location in a housing ward. /// public class HousingLocation { /// /// The housing ward that the player is in. /// public ushort? Ward; /// /// /// The yard that the player is in. /// /// /// This is the same as plot number but indicates that the player is in /// the exterior area (the yard) of that plot. /// /// public ushort? Yard; /// /// The plot that the player is in. /// public ushort? Plot; /// /// The apartment wing (1 or 2 for normal or subdivision) that the /// player is in. /// public ushort? ApartmentWing; /// /// The apartment that the player is in. /// public ushort? Apartment; internal static unsafe HousingLocation? Current() { var manager = HousingManager.Instance(); return manager == null ? null : new HousingLocation(manager); } private unsafe HousingLocation(HousingManager* manager) { var ward = manager->GetCurrentWard(); var currentPlot = manager->GetCurrentPlot(); if (currentPlot < -1) { // the struct is in apartment mode this.ApartmentWing = (ushort?) ((unchecked((byte) currentPlot) & ~0x80) + 1); this.Apartment = (ushort) manager->GetCurrentRoom(); if (this.Apartment == 0) { this.Apartment = null; } } else if (currentPlot > 0) { if (manager->GetCurrentHouseId() == -1) { // not inside a plot // yard is 0xFF when not in one this.Yard = (ushort?) (currentPlot + 1); } else { // inside a plot this.Plot = (ushort?) (currentPlot + 1); } } if (ward > -1) { this.Ward = (ushort) (ward + 1); } } }