Skip to content

Commit 63ee907

Browse files
authored
..
1 parent 4d0d8e9 commit 63ee907

File tree

9 files changed

+112
-20
lines changed

9 files changed

+112
-20
lines changed

SCP-600V/API/RoleGet.cs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using Exiled.API.Features;
2+
using MEC;
3+
using PlayerRoles;
4+
using SCP_600V.Extension;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using Exiled.CustomRoles.API.Features;
8+
9+
10+
namespace SCP_600V.API.Role
11+
{
12+
public class Role
13+
{
14+
/// <summary>
15+
/// gets a list of players with the Breeder role on the server
16+
/// </summary>
17+
/// <returns>Player list</returns>
18+
public static List<Player> Scp600Players() => Player.List.Where(x => x != null & x.SessionVariables.ContainsKey("IsSCP600")).ToList();
19+
/// <summary>
20+
/// gets a list of players who have the Serpent's Hand role on the server
21+
/// </summary>
22+
/// <returns>Player list</returns>
23+
public static List<Player> SHPlayers() => Player.List.Where(x => x != null & x.SessionVariables.ContainsKey("IsSH")).ToList();
24+
/// <summary>
25+
/// gets a list of players with the role of Mask of Obsession on the server
26+
/// </summary>
27+
/// <returns>Player list</returns>
28+
public static List<Player> Scp035Players() => Player.List.Where(x => x != null & x.SessionVariables.ContainsKey("IsScp035")).ToList();
29+
/// <summary>
30+
/// Gets a player and defines their role
31+
/// </summary>
32+
/// <param name="player">Player to check</param>
33+
/// <returns>returns true if the player is SCP-600 or not null</returns>
34+
public static bool IsScp600(Player player)
35+
{
36+
if (player != null & player.SessionVariables.ContainsKey("IsSCP600"))
37+
{
38+
return true;
39+
}
40+
else
41+
{
42+
return false;
43+
}
44+
}
45+
/// <summary>
46+
/// Gives the role of SCP-600V to the player
47+
/// </summary>
48+
/// <param name="player">The player who will receive the role of SCP-600V</param>
49+
public static void Spawn(Player player)
50+
{
51+
if (player == null && player.IsDead)
52+
{
53+
return;
54+
}
55+
else
56+
{
57+
CustomRole.Get(typeof(Scp600CotumRoleBase)).AddRole(player);
58+
}
59+
}
60+
/// <summary>
61+
/// Gives the role of SCP-600V to the player
62+
/// </summary>
63+
/// <param name="player">The player who will receive the role of SCP-600V</param>
64+
/// <param name="MaxHealt">Assigning a custom MaxHealt parameter to a player</param>
65+
public static void Spawn(Player player, int MaxHealt = 400)
66+
{
67+
if (player == null && player.IsDead)
68+
{
69+
return;
70+
}
71+
else
72+
{
73+
CustomRole.Get(typeof(Scp600CotumRoleBase)).AddRole(player);
74+
Timing.CallDelayed(2f, () =>
75+
{
76+
player.MaxHealth = MaxHealt;
77+
player.Health = MaxHealt;
78+
});
79+
}
80+
}
81+
/// <summary>
82+
/// Allows you to get the number of people who do not have the role Breeder on the server
83+
/// </summary>
84+
/// <param name="team">Team to check</param>
85+
/// <returns>returns the number of players in the team excluding scp</returns>
86+
public static int AmountTeamNotScp(Team team) => Player.List.Count(x => x != null & !x.SessionVariables.ContainsKey("IsSCP600") & x.Role.Team == team);
87+
/// <summary>
88+
/// Determine if a player who is an SCP is in the team
89+
/// </summary>
90+
/// <param name="team">Team to check</param>
91+
/// <returns>returns true if the SCP player is on the team</returns>
92+
public static bool ScpInTeam(Team team) => Player.List.Any(x => x != null & x.Role.Team == team & x.SessionVariables.ContainsKey("IsSCP600"));
93+
94+
}
95+
}

SCP-600V/Command/GetPlayerAsScp600.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
2121
if (player != null && player.CheckPermission("s6.GetPlayers"))
2222
{
2323
StringBuilder playerListBuilder = new StringBuilder();
24-
foreach (Player ply in RoleGet.Scp600Players())
24+
foreach (Player ply in Role.Scp600Players())
2525
{
2626
playerListBuilder.Append(ply.Nickname).Append(", ");
2727
}

SCP-600V/Command/MaxHealth.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal class MaxHealth : ICommand
1717
public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
1818
{
1919
Player ply = Player.Get(sender);
20-
if (ply != null && ply.CheckPermission("s6.ChengeMHP") && RoleGet.IsScp600(ply))
20+
if (ply != null && ply.CheckPermission("s6.ChengeMHP") && Role.IsScp600(ply))
2121
{
2222
string arg = arguments.At(0);
2323
if (!string.IsNullOrEmpty(arg) & int.TryParse(arg, out _))

SCP-600V/Command/Spawn.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
3030
response = "Player not found by id";
3131
return false;
3232
}
33-
RoleSet.Spawn(GiveTo);
33+
Role.Spawn(GiveTo);
3434
response = $"Role successfully assigned to player {GiveTo.DisplayNickname}";
3535
return true;
3636
}
3737
else
3838
{
3939
GiveTo = Player.Get(sender);
40-
RoleSet.Spawn(GiveTo);
40+
Role.Spawn(GiveTo);
4141
response = "role successfully issued (if nothing happened maybe you are an observer)";
4242
return true;
4343
}

SCP-600V/EventHandler/GameEvents.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal class GameEvents
1111
// does not allow escape for 600
1212
internal void OnEscape(EscapingEventArgs e)
1313
{
14-
if (e.Player != null && RoleGet.IsScp600(e.Player))
14+
if (e.Player != null && Role.IsScp600(e.Player))
1515
{
1616
Log.Debug($"Canceling escape scp600 player: [{e.Player.Nickname}]");
1717
e.IsAllowed = false;
@@ -20,7 +20,7 @@ internal void OnEscape(EscapingEventArgs e)
2020
// does not allow 106 to catch 600 in its dimension
2121
internal void EnterignPocketDemens(EnteringPocketDimensionEventArgs e)
2222
{
23-
if (e.Player != null && RoleGet.IsScp600(e.Player))
23+
if (e.Player != null && Role.IsScp600(e.Player))
2424
{
2525
Log.Debug("Scp-106 don't touch scp600 in pocket demension");
2626
e.IsAllowed = false;
@@ -29,7 +29,7 @@ internal void EnterignPocketDemens(EnteringPocketDimensionEventArgs e)
2929
// making sure SCPs can't kill 600
3030
internal void HurtingPlayer(HurtingEventArgs e)
3131
{
32-
if (e.Player != null & e.Attacker != null & RoleGet.IsScp600(e.Player) & e.Attacker.Role.Team == Team.SCPs)
32+
if (e.Player != null & e.Attacker != null & Role.IsScp600(e.Player) & e.Attacker.Role.Team == Team.SCPs)
3333
{
3434
e.IsAllowed = false;
3535
}

SCP-600V/EventHandler/RoundEvents.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ internal void OnEndingRound(EndingRoundEventArgs e)
1616
bool scp = false;
1717
bool human = false;
1818

19-
int mtf = TeamGet.AmountTeamNotScp(Team.FoundationForces);
20-
int d = TeamGet.AmountTeamNotScp(Team.ClassD);
21-
int s = TeamGet.AmountTeamNotScp(Team.SCPs);
19+
int mtf = Role.AmountTeamNotScp(Team.FoundationForces);
20+
int d = Role.AmountTeamNotScp(Team.ClassD);
21+
int s = Role.AmountTeamNotScp(Team.SCPs);
2222

2323
if (mtf > 0 || d > 0)
2424
{
2525
human = true;
2626
}
27-
if (s > 0 || RoleGet.Scp600Players().Count() > 0)
27+
if (s > 0 || Role.Scp600Players().Count() > 0)
2828
{
2929
scp = true;
3030
}
@@ -44,7 +44,7 @@ internal void OnRoundStarted()
4444
{
4545
players.Add(p);
4646
}
47-
RoleSet.Spawn(players[UnityEngine.Random.Range(1, players.Count())]);
47+
Role.Spawn(players[UnityEngine.Random.Range(1, players.Count())]);
4848
Log.Debug("Spawned random players");
4949
}
5050
else
@@ -54,7 +54,7 @@ internal void OnRoundStarted()
5454
}
5555
internal bool IsSpawnable()
5656
{
57-
if (UnityEngine.Random.value <= Sai.Instance.Config.PercentToSpawn)
57+
if (UnityEngine.Random.value <= Sai.Instance.Config.PercentToSpawn/100)
5858
{
5959
return true;
6060
}

SCP-600V/Extension/Scp600CotumRoleBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ public override void AddRole(Player player)
129129
}
130130
});
131131
}
132-
base.RoleAdded(player);
133132
}
134133
protected override void RoleAdded(Player player)
135134
{
@@ -138,7 +137,7 @@ protected override void RoleAdded(Player player)
138137
player.ChangeAppearance(this.StartAppearance, false, 0);
139138
this.VisibledRole = RoleTypeId.ClassD;
140139
});
141-
base.RoleRemoved(player);
140+
base.RoleAdded(player);
142141
}
143142
protected override void RoleRemoved(Player player)
144143
{

SCP-600V/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
// Можно задать все значения или принять номера сборки и редакции по умолчанию
3434
// используя "*", как показано ниже:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("2.2.0.0")]
37-
[assembly: AssemblyFileVersion("2.2.0.0")]
36+
[assembly: AssemblyVersion("2.2.1.0")]
37+
[assembly: AssemblyFileVersion("2.2.1.0")]
3838
[assembly: NeutralResourcesLanguage("ru-RU")]

SCP-600V/SCP-600V.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@
4242
<SignAssembly>false</SignAssembly>
4343
</PropertyGroup>
4444
<ItemGroup>
45-
<Compile Include="API\Role\RoleGet.cs" />
46-
<Compile Include="API\Role\RoleSet.cs" />
47-
<Compile Include="API\Role\TeamGet.cs" />
45+
<Compile Include="API\RoleGet.cs" />
4846
<Compile Include="Command\GetPlayerAsScp600.cs" />
4947
<Compile Include="Command\GetSessionVariables.cs" />
5048
<Compile Include="Command\MaxHealth.cs" />

0 commit comments

Comments
 (0)