Pada sebelumnya bagian dari tutorial, kami belajar pekerjaan dasar dengan VPC dan pesan mencetak ke konsol pengembang.
Di bagian tutorial ini, kita akan memecah sistem entitas, mempelajari cara membuat kelas, dan membuat entitas logis pertama kita.
Istilah lagi
(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 .
, , .