#region Arthea License /*********************************************************************** * Arthea MUD by R. Jennings (2007) http://arthea.googlecode.com/ * * By using this code you comply with the Artistic and GPLv2 Licenses. * ***********************************************************************/ #endregion using System.Xml.Serialization; using Arthea.Affects; using Arthea.Connections.Players; using Arthea.Continents.Areas.Items.Enums; using Arthea.Creation.Attributes; using Arthea.Database.Interfaces; using Arthea.Environment; using Arthea.Interfaces; using Arthea.Scripts; namespace Arthea.Continents.Areas.Items { /// <summary> /// Implements a persistant item that is the basis for duplicate items /// </summary> public class ItemIndex : Scriptable, Indexed { #region [rgn] Fields (9) private AffectList affects = new AffectList(); [EditShow] private Area area; [EditShow] private uint id; private string name; private string roomDescr; private ScriptList scripts = new ScriptList(); private string shortDescr; private ItemType type; private WearLocation wearLocation; #endregion [rgn] #region [rgn] Constructors (2) /// <summary> /// Initializes a new instance of the <see cref="ItemIndex"/> class. /// </summary> /// <param name="area">The area.</param> /// <param name="Id">The id.</param> /// <param name="name">The name.</param> /// <param name="shortDesc">The short desc.</param> /// <param name="roomDesc">The room desc.</param> /// <param name="type">The type.</param> public ItemIndex(Area area, uint Id, string name, string shortDesc, string roomDesc, ItemType type) { this.area = area; id = Id; this.name = name; shortDescr = shortDesc; roomDescr = roomDesc; this.type = type; } /// <summary> /// Initializes a new instance of the <see cref="ItemIndex"/> class. /// </summary> public ItemIndex() { } #endregion [rgn] #region [rgn] Properties (9) /// <summary> /// Gets or sets the affects. /// </summary> /// <value>The affects.</value> public AffectList Affects { get { return affects; } set { affects = value; } } /// <summary> /// Gets or sets the area. /// </summary> /// <value>The area.</value> [XmlIgnore] public Area Area { get { return area; } set { area = value; } } /// <summary> /// Gets or sets the room descr. /// </summary> /// <value>The room descr.</value> public string RoomDescr { get { return roomDescr; } set { roomDescr = value; } } /// <summary> /// Gets or sets the scripts. /// </summary> /// <value>The scripts.</value> public ScriptList Scripts { get { return scripts; } set { scripts = value; } } /// <summary> /// Gets or sets the type. /// </summary> /// <value>The type.</value> public ItemType Type { get { return type; } set { type = value; } } /// <summary> /// Gets or sets the wear loc. /// </summary> /// <value>The wear loc.</value> public WearLocation WearLoc { get { return wearLocation; } set { wearLocation = value; } } #region Indexed Members /// <summary> /// Gets or sets the id. /// </summary> /// <value>The id.</value> public uint Id { get { return id; } set { id = value; } } #endregion #region Scriptable Members /// <summary> /// Gets or sets the name. /// </summary> /// <value>The name.</value> public string Name { get { return name; } set { name = value; } } /// <summary> /// Gets or sets the short descr. /// </summary> /// <value>The short descr.</value> public string ShortDescr { get { return shortDescr; } set { shortDescr = value; } } #endregion #endregion [rgn] #region [rgn] Methods (4) // [rgn] Public Methods (4) /// <summary> /// Attaches this instance to applicable lists. /// </summary> public void Attach() { if (area != null) area.Items.Add(this); Lists.ItemIndexes.Add(this); } /// <summary> /// Creates an instance for editing by a player. /// </summary> /// <param name="player">The player.</param> /// <param name="argument">The argument.</param> public static void Create(Player player, String argument) { uint id = player.Room.Area.GetNextItemId(); if (id == 0) { player.WriteLine("No more items available in this area."); return; } ItemIndex item = new ItemIndex(); item.Name = argument; item.ShortDescr = item.Name; item.RoomDescr = string.Format("{0} is here.", item.Name); item.Id = id; item.Area = player.Room.Area; item.Attach(); player.WriteLine("Item created."); player.Connection.Edit(item); } /// <summary> /// Releases this instance from applicable lists. /// </summary> public void Release() { if (area != null) area.Items.Remove(this); Lists.ItemIndexes.Remove(this); } /// <summary> /// Returns a <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>. /// </summary> /// <returns> /// A <see cref="T:System.String"></see> that represents the current <see cref="T:System.Object"></see>. /// </returns> public override string ToString() { return id.ToString(); } #endregion [rgn] #region Scriptable Members /// <summary> /// Creates a script of proper type. /// </summary> /// <returns></returns> public Script CreateScript(ScriptCode code, String trigger) { return new ItemScript(code, trigger); } #endregion } }