forked from Marco15453-Archived/UIURescueSquad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
API.cs
86 lines (75 loc) · 2.55 KB
/
API.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
namespace UIURescueSquad
{
using System.Collections.Generic;
using System.Linq;
using Exiled.API.Features;
/// <summary>
/// The UIU Rescue Sqaud API with <see langword="static"/> methods.
/// </summary>
public static class API
{
/// <summary>
/// Checks if <see cref="Player"/> is UIU.
/// </summary>
/// <param name="player"> The player to check.</param>
/// <returns><see langword="true"/> if player is UIU, <see langword="false"/> if not.</returns>
public static bool IsUiu(Player player)
{
return player.SessionVariables.ContainsKey("IsUIU");
}
/// <summary>
/// Gets a <see cref="UiuType"/> from provided <see cref="RoleType"/>.
/// </summary>
/// <param name="roleType">RoleType to check.</param>
/// <returns>A valid <see cref="UiuType"/> or <see cref="UiuType.None"/> if the role couldn't be parsed.</returns>
public static UiuType GetUIURole(RoleType roleType)
{
switch (roleType)
{
case RoleType.NtfPrivate:
return UiuType.Soldier;
case RoleType.NtfSergeant:
return UiuType.Agent;
case RoleType.NtfCaptain:
return UiuType.Leader;
default:
return UiuType.None;
}
}
/// <inheritdoc cref="EventHandlers.SpawnPlayer(Player, UiuType)"/>
public static void SpawnPlayer(Player player, UiuType uiuType)
{
EventHandlers.SpawnPlayer(player, uiuType);
}
/// <summary>
/// Gets all alive UIU players.
/// </summary>
/// <returns><see cref="List{Player}"/> of all alive UIU players.</returns>
public static List<Player> GetUIUPlayers()
{
return Player.List.Where(x => x.SessionVariables.ContainsKey("IsUIU")).ToList();
}
}
/// <summary>
/// Basically <see cref="RoleType"/>, but for UIU.
/// </summary>
public enum UiuType
{
/// <summary>
/// RoleType isn't a UIU role.
/// </summary>
None = -1,
/// <summary>
/// Equivalent of <see cref="RoleType.NtfPrivate"/>
/// </summary>
Soldier = 0,
/// <summary>
/// Equivalent of <see cref="RoleType.NtfSergeant"/>
/// </summary>
Agent = 1,
/// <summary>
/// Equivalent of <see cref="RoleType.NtfCaptain"/>
/// </summary>
Leader = 2,
}
}