-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
183 additions
and
0 deletions.
There are no files selected for viewing
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,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<Formatting.Languages.English> { | ||
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." }; | ||
} |
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,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<Formatting.Languages.English> { | ||
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." }; | ||
} |
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,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<int> 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<CChicken>("chicken"); | ||
if (chicken == null || !chicken.IsValid) { | ||
locale.SpawnFailed.ToChat(player); | ||
return; | ||
} | ||
chicken.Teleport(player.AbsOrigin); | ||
locale.ChickenSpawned.ToAllChat(); | ||
chicken.DispatchSpawn(); | ||
} | ||
} |
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,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<int> 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<CPhysicsPropMultiplayer>( | ||
"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(); | ||
} | ||
} |
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
9 changes: 9 additions & 0 deletions
9
public/Jailbreak.Formatting/Views/Warden/IWardenCmdChickenLocale.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,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; } | ||
} |
9 changes: 9 additions & 0 deletions
9
public/Jailbreak.Formatting/Views/Warden/IWardenCmdSoccerLocale.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,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; } | ||
} |
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