finalized TE setup stocks
added TE_SetEntDataFloatArray native to sdktools --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401045
This commit is contained in:
@@ -126,9 +126,28 @@ bool TempEntityInfo::TE_SetEntDataVector(const char *name, float vector[3])
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TempEntityInfo::TE_SetEntDataFloatArray(const char *name, cell_t *array, int size)
|
||||
{
|
||||
/* Search for our offset */
|
||||
int offset = _FindOffset(name);
|
||||
|
||||
if (offset < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
float *base = (float *)((uint8_t *)m_Me + offset);
|
||||
for (int i=0; i<size; i++)
|
||||
{
|
||||
base[i] = sp_ctof(array[i]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void TempEntityInfo::Send(IRecipientFilter &filter, float delay)
|
||||
{
|
||||
engine->PlaybackTempEntity(filter, delay, (void *)m_Me, m_Sc->m_pTable, m_Sc->m_ClassID);
|
||||
engine->PlaybackTempEntity(filter, delay, m_Me, m_Sc->m_pTable, m_Sc->m_ClassID);
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -41,6 +41,7 @@ public:
|
||||
bool TE_SetEntData(const char *name, int value);
|
||||
bool TE_SetEntDataFloat(const char *name, float value);
|
||||
bool TE_SetEntDataVector(const char *name, float vector[3]);
|
||||
bool TE_SetEntDataFloatArray(const char *name, cell_t *array, int size);
|
||||
void Send(IRecipientFilter &filter, float delay);
|
||||
private:
|
||||
int _FindOffset(const char *name, int *size=NULL);
|
||||
|
||||
@@ -116,6 +116,31 @@ static cell_t smn_TEWriteVector(IPluginContext *pContext, const cell_t *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t smn_TEWriteFloatArray(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
if (!g_TEManager.IsAvailable())
|
||||
{
|
||||
return pContext->ThrowNativeError("TempEntity System unsupported or not available, file a bug report");
|
||||
}
|
||||
if (!g_CurrentTE)
|
||||
{
|
||||
return pContext->ThrowNativeError("No TempEntity call is in progress");
|
||||
}
|
||||
|
||||
char *prop;
|
||||
pContext->LocalToString(params[1], &prop);
|
||||
|
||||
cell_t *addr;
|
||||
pContext->LocalToPhysAddr(params[2], &addr);
|
||||
|
||||
if (!g_CurrentTE->TE_SetEntDataFloatArray(prop, addr, params[3]))
|
||||
{
|
||||
return pContext->ThrowNativeError("Temp entity property \"%s\" not found", prop);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t smn_TESend(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
if (!g_TEManager.IsAvailable())
|
||||
@@ -165,5 +190,6 @@ sp_nativeinfo_t g_TENatives[] =
|
||||
{"TE_WriteAngles", smn_TEWriteVector},
|
||||
{"TE_Send", smn_TESend},
|
||||
{"TE_IsValidProp", smn_TEIsValidProp},
|
||||
{"TE_WriteFloatArray", smn_TEWriteFloatArray},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user