2013-12-03 07:31:46 +04:00
|
|
|
//========= Copyright Valve Corporation, All rights reserved. ============//
|
|
|
|
//
|
|
|
|
// Purpose: Declares basic entity communications classes, for input/output of data
|
|
|
|
// between entities
|
|
|
|
//
|
|
|
|
// $NoKeywords: $
|
|
|
|
//=============================================================================//
|
|
|
|
|
|
|
|
#ifndef ENTITYOUTPUT_H
|
|
|
|
#define ENTITYOUTPUT_H
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#pragma once
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#include "baseentity.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define EVENT_FIRE_ALWAYS -1
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: A COutputEvent consists of an array of these CEventActions.
|
|
|
|
// Each CEventAction holds the information to fire a single input in
|
|
|
|
// a target entity, after a specific delay.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class CEventAction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CEventAction( const char *ActionData = NULL );
|
|
|
|
|
|
|
|
string_t m_iTarget; // name of the entity(s) to cause the action in
|
|
|
|
string_t m_iTargetInput; // the name of the action to fire
|
|
|
|
string_t m_iParameter; // parameter to send, 0 if none
|
|
|
|
float m_flDelay; // the number of seconds to wait before firing the action
|
|
|
|
int m_nTimesToFire; // The number of times to fire this event, or EVENT_FIRE_ALWAYS.
|
|
|
|
|
|
|
|
int m_iIDStamp; // unique identifier stamp
|
|
|
|
|
|
|
|
static int s_iNextIDStamp;
|
|
|
|
|
|
|
|
CEventAction *m_pNext;
|
|
|
|
|
|
|
|
// allocates memory from engine.MPool/g_EntityListPool
|
|
|
|
static void *operator new( size_t stAllocateBlock );
|
|
|
|
static void *operator new( size_t stAllocateBlock, int nBlockUse, const char *pFileName, int nLine );
|
|
|
|
static void operator delete( void *pMem );
|
|
|
|
static void operator delete( void *pMem , int nBlockUse, const char *pFileName, int nLine ) { operator delete(pMem); }
|
|
|
|
|
|
|
|
DECLARE_SIMPLE_DATADESC();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: Stores a list of connections to other entities, for data/commands to be
|
|
|
|
// communicated along.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class CBaseEntityOutput
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~CBaseEntityOutput();
|
|
|
|
|
|
|
|
void ParseEventAction( const char *EventData );
|
|
|
|
void AddEventAction( CEventAction *pEventAction );
|
2020-05-04 09:25:15 +03:00
|
|
|
void RemoveEventAction( CEventAction *pEventAction );
|
2013-12-03 07:31:46 +04:00
|
|
|
|
|
|
|
int Save( ISave &save );
|
|
|
|
int Restore( IRestore &restore, int elementCount );
|
|
|
|
|
|
|
|
int NumberOfElements( void );
|
|
|
|
|
|
|
|
float GetMaxDelay( void );
|
|
|
|
|
|
|
|
fieldtype_t ValueFieldType() { return m_Value.FieldType(); }
|
|
|
|
|
|
|
|
void FireOutput( variant_t Value, CBaseEntity *pActivator, CBaseEntity *pCaller, float fDelay = 0 );
|
|
|
|
|
|
|
|
/// Delete every single action in the action list.
|
|
|
|
void DeleteAllElements( void ) ;
|
|
|
|
|
2019-08-31 22:28:20 +03:00
|
|
|
#ifdef MAPBASE
|
|
|
|
// Needed for ReplaceOutput, hopefully not bad
|
|
|
|
CEventAction *GetActionList() { return m_ActionList; }
|
|
|
|
void SetActionList(CEventAction *newlist) { m_ActionList = newlist; }
|
|
|
|
#endif
|
|
|
|
|
2013-12-03 07:31:46 +04:00
|
|
|
protected:
|
|
|
|
variant_t m_Value;
|
|
|
|
CEventAction *m_ActionList;
|
|
|
|
DECLARE_SIMPLE_DATADESC();
|
|
|
|
|
|
|
|
CBaseEntityOutput() {} // this class cannot be created, only it's children
|
|
|
|
|
|
|
|
private:
|
|
|
|
CBaseEntityOutput( CBaseEntityOutput& ); // protect from accidental copying
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: wraps variant_t data handling in convenient, compiler type-checked template
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
template< class Type, fieldtype_t fieldType >
|
|
|
|
class CEntityOutputTemplate : public CBaseEntityOutput
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//
|
|
|
|
// Sets an initial value without firing the output.
|
|
|
|
//
|
|
|
|
void Init( Type value )
|
|
|
|
{
|
|
|
|
m_Value.Set( fieldType, &value );
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Sets a value and fires the output.
|
|
|
|
//
|
|
|
|
void Set( Type value, CBaseEntity *pActivator, CBaseEntity *pCaller )
|
|
|
|
{
|
|
|
|
m_Value.Set( fieldType, &value );
|
|
|
|
FireOutput( m_Value, pActivator, pCaller );
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Returns the current value.
|
|
|
|
//
|
|
|
|
Type Get( void )
|
|
|
|
{
|
|
|
|
return *((Type*)&m_Value);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// Template specializations for type Vector, so we can implement Get, Set, and Init differently.
|
|
|
|
//
|
|
|
|
template<>
|
|
|
|
class CEntityOutputTemplate<class Vector, FIELD_VECTOR> : public CBaseEntityOutput
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void Init( const Vector &value )
|
|
|
|
{
|
|
|
|
m_Value.SetVector3D( value );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Set( const Vector &value, CBaseEntity *pActivator, CBaseEntity *pCaller )
|
|
|
|
{
|
|
|
|
m_Value.SetVector3D( value );
|
|
|
|
FireOutput( m_Value, pActivator, pCaller );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Get( Vector &vec )
|
|
|
|
{
|
|
|
|
m_Value.Vector3D(vec);
|
|
|
|
}
|
Mapbase v2.0; bulk commit
- Added custom map compile tools (vbsp, vvis, vrad)
- Changed blink fix (shouldn't change anything in-game)
- Added auto-completion to ent_create, npc_create, and the main set of "npc_" debug commands
- Added ent_create_aimed, an ent_create equivalent of npc_create_aimed
- Made hunters start using the "vs. player" melee animation against smaller NPCs that look weird with the "stab" attack
- Added "explosion_sparks" convar, which fixes broken code for giving explosions sparks (disabled by default because of how different it looks)
- Made interaction code capable of being dispatched on any entity, not just combat characters
- Added npc_barnacle_ignite convar, which lets barnacles be ignited by flares
- Fixed certain NPCs getting out of the way for the player when they hate them
- Fixed auto-generated "speak" scene responses not using parameters that work on real VCDs
- Made "stop_on_nonidle" capable of being used in any mod, not just HL2 episodic mods
- Selectable color for ragdoll boogie/point_ragdollboogie
- Fixed PickupWeaponInstant not firing weapon pickup outputs
- Introduced inputs and keyvalues for "lerping" to math_counter_advanced
- Fixed ClearConsole on logic_console
- logic_convar should now detect client convars correctly
- New NormalizeAngles input on math_vector
- logic_modelinfo LookupActivity input
- math_generate fixed and expanded to be more like math_counter
- Added a WIP game logging system for playtesting maps
- Introduced logic_playerinfo, an entity that can read a player's name or ID
- Fixed some new filters not working with filter_multi
- Added radius pickup spawnflag to func_physbox
- Added "Preserve name" spawnflag to weapons
- Added cc_achievement_debug message for when an achievement doesn't exist
- Made npc_combine_s not speak while in logic_choreographed_scenes
- Fixed zombie torsos/legs/headcrabs not being serverside when zombie is forced to server ragdoll
- Expanded and cleaned up npc_zombie_custom
- Fixed func_commandredirects not cleaning up correctly and sometimes crashing the game
- Allowed player squad commands to go through +USE-held objects
- Added a bunch of I/O/KV to trigger_waterydeath for better configuration
- Changed save comment system to use the chapter title from world properties, and the ability to suppress the title popup that normally results from it
- Adjusted game_convar_mod for MP planning
- Removed the func_precipitation custom particle/splash code for now, as it was causing problems
- Fixed env_global_light not accepting lightcolor
- Added "Additional Buttons" to player_speedmod
- Added save comment to RPC
- Added env_projectedtexture attenuation
- Added scripted_sequence OnPreIdleSequence
- Added OnCrab to zombies
- Added skill_changed game event (may need further testing)
- Added a fix for viewmodels flipping under extreme FOV values
- Added code that allows mappers to change the skin on shotgunners without it usually flipping back randomly
- Fixed a very, very, very major shader performance issue
- New SetAbsOrigin/Angles inputs on all entities, analogous to SetLocalOrigin/Angles
- Code improvements for I/O involving angles
- logic_entity_position improvements/fixes, including a new OutAngles output that outputs the angles on position calls
- Alternate collision/player avoidance spawnflag obsoletion enforcement disabled
- Enable/DisableHazardLights inputs on the EP2 jalopy, equivalent to the keyvalue
- Miscellaneous shader formatting adjustments and fixes
- Fixed AlwaysDrawOff on env_projectedtexture not being a valid input
2019-12-14 07:20:02 +03:00
|
|
|
|
|
|
|
#ifdef MAPBASE
|
|
|
|
// Shortcut to using QAngles in Vector outputs, makes it look cleaner and allows easy modification
|
|
|
|
void Init( const QAngle &value )
|
|
|
|
{
|
|
|
|
// reinterpret_cast<const Vector&>(value)
|
|
|
|
m_Value.SetAngle3D( value );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Shortcut to using QAngles in Vector outputs, makes it look cleaner and allows easy modification
|
|
|
|
void Set( const QAngle &value, CBaseEntity *pActivator, CBaseEntity *pCaller )
|
|
|
|
{
|
|
|
|
// reinterpret_cast<const Vector&>(value)
|
|
|
|
m_Value.SetAngle3D( value );
|
|
|
|
FireOutput( m_Value, pActivator, pCaller );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Shortcut to using QAngles in Vector outputs, makes it look cleaner and allows easy modification
|
|
|
|
void Get( QAngle &ang )
|
|
|
|
{
|
|
|
|
m_Value.Angle3D(ang);
|
|
|
|
}
|
|
|
|
#endif
|
2013-12-03 07:31:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
class CEntityOutputTemplate<class Vector, FIELD_POSITION_VECTOR> : public CBaseEntityOutput
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void Init( const Vector &value )
|
|
|
|
{
|
|
|
|
m_Value.SetPositionVector3D( value );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Set( const Vector &value, CBaseEntity *pActivator, CBaseEntity *pCaller )
|
|
|
|
{
|
|
|
|
m_Value.SetPositionVector3D( value );
|
|
|
|
FireOutput( m_Value, pActivator, pCaller );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Get( Vector &vec )
|
|
|
|
{
|
|
|
|
m_Value.Vector3D(vec);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Purpose: parameterless entity event
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
class COutputEvent : public CBaseEntityOutput
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// void Firing, no parameter
|
|
|
|
void FireOutput( CBaseEntity *pActivator, CBaseEntity *pCaller, float fDelay = 0 );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// useful typedefs for allowed output data types
|
|
|
|
typedef CEntityOutputTemplate<variant_t,FIELD_INPUT> COutputVariant;
|
|
|
|
typedef CEntityOutputTemplate<int,FIELD_INTEGER> COutputInt;
|
|
|
|
typedef CEntityOutputTemplate<float,FIELD_FLOAT> COutputFloat;
|
|
|
|
typedef CEntityOutputTemplate<string_t,FIELD_STRING> COutputString;
|
|
|
|
typedef CEntityOutputTemplate<EHANDLE,FIELD_EHANDLE> COutputEHANDLE;
|
|
|
|
typedef CEntityOutputTemplate<Vector,FIELD_VECTOR> COutputVector;
|
|
|
|
typedef CEntityOutputTemplate<Vector,FIELD_POSITION_VECTOR> COutputPositionVector;
|
|
|
|
typedef CEntityOutputTemplate<color32,FIELD_COLOR32> COutputColor32;
|
|
|
|
|
|
|
|
#endif // ENTITYOUTPUT_H
|