Ru/Generalities On Entities: Difference between revisions

From Valve Developer Community
< Ru
Jump to navigation Jump to search
m (Nesciuse moved page Generalities On Entities:ru to Ru/Generalities On Entities over redirect: -Language prefixes)
m (Using L template for links)
Line 19: Line 19:
  Client: C_MyEntity
  Client: C_MyEntity


Стиль (соглашение) имён, которому следует основной код SDK, известен как [[Wikipedia:Hungarian notation|Венгерская нотация]]. Начинающим рекомендуется придерживаться того же стиля, что и в основном коде, для устранения недоразумений.
Стиль (соглашение) имён, которому следует основной код SDK, известен как {{L|Wikipedia:Hungarian notation|Венгерская нотация}}. Начинающим рекомендуется придерживаться того же стиля, что и в основном коде, для устранения недоразумений.


== Базовые классы ==
== Базовые классы ==
Line 30: Line 30:


=== CBaseTrigger ===
=== CBaseTrigger ===
[[trigger|Триггеры]] - это сущности-кисти, которые, в основном, размещаются в процессе создания карты.
{{L|trigger|Триггеры}} - это сущности-кисти, которые, в основном, размещаются в процессе создания карты.


=== CBasePlayer ===
=== CBasePlayer ===
Line 43: Line 43:
{{main|Think()}}
{{main|Think()}}
Think functions are a group of functions comprising the main way to have an entity act without input.  
Think functions are a group of functions comprising the main way to have an entity act without input.  
An entity's Think() is run once after it spawns, and can be told when to call itself again using SetNextThink(). Using SetThink() can change between several Think() functions, and GetLastThink() returns the time of the last think function. See [[Think()]] for detailed description.
An entity's Think() is run once after it spawns, and can be told when to call itself again using SetNextThink(). Using SetThink() can change between several Think() functions, and GetLastThink() returns the time of the last think function. See {{L|Think()}} for detailed description.


== Макросы ==
== Макросы ==
Badly set up macros will give error messages, crash the game and cause erratic behavior. Далее следует список определений наиболее часто используемых макросов и некоторые проблемы, возникающие в процессе их использования.
Badly set up macros will give error messages, crash the game and cause erratic behavior. Далее следует список определений наиболее часто используемых макросов и некоторые проблемы, возникающие в процессе их использования.


=== [[LINK_ENTITY_TO_CLASS]]() ===
=== {{L|LINK_ENTITY_TO_CLASS}}() ===
This is one of the main macros. An entity cannot be created without this macro being used to define the entity's classname (as returned from <code>GetClassname()</code> on the server). However, on the client, an entity will not return its classname unless there is a matching data description (<code>DATADESC</code>).
This is one of the main macros. An entity cannot be created without this macro being used to define the entity's classname (as returned from <code>GetClassname()</code> on the server). However, on the client, an entity will not return its classname unless there is a matching data description (<code>DATADESC</code>).


=== [[PRECACHE_REGISTER]]() ===
=== {{L|PRECACHE_REGISTER}}() ===
This is used to tell the engine that it needs to precache the entity when it loads. This is provided with the name of the entity (the same name as passed to [[LINK_ENTITY_TO_CLASS]]() ).
This is used to tell the engine that it needs to precache the entity when it loads. This is provided with the name of the entity (the same name as passed to {{L|LINK_ENTITY_TO_CLASS}}() ).


=== [[DECLARE_CLASS]]() ===
=== {{L|DECLARE_CLASS}}() ===
This should be placed in the public section of an entities Class definition. This provides access to the BaseClass Macro.
This should be placed in the public section of an entities Class definition. This provides access to the BaseClass Macro.


=== DECLARE_[[DATADESC]](), BEGIN_[[DATADESC]](), END_[[DATADESC]](), and DEFINE_XXX() ===
=== DECLARE_{{L|DATADESC}}(), BEGIN_{{L|DATADESC}}(), END_{{L|DATADESC}}(), and DEFINE_XXX() ===


The Data Description macros provide for a number of different features;
The Data Description macros provide for a number of different features;
Line 64: Line 64:
* Providing external variable inputs (such as setting a model or the health of an item)
* Providing external variable inputs (such as setting a model or the health of an item)


Подробная информация доступна на странице [[Data Descriptions]].
Подробная информация доступна на странице {{L|Data Descriptions}}.


=== Networking сущности ===
=== Networking сущности ===

Revision as of 07:27, 11 July 2024

English (en)Русский (ru)Translate (Translate)
Info content.png
This page needs to be translated.
This page either contains information that is only partially or incorrectly translated, or there isn't a translation yet.
If this page cannot be translated for some reason, or is left untranslated for an extended period of time after this notice is posted, the page should be requested to be deleted.
Also, please make sure the article complies with the alternate languages guide.(en)

Введение

Note.pngПримечание:В данной статье предполагается, что читатель имеет хотя бы базовый опыт работы в C++

Эта статья кратко описывает сущности в Source engine и пытается объяснить все про сущности.

Каждый объект, даже мир, является сущностью в Source Engine. Все сущности являются производными от CBaseEntity.

Соглашения имён

В Source SDK, класс server начинается с большой буквы С (C), в то время как класс client начинается с большой буквы С с последующим подчеркиванием (C_) - это помогает различать две базы кода.

Пример:

Server: CMyEntity
Client: C_MyEntity

Стиль (соглашение) имён, которому следует основной код SDK, известен как Венгерская нотация(en). Начинающим рекомендуется придерживаться того же стиля, что и в основном коде, для устранения недоразумений.

Базовые классы

Каждая сущность основана на базовом классе CBaseEntity, однако есть много производных классов. Ниже приведен список наиболее распространенных производных классов.

CBaseAnimating

Каждая сущность, имеющая модель, должна использовать класс CBaseAnimating. Классы, производные от CBaseAnimating могут использовать модели и анимацию.

Note.pngПримечание:Сущности без моделей по умолчанию не networked. Обойти это ограничение можно, используя функцию AddEFlags( EFL_FORCE_CHECK_TRANSMIT );
Note.pngПримечание:Для использования движущихся моделей необходимо инициализировать частоту кадров проигрывателя, используя функцию SetPlaybackRate(1.0f);, и вызвать StudioFrameAdvance(); в функции think.

CBaseTrigger

Триггеры(en) - это сущности-кисти, которые, в основном, размещаются в процессе создания карты.

CBasePlayer

Эта сущность описывает игрока. Каждая сущность-игрок является экземпляром класса CBasePlayer или его класса-потомка.

CGameRules

Эта сущность описывает правила игры. В основном используется для описания логики игры.

CBaseCombatCharacter

Все сущности-NPC и игроки являются производными от этого класса.

Функции Think

Основная статья:  Think()

Think functions are a group of functions comprising the main way to have an entity act without input. An entity's Think() is run once after it spawns, and can be told when to call itself again using SetNextThink(). Using SetThink() can change between several Think() functions, and GetLastThink() returns the time of the last think function. See Think()(en) for detailed description.

Макросы

Badly set up macros will give error messages, crash the game and cause erratic behavior. Далее следует список определений наиболее часто используемых макросов и некоторые проблемы, возникающие в процессе их использования.

LINK_ENTITY_TO_CLASS(en)()

This is one of the main macros. An entity cannot be created without this macro being used to define the entity's classname (as returned from GetClassname() on the server). However, on the client, an entity will not return its classname unless there is a matching data description (DATADESC).

PRECACHE_REGISTER(en)()

This is used to tell the engine that it needs to precache the entity when it loads. This is provided with the name of the entity (the same name as passed to LINK_ENTITY_TO_CLASS(en)() ).

DECLARE_CLASS(en)()

This should be placed in the public section of an entities Class definition. This provides access to the BaseClass Macro.

DECLARE_DATADESC(en)(), BEGIN_DATADESC(en)(), END_DATADESC(en)(), and DEFINE_XXX()

The Data Description macros provide for a number of different features;

  • Specifying Think and Touch functions
  • Providing Inputs and Outputs for mappers
  • Providing external variable inputs (such as setting a model or the health of an item)

Подробная информация доступна на странице Data Descriptions(en).

Networking сущности

См. раздел Networking для получения подробной информации о networking сущностях, так как их описание выходит за рамки данной статьи.