diff --git a/lang/Jailbreak.English/Warden/WardenCmdChickenLocale.cs b/lang/Jailbreak.English/Warden/WardenCmdChickenLocale.cs new file mode 100644 index 00000000..3097b622 --- /dev/null +++ b/lang/Jailbreak.English/Warden/WardenCmdChickenLocale.cs @@ -0,0 +1,25 @@ +using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Modules.Utils; +using Jailbreak.Formatting.Base; +using Jailbreak.Formatting.Logistics; +using Jailbreak.Formatting.Views.Warden; +using Jailbreak.Public.Mod.Warden; + +namespace Jailbreak.English.Warden; + +public class WardenCmdChickenLocale : IWardenCmdChickenLocale, + ILanguage { + public IView ChickenSpawned + => new SimpleView { + WardenLocale.PREFIX, + ChatColors.Blue + "The warden" + ChatColors.Grey + " spawned a chicken." + }; + + public IView SpawnFailed + => new SimpleView { + WardenLocale.PREFIX, ChatColors.Red + "Failed to spawn a chicken." + }; + + public IView TooManyChickens + => new SimpleView { WardenLocale.PREFIX, "Too many chickens." }; +} \ No newline at end of file diff --git a/lang/Jailbreak.English/Warden/WardenCmdSoccerLocale.cs b/lang/Jailbreak.English/Warden/WardenCmdSoccerLocale.cs new file mode 100644 index 00000000..aa0e0f3f --- /dev/null +++ b/lang/Jailbreak.English/Warden/WardenCmdSoccerLocale.cs @@ -0,0 +1,26 @@ +using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Modules.Utils; +using Jailbreak.Formatting.Base; +using Jailbreak.Formatting.Logistics; +using Jailbreak.Formatting.Views.Warden; +using Jailbreak.Public.Mod.Warden; + +namespace Jailbreak.English.Warden; + +public class WardenCmdSoccerLocale : IWardenCmdSoccerLocale, + ILanguage { + public IView SoccerSpawned + => new SimpleView { + WardenLocale.PREFIX, + ChatColors.Blue + "The warden" + ChatColors.Grey + + " spawned a soccer ball." + }; + + public IView SpawnFailed + => new SimpleView { + WardenLocale.PREFIX, ChatColors.Red + "Failed to spawn a soccer ball." + }; + + public IView TooManySoccers + => new SimpleView { WardenLocale.PREFIX, "Too many soccer balls." }; +} \ No newline at end of file diff --git a/mod/Jailbreak.Warden/Commands/ChickenCommandBehavior.cs b/mod/Jailbreak.Warden/Commands/ChickenCommandBehavior.cs new file mode 100644 index 00000000..363c4a1a --- /dev/null +++ b/mod/Jailbreak.Warden/Commands/ChickenCommandBehavior.cs @@ -0,0 +1,51 @@ +using CounterStrikeSharp.API; +using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Core.Attributes.Registration; +using CounterStrikeSharp.API.Modules.Commands; +using CounterStrikeSharp.API.Modules.Cvars; +using Jailbreak.Formatting.Extensions; +using Jailbreak.Formatting.Views.Warden; +using Jailbreak.Public.Behaviors; +using Jailbreak.Public.Mod.Warden; + +namespace Jailbreak.Warden.Commands; + +public class ChickenCommandBehavior(IWardenService warden, + IWardenLocale wardenLocale, IWardenCmdChickenLocale locale) + : IPluginBehavior { + public static readonly FakeConVar CV_MAX_CHICKENS = + new("css_jb_max_chickens", + "The maximum number of chickens that the warden can spawn", 5); + + private int chickens = 0; + + [GameEventHandler] + public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) { + chickens = 0; + return HookResult.Continue; + } + + [ConsoleCommand("css_chicken", "Spawn a chicken as the warden")] + public void Command_Toggle(CCSPlayerController? player, CommandInfo command) { + if (player == null) return; + + if (!warden.IsWarden(player)) { + wardenLocale.NotWarden.ToChat(player); + return; + } + + if (chickens >= CV_MAX_CHICKENS.Value) { + locale.TooManyChickens.ToChat(player); + return; + } + + var chicken = Utilities.CreateEntityByName("chicken"); + if (chicken == null || !chicken.IsValid) { + locale.SpawnFailed.ToChat(player); + return; + } + chicken.Teleport(player.AbsOrigin); + locale.ChickenSpawned.ToAllChat(); + chicken.DispatchSpawn(); + } +} \ No newline at end of file diff --git a/mod/Jailbreak.Warden/Commands/SoccerCommandBehavior.cs b/mod/Jailbreak.Warden/Commands/SoccerCommandBehavior.cs new file mode 100644 index 00000000..51554a62 --- /dev/null +++ b/mod/Jailbreak.Warden/Commands/SoccerCommandBehavior.cs @@ -0,0 +1,56 @@ +using CounterStrikeSharp.API; +using CounterStrikeSharp.API.Core; +using CounterStrikeSharp.API.Core.Attributes.Registration; +using CounterStrikeSharp.API.Modules.Commands; +using CounterStrikeSharp.API.Modules.Cvars; +using Jailbreak.Formatting.Extensions; +using Jailbreak.Formatting.Views.Warden; +using Jailbreak.Public.Behaviors; +using Jailbreak.Public.Mod.Warden; + +namespace Jailbreak.Warden.Commands; + +public class SoccerCommandBehavior(IWardenService warden, + IWardenLocale wardenLocale, IWardenCmdSoccerLocale locale) : IPluginBehavior { + public static readonly FakeConVar CV_MAX_SOCCERS = + new("css_jb_max_soccers", + "The maximum number of soccer balls that the warden can spawn", 3); + + private int soccers = 0; + + [GameEventHandler] + public HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info) { + soccers = 0; + return HookResult.Continue; + } + + [ConsoleCommand("css_soccer", "Spawn a soccer ball as the warden")] + [ConsoleCommand("css_spawnball", "Spawn a soccer ball as the warden")] + public void Command_Toggle(CCSPlayerController? player, CommandInfo command) { + if (player == null) return; + + if (!warden.IsWarden(player)) { + wardenLocale.NotWarden.ToChat(player); + return; + } + + if (soccers >= CV_MAX_SOCCERS.Value) { + locale.TooManySoccers.ToChat(player); + return; + } + + var chicken = + Utilities.CreateEntityByName( + "prop_physics_multiplayer"); + if (chicken == null || !chicken.IsValid) { + locale.SpawnFailed.ToChat(player); + return; + } + + chicken.SetModel( + "models/props/de_dust/hr_dust/dust_soccerball/dust_soccer_ball001.vmdl"); + chicken.Teleport(player.AbsOrigin); + locale.SoccerSpawned.ToAllChat(); + chicken.DispatchSpawn(); + } +} \ No newline at end of file diff --git a/mod/Jailbreak.Warden/WardenServiceExtension.cs b/mod/Jailbreak.Warden/WardenServiceExtension.cs index 07390ef3..78165ffa 100644 --- a/mod/Jailbreak.Warden/WardenServiceExtension.cs +++ b/mod/Jailbreak.Warden/WardenServiceExtension.cs @@ -25,6 +25,8 @@ public static void AddJailbreakWarden( serviceCollection.AddPluginBehavior(); serviceCollection.AddPluginBehavior(); serviceCollection.AddPluginBehavior(); + serviceCollection.AddPluginBehavior(); + serviceCollection.AddPluginBehavior(); serviceCollection.AddPluginBehavior(); serviceCollection.AddPluginBehavior(); diff --git a/public/Jailbreak.Formatting/Views/Warden/IWardenCmdChickenLocale.cs b/public/Jailbreak.Formatting/Views/Warden/IWardenCmdChickenLocale.cs new file mode 100644 index 00000000..06fe11b1 --- /dev/null +++ b/public/Jailbreak.Formatting/Views/Warden/IWardenCmdChickenLocale.cs @@ -0,0 +1,9 @@ +using Jailbreak.Formatting.Base; + +namespace Jailbreak.Formatting.Views.Warden; + +public interface IWardenCmdChickenLocale { + public IView ChickenSpawned { get; } + public IView SpawnFailed { get; } + public IView TooManyChickens { get; } +} \ No newline at end of file diff --git a/public/Jailbreak.Formatting/Views/Warden/IWardenCmdSoccerLocale.cs b/public/Jailbreak.Formatting/Views/Warden/IWardenCmdSoccerLocale.cs new file mode 100644 index 00000000..0e154158 --- /dev/null +++ b/public/Jailbreak.Formatting/Views/Warden/IWardenCmdSoccerLocale.cs @@ -0,0 +1,9 @@ +using Jailbreak.Formatting.Base; + +namespace Jailbreak.Formatting.Views.Warden; + +public interface IWardenCmdSoccerLocale { + public IView SoccerSpawned { get; } + public IView SpawnFailed { get; } + public IView TooManySoccers { get; } +} \ No newline at end of file diff --git a/src/Jailbreak/JailbreakServiceCollection.cs b/src/Jailbreak/JailbreakServiceCollection.cs index 8107ecd2..5d1e6dfd 100644 --- a/src/Jailbreak/JailbreakServiceCollection.cs +++ b/src/Jailbreak/JailbreakServiceCollection.cs @@ -18,6 +18,7 @@ using Jailbreak.LastRequest; using Jailbreak.Logs; using Jailbreak.Mute; +using Jailbreak.Public.Mod.Warden; using Jailbreak.Rebel; using Jailbreak.RTD; using Jailbreak.SpecialDay; @@ -50,6 +51,10 @@ public void ConfigureServices(IServiceCollection serviceCollection) { serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); + serviceCollection + .AddSingleton(); + serviceCollection + .AddSingleton(); // Do we want to make this scoped? // Not sure how this will behave with multiple rounds and whatnot.