Compare commits

...

7 Commits

Author SHA1 Message Date
Anna 7b62a6df96
chore: bump version to 1.7.0 2023-02-19 22:59:21 -05:00
Anna a1364ceb6a
fix: account for lobby 2023-02-19 22:59:21 -05:00
Anna 6b46e39eda
fix: handle delay better 2023-02-19 22:59:21 -05:00
Anna 9ae5a68876
fix: add delay to spawning 2023-02-19 22:59:21 -05:00
Anna b0c9661947
fix(server): insert plot 2023-02-19 22:59:20 -05:00
Anna 961968b7f5
fix: handle apartments 2023-02-19 22:59:20 -05:00
Anna f776188086
fix: handle plots better 2023-02-19 22:59:20 -05:00
9 changed files with 79 additions and 18 deletions

0
client/FodyWeavers.xml Executable file → Normal file
View File

20
client/HousingLocationExt.cs Executable file
View File

@ -0,0 +1,20 @@
using XivCommon.Functions.Housing;
namespace OrangeGuidanceTomestone;
internal static class HousingLocationExt {
internal const ushort Apt = 10_000;
internal const ushort Wng = 5_000;
internal static ushort? CombinedPlot(this HousingLocation housing) {
return housing switch {
// lobby
{ Apartment: null, ApartmentWing: { } wang } => (ushort) (Apt + (wang - 1) * Wng),
// apartment
{ Apartment: { } apt, ApartmentWing: { } wing } => (ushort) (Apt + (wing - 1) * Wng + apt),
// normal plot interior
{ Plot: { } plotNum } => plotNum,
_ => null,
};
}
}

View File

@ -31,6 +31,7 @@ internal class MessageWithTerritory {
public Guid Id { get; init; }
public uint Territory { get; init; }
public uint? Ward { get; init; }
public uint? Plot { get; init; }
public float X { get; init; }
public float Y { get; init; }
public float Z { get; init; }

View File

@ -1,3 +1,4 @@
using System.Diagnostics;
using System.Numerics;
using Dalamud.Data;
using Dalamud.Game;
@ -83,23 +84,54 @@ internal class Messages : IDisposable {
this.SpawnVfx();
}
this.Plugin.Framework.Update += this.DetermineIfSpawn;
this.Plugin.Framework.Update += this.RemoveConditionally;
this.Plugin.Framework.Update += this.HandleSpawnQueue;
this.Plugin.ClientState.TerritoryChanged += this.TerritoryChanged;
this.Plugin.ClientState.Login += this.SpawnVfx;
this.Plugin.ClientState.Logout += this.RemoveVfx;
this.Plugin.ClientState.TerritoryChanged += this.SpawnVfx;
}
public void Dispose() {
this.Plugin.ClientState.TerritoryChanged -= this.SpawnVfx;
this.Plugin.ClientState.Logout -= this.RemoveVfx;
this.Plugin.ClientState.Login -= this.SpawnVfx;
this.Plugin.ClientState.TerritoryChanged -= this.TerritoryChanged;
this.Plugin.Framework.Update -= this.HandleSpawnQueue;
this.Plugin.Framework.Update -= this.RemoveConditionally;
this.Plugin.Framework.Update -= this.DetermineIfSpawn;
this.RemoveVfx();
}
private readonly Stopwatch _timer = new();
private void TerritoryChanged(object? sender, ushort e) {
this._territoryChanged = true;
this.RemoveVfx();
}
private ushort _lastTerritory;
private bool _territoryChanged;
private void DetermineIfSpawn(Framework framework) {
var current = this.Plugin.ClientState.TerritoryType;
var diffTerritory = current != this._lastTerritory;
var playerPresent = this.Plugin.ClientState.LocalPlayer != null;
if ((this._territoryChanged || diffTerritory) && playerPresent) {
this._territoryChanged = false;
this._timer.Start();
}
if (this._timer.Elapsed >= TimeSpan.FromSeconds(1.5)) {
this._timer.Reset();
this.SpawnVfx();
}
this._lastTerritory = current;
}
private void RemoveConditionally(Framework framework) {
var nowCutscene = this.CutsceneActive;
var cutsceneChanged = this._inCutscene != nowCutscene;
@ -143,10 +175,6 @@ internal class Messages : IDisposable {
this.SpawnVfx();
}
private void SpawnVfx(object? sender, ushort e) {
this.SpawnVfx();
}
internal void SpawnVfx() {
var territory = this.Plugin.ClientState.TerritoryType;
if (territory == 0 || this.Plugin.Config.BannedTerritories.Contains(territory)) {
@ -155,14 +183,7 @@ internal class Messages : IDisposable {
var housing = this.Plugin.Common.Functions.Housing.Location;
var ward = housing?.Ward;
ushort? plot = null;
if (housing is { Apartment: { } apt, ApartmentWing: { } wing }) {
plot = (ushort) (10_000
+ (wing - 1) * 5_000
+ apt);
} else if (housing?.Plot is { } plotNum) {
plot = plotNum;
}
var plot = housing?.CombinedPlot();
if (this.Plugin.Config.DisableTrials && this.Trials.Contains(territory)) {
return;

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.6.5</Version>
<Version>1.7.0</Version>
<TargetFramework>net7.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

0
client/OrangeGuidanceTomestone.yaml Executable file → Normal file
View File

View File

@ -76,7 +76,25 @@ internal class MessageList : ITab {
var loc = $"Location: {territoryName}";
if (message.Ward != null) {
loc += $" (Ward {message.Ward.Value})";
loc += $" (Ward {message.Ward.Value}";
if (message.Plot != null) {
if (message.Plot.Value >= HousingLocationExt.Apt) {
var apartment = message.Plot.Value - 10_000;
var wing = apartment < HousingLocationExt.Wng ? 1 : 2;
var apt = wing == 2 ? apartment - HousingLocationExt.Wng : apartment;
if (apt == 0) {
loc += $", Wing {wing} Lobby";
} else {
loc += $", Apt. {apt}, Wing {wing}";
}
} else {
loc += $", Plot {message.Plot.Value}";
}
}
loc += ")";
}
ImGui.TextUnformatted(message.Text);

View File

@ -232,7 +232,7 @@ internal class Write : ITab {
var req = new MessageRequest {
Territory = this.Plugin.ClientState.TerritoryType,
Ward = this.Plugin.Common.Functions.Housing.Location?.Ward,
Plot = this.Plugin.Common.Functions.Housing.Location?.Plot,
Plot = this.Plugin.Common.Functions.Housing.Location?.CombinedPlot(),
X = player.Position.X,
Y = player.Position.Y,
Z = player.Position.Z,

View File

@ -67,11 +67,12 @@ async fn logic(state: Arc<State>, id: i64, extra: i64, message: Message) -> Resu
sqlx::query!(
// language=sqlite
"insert into messages (id, user, territory, ward, x, y, z, yaw, message, glyph) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
"insert into messages (id, user, territory, ward, plot, x, y, z, yaw, message, glyph) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
message_id,
id,
territory,
message.ward,
message.plot,
message.x,
message.y,
message.z,