[NodeMod Core]
/ .. / default
Class: default
Defined in: src/enhanced/entity.ts:88
Comprehensive entity management system providing enhanced entity creation, searching, and manipulation. Wraps raw nodemod entities with convenient property accessors and utility methods.
Example
// Find all players
const players = nodemodCore.entity.find({ className\: 'player' });
players.forEach(player => {
console.log(`Player at\: ${player.origin}`);
});
// Create a light entity
const light = nodemodCore.entity.createLight([100, 200, 300], '_light', 500);
if (light) {
light.targetName = 'my_light';
}
// Find entities near a position
const nearby = nodemodCore.entity.findInSphere([0, 0, 0], 512, 'weapon_ak47');
console.log(`Found ${nearby.length} AK47s nearby`);
Constructors
Constructor
new default(
utilService
):NodemodEntity
Defined in: src/enhanced/entity.ts:97
Creates a new NodemodEntity instance.
Parameters
utilService
Utility service for entity operations
Returns
NodemodEntity
Properties
util
private
util:default
Defined in: src/enhanced/entity.ts:90
Utility service for entity operations
Methods
create()
create(
className
):null
|EntityWrapper
Defined in: src/enhanced/entity.ts:119
Creates a new entity with optional class name.
Parameters
className
Entity class name (e.g., 'info_player_start', 'weapon_ak47')
null
| string
Returns
null
| EntityWrapper
EntityWrapper for the created entity, or null if creation failed
Example
// Create a generic entity
const entity = nodemodCore.entity.create();
// Create a specific entity class
const weapon = nodemodCore.entity.create('weapon_ak47');
if (weapon) {
weapon.origin = [100, 200, 300];
}
wrap()
wrap(
entity
):null
|EntityWrapper
Defined in: src/enhanced/entity.ts:162
Wraps a raw nodemod entity with enhanced functionality while preserving nodemod.eng compatibility. The entity object itself is returned with additional methods attached, ensuring full compatibility with core nodemod.eng functions.
Parameters
entity
The raw nodemod entity to wrap
Returns
null
| EntityWrapper
EntityWrapper with enhanced functionality, or null if entity is invalid
Example
const rawEntity = nodemod.eng.pEntityOfEntIndex(1);
const wrapped = nodemodCore.entity.wrap(rawEntity);
if (wrapped) {
console.log(`Entity class\: ${wrapped.classname}`);
wrapped.health = 100;
wrapped.emitSound(0, 'items/healthkit.wav');
// Still compatible with nodemod.eng functions\:
nodemod.eng.setOrigin(wrapped, [0, 0, 0]);
}
find()
find(
criteria
):EntityWrapper
[]
Defined in: src/enhanced/entity.ts:280
Finds entities matching the specified criteria.
Parameters
criteria
Search criteria to filter entities
Returns
Array of EntityWrapper objects matching the criteria
Example
// Find all players
const players = nodemodCore.entity.find({ className\: 'player' });
// Find entities with specific target name
const targets = nodemodCore.entity.find({ targetName\: 'button_secret' });
// Find entities with specific flags
const onGroundEntities = nodemodCore.entity.find({
flags\: nodemod.FL.ONGROUND
});
// Combine multiple criteria
const healthyPlayers = nodemodCore.entity.find({
className\: 'player',
health\: 100
});
findOne()
findOne(
criteria
):null
|EntityWrapper
Defined in: src/enhanced/entity.ts:355
Finds the first entity matching the specified criteria. Convenience method for when you only need one result.
Parameters
criteria
Search criteria to filter entities
Returns
null
| EntityWrapper
First EntityWrapper matching criteria, or null if none found
Example
// Find first player
const player = nodemodCore.entity.findOne({ className\: 'player' });
if (player) {
console.log(`Player health\: ${player.health}`);
}
// Find specific target
const secretButton = nodemodCore.entity.findOne({
targetName\: 'secret_button'
});
findInSphere()
findInSphere(
origin
,radius
,className
):EntityWrapper
[]
Defined in: src/enhanced/entity.ts:390
Finds entities within a spherical radius of a position. Uses actual entity bounds, not just origin points - works correctly with brush entities.
Parameters
origin
number
[]
Center position [x, y, z] to search from
radius
number
Search radius in world units
className
Optional filter by entity class name
null
| string
Returns
Array of EntityWrapper objects within the sphere
Example
// Find all entities near player
const playerPos = [100, 200, 300];
const nearbyEntities = nodemodCore.entity.findInSphere(playerPos, 512);
// Find specific entity types nearby
const nearbyWeapons = nodemodCore.entity.findInSphere(
playerPos,
256,
'weapon_ak47'
);
// Find entities in explosion radius
const explosionPos = [0, 0, 0];
const affected = nodemodCore.entity.findInSphere(explosionPos, 200);
affected.forEach(entity => {
// Apply damage logic
});
getById()
getById(
id
):null
|EntityWrapper
Defined in: src/enhanced/entity.ts:423
Parameters
id
number
Returns
null
| EntityWrapper
getAll()
getAll():
EntityWrapper
[]
Defined in: src/enhanced/entity.ts:429
Returns
matchesCriteria()
private
matchesCriteria(entity
,criteria
):boolean
Defined in: src/enhanced/entity.ts:444
Parameters
entity
criteria
Returns
boolean
createLight()
createLight(
origin
,color
,brightness
):null
|EntityWrapper
Defined in: src/enhanced/entity.ts:477
Creates a light entity at the specified position.
Parameters
origin
number
[]
Position [x, y, z] for the light
color
string
= '_light'
Light color property name (default: '_light')
brightness
number
= 300
Light brightness value (default: 300)
Returns
null
| EntityWrapper
EntityWrapper for the created light, or null if creation failed
Example
// Create standard light
const light = nodemodCore.entity.createLight([100, 200, 300]);
// Create colored light
const redLight = nodemodCore.entity.createLight([0, 0, 0], '_light', 500);
if (redLight) {
(redLight as any)._color = '255 0 0'; // Red color
}
createInfo()
createInfo(
className
,origin
,angles
):null
|EntityWrapper
Defined in: src/enhanced/entity.ts:486
Parameters
className
string
origin
number
[]
angles
number
[] = ...
Returns
null
| EntityWrapper
createTrigger()
createTrigger(
className
,origin
,size
):null
|EntityWrapper
Defined in: src/enhanced/entity.ts:495
Parameters
className
string
origin
number
[]
size
number
[] = ...
Returns
null
| EntityWrapper
removeAll()
removeAll(
criteria
):number
Defined in: src/enhanced/entity.ts:532
Removes all entities matching the specified criteria.
Parameters
criteria
Search criteria to filter entities for removal
Returns
number
Number of entities removed
Example
// Remove all weapons from the map
const removed = nodemodCore.entity.removeAll({
className\: 'weapon_ak47'
});
console.log(`Removed ${removed} AK47s`);
// Remove entities with specific target name
nodemodCore.entity.removeAll({
targetName\: 'cleanup_target'
});
// Remove all low-health entities
nodemodCore.entity.removeAll({
health\: 1
});