Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add crosshair target changed callback #893

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
20 changes: 20 additions & 0 deletions Northstar.Client/mod/scripts/vscripts/client/cl_player.gnut
NachosChipeados marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ global function GetWaveSpawnTime
global function ServerCallback_HideNextSpawnMessage

global function ClientCodeCallback_OnHealthChanged

// Northstar
global function AddCallback_OnCrosshairCurrentTargetChanged
global function ClientCodeCallback_OnCrosshairCurrentTargetChanged
global function Pressed_TitanNextMode
global function ClientCodeCallback_OnGib
Expand Down Expand Up @@ -70,6 +73,9 @@ struct {
var law_missile_tracer = null
float nextSpawnTime = 0.0
entity lastEarnedReward // primarily used to check if we should still show the reward message after a delay

// Northstar
array< void functionref( entity, entity ) > OnCrosshairCurrentTargetChangedCallbacks
} file

struct BloodDecalParams
Expand Down Expand Up @@ -1515,6 +1521,14 @@ void function ClientCodeCallback_OnHealthChanged( entity ent, int oldHealth, int
ent.Signal( "HealthChanged", { oldHealth = oldHealth, newHealth = newHealth } )
}

// Northstar
void function AddCallback_OnCrosshairCurrentTargetChanged( void functionref( entity, entity ) callbackFunc )
{
Assert( !file.OnCrosshairCurrentTargetChangedCallbacks.contains( callbackFunc ), "Already added " + string( callbackFunc ) + " with AddCallback_OnCrosshairCurrentTargetChanged" )

file.OnCrosshairCurrentTargetChangedCallbacks.append( callbackFunc )
}

void function ClientCodeCallback_OnCrosshairCurrentTargetChanged( entity player, entity newTarget )
{
if ( IsLobby() )
Expand All @@ -1524,6 +1538,12 @@ void function ClientCodeCallback_OnCrosshairCurrentTargetChanged( entity player,

if ( IsValid( newTarget ) )
TryOfferRodeoBatteryHint( newTarget )

// Northstar
foreach ( callback in file.OnCrosshairCurrentTargetChangedCallbacks )
{
callback( player, newTarget )
}
}

void function SetupPlayerAnimEvents( entity player )
Expand Down
Loading
Loading