diff --git a/mod/TTT.Roles/RoleBehavior.cs b/mod/TTT.Roles/RoleBehavior.cs index 3e3d45a..dde5a6f 100644 --- a/mod/TTT.Roles/RoleBehavior.cs +++ b/mod/TTT.Roles/RoleBehavior.cs @@ -22,22 +22,14 @@ public class RoleBehavior : IRoleService, IPluginBehavior { private readonly IRoundService _roundService; private int _traitorsLeft; - public RoleBehavior(IPlayerService playerService) { - _roundService = new RoundBehavior(this); + public RoleBehavior(IPlayerService playerService, IRoundService roundService) { + _roundService = roundService; service = playerService; } public void Start(BasePlugin parent) { ModelHandler.RegisterListener(parent); - _roundService.Start(parent); - /* - parent.RegisterEventHandler(OnPlayerConnect); - parent.RegisterEventHandler(OnRoundStart); - parent.RegisterEventHandler(OnRoundEnd); - parent.RegisterEventHandler(OnPlayerDisconnect); - parent.RegisterEventHandler(OnPlayerDeath, HookMode.Pre); - parent.RegisterEventHandler(OnMapStart); - */ + // _roundService.Start(parent); } public IRoundService GetRoundService() { return _roundService; } diff --git a/mod/TTT.Round/RoundBehavior.cs b/mod/TTT.Round/RoundBehavior.cs index 2a45306..bbc413c 100644 --- a/mod/TTT.Round/RoundBehavior.cs +++ b/mod/TTT.Round/RoundBehavior.cs @@ -5,6 +5,7 @@ using CounterStrikeSharp.API.Modules.Memory; using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions; using CounterStrikeSharp.API.Modules.Timers; +using TTT.Public.Behaviors; using TTT.Public.Extensions; using TTT.Public.Formatting; using TTT.Public.Mod.Role; @@ -12,7 +13,8 @@ namespace TTT.Round; -public class RoundBehavior(IRoleService _roleService) : IRoundService { +public class RoundBehavior(IRoleService _roleService) + : IRoundService, IPluginBehavior { private Round? _round; private int _roundId = 1; private RoundStatus _roundStatus = RoundStatus.Paused; @@ -25,6 +27,11 @@ public void Start(BasePlugin plugin) { plugin.AddTimer(3, EndRound, TimerFlags.REPEAT); } + public void Dispose() { + VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Unhook(BlockDamage, + HookMode.Pre); + } + public RoundStatus GetRoundStatus() { return _roundStatus; } public void SetRoundStatus(RoundStatus roundStatus) { diff --git a/mod/TTT.Round/RoundServiceExtension.cs b/mod/TTT.Round/RoundServiceExtension.cs index 588fedb..3bf6095 100644 --- a/mod/TTT.Round/RoundServiceExtension.cs +++ b/mod/TTT.Round/RoundServiceExtension.cs @@ -1,7 +1,11 @@ using Microsoft.Extensions.DependencyInjection; +using TTT.Public.Extensions; +using TTT.Public.Mod.Round; namespace TTT.Round; public static class RoundServiceExtension { - public static void AddRoundService(this IServiceCollection collection) { } + public static void AddRoundService(this IServiceCollection collection) { + collection.AddPluginBehavior(); + } } \ No newline at end of file