You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: api/custom-entities/README.future.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ The Custom Entities API provides a flexible framework for managing and creating
6
6
7
7
## Implementing a Custom Entity
8
8
9
-
### Registering a New Entity Class
9
+
### 📚 Registering a New Entity Class
10
10
11
11
To implement a custom entity, the first thing you need to do is register a new entity class using the `CE_RegisterClass` native function. This can be done in the `plugin_precache` function, allowing you to place your entities directly on the map using the registered class as the `classname`.
12
12
@@ -24,9 +24,9 @@ public plugin_precache() {
24
24
25
25
In this example, the `CEPreset_Item` preset class is used to implement the item. It inherits logic for items such as pickup methods.
26
26
27
-
### Setting Entity Properties
27
+
### ⚙️ Setting Entity Members
28
28
29
-
The entity currently lacks a model and size, so let's provide them by implementing the `Allocate` method for the entity to supply all the necessary properties:
29
+
The entity currently lacks a model and size, so let's provide them by implementing the `Allocate` method for the entity to supply all the necessary members:
30
30
31
31
```cpp
32
32
public plugin_precache() {
@@ -53,7 +53,7 @@ In the implementation of the `Allocate` method, the `CE_CallBaseMethod()` call a
53
53
54
54
Natives like `CE_SetMemberString` and `CE_SetMemberVec` are used to set members/properties for the entity instance. Constants such as `CE_MEMBER_*` are used to specify the property names that will set the model each time the entity is spawned or its variables are reset. For example, `CE_MEMBER_MODEL` sets `pev->model` of the entity every respawn. Similarly, `CE_MEMBER_MINS` and `CE_MEMBER_MAXS` specify the entity's bounding box.
55
55
56
-
### Writing Logic for the Entity
56
+
### 💡 Writing Logic for the Entity
57
57
58
58
Our `item_key` entity is functional, allowing you to place the entity with the classname `item_key` on your map. It will spawn in the game and can be picked up.
59
59
@@ -93,7 +93,7 @@ public plugin_precache() {
93
93
94
94
This simple implementation will display the text `"You have found a key!"` to the player who picks up the key and mark that the player has picked up a key.
95
95
96
-
### Custom Properties
96
+
### 🧩 Custom Members
97
97
98
98
If you want to implement different key types, you can use custom members. Let's update our logic and improve the code:
99
99
@@ -185,7 +185,7 @@ Here, we added `KeyType` constants to represent different key types and implemen
185
185
186
186
You may have noticed the constant `m_iType`, which is a string constant used for the custom member we work with using `CE_GetMember` and `CE_SetMember` natives. We also use `CE_RegisterClassKeyMemberBinding` to bind this member to the entity key `type`, allowing us to change the key type by setting the `type` key-value on the map.
187
187
188
-
### Testing and Debugging
188
+
### 🕵️♂️ Testing and Debugging
189
189
190
190
> What if we don't have a map yet to test it? Is there another way to spawn our entity?
0 commit comments