Empeld
Empeld plugin documentation.
essentials.Systems.Structures.Structure Class Referenceabstract

Base-class for an entity that represents a prefab structure (That is, composed of blocks) More...

Inheritance diagram for essentials.Systems.Structures.Structure:
pluginbase.Objects.Syncable.Entity.EntityBase essentials.Systems.Structures.IStructure pluginbase.Objects.Syncable.Entity.Controllers.IComponentizedEntity 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.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.Entity.Controllers.IEntityController pluginbase.Objects.Syncable.Entity.Controllers.IEntityController pluginbase.Objects.Syncable.INetWatcher essentials.Systems.Structures.Network.NetworkedStructure essentials.Systems.Structures.Network.Resources.ConstructedStructure essentials.Systems.Structures.Network.Resources.PoweredStructure essentials.Systems.Structures.Network.Resources.ContainerStructure< T >

Public Member Functions

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.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...
 
- Public Member Functions inherited from essentials.Systems.Structures.IStructure
void Destroy ()
 Destroy the structure More...
 

Public Attributes

Vector3i Position => _position
 The world-position of the structure More...
 

Protected Member Functions

 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 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...
 

Protected Attributes

virtual double ViewDistance => 150
 

Properties

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

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

Base-class for an entity that represents a prefab structure (That is, composed of blocks)

Constructor & Destructor Documentation

◆ Structure() [1/2]

essentials.Systems.Structures.Structure.Structure ( Vector3i  position)
protected
35  :this()
36  {
37  this._position.Value = position;
38  }

◆ Structure() [2/2]

essentials.Systems.Structures.Structure.Structure ( )
protected
42  {
43  this.InjectDependencies();
44  }

Member Function Documentation

◆ Build()

virtual void essentials.Systems.Structures.Structure.Build ( )
virtual

Construct the prefab instantly

Implements essentials.Systems.Structures.IStructure.

94  {
95  if (!this.IsServer)
96  throw new InvalidOperationException("Only server can build");
97  this.PrefabInstance.CreateConstructor().Construct();
98  }
bool IsServer
Is the current object instantiated on the server
Definition: EntityBase.cs:130
An object that represents an in-world instance of a prefab
Definition: PrefabInstance.cs:14

◆ CreatePrefab()

abstract IReadonlyPrefab essentials.Systems.Structures.Structure.CreatePrefab ( )
protectedpure virtual

◆ OnServerDestroy()

override void essentials.Systems.Structures.Structure.OnServerDestroy ( )
protectedvirtual

Raises the server destroy event.

Reimplemented from pluginbase.Objects.Syncable.Entity.EntityBase.

84  {
85  base.OnServerDestroy();
86  this.Unbuild();
87  }
virtual void Unbuild()
Destroy and erase the prefab from the world
Definition: Structure.cs:75

◆ ShouldSyncWith()

sealed override bool essentials.Systems.Structures.Structure.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.

Reimplemented from pluginbase.Objects.Syncable.Entity.EntityBase.

101  {
102  return user != null && (this.Position - user.Position).LengthFast < this.ViewDistance;
103  }
Vector3i Position
The world-position of the structure
Definition: Structure.cs:32
virtual double ViewDistance
Definition: Structure.cs:26
Vector3d Position
Gets the position.
Definition: IPositionableEntity.cs:17

◆ Unbuild()

virtual void essentials.Systems.Structures.Structure.Unbuild ( )
virtual

Destroy and erase the prefab from the world

Attribute: block.WorldPos

.Block = _world.BlockLookup.EmptyBlock;

76  {
77  foreach(var block in this.PrefabInstance.DiscoverPlacedBlocks())
78  {
79  _world [block.WorldPos].Block = _world.BlockLookup.EmptyBlock;
80  }
81  }
An object that represents an in-world instance of a prefab
Definition: PrefabInstance.cs:14

Member Data Documentation

◆ Position

Vector3i essentials.Systems.Structures.Structure.Position => _position

The world-position of the structure

The position.

◆ ViewDistance

virtual double essentials.Systems.Structures.Structure.ViewDistance => 150
protected

Property Documentation

◆ Name

abstract string essentials.Systems.Structures.Structure.Name
get

◆ PrefabInstance

PrefabInstance essentials.Systems.Structures.Structure.PrefabInstance
get

The prefab instance of the structure

The prefab instance.


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