Show / Hide Table of Contents

Class Entity

A server entity.

Inheritance
System.Object
BaseEntity
Entity
Implements
IEventCompatible
Inherited Members
BaseEntity.DirtyBit
BaseEntity.NetUpdateTime
BaseEntity.EntId
BaseEntity.EntName
BaseEntity.EntType
BaseEntity.IsEntitySpawned
BaseEntity.NetUpdateInterval
BaseEntity.OnAwake()
BaseEntity.OnStart()
BaseEntity.OnUpdate()
BaseEntity.OnFixedUpdate()
BaseEntity.OnLateUpdate()
BaseEntity.OnEntitySpawned()
BaseEntity.OnEntityDestroyed()
BaseEntity.OnSetPos(Vector3, Vector3)
BaseEntity.OnSetRot(Quaternion, Quaternion)
BaseEntity.OnSetParent(BaseEntity)
Namespace: DuneNet.Server.Entities
Assembly: DuneNet.Server.dll
Syntax
public abstract class Entity : BaseEntity, IEventCompatible

Properties

AuthorityConnection

The connection that has authority over the entity.

Declaration
public DuneConnection AuthorityConnection { get; }
Property Value
Type Description
DuneConnection

NetVars

A dictionary containing all the current Networked Variables and their values.

Declaration
public Dictionary<string, object> NetVars { get; }
Property Value
Type Description
System.Collections.Generic.Dictionary<System.String, System.Object>
Remarks

Used for display and debug purposes. For normal operation, use SetNetworkedVar and GetNetworkedVar.

NetworkedPositionAndRotation

Whether the movement of the entity should be synchronized.

Declaration
public bool NetworkedPositionAndRotation { get; set; }
Property Value
Type Description
System.Boolean

Methods

Awake()

Declaration
protected override sealed void Awake()
Overrides
BaseEntity.Awake()

FixedUpdate()

Declaration
protected override sealed void FixedUpdate()
Overrides
BaseEntity.FixedUpdate()

GetNetworkedVar<T>(String)

Returns the specified Networked Variable's value.

Declaration
public T GetNetworkedVar<T>(string varName)
Parameters
Type Name Description
System.String varName

The name of the Networked Variable to obtain.

Returns
Type Description
T

An instance of type T representing the value of the Networked Variable. If the Networked Variable does not exist, the default value of T is returned instead.

Type Parameters
Name Description
T

The type of the Networked Variable to obtain. It must flagged as Serializable.

Remarks

Networked Variables are unidirectional: they are set by the server and synchronized to all clients that can observe the entity.

GetUMessage<T>(String)

Returns the specified User Message's value.

Declaration
public T GetUMessage<T>(string varName)
Parameters
Type Name Description
System.String varName

The name of the User Message to obtain.

Returns
Type Description
T

An instance of type T representing the value of the User Message. If the User Message does not exist, the default value of T is returned instead.

Type Parameters
Name Description
T

The type of the User Message to obtain. It must flagged as Serializable.

Remarks

User Messages are unidirectional: they are set by a client and synchronized to to the server. Only clients with authority over the entity may set its User Messages.

LateUpdate()

Declaration
protected override sealed void LateUpdate()
Overrides
BaseEntity.LateUpdate()

OnEntityDestroyedInternal()

Declaration
protected override sealed void OnEntityDestroyedInternal()
Overrides
BaseEntity.OnEntityDestroyedInternal()

OnNetUpdate()

Overridable method called once every network update.

Declaration
protected virtual void OnNetUpdate()
Remarks

How often this method gets called depends on the network tickrate of the entity (by default, 33 times per second). This method is called before any synchronization takes place. The entity should update its Networked Variables here since this is the fastest they will be synchronized.

OnSetUMessage(String)

Overridable method called when the authoritative client updates any of the User Messages of the entity.

Declaration
protected virtual void OnSetUMessage(string varName)
Parameters
Type Name Description
System.String varName

The name of the User Message that was received from the server.

Remarks

For entities with a large amount of User Messages, it is advisable to switch over varName.

RegisterEventInstance()

Declaration
public void RegisterEventInstance()

SendEntityToConnection(DuneConnection)

Sends the entity to the provided connection without respawning it on the server or the unaffected clients.

Declaration
public void SendEntityToConnection(DuneConnection conn)
Parameters
Type Name Description
DuneConnection conn

The connection to send the entity to.

Remarks

This is useful for sending entities to newly connecing clients.

SetNetworkedVar(String, Object)

Sets the specified Networked Variable's value.

Declaration
public void SetNetworkedVar(string varName, object value)
Parameters
Type Name Description
System.String varName

The name of the Networked Variable to set.

System.Object value

The value to set the Networked Variable to.

Remarks

Networked Variables are unidirectional: they are set by the server and synchronized to all clients that can observe the entity.

SetParent(BaseEntity)

Sets the parent of the entity and sends it to all ready clients.

Declaration
public override void SetParent(BaseEntity newParent)
Parameters
Type Name Description
BaseEntity newParent

The entity the parent will be se to.

Overrides
BaseEntity.SetParent(BaseEntity)

SetPos(Vector3)

Sets the position of the entity and sends it to all ready clients.

Declaration
public override void SetPos(Vector3 position)
Parameters
Type Name Description
Vector3 position

The position to set the entity to.

SetRot(Quaternion)

Sets the rotation of the entity and sends it to all ready clients.

Declaration
public override void SetRot(Quaternion rotation)
Parameters
Type Name Description
Quaternion rotation

The rotation to set the entity to.

Start()

Declaration
protected override sealed void Start()
Overrides
BaseEntity.Start()

Update()

Declaration
protected override sealed void Update()
Overrides
BaseEntity.Update()

Implements

IEventCompatible
Back to top Copyright © 2018 Dune Interactive.