En la parte anterior del tutorial, aprendimos el trabajo básico con la VPC y cómo imprimir mensajes en la consola del desarrollador.
En esta parte del tutorial, analizaremos el sistema de entidades, aprenderemos a crear clases y crearemos nuestra primera entidad lógica.
Términos de nuevo
(entity) — .
I/O — , "" .
(input) — , . .
(output) — , .
, ?
Source — .
, worldspawn
. — "" , :
- a.k.a. — , , , etc.
- displacements (,
) — , ( CS:GO !) . , "" . - (
prop_static
).prop_dynamic
, .
( !) .
:
- — , .
- — , .
/Hammer: displacement , (vbsp)!
— , . !
, logic_auto
.
logic_5 —
, .
logic_5.cpp
.
, :src/game/server/logic_5.cpp
.
:
// cbase.h - . // . #include "cbase.h" // memdbgon.h - new delete // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h"
CLogicFive
CLogicEntity
:
class CLogicFive : public CLogicEntity { DECLARE_CLASS( CLogicFive, CLogicEntity ); public: // ... private: // ... };
-! DECLARE_CLASS()? , . —
ThisClass
BaseClass
( ...).
public
:
public: DECLARE_DATADESC(); void Input_Tick( inputdata_t &id );
?
DECLARE_DATADESC()
, .void Input_Tick( inputdata_t &id )
,tick
.
private
:
private: int m_iTicks = 0;
" "
logic_5
.
( !) —LINK_ENTITY_TO_CLASS()
!
:
// ... int m_iTicks = 0; }; LINK_ENTITY_TO_CLASS( logic_5, CLogicFive );
, 4:
BEGIN_DATADESC( CLogicFive ) DEFINE_FIELD( m_iTicks, FIELD_INTEGER ), // DEFINE_INPUTFUNC( FIELD_VOID, "tick", Input_Tick ), // END_DATADESC();
BEGIN_DATADESC()
— , .DEFINE_FIELD()
— , . , !DEFINE_INPUTFUNC()
— , . (FIELD_VOID
),tick
Input_Tick
.END_DATADESC()
— , .
Input_Tick
:
// tick() void CLogicFive::Input_Tick( inputdata_t &id ) { m_iTicks++; if( m_iTicks % 5 == 0 ) // , ! ConColorMsg( Color( 255, 255, 0 ), "logic_five: Another fifth tick!\n" ); }
[] VPC :
// src/game/server/server_episodic.vpc // - $Folder "Source Files" $File "$SRCDIR/game/server/logic_5.cpp
, , .
logic_5 —
- (
sdk_vehicles
dm_lockdown
, ) - :
ent_create logic_5
-
tick
:
ent_fire logic_5 tick
- ( ) !
?
[ , ] :
- -
?
Valve Hammer Editor FGD .
, , .