Class EntityLogic
Base class for simple (not controlled by controller) entity
Implements
Inherited Members
Namespace: LiteEntitySystem
Assembly: LiteEntitySystem.dll
Syntax
public abstract class EntityLogic : InternalEntity, IComparable<InternalEntity>
Constructors
EntityLogic(EntityParams)
Declaration
protected EntityLogic(EntityParams entityParams)
Parameters
Type | Name | Description |
---|---|---|
EntityParams | entityParams |
Fields
Childs
Child entities (can be used for transforms or as components)
Declaration
public readonly SyncChilds Childs
Field Value
Type | Description |
---|---|
SyncChilds |
Properties
IsPredicted
Is entity spawned using AddPredictedEntity
Declaration
public bool IsPredicted { get; }
Property Value
Type | Description |
---|---|
bool |
Parent
Parent entity
Declaration
public EntityLogic Parent { get; }
Property Value
Type | Description |
---|---|
EntityLogic |
ParentId
Parent entity shared reference
Declaration
public EntitySharedReference ParentId { get; }
Property Value
Type | Description |
---|---|
EntitySharedReference |
SharedReference
Shared reference of this entity
Declaration
public EntitySharedReference SharedReference { get; }
Property Value
Type | Description |
---|---|
EntitySharedReference |
Methods
AddPredictedEntity<T>(ref SyncVar<EntitySharedReference>, Action<T>)
Create predicted entity (like projectile) that will be replaced by server entity if prediction is successful Should be called also in rollback mode if you use EntityLogic.Childs
Declaration
public void AddPredictedEntity<T>(ref SyncVar<EntitySharedReference> targetReference, Action<T> initMethod = null) where T : EntityLogic
Parameters
Type | Name | Description |
---|---|---|
SyncVar<EntitySharedReference> | targetReference | SyncVar of class that will be set to predicted entity and synchronized once confirmation will be received |
Action<T> | initMethod | Method that will be called after entity constructed |
Type Parameters
Name | Description |
---|---|
T | Entity type |
AddPredictedEntity<T>(Action<T>)
Create predicted entity (like projectile) that will be replaced by server entity if prediction is successful Should be called also in rollback mode
Declaration
public T AddPredictedEntity<T>(Action<T> initMethod = null) where T : EntityLogic
Parameters
Type | Name | Description |
---|---|---|
Action<T> | initMethod | Method that will be called after entity constructed |
Returns
Type | Description |
---|---|
T | Created predicted local entity |
Type Parameters
Name | Description |
---|---|
T | Entity type |
DisableLagCompensationForOwner()
Disable lag compensation for player that owns this entity
Declaration
public void DisableLagCompensationForOwner()
EnableLagCompensationForOwner()
Enable lag compensation for player that owns this entity
Declaration
public void EnableLagCompensationForOwner()
GetFrameSeed()
Get synchronized seed for random generators based on current tick. Can be used for rollback or inside RPCs
Declaration
public int GetFrameSeed()
Returns
Type | Description |
---|---|
int | current tick depending on entity manager state (IsExecutingRPC and InRollBackState) |
GetParent<T>()
Get parent entity
Declaration
public T GetParent<T>() where T : EntityLogic
Returns
Type | Description |
---|---|
T | parent entity |
Type Parameters
Name | Description |
---|---|
T | Type of entity |
IsSyncGroupEnabled(SyncGroup)
Client only. Is synchronization of this entity to local player enabled
Declaration
public bool IsSyncGroupEnabled(SyncGroup group)
Parameters
Type | Name | Description |
---|---|---|
SyncGroup | group |
Returns
Type | Description |
---|---|
bool | true - when we have data on client or when called on server |
OnBeforeParentDestroy()
Called before parent destroy
Declaration
protected virtual void OnBeforeParentDestroy()
OnChildAdded(EntityLogic)
Called when child added
Declaration
protected virtual void OnChildAdded(EntityLogic child)
Parameters
Type | Name | Description |
---|---|---|
EntityLogic | child |
OnChildRemoved(EntityLogic)
Called when child removed
Declaration
protected virtual void OnChildRemoved(EntityLogic child)
Parameters
Type | Name | Description |
---|---|---|
EntityLogic | child |
OnLagCompensationEnd()
Called when lag compensation ended for this entity
Declaration
protected virtual void OnLagCompensationEnd()
OnLagCompensationStart()
Called when lag compensation was started for this entity
Declaration
protected virtual void OnLagCompensationStart()
OnParentChanged(EntityLogic)
Called when parent changed
Declaration
protected virtual void OnParentChanged(EntityLogic oldParent)
Parameters
Type | Name | Description |
---|---|---|
EntityLogic | oldParent |
OnSyncGroupsChanged(SyncGroup)
Called when SyncGroups enabled or disabled on client
Declaration
protected virtual void OnSyncGroupsChanged(SyncGroup enabledGroups)
Parameters
Type | Name | Description |
---|---|---|
SyncGroup | enabledGroups | groups that are currently enabled |
RegisterRPC(ref RPCRegistrator)
Method for registering RPCs and OnChange notifications
Declaration
protected override void RegisterRPC(ref RPCRegistrator r)
Parameters
Type | Name | Description |
---|---|---|
RPCRegistrator | r |
Overrides
SetParent(EntityLogic)
Set parent entity
Declaration
public void SetParent(EntityLogic newParent)
Parameters
Type | Name | Description |
---|---|---|
EntityLogic | newParent | parent entity |