OrangeGuidanceTomestone/client/Message.cs

84 lines
2.4 KiB
C#
Raw Normal View History

2022-09-04 02:23:35 +00:00
using System.Numerics;
2022-09-03 23:45:16 +00:00
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace OrangeGuidanceTomestone;
[Serializable]
[JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
internal class Message {
public Guid Id { get; init; }
public float X { get; init; }
public float Y { get; init; }
public float Z { get; init; }
2022-09-04 21:02:13 +00:00
public float Yaw { get; init; }
2022-09-03 23:45:16 +00:00
[JsonProperty("message")]
public string Text { get; init; }
2022-09-04 02:23:35 +00:00
2022-09-04 07:19:48 +00:00
public int PositiveVotes { get; set; }
public int NegativeVotes { get; set; }
2022-09-04 07:12:51 +00:00
public int UserVote { get; set; }
2022-09-04 02:23:35 +00:00
2022-09-06 04:24:32 +00:00
public int Glyph { get; set; }
2022-09-04 02:23:35 +00:00
internal Vector3 Position => new(this.X, this.Y, this.Z);
2022-09-03 23:45:16 +00:00
}
2022-09-04 05:03:59 +00:00
[Serializable]
[JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
internal class MessageWithTerritory {
public Guid Id { get; init; }
public uint Territory { get; init; }
2023-02-20 02:41:17 +00:00
public uint? Ward { get; init; }
2023-02-20 03:13:29 +00:00
public uint? Plot { get; init; }
2023-02-20 04:52:04 +00:00
public uint? World { get; init; }
2022-09-04 05:03:59 +00:00
public float X { get; init; }
public float Y { get; init; }
public float Z { get; init; }
2022-09-04 21:02:13 +00:00
public float Yaw { get; init; }
2022-09-04 05:03:59 +00:00
[JsonProperty("message")]
public string Text { get; init; }
public int PositiveVotes { get; init; }
public int NegativeVotes { get; init; }
2022-09-04 07:12:51 +00:00
public int UserVote { get; set; }
2022-09-04 05:03:59 +00:00
2022-09-06 04:24:32 +00:00
public int Glyph { get; set; }
2022-09-09 10:19:14 +00:00
public bool IsHidden { get; set; }
2022-09-06 04:24:32 +00:00
2022-09-04 05:03:59 +00:00
internal Vector3 Position => new(this.X, this.Y, this.Z);
internal static MessageWithTerritory From(Message message, uint territory) {
return new MessageWithTerritory {
Id = message.Id,
Territory = territory,
X = message.X,
Y = message.Y,
Z = message.Z,
2022-09-04 21:10:03 +00:00
Yaw = message.Yaw,
2022-09-04 05:03:59 +00:00
Text = message.Text,
PositiveVotes = message.PositiveVotes,
NegativeVotes = message.NegativeVotes,
2022-09-04 07:12:51 +00:00
UserVote = message.UserVote,
2022-09-06 04:24:32 +00:00
Glyph = message.Glyph,
2022-09-09 10:19:14 +00:00
IsHidden = false,
2022-09-04 05:03:59 +00:00
};
}
}
2022-09-05 08:21:45 +00:00
[Serializable]
[JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
internal class ErrorMessage {
public string Code { get; set; }
public string Message { get; set; }
}
[Serializable]
[JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
internal class MyMessages {
public uint Extra { get; set; }
public MessageWithTerritory[] Messages { get; set; }
}