feat(client): add current world
This commit is contained in:
parent
bd334442b5
commit
805b8ac861
|
@ -0,0 +1,12 @@
|
|||
namespace PlayerMap;
|
||||
|
||||
internal static class ListExt {
|
||||
public static void Shuffle<T>(this IList<T> list) {
|
||||
var n = list.Count;
|
||||
while (n > 1) {
|
||||
n--;
|
||||
var k = Random.Shared.Next(n + 1);
|
||||
(list[k], list[n]) = (list[n], list[k]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -53,7 +53,14 @@ public class Plugin : IDalamudPlugin {
|
|||
})
|
||||
.ToList();
|
||||
|
||||
var update = new Update(territory, players);
|
||||
if (players.Count == 0 || this.ClientState.LocalPlayer is not { } player) {
|
||||
return;
|
||||
}
|
||||
|
||||
// shuffle so first player isn't always local player
|
||||
players.Shuffle();
|
||||
|
||||
var update = new Update(territory, player.CurrentWorld.Id, players);
|
||||
var json = JsonConvert.SerializeObject(update, new JsonSerializerSettings {
|
||||
ContractResolver = new DefaultContractResolver {
|
||||
NamingStrategy = new SnakeCaseNamingStrategy(),
|
||||
|
@ -73,8 +80,9 @@ public class Plugin : IDalamudPlugin {
|
|||
}
|
||||
|
||||
[Serializable]
|
||||
internal struct Update(uint territory, List<PlayerInfo> players) {
|
||||
internal struct Update(uint territory, uint world, List<PlayerInfo> players) {
|
||||
public readonly uint Territory = territory;
|
||||
public readonly uint World = world;
|
||||
public readonly List<PlayerInfo> Players = players;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue