-
-
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.
Refactor entity I/O listener, add func_breakable IO listener
* TODO: IO listener will only listen for when the breakable does something when it breaks... We need a better way to listen for eg. CTs pursuing vents.
- Loading branch information
Showing
2 changed files
with
51 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using CounterStrikeSharp.API; | ||
using CounterStrikeSharp.API.Core; | ||
|
||
namespace Jailbreak.Public.Extensions; | ||
|
||
public static class EntityIOExtensions | ||
{ | ||
public static bool TryGetController(this CEntityInstance pawn, out CCSPlayerController? controller) | ||
{ | ||
controller = null; | ||
|
||
if (!pawn.IsValid) | ||
return false; | ||
|
||
int index = (int)pawn.Index; | ||
var playerPawn = Utilities.GetEntityFromIndex<CCSPlayerPawn>(index); | ||
|
||
if (!playerPawn.IsValid) | ||
return false; | ||
|
||
if (!playerPawn.OriginalController.IsValid) | ||
return false; | ||
|
||
controller = playerPawn.OriginalController.Value; | ||
|
||
if (controller?.IsReal() != true) | ||
return false; | ||
|
||
return true; | ||
} | ||
} |