Table of Contents

Class EntityLogic

Namespace
LiteEntitySystem
Assembly
LiteEntitySystem.dll

Base class for simple (not controlled by controller) entity

public abstract class EntityLogic : InternalEntity, IComparable<InternalEntity>
Inheritance
object
EntityLogic
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

SyncChilds

Properties

Parent

Parent entity

public EntityLogic Parent { get; }

Property Value

EntityLogic

ParentId

Parent entity shared reference

public EntitySharedReference ParentId { get; }

Property Value

EntitySharedReference

SharedReference

Shared reference of this entity

public EntitySharedReference SharedReference { get; }

Property Value

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

public void AddPredictedEntity<T>(ref SyncVar<EntitySharedReference> targetReference, Action<T> initMethod = null) where T : PredictableEntityLogic

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 Don't call this method inside Server->Client RPC! This will break many things.

public T AddPredictedEntity<T>(Action<T> initMethod = null) where T : PredictableEntityLogic

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()

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 SyncGroup

groups that are currently enabled

RegisterRPC(ref RPCRegistrator)

Method for registering RPCs and OnChange notifications

protected override void RegisterRPC(ref RPCRegistrator r)

Parameters

r RPCRegistrator

SetParent(EntityLogic)

Set parent entity

public void SetParent(EntityLogic newParent)

Parameters

newParent EntityLogic

parent entity

TryGetOwnerTick(out ushort)

Gets owner tick on client if entity is owned, and on server it returns owner tick. Useful as seed for random generators based on current tick.

public bool TryGetOwnerTick(out ushort tick)

Parameters

tick ushort

Returns

bool

true if owner tick accessible, false if you trying get remote player tick