Skip to content

Commit

Permalink
Revert "Feat/debug (#11)"
Browse files Browse the repository at this point in the history
This reverts commit 30e838c.
  • Loading branch information
MSWS committed Jul 20, 2024
1 parent a92368b commit 574c7cc
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 103 deletions.
7 changes: 0 additions & 7 deletions TTT.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TTT.Player", "mod\TTT.Playe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TTT.Manager", "mod\TTT.Manager\TTT.Manager.csproj", "{C3C26EF9-0E5E-4AAF-AE00-EFF4BB129FDB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TTT.Debug", "mod\TTT.Debug\TTT.Debug.csproj", "{5617C94C-B2F9-429C-B4C1-DDD03380A108}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -80,10 +78,6 @@ Global
{C3C26EF9-0E5E-4AAF-AE00-EFF4BB129FDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3C26EF9-0E5E-4AAF-AE00-EFF4BB129FDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3C26EF9-0E5E-4AAF-AE00-EFF4BB129FDB}.Release|Any CPU.Build.0 = Release|Any CPU
{5617C94C-B2F9-429C-B4C1-DDD03380A108}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5617C94C-B2F9-429C-B4C1-DDD03380A108}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5617C94C-B2F9-429C-B4C1-DDD03380A108}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5617C94C-B2F9-429C-B4C1-DDD03380A108}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{A917B0F5-762F-4C4A-9F50-02BA4A0C6B63} = {C7CCF187-9F99-4091-B092-6397C35BE9F1}
Expand All @@ -96,6 +90,5 @@ Global
{E76CD078-0F1B-4EE8-9A19-EE93BAE3FA6B} = {14FF3D75-F9CF-4A32-9F59-83765EA68874}
{D9327D60-67EE-4AF3-BD99-8A95634600B5} = {14FF3D75-F9CF-4A32-9F59-83765EA68874}
{C3C26EF9-0E5E-4AAF-AE00-EFF4BB129FDB} = {14FF3D75-F9CF-4A32-9F59-83765EA68874}
{5617C94C-B2F9-429C-B4C1-DDD03380A108} = {14FF3D75-F9CF-4A32-9F59-83765EA68874}
EndGlobalSection
EndGlobal
30 changes: 0 additions & 30 deletions mod/TTT.Debug/Commands/GetRagdoll.cs

This file was deleted.

11 changes: 0 additions & 11 deletions mod/TTT.Debug/DebugServiceExtension.cs

This file was deleted.

17 changes: 0 additions & 17 deletions mod/TTT.Debug/TTT.Debug.csproj

This file was deleted.

2 changes: 1 addition & 1 deletion mod/TTT.Detective/DetectiveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public HookResult OnZeus(DynamicHook hook) {
private void OnPlayerUse(CCSPlayerController player) { IdentifyBody(player); }

private void IdentifyBody(CCSPlayerController caller) {
// if (roleService.GetPlayer(caller).PlayerRole() != Role.Detective) return;
if (roleService.GetPlayer(caller).PlayerRole() != Role.Detective) return;

var entity = caller.GetClientRagdollAimTarget();

Expand Down
73 changes: 40 additions & 33 deletions mod/TTT.Roles/RoleBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,33 @@ public class RoleBehavior : IRoleService, IPluginBehavior {
private const int MaxDetectives = 3;
private readonly IPlayerService service;

private int innocentsLeft;
private readonly IRoundService roundService;
private int traitorsLeft;
private int _innocentsLeft;
private readonly IRoundService _roundService;
private int _traitorsLeft;

public RoleBehavior(IPlayerService playerService) {
roundService = new RoundBehavior(this);
service = playerService;
_roundService = new RoundBehavior(this);
service = playerService;
}

public void Start(BasePlugin parent) {
ModelHandler.RegisterListener(parent);
roundService.Start(parent);
_roundService.Start(parent);
}

public IRoundService GetRoundService() { return roundService; }
public IRoundService GetRoundService() { return _roundService; }

public void AddRoles() {
var eligible = Utilities.GetPlayers()
.Where(player => player.IsReal())
.Where(player => player.Team is not (CsTeam.Spectator or CsTeam.None))
.ToList();

var traitorCount = (int)Math.Floor(Convert.ToDouble(eligible.Count / 3));
var detectiveCount = (int)Math.Floor(Convert.ToDouble(eligible.Count / 8));

traitorsLeft = traitorCount;
innocentsLeft = eligible.Count - traitorCount;
_traitorsLeft = traitorCount;
_innocentsLeft = eligible.Count - traitorCount;

if (detectiveCount > MaxDetectives) detectiveCount = MaxDetectives;

Expand Down Expand Up @@ -89,7 +90,7 @@ public Role GetRole(CCSPlayerController player) {
public void AddTraitor(params CCSPlayerController[] players) {
foreach (var player in players) {
service.GetPlayer(player).SetPlayerRole(Role.Traitor);
player.SwitchTeam(CsTeam.Spectator);
player.SwitchTeam(CsTeam.Terrorist);
player.PrintToCenter(
Role.Traitor.FormatStringFullBefore("You are now a"));
player.PrintToChat(Role.Traitor.FormatStringFullBefore("You are now a"));
Expand All @@ -113,7 +114,7 @@ public void AddInnocents(params CCSPlayerController[] players) {
service.GetPlayer(player).SetPlayerRole(Role.Innocent);
player.PrintToCenter(
Role.Innocent.FormatStringFullBefore("You are now an"));
player.SwitchTeam(CsTeam.Spectator);
player.SwitchTeam(CsTeam.Terrorist);
ModelHandler.SetModel(player, ModelHandler.ModelPathTmPhoenix);
}
}
Expand All @@ -138,7 +139,7 @@ public void Clear() {
[GameEventHandler]
public HookResult
OnRoundStart(EventRoundFreezeEnd @event, GameEventInfo info) {
roundService.SetRoundStatus(RoundStatus.Waiting);
_roundService.SetRoundStatus(RoundStatus.Waiting);
foreach (var player in Utilities.GetPlayers()
.Where(player => player.IsReal() && player.Team != CsTeam.None
|| player.Team != CsTeam.Spectator)) {
Expand All @@ -154,8 +155,10 @@ public HookResult
[GameEventHandler]
public HookResult OnPlayerConnect(EventPlayerConnectFull @event,
GameEventInfo info) {
if (Utilities.GetPlayers().Count(player => player.PawnIsAlive) < 3)
roundService.ForceEnd();
if (Utilities.GetPlayers()
.Count(player => player.IsReal() && player.Team != CsTeam.None
|| player.Team == CsTeam.Spectator) < 3)
_roundService.ForceEnd();

return HookResult.Continue;
}
Expand All @@ -174,25 +177,26 @@ public HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) {

service.GetPlayer(playerWhoWasDamaged).SetKiller(attacker);

if (IsTraitor(playerWhoWasDamaged)) traitorsLeft--;
if (IsTraitor(playerWhoWasDamaged)) _traitorsLeft--;
if (IsDetective(playerWhoWasDamaged) || IsInnocent(playerWhoWasDamaged))
innocentsLeft--;
_innocentsLeft--;

if (traitorsLeft == 0 || innocentsLeft == 0)
Server.NextFrame(() => roundService.ForceEnd());
if (_traitorsLeft == 0 || _innocentsLeft == 0)
Server.NextFrame(() => _roundService.ForceEnd());

// Server.PrintToChatAll(StringUtils.FormatTTT(
// $"{GetRole(playerWhoWasDamaged).FormatStringFullAfter(" has been found.")}"));
Server.NextFrame(() => {
Server.PrintToChatAll(StringUtils.FormatTTT(
$"{GetRole(playerWhoWasDamaged).FormatStringFullAfter(" has been found.")}"));

if (attacker == playerWhoWasDamaged || attacker == null)
return HookResult.Continue;
if (attacker == playerWhoWasDamaged || attacker == null) return;

attacker.ModifyScoreBoard();
attacker.ModifyScoreBoard();

playerWhoWasDamaged.PrintToChat(StringUtils.FormatTTT(
$"You were killed by {GetRole(attacker).FormatStringFullAfter(" " + attacker.PlayerName)}."));
attacker.PrintToChat(StringUtils.FormatTTT(
$"You killed {GetRole(playerWhoWasDamaged).FormatStringFullAfter(" " + playerWhoWasDamaged.PlayerName)}."));
playerWhoWasDamaged.PrintToChat(StringUtils.FormatTTT(
$"You were killed by {GetRole(attacker).FormatStringFullAfter(" " + attacker.PlayerName)}."));
attacker.PrintToChat(StringUtils.FormatTTT(
$"You killed {GetRole(playerWhoWasDamaged).FormatStringFullAfter(" " + playerWhoWasDamaged.PlayerName)}."));
});

return HookResult.Continue;
}
Expand All @@ -201,23 +205,26 @@ public HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info) {
public HookResult OnRoundEnd(EventRoundEnd @event, GameEventInfo info) {
var players = Utilities.GetPlayers()
.Where(player => player.IsValid)
.Where(player => player.IsReal())
.ToList();

foreach (var player in players)
player.PrintToCenter(GetWinner().FormatStringFullAfter("s has won!"));

Clear();
Server.NextFrame(Clear);

return HookResult.Continue;
}

[GameEventHandler]
public HookResult OnPlayerDisconnect(EventPlayerDisconnect @event,
GameEventInfo info) {
var player = @event.Userid;
if (player == null) return HookResult.Continue;
service.RemovePlayer(player);
if (service.Players().Count == 0)
roundService.SetRoundStatus(RoundStatus.Paused);
Server.NextFrame(() => {
service.RemovePlayer(player);
if (service.Players().Count == 0)
_roundService.SetRoundStatus(RoundStatus.Paused);
});

return HookResult.Continue;
}
Expand All @@ -227,7 +234,7 @@ public bool IsInnocent(CCSPlayerController player) {
}

private Role GetWinner() {
return traitorsLeft == 0 ? Role.Traitor : Role.Innocent;
return _traitorsLeft == 0 ? Role.Traitor : Role.Innocent;
}

public void SetColor(CCSPlayerController player) {
Expand Down
1 change: 1 addition & 0 deletions mod/TTT.Round/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void Tick() {

public void Start() {
foreach (var player in Utilities.GetPlayers()
.Where(player => player.IsReal())
.Where(player => !player.PawnIsAlive)
.Where(player
=> player.Team is CsTeam.Terrorist or CsTeam.CounterTerrorist))
Expand Down
2 changes: 1 addition & 1 deletion public/TTT.Formatting/Extensions/ViewExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static IView ToPlayerConsole(this IView view,

public static IView
ToPlayerChat(this IView view, CCSPlayerController player) {
if (player.IsBot) return view;
if (!player.IsReal() || player.IsBot) return view;

var writer = view.ToWriter();

Expand Down
1 change: 0 additions & 1 deletion src/TTT/TTT.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\mod\TTT.Debug\TTT.Debug.csproj" />
<ProjectReference Include="..\..\public\TTT.Public\TTT.Public.csproj"/>
<ProjectReference Include="..\..\mod\TTT.Detective\TTT.Detective.csproj"/>
<ProjectReference Include="..\..\mod\TTT.Roles\TTT.Roles.csproj"/>
Expand Down
2 changes: 0 additions & 2 deletions src/TTT/TTTServiceCollection.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using CounterStrikeSharp.API.Core;
using Microsoft.Extensions.DependencyInjection;
using TTT.Debug;
using TTT.Detective;
using TTT.Logs;
using TTT.Manager;
Expand All @@ -16,6 +15,5 @@ public void ConfigureServices(IServiceCollection serviceCollection) {
serviceCollection.AddDetectiveBehavior();
serviceCollection.AddLogsService();
serviceCollection.AddManagerService();
serviceCollection.AddDebugBehavior();
}
}

0 comments on commit 574c7cc

Please sign in to comment.