Added hook for CBaseAnimating::HandleAnimEvent()

This commit is contained in:
Blixibon
2021-03-12 15:33:48 -06:00
parent 97116a5eca
commit 3bb9a92ed8
5 changed files with 107 additions and 0 deletions

View File

@@ -26,6 +26,7 @@
#include "con_nprint.h"
#include "particle_parse.h"
#include "npcevent.h"
#include "vscript_funcs_shared.h"
#include "vscript_singletons.h"
@@ -501,6 +502,61 @@ FireBulletsInfo_t *GetFireBulletsInfoFromInfo( HSCRIPT hBulletsInfo )
return HScriptToClass<FireBulletsInfo_t>( hBulletsInfo );
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
CAnimEventTInstanceHelper g_AnimEventTInstanceHelper;
BEGIN_SCRIPTDESC_ROOT( animevent_t, "Handle for accessing animevent_t info." )
DEFINE_SCRIPT_INSTANCE_HELPER( &g_AnimEventTInstanceHelper )
END_SCRIPTDESC();
bool CAnimEventTInstanceHelper::Get( void *p, const char *pszKey, ScriptVariant_t &variant )
{
animevent_t *ani = ((animevent_t *)p);
if (FStrEq( pszKey, "event" ))
variant = ani->event;
else if (FStrEq( pszKey, "options" ))
variant = ani->options;
else if (FStrEq( pszKey, "cycle" ))
variant = ani->cycle;
else if (FStrEq( pszKey, "eventtime" ))
variant = ani->eventtime;
else if (FStrEq( pszKey, "type" ))
variant = ani->type;
else if (FStrEq( pszKey, "source" ))
variant = ToHScript(ani->pSource);
else
return false;
return true;
}
bool CAnimEventTInstanceHelper::Set( void *p, const char *pszKey, ScriptVariant_t &variant )
{
animevent_t *ani = ((animevent_t *)p);
if (FStrEq( pszKey, "event" ))
ani->event = variant;
else if (FStrEq( pszKey, "options" ))
ani->options = variant;
else if (FStrEq( pszKey, "cycle" ))
ani->cycle = variant;
else if (FStrEq( pszKey, "eventtime" ))
ani->eventtime = variant;
else if (FStrEq( pszKey, "type" ))
ani->type = variant;
else if (FStrEq( pszKey, "source" ))
{
CBaseEntity *pEnt = ToEnt( variant.m_hScript );
if (pEnt)
ani->pSource = pEnt->GetBaseAnimating();
}
else
return false;
return true;
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------

View File

@@ -121,4 +121,13 @@ private:
HSCRIPT m_planeAccessor;
};
//-----------------------------------------------------------------------------
// Exposes animevent_t to VScript
//-----------------------------------------------------------------------------
class CAnimEventTInstanceHelper : public IScriptInstanceHelper
{
bool Get( void *p, const char *pszKey, ScriptVariant_t &variant );
bool Set( void *p, const char *pszKey, ScriptVariant_t &variant );
};
#endif