Photon Quantum 2.1.1

Classes | Public Member Functions | Public Attributes | Properties | List of all members
Quantum.Core.FrameBase Class Reference

The Frame class is the container for all the transient and static game state data, including the API for entities, physics, assets and others. More...

Inheritance diagram for Quantum.Core.FrameBase:
Quantum.Frame

Classes

class  EntitiesConfig
 Global entities configuration More...
 
struct  FrameBaseUnsafe
 Frame API to give access to C# unsafe pointers and advanced immediate operations. More...
 

Public Member Functions

AddResult Add (EntityRef entity, int componentIndex, out void *result)
 Adds a component of default value to an entity and returns a pointer to the added component. More...
 
AddResult Add (EntityRef entity, int componentIndex, void *value)
 Adds a component of defined value to an entity More...
 
AddResult Add (EntityRef entity, int componentIndex, void *value, out void *result)
 Adds a component of defined value to an entity and returns a pointer to the added component. More...
 
AddResult Add< T > (EntityRef entity)
 Adds a default component to an entity. More...
 
AddResult Add< T > (EntityRef entity, out T *result)
 Adds a component of default value to an entity and returns a pointer to the added component. More...
 
AddResult Add< T > (EntityRef entity, T value)
 Adds a component to an entity. More...
 
AddResult Add< T > (EntityRef entity, T value, out T *result)
 Adds a component of defined value to an entity and returns a pointer to the added component. More...
 
AssetGuid AddAsset (AssetObject asset)
 Adds a dynamic asset to the frame. Dynamic Asset DB generates and assigns Guids for dynamic assets, so asset can not have AssetObject.Guid set before calling this method. More...
 
bool AddOrGet (EntityRef entity, int componentIndex, out void *result)
 Adds a component of default value to an entity (if it does not have that component yet) and gets a pointer to the component. More...
 
bool AddOrGet< T > (EntityRef entity, out T *result)
 Adds a component of default value to an entity (if it does not have that component yet) and gets a pointer to the component. More...
 
void ClearAllNavMeshRegions ()
 If a navmesh region is toggled on/off is saved here. Call this method to reset every region state to be enabled again. More...
 
void ClearCulledState ()
 Marks all entities as not culled. More...
 
int ComponentCount (int componentIndex, bool includePendingRemoval=false)
 Gets the total count of components of a given index. See ComponentTypeId and ComponentTypeId<T> to have access to component types metadata. More...
 
int ComponentCount< T > (bool includePendingRemoval=false)
 Gets the total count of T components More...
 
EntityRef Create ()
 Creates an entity that is saved in the game state. More...
 
EntityRef Create (AssetRefEntityPrototype prototype)
 Creates an entity from a prototype asset. This process is also reffered to as "prototype materialization". More...
 
EntityRef Create (EntityPrototype prototype)
 Creates an entity from a prototype. This process is also reffered to as "prototype materialization". More...
 
void Create (EntityPrototypeContainer[] prototypes, Map parentAsset)
 Creates (materializes) map prototypes. The difference between this method and calling Create(EntityPrototype) repeatedly is that EntityRef fields get resolved and that MapEntityLink components are added implicitly. More...
 
void Cull (EntityRef entityRef)
 Marks a cullable and existing entity as culled. If the entity does not Exist or is not cullable, nothing is done. More...
 
bool Culled (EntityRef entityRef)
 If the entity is prediction-culled. More...
 
bool Destroy (EntityRef entityRef)
 Destroys the entity and all components that were added to it. More...
 
bool DestroyPending (EntityRef entityRef)
 Check if a destroy is pending for this entity More...
 
bool DisposeAsset (AssetGuid guid)
 Disposes an asset. More...
 
void DisposeAsset (string path, DatabaseType dbType=DatabaseType.Default)
 Disposes an asset. More...
 
bool Exists (EntityRef entityRef)
 Checks if an entity is still valid. More...
 
FindAsset< T > (AssetGuid guid)
 Retrieves an asset either from the asset database or as an dynamic asset. In case of a missing asset logs a warning. More...
 
FindAsset< T > (AssetRef assetRef)
 Retrieves an asset either from the asset database or as an dynamic asset. In case of a missing asset logs a warning. More...
 
bool FindAsset< T > (AssetRef assetRef, out T asset)
 Retrieves an asset either from the asset database or as an dynamic asset. In case of a missing asset logs a warning. More...
 
FindAsset< T > (string path, DatabaseType dbType=DatabaseType.Default)
 Retrieves an asset by path from selected databases. In case of a missing asset logs a warning. More...
 
ComponentPrototype FindPrototype (ComponentPrototypeRef prototypeRef)
 
EntityPrototypeContainer FindPrototype (EntityPrototypeRef prototypeRef)
 
Get< T > (EntityRef entityRef)
 Gets a component from an entity. More...
 
ComponentIterator< T > GetComponentIterator< T > ()
 Create a component iterator for all components of one type. More...
 
ComponentSet GetComponentSet (EntityRef entityRef)
 Gets a set of all component types that were added to the entity. More...
 
bool Has (EntityRef entityRef, ComponentSet set)
 Checks if the entity contains a whole set of components. More...
 
bool Has< T > (EntityRef entityRef)
 Checks if an entity has a component. More...
 
bool IsCullable (EntityRef entity)
 If an entity can be culled during simulation. For instance, used by the prediction culling systems to cull entities outside of the prediction area. More...
 
bool IsCulled (EntityRef entityRef)
 If an entity is currently culled from the simulation, regardless of the frame state (Predicted or Verified). More...
 
bool LoadAsset (AssetGuid guid)
 Loads an asset asynchronously into memory. More...
 
bool Remove (EntityRef entityRef, int componentIndex)
 Removes a component from an entity. More...
 
bool Remove (EntityRef entityRef, Type componentType)
 Removes a component from an entity. More...
 
bool Remove< T > (EntityRef entityRef)
 Removes a component from an entity. More...
 
void ReplaceAsset (AssetGuid guid, AssetObject asset)
 Replaces a dynamic asset in the frame. Asset asset can not have AssetObject.Path or AssetObject.Guid set as it inherits both from the original asset. More...
 
SetResult Set (EntityRef entity, AssetRefEntityPrototype prototype)
 Adds (materializes) components to an already existing entity. More...
 
SetResult Set (EntityRef entity, AssetRefEntityPrototype prototype, out ComponentSet overwrittenComponents)
 Adds (materializes) components to an already existing entity. More...
 
SetResult Set (EntityRef entity, EntityPrototype prototype)
 Adds (materializes) components to an already existing entity. If a component already exists, it will get completely overwritten, but an error message will be logged. To avoid errors in such case use Set(EntityRef, EntityPrototype, out ComponentSet) instead. More...
 
SetResult Set (EntityRef entity, EntityPrototype prototype, out ComponentSet overwrittenComponents)
 Adds (materializes) components to an already existing entity. If a component already exists, it will get completely overwritten. More...
 
SetResult Set (EntityRef entity, int componentIndex, void *value)
 Sets a component on an entity. More...
 
SetResult Set< T > (EntityRef entity, T value)
 Sets a component on an entity. More...
 
void SetCullable (EntityRef entityRef, bool cullable)
 Sets if an existing entity is cullable or not. More...
 
bool TryFindAsset< T > (AssetGuid guid, out T asset)
 Retrieves an asset either from the asset database or as an dynamic asset. More...
 
bool TryFindAsset< T > (AssetRef assetRef, out T asset)
 Retrieves an asset either from the asset database or as an dynamic asset. More...
 
bool TryFindAsset< T > (string path, out T asset, DatabaseType dbType=DatabaseType.Default)
 Retrieves an asset by path from selected databases. More...
 
bool TryFindAsset< TAssetRef, T > (TAssetRef assetRef, out T asset)
 Retrieves an asset either from the asset database or as an dynamic asset. More...
 
bool TryGet< T > (EntityRef entityRef, out T value)
 Gets a component from an entity. Does not throw when the component does not exist. More...
 
bool TryGetComponentSet (EntityRef entityRef, out ComponentSet set)
 Gets a set of all component types that were added to the entity. More...
 

Public Attributes

Physics2D.PhysicsEngine2D.Api Physics2D
 Access to the Physics2D API. More...
 
Physics3D.PhysicsEngine3D.Api Physics3D
 Access to the Physics3D API. More...
 

Properties

Navigation Navigation [get]
 Access to the Navigation API. More...
 

Detailed Description

The Frame class is the container for all the transient and static game state data, including the API for entities, physics, assets and others.

The reason for this is that Systems must be stateless to comply with Quantum's predict/rollback model. Quantum only guarantees determinism if all game state data is fully contained in the Frame class.

Member Function Documentation

◆ ComponentCount< T >()

int Quantum.Core.FrameBase.ComponentCount< T > ( bool  includePendingRemoval = false)
inline

Gets the total count of T components

Parameters
includePendingRemovalIf the component entries that were removed but are not yet committed in memory should be considered.
Template Parameters
TThe component type
Returns
Total count
Type Constraints
T :unmanaged 
T :IComponent 

◆ ComponentCount()

int Quantum.Core.FrameBase.ComponentCount ( int  componentIndex,
bool  includePendingRemoval = false 
)
inline

Gets the total count of components of a given index. See ComponentTypeId and ComponentTypeId<T> to have access to component types metadata.

Parameters
includePendingRemovalIf the component entries that were removed but are not yet committed in memory should be considered.
componentIndexThe index of the component type
Returns
Total count

◆ AddAsset()

AssetGuid Quantum.Core.FrameBase.AddAsset ( AssetObject  asset)
inline

Adds a dynamic asset to the frame. Dynamic Asset DB generates and assigns Guids for dynamic assets, so asset can not have AssetObject.Guid set before calling this method.

Parameters
assetAsset object
Returns
Asset id
PhysicsMaterial material = new PhysicsMaterial {
Restitution = 1,
FrictionCombineFunction = PhysicsCombineFunction.Average,
RestitutionCombineFunction = PhysicsCombineFunction.Average };
var assetId = f.AddAsset(material);

◆ ReplaceAsset()

void Quantum.Core.FrameBase.ReplaceAsset ( AssetGuid  guid,
AssetObject  asset 
)
inline

Replaces a dynamic asset in the frame. Asset asset can not have AssetObject.Path or AssetObject.Guid set as it inherits both from the original asset.

Parameters
guidGuid of an asset to be replaced
assetAsset object

◆ LoadAsset()

bool Quantum.Core.FrameBase.LoadAsset ( AssetGuid  guid)
inline

Loads an asset asynchronously into memory.

Parameters
guidAsset guid

Typically assets are loaded on demand. Use this method to preload assets.

◆ DisposeAsset() [1/2]

bool Quantum.Core.FrameBase.DisposeAsset ( AssetGuid  guid)
inline

Disposes an asset.

Parameters
guidAsset guid

The actual releasing of the asset is postponed and usually is triggered from the main thread at a later time.

◆ DisposeAsset() [2/2]

void Quantum.Core.FrameBase.DisposeAsset ( string  path,
DatabaseType  dbType = DatabaseType.Default 
)
inline

Disposes an asset.

Parameters
pathUnique asset path
dbType

The actual releasing of the asset is postponed and usually is triggered from the main thread at a later time.

◆ FindAsset< T >() [1/4]

T Quantum.Core.FrameBase.FindAsset< T > ( AssetGuid  guid)
inline

Retrieves an asset either from the asset database or as an dynamic asset. In case of a missing asset logs a warning.

Template Parameters
TAsset type
Parameters
guidAsset guid
Returns
Null if guid is not valid or not found, otherwise the requested asset object
Type Constraints
T :AssetObject 

◆ FindAsset< T >() [2/4]

T Quantum.Core.FrameBase.FindAsset< T > ( AssetRef  assetRef)
inline

Retrieves an asset either from the asset database or as an dynamic asset. In case of a missing asset logs a warning.

Template Parameters
TAsset type
Parameters
assetRefAsset reference
Returns
Null if reference is not valid or not found, otherwise the requested asset object
Type Constraints
T :AssetObject 

◆ FindAsset< T >() [3/4]

bool Quantum.Core.FrameBase.FindAsset< T > ( AssetRef  assetRef,
out T  asset 
)
inline

Retrieves an asset either from the asset database or as an dynamic asset. In case of a missing asset logs a warning.

Template Parameters
TAsset type
Parameters
assetRefAsset reference
assetNull if reference is not valid or not found, otherwise the requested asset object.
Returns
True if guid is valid and an asset is found
Type Constraints
T :AssetObject 

◆ TryFindAsset< T >() [1/3]

bool Quantum.Core.FrameBase.TryFindAsset< T > ( AssetGuid  guid,
out T  asset 
)
inline

Retrieves an asset either from the asset database or as an dynamic asset.

Template Parameters
TAsset type
Parameters
guidAsset guid
assetNull if guid is not valid or not found, otherwise the requested asset object
Returns
True if guid is valid and an asset is found
Type Constraints
T :AssetObject 

◆ TryFindAsset< TAssetRef, T >()

bool Quantum.Core.FrameBase.TryFindAsset< TAssetRef, T > ( TAssetRef  assetRef,
out T  asset 
)
inline

Retrieves an asset either from the asset database or as an dynamic asset.

Template Parameters
TAssetRefAsset ref type
TAsset type
Parameters
assetRefAsset reference
assetNull if reference is not valid or not found, otherwise the requested asset object
Returns
True if reference is valid and an asset is found


Type Constraints
TAssetRef :unmanaged 
TAssetRef :IAssetRef<T> 
T :AssetObject 

◆ TryFindAsset< T >() [2/3]

bool Quantum.Core.FrameBase.TryFindAsset< T > ( AssetRef  assetRef,
out T  asset 
)
inline

Retrieves an asset either from the asset database or as an dynamic asset.

Template Parameters
TAsset type
Parameters
assetRefAsset reference
assetNull if reference is not valid or not found, otherwise the requested asset object
Returns
True if reference is valid and an asset is found
Type Constraints
T :AssetObject 

◆ FindAsset< T >() [4/4]

T Quantum.Core.FrameBase.FindAsset< T > ( string  path,
DatabaseType  dbType = DatabaseType.Default 
)
inline

Retrieves an asset by path from selected databases. In case of a missing asset logs a warning.

Template Parameters
TAsset type
Parameters
pathUnique asset path
dbTypeType of the database to look in (AssetDB by default)
Returns
Null if the asset path can not be found, otherwise the requested asset object
Type Constraints
T :AssetObject 

◆ TryFindAsset< T >() [3/3]

bool Quantum.Core.FrameBase.TryFindAsset< T > ( string  path,
out T  asset,
DatabaseType  dbType = DatabaseType.Default 
)
inline

Retrieves an asset by path from selected databases.

Template Parameters
TAsset type
Parameters
pathUnique asset path
assetNull if the path is not valid or not found, otherwise the requested asset object
dbTypeType of the database to look in (AssetDB by default)
Returns
True if the path is valid and an asset is found
Type Constraints
T :AssetObject 

◆ FindPrototype() [1/2]

EntityPrototypeContainer Quantum.Core.FrameBase.FindPrototype ( EntityPrototypeRef  prototypeRef)
inline

Parameters
prototypeRef
Returns

◆ FindPrototype() [2/2]

ComponentPrototype Quantum.Core.FrameBase.FindPrototype ( ComponentPrototypeRef  prototypeRef)
inline

Parameters
prototypeRef
Returns

◆ ClearAllNavMeshRegions()

void Quantum.Core.FrameBase.ClearAllNavMeshRegions ( )
inline

If a navmesh region is toggled on/off is saved here. Call this method to reset every region state to be enabled again.

◆ Has< T >()

bool Quantum.Core.FrameBase.Has< T > ( EntityRef  entityRef)
inline

Checks if an entity has a component.

Template Parameters
TComponent type
Parameters
entityRefEntity reference
Returns
True if the component type exists on the entity
Exceptions
InvalidOperationExceptionThrown when the entity does not exist
Type Constraints
T :unmanaged 
T :IComponent 

◆ DestroyPending()

bool Quantum.Core.FrameBase.DestroyPending ( EntityRef  entityRef)
inline

Check if a destroy is pending for this entity

Parameters
entityRefEntity reference
Returns
True of destroy is pending, False otherwise

◆ Set() [1/2]

SetResult Quantum.Core.FrameBase.Set ( EntityRef  entity,
AssetRefEntityPrototype  prototype 
)
inline

Adds (materializes) components to an already existing entity.

Parameters
entity
prototype
Returns

Set(EntityRef, EntityPrototype)

◆ Set() [2/2]

SetResult Quantum.Core.FrameBase.Set ( EntityRef  entity,
AssetRefEntityPrototype  prototype,
out ComponentSet  overwrittenComponents 
)
inline

Adds (materializes) components to an already existing entity.

Parameters
entity
prototype
overwrittenComponents
Returns

Set(EntityRef, EntityPrototype, out ComponentSet)