Skip to content

Commit ec54bb0

Browse files
authored
Merge pull request #7 from UncomplicatedCustomServer/dev-labapi
UCEZ v1.1.0 - InternalFaction support
2 parents 86b1b9c + 7e0d313 commit ec54bb0

7 files changed

Lines changed: 41 additions & 24 deletions

File tree

UncomplicatedCustomEscapeZones/API/Features/CustomEscapeZone.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class CustomEscapeZone : ICustomEscapeZone
5151
new Dictionary<string, string>
5252
{
5353
{ "default", "InternalRole ChaosRepressor" },
54-
{ "cuffed by InternalTeam FoundationForces", "InternalRole NtfPrivate" }
54+
{ "cuffed by InternalFaction FoundationForces", "InternalRole NtfPrivate" }
5555
}
5656
]
5757
},
@@ -60,7 +60,7 @@ public class CustomEscapeZone : ICustomEscapeZone
6060
new Dictionary<string, string>
6161
{
6262
{ "default", "InternalRole NtfSpecialist" },
63-
{ "cuffed by InternalTeam ChaosInsurgency", "InternalRole ChaosRepressor" }
63+
{ "cuffed by InternalFaction FoundationEnemy", "InternalRole ChaosRepressor" }
6464
}
6565
]
6666
}

UncomplicatedCustomEscapeZones/Commands/CommandParent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public sealed override void LoadGeneratedCommands()
2828
{
2929
RegisteredCommands.Add(new Reload());
3030
RegisteredCommands.Add(new Outline());
31-
RegisteredCommands.Add(new GetData());
31+
RegisteredCommands.Add(new GetPosition());
3232
}
3333

3434
protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSender sender, out string response)

UncomplicatedCustomEscapeZones/Commands/GetData.cs renamed to UncomplicatedCustomEscapeZones/Commands/GetPosition.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
namespace UncomplicatedEscapeZones.Commands;
99

10-
public class GetData : IUCEZCommand
10+
public class GetPosition : IUCEZCommand
1111
{
12-
public string Name { get; } = "getdata";
12+
public string Name { get; } = "getposition";
1313

1414
public string Description { get; } = "Gets the current position from the Room's origin and the Room's name.";
1515

16-
public string RequiredPermission { get; } = "ucez.getdata";
16+
public string RequiredPermission { get; } = "ucez.getposition";
1717

1818
public bool Executor(List<string> arguments, ICommandSender sender, out string response)
1919
{

UncomplicatedCustomEscapeZones/Events/EventHandler.cs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public override void OnPlayerEscaping(PlayerEscapingEventArgs ev)
2525
{
2626
LogManager.Debug($"Player {ev.Player.Nickname} evaluated for a natural respawn Reason: No RoleAfterEscape configured! {ev.EscapeScenario}");
2727
ev.IsAllowed = true;
28+
base.OnPlayerEscaping(ev);
2829
return;
2930
}
3031

@@ -33,17 +34,20 @@ public override void OnPlayerEscaping(PlayerEscapingEventArgs ev)
3334

3435
if (newRole is null)
3536
{
36-
ev.IsAllowed = false;
37-
LogManager.Debug($"Player {ev.Player.Nickname} has no role to be assigned after escaping!");
37+
ev.IsAllowed = true;
38+
LogManager.Warn($"Player {ev.Player.Nickname} evaluated for a natural respawn Reason: Player has no role to be assigned after escaping!");
39+
base.OnPlayerEscaping(ev);
3840
return;
3941
}
4042

43+
// bool: isCustomRole | object: RoleTypeId or CustomRoleId
4144
KeyValuePair<bool, object> newRoleValue = (KeyValuePair<bool, object>)newRole;
4245

4346
if (newRoleValue.Value is null)
4447
{
4548
ev.IsAllowed = true;
46-
LogManager.Debug($"Player {ev.Player.Nickname} evaluated for a natural respawn! {ev.EscapeScenario}");
49+
LogManager.Debug($"Player {ev.Player.Nickname} evaluated for a natural respawn! Reason: RoleAfterEscape returned null! {ev.EscapeScenario}");
50+
base.OnPlayerEscaping(ev);
4751
return;
4852
}
4953

@@ -57,7 +61,7 @@ public override void OnPlayerEscaping(PlayerEscapingEventArgs ev)
5761
ev.IsAllowed = true;
5862
if (ev.EscapeScenario == Escape.EscapeScenarioType.None)
5963
ev.EscapeScenario = Escape.EscapeScenarioType.Custom;
60-
LogManager.Debug($"Player {ev.Player.Nickname} will respawn as {role})!");
64+
LogManager.Debug($"Player {ev.Player.Nickname} will respawn as {role}!");
6165
}
6266
}
6367
else
@@ -110,13 +114,15 @@ public override void OnServerWaitingForPlayers()
110114

111115
foreach (ICustomEscapeZone customEscapeZone in CustomEscapeZone.List) new SummonedEscapeZone(customEscapeZone);
112116

113-
if (!Plugin.Instance.Config.EnableBasicLogs) return;
114-
LogManager.Info(
115-
$"Thanks for using UncomplicatedCustomEscapeZones v{Plugin.Instance.Version.ToString(3)} by {Plugin.Instance.Author}! Note that if you're using UCR, this plugin is the higher priority.",
116-
ConsoleColor.Blue);
117-
LogManager.Info(
118-
"To receive support and to stay up-to-date, join our official Discord server: https://discord.gg/5StRGu8EJV",
119-
ConsoleColor.DarkYellow);
117+
if (Plugin.Instance.Config.EnableBasicLogs)
118+
{
119+
LogManager.Info(
120+
$"Thanks for using UncomplicatedCustomEscapeZones v{Plugin.Instance.Version.ToString(3)} by {Plugin.Instance.Author}! Note that if you're using UCR, this plugin is the higher priority.",
121+
ConsoleColor.Blue);
122+
LogManager.Info(
123+
"To receive support and to stay up-to-date, join our official Discord server: https://discord.gg/5StRGu8EJV",
124+
ConsoleColor.DarkYellow);
125+
}
120126

121127
base.OnServerWaitingForPlayers();
122128
}

UncomplicatedCustomEscapeZones/Managers/EscapeManager.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ public class EscapeManager
1818
// Determine which role-specific configuration applies to this player
1919
string playerRoleKey = player.Role.ToString();
2020
string playerTeamKey = player.Team.ToString();
21+
string playerFactionKey = player.Faction.ToString();
2122

2223
LogManager.Debug($"Player Role: {playerRoleKey}");
2324
LogManager.Debug($"Player Team: {playerTeamKey}");
25+
LogManager.Debug($"Player Faction: {playerFactionKey}");
2426

25-
if (string.IsNullOrWhiteSpace(playerRoleKey) || string.IsNullOrWhiteSpace(playerTeamKey))
27+
if (string.IsNullOrWhiteSpace(playerRoleKey) || string.IsNullOrWhiteSpace(playerTeamKey) || string.IsNullOrWhiteSpace(playerFactionKey))
2628
{
2729
LogManager.Warn(
2830
$"Unable to determine player's role or team for escape evaluation (PlayerId={player.PlayerId}). Allowing natural escape.");
@@ -33,6 +35,8 @@ public class EscapeManager
3335
roleAfterEscape,
3436
$"InternalTeam {playerTeamKey}",
3537
$"IT {playerRoleKey}",
38+
$"InternalFaction {playerFactionKey}",
39+
$"IF {playerFactionKey}",
3640
playerRoleKey);
3741

3842
if (UCR.TryGetSummonedCustomRole(player, out object summonedPlayer))
@@ -62,6 +66,7 @@ public class EscapeManager
6266
LogManager.Debug($"Found {entries.Count} RoleAfterEscape entries for role '{playerRoleKey}'.");
6367

6468
Dictionary<Team, KeyValuePair<bool, object?>?> asCuffedByInternalTeam = new();
69+
Dictionary<Faction, KeyValuePair<bool, object?>?> asCuffedByInternalFaction = new();
6570
Dictionary<RoleTypeId, KeyValuePair<bool, object?>?> asCuffedByInternalRole = new();
6671
// Dictionary<uint, KeyValuePair<bool, object?>?> asCuffedByCustomTeam = new(); we will add the support to UCT and UIU-RS
6772
Dictionary<int, KeyValuePair<bool, object?>?> asCuffedByCustomRole = new();
@@ -89,13 +94,16 @@ public class EscapeManager
8994
{
9095
LogManager.Warn(
9196
$"Failed to parse an EscapeRole[key]: syntax should be cuffed by <source> <id>, found {elements.Count} args!\nSource: {kvp.Key}");
92-
return new KeyValuePair<bool, object?>(false, RoleTypeId.Spectator);
97+
return new KeyValuePair<bool, object?>(false, null);
9398
}
9499

95100
LogManager.Debug($"Parsing escape condition: {kvp.Key} -> {kvp.Value}");
96101

97102
switch (elements[2])
98103
{
104+
case "InternalFaction" or "IF" when Enum.TryParse(elements[3], out Faction faction):
105+
asCuffedByInternalFaction.TryAdd(faction, data);
106+
break;
99107
case "InternalTeam" or "IT" when Enum.TryParse(elements[3], out Team team):
100108
asCuffedByInternalTeam.TryAdd(team, data);
101109
break;
@@ -110,7 +118,7 @@ when int.TryParse(elements[3], out int id) && UCR.TryGetCustomRole(id, out _):
110118
{
111119
bool okInt = int.TryParse(elements[3], out _);
112120
LogManager.Warn(
113-
$"Function SpawnManager::ParseEscapeRole[2](<...>) failed!\nPossible causes can be:\n- The source is not valid. Allowed: InternalTeam / IT / CustomRole / CR. Found: {elements[2]}\n- The target is not a CustomRole / InternalRole. Found: {elements[3]} (int32 parsable: {okInt})");
121+
$"Function SpawnManager::ParseEscapeRole[2](<...>) failed!\nPossible causes can be:\n- The source is not valid. Allowed: InternalTeam / IT / InternalFaction / IF / CustomRole / CR. Found: {elements[2]}\n- The target is not a CustomRole / InternalRole. Found: {elements[3]} (int32 parsable: {okInt})");
114122
break;
115123
}
116124
}
@@ -141,10 +149,13 @@ when int.TryParse(elements[3], out int id) && UCR.TryGetCustomRole(id, out _):
141149

142150
if (asCuffedByInternalTeam.TryGetValue(player.DisarmedBy.Team, out KeyValuePair<bool, object?>? teamValue) && teamValue is not null)
143151
return teamValue;
152+
153+
if (asCuffedByInternalFaction.TryGetValue(player.DisarmedBy.Faction, out KeyValuePair<bool, object?>? factionValue) && factionValue is not null)
154+
return factionValue;
144155
}
145156

146157
LogManager.Debug(
147-
$"Returing default type for escaping evaluation of player {player.PlayerId} who's cuffed by {player.DisarmedBy?.Team}");
158+
$"Returing default type for escaping evaluation of player {player.PlayerId} who's cuffed by team: {player.DisarmedBy?.Team} faction: {player.DisarmedBy?.Faction} role: {player.DisarmedBy?.Role}");
148159
return defaultValue;
149160

150161
// Local function to resolve entries with case-insensitive keys

UncomplicatedCustomEscapeZones/Plugin.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ internal class Plugin : Plugin<Config>
2323
public override string Name => "UncomplicatedCustomEscapeZones";
2424
public override string Description => "Customize your SCP:SL server with Custom Escape Zones!";
2525
public override string Author => "MedveMarci & FoxWorn3365";
26-
public override Version Version => new(1, 0, 1, 0);
26+
public override Version Version => new(1, 1, 0, 0);
2727
public override Version RequiredApiVersion { get; } = new(LabApiProperties.CompiledVersion);
2828
public override LoadPriority Priority => LoadPriority.Highest;
2929

UncomplicatedCustomEscapeZones/UncomplicatedCustomEscapeZones.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<Reference Include="Mirror" HintPath="$(sl_references)\Mirror.dll"/>
5555
<Reference Include="UnityEngine.CoreModule" HintPath="$(sl_references)\UnityEngine.CoreModule.dll"/>
5656
<PackageReference Include="Newtonsoft.Json">
57-
<Version>13.0.3</Version>
57+
<Version>13.0.4</Version>
5858
</PackageReference>
5959
<PackageReference Include="System.ComponentModel">
6060
<Version>4.3.0</Version>
@@ -81,7 +81,7 @@
8181
<Compile Include="API\Features\SummonedEscapeZone.cs"/>
8282
<Compile Include="API\Struct\Triplet.cs"/>
8383
<Compile Include="Commands\CommandParent.cs"/>
84-
<Compile Include="Commands\GetData.cs"/>
84+
<Compile Include="Commands\GetPosition.cs" />
8585
<Compile Include="Commands\Outline.cs"/>
8686
<Compile Include="Commands\Reload.cs"/>
8787
<Compile Include="Config.cs"/>

0 commit comments

Comments
 (0)