forked from ScriptedEvents/ScriptedEvents
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntercomVariables.cs
More file actions
81 lines (67 loc) · 2.65 KB
/
IntercomVariables.cs
File metadata and controls
81 lines (67 loc) · 2.65 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
namespace ScriptedEvents.Variables.Intercom
{
using System;
#pragma warning disable SA1402 // File may only contain a single type.
using System.Collections.Generic;
using System.Linq;
using Exiled.API.Features;
using ScriptedEvents.Structures;
using ScriptedEvents.Variables.Interfaces;
public class IntercomVariables : IVariableGroup
{
public string GroupName => "Intercom";
public IVariable[] Variables { get; } = new IVariable[]
{
new IntercomSpeaker(),
new GeneralIntercom(),
};
}
public class IntercomSpeaker : IFloatVariable, IPlayerVariable
{
/// <inheritdoc/>
public string Name => "{INTERCOMSPEAKER}";
/// <inheritdoc/>
public string Description => "Gets the amount of players who are speaking on the intercom (always either 0 or 1).";
/// <inheritdoc/>
public float Value => Players.Count();
/// <inheritdoc/>
public IEnumerable<Player> Players => Player.Get(player => Intercom.Speaker == player);
}
public class GeneralIntercom : IStringVariable, IArgumentVariable
{
/// <inheritdoc/>
public string Name => "{INTERCOM}";
/// <inheritdoc/>
public string Description => "All-in-one variable for Intercom related information.";
/// <inheritdoc/>
public string[] RawArguments { get; set; }
/// <inheritdoc/>
public object[] Arguments { get; set; }
/// <inheritdoc/>
public Argument[] ExpectedArguments => new[]
{
new OptionsArgument("mode", true,
new("READY", "Is ready to detonate."),
new("COOLDOWN", "The cooldown remaining."),
new("TIMELEFT", "The time left for speaking."),
new("INUSE", "Is in use already.")),
};
/// <inheritdoc/>
public string Value
{
get
{
string mode = (string)Arguments[0];
return mode.ToUpper() switch
{
"READY" => (!Intercom.InUse && Intercom.RemainingCooldown <= 0).ToString().ToUpper(),
"INUSE" => Intercom.InUse.ToString().ToUpper(),
"COOLDOWN" => Intercom.RemainingCooldown.ToString(),
"TIMELEFT" => Intercom.SpeechRemainingTime.ToString(),
_ => throw new ArgumentException("Invalid mode.", mode),
};
}
}
}
#pragma warning restore SA1402 // File may only contain a single type.
}