Empeld
Empeld plugin documentation.
essentials.action.ItemFramework.ItemBase Class Reference
Inheritance diagram for essentials.action.ItemFramework.ItemBase:
pluginbase.Objects.Syncable.SyncableObject essentials.action.ItemFramework.IItem pluginbase.Objects.Syncable.SyncableBase< SyncableObject > pluginbase.Objects.Syncable.INetSyncable pluginbase.Objects.Syncable.INetWatcher essentials.action.ItemFramework.BlockItem essentials.action.ItemFramework.Interactive.Bases.UseableItemBase essentials.action.ItemFramework.ItemBundle essentials.action.ItemFramework.BlockStackItem essentials.action.ItemFramework.Interactive.Bases.DeterioratingItemBase essentials.action.ItemFramework.Interactive.Bases.Simple.MagicWand essentials.action.ItemFramework.Interactive.UseableBlockItem essentials.action.ItemFramework.Interactive.Bases.WorldModifyingItemBase essentials.action.ItemFramework.Interactive.Bases.Simple.Shovel

Public Member Functions

 ItemBase ()
 
override string ToString ()
 
- 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

virtual Bitmap LoadIcon ()
 Loads the bitmap representing the image of the item More...
 
virtual IReadonlyModel LoadModel ()
 Loads the mesh representing the model in-world 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

readonly IModelFactory ModelFactory
 
readonly IPluginLogger Logger
 
virtual float ModelSize => 0.5f
 Size to render the model More...
 
virtual Matrix4 ModelTransform => null
 How to transform the generated model (Only impacts generated meshes, not loaded models) More...
 
virtual ItemRenderMode ItemRenderMode => ItemRenderMode.Meshalizer
 How the item is rendered when dropped (ItemDropEntity) More...
 

Properties

abstract string Icon [get]
 Gets the path to the icon More...
 
abstract string Name [get]
 Gets the name of the item More...
 
virtual string IconLabel [get]
 
virtual string Description [get]
 
virtual string MeshResource [get]
 
virtual string ModelImage [get]
 
virtual int MeshalizerResolution [get]
 
virtual float MeshalizerDepth [get]
 
virtual string ModelCacheKey [get]
 
virtual bool ShowNameplate [get]
 
virtual bool Bounce [get]
 
virtual bool AutoDespawn [get]
 
virtual TimeSpan AutoDespawnDelay [get]
 
virtual bool HasGravity [get]
 
virtual double ViewDistance [get]
 
- Properties inherited from pluginbase.Objects.Syncable.SyncableObject
virtual ushort NetOwnerId [get]
 Gets the network owner of this object (user id) More...
 
- Properties inherited from essentials.action.ItemFramework.IItem
string Name [get]
 The human-readable name of the item More...
 
string IconLabel [get]
 Gets the wording that can appear over a icon More...
 
bool ShowNameplate [get]
 Whether or not to show the nameplate above the item More...
 
bool Bounce [get]
 Whether or not the item should bounce in the world More...
 
bool AutoDespawn [get]
 Whether or not the item should be subject to auto-despawn More...
 
TimeSpan AutoDespawnDelay [get]
 The amount of time the auto despawn will take, if set (Overrides global default) More...
 
bool HasGravity [get]
 Whether or not gravity affects the item More...
 
double ViewDistance [get]
 The distance from which the dropped item can be viewed 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...
 

Constructor & Destructor Documentation

◆ ItemBase()

essentials.action.ItemFramework.ItemBase.ItemBase ( )
29  {
30  this.InjectDependencies();
31  }

Member Function Documentation

◆ LoadIcon()

virtual Bitmap essentials.action.ItemFramework.ItemBase.LoadIcon ( )
protectedvirtual

Loads the bitmap representing the image of the item

Returns
The icon.

Implements essentials.action.ItemFramework.IItem.

Reimplemented in essentials.action.ItemFramework.ItemBundle, and essentials.action.ItemFramework.BlockItem.

110  {
111  if (!string.IsNullOrEmpty(this.Icon))
112  {
113  using (var stream = _resourceResolver.OpenRead(this.Icon))
114  {
115  return new Bitmap(stream);
116  }
117  }
118  return null;
119  }
abstract string Icon
Gets the path to the icon
Definition: ItemBase.cs:40
Stream OpenRead(string module, string resource)
Opens a file for reading

◆ LoadModel()

virtual IReadonlyModel essentials.action.ItemFramework.ItemBase.LoadModel ( )
protectedvirtual

Loads the mesh representing the model in-world

Returns
The model.

Implements essentials.action.ItemFramework.IItem.

Reimplemented in essentials.action.ItemFramework.ItemBundle, and essentials.action.ItemFramework.BlockStackItem.

122  {
123  Logger.LogDebug("Loading item model for '{0}'...", this.Name);
124 
125  if (!string.IsNullOrWhiteSpace(this.MeshResource))
126  {
127  return this.ModelFactory.LoadModel(this.MeshResource);
128  }
129 
130  if (!string.IsNullOrEmpty(this.ModelImage))
131  {
132  var mesh = this.BuildMeshFromModelImage();
133  if (this.ModelTransform.HasValue)
134  mesh.TransformCoordinates(this.ModelTransform.Value);
135  return this.ModelFactory.CreateMesh(mesh);
136  }
137  return null;
138  }
IReadonlyModel CreateMesh(Mesh mesh)
Creates a model given a mesh
readonly IPluginLogger Logger
Definition: ItemBase.cs:23
void LogDebug(string msg, params object[] args)
virtual string MeshResource
Definition: ItemBase.cs:59
virtual string ModelImage
Definition: ItemBase.cs:64
readonly IModelFactory ModelFactory
Definition: ItemBase.cs:20
abstract string Name
Gets the name of the item
Definition: ItemBase.cs:46
IReadonlyModel LoadModel(string resource)
Load a model to a readonly model instance
virtual Matrix4 ModelTransform
How to transform the generated model (Only impacts generated meshes, not loaded models) ...
Definition: ItemBase.cs:88

◆ ToString()

override string essentials.action.ItemFramework.ItemBase.ToString ( )
290  {
291  return string.Format("[Item: {0}]", Name ?? "Unknown");
292  }
abstract string Name
Gets the name of the item
Definition: ItemBase.cs:46

Member Data Documentation

◆ ItemRenderMode

virtual ItemRenderMode essentials.action.ItemFramework.ItemBase.ItemRenderMode => ItemRenderMode.Meshalizer
protected

How the item is rendered when dropped (ItemDropEntity)

The item render mode.

◆ Logger

readonly IPluginLogger essentials.action.ItemFramework.ItemBase.Logger
protected

Attribute: Dependency

◆ ModelFactory

readonly IModelFactory essentials.action.ItemFramework.ItemBase.ModelFactory
protected

Attribute: Dependency(Optional = true)

◆ ModelSize

virtual float essentials.action.ItemFramework.ItemBase.ModelSize => 0.5f
protected

Size to render the model

The size of the model.

◆ ModelTransform

virtual Matrix4 essentials.action.ItemFramework.ItemBase.ModelTransform => null
protected

How to transform the generated model (Only impacts generated meshes, not loaded models)

The model transform.

Property Documentation

◆ AutoDespawn

virtual bool essentials.action.ItemFramework.ItemBase.AutoDespawn
get

◆ AutoDespawnDelay

virtual TimeSpan essentials.action.ItemFramework.ItemBase.AutoDespawnDelay
get

◆ Bounce

virtual bool essentials.action.ItemFramework.ItemBase.Bounce
get

◆ Description

virtual string essentials.action.ItemFramework.ItemBase.Description
get

◆ HasGravity

virtual bool essentials.action.ItemFramework.ItemBase.HasGravity
get

◆ Icon

abstract string essentials.action.ItemFramework.ItemBase.Icon
getprotected

Gets the path to the icon

The icon.

◆ IconLabel

virtual string essentials.action.ItemFramework.ItemBase.IconLabel
get

◆ MeshalizerDepth

virtual float essentials.action.ItemFramework.ItemBase.MeshalizerDepth
getprotected

◆ MeshalizerResolution

virtual int essentials.action.ItemFramework.ItemBase.MeshalizerResolution
getprotected

◆ MeshResource

virtual string essentials.action.ItemFramework.ItemBase.MeshResource
getprotected

◆ ModelCacheKey

virtual string essentials.action.ItemFramework.ItemBase.ModelCacheKey
getprotected

◆ ModelImage

virtual string essentials.action.ItemFramework.ItemBase.ModelImage
getprotected

◆ Name

abstract string essentials.action.ItemFramework.ItemBase.Name
get

Gets the name of the item

The name.

◆ ShowNameplate

virtual bool essentials.action.ItemFramework.ItemBase.ShowNameplate
get

◆ ViewDistance

virtual double essentials.action.ItemFramework.ItemBase.ViewDistance
get

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