Enfusion Script API
Loading...
Searching...
No Matches
Public Member Functions | List of all members
BaseRplComponent Interface Reference
Inheritance diagram for BaseRplComponent:
[legend]

Public Member Functions

proto external RplNode GetNode ()
 
proto external void Give (RplIdentity identity)
 Transfers ownership of the hierarchy to given connection.
 
proto external RplId Id ()
 Returns replication id of the RplComponent.
 
proto RplId ChildId (notnull Class item)
 Returns replication id of the registered entity child.
 
proto external RplRole Role ()
 Returns current role of the component and its hierarchy within the replication.
 
proto external bool IsOwner ()
 If true we are the owner of the hierarchy.
 
proto external bool IsProxy ()
 If true we are a proxy.
 
proto external bool IsMaster ()
 If true we are both owner and authority (IsOwner() && !IsProxy())
 
proto external bool IsOwnerProxy ()
 If true we are both owner and proxy (IsOwner() && IsProxy())
 
proto external bool IsRemoteProxy ()
 If true we are a ghost item - not owned while being a proxy (!IsOwner() && IsProxy())
 
proto external EItemInsertionResult InsertItem (Managed instance)
 Registers additional item into the set that will be inserted into replication when InsertToReplication is called.
 
proto external bool InsertToReplication (RplSchedulerInsertionCtx ctx=NULL)
 Inserts the component along with the entity and its children into the replication.
 
proto external IEntity GetEntity ()
 Returns the entity owning the component.
 
proto external void ReleaseFromRpl ()
 Marks the item as released from replication.
 
proto external bool IsReleasedFromRpl ()
 True if entity is marked as to-be-manually-deleted by proxies after removed from replication.
 
proto external bool IsSelfInserted ()
 Returns true if the node is self-inserting (it inserts itself to replication in BaseRplComponent's EOnInit)
 
- Public Member Functions inherited from GenericComponent
proto external EntityComponentPrefabData GetComponentData (notnull IEntity ent)
 Gets GenericComponentClass descendant instance with the prefab data.
 
proto external BaseContainer GetComponentSource (notnull IEntity ent)
 Gets config container with the prefab data.
 
proto void Rpc (func method, void p0=NULL, void p1=NULL, void p2=NULL, void p3=NULL, void p4=NULL, void p5=NULL, void p6=NULL, void p7=NULL)
 Attempts to run a remote procedure call (RPC) of this instance with parameters specified in method RplRpc attribute.
 
proto external int GetEventMask ()
 Gets current eventmask of the component.
 
proto external int SetEventMask (notnull IEntity owner, int mask)
 Sets eventmask.
 
proto external int ClearEventMask (notnull IEntity owner, int mask)
 Clears bitmask.
 
proto external GenericComponent FindComponent (TypeName typeName)
 Finds first occurance of the coresponding component.
 
proto external int FindComponents (TypeName typeName, notnull array< GenericComponent > outComponents)
 Finds all occurances of the coresponding component.
 
proto external void Activate (IEntity owner)
 Activate component and calls EOnActivate().
 
proto external void Deactivate (IEntity owner)
 Deactivate component and calls EOnDectivate().
 
proto external bool IsActive ()
 Returns activity state.
 
proto external void OnTransformReset (bool isCorrection=false, vector newVelocity=vector.Zero)
 Notifies the component that a transformation of the owner entity has been discontinuously changed.
 
void _WB_SetTransform (IEntity owner, inout vector mat[4], IEntitySource src)
 Editor changed entity transformation matrix source. Do not call editor API here!
 
void _WB_OnInit (IEntity owner, inout vector mat[4], IEntitySource src)
 Called always after entity creation. It's purpose is to prepare entity for editing. Do not edit anything through editor API here because it's too early for undoable actions! Use plain BaseContainer API for changes through src parameter if needed!
 
bool _WB_CanDelete (IEntity owner, IEntitySource src)
 Editor needs to know if this entity can be deleted. Do not call editor API here!
 
bool _WB_CanRename (IEntity owner, IEntitySource src)
 Editor needs to know if this entity can be renamed. Do not call editor API here!
 
bool _WB_CanCopy (IEntity owner, IEntitySource src)
 Editor needs to know if this entity can be copied. Do not call editor API here!
 
bool _WB_CanSelect (IEntity owner, IEntitySource src)
 Editor needs to know whether this entity can be selected in scene window or not.
 
void _WB_GetBoundBox (IEntity owner, inout vector min, inout vector max, IEntitySource src)
 Editor needs to know a bound box of entity (For ray-casting, visualizers etc.). You can return any custom size you need. Do not call editor API here!
 
void _WB_SetExtraVisualiser (IEntity owner, EntityVisualizerType type, IEntitySource src)
 If entity needs to have a special visualizer instead of default one, here is the place where you can implement it. Do not call editor API here!
 
array< ref WB_UIMenuItem_WB_GetContextMenuItems (IEntity owner)
 An opportunity to append items into editor's "Component" context menu. Do not call editor API here!
 
bool _WB_OnPhysSimulPlacementBegin (IEntity owner, IEntitySource src)
 Does this entity support editing transformation using physics simulation? Do not call editor API here!
 
bool _WB_EnablePhysics (IEntity owner, IEntitySource src, bool physics)
 Prepare to edit transformation using physics simulation. Return previous status. Do not call editor API here!
 
bool _WB_OnKeyChanged (IEntity owner, BaseContainer src, string key, BaseContainerList ownerContainers, IEntity parent)
 Any property value has been changed. You can use editor API here and do some additional edit actions which will be part of the same "key changed" action.
 
void _WB_AfterWorldUpdate (IEntity owner, float timeSlice)
 Called after updating world in Workbench. The entity must be selected. You can use editor API here and do some edit actions if needed.
 
void _WB_OnContextMenu (IEntity owner, int id)
 User has chosen any of your menu item from editor's "Component" menu which you have recently provided in WB_GetContextMenuItems(). You can use editor API here and do some edit actions.
 
void _WB_OnKeyDown (IEntity owner, int keyCode)
 User pressed a key and this entity is main member of entity selection. You can use editor API here and do some edit actions which will be undoable.
 
void _WB_OnCreate (IEntity owner, IEntitySource src)
 Called after entity gets created in map during editing or when deleted entity gets restored after undo action. This event isn't called by loading map!!! If you need an event that is being called after every entity creation then use WB_OnInit instead it. You can use editor API here and do some additional edit actions which will be part of the same "create entity" action.
 
void _WB_OnParentChange (IEntity owner, IEntitySource src, IEntitySource prevParentSrc)
 Parent entity has been changed ( it's available through src->GetParent() ). prevParentSrc is a pointer to a previous parent (if any)
 
void _WB_OnDelete (IEntity owner, IEntitySource src)
 Entity is going to be deleted. You can use editor API here and do some additional edit actions which will be part of the same "entity delete" action.
 
void _WB_OnRename (IEntity owner, IEntitySource src, string oldName)
 Entity has been renamed. You can use editor API here and do some additional edit actions which will be part of the same "entity rename" action.
 
array< ref ParamEnum_WB_GetUserEnums (string varName, IEntity owner, IEntityComponentSource src)
 Possibility to get variable value choices dynamically.
 

Additional Inherited Members

- Static Public Member Functions inherited from GenericComponent
static bool Preload (IEntityComponentSource src)
 
- Protected Member Functions inherited from GenericComponent
proto external void ConnectToDiagSystem (IEntity owner)
 
proto external void DisconnectFromDiagSystem (IEntity owner)
 
void OnTransformResetImpl (TransformResetParams params)
 Script-side implementation of OnTransformReset.
 

Detailed Description

BaseRplComponent

A convenience wrapper for RplNode in the ECS. Its role is to serve as an accessor to the nodes data as well as collector of replicated items within the entity component hierarchy.

During its initialization it traverses the hierarchy and looks for replicated items, collects them and registers into the replication pipeline.

Also listens to changes within the entity component hierarchy and calls the appropriate replication methods to replicate the hierarchy changes to replicas.

All of its features can be disabled, overridden or handled manually. For the most fine grained access to data its advisable to use the RplNode itself.

Initialization

The RplNode provides a accurate role and ownership from the time of its construction.

Then in EOnInit the InsertToReplication method is called, the hierarchy is traversed and replicated items are collected. The component looks for another BaseRplComponent instance in the direction upwards in the entity component hierarchy. If such instance is found it will become responsible for registration of this child instance.

The BaseRplComponent has a low priority setup to make it possibly the last component to be initialized. If any of the components within the hierarchy would spawn children this way they would get registered into the pipeline too.

WARNING: If anything gets spawned after the EOnInit is called on the BaseRplComponent instance it won't get registered at all.

If the user chooses to disable the SELF_INSERT mechanism he will become ultimately responsible for calling the InsertToReplication method himself.

Hierarchy changes

The component handles the hierarchy changes automatically by default. Its a convenience function that should be turned off for more complex usage.

WARNING: Not every replicated entity can change hierarchy at will. It has to be an owner of an RplNode (BaseRplComponent) as the Nodes are immutable collections in replication pipeline. There is no such mechanism that will prevent the user from doing so but it will cause a serious harm and malfunction.

Destruction

Upon destruction the component will unregister its contents from replication pipeline automatically.

Member Function Documentation

◆ ChildId()

proto RplId BaseRplComponent.ChildId ( notnull Class  item)

Returns replication id of the registered entity child.

◆ GetEntity()

proto external IEntity BaseRplComponent.GetEntity ( )

Returns the entity owning the component.

◆ GetNode()

proto external RplNode BaseRplComponent.GetNode ( )

◆ Give()

proto external void BaseRplComponent.Give ( RplIdentity  identity)

Transfers ownership of the hierarchy to given connection.

Parameters
identityconnection identity.

◆ Id()

proto external RplId BaseRplComponent.Id ( )

Returns replication id of the RplComponent.

◆ InsertItem()

proto external EItemInsertionResult BaseRplComponent.InsertItem ( Managed  instance)

Registers additional item into the set that will be inserted into replication when InsertToReplication is called.

This can be used if you need to insert some custom items into your replicated node.

Warning
Can be used only before the RplNode is inserted into the replication

◆ InsertToReplication()

proto external bool BaseRplComponent.InsertToReplication ( RplSchedulerInsertionCtx  ctx = NULL)

Inserts the component along with the entity and its children into the replication.

Keep in mind that only items with replication code will be registered and receive the RplId.

◆ IsMaster()

proto external bool BaseRplComponent.IsMaster ( )

If true we are both owner and authority (IsOwner() && !IsProxy())

◆ IsOwner()

proto external bool BaseRplComponent.IsOwner ( )

If true we are the owner of the hierarchy.

◆ IsOwnerProxy()

proto external bool BaseRplComponent.IsOwnerProxy ( )

If true we are both owner and proxy (IsOwner() && IsProxy())

◆ IsProxy()

proto external bool BaseRplComponent.IsProxy ( )

If true we are a proxy.

◆ IsReleasedFromRpl()

proto external bool BaseRplComponent.IsReleasedFromRpl ( )

True if entity is marked as to-be-manually-deleted by proxies after removed from replication.

◆ IsRemoteProxy()

proto external bool BaseRplComponent.IsRemoteProxy ( )

If true we are a ghost item - not owned while being a proxy (!IsOwner() && IsProxy())

◆ IsSelfInserted()

proto external bool BaseRplComponent.IsSelfInserted ( )

Returns true if the node is self-inserting (it inserts itself to replication in BaseRplComponent's EOnInit)

◆ ReleaseFromRpl()

proto external void BaseRplComponent.ReleaseFromRpl ( )

Marks the item as released from replication.

Items marked this way won't be physically deleted once removed from replication. When released, proxies will have to delete their entities manually after they're removed from replication.

Warning
Only has effect if called by the authority

◆ Role()

proto external RplRole BaseRplComponent.Role ( )

Returns current role of the component and its hierarchy within the replication.


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