mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-13 15:27:56 +03:00
Exposed developer commentary nodes to VScript
This commit is contained in:
parent
78f7ae6b8d
commit
f638009797
@ -164,6 +164,9 @@ class C_PointCommentaryNode : public C_BaseAnimating, public IChoreoEventCallbac
|
||||
public:
|
||||
DECLARE_CLIENTCLASS();
|
||||
DECLARE_DATADESC();
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
DECLARE_ENT_SCRIPTDESC();
|
||||
#endif
|
||||
|
||||
virtual void OnPreDataChanged( DataUpdateType_t type );
|
||||
virtual void OnDataChanged( DataUpdateType_t type );
|
||||
@ -256,6 +259,20 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT // VScript funcs
|
||||
bool IsActive() { return m_bActive; }
|
||||
|
||||
int GetCommentaryType() { return m_iCommentaryType; }
|
||||
void SetCommentaryType( int iType ) { m_iCommentaryType = iType; }
|
||||
|
||||
const char *GetCommentaryFile() { return m_iszCommentaryFile; }
|
||||
void SetCommentaryFile( const char *pszNewFile ) { Q_strncpy( m_iszCommentaryFile, pszNewFile, sizeof( m_iszCommentaryFile ) ); }
|
||||
const char *GetSpeakers() { return m_iszSpeakers; }
|
||||
void SetSpeakers( const char *pszSpeakers ) { Q_strncpy( m_iszSpeakers, pszSpeakers, sizeof( m_iszSpeakers ) ); }
|
||||
const char *GetPrintName() { return m_iszPrintName; }
|
||||
void SetPrintName( const char *pszPrintName ) { Q_strncpy( m_iszPrintName, pszPrintName, sizeof( m_iszPrintName ) ); }
|
||||
#endif
|
||||
|
||||
public:
|
||||
// Data received from the server
|
||||
bool m_bActive;
|
||||
@ -280,6 +297,10 @@ public:
|
||||
//CHandle<C_SceneEntity> m_hScene;
|
||||
EHANDLE m_hSceneOrigin;
|
||||
#endif
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
static ScriptHook_t g_Hook_PreStartCommentaryClient;
|
||||
#endif
|
||||
};
|
||||
|
||||
IMPLEMENT_CLIENTCLASS_DT(C_PointCommentaryNode, DT_PointCommentaryNode, CPointCommentaryNode)
|
||||
@ -306,6 +327,26 @@ BEGIN_DATADESC( C_PointCommentaryNode )
|
||||
DEFINE_SOUNDPATCH( m_sndCommentary ),
|
||||
END_DATADESC()
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
ScriptHook_t C_PointCommentaryNode::g_Hook_PreStartCommentaryClient;
|
||||
|
||||
BEGIN_ENT_SCRIPTDESC( C_PointCommentaryNode, C_BaseAnimating, "Commentary nodes which play commentary in commentary mode." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( IsActive, "" )
|
||||
DEFINE_SCRIPTFUNC( GetCommentaryFile, "" )
|
||||
DEFINE_SCRIPTFUNC( SetCommentaryFile, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSpeakers, "" )
|
||||
DEFINE_SCRIPTFUNC( SetSpeakers, "" )
|
||||
DEFINE_SCRIPTFUNC( GetPrintName, "" )
|
||||
DEFINE_SCRIPTFUNC( SetPrintName, "" )
|
||||
DEFINE_SCRIPTFUNC( GetCommentaryType, "" )
|
||||
DEFINE_SCRIPTFUNC( SetCommentaryType, "" )
|
||||
|
||||
DEFINE_SIMPLE_SCRIPTHOOK( C_PointCommentaryNode::g_Hook_PreStartCommentaryClient, "PreStartCommentaryClient", FIELD_BOOLEAN, "Called just before commentary begins on the client. Use this to modify variables or commentary behavior before it begins. Returning false will prevent the commentary from starting." )
|
||||
|
||||
END_SCRIPTDESC();
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
@ -335,6 +376,22 @@ void C_PointCommentaryNode::OnDataChanged( DataUpdateType_t updateType )
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( m_bActive && pPlayer )
|
||||
{
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
if (m_ScriptScope.IsInitialized() && g_Hook_PreStartCommentaryClient.CanRunInScope( m_ScriptScope ))
|
||||
{
|
||||
ScriptVariant_t functionReturn;
|
||||
if (g_Hook_PreStartCommentaryClient.Call( m_ScriptScope, &functionReturn, NULL ) && functionReturn.m_type == FIELD_BOOLEAN)
|
||||
{
|
||||
// Don't play the commentary if it returned false
|
||||
if (functionReturn.m_bool == false)
|
||||
{
|
||||
engine->ServerCmd( "commentary_finishnode\n" );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Use the HDR / Non-HDR version based on whether we're running HDR or not
|
||||
char *pszCommentaryFile;
|
||||
if ( g_pMaterialSystemHardwareConfig->GetHDRType() == HDR_TYPE_NONE && m_iszCommentaryFileNoHDR && m_iszCommentaryFileNoHDR[0] )
|
||||
|
@ -72,6 +72,9 @@ class CPointCommentaryNode : public CBaseAnimating
|
||||
DECLARE_CLASS( CPointCommentaryNode, CBaseAnimating );
|
||||
public:
|
||||
DECLARE_DATADESC();
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
DECLARE_ENT_SCRIPTDESC();
|
||||
#endif
|
||||
DECLARE_SERVERCLASS();
|
||||
|
||||
CPointCommentaryNode()
|
||||
@ -114,11 +117,37 @@ public:
|
||||
void TeleportTo( CBasePlayer *pPlayer );
|
||||
bool CanTeleportTo( void );
|
||||
|
||||
#ifdef MAPBASE
|
||||
bool IsActive() { return m_bActive; }
|
||||
bool IsDisabled() { return m_bDisabled; }
|
||||
|
||||
int GetCommentaryType() { return m_iCommentaryType; }
|
||||
void SetCommentaryType( int iType ) { m_iCommentaryType = iType; }
|
||||
|
||||
const char *GetCommentaryFile() { return STRING( m_iszCommentaryFile.Get() ); }
|
||||
void SetCommentaryFile( const char *pszNewFile ) { m_iszCommentaryFile.Set( AllocPooledString( pszNewFile ) ); }
|
||||
const char *GetSpeakers() { return STRING( m_iszSpeakers.Get() ); }
|
||||
void SetSpeakers( const char *pszSpeakers ) { m_iszSpeakers.Set( AllocPooledString( pszSpeakers ) ); }
|
||||
const char *GetPrintName() { return STRING( m_iszPrintName.Get() ); }
|
||||
void SetPrintName( const char *pszPrintName ) { m_iszPrintName.Set( AllocPooledString( pszPrintName ) ); }
|
||||
#endif
|
||||
|
||||
// Inputs
|
||||
void InputStartCommentary( inputdata_t &inputdata );
|
||||
void InputStartUnstoppableCommentary( inputdata_t &inputdata );
|
||||
void InputEnable( inputdata_t &inputdata );
|
||||
void InputDisable( inputdata_t &inputdata );
|
||||
#ifdef MAPBASE
|
||||
void InputSetViewTarget( inputdata_t &inputdata );
|
||||
void InputSetViewPosition( inputdata_t &inputdata );
|
||||
void InputSetViewTargetSpeed( inputdata_t &inputdata );
|
||||
void InputSetViewPositionSpeed( inputdata_t &inputdata );
|
||||
void InputSetReturnSpeed( inputdata_t &inputdata );
|
||||
#endif
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
static ScriptHook_t g_Hook_PreStartCommentary;
|
||||
#endif
|
||||
|
||||
private:
|
||||
string_t m_iszPreCommands;
|
||||
@ -227,6 +256,35 @@ BEGIN_DATADESC( CPointCommentaryNode )
|
||||
DEFINE_THINKFUNC( UpdateViewPostThink ),
|
||||
END_DATADESC()
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
|
||||
ScriptHook_t CPointCommentaryNode::g_Hook_PreStartCommentary;
|
||||
|
||||
BEGIN_ENT_SCRIPTDESC( CPointCommentaryNode, CBaseAnimating, "Commentary nodes which play commentary in commentary mode." )
|
||||
DEFINE_SCRIPTFUNC( IsDisabled, "" )
|
||||
DEFINE_SCRIPTFUNC( SetDisabled, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( IsActive, "" )
|
||||
DEFINE_SCRIPTFUNC( GetCommentaryFile, "" )
|
||||
DEFINE_SCRIPTFUNC( SetCommentaryFile, "" )
|
||||
DEFINE_SCRIPTFUNC( GetSpeakers, "" )
|
||||
DEFINE_SCRIPTFUNC( SetSpeakers, "" )
|
||||
DEFINE_SCRIPTFUNC( GetPrintName, "" )
|
||||
DEFINE_SCRIPTFUNC( SetPrintName, "" )
|
||||
DEFINE_SCRIPTFUNC( GetCommentaryType, "" )
|
||||
DEFINE_SCRIPTFUNC( SetCommentaryType, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( HasViewTarget, "" )
|
||||
DEFINE_SCRIPTFUNC( PreventsMovement, "" )
|
||||
DEFINE_SCRIPTFUNC( CannotBeStopped, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( AbortPlaying, "Stops playing the node and snaps out of its camera control immediately. The game uses this function to shut down commentary while in the middle of playing a node, as it can't smoothly blend out (since the commentary entities need to be removed)." )
|
||||
|
||||
DEFINE_SIMPLE_SCRIPTHOOK( CPointCommentaryNode::g_Hook_PreStartCommentary, "PreStartCommentary", FIELD_BOOLEAN, "Called just before commentary begins. Use this to modify variables or commentary behavior before it begins. Returning false will prevent the commentary from starting." )
|
||||
END_SCRIPTDESC();
|
||||
|
||||
#endif // MAPBASE_VSCRIPT
|
||||
|
||||
IMPLEMENT_SERVERCLASS_ST( CPointCommentaryNode, DT_PointCommentaryNode )
|
||||
SendPropBool( SENDINFO(m_bActive) ),
|
||||
SendPropStringT( SENDINFO(m_iszCommentaryFile) ),
|
||||
@ -1198,6 +1256,19 @@ void CPointCommentaryNode::StartCommentary( void )
|
||||
if ( !pPlayer )
|
||||
return;
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
if (m_ScriptScope.IsInitialized() && g_Hook_PreStartCommentary.CanRunInScope( m_ScriptScope ))
|
||||
{
|
||||
ScriptVariant_t functionReturn;
|
||||
if ( g_Hook_PreStartCommentary.Call( m_ScriptScope, &functionReturn, NULL ) && functionReturn.m_type == FIELD_BOOLEAN )
|
||||
{
|
||||
// Don't play the commentary if it returned false
|
||||
if (functionReturn.m_bool == false)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
m_bActive = true;
|
||||
|
||||
m_flAnimTime = gpGlobals->curtime;
|
||||
|
Loading…
x
Reference in New Issue
Block a user