ESE_Entities Class - NarcoMarshDev/Enforce-Script-Extensions Wiki

Category: Static
Path: scripts/Game/ESE_Entities.c

ESE static methods for handling entities. Versions of these may appear on a modded IEntity class in the future, if this happens it will be mentioned here and be made obvious on the home page.


The methods in this class primarily handle the following aspects of working with entities:

  • Spawning and deleting entities
  • Manipulating entities
  • Entity physics and collision
  • Materials and models


Name⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ Return⠀⠀⠀⠀⠀ Description
SpawnPrefab (vector origin, ResourceName resName) IEntity Spawns .et entity prefab at given coordinate vector, and returns reference to created entity.
SpawnPrefabOnPlayer (int playerId, ResourceName resName) IEntity Same as SpawnPrefab() but will spawn entity directly on the player referenced by the playerId.
DeleteEntity (IEntity ent) void EDeletes given entity server side, replicating to all connected clients.
DeleteEntityByRplId (RplId id) void Same as DeleteEntity() but finds entity based on RplId instead of using a direct reference.
DisableCollisions (IEntity ent) void Disables collisions of entity by destroying it's Physics if it has one, otherwise does nothing.
EnableCollisions (IEntity ent, int layerMask = 0xffffffff) void Adds collision to entity if it doesn't have any by creating new CollisionObject using given bit mask, leave layerMask as default for general use.
SetMaterial (IEntity ent, ResourceName mat, bool recursive=true) void Sets all materials of given entity's VObject to the material loaded from mat. With recursive=true all child entities have their material updated as well.
RestoreMaterial (IEntity ent, bool recursive) void Restores given entity's VObject to it's default material by finding the original materials from it's model reference. This can break sometimes with inherited entities however, check the known issues. recursive=true restores materials of all child entities too.
IsEntityOnScreen (IEntity ent) bool Checks if given entity is visible on screen on local machine, returns true if so and false if not or no valid world position for the entity is found. WIP AND CURRENTLY DISABLED BY DEFAULT