-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameMessage.cs
237 lines (186 loc) · 5.72 KB
/
GameMessage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
using System.Text.Json.Serialization;
// ReSharper disable UnusedMember.Global
// ReSharper disable NotAccessedPositionalProperty.Global
// ReSharper disable ClassNeverInstantiated.Global
namespace Application;
[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum ActionTypes
{
[JsonPropertyName("TURRET_ROTATE")]
TurretRotate,
[JsonPropertyName("TURRET_LOOK_AT")]
TurretLookAt,
[JsonPropertyName("TURRET_CHARGE")]
TurretCharge,
[JsonPropertyName("TURRET_SHOOT")]
TurretShoot,
[JsonPropertyName("RADAR_SCAN")]
RadarScan,
[JsonPropertyName("CREW_MOVE")]
CrewMove,
[JsonPropertyName("SHIP_ROTATE")]
ShipRotate,
[JsonPropertyName("SHIP_LOOK_AT")]
ShipLookAt,
}
public enum DebrisType
{
[JsonPropertyName("LARGE")]
Large,
[JsonPropertyName("MEDIUM")]
Medium,
[JsonPropertyName("SMALL")]
Small
}
[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum TurretType
{
[JsonPropertyName("NORMAL")]
Normal,
[JsonPropertyName("FAST")]
Fast,
[JsonPropertyName("CANNON")]
Cannon,
[JsonPropertyName("SNIPER")]
Sniper,
[JsonPropertyName("EMP")]
EMP
}
public record Vector(double X, double Y);
public record Projectile(
string Id,
Vector Position,
Vector Velocity,
double Radius,
double Damage,
double BonusShieldDamage,
double BonusHullDamage,
string? TeamId
);
public record Debris(
string Id,
Vector Position,
Vector Velocity,
double Radius,
double Damage,
double BonusShieldDamage,
double BonusHullDamage,
DebrisType DebrisType,
string? TeamId
) : Projectile(Id, Position, Velocity, Radius, Damage, BonusShieldDamage, BonusHullDamage, TeamId);
[JsonDerivedType(typeof(TurretShootAction))]
[JsonDerivedType(typeof(TurretChargeAction))]
[JsonDerivedType(typeof(TurretLookAtAction))]
[JsonDerivedType(typeof(TurretRotateAction))]
[JsonDerivedType(typeof(RadarScanAction))]
[JsonDerivedType(typeof(CrewMoveAction))]
[JsonDerivedType(typeof(ShipLookAtAction))]
[JsonDerivedType(typeof(ShipRotateAction))]
public abstract record Action(ActionTypes Type);
public record TurretShootAction(string StationId) : Action(ActionTypes.TurretShoot);
public record TurretChargeAction(string StationId) : Action(ActionTypes.TurretCharge);
public record TurretLookAtAction(string StationId, Vector Target)
: Action(ActionTypes.TurretLookAt);
public record TurretRotateAction(string StationId, double Angle) : Action(ActionTypes.TurretRotate);
public record RadarScanAction(string StationId, string TargetShip) : Action(ActionTypes.RadarScan);
public record CrewMoveAction(string CrewMemberId, Vector Destination)
: Action(ActionTypes.CrewMove);
public record ShipRotateAction(double Angle) : Action(ActionTypes.ShipRotate);
public record ShipLookAtAction(Vector Target) : Action(ActionTypes.ShipLookAt);
public record DebrisInfos(
double Damage,
double Radius,
double ApproximateSpeed,
ExplodesInto[] ExplodesInto
);
public record ExplodesInto(DebrisType DebrisType, double ApproximateAngle);
public record World(double Width, double Height);
public record Constants(
World World,
Dictionary<DebrisType, DebrisInfos> DebrisInfos,
ShipInfo Ship
);
public record ShipInfo(Grid Grid, int MaxHealth, int MaxShield, double MaxRotationDegrees, StationsInfo Stations);
public record Grid(int Width, int Height);
public record StationsInfo(
Dictionary<TurretType, TurretInfo> TurretInfos,
ShieldInfo Shield,
RadarInfo Radar
);
public record TurretInfo(
bool Rotatable,
int RocketChargeCost,
int MaxCharge,
double RocketSpeed,
double RocketRadius,
double RocketDamage,
double RocketBonusShieldDamage,
double RocketBonusHullDamage
);
public record ShieldInfo(double ShieldRadius, double ShieldRegenerationPercent, int ShieldBreakHandicap);
public record RadarInfo(double RadarRadius);
public record GameMessage(
int CurrentTickNumber,
string[] LastTickErrors,
string CurrentTeamId,
Constants Constants,
Debris[] Debris,
Projectile[] Rockets,
Dictionary<string, Vector> ShipsPositions,
Dictionary<string, Ship> Ships
);
public record Ship(
string TeamId,
Vector WorldPosition,
double CurrentHealth,
double CurrentShield,
double OrientationDegrees,
Vector[] WalkableTiles,
Crewmate[] Crew,
Stations Stations
);
// ඞ
public record Crewmate(
string Id,
Vector GridPosition,
string Name,
int Age,
string SocialInsurance,
Vector? Destination,
string? CurrentStation,
Distances DistanceFromStations
);
public record Distances(
DistanceFromStation[] Turrets,
DistanceFromStation[] Shields,
DistanceFromStation[] Radars,
DistanceFromStation[] Helms
);
public record DistanceFromStation(string StationId, int Distance, Vector StationPosition);
public abstract record Station(string Id, Vector GridPosition, string? Operator);
public record TurretStation(
string Id,
Vector GridPosition,
TurretType TurretType,
string? Operator,
Vector WorldPosition,
double OrientationDegrees,
double Charge,
double Cooldown
) : Station(Id, GridPosition, Operator);
public record ShieldStation(string Id, Vector GridPosition, string? Operator)
: Station(Id, GridPosition, Operator);
public record RadarStation(
string Id,
Vector GridPosition,
string? Operator,
string? CurrentTarget
) : Station(Id, GridPosition, Operator);
public record HelmStation(string Id, Vector GridPosition, string? Operator)
: Station(Id, GridPosition, Operator);
public record Stations(
TurretStation[] Turrets,
ShieldStation[] Shields,
RadarStation[] Radars,
HelmStation[] Helms
);