Class ContainerItem
Class that represents all container items in the game.
Implements
Inherited Members
Namespace: Fibula.Items
Assembly: Fibula.Items.dll
Syntax
public class ContainerItem : Item, IContainerItem, IItem, IThing, IEquatable<IThing>, IContainedThing, IThingContainer, ILocatable
Constructors
| Improve this Doc View SourceContainerItem(IItemTypeEntity)
Initializes a new instance of the ContainerItem class.
Declaration
public ContainerItem(IItemTypeEntity type)
Parameters
Type | Name | Description |
---|---|---|
IItemTypeEntity | type | The type of this item. |
Properties
| Improve this Doc View SourceCapacity
Gets the capacity of this container.
Declaration
public virtual byte Capacity { get; }
Property Value
Type | Description |
---|---|
System.Byte |
Content
Gets the collection of items contained in this container.
Declaration
public IList<IItem> Content { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IList<IItem> |
Item[Int32]
Attempts to retrieve an item from the contents of this container based on a given index.
Declaration
public IItem this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index to retrieve. |
Property Value
Type | Description |
---|---|
IItem | The item retrieved, if any, or null. |
Methods
| Improve this Doc View SourceAddContent(IThingFactory, IThing, Byte)
Attempts to add a IThing to this container.
Declaration
public virtual (bool result, IThing remainder) AddContent(IThingFactory thingFactory, IThing thing, byte index = 255)
Parameters
Type | Name | Description |
---|---|---|
IThingFactory | thingFactory | A reference to the factory of things to use. |
IThing | thing | The IThing to add to the container. |
System.Byte | index | Optional. The index at which to add the IThing. Defaults to byte.MaxValue, which instructs to add the IThing at any free index. |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, IThing> | A tuple with a value indicating whether the attempt was at least partially successful, and false otherwise. If the result was only partially successful, a remainder of the thing may be returned. |
CountAmountAt(Byte, UInt16)
Counts the amount of the specified content item at a given index within this container.
Declaration
public sbyte CountAmountAt(byte index, ushort typeIdExpected = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | index | The index at which to count. |
System.UInt16 | typeIdExpected | Optional. The type id of the content item expected to be found. |
Returns
Type | Description |
---|---|
System.SByte | The count of the item at the index. If |
FindThingAtIndex(Byte)
Attempts to find an IThing whitin this container.
Declaration
public IThing FindThingAtIndex(byte index)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | index | The index at which to look for the IThing. |
Returns
Type | Description |
---|---|
IThing | The IThing found at the index, if any was found. |
InvokeContentAdded(IItem)
Invokes the ContentAdded event on this container.
Declaration
protected void InvokeContentAdded(IItem itemAdded)
Parameters
Type | Name | Description |
---|---|---|
IItem | itemAdded | The item added. |
InvokeContentRemoved(Byte)
Invokes the ContentRemoved event on this container.
Declaration
protected void InvokeContentRemoved(byte index)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | index | The index within the container from where the item was removed. |
InvokeContentUpdated(Byte, IItem)
Invokes the ContentUpdated event on this container.
Declaration
protected void InvokeContentUpdated(byte index, IItem updatedItem)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | index | The index within the container from where the item was updated. |
IItem | updatedItem | The item that was updated. |
IsChildOf(IItem)
Checks that this item's parents are not this same item.
Declaration
public bool IsChildOf(IItem item)
Parameters
Type | Name | Description |
---|---|---|
IItem | item | The parent item to check. |
Returns
Type | Description |
---|---|
System.Boolean | True if the given item is a parent of this item, at any level of the parent hierarchy, false otherwise. |
RemoveContent(IThingFactory, ref IThing, Byte, Byte)
Attempts to remove a thing from this container.
Declaration
public virtual (bool result, IThing remainder) RemoveContent(IThingFactory thingFactory, ref IThing thing, byte index = 255, byte amount = 1)
Parameters
Type | Name | Description |
---|---|---|
IThingFactory | thingFactory | A reference to the factory of things to use. |
IThing | thing | The IThing to remove from the container. |
System.Byte | index | Optional. The index from which to remove the IThing. Defaults to byte.MaxValue, which instructs to remove the IThing if found at any index. |
System.Byte | amount | Optional. The amount of the |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, IThing> | A tuple with a value indicating whether the attempt was at least partially successful, and false otherwise. If the result was only partially successful, a remainder of the thing may be returned. |
ReplaceContent(IThingFactory, IThing, IThing, Byte, Byte)
Attempts to replace a IThing from this container with another.
Declaration
public (bool result, IThing remainderToChange) ReplaceContent(IThingFactory thingFactory, IThing fromThing, IThing toThing, byte index = 255, byte amount = 1)
Parameters
Type | Name | Description |
---|---|---|
IThingFactory | thingFactory | A reference to the factory of things to use. |
IThing | fromThing | The IThing to remove from the container. |
IThing | toThing | The IThing to add to the container. |
System.Byte | index | Optional. The index from which to replace the IThing. Defaults to byte.MaxValue, which instructs to replace the IThing if found at any index. |
System.Byte | amount | Optional. The amount of the |
Returns
Type | Description |
---|---|
System.ValueTuple<System.Boolean, IThing> | A tuple with a value indicating whether the attempt was at least partially successful, and false otherwise. If the result was only partially successful, a remainder of the thing may be returned. |
Events
| Improve this Doc View SourceContentAdded
A delegate to invoke when new content is added to this container.
Declaration
public event OnContentAdded ContentAdded
Event Type
Type | Description |
---|---|
OnContentAdded |
ContentRemoved
A delegate to invoke when content is removed from this container.
Declaration
public event OnContentRemoved ContentRemoved
Event Type
Type | Description |
---|---|
OnContentRemoved |
ContentUpdated
A delegate to invoke when content is updated in this container.
Declaration
public event OnContentUpdated ContentUpdated
Event Type
Type | Description |
---|---|
OnContentUpdated |