Enfusion Script API
|
Base entity class. More...
Public Member Functions | |
proto external void | Activate () |
Activate entity events. | |
proto external void | Deactivate () |
Deactivate entity events. | |
proto external void | Show (bool show) |
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 WorldEditorAPI | _WB_GetEditorAPI () |
This returns world editor API, which is safe to use from editor events bellow. | |
proto external void | OnTransformReset (bool isCorrection=false, vector newVelocity=vector.Zero) |
Notifies the entity that its transformation has been discontinuously changed. | |
IEntity | _WB_GetEditableOwner () |
Editor needs to know if there is any entity which manages this one and is editable. | |
void | _WB_MakeVisible (IEntitySource src, bool visible) |
Editor needs to have entity visible or not. Do not call editor API here! | |
void | _WB_SetTransform (inout vector mat[4], IEntitySource src) |
Editor changed transformation matrix source. This is the place to apply it on entity. Do not call editor API here! | |
void | _WB_OnInit (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 (IEntitySource src) |
Editor needs to know if this entity can to be deleted. Do not call editor API here! | |
bool | _WB_CanRename (IEntitySource src) |
Editor needs to know if this entity can to be renamed. Do not call editor API here! | |
bool | _WB_CanCopy (IEntitySource src) |
Editor needs to know if this entity can be copied. Do not call editor API here! | |
bool | _WB_CanSelect (IEntitySource src) |
Editor needs to know whether this entity can be selected in scene window or not. | |
int | _WB_GetAnchorCount (IEntitySource src) |
Returns how many anchor points does this entity have at this time. | |
void | _WB_GetAnchor (inout vector position, IEntitySource src, int index) |
Fills position of anchor at index index to anchorPosition | |
void | _WB_OnAnchorSnapped (IEntitySource thisSrc, int thisAnchor, IEntitySource otherSrc, int otherAnchor, bool isReceiver) |
Called when two entities are snapped together. | |
bool | _WB_CanAnchorSnap (IEntitySource thisSrc, int thisAnchor, IEntitySource otherSrc, int otherAnchor, bool isReceiver) |
void | _WB_GetBoundBox (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! | |
bool | _WB_ShouldShowBoundBox (IEntitySource src) |
Returns true if bound box should be visible when entity is hovered/selected in WB. | |
void | _WB_SetExtraVisualiser (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 () |
An opportunity to append items into editor's "Entity" context menu. Do not call editor API here! | |
bool | _WB_OnPhysSimulPlacementBegin (IEntitySource src) |
Does this entity support editing transformation using physics simulation? Do not call editor API here! | |
bool | _WB_EnablePhysics (IEntitySource src, bool physics) |
Prepare to edit transformation using physics simulation. Return previous status. Do not call editor API here! | |
array< ref ParamEnum > | _WB_GetUserEnums (string varName, IEntitySource src) |
Possibility to get variable value choices dynamically. Do not call editor API here! | |
bool | _WB_OnKeyChanged (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 (float timeSlice) |
Called after updating world in Workbench. The entity must be visible in frustum, selected or named. You can use editor API here and do some edit actions if needed. | |
void | _WB_OnContextMenu (int id) |
User has chosen any of your menu item from editor's "Entity" menu which you have recently provided in WB_GetContextMenuItems(). You can use editor API here and do some edit actions. | |
void | _WB_OnKeyDown (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 (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 (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 (IEntitySource src) |
This 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 (IEntitySource src, string oldName) |
This 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. | |
Public Member Functions inherited from IEntity | |
proto external EntityID | GetID () |
Return unique entity ID. | |
proto external IEntity | GetParent () |
Returns parent of this entity (entity on upper level of hierarchy). | |
proto external IEntity | GetRootParent () |
Returns top-parent of this entity. | |
proto external IEntity | GetChildren () |
Returns first child from this level of hierarchy if there is any. | |
proto external IEntity | GetSibling () |
Returns next sibling of this entity (next entity on this level of hierarchy). | |
proto external VObject | GetVObject () |
Returns visual object set to this Entity. No reference is added. | |
proto external EntityPrefabData | GetPrefabData () |
proto external EntityComponentPrefabData | FindComponentData (TypeName typeName) |
proto external BaseWorld | GetWorld () |
proto external void | SetFixedLOD (int lod) |
Set fixed LOD. Use -1 for non-fixed LOD. | |
proto external void | GetTransform (out vector mat[]) |
Returns world transformation of Entity. | |
proto external void | GetWorldTransform (out vector mat[]) |
See IEntity::GetTransform. | |
proto external void | GetLocalTransform (out vector mat[]) |
See IEntity::GetTransform. | |
proto external vector | VectorToParent (vector vec) |
Transforms local vector to parent(world) space. | |
proto external vector | CoordToParent (vector coord) |
Transforms local position to parent(world) space. | |
proto external vector | VectorToLocal (vector vec) |
Transforms world space vector to local space. | |
proto external vector | CoordToLocal (vector coord) |
Transforms world space position to local space. | |
proto external vector | GetYawPitchRoll () |
Returns orientation of Entity in world space (Yaw, Pitch, Roll). | |
proto external void | SetYawPitchRoll (vector angles) |
Sets angles for entity (Yaw, Pitch, Roll). | |
proto external vector | GetWorldTransformAxis (int axis) |
See IEntity::GetTransformAxis. | |
proto external vector | GetTransformAxis (int axis) |
See IEntity::GetTransformAxis. | |
proto external vector | GetLocalTransformAxis (int axis) |
See IEntity::GetTransformAxis. | |
proto external bool | SetLocalTransform (vector mat[4]) |
See IEntity::SetTransform. Returns false , if there is no change in transformation. | |
proto external bool | SetWorldTransform (vector mat[4]) |
See IEntity::SetTransform. Returns false , if there is no change in transformation. | |
proto external TNodeId | GetPivot () |
Returns pivot ID from hierarchy component. | |
proto external bool | SetTransform (vector mat[4]) |
Sets entity world transformation. | |
proto external vector | GetLocalAngles () |
Same as GetLocalYawPitchRoll(), but returns rotation vector around X, Y and Z axis. | |
proto external vector | GetLocalYawPitchRoll () |
Returns local orientation when it's in hierarchy (Yaw, Pitch, Roll). | |
proto external vector | GetAngles () |
Same as GetYawPitchRoll(), but returns rotation vector around X, Y and Z axis. | |
proto external void | SetAngles (vector angles) |
Same as SetYawPitchRoll(), but sets rotation around X, Y and Z axis. | |
proto external vector | GetOrigin () |
Returns origin of Entity. | |
proto external void | SetOrigin (vector orig) |
Sets origin for entity. | |
proto external void | SetScale (float scale) |
proto external float | GetScale () |
proto external void | GetBounds (out vector mins, out vector maxs) |
Returns local bounding box of model on Entity. | |
proto external void | GetWorldBounds (out vector mins, out vector maxs) |
Returns quantized world-bound-box of Entity. | |
proto external volatile void | SendEvent (notnull IEntity actor, EntityEvent e, void extra) |
Dynamic event invocation. Parameters are the same as in IEntity::EOnXXXX() methods. | |
proto external string | GetName () |
proto external int | SetVComponentFlags (VCFlags flags) |
Sets component flags. | |
proto external void | SetObject (VObject object, string options) |
Sets the visual object to this entity. | |
proto external EntityFlags | SetFlags (EntityFlags flags, bool recursively=false) |
Sets Entity flags. | |
proto external EntityFlags | ClearFlags (EntityFlags flags, bool recursively=false) |
Clear Entity flags. | |
proto external EntityFlags | GetFlags () |
Returns Entity flags. | |
proto external EntityEvent | SetEventMask (EntityEvent e) |
Sets event mask. | |
proto external EntityEvent | ClearEventMask (EntityEvent e) |
Clears event mask. | |
proto external EntityEvent | GetEventMask () |
Returns current event mask. | |
proto external bool | IsLoaded () |
proto external bool | IsRemoved () |
proto external bool | IsDeleted () |
proto external int | Update () |
Updates entity state/position. | |
proto external int | AddChild (notnull IEntity child, TNodeId pivot, EAddChildFlags flags=EAddChildFlags.AUTO_TRANSFORM) |
Add Entity to hierarchy. Pivot is pivot index, or -1 for center of parent. | |
proto external void | RemoveChild (notnull IEntity child, bool keepTransform=false) |
Remove Entity from hierarchy. | |
proto external void | SetName (string name) |
proto external int | SetCameraMask (int mask) |
Sets visibility mask for cameras, where Entity will be rendered. | |
proto external Physics | GetPhysics () |
proto external Particles | GetParticles () |
proto external Animation | GetAnimation () |
proto external int | Animate (float speed, int loop) |
Updates animation (either xob, or particle, whatever). | |
proto external int | AnimateEx (float speed, int loop, out vector lin, out vector ang) |
Updates animation (either xob, or particle, whatever). | |
proto external void | SetBone (TNodeId bone, vector angles, vector trans, float scale) |
proto external bool | SetBoneMatrix (TNodeId bone, vector mat[4]) |
proto external bool | GetBoneMatrix (TNodeId bone, out vector mat[4]) |
proto external TNodeId | GetBoneIndex (string boneName) |
proto external void | GetBoneNames (out notnull array< string > boneNames) |
proto external bool | GetBoneLocalMatrix (TNodeId bone, out vector mat[4]) |
proto external Managed | FindComponent (TypeName typeName) |
Finds first occurance of the coresponding component. | |
proto external int | FindComponents (TypeName typeName, notnull array< Managed > outComponents) |
Finds all occurances of the coresponding component. | |
Public Member Functions inherited from Managed | |
proto external ref Managed | Clone () |
Return shallow copy of object, or null if it is not allowed (not public constructor) | |
Static Public Member Functions | |
static bool | Preload (IEntitySource src) |
static proto void | GetMatrixFromSource (BaseWorld world, IEntitySource src, bool withScale, out vector mat[4]) |
Protected Member Functions | |
bool | RplLoad (ScriptBitReader reader) |
Called when Item is initialized from replication stream. | |
bool | RplSave (ScriptBitWriter writer) |
Called when Item is getting replicated from Master to Slave connection. | |
proto external void | ConnectToDiagSystem () |
proto external void | DisconnectFromDiagSystem () |
void | EOnDiag (IEntity owner, float timeSlice) |
void | EOnActivate (IEntity owner) |
Event when entity is activated. | |
void | EOnDeactivate (IEntity owner) |
Event when entity is deactivated. | |
void | OnTransformResetImpl (TransformResetParams params) |
Script-side implementation of OnTransformReset. | |
Protected Member Functions inherited from IEntity | |
void | EOnTouch (IEntity owner, IEntity other, int touchTypesMask) |
Event when touched by other entity. | |
void | EOnInit (IEntity owner) |
Event after entity is allocated and initialized. | |
void | EOnVisible (IEntity owner, int frameNumber) |
Event when we are visible. | |
void | EOnFrame (IEntity owner, float timeSlice) |
Event every frame. | |
void | EOnPostFrame (IEntity owner, float timeSlice) |
Event after physics update. | |
void | EOnAnimEvent (IEntity owner, int type, int slot) |
Event from animation system. | |
void | EOnSimulate (IEntity owner, float timeSlice) |
Event before every physics fixed step (can be multiple calls per engine update) | |
void | EOnPostSimulate (IEntity owner, float timeSlice) |
Event after every physics fixed step (can be multiple calls per engine update) | |
void | EOnJointBreak (IEntity owner, IEntity other) |
Event when joint attached to RigidBody of this entity is broken. | |
void | EOnPhysicsMove (IEntity owner) |
Event when physics engine has moved with this Entity. | |
void | EOnContact (IEntity owner, IEntity other, Contact contact) |
Event when physics engine registered contact with other RigidBody. | |
void | EOnPhysicsActive (IEntity owner, bool activeState) |
Event when a RigidBody active state is changed between consecutive fixed steps. | |
void | EOnFixedFrame (IEntity owner, float timeSlice) |
Event every fixed frame. | |
void | EOnFixedPostFrame (IEntity owner, float timeSlice) |
Event after physics update every fixed frame. | |
void | EOnUser0 (IEntity other, int extra) |
EntityEvent.EV_USER+0. | |
void | EOnUser1 (IEntity other, int extra) |
EntityEvent.EV_USER+1. | |
void | EOnUser2 (IEntity other, int extra) |
EntityEvent.EV_USER+2. | |
void | EOnUser3 (IEntity other, int extra) |
EntityEvent.EV_USER+3. | |
void | EOnUser4 (IEntity other, int extra) |
EntityEvent.EV_USER+4. | |
void | IEntity (IEntitySource src, IEntity parent) |
protected script Constructor | |
Base entity class.
void GenericEntity._WB_AfterWorldUpdate | ( | float | timeSlice | ) |
Called after updating world in Workbench. The entity must be visible in frustum, selected or named. You can use editor API here and do some edit actions if needed.
bool GenericEntity._WB_CanAnchorSnap | ( | IEntitySource | thisSrc, |
int | thisAnchor, | ||
IEntitySource | otherSrc, | ||
int | otherAnchor, | ||
bool | isReceiver | ||
) |
Implemented in CrossroadEntity.
bool GenericEntity._WB_CanCopy | ( | IEntitySource | src | ) |
Editor needs to know if this entity can be copied. Do not call editor API here!
bool GenericEntity._WB_CanDelete | ( | IEntitySource | src | ) |
Editor needs to know if this entity can to be deleted. Do not call editor API here!
bool GenericEntity._WB_CanRename | ( | IEntitySource | src | ) |
Editor needs to know if this entity can to be renamed. Do not call editor API here!
bool GenericEntity._WB_CanSelect | ( | IEntitySource | src | ) |
Editor needs to know whether this entity can be selected in scene window or not.
Implemented in RoadGeneratorEntity.
bool GenericEntity._WB_EnablePhysics | ( | IEntitySource | src, |
bool | physics | ||
) |
Prepare to edit transformation using physics simulation. Return previous status. Do not call editor API here!
void GenericEntity._WB_GetAnchor | ( | inout vector | position, |
IEntitySource | src, | ||
int | index | ||
) |
Fills position of anchor at index index
to anchorPosition
Implemented in CrossroadEntity.
int GenericEntity._WB_GetAnchorCount | ( | IEntitySource | src | ) |
Returns how many anchor points does this entity have at this time.
Implemented in CrossroadEntity.
void GenericEntity._WB_GetBoundBox | ( | 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!
Implemented in WorldDecal.
array< ref WB_UIMenuItem > GenericEntity._WB_GetContextMenuItems | ( | ) |
An opportunity to append items into editor's "Entity" context menu. Do not call editor API here!
IEntity GenericEntity._WB_GetEditableOwner | ( | ) |
Editor needs to know if there is any entity which manages this one and is editable.
proto external WorldEditorAPI GenericEntity._WB_GetEditorAPI | ( | ) |
This returns world editor API, which is safe to use from editor events bellow.
array< ref ParamEnum > GenericEntity._WB_GetUserEnums | ( | string | varName, |
IEntitySource | src | ||
) |
Possibility to get variable value choices dynamically. Do not call editor API here!
void GenericEntity._WB_MakeVisible | ( | IEntitySource | src, |
bool | visible | ||
) |
Editor needs to have entity visible or not. Do not call editor API here!
void GenericEntity._WB_OnAnchorSnapped | ( | IEntitySource | thisSrc, |
int | thisAnchor, | ||
IEntitySource | otherSrc, | ||
int | otherAnchor, | ||
bool | isReceiver | ||
) |
Called when two entities are snapped together.
isReceiver | True if another entity snapped to this one, false otherwise. |
Implemented in CrossroadEntity.
void GenericEntity._WB_OnContextMenu | ( | int | id | ) |
User has chosen any of your menu item from editor's "Entity" menu which you have recently provided in WB_GetContextMenuItems(). You can use editor API here and do some edit actions.
void GenericEntity._WB_OnCreate | ( | 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.
Implemented in RoadGeneratorEntity.
void GenericEntity._WB_OnDelete | ( | IEntitySource | src | ) |
This 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.
Implemented in RoadGeneratorEntity.
void GenericEntity._WB_OnInit | ( | 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 GenericEntity._WB_OnKeyChanged | ( | 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.
Implemented in CrossroadEntity, and RoadGeneratorEntity.
void GenericEntity._WB_OnKeyDown | ( | 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 GenericEntity._WB_OnParentChange | ( | 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)
bool GenericEntity._WB_OnPhysSimulPlacementBegin | ( | IEntitySource | src | ) |
Does this entity support editing transformation using physics simulation? Do not call editor API here!
void GenericEntity._WB_OnRename | ( | IEntitySource | src, |
string | oldName | ||
) |
This 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.
void GenericEntity._WB_SetExtraVisualiser | ( | 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!
Implemented in WorldDecal.
void GenericEntity._WB_SetTransform | ( | inout vector | mat[4], |
IEntitySource | src | ||
) |
Editor changed transformation matrix source. This is the place to apply it on entity. Do not call editor API here!
Implemented in WorldDecal.
bool GenericEntity._WB_ShouldShowBoundBox | ( | IEntitySource | src | ) |
Returns true if bound box should be visible when entity is hovered/selected in WB.
proto external void GenericEntity.Activate | ( | ) |
Activate entity events.
Will also activate all components of the entity.
|
protected |
proto external void GenericEntity.Deactivate | ( | ) |
Deactivate entity events.
Will also deactivate all components of the entity.
|
protected |
|
static |
proto external void GenericEntity.OnTransformReset | ( | bool | isCorrection = false , |
vector | newVelocity = vector.Zero |
||
) |
Notifies the entity that its transformation has been discontinuously changed.
Should be called after any transformation discontinuity (right after updating the transform) e.g. by teleportation or desync-correction code so the entity can react appropriately.
The default implementation handles Particles (if present on the entity) and calls OnTransformReset on all of the entity's GenericComponent instances and child GenericEntity instances with auto-transform enabled (i.e. it handles the whole entity and component hierarchy by recursion).
The default behavior may be changed in inherited entities by overriding OnTransformResetImpl.
isCorrection | [optional] Hint that the transform was reset due to its correction (e.g. by net-code), i.e. not a placement/teleport |
newVelocity | [optional] Initial velocity of the entity after the transform reset |
|
protected |
Script-side implementation of OnTransformReset.
The default implementation handles Particles (if present on the entity) and calls OnTransformReset on all of the entity's GenericComponent instances and child GenericEntity instances (i.e. it handles the whole entity and component hierarchy by recursion).
Can be overridden to alter the default behavior. Usually, you'll want to call the base implementation somewhere in the override to preserve the recursion.
params | See the TransformResetParams documentation. |
|
static |
proto void GenericEntity.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.
method | Member function to be invoked as an RPC. |
|
protected |
Called when Item is initialized from replication stream.
Carries the data from Master.
|
protected |
Called when Item is getting replicated from Master to Slave connection.
The data will be delivered to Slave using RplInit method.
proto external void GenericEntity.Show | ( | bool | show | ) |