In the previous part of the tutorial, we learned the basic work with the VPC and how to print messages to the developer console.
In this part of the tutorial, we will break down the entity system, learn how to create classes, and create our first logical entity.
Again terms
(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 .
, , .