Empeld
Empeld plugin documentation.
pluginbase.Objects.Syncable.Entity.EntityBase Class Reference

A base class representing entities More...

Inheritance diagram for pluginbase.Objects.Syncable.Entity.EntityBase:
pluginbase.Objects.Syncable.SyncableObject pluginbase.Objects.Syncable.Entity.IMutableEntity pluginbase.Objects.Syncable.Entity.Controllers.IRpcEntity pluginbase.Objects.Syncable.SyncableBase< SyncableObject > pluginbase.Objects.Syncable.Entity.IEntity pluginbase.Objects.Syncable.INetSyncable pluginbase.Objects.Syncable.Entity.IEntity pluginbase.Objects.Syncable.Entity.Controllers.IEntityController pluginbase.Objects.Syncable.INetWatcher essentials.action.Entities.Actor.ActorBase essentials.action.ItemFramework.World.ItemDropEntity essentials.BlockEntities.BlockEntityBase< TBlock > essentials.Systems.Structures.Structure pluginbase.Objects.Syncable.Entity.Static.StaticEntityBase essentials.action.Entities.Actor.AttachableActorBase essentials.action.Entities.Actor.RailEntityBase essentials.Systems.Structures.Network.NetworkedStructure essentials.action.Entities.Actor.NewtonianBase essentials.action.Entities.Basic.NpcEntity essentials.Systems.Structures.Network.Resources.ConstructedStructure essentials.action.Entities.Actor.PathingEntityBase essentials.action.Entities.Actor.PlayableBase essentials.Systems.Structures.Network.Resources.PoweredStructure essentials.action.Entities.AI.AiEntityBase essentials.action.Entities.Basic.GuyEntity essentials.Systems.Structures.Network.Resources.ContainerStructure< T >

Public Member Functions

void Destroy ()
 Marks the entity for destruction More...
 
override string ToString ()
 Gets a human-readable string representing an entity More...
 
- Public Member Functions inherited from pluginbase.Objects.Syncable.INetSyncable
void ResetWatch ()
 Resets the watch. Overridable to reset all sub-items More...
 
void EncodeTo (BinaryWriter writer, EncodeContext context)
 Encodes to. More...
 
void DecodeFrom (BinaryReader reader, DecodeContext context)
 Decodes from. More...
 
void Persist (IPersistObject obj)
 Persist the network object to a persist object More...
 
void Load (IReadPersistObject obj)
 Load the network object from a persist object More...
 
- Public Member Functions inherited from pluginbase.Objects.Syncable.INetWatcher
void Touch ()
 Touch the class, signalling that a change ocurred More...
 
void TouchRecurse ()
 Touches a class and any sub-classes it may have More...
 

Protected Member Functions

void SetTransient (bool isTransient=true)
 Sets whether or not the entity will be persisted Transient entities will not be persisted More...
 
virtual bool ShouldSyncWith (IPositionableEntity user)
 Gets whether or not the entity shuold sync with another entity More...
 
virtual void OnServerSpawn ()
 Raises the server spawn event. Will only be called once, even across reloads More...
 
virtual void OnServerDestroy ()
 Raises the server destroy event. More...
 
void InvokeRemotely (string methodName, RpcTarget target, params object[] args)
 Invoke a remote method on a target More...
 
void InvokeRemotely< T > (string methodName, RpcTarget target, Action< RpcNetworkContext, T > returnCallback, params object[] args)
 Invoke a remote method on a target More...
 
void InvokeRemotely< T > (string methodName, RpcTarget target, Action< T > returnCallback, params object[] args)
 Invoke a remote method on a target More...
 
void InvokeRemotely (RpcTarget target, Expression< Action > thisExpression)
 Invokes a remote target with an expression More...
 
void InvokeDirect (string methodName, params object[] args)
 Invoke a remote method on the opposite-owner eg. if this is the server, than on the client owner, otherwise on the server More...
 
void InvokeDirect< T > (string methodName, Action< RpcNetworkContext, T > returnCallback, params object[] args)
 Invoke a remote method on the opposite-owner eg. if this is the server, than on the client owner, otherwise on the server More...
 
void InvokeDirect< T > (string methodName, Action< T > returnCallback, params object[] args)
 Invoke a remote method on the opposite-owner eg. if this is the server, than on the client owner, otherwise on the server More...
 
void InvokeDirect (Expression< Action > thisExpression)
 Invokes a method on the opposite-owner. Action must act upon this More...
 
void InvokeDirect< TRet > (Expression< Func< TRet >> thisExpression, Action< TRet > returnCallback)
 Invokes a method on the opposite-owner. Action must act upon this More...
 
- Protected Member Functions inherited from pluginbase.Objects.Syncable.SyncableObject
 SyncableObject ()
 Initializes a new instance of the pluginbase.Objects.Syncable.SyncableObject class. More...
 
sealed override void ResetWatch ()
 Reset variables watched status More...
 
sealed override void TouchRecurse ()
 Touch self, including all children of this syncable object More...
 
sealed override void EncodeTo (BinaryWriter writer, EncodeContext context)
 Encode changes to binary data More...
 
sealed override void DecodeFrom (BinaryReader reader, DecodeContext context)
 Decode changes from binary data More...
 
sealed override void Persist (IPersistObject obj)
 Build up a persistant object for this syncable, including all sync children and persist objects More...
 
sealed override void Load (IReadPersistObject obj)
 Load a given persistent object back into this instance More...
 
- Protected Member Functions inherited from pluginbase.Objects.Syncable.SyncableBase< SyncableObject >
void Touch ()
 Touch the instance, notifying something has changed More...
 
virtual void OnChanged ()
 Raises the changed event. More...
 
abstract void Persist (IPersistObject obj)
 Persist the instance to a persist object More...
 
abstract void Load (IReadPersistObject obj)
 Load the instance from a persist object More...
 

Properties

bool Spawned [get]
 Gets a value indicating whether this entity has been spawned More...
 
uint ObjectId [get]
 Gets or sets the object identifier. (aka entity id) More...
 
ushort OwnerId [get]
 The ident of the owner of the obejct More...
 
sealed override ushort NetOwnerId [get]
 Who owns me?! (Net ID) This is how we pass information down to SyncableObject More...
 
bool IsServer [get]
 Is the current object instantiated on the server More...
 
ushort ObjectTypeId [get]
 The type ID of the object, as defined by the entity attribute More...
 
- Properties inherited from pluginbase.Objects.Syncable.SyncableObject
virtual ushort NetOwnerId [get]
 Gets the network owner of this object (user id) More...
 
- Properties inherited from pluginbase.Objects.Syncable.Entity.IEntity
uint ObjectId [get]
 Gets the object identifier. More...
 
ushort OwnerId [get]
 Gets the owner identifier. (Net Ident) More...
 
ushort ObjectTypeId [get]
 Gets the object type identifier, as defined by the attribute More...
 
bool DestroyFlag [get]
 Gets a value indicating whether this pluginbase.Objects.Syncable.Entity.IEntity is destroyable. More...
 
bool Spawned [get]
 Gets a value indicating whether this entity has been spawned More...
 
bool Transient [get]
 Gets a value indicating whether this entity is transient (Won't be saved) More...
 
- Properties inherited from pluginbase.Objects.Syncable.INetSyncable
INetWatcher Watcher [get, set]
 Who is watching (who to inform of a change) More...
 
bool Modified [get]
 Gets a value indicating whether this pluginbase.Objects.Syncable.INetSyncable is modified. More...
 

Additional Inherited Members

- Events inherited from pluginbase.Objects.Syncable.SyncableBase< SyncableObject >
Action< T > Changed
 Event triggered when any change occurs on this object, either locally or over the network More...
 
Action< T > NetUpdate
 Event triggered when a change occurs resulting from a change over the network More...
 
Action< T > Touched
 Event occurs only when an object is first touched. Usually the first instance of a local-change More...
 

Detailed Description

A base class representing entities

Member Function Documentation

◆ Destroy()

void pluginbase.Objects.Syncable.Entity.EntityBase.Destroy ( )

Marks the entity for destruction

182  {
183  if (!this.IsServer)
184  throw new Exception("Destroy only allowed by server");
185  _destroyFlag = true;
186  }
bool IsServer
Is the current object instantiated on the server
Definition: EntityBase.cs:130

◆ InvokeDirect() [1/2]

void pluginbase.Objects.Syncable.Entity.EntityBase.InvokeDirect ( string  methodName,
params object []  args 
)
protected

Invoke a remote method on the opposite-owner eg. if this is the server, than on the client owner, otherwise on the server

Parameters
methodNameMethod name.
argsArguments.
291  {
292  this._rpc.Invoke(methodName, this.GetDirectTarget(), args);
293  }

◆ InvokeDirect() [2/2]

void pluginbase.Objects.Syncable.Entity.EntityBase.InvokeDirect ( Expression< Action >  thisExpression)
protected

Invokes a method on the opposite-owner. Action must act upon this

Parameters
thisExpressionThis expression.
326  {
327  var method = thisExpression.ReduceMethodCall();
328  if (!method.TargetType.IsAssignableFrom(this.GetType()))
329  {
330  throw new Exception("RPC Expression must act upon self");
331  }
332  InvokeDirect(method.Method.Name, method.ArgumentValues);
333  }
void InvokeDirect(string methodName, params object[] args)
Invoke a remote method on the opposite-owner eg. if this is the server, than on the client owner...
Definition: EntityBase.cs:290

◆ InvokeDirect< T >() [1/2]

void pluginbase.Objects.Syncable.Entity.EntityBase.InvokeDirect< T > ( string  methodName,
Action< RpcNetworkContext, T >  returnCallback,
params object []  args 
)
protected

Invoke a remote method on the opposite-owner eg. if this is the server, than on the client owner, otherwise on the server

Parameters
methodNameMethod name.
returnCallbackReturn callback.
argsArguments.
Template Parameters
TThe 1st type parameter.
304  {
305  this._rpc.Invoke(methodName, this.GetDirectTarget(), returnCallback, args);
306  }

◆ InvokeDirect< T >() [2/2]

void pluginbase.Objects.Syncable.Entity.EntityBase.InvokeDirect< T > ( string  methodName,
Action< T >  returnCallback,
params object []  args 
)
protected

Invoke a remote method on the opposite-owner eg. if this is the server, than on the client owner, otherwise on the server

Parameters
methodNameMethod name.
returnCallbackReturn callback.
argsArguments.
Template Parameters
TThe 1st type parameter.
317  {
318  this._rpc.Invoke(methodName, this.GetDirectTarget(), returnCallback, args);
319  }

◆ InvokeDirect< TRet >()

void pluginbase.Objects.Syncable.Entity.EntityBase.InvokeDirect< TRet > ( Expression< Func< TRet >>  thisExpression,
Action< TRet >  returnCallback 
)
protected

Invokes a method on the opposite-owner. Action must act upon this

Parameters
thisExpressionThis expression.
returnCallbackReturn callback.
Template Parameters
TRetThe 1st type parameter.
342  {
343  var method = thisExpression.ReduceMethodCall();
344  if (!method.TargetType.IsAssignableFrom(this.GetType()))
345  {
346  throw new Exception("RPC Expression must act upon self");
347  }
348  InvokeDirect(method.Method.Name, returnCallback, method.ArgumentValues);
349  }
void InvokeDirect(string methodName, params object[] args)
Invoke a remote method on the opposite-owner eg. if this is the server, than on the client owner...
Definition: EntityBase.cs:290

◆ InvokeRemotely() [1/2]

void pluginbase.Objects.Syncable.Entity.EntityBase.InvokeRemotely ( string  methodName,
RpcTarget  target,
params object []  args 
)
protected

Invoke a remote method on a target

Parameters
methodNameMethod name.
targetTarget.
argsArguments.
232  {
233  this._rpc.Invoke(methodName, target, args);
234  }

◆ InvokeRemotely() [2/2]

void pluginbase.Objects.Syncable.Entity.EntityBase.InvokeRemotely ( RpcTarget  target,
Expression< Action >  thisExpression 
)
protected

Invokes a remote target with an expression

Parameters
targetTarget.
thisExpressionThis expression.
268  {
269  var method = thisExpression.ReduceMethodCall();
270  if (!method.TargetType.IsAssignableFrom(this.GetType()))
271  {
272  throw new Exception("RPC Expression must act upon self");
273  }
274  this.InvokeRemotely(method.Method.Name, target, method.ArgumentValues);
275  }
void InvokeRemotely(string methodName, RpcTarget target, params object[] args)
Invoke a remote method on a target
Definition: EntityBase.cs:231

◆ InvokeRemotely< T >() [1/2]

void pluginbase.Objects.Syncable.Entity.EntityBase.InvokeRemotely< T > ( string  methodName,
RpcTarget  target,
Action< RpcNetworkContext, T >  returnCallback,
params object []  args 
)
protected

Invoke a remote method on a target

Parameters
methodNameMethod name.
targetTarget.
returnCallbackReturn callback.
argsArguments.
Template Parameters
TThe 1st type parameter.
245  {
246  this._rpc.Invoke(methodName, target, returnCallback, args);
247  }

◆ InvokeRemotely< T >() [2/2]

void pluginbase.Objects.Syncable.Entity.EntityBase.InvokeRemotely< T > ( string  methodName,
RpcTarget  target,
Action< T >  returnCallback,
params object []  args 
)
protected

Invoke a remote method on a target

Parameters
methodNameMethod name.
targetTarget.
returnCallbackReturn callback.
argsArguments.
Template Parameters
TThe 1st type parameter.
258  {
259  this._rpc.Invoke(methodName, target, returnCallback, args);
260  }

◆ OnServerDestroy()

virtual void pluginbase.Objects.Syncable.Entity.EntityBase.OnServerDestroy ( )
protectedvirtual

◆ OnServerSpawn()

virtual void pluginbase.Objects.Syncable.Entity.EntityBase.OnServerSpawn ( )
protectedvirtual

Raises the server spawn event. Will only be called once, even across reloads

Implements pluginbase.Objects.Syncable.Entity.IMutableEntity.

Reimplemented in essentials.BlockEntities.BlockEntityBase< TBlock >.

216 {}

◆ SetTransient()

void pluginbase.Objects.Syncable.Entity.EntityBase.SetTransient ( bool  isTransient = true)
protected

Sets whether or not the entity will be persisted Transient entities will not be persisted

Parameters
isTransientIf set to true is transient.
88  {
89  if (!this.IsServer)
90  throw new Exception("Only server may set transient");
91  _transient = isTransient;
92  }
bool IsServer
Is the current object instantiated on the server
Definition: EntityBase.cs:130

◆ ShouldSyncWith()

virtual bool pluginbase.Objects.Syncable.Entity.EntityBase.ShouldSyncWith ( IPositionableEntity  user)
protectedvirtual

Gets whether or not the entity shuold sync with another entity

Returns
true, if sync with was shoulded, false otherwise.
Parameters
userUser.

Implements pluginbase.Objects.Syncable.Entity.IMutableEntity.

Reimplemented in essentials.action.ItemFramework.World.ItemDropEntity, essentials.action.Entities.Actor.ActorBase, essentials.BlockEntities.BlockEntityBase< TBlock >, and essentials.Systems.Structures.Structure.

208  {
209  //We don't have any concept of a position, so of course, let's send
210  return true;
211  }

◆ ToString()

override string pluginbase.Objects.Syncable.Entity.EntityBase.ToString ( )

Gets a human-readable string representing an entity

Returns
A System.String that represents the current pluginbase.Objects.Syncable.Entity.EntityBase.
360  {
361  _typeName = _typeName ?? this.GetType().Name;
362  return string.Format("[Entity: OID={0}, Owner={1}, TypeId={2}({3})]", ObjectId, OwnerId, ObjectTypeId, _typeName);
363  }
ushort OwnerId
The ident of the owner of the obejct
Definition: EntityBase.cs:108
uint ObjectId
Gets or sets the object identifier. (aka entity id)
Definition: EntityBase.cs:100
ushort ObjectTypeId
The type ID of the object, as defined by the entity attribute
Definition: EntityBase.cs:144

Property Documentation

◆ IsServer

bool pluginbase.Objects.Syncable.Entity.EntityBase.IsServer
getprotected

Is the current object instantiated on the server

true if this instance is server; otherwise, false.

◆ NetOwnerId

sealed override ushort pluginbase.Objects.Syncable.Entity.EntityBase.NetOwnerId
getprotected

Who owns me?! (Net ID) This is how we pass information down to SyncableObject

The owner identifier.

◆ ObjectId

uint pluginbase.Objects.Syncable.Entity.EntityBase.ObjectId
get

Gets or sets the object identifier. (aka entity id)

The object identifier.

◆ ObjectTypeId

ushort pluginbase.Objects.Syncable.Entity.EntityBase.ObjectTypeId
get

The type ID of the object, as defined by the entity attribute

The object type identifier.

◆ OwnerId

ushort pluginbase.Objects.Syncable.Entity.EntityBase.OwnerId
get

The ident of the owner of the obejct

The owner identifier.

◆ Spawned

bool pluginbase.Objects.Syncable.Entity.EntityBase.Spawned
get

Gets a value indicating whether this entity has been spawned

true

false


The documentation for this class was generated from the following file: