Enfusion Script API
|
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. | |
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.
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.
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.
Upon destruction the component will unregister its contents from replication pipeline automatically.
Returns replication id of the registered entity child.
proto external IEntity BaseRplComponent.GetEntity | ( | ) |
Returns the entity owning the component.
proto external RplNode BaseRplComponent.GetNode | ( | ) |
proto external void BaseRplComponent.Give | ( | RplIdentity | identity | ) |
Transfers ownership of the hierarchy to given connection.
identity | connection identity. |
proto external RplId BaseRplComponent.Id | ( | ) |
Returns replication id of the RplComponent.
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.
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.
proto external bool BaseRplComponent.IsMaster | ( | ) |
If true we are both owner and authority (IsOwner() && !IsProxy())
proto external bool BaseRplComponent.IsOwner | ( | ) |
If true we are the owner of the hierarchy.
proto external bool BaseRplComponent.IsOwnerProxy | ( | ) |
proto external bool BaseRplComponent.IsProxy | ( | ) |
If true we are a proxy.
proto external bool BaseRplComponent.IsReleasedFromRpl | ( | ) |
True if entity is marked as to-be-manually-deleted by proxies after removed from replication.
proto external bool BaseRplComponent.IsRemoteProxy | ( | ) |
If true we are a ghost item - not owned while being a proxy (!IsOwner() && IsProxy())
proto external bool BaseRplComponent.IsSelfInserted | ( | ) |
Returns true if the node is self-inserting (it inserts itself to replication in BaseRplComponent's EOnInit)
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.
proto external RplRole BaseRplComponent.Role | ( | ) |
Returns current role of the component and its hierarchy within the replication.