Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
essentials.Systems.Structures.Network.NetworkedStructure Class Reference

Base class for a structure that may be networked to other structures More...

Inheritance diagram for essentials.Systems.Structures.Network.NetworkedStructure:
essentials.Systems.Structures.Structure essentials.Systems.Structures.Network.INetworkedStructure pluginbase.Objects.Syncable.Entity.EntityBase essentials.Systems.Structures.IStructure pluginbase.Objects.Syncable.Entity.Controllers.IComponentizedEntity essentials.Systems.Structures.IStructure pluginbase.Objects.Syncable.SyncableObject pluginbase.Objects.Syncable.Entity.IMutableEntity pluginbase.Objects.Syncable.Entity.Controllers.IRpcEntity pluginbase.Objects.Syncable.Entity.IEntity pluginbase.Objects.Syncable.Entity.Controllers.ITaskedEntity pluginbase.Objects.Syncable.Entity.Controllers.IHookedEntity pluginbase.Objects.Syncable.Entity.IEntity pluginbase.Objects.Syncable.SyncableBase< T > pluginbase.Objects.Syncable.Entity.IEntity pluginbase.Objects.Syncable.INetSyncable pluginbase.Objects.Syncable.Entity.IEntity pluginbase.Objects.Syncable.Entity.Controllers.IEntityController pluginbase.Objects.Syncable.Entity.Controllers.IEntityController pluginbase.Objects.Syncable.Entity.Controllers.IEntityController pluginbase.Objects.Syncable.INetSyncable pluginbase.Objects.Syncable.INetWatcher pluginbase.Objects.Syncable.INetWatcher essentials.Systems.Structures.Network.Resources.ConstructedStructure essentials.Systems.Structures.Network.Resources.PoweredStructure essentials.Systems.Structures.Network.Resources.ContainerStructure< T >

Protected Member Functions

 NetworkedStructure (Vector3i position)
 
 NetworkedStructure ()
 
bool IsConnectedTo (INetworkedStructure other, BlockTypeGroup blockTypes)
 Tests if this structure is connected a specific other structure More...
 
IEnumerable< IStructureConnectionGetConnectedTo (BlockTypeGroup blockTypes)
 Enumerates over all structures connected to this structure (even indirectly) More...
 
virtual void OnConnectionEstablished (IStructureConnection connection)
 Raises when a connection is established to another networked structure More...
 
virtual void OnConnectionInvalidated (IStructureConnection connection)
 Raises the connection to another network structure is invalidated More...
 
- Protected Member Functions inherited from essentials.Systems.Structures.Structure
 Structure (Vector3i position)
 
 Structure ()
 
abstract IReadonlyPrefab CreatePrefab ()
 
override void OnServerDestroy ()
 Raises the server destroy event. More...
 
sealed override bool ShouldSyncWith (IPositionableEntity user)
 Gets whether or not the entity shuold sync with another entity More...
 
- Protected Member Functions inherited from pluginbase.Objects.Syncable.Entity.EntityBase
void SetTransient (bool isTransient=true)
 Sets whether or not the entity will be persisted Transient entities will not be persisted More...
 
virtual void OnServerSpawn ()
 Raises the server spawn event. Will only be called once, even across reloads 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 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
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< T >
void Touch ()
 Touch the instance, notifying something has changed More...
 
virtual void OnChanged ()
 Raises the changed event. More...
 

Protected Attributes

int MaxScanRange = 128
 Max range to scan for a connected structure More...
 

Properties

int NetworkConnections [get]
 
- Properties inherited from essentials.Systems.Structures.Structure
Vector3i Position [get]
 The world-position of the structure More...
 
abstract string Name [get]
 
PrefabInstance PrefabInstance [get]
 The prefab instance of the structure More...
 
- Properties inherited from pluginbase.Objects.Syncable.Entity.EntityBase
bool Spawned [get]
 Gets a value indicating whether this entity has been spawned More...
 
uint ObjectId [get]
 Gets or sets the object identifier. 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.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...
 
- 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 essentials.Systems.Structures.IStructure
string Name [get]
 Name of the structure More...
 
Vector3i Position [get]
 The world-position of the structure More...
 
PrefabInstance PrefabInstance [get]
 The prefab instance of the structure More...
 
- Properties inherited from essentials.Systems.Structures.Network.INetworkedStructure
int NetworkConnections [get]
 Gets the total number of outgoing network connections More...
 

Additional Inherited Members

- Public Member Functions inherited from essentials.Systems.Structures.Structure
virtual void Unbuild ()
 Destroy and erase the prefab from the world More...
 
virtual void Build ()
 Construct the prefab instantly More...
 
- Public Member Functions inherited from pluginbase.Objects.Syncable.Entity.EntityBase
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.SyncableObject
 SyncableObject ()
 Initializes a new instance of the pluginbase.Objects.Syncable.SyncableObject class. More...
 
- Public Member Functions inherited from essentials.Systems.Structures.IStructure
void Destroy ()
 Destroy the structure More...
 
- Events inherited from pluginbase.Objects.Syncable.SyncableBase< T >
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

Base class for a structure that may be networked to other structures

Constructor & Destructor Documentation

essentials.Systems.Structures.Network.NetworkedStructure.NetworkedStructure ( Vector3i  position)
protected
45  :base(position)
46  {
47  this.InjectDependencies();
48  }
essentials.Systems.Structures.Network.NetworkedStructure.NetworkedStructure ( )
protected
51  {
52  this.InjectDependencies();
53  }

Member Function Documentation

IEnumerable<IStructureConnection> essentials.Systems.Structures.Network.NetworkedStructure.GetConnectedTo ( BlockTypeGroup  blockTypes)
protected

Enumerates over all structures connected to this structure (even indirectly)

Returns
The connected.

Attribute: i

;

71  {
72  if (!this.IsServer)
73  throw new Exception("Can only scan structures on server");
74 
75  var now = DateTime.UtcNow;
76  if (now - _lastUpdated > UPDATE_INTERVAL)
77  {
78  ScanConnectors(blockTypes);
79  _lastUpdated = now;
80  }
81 
82  ConnectionGroup conns;
83  if (_connections.TryGetValue(blockTypes, out conns))
84  {
85  for (int i=conns.Connections.Count-1; i>=0; --i)
86  {
87  var connection = conns.Connections[i];
88  if (connection.IsValid)
89  {
90  yield return connection;
91  }
92  else
93  {
94  OnConnectionInvalidated(connection);
95  conns.Connections.RemoveAt(i);
96  }
97  }
98  }
99  }
bool IsServer
Is the current object instantiated on the server
Definition: EntityBase.cs:130
virtual void OnConnectionInvalidated(IStructureConnection connection)
Raises the connection to another network structure is invalidated
Definition: NetworkedStructure.cs:200
bool essentials.Systems.Structures.Network.NetworkedStructure.IsConnectedTo ( INetworkedStructure  other,
BlockTypeGroup  blockTypes 
)
protected

Tests if this structure is connected a specific other structure

Returns
true, if connected was ared, false otherwise.
Parameters
otherOther.
blockTypesBlocks that can be connected with
62  {
63  return this.GetConnectedTo(blockTypes).Any(x => x.Target == other);
64  }
IEnumerable< IStructureConnection > GetConnectedTo(BlockTypeGroup blockTypes)
Enumerates over all structures connected to this structure (even indirectly)
Definition: NetworkedStructure.cs:70
virtual void essentials.Systems.Structures.Network.NetworkedStructure.OnConnectionEstablished ( IStructureConnection  connection)
protectedvirtual

Raises when a connection is established to another networked structure

Parameters
connectionConnection.
192  {
193  _log.LogInfo("Found connection from {0} to {1}", this.ToString(), connection.Target.ToString());
194  }
override string ToString()
Gets a human-readable string representing an entity
Definition: EntityBase.cs:344
void LogInfo(string msg, params object[] args)
virtual void essentials.Systems.Structures.Network.NetworkedStructure.OnConnectionInvalidated ( IStructureConnection  connection)
protectedvirtual

Raises the connection to another network structure is invalidated

Parameters
connectionConnection.
201  {
202  _log.LogInfo("Invalidated connection from {0} to {1}", this.ToString(), connection.Target.ToString());
203  }
override string ToString()
Gets a human-readable string representing an entity
Definition: EntityBase.cs:344
void LogInfo(string msg, params object[] args)

Member Data Documentation

int essentials.Systems.Structures.Network.NetworkedStructure.MaxScanRange = 128
protected

Max range to scan for a connected structure

Property Documentation

int essentials.Systems.Structures.Network.NetworkedStructure.NetworkConnections
get

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