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