mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2024-12-26 06:45:31 +03:00
add info_particle_system_coordinate, plus infinite cooldown functionality for prop_interactable similar to that of func_button
This commit is contained in:
parent
0cf49fbfa0
commit
697b92ea35
@ -42,6 +42,7 @@ protected:
|
||||
|
||||
|
||||
EHANDLE m_hControlPointEnts[kMAXCONTROLPOINTS];
|
||||
Vector m_vControlPointVecs[kMAXCONTROLPOINTS];
|
||||
// SendPropArray3( SENDINFO_ARRAY3(m_iControlPointParents), SendPropInt( SENDINFO_ARRAY(m_iControlPointParents), 3, SPROP_UNSIGNED ) ),
|
||||
unsigned char m_iControlPointParents[kMAXCONTROLPOINTS];
|
||||
|
||||
@ -65,6 +66,7 @@ BEGIN_RECV_TABLE_NOBASE( C_ParticleSystem, DT_ParticleSystem )
|
||||
RecvPropFloat(RECVINFO(m_flStartTime)),
|
||||
|
||||
RecvPropArray3(RECVINFO_ARRAY(m_hControlPointEnts), RecvPropEHandle(RECVINFO(m_hControlPointEnts[0]))),
|
||||
RecvPropArray3(RECVINFO_ARRAY(m_vControlPointVecs), RecvPropVector(RECVINFO(m_vControlPointVecs[0]))),
|
||||
RecvPropArray3(RECVINFO_ARRAY(m_iControlPointParents), RecvPropInt(RECVINFO(m_iControlPointParents[0]))),
|
||||
RecvPropBool(RECVINFO(m_bWeatherEffect)),
|
||||
END_RECV_TABLE();
|
||||
@ -150,14 +152,11 @@ void C_ParticleSystem::ClientThink( void )
|
||||
AssertMsg1(pEffect, "Particle system couldn't make %s", pszName);
|
||||
if (pEffect)
|
||||
{
|
||||
if (m_vControlPointVecs[0] != GetAbsOrigin() && m_hControlPointEnts[0] == NULL){
|
||||
// we are using info_particle_system_coordinate
|
||||
for (int i = 0; i < kMAXCONTROLPOINTS; ++i)
|
||||
{
|
||||
CBaseEntity *pOnEntity = m_hControlPointEnts[i].Get();
|
||||
if ( pOnEntity )
|
||||
{
|
||||
ParticleProp()->AddControlPoint( pEffect, i + 1, pOnEntity, PATTACH_ABSORIGIN_FOLLOW );
|
||||
}
|
||||
|
||||
ParticleProp()->AddControlPoint(pEffect, i + 1, this, PATTACH_WORLDORIGIN, 0, m_vControlPointVecs[i] - GetAbsOrigin());
|
||||
AssertMsg2(m_iControlPointParents[i] >= 0 && m_iControlPointParents[i] <= kMAXCONTROLPOINTS,
|
||||
"Particle system specified bogus control point parent (%d) for point %d.",
|
||||
m_iControlPointParents[i], i);
|
||||
@ -167,6 +166,25 @@ void C_ParticleSystem::ClientThink( void )
|
||||
pEffect->SetControlPointParent(i + 1, m_iControlPointParents[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
for (int i = 0; i < kMAXCONTROLPOINTS; ++i)
|
||||
{
|
||||
CBaseEntity* pOnEntity = m_hControlPointEnts[i].Get();
|
||||
if (pOnEntity)
|
||||
{
|
||||
ParticleProp()->AddControlPoint(pEffect, i + 1, pOnEntity, PATTACH_ABSORIGIN_FOLLOW);
|
||||
}
|
||||
AssertMsg2(m_iControlPointParents[i] >= 0 && m_iControlPointParents[i] <= kMAXCONTROLPOINTS,
|
||||
"Particle system specified bogus control point parent (%d) for point %d.",
|
||||
m_iControlPointParents[i], i);
|
||||
|
||||
if (m_iControlPointParents[i] != 0)
|
||||
{
|
||||
pEffect->SetControlPointParent(i + 1, m_iControlPointParents[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: What we really want here is to compare our lifetime and that of our children and see if this delta is
|
||||
// already past the end of it, denoting that we're finished. In that case, just destroy us and be done. -- jdw
|
||||
|
@ -31,6 +31,7 @@ IMPLEMENT_SERVERCLASS_ST_NOBASE(CParticleSystem, DT_ParticleSystem)
|
||||
SendPropFloat(SENDINFO(m_flStartTime)),
|
||||
|
||||
SendPropArray3(SENDINFO_ARRAY3(m_hControlPointEnts), SendPropEHandle(SENDINFO_ARRAY(m_hControlPointEnts))),
|
||||
SendPropArray3(SENDINFO_ARRAY3(m_vControlPointVecs), SendPropVector(SENDINFO_ARRAY(m_vControlPointVecs))),
|
||||
SendPropArray3(SENDINFO_ARRAY3(m_iControlPointParents), SendPropInt(SENDINFO_ARRAY(m_iControlPointParents), 3, SPROP_UNSIGNED)),
|
||||
SendPropBool(SENDINFO(m_bWeatherEffect)),
|
||||
END_SEND_TABLE()
|
||||
@ -119,6 +120,7 @@ BEGIN_DATADESC( CParticleSystem )
|
||||
DEFINE_KEYFIELD(m_iControlPointParents[6], FIELD_CHARACTER, "cpoint7_parent"),
|
||||
|
||||
DEFINE_AUTO_ARRAY(m_hControlPointEnts, FIELD_EHANDLE),
|
||||
DEFINE_AUTO_ARRAY(m_vControlPointVecs, FIELD_VECTOR),
|
||||
|
||||
DEFINE_INPUTFUNC(FIELD_VOID, "Start", InputStart),
|
||||
DEFINE_INPUTFUNC(FIELD_VOID, "Stop", InputStop),
|
||||
@ -131,6 +133,7 @@ BEGIN_DATADESC( CParticleSystem )
|
||||
END_DATADESC()
|
||||
|
||||
LINK_ENTITY_TO_CLASS(info_particle_system, CParticleSystem);
|
||||
LINK_ENTITY_TO_CLASS(info_particle_system_coordinate, CParticleSystemCoordinate);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
@ -254,15 +257,27 @@ void CParticleSystem::InputDestroyImmediately( inputdata_t &inputdata )
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Find each entity referred to by m_iszControlPointNames and
|
||||
// resolve it into the corresponding slot in m_hControlPointEnts
|
||||
// resolve it into the corresponding slot in m_vControlPointVecs
|
||||
//-----------------------------------------------------------------------------
|
||||
void CParticleSystem::ReadControlPointEnts(void)
|
||||
{
|
||||
for (int i = 0; i < kMAXCONTROLPOINTS; ++i)
|
||||
{
|
||||
if (UsesCoordinates()) {
|
||||
float vecCoords[3];
|
||||
if (m_iszControlPointNames[i] == NULL_STRING)
|
||||
m_vControlPointVecs.Set(i, GetAbsOrigin()); // use self as default position
|
||||
else{
|
||||
// cast str to vector, add vector to array
|
||||
const char* pszVector = STRING(m_iszControlPointNames[i]);
|
||||
UTIL_StringToVector(vecCoords, pszVector);
|
||||
m_vControlPointVecs.Set(i, Vector(vecCoords[0], vecCoords[1], vecCoords[2]));
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
if (m_iszControlPointNames[i] == NULL_STRING)
|
||||
continue;
|
||||
|
||||
CBaseEntity *pPointEnt = gEntList.FindEntityGeneric(NULL, STRING(m_iszControlPointNames[i]), this);
|
||||
Assert(pPointEnt != NULL);
|
||||
if (pPointEnt == NULL)
|
||||
@ -274,3 +289,4 @@ void CParticleSystem::ReadControlPointEnts( void )
|
||||
m_hControlPointEnts.Set(i, pPointEnt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,10 +41,12 @@ public:
|
||||
|
||||
enum { kMAXCONTROLPOINTS = 63 }; ///< actually one less than the total number of cpoints since 0 is assumed to be me
|
||||
|
||||
virtual bool UsesCoordinates(void) { return false; }
|
||||
|
||||
protected:
|
||||
|
||||
/// Load up and resolve the entities that are supposed to be the control points
|
||||
void ReadControlPointEnts( void );
|
||||
virtual void ReadControlPointEnts(void);
|
||||
|
||||
bool m_bStartActive;
|
||||
string_t m_iszEffectName;
|
||||
@ -58,8 +60,19 @@ protected:
|
||||
|
||||
string_t m_iszControlPointNames[kMAXCONTROLPOINTS];
|
||||
CNetworkArray(EHANDLE, m_hControlPointEnts, kMAXCONTROLPOINTS);
|
||||
CNetworkArray(Vector, m_vControlPointVecs, kMAXCONTROLPOINTS);
|
||||
CNetworkArray(unsigned char, m_iControlPointParents, kMAXCONTROLPOINTS);
|
||||
CNetworkVar(bool, m_bWeatherEffect);
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: An entity that spawns and controls a particle system using coordinates.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CParticleSystemCoordinate : public CParticleSystem
|
||||
{
|
||||
DECLARE_CLASS(CParticleSystemCoordinate, CParticleSystem);
|
||||
public:
|
||||
virtual bool UsesCoordinates(void) { return true; }
|
||||
};
|
||||
|
||||
#endif // PARTICLE_SYSTEM_H
|
||||
|
@ -2853,8 +2853,16 @@ void CInteractableProp::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_
|
||||
m_pOutputAnimBegun.FireOutput(pActivator, this);
|
||||
}
|
||||
|
||||
if (m_flCooldown == -1 && !m_bLocked){
|
||||
m_flCooldownTime = 1e+30; // yeah we're not going to hit this any time soon
|
||||
}
|
||||
else if (m_flCooldown == -1){
|
||||
m_flCooldownTime = gpGlobals->curtime + 1.0f; // 1s cooldown if locked
|
||||
}
|
||||
else{
|
||||
m_flCooldownTime = gpGlobals->curtime + m_flCooldown;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
|
Loading…
Reference in New Issue
Block a user