Na parte anterior do tutorial, aprendemos o trabalho básico com o VPC e a impressão de mensagens no console do desenvolvedor.
Nesta parte do tutorial, vamos dividir o sistema de entidades, aprender como criar classes e criar nossa primeira entidade lógica.
Novamente termos
(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 .
, , .