ye
This commit is contained in:
parent
25b69af90e
commit
7d19bf1fbd
|
@ -41,7 +41,7 @@ internal class Messages : IDisposable {
|
|||
}
|
||||
|
||||
PluginLog.Log($"spawning vfx for {message.Id}");
|
||||
if (this.Plugin.Vfx.SpawnStatic(VfxPath, message.Position) == null) {
|
||||
if (this.Plugin.Vfx.SpawnStatic(message.Id, VfxPath, message.Position) == null) {
|
||||
PluginLog.Log("trying again");
|
||||
this.SpawnQueue.Enqueue(message);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class Plugin : IDalamudPlugin {
|
|||
});
|
||||
}
|
||||
|
||||
this.Vfx = new Vfx(this);
|
||||
this.Vfx = new Vfx();
|
||||
this.Ui = new PluginUi(this);
|
||||
this.Messages = new Messages(this);
|
||||
this.Commands = new Commands(this);
|
||||
|
|
|
@ -24,11 +24,16 @@ internal class MessageList : ITab {
|
|||
|
||||
foreach (var message in this.Messages) {
|
||||
ImGui.TextUnformatted(message.Text);
|
||||
ImGui.TreePush();
|
||||
ImGui.TextUnformatted($"Likes: {message.PositiveVotes}");
|
||||
ImGui.TextUnformatted($"Dislikes: {message.NegativeVotes}");
|
||||
if (ImGui.Button($"Delete##{message.Id}")) {
|
||||
this.Delete(message.Id);
|
||||
}
|
||||
|
||||
ImGui.TreePop();
|
||||
|
||||
ImGui.Separator();
|
||||
}
|
||||
|
||||
this.MessagesMutex.Release();
|
||||
|
@ -60,14 +65,8 @@ internal class MessageList : ITab {
|
|||
|
||||
if (resp.IsSuccessStatusCode) {
|
||||
this.Refresh();
|
||||
this.Plugin.Messages.SpawnVfx();
|
||||
this.Plugin.Vfx.RemoveStatic(id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
internal void Add(MessageWithTerritory message) {
|
||||
this.Messages.Clear();
|
||||
this.Messages.Add(message);
|
||||
this.MessagesMutex.Release();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ namespace OrangeGuidanceTomestone;
|
|||
internal unsafe class Vfx : IDisposable {
|
||||
private static readonly byte[] Pool = Encoding.UTF8.GetBytes("Client.System.Scheduler.Instance.VfxObject");
|
||||
|
||||
private Plugin Plugin { get; }
|
||||
|
||||
[Signature("E8 ?? ?? ?? ?? F3 0F 10 35 ?? ?? ?? ?? 48 89 43 08")]
|
||||
private delegate* unmanaged<byte*, byte*, VfxStruct*> _staticVfxCreate;
|
||||
|
||||
|
@ -19,10 +17,9 @@ internal unsafe class Vfx : IDisposable {
|
|||
[Signature("40 53 48 83 EC 20 48 8B D9 48 8B 89 ?? ?? ?? ?? 48 85 C9 74 28 33 D2 E8 ?? ?? ?? ?? 48 8B 8B ?? ?? ?? ?? 48 85 C9")]
|
||||
private delegate* unmanaged<VfxStruct*, void> _staticVfxRemove;
|
||||
|
||||
private List<IntPtr> Spawned { get; } = new();
|
||||
private Dictionary<Guid, IntPtr> Spawned { get; } = new();
|
||||
|
||||
internal Vfx(Plugin plugin) {
|
||||
this.Plugin = plugin;
|
||||
internal Vfx() {
|
||||
SignatureHelper.Initialise(this);
|
||||
}
|
||||
|
||||
|
@ -31,14 +28,14 @@ internal unsafe class Vfx : IDisposable {
|
|||
}
|
||||
|
||||
internal void RemoveAll() {
|
||||
foreach (var spawned in this.Spawned) {
|
||||
foreach (var spawned in this.Spawned.Values) {
|
||||
this.RemoveStatic((VfxStruct*) spawned);
|
||||
}
|
||||
|
||||
this.Spawned.Clear();
|
||||
}
|
||||
|
||||
internal VfxStruct* SpawnStatic(string path, Vector3 pos) {
|
||||
internal VfxStruct* SpawnStatic(Guid id, string path, Vector3 pos) {
|
||||
VfxStruct* vfx;
|
||||
fixed (byte* p = Encoding.UTF8.GetBytes(path)) {
|
||||
fixed (byte* pool = Pool) {
|
||||
|
@ -61,7 +58,7 @@ internal unsafe class Vfx : IDisposable {
|
|||
// update
|
||||
vfx->Flags |= 2;
|
||||
|
||||
this.Spawned.Add((IntPtr) vfx);
|
||||
this.Spawned[id] = (IntPtr) vfx;
|
||||
|
||||
return vfx;
|
||||
}
|
||||
|
@ -70,6 +67,12 @@ internal unsafe class Vfx : IDisposable {
|
|||
this._staticVfxRemove(vfx);
|
||||
}
|
||||
|
||||
internal void RemoveStatic(Guid id) {
|
||||
if (this.Spawned.TryGetValue(id, out var vfx)) {
|
||||
this.RemoveStatic((VfxStruct*) vfx);
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
internal struct VfxStruct {
|
||||
[FieldOffset(0x38)]
|
||||
|
|
Loading…
Reference in New Issue
Block a user