95 template <
typename TYPE>
99 template <
typename TYPE>
107 template <
typename TYPE>
113 template <
typename TYPE>
119 template <
typename TYPE>
122 template <
typename TYPE>
312template <
typename TYPE>
319 "Settings components in arbitrary entities while executing an async processor is currently not supported!"
326 "SetComponent: Provided value's type is not the correct size for the given ComponentId."
337template <
typename TYPE>
344 "Getting components from entities while executing an async processor is currently not supported!"
351 "GetComponent: Provided value's type is not the correct size for the given ComponentId."
362template <
typename TYPE>
369 "Removing components from entities while executing an async processor is currently not supported!"
382template <
typename TYPE>
392template <
typename TYPE>
404 !this->
pipeline.IsRunningAsync(),
"Adding component to entities while in an async processor is currently not supported!"
419 .dataSize =
sizeof(TYPE),
431 cInterface->
Init(
this, entity, data);
440template <
typename TYPE>
446 !this->
pipeline.IsRunningAsync(),
"Adding component to entities while in an async processor is currently not supported!"
460 .dataSize =
sizeof(TYPE),
472 cInterface->
Init(
this, entity, data);
These are registered to the attribute registry so that we can add more functionality to attributes.
Definition component.h:75
ComponentInitFunc Init
Definition component.h:91
Generation pool.
Definition entitypool.h:22
Definition frameevent.h:115
Represents a level that can be instantiated into a world.
Definition level.h:38
A container of entities, their components, and processors.
Definition world.h:70
PackedLevel * PreloadLevel(Util::String const &path)
preload a level that can be instantiated
Definition world.cc:87
void MoveInstance(MemDb::Table::Partition *partition, MemDb::RowId from, MemDb::RowId to)
Move a instance/row within a partition.
Definition world.cc:1388
Dataset Query(Filter filter)
Query the entity database using specified filter set. This does NOT wait for resources to be availabl...
Definition world.cc:1792
void AddStagedComponentsToEntity(Entity entity, AddStagedComponentCommand *cmds, SizeT numCmds)
Adds all components in cmds to entity.
Definition world.cc:969
Entity AllocateEntityId()
Allocate an entity id. Use this with caution!
Definition world.cc:499
bool componentInitializationEnabled
Disable if initialization of components is not required (ex. when running as editor db).
Definition world.h:190
EntityPool pool
used to allocate entity ids for this world
Definition world.h:260
Util::Array< RemoveComponentCommand > removeComponentQueue
Stores all deferred remove component commands.
Definition world.h:278
ComponentDecayBuffer const GetDecayBuffer(ComponentId component)
Get a decay buffer for the given component.
Definition world.cc:816
Ptr< MemDb::Database > db
contains all entity instances
Definition world.h:266
WorldId GetWorldId() const
Returns the world ID for this world. This corresponds to Game::Entity::world.
Definition world.h:304
bool IsValid(Entity entity) const
Check if an entity ID is still valid.
Definition world.cc:841
EntityMapping GetEntityMapping(Entity entity) const
Returns the entity mapping of an entity.
Definition world.cc:860
TYPE GetComponent(Entity entity)
Get an entitys component.
Definition world.h:339
void PrefilterProcessors()
Definition world.cc:591
void ClearDecayBuffers()
Clears all decay buffers. This is called by the game server automatically.
Definition world.cc:828
bool HasComponent(Entity entity) const
Check if entity has a specific component.
Definition world.h:384
void ExecuteAddComponentCommands()
dispatches all staged components to be added to entities
Definition world.cc:891
Entity CreateEntity(bool immediate=true)
Create a new empty entity.
Definition world.cc:665
void RenderDebug()
Definition world.cc:1499
bool cacheValid
Set to true if the caches for the frame pipeline are valid.
Definition world.h:282
Util::Queue< AllocateInstanceCommand > allocQueue
Stores all deferred allocation commands.
Definition world.h:272
void SetComponentValue(Entity entity, ComponentId component, void *value, uint64_t size)
Set the value of a component by providing a pointer and type size.
Definition world.cc:1443
void Reset()
Definition world.cc:646
void SimFrame()
Definition world.cc:547
void DeleteEntity(Entity entity)
Delete entity.
Definition world.cc:688
void ReinitializeComponent(Entity entity, ComponentId component, void *value, uint64_t size)
Set the value of a component by providing a pointer and type size, then reinitialize the component.
Definition world.cc:1461
void UnloadLevel(PackedLevel *level)
unload a preloaded level
Definition world.cc:303
~World()
Definition world.cc:78
bool HasInstance(Entity entity) const
Check if an entity has an instance. It might be valid, but not have received an instance just after i...
Definition world.cc:850
MemDb::RowId AllocateInstance(Entity entity)
Allocate an entity instance in default (empty) table without initializing components....
Definition world.cc:1191
FramePipeline pipeline
The frame pipeline for this world.
Definition world.h:284
World(WorldHash hash, WorldId id)
Definition world.cc:51
void FinalizeAllocate(Entity entity)
Definition world.cc:1277
SizeT GetNumInstances(MemDb::TableId tid)
Get total number of instances in an entity table.
Definition world.cc:882
friend class PackedLevel
Definition world.h:196
void * GetColumnData(MemDb::TableId const tableId, uint16_t partitionId, MemDb::ColumnIndex const column)
Get a pointer to the first instance of a column in a partition of an entity table....
Definition world.cc:1114
Util::FixedArray< ComponentDecayBuffer > componentDecayTable
Contains all the component decay buffers. Lookup directly via ComponentId.
Definition world.h:288
MemDb::TableId CreateEntityTable(EntityTableCreateInfo const &info)
Create a table in the entity database that has a specific set of components.
Definition world.cc:1133
void DecayComponent(ComponentId component, MemDb::TableId tableId, MemDb::ColumnIndex column, MemDb::RowId instance)
Copies the component to the decay table.
Definition world.cc:710
void RemoveComponentsFromEntity(Entity entity, RemoveComponentCommand *cmds, SizeT numCmds)
Removes all components in cmds from entity.
Definition world.cc:1038
void RemoveComponent(Entity entity)
Remove a component from an entity.
Definition world.h:364
void ExecuteRemoveComponentCommands()
dispatches all staged components to be removed from entities
Definition world.cc:931
friend class GameServer
Definition world.h:195
void DeallocateEntityId(Entity entity)
Deallocate an entity id. Use this with caution!
Definition world.cc:515
Util::Array< EntityMapping > entityMap
maps entity index to table+row pair
Definition world.h:264
FramePipeline & GetFramePipeline()
Get the frame pipeline.
Definition world.cc:1767
void BeginFrame()
Definition world.cc:537
MemDb::RowId GetInstance(Entity entity) const
Get instance of entity.
Definition world.cc:1124
WorldId worldId
world id
Definition world.h:270
void Start()
Definition world.cc:526
void EndFrame()
Definition world.cc:557
Ptr< MemDb::Database > GetDatabase()
Get the entity database. Be careful when directly modifying the database, as some information is only...
Definition world.cc:656
WorldHash GetWorldHash() const
Returns the world hash for this world.
Definition world.h:295
void Defragment(MemDb::TableId tableId)
Defragment an entity table.
Definition world.cc:1418
void DeallocateInstance(MemDb::TableId table, MemDb::RowId instance)
Deallocate an entity instance. Use this with caution!
Definition world.cc:1290
MemDb::RowId Migrate(Entity entity, MemDb::TableId newTable)
Migrate an entity from it's current table to a different table.
Definition world.cc:1328
static void Override(World *src, World *dst)
Copy src over dst without initializing components. This is extremely destructive.
Definition world.cc:1735
void ManageEntities()
Definition world.cc:601
TYPE * AddComponent(Entity entity)
Create a component. This queues the component in a command buffer to be added later.
Definition world.h:394
Util::Queue< DeallocInstanceCommand > deallocQueue
Stores all deferred deallocation commands.
Definition world.h:274
void * GetInstanceBuffer(MemDb::TableId const tableId, uint16_t partitionId, ComponentId const component)
Get a pointer to the first instance of a component in a partition of an entity table....
Definition world.cc:1096
void OnSave()
Definition world.cc:582
Util::Array< AddStagedComponentCommand > addStagedQueue
Stores all deferred add staged component commands.
Definition world.h:276
bool ExportLevel(Util::String const &path)
Export the world as a level.
Definition world.cc:312
Memory::ArenaAllocator< 4096_KB > componentStageAllocator
Allocator for staged components.
Definition world.h:280
void OnLoad()
Definition world.cc:573
SizeT numEntities
Number of entities alive.
Definition world.h:262
MemDb::TableId defaultTableId
The default table that empty entities are instantiated into.
Definition world.h:286
void MarkAsModified(Game::Entity entity)
Mark an entity as modified in its table.
Definition world.cc:1776
void SetComponent(Entity entity, TYPE const &value)
Set the value of an entitys component.
Definition world.h:314
WorldHash hash
world hash
Definition world.h:268
void InitializeInstance(Entity entity)
Initialize all components on an allocated entity instance.
Definition world.cc:1240
Definition attribute.h:29
static void const *const DefaultValue(AttributeId descriptor)
get attribute default value pointer
Definition attributeregistry.h:269
static SizeT TypeSize(AttributeId descriptor)
get type size by attribute id
Definition attributeregistry.h:247
static Attribute * GetAttribute(AttributeId descriptor)
get attribute description by id
Definition attributeregistry.h:229
Represents a partition within a Table in MemDb.
Definition table.h:205
Allocates memory in chunks.
Definition arenaallocator.h:36
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
Nebula's dynamic array class.
Definition array.h:61
The Util::Blob class encapsulates a chunk of raw memory into a C++ object which can be copied,...
Definition blob.h:22
Implements a fixed size one-dimensional array.
Definition fixedarray.h:20
Nebula's queue class (a FIFO container).
Definition queue.h:22
Nebula's universal string class.
Definition string.h:50
#define n_assert2(exp, msg)
Definition debug.h:51
#define n_assert(exp)
Definition debug.h:50
Resolves local hierarchical transforms into the mandatory world transform components.
Definition graphicsmanager.h:67
MemDb::AttributeId ComponentId
Definition componentid.h:15
uint32_t Filter
Opaque filter identifier.
Definition filter.h:26
ComponentId GetComponentId()
Returns a component id, based on template type.
Definition component.h:120
uint32_t WorldId
Definition entity.h:28
World * GetWorld(WorldHash hash)
returns a world by hash
Definition world.cc:34
ComponentId GetComponentId(Util::StringAtom name)
Returns a component id.
Definition component.h:139
Attribute.
Definition attribute.h:26
void Copy(const void *from, void *to, size_t numBytes)
Copy a chunk of memory (note the argument order is different from memcpy()!
Definition osxmemory.cc:213
A quad tree designed to return regions of free 2D space.
Definition Random.cs:4
Contains data for components flagged with COMPONENTFLAG_DECAY, that has been deleted this frame.
Definition component.h:47
A dataset that contains views into category tables.
Definition dataset.h:23
An entity is essentially just an Id with some utility functions attached.
Definition entity.h:35
static constexpr Entity Invalid()
Definition entity.h:138
Maps an entity to a table and instance id.
Definition entity.h:87
MemDb::RowId instance
Definition entity.h:89
MemDb::TableId table
Definition entity.h:88
A component that stores the orientation of an entity.
Definition orientation.h:18
A component that stores the position of an entity in world space coordinates.
Definition position.h:19
A component that stores the scale of an entity.
Definition scale.h:18
ComponentId componentId
Definition world.h:211
SizeT dataSize
Definition world.h:212
void * data
Definition world.h:213
Game::Entity entity
Definition world.h:210
Game::Entity entity
Definition world.h:200
Game::Entity entity
Definition world.h:205
ComponentId componentId
Definition world.h:219
Entity entity
Definition world.h:218
column id
Definition tableid.h:38
row identifier
Definition tableid.h:18
uint16_t partition
Definition tableid.h:19
uint16_t index
Definition tableid.h:20
Table identifier.
Definition tableid.h:14
int SizeT
Definition types.h:42