API Entities and Components - Krystian-L-Lis/Stage GitHub Wiki
#API #EntitiesAndComponents
Type: Interface
Extends: I_Debug
, __System.IQueryInterface
Description:
Alias for __System.IQueryInterface
. It can be cast to other interfaces.
Type: Interface
Extends: I_Debug
Description:
Represents a component interface with metadata.
Type: Property
Accessors: Get
Description: Returns the parent entity.
Signature: PROPERTY Entity: I_Entity
Type: Property
Accessors: Get
Description: Returns the raw I_RawComponent
pointer.
Signature: PROPERTY Raw: I_RawComponent
Type: Function Block
Implements: I_Component
Description:
Allows registration of a function block implementing I_RawComponent
. The framework automatically adds this function block to the entity's scope.
Description: Initializes the Component
with the raw component reference.
Signature:
METHOD FB_Init : BOOL
VAR_INPUT
bInitRetains : BOOL;
bInCopyCode : BOOL;
iComponent : I_RawComponent; // Raw component to register
END_VAR
Type: Property
Accessors: Get
From: I_Component
Description: Returns the parent entity.
Signature: PROPERTY Entity: I_Entity
Type: Property
Accessors: Get
From: I_Component
Description: Returns the raw I_Component
pointer.
Signature: PROPERTY Raw: I_Component
Type: Function
Description:
Retrieves the next I_Entity
relative to the input, or the first entity if input is null.
Returns:
-
Ok
– Success. ReplacesiEntity
with the next or first entity. -
Err.InvRef
– Invalid reference. -
Err.Itf0
– Null input; no entity found. -
Err.End
– End of collection reached.
Signature:
FUNCTION GetNextEntity : Result
VAR_INPUT
iEntity : REFERENCE TO I_Entity;
END_VAR
Type: Function
Description:
Retrieves the previous I_Entity
relative to the input, or the last entity if input is null.
Returns:
-
Ok
– Success. ReplacesiEntity
with the previous or last entity. -
Err.InvRef
– Invalid reference. -
Err.Itf0
– Null input; no entity found. -
Err.End
– Start of collection reached.
Signature:
FUNCTION GetPrevEntity : Result
VAR_INPUT
iEntity : REFERENCE TO I_Entity;
END_VAR
Type: Function
Description:
Finds the owning entity of a given component. Costly.
Returns:
-
Ok
– Owning entity successfully found. -
Err.Itf0
– Null input. -
Err.InvRef
– Invalid output reference. -
Err.NotFound
– No owning entity found;iOut
is null.
Signature:
FUNCTION GetOwnerFromRaw : Result
VAR_INPUT
iIn : I_RawComponent;
iOut : REFERENCE TO I_Entity;
END_VAR
Type: Interface
Extends: I_Debug
Description:
Represents a registered entity within the Entity-Component system.
Type: Method
Description:
Retrieves the next component or the first if the input is null.
Returns:
-
Ok
– Success. UpdatesiOut
. -
Err.InvRef
– Invalid reference. -
Err.ItfEq
– Component does not belong to entity. -
Err.NotFound
– No components found. -
Err.End
– End of component list.
Signature:
METHOD GetNextComp : Result
VAR_INPUT
iOut : REFERENCE TO I_Component;
END_VAR
Type: Method
Description:
Retrieves the previous component or the last if the input is null.
Returns:
-
Ok
– Success. UpdatesiOut
. -
Err.InvRef
– Invalid reference. -
Err.ItfEq
– Component does not belong to entity. -
Err.NotFound
– No components found. -
Err.End
– Start of component list.
Signature:
METHOD GetPrevComp : Result
VAR_INPUT
iOut : REFERENCE TO I_Component;
END_VAR
Type: Property
Accessors: Get
Description:
Returns the number of components managed by the entity.
Signature: PROPERTY Size : UDINT
Type: Function Block
Implements: I_Entity
Description:
Marks the start of an entity scope. Nested scopes are supported. Components are registered in the innermost scope.
Type: Method
From: I_Entity
Description:
Retrieves the next component or the first if the input is null.
Returns:
-
Ok
– Success. UpdatesiOut
. -
Err.InvRef
– Invalid reference. -
Err.ItfEq
– Component does not belong to entity. -
Err.NotFound
– No components found. -
Err.End
– End of component list.
Signature:
METHOD GetNextComp : Result
VAR_INPUT
iOut : REFERENCE TO I_Component;
END_VAR
Type: Method
From: I_Entity
Description:
Retrieves the previous component or the last if the input is null.
Returns:
-
Ok
– Success. UpdatesiOut
. -
Err.InvRef
– Invalid reference. -
Err.ItfEq
– Component does not belong to entity. -
Err.NotFound
– No components found. -
Err.End
– Start of component list.
Signature:
METHOD GetPrevComp : Result
VAR_INPUT
iOut : REFERENCE TO I_Component;
END_VAR
Type: Property
Accessors: Get
From: I_Entity
Description:
Returns the number of components managed by the entity.
Signature: PROPERTY Size : UDINT
Type: Function Block
Implements: I_Debug
Description:
Marks the end of an entity scope. No new components may be registered beyond this point.
Type: Function Block
Implements: I_Debug
Description:
Reopens an entity scope to allow further modifications.
Type: Method
Description: Initializes the function block with the entity to extend.
Signature:
METHOD FB_Init : BOOL
VAR_INPUT
bInitRetains : BOOL;
bInCopyCode : BOOL;
iEntity : I_Entity;
END_VAR