-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
193 additions
and
2 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
lang/Jailbreak.English/Warden/SpecialTreatmentNotifications.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Modules.Utils; | ||
|
||
using Jailbreak.Formatting.Base; | ||
using Jailbreak.Formatting.Core; | ||
using Jailbreak.Formatting.Logistics; | ||
using Jailbreak.Formatting.Objects; | ||
using Jailbreak.Formatting.Views; | ||
|
||
namespace Jailbreak.English.Warden; | ||
|
||
public class SpecialTreatmentNotifications : ISpecialTreatmentNotifications, ILanguage<Formatting.Languages.English> | ||
{ | ||
public static FormatObject PREFIX = new HiddenFormatObject( $" {ChatColors.Lime}[{ChatColors.Green}ST{ChatColors.Lime}]" ) | ||
{ | ||
// Hide in panorama and center text | ||
Plain = false, | ||
Panorama = false, | ||
Chat = true, | ||
}; | ||
|
||
public IView GRANTED => | ||
new SimpleView { PREFIX, "You now have special treatment!" }; | ||
|
||
public IView REVOKED => | ||
new SimpleView { PREFIX, "Your special treatment was removed" }; | ||
|
||
public IView GRANTED_TO(CCSPlayerController player) | ||
{ | ||
return new SimpleView { PREFIX, player, "now has Special Treatment!" }; | ||
} | ||
|
||
public IView REVOKED_FROM(CCSPlayerController player) | ||
{ | ||
return new SimpleView { PREFIX, player, "no longer has Special Treatment." }; | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
mod/Jailbreak.Warden/Commands/SpecialTreatmentCommandsBehavior.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Core.Attributes.Registration; | ||
using CounterStrikeSharp.API.Modules.Commands; | ||
|
||
namespace Jailbreak.Warden.Commands; | ||
|
||
public class SpecialTreatmentCommandsBehavior | ||
{ | ||
|
||
[ConsoleCommand("css_treat", "Grant or revoke special treatment from a player")] | ||
[ConsoleCommand("css_st", "Grant or revoke special treatment from a player")] | ||
[CommandHelper(0, "css_st / css_treat <player>", CommandUsage.CLIENT_ONLY)] | ||
public void Command_Toggle(CCSPlayerController? player, CommandInfo command) | ||
{ | ||
|
||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
mod/Jailbreak.Warden/SpecialTreatment/SpecialTreatmentBehavior.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System.Drawing; | ||
|
||
using CounterStrikeSharp.API; | ||
using CounterStrikeSharp.API.Core; | ||
|
||
using Jailbreak.Formatting.Extensions; | ||
using Jailbreak.Formatting.Views; | ||
using Jailbreak.Public.Behaviors; | ||
using Jailbreak.Public.Generic; | ||
using Jailbreak.Public.Mod.Rebel; | ||
using Jailbreak.Public.Mod.Warden; | ||
|
||
namespace Jailbreak.Warden.SpecialTreatment; | ||
|
||
public class SpecialTreatmentBehavior : IPluginBehavior, ISpecialTreatmentService | ||
{ | ||
private IPlayerState<SpecialTreatmentState> _sts; | ||
private IRebelService _rebel; | ||
private ISpecialTreatmentNotifications _notifications; | ||
|
||
public SpecialTreatmentBehavior(IPlayerStateFactory factory, IRebelService rebel, ISpecialTreatmentNotifications notifications) | ||
{ | ||
_sts = factory.Round<SpecialTreatmentState>(); | ||
|
||
_rebel = rebel; | ||
_notifications = notifications; | ||
} | ||
|
||
private class SpecialTreatmentState | ||
{ | ||
public bool HasSpecialTreatment { get; set; } = false; | ||
} | ||
|
||
public bool IsSpecialTreatment(CCSPlayerController player) | ||
{ | ||
return _sts.Get(player) | ||
.HasSpecialTreatment; | ||
} | ||
|
||
public void Grant(CCSPlayerController player) | ||
{ | ||
// Player is already granted ST | ||
if (IsSpecialTreatment(player)) | ||
return; | ||
|
||
_sts.Get(player).HasSpecialTreatment = true; | ||
|
||
_rebel.UnmarkRebel(player); | ||
this.SetPlayerColor(player, /* hasSt */ true); | ||
|
||
_notifications.GRANTED | ||
.ToPlayerChat(player) | ||
.ToPlayerCenter(player); | ||
|
||
_notifications.GRANTED_TO(player) | ||
.ToAllChat(); | ||
} | ||
|
||
public void Revoke(CCSPlayerController player) | ||
{ | ||
// Player is already revoked | ||
if (!IsSpecialTreatment(player)) | ||
return; | ||
|
||
_sts.Get(player).HasSpecialTreatment = false; | ||
|
||
this.SetPlayerColor(player, /* hasSt */ false); | ||
|
||
_notifications.REVOKED | ||
.ToPlayerChat(player) | ||
.ToPlayerCenter(player); | ||
|
||
_notifications.REVOKED_FROM(player) | ||
.ToAllChat(); | ||
} | ||
|
||
private void SetPlayerColor(CCSPlayerController player, bool hasSt) | ||
{ | ||
if (!player.IsValid || player.Pawn.Value == null) | ||
return; | ||
|
||
var color = hasSt | ||
? Color.FromArgb(254, 150, 255, 150) | ||
: Color.FromArgb(254, 255, 255, 255); | ||
|
||
player.Pawn.Value.RenderMode = RenderMode_t.kRenderTransColor; | ||
player.Pawn.Value.Render = color; | ||
Utilities.SetStateChanged(player.Pawn.Value, "CBaseModelEntity", "m_clrRender"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
public/Jailbreak.Formatting/Views/ISpecialTreatmentNotifications.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using CounterStrikeSharp.API.Core; | ||
|
||
using Jailbreak.Formatting.Base; | ||
|
||
namespace Jailbreak.Formatting.Views; | ||
|
||
public interface ISpecialTreatmentNotifications | ||
{ | ||
public IView GRANTED { get; } | ||
|
||
public IView REVOKED { get; } | ||
|
||
public IView GRANTED_TO(CCSPlayerController player); | ||
|
||
public IView REVOKED_FROM(CCSPlayerController player); | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
public/Jailbreak.Public/Mod/Warden/ISpecialTreatmentService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using CounterStrikeSharp.API.Core; | ||
|
||
namespace Jailbreak.Public.Mod.Warden; | ||
|
||
public interface ISpecialTreatmentService | ||
{ | ||
public bool IsSpecialTreatment(CCSPlayerController player); | ||
|
||
/// <summary> | ||
/// Give this player ST for the rest of the round | ||
/// </summary> | ||
/// <param name="player"></param> | ||
public void Grant(CCSPlayerController player); | ||
|
||
/// <summary> | ||
/// Revoke the player's special treatment for the current round | ||
/// Does nothing if not ST. | ||
/// </summary> | ||
/// <param name="player"></param> | ||
public void Revoke(CCSPlayerController player); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters