mirror of
https://github.com/edgegamers/Jailbreak.git
synced 2025-12-05 20:40:29 -08:00
More cleanup
This commit is contained in:
@@ -72,6 +72,7 @@
|
||||
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpAutoNaming/IsNotificationDisabled/@EntryValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=API/@EntryIndexedValue">API</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=IO/@EntryIndexedValue">IO</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LG/@EntryIndexedValue">LG</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=LR/@EntryIndexedValue">LR</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=ST/@EntryIndexedValue">ST</s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=08582792_002Dd334_002D4f6d_002Db467_002Dfc7b9fd4557b/@EntryIndexedValue"><Policy><Descriptor Staticness="Any" AccessRightKinds="Private, ProtectedInternal, Internal, PrivateProtected" Description="Non-Public Methods"><ElementKinds><Kind Name="METHOD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></Policy></s:String>
|
||||
@@ -83,6 +84,10 @@
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=8a85b61a_002D1024_002D4f87_002Db9ef_002D1fdae19930a1/@EntryIndexedValue"><Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Parameters"><ElementKinds><Kind Name="PARAMETER" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb"><ExtraRule Prefix="_" Suffix="" Style="aaBb" /></Policy></Policy></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=8b8504e3_002Df0be_002D4c14_002D9103_002Dc732f2bddc15/@EntryIndexedValue"><Policy><Descriptor Staticness="Any" AccessRightKinds="Any" Description="Enum members"><ElementKinds><Kind Name="ENUM_MEMBER" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></Policy></s:String>
|
||||
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=c873eafb_002Dd57f_002D481d_002D8c93_002D77f6863c2f88/@EntryIndexedValue"><Policy><Descriptor Staticness="Static" AccessRightKinds="Protected, ProtectedInternal, Internal, Public, PrivateProtected" Description="Static readonly fields (not private)"><ElementKinds><Kind Name="READONLY_FIELD" /></ElementKinds></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="AA_BB" /></Policy></s:String>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -9,14 +9,14 @@ namespace Jailbreak.English.LastGuard;
|
||||
|
||||
public class LastGuardNotifications : ILastGuardNotifications,
|
||||
ILanguage<Formatting.Languages.English> {
|
||||
public static readonly FormatObject PREFIX =
|
||||
private static readonly FormatObject PREFIX =
|
||||
new HiddenFormatObject(
|
||||
$" {ChatColors.DarkRed}[{ChatColors.LightRed}Last Guard{ChatColors.DarkRed}]") {
|
||||
// Hide in panorama and center text
|
||||
Plain = false, Panorama = false, Chat = true
|
||||
};
|
||||
|
||||
public IView LG_STARTED(int ctHealth, int tHealth) {
|
||||
public IView LGStarted(int ctHealth, int tHealth) {
|
||||
return new SimpleView {
|
||||
PREFIX,
|
||||
$"{ChatColors.Red}Last Guard has been activated! Last guard has",
|
||||
|
||||
@@ -89,6 +89,22 @@ public class LastRequestMessages : ILastRequestMessages,
|
||||
};
|
||||
}
|
||||
|
||||
public IView CannotLR(string reason) {
|
||||
return new SimpleView {
|
||||
PREFIX,
|
||||
$"{ChatColors.Red}You cannot LR: {ChatColors.White + reason + ChatColors.Red}."
|
||||
};
|
||||
}
|
||||
|
||||
public IView CannotLR(CCSPlayerController player, string reason) {
|
||||
return new SimpleView {
|
||||
PREFIX,
|
||||
ChatColors.Red + "You cannot LR",
|
||||
player,
|
||||
": " + ChatColors.White + reason + ChatColors.Red + "."
|
||||
};
|
||||
}
|
||||
|
||||
public IView DamageBlockedInsideLastRequest
|
||||
=> new SimpleView { PREFIX, "You or they are in LR, damage blocked." };
|
||||
|
||||
|
||||
@@ -34,4 +34,20 @@ public class RaceLRMessages : IRaceLRMessages,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public IView NotInRaceLR()
|
||||
=> new SimpleView {
|
||||
{
|
||||
LastRequestMessages.PREFIX,
|
||||
$"You must be in a race {ChatColors.Blue + "!lr" + ChatColors.White} to use this command"
|
||||
}
|
||||
};
|
||||
|
||||
public IView NotInPendingState()
|
||||
=> new SimpleView {
|
||||
{
|
||||
LastRequestMessages.PREFIX,
|
||||
"You must be in the pending state to use this command."
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -17,13 +17,13 @@ public class PeaceMessages : IPeaceMessages,
|
||||
|
||||
public IView PeaceEnactedByAdmin(int seconds) {
|
||||
return new SimpleView {
|
||||
PREFIX, "An admin has enacted peace for", seconds, "seconds."
|
||||
PREFIX, "An admin enacted peace for", seconds, "seconds."
|
||||
};
|
||||
}
|
||||
|
||||
public IView WardenEnactedPeace(int seconds) {
|
||||
return new SimpleView {
|
||||
PREFIX, "Warden has enacted peace for", seconds, "seconds."
|
||||
PREFIX, "Warden enacted peace for", seconds, "seconds."
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ namespace Jailbreak.English.Rebel;
|
||||
|
||||
public class JihadC4Notifications : IJihadC4Notifications,
|
||||
ILanguage<Formatting.Languages.English> {
|
||||
// public IView JIHAD_C4_DROPPED => new SimpleView { RebelNotifications.PREFIX, "You dropped your Jihad C4!" };
|
||||
public IView JihadC4Pickup
|
||||
=> new SimpleView {
|
||||
RebelNotifications.PREFIX, "You picked up a Jihad C4!"
|
||||
@@ -21,11 +20,4 @@ public class JihadC4Notifications : IJihadC4Notifications,
|
||||
RebelNotifications.PREFIX,
|
||||
$"To detonate it, hold it out and press {ChatColors.Yellow + "E" + ChatColors.Default}."
|
||||
};
|
||||
// public IView JIHAD_C4_USAGE2 => new SimpleView { RebelNotifications.PREFIX, $"You can drop the C4 to other players with {ChatColors.Yellow + "G" + ChatColors.Default}." };
|
||||
|
||||
|
||||
// public IView PlayerDetonateC4(CCSPlayerController player)
|
||||
// {
|
||||
// return new SimpleView { RebelNotifications.PREFIX, $"{player.PlayerName} has detonated a Jihad C4!" };
|
||||
// }
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class SpecialTreatmentNotifications : ISpecialTreatmentNotifications,
|
||||
return new SimpleView {
|
||||
PREFIX,
|
||||
player,
|
||||
$"now has {ChatColors.Grey}Special Treatment{ChatColors.White}!"
|
||||
$"now has {ChatColors.Green}Special Treatment{ChatColors.White}!"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class WardenNotifications : IWardenNotifications,
|
||||
Plain = false, Panorama = false, Chat = true
|
||||
};
|
||||
|
||||
public IView PICKING_SHORTLY
|
||||
public IView PickingShortly
|
||||
=> new SimpleView {
|
||||
{ PREFIX, $"{ChatColors.Grey}Picking a warden shortly..." },
|
||||
SimpleView.NEWLINE, {
|
||||
@@ -26,59 +26,59 @@ public class WardenNotifications : IWardenNotifications,
|
||||
}
|
||||
};
|
||||
|
||||
public IView NO_WARDENS
|
||||
public IView NoWardens
|
||||
=> new SimpleView {
|
||||
PREFIX,
|
||||
$"No wardens in queue! The next player to run {ChatColors.Blue}!warden{ChatColors.White} will become a warden."
|
||||
};
|
||||
|
||||
public IView WARDEN_LEFT
|
||||
public IView WardenLeft
|
||||
=> new SimpleView { PREFIX, "The warden has left the game." };
|
||||
|
||||
public IView WARDEN_DIED
|
||||
public IView WardenDied
|
||||
=> new SimpleView {
|
||||
PREFIX,
|
||||
$"{ChatColors.Red}The warden has {ChatColors.DarkRed}died{ChatColors.Red}! CTs must pursue {ChatColors.Blue}!warden{ChatColors.Red}."
|
||||
};
|
||||
|
||||
public IView BECOME_NEXT_WARDEN
|
||||
public IView BecomeNextWarden
|
||||
=> new SimpleView {
|
||||
PREFIX,
|
||||
$"{ChatColors.Grey}Type {ChatColors.Blue}!warden{ChatColors.Grey} to become the next warden"
|
||||
};
|
||||
|
||||
public IView JOIN_RAFFLE
|
||||
public IView JoinRaffle
|
||||
=> new SimpleView {
|
||||
PREFIX,
|
||||
$"{ChatColors.Grey}You've {ChatColors.Green}joined {ChatColors.Grey}the warden raffle."
|
||||
};
|
||||
|
||||
public IView LEAVE_RAFFLE
|
||||
public IView LeaveRaffle
|
||||
=> new SimpleView {
|
||||
PREFIX,
|
||||
$"{ChatColors.Grey}You've {ChatColors.Red}left {ChatColors.Grey}the warden raffle."
|
||||
};
|
||||
|
||||
public IView NOT_WARDEN
|
||||
public IView NotWarden
|
||||
=> new SimpleView {
|
||||
PREFIX, $"{ChatColors.LightRed}You are not the warden."
|
||||
};
|
||||
|
||||
public IView FIRE_COMMAND_FAILED
|
||||
public IView FireCommandFailed
|
||||
=> new SimpleView {
|
||||
PREFIX, "The fire command has failed to work for some unknown reason..."
|
||||
};
|
||||
|
||||
public IView PASS_WARDEN(CCSPlayerController player) {
|
||||
public IView PassWarden(CCSPlayerController player) {
|
||||
return new SimpleView { PREFIX, player, "resigned from being warden." };
|
||||
}
|
||||
|
||||
public IView FIRE_WARDEN(CCSPlayerController player) {
|
||||
public IView FireWarden(CCSPlayerController player) {
|
||||
return new SimpleView { PREFIX, player, "was fired from being warden." };
|
||||
}
|
||||
|
||||
public IView FIRE_WARDEN(CCSPlayerController player,
|
||||
CCSPlayerController admin) {
|
||||
public IView
|
||||
FireWarden(CCSPlayerController player, CCSPlayerController admin) {
|
||||
return new SimpleView {
|
||||
PREFIX,
|
||||
admin,
|
||||
@@ -88,17 +88,17 @@ public class WardenNotifications : IWardenNotifications,
|
||||
};
|
||||
}
|
||||
|
||||
public IView NEW_WARDEN(CCSPlayerController player) {
|
||||
public IView NewWarden(CCSPlayerController player) {
|
||||
return new SimpleView { PREFIX, player, "is now the warden!" };
|
||||
}
|
||||
|
||||
public IView CURRENT_WARDEN(CCSPlayerController? player) {
|
||||
if (player is not null)
|
||||
return new SimpleView { PREFIX, "The warden is", player, "." };
|
||||
return new SimpleView { PREFIX, "There is no warden." };
|
||||
public IView CurrentWarden(CCSPlayerController? player) {
|
||||
return player is not null ?
|
||||
new SimpleView { PREFIX, "The warden is", player, "." } :
|
||||
new SimpleView { PREFIX, "There is no warden." };
|
||||
}
|
||||
|
||||
public IView FIRE_COMMAND_SUCCESS(CCSPlayerController player) {
|
||||
public IView FireCommandSuccess(CCSPlayerController player) {
|
||||
return new SimpleView {
|
||||
PREFIX, player, "was fired and is no longer the warden."
|
||||
};
|
||||
|
||||
@@ -75,14 +75,11 @@ public abstract class AbstractCommand(IServiceProvider services) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (matches.Count() > 1) {
|
||||
if (command.CallingPlayer != null)
|
||||
lang.PlayerFoundMultiple(command.GetArg(argIndex))
|
||||
.ToPlayerChat(command.CallingPlayer);
|
||||
return null;
|
||||
}
|
||||
|
||||
return matches;
|
||||
if (matches.Count() <= 1) return matches;
|
||||
if (command.CallingPlayer != null)
|
||||
lang.PlayerFoundMultiple(command.GetArg(argIndex))
|
||||
.ToPlayerChat(command.CallingPlayer);
|
||||
return null;
|
||||
}
|
||||
|
||||
protected string GetTargetLabel(WrappedInfo info, int argIndex = 1) {
|
||||
@@ -126,7 +123,7 @@ public abstract class AbstractCommand(IServiceProvider services) {
|
||||
|
||||
protected string GetTargetLabels(CommandInfo info, int argIndex = 1) {
|
||||
var label = GetTargetLabel(info, argIndex);
|
||||
if (label.ToLower().EndsWith("s")) return label + "'";
|
||||
if (label.ToLower().EndsWith('s')) return label + "'";
|
||||
return label + "'s";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,22 +35,25 @@ public class LastRequest : AbstractCommand {
|
||||
WrappedInfo info) {
|
||||
if (executor == null || !executor.IsReal()) return;
|
||||
|
||||
if (info.ArgCount == 1) {
|
||||
MenuManager.OpenCenterHtmlMenu(plugin, executor, menuSelector.GetMenu());
|
||||
return;
|
||||
}
|
||||
switch (info.ArgCount) {
|
||||
case 1:
|
||||
MenuManager.OpenCenterHtmlMenu(plugin, executor,
|
||||
menuSelector.GetMenu());
|
||||
return;
|
||||
case 2:
|
||||
switch (info.GetArg(1).ToLower()) {
|
||||
case "enable":
|
||||
manager.EnableLR();
|
||||
info.ReplyToCommand("Last Request enabled.");
|
||||
return;
|
||||
case "disable":
|
||||
manager.DisableLR();
|
||||
info.ReplyToCommand("Last Request disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (info.ArgCount == 2)
|
||||
switch (info.GetArg(1).ToLower()) {
|
||||
case "enable":
|
||||
manager.EnableLR();
|
||||
info.ReplyToCommand("Last Request enabled.");
|
||||
return;
|
||||
case "disable":
|
||||
manager.DisableLR();
|
||||
info.ReplyToCommand("Last Request disabled.");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var type = LRTypeExtensions.FromString(info.GetArg(1));
|
||||
if (type is null) {
|
||||
@@ -69,7 +72,7 @@ public class LastRequest : AbstractCommand {
|
||||
if (fromPlayer == null) return;
|
||||
|
||||
switch (info.ArgCount) {
|
||||
case 3 when executor != null: {
|
||||
case 3: {
|
||||
if (executor.Team == CsTeam.Terrorist)
|
||||
manager.InitiateLastRequest(executor, fromPlayer.First(), type.Value);
|
||||
else // They aren't necessarily on different teams, but this is debug so that's OK
|
||||
|
||||
@@ -11,84 +11,94 @@ using Jailbreak.Public.Mod.LastRequest;
|
||||
|
||||
namespace Jailbreak.LastGuard;
|
||||
|
||||
public class LastGuard(LastGuardConfig config, ILastGuardNotifications notifications, ILastRequestManager lrManager)
|
||||
: ILastGuardService, IPluginBehavior
|
||||
{
|
||||
private bool canStart;
|
||||
public class LastGuard(LastGuardConfig config,
|
||||
ILastGuardNotifications notifications, ILastRequestManager lrManager)
|
||||
: ILastGuardService, IPluginBehavior {
|
||||
private bool canStart;
|
||||
|
||||
[GameEventHandler]
|
||||
public HookResult OnPlayerDeathEvent(EventPlayerDeath @event, GameEventInfo info)
|
||||
{
|
||||
checkLastGuard(@event.Userid);
|
||||
return HookResult.Continue;
|
||||
}
|
||||
public int CalculateHealth() {
|
||||
var aliveTerrorists = Utilities.GetPlayers()
|
||||
.Where(plr
|
||||
=> plr.IsReal() && plr is { PawnIsAlive: true, Team: CsTeam.Terrorist })
|
||||
.ToList();
|
||||
|
||||
[GameEventHandler]
|
||||
public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event, GameEventInfo info)
|
||||
{
|
||||
checkLastGuard(@event.Userid);
|
||||
return HookResult.Continue;
|
||||
}
|
||||
return aliveTerrorists
|
||||
.Select(player => player.PlayerPawn?.Value?.Health ?? 0)
|
||||
.Select(playerHealth => (int)(Math.Min(playerHealth, 200) * 0.8))
|
||||
.Sum();
|
||||
}
|
||||
|
||||
private void checkLastGuard(CCSPlayerController? poi)
|
||||
{
|
||||
if (poi == null) return;
|
||||
if (poi.Team != CsTeam.CounterTerrorist) return;
|
||||
var aliveCts = Utilities.GetPlayers()
|
||||
.Count(plr => plr.IsReal() && plr is { PawnIsAlive: true, Team: CsTeam.CounterTerrorist }) - 1;
|
||||
public void StartLastGuard(CCSPlayerController lastGuard) {
|
||||
var guardPlayerPawn = lastGuard.PlayerPawn.Value;
|
||||
|
||||
if (aliveCts != 1 || lrManager.IsLREnabled) return;
|
||||
var lastGuard = Utilities.GetPlayers().First(plr =>
|
||||
plr.IsReal() && plr != poi && plr is { PawnIsAlive: true, Team: CsTeam.CounterTerrorist });
|
||||
if (guardPlayerPawn == null || !guardPlayerPawn.IsValid) return;
|
||||
|
||||
if (canStart)
|
||||
StartLastGuard(lastGuard);
|
||||
}
|
||||
var guardCalcHealth = CalculateHealth();
|
||||
|
||||
[GameEventHandler]
|
||||
public HookResult OnRoundStartEvent(EventRoundStart @event, GameEventInfo info)
|
||||
{
|
||||
canStart = Utilities.GetPlayers()
|
||||
.Count(plr => plr.IsReal() && plr is { PawnIsAlive: true, Team: CsTeam.CounterTerrorist }) >=
|
||||
config.MinimumCTs;
|
||||
return HookResult.Continue;
|
||||
}
|
||||
guardPlayerPawn.Health = guardCalcHealth;
|
||||
Utilities.SetStateChanged(guardPlayerPawn, "CBaseEntity", "m_iHealth");
|
||||
|
||||
public int CalculateHealth()
|
||||
{
|
||||
var aliveTerrorists = Utilities.GetPlayers()
|
||||
.Where(plr => plr.IsReal() && plr is { PawnIsAlive: true, Team: CsTeam.Terrorist }).ToList();
|
||||
// foreach (var player in Utilities.GetPlayers().Where(p => p.IsReal()))
|
||||
// player.ExecuteClientCommand("play sounds/lastct");
|
||||
|
||||
return aliveTerrorists.Select(player => player.PlayerPawn?.Value?.Health ?? 0)
|
||||
.Select(playerHealth => (int)(Math.Min(playerHealth, 200) * 0.8)).Sum();
|
||||
}
|
||||
var aliveTerrorists = Utilities.GetPlayers()
|
||||
.Where(p
|
||||
=> p.IsReal() && p is { PawnIsAlive: true, Team: CsTeam.Terrorist })
|
||||
.ToList();
|
||||
|
||||
public void StartLastGuard(CCSPlayerController lastGuard)
|
||||
{
|
||||
var guardPlayerPawn = lastGuard.PlayerPawn.Value;
|
||||
var prisonerHp =
|
||||
aliveTerrorists.Sum(prisoner => prisoner.PlayerPawn?.Value?.Health ?? 0);
|
||||
|
||||
if (guardPlayerPawn == null || !guardPlayerPawn.IsValid) return;
|
||||
notifications.LGStarted(guardCalcHealth, prisonerHp)
|
||||
.ToAllCenter()
|
||||
.ToAllChat();
|
||||
|
||||
var guardCalcHealth = CalculateHealth();
|
||||
if (string.IsNullOrEmpty(config.LastGuardWeapon)) return;
|
||||
|
||||
guardPlayerPawn.Health = guardCalcHealth;
|
||||
Utilities.SetStateChanged(guardPlayerPawn, "CBaseEntity", "m_iHealth");
|
||||
foreach (var player in aliveTerrorists)
|
||||
player.GiveNamedItem(config.LastGuardWeapon);
|
||||
}
|
||||
|
||||
// foreach (var player in Utilities.GetPlayers().Where(p => p.IsReal()))
|
||||
// player.ExecuteClientCommand("play sounds/lastct");
|
||||
[GameEventHandler]
|
||||
public HookResult OnPlayerDeathEvent(EventPlayerDeath @event,
|
||||
GameEventInfo info) {
|
||||
checkLastGuard(@event.Userid);
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
var aliveTerrorists = Utilities.GetPlayers()
|
||||
.Where(p => p.IsReal() && p is { PawnIsAlive: true, Team: CsTeam.Terrorist }).ToList();
|
||||
[GameEventHandler]
|
||||
public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event,
|
||||
GameEventInfo info) {
|
||||
checkLastGuard(@event.Userid);
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
var prisonerHp = aliveTerrorists.Sum(prisoner => prisoner.PlayerPawn?.Value?.Health ?? 0);
|
||||
private void checkLastGuard(CCSPlayerController? poi) {
|
||||
if (poi == null) return;
|
||||
if (poi.Team != CsTeam.CounterTerrorist) return;
|
||||
var aliveCts = Utilities.GetPlayers()
|
||||
.Count(plr
|
||||
=> plr.IsReal() && plr is {
|
||||
PawnIsAlive: true, Team: CsTeam.CounterTerrorist
|
||||
}) - 1;
|
||||
|
||||
notifications.LG_STARTED(guardCalcHealth, prisonerHp).ToAllCenter().ToAllChat();
|
||||
if (aliveCts != 1 || lrManager.IsLREnabled) return;
|
||||
var lastGuard = Utilities.GetPlayers()
|
||||
.First(plr => plr.IsReal() && plr != poi && plr is {
|
||||
PawnIsAlive: true, Team: CsTeam.CounterTerrorist
|
||||
});
|
||||
|
||||
if (string.IsNullOrEmpty(config.LastGuardWeapon)) return;
|
||||
if (canStart) StartLastGuard(lastGuard);
|
||||
}
|
||||
|
||||
foreach (var player in aliveTerrorists)
|
||||
{
|
||||
player.GiveNamedItem(config.LastGuardWeapon);
|
||||
}
|
||||
}
|
||||
[GameEventHandler]
|
||||
public HookResult OnRoundStartEvent(EventRoundStart @event,
|
||||
GameEventInfo info) {
|
||||
canStart = Utilities.GetPlayers()
|
||||
.Count(plr
|
||||
=> plr.IsReal() && plr is {
|
||||
PawnIsAlive: true, Team: CsTeam.CounterTerrorist
|
||||
}) >= config.MinimumCTs;
|
||||
return HookResult.Continue;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Core.Attributes.Registration;
|
||||
using CounterStrikeSharp.API.Modules.Commands;
|
||||
using Jailbreak.Formatting.Extensions;
|
||||
using Jailbreak.Formatting.Views;
|
||||
using Jailbreak.Public.Behaviors;
|
||||
using Jailbreak.Public.Mod.LastRequest;
|
||||
using Jailbreak.Public.Mod.LastRequest.Enums;
|
||||
|
||||
namespace Jailbreak.LastRequest;
|
||||
|
||||
public class EndRaceCommand(ILastRequestManager lrManager) : IPluginBehavior {
|
||||
public class EndRaceCommand(ILastRequestManager lrManager,
|
||||
IRaceLRMessages messages) : IPluginBehavior {
|
||||
[ConsoleCommand("css_endrace", "Used to set the end point of a race LR")]
|
||||
[CommandHelper(whoCanExecute: CommandUsage.CLIENT_ONLY)]
|
||||
public void Command_EndRace(CCSPlayerController? executor, CommandInfo info) {
|
||||
@@ -15,13 +18,12 @@ public class EndRaceCommand(ILastRequestManager lrManager) : IPluginBehavior {
|
||||
var lr = lrManager.GetActiveLR(executor);
|
||||
|
||||
if (lr is not { Type: LRType.RACE }) {
|
||||
info.ReplyToCommand("You must be in a race LR to use this command.");
|
||||
messages.NotInRaceLR().ToPlayerChat(executor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (lr.State != LRState.PENDING) {
|
||||
info.ReplyToCommand(
|
||||
"You must be in the pending state to use this command.");
|
||||
messages.NotInPendingState().ToPlayerChat(executor);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,28 +31,29 @@ public class LastRequestCommand(ILastRequestManager manager,
|
||||
public void Command_LastRequest(CCSPlayerController? executor,
|
||||
CommandInfo info) {
|
||||
if (executor == null || !executor.IsReal()) return;
|
||||
if (executor.Team != CsTeam.Terrorist) {
|
||||
info.ReplyToCommand("You must be a terrorist to LR.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!executor.PawnIsAlive) {
|
||||
info.ReplyToCommand("You must be alive to LR.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!manager.IsLREnabled) {
|
||||
messages.LastRequestNotEnabled().ToPlayerChat(executor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (executor.Team != CsTeam.Terrorist) {
|
||||
messages.CannotLR("You are not a Prisoner").ToPlayerChat(executor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!executor.PawnIsAlive) {
|
||||
messages.CannotLR("You are not alive").ToPlayerChat(executor);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!playerSelector!.WouldHavePlayers()) {
|
||||
info.ReplyToCommand("There are no players available to LR.");
|
||||
messages.CannotLR("No players available to LR").ToPlayerChat(executor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (manager.IsInLR(executor)) {
|
||||
info.ReplyToCommand("You are already in an LR!");
|
||||
messages.CannotLR("You are already in an LR").ToPlayerChat(executor);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -89,23 +90,18 @@ public class LastRequestCommand(ILastRequestManager manager,
|
||||
|
||||
var player = target.Players.First();
|
||||
if (player.Team != CsTeam.CounterTerrorist) {
|
||||
messages.InvalidPlayerChoice(player, "They're not on CT!");
|
||||
messages.CannotLR(player, "They are not a Guard").ToPlayerChat(executor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.PawnIsAlive) {
|
||||
messages.InvalidPlayerChoice(player, "They're not alive!");
|
||||
messages.CannotLR(player, "They are not alive").ToPlayerChat(executor);
|
||||
return;
|
||||
}
|
||||
|
||||
if (manager.IsInLR(player)) {
|
||||
messages.InvalidPlayerChoice(player, "They're already in an LR!");
|
||||
return;
|
||||
}
|
||||
|
||||
//One final check in case they got the menu open in the last round
|
||||
if (!manager.IsLREnabled) {
|
||||
messages.LastRequestNotEnabled().ToPlayerChat(executor);
|
||||
messages.CannotLR(player, "They are already in an LR")
|
||||
.ToPlayerChat(executor);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,14 +31,13 @@ public class LastRequestManager(LastRequestConfig config,
|
||||
// Neither of them is in an LR
|
||||
return false;
|
||||
|
||||
if (playerLR == null != (attackerLR == null)) {
|
||||
if ((playerLR == null) != (attackerLR == null)) {
|
||||
// One of them is in an LR
|
||||
messages.DamageBlockedInsideLastRequest.ToPlayerCenter(attacker);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Both of them are in LR
|
||||
// verify they're in same LR
|
||||
// Both of them are in LR, verify they're in same LR
|
||||
if (playerLR == null) return false;
|
||||
|
||||
if (playerLR.Prisoner.Equals(attacker) || playerLR.Guard.Equals(attacker))
|
||||
@@ -75,31 +74,25 @@ public class LastRequestManager(LastRequestConfig config,
|
||||
|
||||
public bool InitiateLastRequest(CCSPlayerController prisoner,
|
||||
CCSPlayerController guard, LRType type) {
|
||||
try {
|
||||
var lr = factory!.CreateLastRequest(prisoner, guard, type);
|
||||
lr.Setup();
|
||||
ActiveLRs.Add(lr);
|
||||
var lr = factory!.CreateLastRequest(prisoner, guard, type);
|
||||
lr.Setup();
|
||||
ActiveLRs.Add(lr);
|
||||
|
||||
if (prisoner.Pawn.Value != null) {
|
||||
prisoner.Pawn.Value.Health = 100;
|
||||
prisoner.PlayerPawn.Value!.ArmorValue = 0;
|
||||
Utilities.SetStateChanged(prisoner.Pawn.Value, "CBaseEntity",
|
||||
"m_iHealth");
|
||||
}
|
||||
|
||||
|
||||
if (guard.Pawn.Value != null) {
|
||||
guard.Pawn.Value.Health = 100;
|
||||
guard.PlayerPawn.Value!.ArmorValue = 0;
|
||||
Utilities.SetStateChanged(guard.Pawn.Value, "CBaseEntity", "m_iHealth");
|
||||
}
|
||||
|
||||
messages.InformLastRequest(lr).ToAllChat();
|
||||
return true;
|
||||
} catch (ArgumentException e) {
|
||||
Console.WriteLine(e);
|
||||
return false;
|
||||
if (prisoner.Pawn.Value != null) {
|
||||
prisoner.Pawn.Value.Health = 100;
|
||||
prisoner.PlayerPawn.Value!.ArmorValue = 0;
|
||||
Utilities.SetStateChanged(prisoner.Pawn.Value, "CBaseEntity",
|
||||
"m_iHealth");
|
||||
}
|
||||
|
||||
if (guard.Pawn.Value != null) {
|
||||
guard.Pawn.Value.Health = 100;
|
||||
guard.PlayerPawn.Value!.ArmorValue = 0;
|
||||
Utilities.SetStateChanged(guard.Pawn.Value, "CBaseEntity", "m_iHealth");
|
||||
}
|
||||
|
||||
messages.InformLastRequest(lr).ToAllChat();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool EndLastRequest(AbstractLastRequest lr, LRResult result) {
|
||||
@@ -156,11 +149,11 @@ public class LastRequestManager(LastRequestConfig config,
|
||||
if (IsLREnabled) {
|
||||
// Handle active LRs
|
||||
var activeLr = ((ILastRequestManager)this).GetActiveLR(player);
|
||||
if (activeLr != null && activeLr.State != LRState.COMPLETED) {
|
||||
var isPrisoner = activeLr.Prisoner.Slot == player.Slot;
|
||||
EndLastRequest(activeLr,
|
||||
isPrisoner ? LRResult.GUARD_WIN : LRResult.PRISONER_WIN);
|
||||
}
|
||||
if (activeLr == null || activeLr.State == LRState.COMPLETED)
|
||||
return HookResult.Continue;
|
||||
var isPrisoner = activeLr.Prisoner.Slot == player.Slot;
|
||||
EndLastRequest(activeLr,
|
||||
isPrisoner ? LRResult.GUARD_WIN : LRResult.PRISONER_WIN);
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
@@ -184,15 +177,15 @@ public class LastRequestManager(LastRequestConfig config,
|
||||
if (!player.IsReal() || ServerExtensions.GetGameRules().WarmupPeriod)
|
||||
return HookResult.Continue;
|
||||
|
||||
if (IsLREnabled) return HookResult.Continue;
|
||||
if (IsLREnabled) {
|
||||
var activeLr = ((ILastRequestManager)this).GetActiveLR(player);
|
||||
if (activeLr != null) {
|
||||
EndLastRequest(activeLr,
|
||||
player.Team == CsTeam.Terrorist ?
|
||||
LRResult.GUARD_WIN :
|
||||
LRResult.PRISONER_WIN);
|
||||
}
|
||||
|
||||
var activeLr = ((ILastRequestManager)this).GetActiveLR(player);
|
||||
|
||||
if (activeLr != null && activeLr.State != LRState.ACTIVE) {
|
||||
EndLastRequest(activeLr,
|
||||
player.Team == CsTeam.Terrorist ?
|
||||
LRResult.GUARD_WIN :
|
||||
LRResult.PRISONER_WIN);
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,13 +13,12 @@ public class LastRequestPlayerSelector(ILastRequestManager manager,
|
||||
Func<string?, string> command) {
|
||||
var menu = new CenterHtmlMenu(command.Invoke("[Player]"), plugin);
|
||||
|
||||
foreach (var target in Utilities.GetPlayers()) {
|
||||
if (!target.IsReal()) continue;
|
||||
if (!target.PawnIsAlive
|
||||
|| target.Team != CsTeam.CounterTerrorist && !debug)
|
||||
continue;
|
||||
foreach (var target in Utilities.GetPlayers()
|
||||
.Where(target => target.IsReal())
|
||||
.Where(target => target.PawnIsAlive
|
||||
&& (target.Team == CsTeam.CounterTerrorist || debug))) {
|
||||
menu.AddMenuOption(target.PlayerName,
|
||||
(_, _) => OnSelect(player, command, target.UserId.ToString()),
|
||||
(_, _) => onSelect(player, command, target.UserId.ToString()),
|
||||
!debug && manager.IsInLR(target));
|
||||
}
|
||||
|
||||
@@ -33,7 +32,7 @@ public class LastRequestPlayerSelector(ILastRequestManager manager,
|
||||
});
|
||||
}
|
||||
|
||||
private void OnSelect(CCSPlayerController player,
|
||||
private void onSelect(CCSPlayerController player,
|
||||
Func<string?, string> command, string? value) {
|
||||
MenuManager.CloseActiveMenu(player);
|
||||
player.ExecuteClientCommandFromServer(command.Invoke(value));
|
||||
|
||||
@@ -53,11 +53,13 @@ public class LogEntityParentListeners(IRichLogService logs) : IPluginBehavior {
|
||||
?.OriginalController.Get();
|
||||
if (weaponPickerUpper == null) return;
|
||||
|
||||
if (weaponPickerUpper == weaponOwner)
|
||||
{
|
||||
logs.Append(weaponPickerUpper, $"picked up their {weaponEntity.ToFriendlyString()}");
|
||||
return;
|
||||
if (weaponPickerUpper == weaponOwner) {
|
||||
logs.Append(weaponPickerUpper,
|
||||
$"picked up their {weaponEntity.ToFriendlyString()}");
|
||||
return;
|
||||
}
|
||||
logs.Append(weaponPickerUpper, "picked up", logs.Player(weaponOwner), $"{weaponEntity.ToFriendlyString()}");
|
||||
|
||||
logs.Append(weaponPickerUpper, "picked up", logs.Player(weaponOwner),
|
||||
$"{weaponEntity.ToFriendlyString()}");
|
||||
}
|
||||
}
|
||||
@@ -11,19 +11,12 @@ using Jailbreak.Public.Extensions;
|
||||
|
||||
namespace Jailbreak.Logs;
|
||||
|
||||
public class LogsManager : IPluginBehavior, IRichLogService {
|
||||
public class LogsManager(ILogMessages messages, IRichPlayerTag richPlayerTag)
|
||||
: IPluginBehavior, IRichLogService {
|
||||
private readonly List<IView> logMessages = [];
|
||||
private readonly ILogMessages messages;
|
||||
|
||||
private readonly IRichPlayerTag richPlayerTag;
|
||||
|
||||
public LogsManager(ILogMessages messages, IRichPlayerTag richPlayerTag) {
|
||||
this.messages = messages;
|
||||
this.richPlayerTag = richPlayerTag;
|
||||
}
|
||||
|
||||
public void Append(string message) {
|
||||
logMessages.Add(messages.CREATE_LOG(message));
|
||||
logMessages.Add(messages.CreateLog(message));
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetMessages() {
|
||||
@@ -37,7 +30,6 @@ public class LogsManager : IPluginBehavior, IRichLogService {
|
||||
messages.BeginJailbreakLogs.ToServerConsole();
|
||||
foreach (var log in logMessages) log.ToServerConsole();
|
||||
messages.EndJailbreakLogs.ToServerConsole();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -48,7 +40,7 @@ public class LogsManager : IPluginBehavior, IRichLogService {
|
||||
}
|
||||
|
||||
public void Append(params FormatObject[] objects) {
|
||||
logMessages.Add(messages.CREATE_LOG(objects));
|
||||
logMessages.Add(messages.CreateLog(objects));
|
||||
}
|
||||
|
||||
public FormatObject Player(CCSPlayerController playerController) {
|
||||
@@ -67,7 +59,6 @@ public class LogsManager : IPluginBehavior, IRichLogService {
|
||||
foreach (var log in logMessages) log.ToServerConsole().ToAllConsole();
|
||||
|
||||
messages.EndJailbreakLogs.ToServerConsole().ToAllConsole();
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,15 +13,15 @@ public static class LogsServiceExtension {
|
||||
services.AddTransient<ILogService>(provider
|
||||
=> provider.GetRequiredService<IRichLogService>());
|
||||
|
||||
services.AddPluginBehavior<LogsCommand>();
|
||||
services.AddPluginBehavior<LogsCommand>();
|
||||
|
||||
|
||||
services.AddPluginBehavior<LogEntityListeners>();
|
||||
services.AddPluginBehavior<LogDamageListeners>();
|
||||
services.AddPluginBehavior<LogEntityParentListeners>();
|
||||
services.AddPluginBehavior<LogEntityListeners>();
|
||||
services.AddPluginBehavior<LogDamageListeners>();
|
||||
services.AddPluginBehavior<LogEntityParentListeners>();
|
||||
|
||||
// PlayerTagHelper is a lower-level class that avoids dependency loops.
|
||||
services.AddTransient<IRichPlayerTag, PlayerTagHelper>();
|
||||
services.AddTransient<IPlayerTag, PlayerTagHelper>();
|
||||
}
|
||||
// PlayerTagHelper is a lower-level class that avoids dependency loops.
|
||||
services.AddTransient<IRichPlayerTag, PlayerTagHelper>();
|
||||
services.AddTransient<IPlayerTag, PlayerTagHelper>();
|
||||
}
|
||||
}
|
||||
@@ -10,21 +10,17 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Jailbreak.Logs.Tags;
|
||||
|
||||
public class PlayerTagHelper : IRichPlayerTag {
|
||||
private readonly Lazy<IRebelService> rebelService;
|
||||
private readonly Lazy<ISpecialTreatmentService> stService;
|
||||
private readonly Lazy<IWardenService> wardenService;
|
||||
public class PlayerTagHelper(IServiceProvider provider) : IRichPlayerTag {
|
||||
private readonly Lazy<IRebelService> rebelService =
|
||||
new(provider.GetRequiredService<IRebelService>);
|
||||
|
||||
public PlayerTagHelper(IServiceProvider provider) {
|
||||
// Lazy-load dependencies to avoid loops, since we are a lower-level class.
|
||||
wardenService =
|
||||
new Lazy<IWardenService>(provider.GetRequiredService<IWardenService>);
|
||||
rebelService =
|
||||
new Lazy<IRebelService>(provider.GetRequiredService<IRebelService>);
|
||||
stService =
|
||||
new Lazy<ISpecialTreatmentService>(provider
|
||||
.GetRequiredService<ISpecialTreatmentService>);
|
||||
}
|
||||
private readonly Lazy<ISpecialTreatmentService> stService =
|
||||
new(provider.GetRequiredService<ISpecialTreatmentService>);
|
||||
|
||||
private readonly Lazy<IWardenService> wardenService =
|
||||
new(provider.GetRequiredService<IWardenService>);
|
||||
|
||||
// Lazy-load dependencies to avoid loops, since we are a lower-level class.
|
||||
|
||||
public FormatObject Rich(CCSPlayerController player) {
|
||||
if (wardenService.Value.IsWarden(player))
|
||||
|
||||
@@ -162,18 +162,16 @@ public class MuteSystem(IServiceProvider provider)
|
||||
return;
|
||||
}
|
||||
|
||||
if (bypassMute(player)) {
|
||||
// Warn admins if they're not muted
|
||||
if (IsPeaceEnabled()) {
|
||||
if (player.Team == CsTeam.CounterTerrorist
|
||||
&& DateTime.Now >= ctPeaceEnd)
|
||||
return;
|
||||
messages!.PeaceReminder.ToPlayerCenter(player);
|
||||
}
|
||||
if (!bypassMute(player)) return;
|
||||
|
||||
if (!player.PawnIsAlive)
|
||||
messages!.AdminDeadReminder.ToPlayerCenter(player);
|
||||
// Warn admins if they're not muted
|
||||
if (IsPeaceEnabled()) {
|
||||
if (player.Team == CsTeam.CounterTerrorist && DateTime.Now >= ctPeaceEnd)
|
||||
return;
|
||||
messages!.PeaceReminder.ToPlayerCenter(player);
|
||||
}
|
||||
|
||||
if (!player.PawnIsAlive) messages!.AdminDeadReminder.ToPlayerCenter(player);
|
||||
}
|
||||
|
||||
private bool isMuted(CCSPlayerController player) {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class PeaceCommandsBehavior(IWardenService warden, IMuteService mute,
|
||||
|
||||
if (!warden.IsWarden(executor)
|
||||
&& !AdminManager.PlayerHasPermissions(executor, "@css/chat")) {
|
||||
notifications.NOT_WARDEN.ToPlayerChat(executor);
|
||||
notifications.NotWarden.ToPlayerChat(executor);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class RollCommandBehavior(IWardenService warden,
|
||||
if (player == null) return;
|
||||
|
||||
if (!warden.IsWarden(player)) {
|
||||
wardenNotifications.NOT_WARDEN.ToPlayerChat(player);
|
||||
wardenNotifications.NotWarden.ToPlayerChat(player);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class SpecialTreatmentCommandsBehavior(IWardenService warden,
|
||||
if (player == null) return;
|
||||
|
||||
if (!warden.IsWarden(player)) {
|
||||
wardenNotifs.NOT_WARDEN.ToPlayerChat(player).ToPlayerConsole(player);
|
||||
wardenNotifs.NotWarden.ToPlayerChat(player).ToPlayerConsole(player);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,14 +34,14 @@ public class WardenCommandsBehavior(IWardenNotifications notifications,
|
||||
if (!warden.IsWarden(player)) return;
|
||||
|
||||
// Handle warden pass
|
||||
notifications.PASS_WARDEN(player).ToAllChat().ToAllCenter();
|
||||
notifications.PassWarden(player).ToAllChat().ToAllCenter();
|
||||
|
||||
// GetPlayers() returns valid players, no need to error check here.
|
||||
foreach (var clients in Utilities.GetPlayers())
|
||||
clients.ExecuteClientCommand(
|
||||
$"play sounds/{config.WardenPassedSoundName}");
|
||||
|
||||
notifications.BECOME_NEXT_WARDEN.ToAllChat();
|
||||
notifications.BecomeNextWarden.ToAllChat();
|
||||
|
||||
if (!warden.TryRemoveWarden(true))
|
||||
Server.PrintToChatAll("[BUG] Couldn't remove warden :^(");
|
||||
@@ -55,7 +55,7 @@ public class WardenCommandsBehavior(IWardenNotifications notifications,
|
||||
if (player == null) return;
|
||||
|
||||
if (!warden.HasWarden || warden.Warden == null) {
|
||||
notifications.CURRENT_WARDEN(null).ToPlayerChat(player);
|
||||
notifications.CurrentWarden(null).ToPlayerChat(player);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -66,15 +66,15 @@ public class WardenCommandsBehavior(IWardenNotifications notifications,
|
||||
|
||||
foreach (var client in Utilities.GetPlayers().Where(p => p.IsReal())) {
|
||||
if (AdminManager.PlayerHasPermissions(client, "@css/chat"))
|
||||
notifications.FIRE_WARDEN(warden.Warden, player).ToPlayerChat(client);
|
||||
notifications.FireWarden(warden.Warden, player).ToPlayerChat(client);
|
||||
else
|
||||
notifications.FIRE_WARDEN(warden.Warden).ToPlayerChat(client);
|
||||
notifications.FireWarden(warden.Warden).ToPlayerChat(client);
|
||||
|
||||
client.ExecuteClientCommand(
|
||||
$"play sounds/{config.WardenPassedSoundName}");
|
||||
}
|
||||
|
||||
notifications.BECOME_NEXT_WARDEN.ToAllChat();
|
||||
notifications.BecomeNextWarden.ToAllChat();
|
||||
|
||||
lastPassCommand[warden.Warden] = DateTime.Now;
|
||||
|
||||
@@ -106,13 +106,13 @@ public class WardenCommandsBehavior(IWardenNotifications notifications,
|
||||
if (queue.Active) {
|
||||
if (!queue.InQueue(player)) {
|
||||
if (queue.TryEnter(player))
|
||||
notifications.JOIN_RAFFLE.ToPlayerChat(player);
|
||||
notifications.JoinRaffle.ToPlayerChat(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (queue.InQueue(player))
|
||||
if (queue.TryExit(player))
|
||||
notifications.LEAVE_RAFFLE.ToPlayerChat(player);
|
||||
notifications.LeaveRaffle.ToPlayerChat(player);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class WardenCommandsBehavior(IWardenNotifications notifications,
|
||||
if (warden.TrySetWarden(player))
|
||||
return;
|
||||
|
||||
notifications.CURRENT_WARDEN(warden.Warden).ToPlayerChat(player);
|
||||
notifications.CurrentWarden(warden.Warden).ToPlayerChat(player);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace Jailbreak.Warden.Extensions;
|
||||
|
||||
public class WardenFormatWriterExtensions { }
|
||||
@@ -71,7 +71,7 @@ public class WardenBehavior(ILogger<WardenBehavior> logger,
|
||||
"m_clrRender");
|
||||
}
|
||||
|
||||
notifications.NEW_WARDEN(Warden).ToAllChat().ToAllCenter();
|
||||
notifications.NewWarden(Warden).ToAllChat().ToAllCenter();
|
||||
|
||||
Warden.PlayerName = "[WARDEN] " + Warden.PlayerName;
|
||||
|
||||
@@ -175,7 +175,7 @@ public class WardenBehavior(ILogger<WardenBehavior> logger,
|
||||
logger.LogWarning("[Warden] BUG: Problem removing current warden :^(");
|
||||
|
||||
// Warden died!
|
||||
notifications.WARDEN_DIED.ToAllChat().ToAllCenter();
|
||||
notifications.WardenDied.ToAllChat().ToAllCenter();
|
||||
|
||||
foreach (var player in Utilities.GetPlayers()) {
|
||||
if (!player.IsReal()) continue;
|
||||
@@ -183,7 +183,7 @@ public class WardenBehavior(ILogger<WardenBehavior> logger,
|
||||
$"play sounds/{config.WardenKilledSoundName}");
|
||||
}
|
||||
|
||||
notifications.BECOME_NEXT_WARDEN.ToAllChat();
|
||||
notifications.BecomeNextWarden.ToAllChat();
|
||||
|
||||
unblueTimer
|
||||
?.Kill(); // If the warden dies withing 3 seconds of becoming warden, we need to cancel the unblue timer
|
||||
@@ -331,7 +331,7 @@ public class WardenBehavior(ILogger<WardenBehavior> logger,
|
||||
logger.LogWarning("[Warden] BUG: Problem removing current warden :^(");
|
||||
|
||||
|
||||
notifications.WARDEN_LEFT.ToAllChat().ToAllCenter();
|
||||
notifications.WardenLeft.ToAllChat().ToAllCenter();
|
||||
|
||||
foreach (var player in Utilities.GetPlayers()) {
|
||||
if (!player.IsReal()) continue;
|
||||
@@ -339,7 +339,7 @@ public class WardenBehavior(ILogger<WardenBehavior> logger,
|
||||
$"play sounds/{config.WardenPassedSoundName}");
|
||||
}
|
||||
|
||||
notifications.BECOME_NEXT_WARDEN.ToAllChat();
|
||||
notifications.BecomeNextWarden.ToAllChat();
|
||||
|
||||
return HookResult.Continue;
|
||||
}
|
||||
|
||||
@@ -9,9 +9,8 @@ using Jailbreak.Public.Mod.Warden;
|
||||
|
||||
namespace Jailbreak.Warden.Markers;
|
||||
|
||||
public class WardenMarkerBehavior : IPluginBehavior {
|
||||
public class WardenMarkerBehavior(IWardenService warden) : IPluginBehavior {
|
||||
private const float MIN_RADIUS = 60f, MAX_RADIUS = 360f;
|
||||
private readonly IWardenService warden;
|
||||
|
||||
private Vector? currentPos;
|
||||
|
||||
@@ -19,8 +18,6 @@ public class WardenMarkerBehavior : IPluginBehavior {
|
||||
private long placementTime;
|
||||
private float radius = MIN_RADIUS;
|
||||
|
||||
public WardenMarkerBehavior(IWardenService warden) { this.warden = warden; }
|
||||
|
||||
public void Start(BasePlugin basePlugin) {
|
||||
marker = new BeamCircle(basePlugin, new Vector(), 60f, (int)Math.PI * 15);
|
||||
basePlugin.AddCommandListener("player_ping", CommandListener_PlayerPing);
|
||||
|
||||
@@ -8,13 +8,11 @@ using Jailbreak.Public.Mod.Warden;
|
||||
|
||||
namespace Jailbreak.Warden.Paint;
|
||||
|
||||
public class WardenPaintBehavior : IPluginBehavior {
|
||||
private readonly IWardenService wardenService;
|
||||
public class WardenPaintBehavior(IWardenService wardenService)
|
||||
: IPluginBehavior {
|
||||
private Vector? lastPosition;
|
||||
private BasePlugin? parent;
|
||||
|
||||
public WardenPaintBehavior(IWardenService warden) { wardenService = warden; }
|
||||
|
||||
public void Start(BasePlugin basePlugin) {
|
||||
parent = basePlugin;
|
||||
basePlugin.RegisterListener<Listeners.OnTick>(paint);
|
||||
|
||||
@@ -82,7 +82,7 @@ public class
|
||||
// Enable the warden queue
|
||||
queueInactive = false;
|
||||
|
||||
notifications.PICKING_SHORTLY.ToAllChat();
|
||||
notifications.PickingShortly.ToAllChat();
|
||||
|
||||
// Start a timer to pick the warden in 7 seconds
|
||||
ScheduleChooseWarden();
|
||||
@@ -109,7 +109,7 @@ public class
|
||||
eligible);
|
||||
|
||||
if (eligible.Count == 0) {
|
||||
notifications.NO_WARDENS.ToAllChat();
|
||||
notifications.NoWardens.ToAllChat();
|
||||
queueInactive = true;
|
||||
|
||||
return;
|
||||
|
||||
@@ -27,7 +27,7 @@ public class SpecialTreatmentBehavior(IPlayerStateFactory factory,
|
||||
sts.Get(player).HasSpecialTreatment = true;
|
||||
|
||||
if (rebel.IsRebel(player)) rebel.UnmarkRebel(player);
|
||||
setSpecialColor(player, /* hasSt */ true);
|
||||
setSpecialColor(player, true);
|
||||
|
||||
notifications.Granted.ToPlayerChat(player).ToPlayerCenter(player);
|
||||
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
namespace Jailbreak.Formatting.Views;
|
||||
|
||||
public interface ILastGuardNotifications {
|
||||
public IView LG_STARTED(int ctHealth, int tHealth);
|
||||
public IView LGStarted(int ctHealth, int tHealth);
|
||||
}
|
||||
@@ -16,4 +16,6 @@ public interface ILastRequestMessages {
|
||||
public IView InformLastRequest(AbstractLastRequest lr);
|
||||
public IView AnnounceLastRequest(AbstractLastRequest lr);
|
||||
public IView LastRequestDecided(AbstractLastRequest lr, LRResult result);
|
||||
public IView CannotLR(string reason);
|
||||
public IView CannotLR(CCSPlayerController player, string reason);
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public interface ILogMessages {
|
||||
return new StringFormatObject($"[{minutes}:{seconds}]", ChatColors.Gold);
|
||||
}
|
||||
|
||||
public IView CREATE_LOG(params FormatObject[] objects) {
|
||||
public IView CreateLog(params FormatObject[] objects) {
|
||||
return new SimpleView { Time(), objects };
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,8 @@ public interface IRaceLRMessages {
|
||||
public IView EndRaceInstruction { get; }
|
||||
|
||||
public IView RaceStartingMessage(CCSPlayerController prisoner);
|
||||
|
||||
public IView NotInRaceLR();
|
||||
|
||||
public IView NotInPendingState();
|
||||
}
|
||||
@@ -6,29 +6,29 @@ using Jailbreak.Formatting.Base;
|
||||
namespace Jailbreak.Formatting.Views;
|
||||
|
||||
public interface IWardenNotifications {
|
||||
public IView PICKING_SHORTLY { get; }
|
||||
public IView NO_WARDENS { get; }
|
||||
public IView WARDEN_LEFT { get; }
|
||||
public IView WARDEN_DIED { get; }
|
||||
public IView BECOME_NEXT_WARDEN { get; }
|
||||
public IView JOIN_RAFFLE { get; }
|
||||
public IView LEAVE_RAFFLE { get; }
|
||||
public IView NOT_WARDEN { get; }
|
||||
public IView FIRE_COMMAND_FAILED { get; }
|
||||
public IView PickingShortly { get; }
|
||||
public IView NoWardens { get; }
|
||||
public IView WardenLeft { get; }
|
||||
public IView WardenDied { get; }
|
||||
public IView BecomeNextWarden { get; }
|
||||
public IView JoinRaffle { get; }
|
||||
public IView LeaveRaffle { get; }
|
||||
public IView NotWarden { get; }
|
||||
public IView FireCommandFailed { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a view for when the specified player passes warden
|
||||
/// </summary>
|
||||
/// <param name="player"></param>
|
||||
/// <returns></returns>
|
||||
public IView PASS_WARDEN(CCSPlayerController player);
|
||||
public IView PassWarden(CCSPlayerController player);
|
||||
|
||||
/// <summary>
|
||||
/// Create a view for when this player becomes a new warden
|
||||
/// </summary>
|
||||
/// <param name="player"></param>
|
||||
/// <returns></returns>
|
||||
public IView NEW_WARDEN(CCSPlayerController player);
|
||||
public IView NewWarden(CCSPlayerController player);
|
||||
|
||||
/// <summary>
|
||||
/// Format a response to a request about the current warden.
|
||||
@@ -36,12 +36,12 @@ public interface IWardenNotifications {
|
||||
/// </summary>
|
||||
/// <param name="player"></param>
|
||||
/// <returns></returns>
|
||||
public IView CURRENT_WARDEN(CCSPlayerController? player);
|
||||
public IView CurrentWarden(CCSPlayerController? player);
|
||||
|
||||
public IView FIRE_COMMAND_SUCCESS(CCSPlayerController player);
|
||||
public IView FireCommandSuccess(CCSPlayerController player);
|
||||
|
||||
public IView FIRE_WARDEN(CCSPlayerController player);
|
||||
public IView FireWarden(CCSPlayerController player);
|
||||
|
||||
public IView FIRE_WARDEN(CCSPlayerController player,
|
||||
public IView FireWarden(CCSPlayerController player,
|
||||
CCSPlayerController admin);
|
||||
}
|
||||
@@ -2,50 +2,84 @@ using CounterStrikeSharp.API.Core;
|
||||
|
||||
namespace Jailbreak.Public.Extensions;
|
||||
|
||||
public static class WeaponExtensions
|
||||
{
|
||||
public static string ToFriendlyString(this CCSWeaponBase weaponEntity)
|
||||
{
|
||||
var designerName = weaponEntity.DesignerName;
|
||||
switch (designerName)
|
||||
{
|
||||
case "weapon_ak47": return "AK47";
|
||||
case "weapon_aug": return "AUG";
|
||||
case "weapon_awp": return "AWP";
|
||||
case "weapon_bizon": return "Bizon";
|
||||
case "weapon_cz75a": return "CZ75";
|
||||
case "weapon_deagle": return "Desert Eagle";
|
||||
case "weapon_famas": return "Famas";
|
||||
case "weapon_fiveseven": return "Five Seven";
|
||||
case "weapon_g3sg1": return "G3SG1";
|
||||
case "weapon_galilar": return "Galil";
|
||||
case "weapon_glock": return "Glock 18";
|
||||
case "weapon_hkp2000": return "HPK2000";
|
||||
case "weapon_m249": return "M249";
|
||||
case "weapon_m4a1": return "M4A1";
|
||||
case "weapon_m4a1_silencer": return "M4A1S";
|
||||
case "weapon_m4a4": return "M4A4";
|
||||
case "weapon_mac10": return "MAC10";
|
||||
case "weapon_mag7": return "MAG7";
|
||||
case "weapon_mp5sd": return "MP5SD";
|
||||
case "weapon_mp7": return "MP7";
|
||||
case "weapon_mp9": return "MP9";
|
||||
case "weapon_negev": return "Negev";
|
||||
case "weapon_nova": return "Nova";
|
||||
case "weapon_p250": return "P250";
|
||||
case "weapon_p90": return "P90";
|
||||
case "weapon_revolver": return "Revolver";
|
||||
case "weapon_sawedoff": return "Sawed Off";
|
||||
case "weapon_scar20": return "Scar20";
|
||||
case "weapon_sg553": return "SG553";
|
||||
case "weapon_sg556": return "SG556";
|
||||
case "weapon_ssg08": return "SSG08";
|
||||
case "weapon_taser": return "Zeus";
|
||||
case "weapon_tec9": return "Tec9";
|
||||
case "weapon_ump45": return "UMP45";
|
||||
case "weapon_usp_silencer": return "USPS";
|
||||
case "weapon_xm1014": return "XM1014";
|
||||
default: return "UNKNOWN: Pleace Contact Tech";
|
||||
}
|
||||
public static class WeaponExtensions {
|
||||
public static string ToFriendlyString(this CCSWeaponBase weaponEntity) {
|
||||
var designerName = weaponEntity.DesignerName;
|
||||
switch (designerName) {
|
||||
case "weapon_ak47":
|
||||
return "AK47";
|
||||
case "weapon_aug":
|
||||
return "AUG";
|
||||
case "weapon_awp":
|
||||
return "AWP";
|
||||
case "weapon_bizon":
|
||||
return "Bizon";
|
||||
case "weapon_cz75a":
|
||||
return "CZ75";
|
||||
case "weapon_deagle":
|
||||
return "Desert Eagle";
|
||||
case "weapon_famas":
|
||||
return "Famas";
|
||||
case "weapon_fiveseven":
|
||||
return "Five Seven";
|
||||
case "weapon_g3sg1":
|
||||
return "G3SG1";
|
||||
case "weapon_galilar":
|
||||
return "Galil";
|
||||
case "weapon_glock":
|
||||
return "Glock 18";
|
||||
case "weapon_hkp2000":
|
||||
return "HPK2000";
|
||||
case "weapon_m249":
|
||||
return "M249";
|
||||
case "weapon_m4a1":
|
||||
return "M4A1";
|
||||
case "weapon_m4a1_silencer":
|
||||
return "M4A1S";
|
||||
case "weapon_m4a4":
|
||||
return "M4A4";
|
||||
case "weapon_mac10":
|
||||
return "MAC10";
|
||||
case "weapon_mag7":
|
||||
return "MAG7";
|
||||
case "weapon_mp5sd":
|
||||
return "MP5SD";
|
||||
case "weapon_mp7":
|
||||
return "MP7";
|
||||
case "weapon_mp9":
|
||||
return "MP9";
|
||||
case "weapon_negev":
|
||||
return "Negev";
|
||||
case "weapon_nova":
|
||||
return "Nova";
|
||||
case "weapon_p250":
|
||||
return "P250";
|
||||
case "weapon_p90":
|
||||
return "P90";
|
||||
case "weapon_revolver":
|
||||
return "Revolver";
|
||||
case "weapon_sawedoff":
|
||||
return "Sawed Off";
|
||||
case "weapon_scar20":
|
||||
return "Scar20";
|
||||
case "weapon_sg553":
|
||||
return "SG553";
|
||||
case "weapon_sg556":
|
||||
return "SG556";
|
||||
case "weapon_ssg08":
|
||||
return "SSG08";
|
||||
case "weapon_taser":
|
||||
return "Zeus";
|
||||
case "weapon_tec9":
|
||||
return "Tec9";
|
||||
case "weapon_ump45":
|
||||
return "UMP45";
|
||||
case "weapon_usp_silencer":
|
||||
return "USPS";
|
||||
case "weapon_xm1014":
|
||||
return "XM1014";
|
||||
default:
|
||||
return "UNKNOWN: Pleace Contact Tech";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.233" />
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.4" />
|
||||
<PackageReference Include="CounterStrikeSharp.API" Version="1.0.233"/>
|
||||
<PackageReference Include="System.Text.Json" Version="8.0.4"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user