Space Engineers
Classes | Public Types | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
VRage.MyEntityIdentifier Struct Reference

Classes

class  PerThreadData
 

Public Types

enum  ID_OBJECT_TYPE : byte {
  ID_OBJECT_TYPE.UNKNOWN = 0, ID_OBJECT_TYPE.ENTITY = 1, ID_OBJECT_TYPE.IDENTITY = 2, ID_OBJECT_TYPE.FACTION = 3,
  ID_OBJECT_TYPE.NPC = 4, ID_OBJECT_TYPE.SPAWN_GROUP = 5, ID_OBJECT_TYPE.ASTEROID = 6, ID_OBJECT_TYPE.PLANET = 7,
  ID_OBJECT_TYPE.VOXEL_PHYSICS = 8, ID_OBJECT_TYPE.PLANET_ENVIRONMENT_SECTOR = 9, ID_OBJECT_TYPE.PLANET_ENVIRONMENT_ITEM = 10, ID_OBJECT_TYPE.PLANET_VOXEL_DETAIL = 11
}
 
enum  ID_ALLOCATION_METHOD : byte { ID_ALLOCATION_METHOD.RANDOM = 0, ID_ALLOCATION_METHOD.SERIAL_START_WITH_1 = 1 }
 

Static Public Member Functions

static MyEntityIdentifier ()
 
static void InitPerThreadStorage (int defaultCapacity)
 
static void LazyInitPerThreadStorage (int defaultCapacity)
 
static void DestroyPerThreadStorage ()
 
static void GetPerThreadEntities (List< IMyEntity > result)
 
static void ClearPerThreadEntities ()
 
static void Reset ()
 
static void MarkIdUsed (long id)
 This method is used when loading existing entity IDs to track the last generated ID More...
 
static void AddEntityWithId (IMyEntity entity)
 Registers entity with given ID. Do not call this directly, it is called automatically when EntityID is first time assigned. More...
 
static long AllocateId (ID_OBJECT_TYPE objectType=ID_OBJECT_TYPE.ENTITY, ID_ALLOCATION_METHOD generationMethod=ID_ALLOCATION_METHOD.RANDOM)
 Allocated new entity ID (won't add to list) Entity with this ID should be added immediatelly More...
 
static ID_OBJECT_TYPE GetIdObjectType (long id)
 
static long GetIdUniqueNumber (long id)
 
static long ConstructIdFromString (ID_OBJECT_TYPE type, string uniqueString)
 
static long ConstructId (ID_OBJECT_TYPE type, long uniqueNumber)
 
static long FixObsoleteIdentityType (long id)
 
static void RemoveEntity (long entityId)
 
static IMyEntity GetEntityById (long entityId)
 
static bool TryGetEntity (long entityId, out IMyEntity entity)
 
static bool TryGetEntity< T > (long entityId, out T entity)
 
static bool ExistsById (long entityId)
 
static void SwapRegisteredEntityId (IMyEntity entity, long oldId, long newId)
 Changes ID by which an entity is registered. Do not call this directly, it is called automatically when EntityID changes. More...
 
static void Clear ()
 

Public Attributes

const int DEFAULT_DICTIONARY_SIZE = 32768
 

Static Public Attributes

static PerThreadData m_perThreadData
 
static PerThreadData m_mainData
 
static long[] m_lastGeneratedIds = new long[(int)MyEnum<ID_OBJECT_TYPE>.Range.Max + 1]
 

Properties

static Dictionary< long, IMyEntitym_entityList [get]
 
static bool AllocationSuspended [get, set]
 Freezes allocating entity ids. This is important, because during load, no entity cannot allocate new id, because it could allocate id which already has entity which will be loaded soon. More...
 

Detailed Description

Definition at line 11 of file MyEntityIdentifier.cs.

Member Enumeration Documentation

Enumerator
RANDOM 
SERIAL_START_WITH_1 

Definition at line 64 of file MyEntityIdentifier.cs.

Enumerator
UNKNOWN 
ENTITY 
IDENTITY 
FACTION 
NPC 
SPAWN_GROUP 
ASTEROID 
PLANET 
VOXEL_PHYSICS 
PLANET_ENVIRONMENT_SECTOR 
PLANET_ENVIRONMENT_ITEM 
PLANET_VOXEL_DETAIL 

Definition at line 48 of file MyEntityIdentifier.cs.

Constructor & Destructor Documentation

static VRage.MyEntityIdentifier.MyEntityIdentifier ( )
inlinestatic

Definition at line 70 of file MyEntityIdentifier.cs.

Member Function Documentation

static void VRage.MyEntityIdentifier.AddEntityWithId ( IMyEntity  entity)
inlinestatic

Registers entity with given ID. Do not call this directly, it is called automatically when EntityID is first time assigned.

Parameters
entity

Definition at line 130 of file MyEntityIdentifier.cs.

static long VRage.MyEntityIdentifier.AllocateId ( ID_OBJECT_TYPE  objectType = ID_OBJECT_TYPE.ENTITY,
ID_ALLOCATION_METHOD  generationMethod = ID_ALLOCATION_METHOD.RANDOM 
)
inlinestatic

Allocated new entity ID (won't add to list) Entity with this ID should be added immediatelly

Definition at line 142 of file MyEntityIdentifier.cs.

static void VRage.MyEntityIdentifier.Clear ( )
inlinestatic

Definition at line 259 of file MyEntityIdentifier.cs.

static void VRage.MyEntityIdentifier.ClearPerThreadEntities ( )
inlinestatic

Definition at line 101 of file MyEntityIdentifier.cs.

static long VRage.MyEntityIdentifier.ConstructId ( ID_OBJECT_TYPE  type,
long  uniqueNumber 
)
inlinestatic

Definition at line 184 of file MyEntityIdentifier.cs.

static long VRage.MyEntityIdentifier.ConstructIdFromString ( ID_OBJECT_TYPE  type,
string  uniqueString 
)
inlinestatic

Construct an ID using the hash from a string.

Definition at line 176 of file MyEntityIdentifier.cs.

static void VRage.MyEntityIdentifier.DestroyPerThreadStorage ( )
inlinestatic

Definition at line 88 of file MyEntityIdentifier.cs.

static bool VRage.MyEntityIdentifier.ExistsById ( long  entityId)
inlinestatic

Definition at line 233 of file MyEntityIdentifier.cs.

static long VRage.MyEntityIdentifier.FixObsoleteIdentityType ( long  id)
inlinestatic

Definition at line 190 of file MyEntityIdentifier.cs.

static IMyEntity VRage.MyEntityIdentifier.GetEntityById ( long  entityId)
inlinestatic

Definition at line 206 of file MyEntityIdentifier.cs.

static ID_OBJECT_TYPE VRage.MyEntityIdentifier.GetIdObjectType ( long  id)
inlinestatic

Definition at line 163 of file MyEntityIdentifier.cs.

static long VRage.MyEntityIdentifier.GetIdUniqueNumber ( long  id)
inlinestatic

Definition at line 168 of file MyEntityIdentifier.cs.

static void VRage.MyEntityIdentifier.GetPerThreadEntities ( List< IMyEntity result)
inlinestatic

Definition at line 94 of file MyEntityIdentifier.cs.

static void VRage.MyEntityIdentifier.InitPerThreadStorage ( int  defaultCapacity)
inlinestatic

Definition at line 76 of file MyEntityIdentifier.cs.

static void VRage.MyEntityIdentifier.LazyInitPerThreadStorage ( int  defaultCapacity)
inlinestatic

Definition at line 82 of file MyEntityIdentifier.cs.

static void VRage.MyEntityIdentifier.MarkIdUsed ( long  id)
inlinestatic

This method is used when loading existing entity IDs to track the last generated ID

Definition at line 116 of file MyEntityIdentifier.cs.

static void VRage.MyEntityIdentifier.RemoveEntity ( long  entityId)
inlinestatic

Definition at line 200 of file MyEntityIdentifier.cs.

static void VRage.MyEntityIdentifier.Reset ( )
inlinestatic

Definition at line 107 of file MyEntityIdentifier.cs.

static void VRage.MyEntityIdentifier.SwapRegisteredEntityId ( IMyEntity  entity,
long  oldId,
long  newId 
)
inlinestatic

Changes ID by which an entity is registered. Do not call this directly, it is called automatically when EntityID changes.

Parameters
entityEntity whose ID has changed.
oldIdOld ID of the entity.
newIdNew ID of the entity.

Definition at line 245 of file MyEntityIdentifier.cs.

static bool VRage.MyEntityIdentifier.TryGetEntity ( long  entityId,
out IMyEntity  entity 
)
inlinestatic

Definition at line 216 of file MyEntityIdentifier.cs.

static bool VRage.MyEntityIdentifier.TryGetEntity< T > ( long  entityId,
out T  entity 
)
inlinestatic
Type Constraints
T :class 
T :IMyEntity 

Definition at line 225 of file MyEntityIdentifier.cs.

Member Data Documentation

const int VRage.MyEntityIdentifier.DEFAULT_DICTIONARY_SIZE = 32768

Definition at line 24 of file MyEntityIdentifier.cs.

long [] VRage.MyEntityIdentifier.m_lastGeneratedIds = new long[(int)MyEnum<ID_OBJECT_TYPE>.Range.Max + 1]
static

Definition at line 36 of file MyEntityIdentifier.cs.

PerThreadData VRage.MyEntityIdentifier.m_mainData
static

Definition at line 28 of file MyEntityIdentifier.cs.

PerThreadData VRage.MyEntityIdentifier.m_perThreadData
static

Definition at line 27 of file MyEntityIdentifier.cs.

Property Documentation

bool VRage.MyEntityIdentifier.AllocationSuspended
staticgetset

Freezes allocating entity ids. This is important, because during load, no entity cannot allocate new id, because it could allocate id which already has entity which will be loaded soon.

Definition at line 43 of file MyEntityIdentifier.cs.

Dictionary<long, IMyEntity> VRage.MyEntityIdentifier.m_entityList
staticget

Definition at line 30 of file MyEntityIdentifier.cs.


The documentation for this struct was generated from the following file: