Enfusion Script API
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
ScriptComponent Interface Reference

Parent class for all components created in script. More...

Inheritance diagram for ScriptComponent:
[legend]

Public Member Functions

proto external GenericEntity GetOwner ()
 Get owner entity.
 
- 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.
 

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.
 
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 EOnDiag (IEntity owner, float timeSlice)
 Event every frame after EOnFrame, when "Entity diag" is enabled from the debug menu.
 
void EOnFixedFrame (IEntity owner, float timeSlice)
 Event every fixed frame.
 
void EOnPostFixedFrame (IEntity owner, float timeSlice)
 Event after physics update on every fixed frame.
 
void EOnActivate (IEntity owner)
 Event when component is activated.
 
void EOnDeactivate (IEntity owner)
 Event when component is deactivated.
 
void OnPostInit (IEntity owner)
 Event called after init when all components are initialized.
 
void OnDelete (IEntity owner)
 Called when Entity is being to be destroyed (deleted) or component to be deleted (see Game::DeleteScriptComponent).
 
void OnAddedToParent (IEntity child, IEntity parent)
 Called on child entity when it is added into hierarchy.
 
void OnRemovedFromParent (IEntity child, IEntity parent)
 Called on child entity when it is removed from hierarchy.
 
void OnChildAdded (IEntity parent, IEntity child)
 Called on parent entity when child entity is added into hierarchy.
 
void OnChildRemoved (IEntity parent, IEntity child)
 Called on parent entity when child entity is removed from hierarchy.
 
- 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.
 

Additional Inherited Members

- Static Public Member Functions inherited from GenericComponent
static bool Preload (IEntityComponentSource src)
 

Detailed Description

Parent class for all components created in script.

Every ScriptComponent is being created in Entity's constructor and may receive following events

  1. OnComponentInsert is being called when component is created. This is last event Workbench sends in World Editor edit mode.
  2. EOnInit is being called after all components have been inserted and if the component registered event mask EV_INIT
  3. EOnActivate is being called if the entity was flagged as TFL_ACTIVE and if the component is active. The component is active by default.
  4. EOnXXXs are being called base on event mask component registered
  5. EOnDeactivate is being called when Deactivate is called or when the component is being to be removed. Component must be active to be deactivated.
  6. OnComponentRemove is being called after a component is removed.
  7. EOnDelete is being called after entity is going to be destroyed.

Member Function Documentation

◆ EOnActivate()

void ScriptComponent.EOnActivate ( IEntity  owner)
protected

Event when component is activated.

◆ EOnAnimEvent()

void ScriptComponent.EOnAnimEvent ( IEntity  owner,
int  type,
int  slot 
)
protected

Event from animation system.

Parameters
ownerThe owner entity
type
slot

◆ EOnContact()

void ScriptComponent.EOnContact ( IEntity  owner,
IEntity  other,
Contact  contact 
)
protected

Event when physics engine registered contact with other RigidBody.

Parameters
ownerThe owner entity
otherOther Entity who contacted us
contactStructure describing the contact

◆ EOnDeactivate()

void ScriptComponent.EOnDeactivate ( IEntity  owner)
protected

Event when component is deactivated.

◆ EOnDiag()

void ScriptComponent.EOnDiag ( IEntity  owner,
float  timeSlice 
)
protected

Event every frame after EOnFrame, when "Entity diag" is enabled from the debug menu.

Parameters
ownerThe owner entity
timeSliceTime slice of simulation step

◆ EOnFixedFrame()

void ScriptComponent.EOnFixedFrame ( IEntity  owner,
float  timeSlice 
)
protected

Event every fixed frame.

Parameters
ownerThe owner entity
timeSliceFixed time step

◆ EOnFrame()

void ScriptComponent.EOnFrame ( IEntity  owner,
float  timeSlice 
)
protected

Event every frame.

Parameters
ownerThe owner entity
timeSliceTime passed since last frame

Implemented in RplExample1ComponentColorAnim, and RplExample2ComponentColorAnim.

◆ EOnInit()

void ScriptComponent.EOnInit ( IEntity  owner)
protected

Event after entity is allocated and initialized.

Parameters
ownerThe owner entity

Implemented in RplExample3System.

◆ EOnJointBreak()

void ScriptComponent.EOnJointBreak ( IEntity  owner,
IEntity  other 
)
protected

Event when joint attached to RigidBody of this entity is broken.

Parameters
ownerThe owner entity
otherOther Entity attached to the joint

◆ EOnPhysicsActive()

void ScriptComponent.EOnPhysicsActive ( IEntity  owner,
bool  activeState 
)
protected

Event when a RigidBody active state is changed between consecutive fixed steps.

Parameters
ownerThe owner entity

◆ EOnPhysicsMove()

void ScriptComponent.EOnPhysicsMove ( IEntity  owner)
protected

Event when physics engine has moved with this Entity.

Parameters
ownerThe owner entity

◆ EOnPostFixedFrame()

void ScriptComponent.EOnPostFixedFrame ( IEntity  owner,
float  timeSlice 
)
protected

Event after physics update on every fixed frame.

Parameters
ownerThe owner entity
timeSliceFixed time step

◆ EOnPostFrame()

void ScriptComponent.EOnPostFrame ( IEntity  owner,
float  timeSlice 
)
protected

Event after physics update.

Parameters
ownerThe owner entity
timeSliceTime passed since last frame

◆ EOnPostSimulate()

void ScriptComponent.EOnPostSimulate ( IEntity  owner,
float  timeSlice 
)
protected

Event after every physics fixed step (can be multiple calls per engine update)

Parameters
ownerThe owner entity
timeSliceTime slice of physics fixed step

◆ EOnSimulate()

void ScriptComponent.EOnSimulate ( IEntity  owner,
float  timeSlice 
)
protected

Event before every physics fixed step (can be multiple calls per engine update)

Parameters
ownerThe owner entity
timeSliceTime slice of physics fixed step

◆ EOnTouch()

void ScriptComponent.EOnTouch ( IEntity  owner,
IEntity  other,
int  touchTypesMask 
)
protected

Event when touched by other entity.

Note
You need to have TouchComponent in entity to receive this event.
Parameters
ownerThe owner entity
otherEntity who touched us
touchTypesMaskBitmask of touch types TouchEvent

◆ EOnVisible()

void ScriptComponent.EOnVisible ( IEntity  owner,
int  frameNumber 
)
protected

Event when we are visible.

Parameters
ownerThe owner entity
frameNumberFrame number

◆ GetOwner()

proto external GenericEntity ScriptComponent.GetOwner ( )

Get owner entity.

◆ OnAddedToParent()

void ScriptComponent.OnAddedToParent ( IEntity  child,
IEntity  parent 
)
protected

Called on child entity when it is added into hierarchy.

◆ OnChildAdded()

void ScriptComponent.OnChildAdded ( IEntity  parent,
IEntity  child 
)
protected

Called on parent entity when child entity is added into hierarchy.

◆ OnChildRemoved()

void ScriptComponent.OnChildRemoved ( IEntity  parent,
IEntity  child 
)
protected

Called on parent entity when child entity is removed from hierarchy.

◆ OnDelete()

void ScriptComponent.OnDelete ( IEntity  owner)
protected

Called when Entity is being to be destroyed (deleted) or component to be deleted (see Game::DeleteScriptComponent).

Parameters
ownerEntity which owns the component

◆ OnPostInit()

void ScriptComponent.OnPostInit ( IEntity  owner)
protected

Event called after init when all components are initialized.

Parameters
ownerEntity into which component is added

Implemented in RplExample1ComponentColorAnim, RplExample2ComponentColorAnim, RplExample3ComponentColorAnim, and RplExample3System.

◆ OnRemovedFromParent()

void ScriptComponent.OnRemovedFromParent ( IEntity  child,
IEntity  parent 
)
protected

Called on child entity when it is removed from hierarchy.

◆ RplLoad()

bool ScriptComponent.RplLoad ( ScriptBitReader  reader)
protected

Called when Item is initialized from replication stream.

Carries the data from Master.

◆ RplSave()

bool ScriptComponent.RplSave ( ScriptBitWriter  writer)
protected

Called when Item is getting replicated from Master to Slave connection.

The data will be delivered to Slave using RplInit method.


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