This repository was archived by the owner on Aug 9, 2023. It is now read-only.
forked from Marco15453-Archived/UIURescueSquad
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMethods.cs
More file actions
145 lines (119 loc) · 5.02 KB
/
Copy pathMethods.cs
File metadata and controls
145 lines (119 loc) · 5.02 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
namespace UIURescueSquad
{
using Exiled.API.Extensions;
using Exiled.API.Features;
using Exiled.CustomItems.API;
using MEC;
using static API;
/// <summary>
/// EventHandlers and Methods which UIURescueSquad uses.
/// </summary>
public partial class EventHandlers
{
/// <summary>
/// Spawns a player as UIU.
/// </summary>
/// <param name="player">The player to spawn.</param>
/// <param name="uiuType">The UIU role of the spawned player.</param>
internal static void SpawnPlayer(Player player, UiuType uiuType = UiuType.None)
{
if (uiuType == UiuType.None)
{
uiuType = GetUIURole(player.Role);
if (uiuType == UiuType.None)
{
Log.Error("The player's role can not be converted into uiuRole.");
return;
}
}
player.SessionVariables.Add("IsUIU", uiuType);
if (!string.IsNullOrEmpty(Config.SpawnManager.UiuBroadcast))
{
if (Config.SpawnManager.UseHints)
{
player.ShowHint(Config.SpawnManager.UiuBroadcast, Config.SpawnManager.UiuBroadcastTime);
}
else
{
player.ClearBroadcasts();
player.Broadcast(Config.SpawnManager.UiuBroadcastTime, Config.SpawnManager.UiuBroadcast);
}
}
Timing.CallDelayed(0.01f, () =>
{
player.IsGodModeEnabled = true;
switch (uiuType)
{
case UiuType.Soldier:
{
if (player.Role.Type != RoleType.NtfPrivate)
{
player.Role.Type = RoleType.NtfPrivate;
}
player.Health = Config.UiuSoldier.Health;
player.ResetInventory(Config.UiuSoldier.Inventory);
foreach (var ammo in Config.UiuSoldier.Ammo)
{
player.SetAmmo(ammo.Key, ammo.Value);
}
player.CustomInfo = $"{player.Nickname}\n{Config.UiuSoldier.Rank}";
break;
}
case UiuType.Agent:
{
if (player.Role.Type != RoleType.NtfSergeant)
{
player.Role.Type = RoleType.NtfSergeant;
}
player.Health = Config.UiuAgent.Health;
player.ResetInventory(Config.UiuAgent.Inventory);
foreach (var ammo in Config.UiuAgent.Ammo)
{
player.SetAmmo(ammo.Key, ammo.Value);
}
player.CustomInfo = $"{player.Nickname}\n{Config.UiuAgent.Rank}";
break;
}
case UiuType.Leader:
{
if (player.Role.Type != RoleType.NtfCaptain)
{
player.Role.Type = RoleType.NtfCaptain;
}
player.Health = Config.UiuLeader.Health;
player.ResetInventory(Config.UiuLeader.Inventory);
foreach (var ammo in Config.UiuLeader.Ammo)
{
player.SetAmmo(ammo.Key, ammo.Value);
}
player.CustomInfo = $"{player.Nickname}\n{Config.UiuLeader.Rank}";
break;
}
default:
{
return;
}
}
player.ReferenceHub.nicknameSync.ShownPlayerInfo &= ~PlayerInfoArea.Nickname;
player.ReferenceHub.nicknameSync.ShownPlayerInfo &= ~PlayerInfoArea.Role;
Timing.CallDelayed(0.4f, () =>
{
player.Position = Config.SpawnManager.SpawnPos;
player.IsGodModeEnabled = false;
});
});
}
/// <summary>
/// Removes a UIU role from a <see cref="Player"/>.
/// </summary>
/// <param name="player">The player to remove.</param>
internal static void DestroyUIU(Player player)
{
player.SessionVariables.Remove("IsUIU");
player.MaxHealth = default;
player.CustomInfo = string.Empty;
player.ReferenceHub.nicknameSync.ShownPlayerInfo |= PlayerInfoArea.Nickname;
player.ReferenceHub.nicknameSync.ShownPlayerInfo |= PlayerInfoArea.Role;
}
}
}