-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMapVariables.cs
More file actions
325 lines (259 loc) · 9.85 KB
/
MapVariables.cs
File metadata and controls
325 lines (259 loc) · 9.85 KB
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
using System;
using System.Collections.Generic;
using System.Linq;
using Exiled.API.Enums;
using Exiled.API.Features;
using Exiled.API.Features.Doors;
using ScriptedEvents.API.Enums;
using ScriptedEvents.API.Extensions;
using ScriptedEvents.API.Features;
using ScriptedEvents.API.Features.Exceptions;
using ScriptedEvents.Structures;
using ScriptedEvents.Variables.Interfaces;
namespace ScriptedEvents.Variables
{
#pragma warning disable SA1402 // File may only contain a single type.
public class MapVariables : IVariableGroup
{
/// <inheritdoc/>
public string GroupName => "Map";
/// <inheritdoc/>
public IVariable[] Variables { get; } = new IVariable[]
{
new Decontaminated(),
new Scp914Active(),
new DoorState(),
new Overcharged(),
new Generators(),
new RandomRoom(),
new RandomDoor(),
new InRoom(),
new CassieSpeaking(),
new MapSeed(),
};
}
public class MapSeed : IStringVariable
{
/// <inheritdoc/>
public string Name => "{MAPSEED}";
/// <inheritdoc/>
public string Description => "Returns the current map seed.";
/// <inheritdoc/>
public string Value => Map.Seed.ToString();
}
public class CassieSpeaking : IBoolVariable
{
/// <inheritdoc/>
public string Name => "{CASSIESPEAKING}";
/// <inheritdoc/>
public string ReversedName => "{!CASSIESPEAKING}";
/// <inheritdoc/>
public string Description => "Whether or not CASSIE is currently speaking.";
/// <inheritdoc/>
public bool Value => Cassie.IsSpeaking;
}
public class InRoom : IFloatVariable, IArgumentVariable, IPlayerVariable, INeedSourceVariable
{
/// <inheritdoc/>
public string Name => "{INROOM}";
/// <inheritdoc/>
public string Description => "The amount of players in the specified room.";
/// <inheritdoc/>
public string[] RawArguments { get; set; }
/// <inheritdoc/>
public object[] Arguments { get; set; }
/// <inheritdoc/>
public Argument[] ExpectedArguments => new[]
{
new Argument("roomType", typeof(RoomType), "The room to filter by.", false),
};
/// <inheritdoc/>
public Script Source { get; set; }
/// <inheritdoc/>
public float Value => Players.Count();
/// <inheritdoc/>
public IEnumerable<Player> Players
{
get
{
RoomType rt = (RoomType)Arguments[0];
return Player.Get(plr => plr.CurrentRoom?.Type == rt);
}
}
}
public class RandomDoor : IStringVariable, INeedSourceVariable, IArgumentVariable
{
/// <inheritdoc/>
public string Name => "{RANDOMDOOR}";
/// <inheritdoc/>
public string Description => "Gets the DoorType of a random door. Can be filtered by zone.";
/// <inheritdoc/>
public string[] RawArguments { get; set; }
/// <inheritdoc/>
public object[] Arguments { get; set; }
/// <inheritdoc/>
public Argument[] ExpectedArguments => new[]
{
new Argument("zone", typeof(ZoneType), "A zone to filter by (optional).", false),
};
/// <inheritdoc/>
public Script Source { get; set; }
/// <inheritdoc/>
public string Value
{
get
{
ZoneType filter = ZoneType.Unspecified;
if (Arguments.Length > 0)
filter = (ZoneType)Arguments[0];
IEnumerable<Door> validDoors = Door.List;
if (filter is not ZoneType.Unspecified)
{
validDoors = validDoors.Where(door => door.Zone.HasFlag(filter));
}
List<Door> newList = validDoors.ToList();
return newList[UnityEngine.Random.Range(0, newList.Count)].Type.ToString();
}
}
}
public class Decontaminated : IBoolVariable
{
/// <inheritdoc/>
public string Name => "{DECONTAMINATED}";
/// <inheritdoc/>
public string ReversedName => "{!DECONTAMINATED}";
/// <inheritdoc/>
public string Description => "Whether or not Light Containment Zone has been decontaminated.";
/// <inheritdoc/>
public bool Value => Map.IsLczDecontaminated;
}
public class Overcharged : IBoolVariable
{
/// <inheritdoc/>
public string Name => "{OVERCHARGED}";
/// <inheritdoc/>
public string ReversedName => "{!OVERCHARGED}";
/// <inheritdoc/>
public string Description => "Indicates whether or not SCP-079 was successfully contained via overcharge sequence.";
/// <inheritdoc/>
public bool Value => Recontainer.IsContainmentSequenceSuccessful;
}
public class Generators : IFloatVariable, IArgumentVariable
{
/// <inheritdoc/>
public string Name => "{GENERATORS}";
/// <inheritdoc/>
public string Description => "Gets the number of generators fulfilling the requirements.";
/// <inheritdoc/>
public string[] RawArguments { get; set; }
/// <inheritdoc/>
public object[] Arguments { get; set; }
/// <inheritdoc/>
public Argument[] ExpectedArguments => new[]
{
new OptionsArgument("mode", true,
new("ENGAGED"),
new("ACTIVATING"),
new("UNLOCKED"),
new("OPENED"),
new("CLOSED")),
};
/// <inheritdoc/>
public float Value
{
get
{
switch (Arguments[0].ToUpper())
{
case "ENGAGED":
return Generator.Get(GeneratorState.Engaged).Count();
case "ACTIVATING":
return Generator.Get(GeneratorState.Activating).Count();
case "UNLOCKED":
return Generator.Get(GeneratorState.Unlocked).Count();
case "OPENED":
return Generator.Get(GeneratorState.Open).Count();
case "CLOSED":
return Generator.Get(gen => gen.IsOpen is false).Count();
default:
throw new ScriptedEventsException($"Mode {Arguments[0]} is not ENGAGED/ACTIVATING/UNLOCKED/OPENED or CLOSED.");
}
}
}
}
public class RandomRoom : IStringVariable, IArgumentVariable, INeedSourceVariable
{
/// <inheritdoc/>
public string Name => "{RANDOMROOM}";
/// <inheritdoc/>
public string Description => "Gets the RoomType of a random room. Can be filtered by zone.";
/// <inheritdoc/>
public string[] RawArguments { get; set; }
/// <inheritdoc/>
public object[] Arguments { get; set; }
/// <inheritdoc/>
public Argument[] ExpectedArguments => new[]
{
new Argument("zone", typeof(ZoneType), "A zone to filter by (optional).", false),
};
/// <inheritdoc/>
public Script Source { get; set; }
/// <inheritdoc/>
public string Value
{
get
{
ZoneType filter = ZoneType.Unspecified;
if (Arguments.Length > 0)
filter = (ZoneType)Arguments[0];
IEnumerable<Room> validRooms = Room.List.Where(room => room.Type != RoomType.Pocket);
if (filter is not ZoneType.Unspecified)
validRooms = validRooms.Where(room => room.Zone.HasFlag(filter));
List<Room> newList = validRooms.ToList();
return newList[UnityEngine.Random.Range(0, newList.Count)].Type.ToString();
}
}
}
public class Scp914Active : IBoolVariable
{
/// <inheritdoc/>
public string Name => "{SCP914ACTIVE}";
/// <inheritdoc/>
public string ReversedName => "{!SCP914ACTIVE}";
/// <inheritdoc/>
public string Description => "Whether or not SCP-914 is currently active.";
/// <inheritdoc/>
public bool Value => Exiled.API.Features.Scp914.IsWorking;
}
public class DoorState : IStringVariable, IArgumentVariable, INeedSourceVariable
{
/// <inheritdoc/>
public string Name => "{DOORSTATE}";
/// <inheritdoc/>
public string Description => "Reveals the state of a door (either 'OPEN' or 'CLOSED').";
/// <inheritdoc/>
public string[] RawArguments { get; set; }
/// <inheritdoc/>
public object[] Arguments { get; set; }
/// <inheritdoc/>
public Script Source { get; set; }
/// <inheritdoc/>
public Argument[] ExpectedArguments => new[]
{
new Argument("door", typeof(DoorType), "The door to get the state of.", true),
};
/// <inheritdoc/>
public string Value
{
get
{
DoorType dt = (DoorType)Arguments[0];
Door d = Door.Get(dt);
return d is null
? throw new ArgumentException(ErrorGen.Get(ErrorCode.InvalidEnumGeneric, dt.ToString(), nameof(DoorType)))
: (d.IsOpen ? "OPEN" : "CLOSED");
}
}
}
#pragma warning restore SA1402 // File may only contain a single type.
}