-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rich log service, redo simpleview semantics again, convert existi…
…ng logging * Fully add rich logging service * Redo Simpleview to use a specific "Newline" struct for explicit newlines
- Loading branch information
Showing
15 changed files
with
281 additions
and
130 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
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
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,72 @@ | ||
using CounterStrikeSharp.API; | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Core.Attributes.Registration; | ||
|
||
using Jailbreak.Formatting.Views; | ||
using Jailbreak.Public.Behaviors; | ||
using Jailbreak.Public.Extensions; | ||
using Jailbreak.Public.Mod.Logs; | ||
|
||
namespace Jailbreak.Logs; | ||
|
||
public class LogDamageListeners : IPluginBehavior | ||
{ | ||
private readonly IRichLogService _logs; | ||
|
||
public LogDamageListeners(IRichLogService logs) | ||
{ | ||
_logs = logs; | ||
} | ||
|
||
|
||
|
||
[GameEventHandler] | ||
public HookResult OnGrenadeThrown(EventGrenadeThrown @event, GameEventInfo info) | ||
{ | ||
var player = @event.Userid; | ||
if (!player.IsReal()) | ||
return HookResult.Continue; | ||
var grenade = @event.Weapon; | ||
|
||
_logs.Append(_logs.Player(player), $"threw a {grenade}"); | ||
|
||
return HookResult.Continue; | ||
} | ||
|
||
[GameEventHandler] | ||
public HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info) | ||
{ | ||
var player = @event.Userid; | ||
if (!player.IsReal()) | ||
return HookResult.Continue; | ||
var attacker = @event.Attacker; | ||
|
||
bool isWorld = attacker == null || !attacker.IsReal(); | ||
int health = @event.DmgHealth; | ||
|
||
if (isWorld) | ||
{ | ||
if (health > 0) | ||
{ | ||
_logs.Append($"The world hurt", _logs.Player(player), $"for {health} damage"); | ||
} | ||
else | ||
{ | ||
_logs.Append("The world killed", _logs.Player(player)); | ||
} | ||
} | ||
else | ||
{ | ||
if (health > 0) | ||
{ | ||
_logs.Append( _logs.Player(attacker), "hurt", _logs.Player(player), $"for {health} damage"); | ||
} | ||
else | ||
{ | ||
_logs.Append(_logs.Player(attacker!), "killed", _logs.Player(player)); | ||
} | ||
} | ||
|
||
return HookResult.Continue; | ||
} | ||
} |
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; | ||
using CounterStrikeSharp.API.Core; | ||
using CounterStrikeSharp.API.Core.Attributes.Registration; | ||
|
||
using Jailbreak.Formatting.Views; | ||
using Jailbreak.Public.Behaviors; | ||
|
||
namespace Jailbreak.Logs; | ||
|
||
public class LogEntityListeners : IPluginBehavior | ||
{ | ||
private readonly IRichLogService _logs; | ||
|
||
public LogEntityListeners(IRichLogService logs) | ||
{ | ||
_logs = logs; | ||
} | ||
|
||
[EntityOutputHook("func_button", "OnPressed")] | ||
public HookResult OnButtonPressed(CEntityIOOutput output, string name, CEntityInstance activator, | ||
CEntityInstance caller, CVariant value, float delay) | ||
{ | ||
if (!activator.IsValid) | ||
return HookResult.Continue; | ||
int index = (int)activator.Index; | ||
CCSPlayerPawn? pawn = Utilities.GetEntityFromIndex<CCSPlayerPawn>(index); | ||
if (!pawn.IsValid) | ||
return HookResult.Continue; | ||
if (!pawn.OriginalController.IsValid) | ||
return HookResult.Continue; | ||
CBaseEntity? ent = Utilities.GetEntityFromIndex<CBaseEntity>((int)caller.Index); | ||
if (!ent.IsValid) | ||
return HookResult.Continue; | ||
_logs.Append( | ||
$"{_logs.Player(pawn.OriginalController.Value!)} pressed a button {ent.Entity?.Name ?? "Unlabeled"} -> {output?.Connections?.TargetDesc ?? "None"}"); | ||
return HookResult.Continue; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.