Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Item"/> class.
        /// </summary>
        /// <param name="type">The type of this item.</param>
        public Item(IItemTypeEntity type)
        {
            this.Type = type;

            // make a copy of the type we are based on...
            this.Attributes = new Dictionary <ItemAttribute, IConvertible>(this.Type.DefaultAttributes.Select(kvp => KeyValuePair.Create((ItemAttribute)kvp.Key, kvp.Value)));

            this.InitializeExpirationTime();
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Item"/> class.
        /// </summary>
        /// <param name="type">The type of this item.</param>
        public Item(IItemTypeEntity type)
        {
            this.Type = type;

            // make a copy of the type we are based on...
            this.Attributes = new Dictionary <ItemAttribute, IConvertible>(this.Type.DefaultAttributes.Select(kvp => KeyValuePair.Create((ItemAttribute)kvp.Key, kvp.Value)));

            this.expirationTimeLeft = !this.HasExpiration ? TimeSpan.Zero :
                                      this.Attributes.ContainsKey(ItemAttribute.ExpirationTimeLeft) ?
                                      TimeSpan.FromSeconds(Convert.ToUInt32(this.Attributes[ItemAttribute.ExpirationTimeLeft]))
                    :
                                      this.Attributes.ContainsKey(ItemAttribute.ExpirationStartTime) ?
                                      TimeSpan.FromSeconds(Convert.ToUInt32(this.Attributes[ItemAttribute.ExpirationStartTime]))
                        :
                                      TimeSpan.Zero;
        }
Esempio n. 3
0
 /// <summary>
 /// Creates item at the specified location.
 /// </summary>
 /// <param name="location">The location at which to create the item.</param>
 /// <param name="itemType">The type of item to create.</param>
 /// <param name="additionalAttributes">Optional. Additional item attributes to set on the new item.</param>
 public void CreateItemAtLocation(Location location, IItemTypeEntity itemType, params (ItemAttribute, IConvertible)[] additionalAttributes)
        /// <summary>
        /// Checks if the item type has the given item flag set.
        /// </summary>
        /// <param name="itemTypeEntity">The item type entity.</param>
        /// <param name="itemFlag">The item flag to check for.</param>
        /// <returns>True if the item type has the item flag set, and false otherwise.</returns>
        public static bool HasItemFlag(this IItemTypeEntity itemTypeEntity, ItemFlag itemFlag)
        {
            itemTypeEntity.ThrowIfNull(nameof(itemTypeEntity));

            return((itemTypeEntity.Flags & (ulong)itemFlag) == (ulong)itemFlag);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ContainerItem"/> class.
 /// </summary>
 /// <param name="type">The type of this item.</param>
 public ContainerItem(IItemTypeEntity type)
     : base(type)
 {
     this.Content = new List <IItem>();
 }