2021-08-23 03:33:57 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using Dalamud.Game.ClientState.Objects.SubKinds;
|
|
|
|
|
using Dalamud.Game.Text.SeStringHandling;
|
2023-09-28 06:56:38 +00:00
|
|
|
|
using Dalamud.Plugin.Services;
|
2021-09-11 17:22:41 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2021-08-23 03:33:57 +00:00
|
|
|
|
|
|
|
|
|
namespace PeepingTom.Ipc {
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class Targeter {
|
2021-09-11 17:22:41 +00:00
|
|
|
|
[JsonConverter(typeof(SeStringConverter))]
|
2021-08-23 03:33:57 +00:00
|
|
|
|
public SeString Name { get; }
|
|
|
|
|
public uint HomeWorldId { get; }
|
|
|
|
|
public uint ObjectId { get; }
|
|
|
|
|
public DateTime When { get; }
|
|
|
|
|
|
|
|
|
|
public Targeter(PlayerCharacter character) {
|
|
|
|
|
this.Name = character.Name;
|
|
|
|
|
this.HomeWorldId = character.HomeWorld.Id;
|
|
|
|
|
this.ObjectId = character.ObjectId;
|
|
|
|
|
this.When = DateTime.UtcNow;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-11 17:22:41 +00:00
|
|
|
|
[JsonConstructor]
|
|
|
|
|
public Targeter(SeString name, uint homeWorldId, uint objectId, DateTime when) {
|
|
|
|
|
this.Name = name;
|
|
|
|
|
this.HomeWorldId = homeWorldId;
|
|
|
|
|
this.ObjectId = objectId;
|
|
|
|
|
this.When = when;
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-28 06:56:38 +00:00
|
|
|
|
public PlayerCharacter? GetPlayerCharacter(IObjectTable objectTable) {
|
2021-08-23 03:33:57 +00:00
|
|
|
|
return objectTable.FirstOrDefault(actor => actor.ObjectId == this.ObjectId && actor is PlayerCharacter) as PlayerCharacter;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|