Logical Entity not working

qwgg

Newbie
Joined
Sep 10, 2010
Messages
6
Reaction score
0
Hi,
I have made a logical entity in c++ to make a block disappear at a key press, "e".
It does not work and i don't know why.
Any help would be greatly appreciated.
Here is my code:
#include "cbase.h"
#include "tier0/platform.h"
#include "appframework/IAppSystem.h"

#include "inputsystem/InputEnums.h"
#include "inputsystem/ButtonCode.h"
#include "inputsystem/AnalogCode.h"


fieldtype_t x = (_fieldtypes)KEY_E;
class CMyLogicalEntity : public CLogicalEntity
{
public:
DECLARE_CLASS( CMyLogicalEntity, CLogicalEntity );
DECLARE_DATADESC();

// Constructor
CMyLogicalEntity ()
{
m_nCounter = 0;
}

// Input function
void InputTick( inputdata_t &inputData );

private:

int m_nThreshold; // Count at which to fire our output
int m_nCounter; // Internal counter
int KEY_E;
COutputEvent m_OnThreshold; // Output event when the counter reaches the threshold
};

LINK_ENTITY_TO_CLASS( my_logical_entity, CMyLogicalEntity );


// Start of our data description for the class
BEGIN_DATADESC( CMyLogicalEntity )

// For save/load
DEFINE_FIELD( m_nCounter, FIELD_INTEGER ),

// Links our member variable to our keyvalue from Hammer
DEFINE_KEYFIELD( m_nThreshold, FIELD_INTEGER, "threshold" ),

// Links our input name from Hammer to our input member function

DEFINE_INPUTFUNC( x, "Tick", InputTick ),

// Links our output member to the output name used by Hammer
DEFINE_OUTPUT( m_OnThreshold, "OnThreshold" ),

END_DATADESC()

//-----------------------------------------------------------------------------
// Purpose: Handle a tick input from another entity
//-----------------------------------------------------------------------------
void CMyLogicalEntity::InputTick( inputdata_t &inputData )
{
// Increment our counter
m_nCounter++;

// See if we've met or crossed our threshold value
if ( m_nCounter >= m_nThreshold )
{
// Fire an output event
m_OnThreshold.FireOutput( inputData.pActivator, this );

// Reset our counter
if (m_nCounter = 9)
m_nCounter = 0;
else m_nCounter = m_nCounter;
}
}
 

Similar threads

Back
Top