Show / Hide Table of Contents

Class Item

Base class for all items inside Eco.

Inheritance
System.Object
ItemLinkable
ItemRepresentation
Item
ActionbarItem
BlockItem
ClaimPaperItemBase
ClothingItem
ColorItem
DurabilityItem
FertilizerItem
PlayerItem
SeedPackItem
SkillBook
SkillScroll
PluginModule
GasItem
SmogItem
Skill
TalentGroup
Implements
IItem
ILinkableParameterized<LinkConfig>
ILinkable
IHasIcon
IController
IViewController
IHasUniversalID
Inherited Members
ItemRepresentation.RepresentsItemType(Item)
ItemRepresentation.RepresentativeHash()
ItemLinkable.ShowName(Single)
ItemLinkable.ShowName(Int32)
ItemLinkable.UILinkAndNumber(Single)
ItemLinkable.UILinkAndNumber(Int32)
ItemLinkable.UILinkAndNumber(Int32, String)
ItemLinkable.UILinkAndNumberAndTier(Int32, Int32)
ItemLinkable.UILinkAndNumberAndTierPrepend(Int32, Int32, String)
ItemLinkable.UILinkAndNumberNoText(Int32)
ItemLinkable.UILinkContent()
ItemLinkable.UILinkContent(Boolean)
ItemLinkable.NameAndNum(Int32)
ItemLinkable.UILinkAndStyledNumber(Int32)
ItemLinkable.UILinkContent(LocString)
ItemLinkable.UILinkNoNumber(Int32)
ItemLinkable.UILinkContent(LinkConfig)
ItemLinkable.ItemIconUILink(LocString)
ItemLinkable.DisplayNamePlural
ItemLinkable.MarkedUpName
ItemLinkable.ControllerID
Namespace: Eco.Gameplay.Items
Assembly: Eco.Gameplay.dll
Syntax
[ItemGroup("Items")]
public abstract class Item : ItemRepresentation, IItem, ILinkableParameterized<LinkConfig>, ILinkable, IHasIcon, IController, IViewController, IHasUniversalID
Remarks

Items are objects that can be stored in stacks inside inventories. Skill is an exception to that rule, violates Liskov substitution principle and should be fixed in the future.

Constructors

Item()

Declaration
public Item()

Fields

ItemsInitialized

Declaration
public static ThreadSafeAction ItemsInitialized
Field Value
Type Description
ThreadSafeAction

Properties

AllItemsExceptHidden

Declaration
public static Item[] AllItemsExceptHidden { get; }
Property Value
Type Description
Item[]

AllItemsIncludingHidden

Declaration
public static Item[] AllItemsIncludingHidden { get; }
Property Value
Type Description
Item[]

CanAirInteraction

Declaration
public bool CanAirInteraction { get; }
Property Value
Type Description
System.Boolean

CanBeCurrency

Declaration
public bool CanBeCurrency { get; }
Property Value
Type Description
System.Boolean

CanBeHeld

Declaration
public virtual bool CanBeHeld { get; }
Property Value
Type Description
System.Boolean

Category

Declaration
public string Category { get; }
Property Value
Type Description
System.String

Compostable

Declaration
public bool Compostable { get; }
Property Value
Type Description
System.Boolean

CustomHighlight

Declaration
public virtual bool CustomHighlight { get; }
Property Value
Type Description
System.Boolean

DisplayName

Returns display name for given item. This name same as class Display Name and should be specified as [LocDisplayName] attribute.

Declaration
public override LocString DisplayName { get; }
Property Value
Type Description
LocString
Overrides
ItemLinkable.DisplayName

Fuel

Declaration
public float Fuel { get; }
Property Value
Type Description
System.Single

GetDescription

Declaration
public LocString GetDescription { get; }
Property Value
Type Description
LocString

Group

Declaration
public string Group { get; }
Property Value
Type Description
System.String

HandOrigin

Declaration
public virtual ItemHandOrigin HandOrigin { get; }
Property Value
Type Description
ItemHandOrigin

HasCrop

Declaration
public bool HasCrop { get; }
Property Value
Type Description
System.Boolean

HasWeight

Flag determining if this item instance has associated weight.

Declaration
public bool HasWeight { get; }
Property Value
Type Description
System.Boolean

HasYield

Declaration
public bool HasYield { get; }
Property Value
Type Description
System.Boolean

Hidden

Declaration
public bool Hidden { get; }
Property Value
Type Description
System.Boolean

IconComment

Declaration
public virtual string IconComment { get; }
Property Value
Type Description
System.String

IconName

Declaration
public virtual string IconName { get; }
Property Value
Type Description
System.String

IgnoreAuth

Declaration
public bool IgnoreAuth { get; }
Property Value
Type Description
System.Boolean

IsCarried

Declaration
public bool IsCarried { get; }
Property Value
Type Description
System.Boolean

IsFuel

Declaration
public bool IsFuel { get; }
Property Value
Type Description
System.Boolean

IsStackable

False if CanStack(Item) will always return false for this item.

Declaration
public virtual bool IsStackable { get; }
Property Value
Type Description
System.Boolean
Remarks

All items are stored in stacks, but for items that are not stackable stack size will always be 1 and CanStack(Item) should always return false. By default unique items are not stackable, so the ones that implement custom stacking logic should override both CanStack(Item) and this property.

IsTool

Declaration
public bool IsTool { get; }
Property Value
Type Description
System.Boolean

IsUnique

Declaration
public bool IsUnique { get; }
Property Value
Type Description
System.Boolean

IsWasteProduct

Is this item a waste return from crafting?

Declaration
public bool IsWasteProduct { get; }
Property Value
Type Description
System.Boolean

MakesRoads

Declaration
public bool MakesRoads { get; }
Property Value
Type Description
System.Boolean

MaxStackSize

Declaration
public int MaxStackSize { get; }
Property Value
Type Description
System.Int32

Name

Declaration
public override string Name { get; set; }
Property Value
Type Description
System.String
Overrides
ItemLinkable.Name

RandomItem

Declaration
public static Item RandomItem { get; }
Property Value
Type Description
Item

ResourcePile

Declaration
public bool ResourcePile { get; }
Property Value
Type Description
System.Boolean

StackingHash

If two items have the same stacking hash and IsStackable returns true for them, CanStack(Item) is guaranteed to also return true for them. This can be used to easily group stackable items into groups that can be stacked together.

Declaration
public virtual int StackingHash { get; }
Property Value
Type Description
System.Int32

Type

Declaration
public Type Type { get; }
Property Value
Type Description
System.Type

TypeID

Declaration
public virtual int TypeID { get; }
Property Value
Type Description
System.Int32

Weight

Represents the WeightWithoutModifiers if this item with player defined modifiers attached, in grams.

Declaration
public int Weight { get; }
Property Value
Type Description
System.Int32

WeightWithoutModifiers

Represents the original weight of this item, in grams.

Declaration
public int WeightWithoutModifiers { get; }
Property Value
Type Description
System.Int32

Yield

Declaration
public SkillModifiedValue Yield { get; }
Property Value
Type Description
SkillModifiedValue

Methods

CanStack(Item)

Checks if two items can be stored in one stack.

Declaration
public virtual bool CanStack(Item other)
Parameters
Type Name Description
Item other
Returns
Type Description
System.Boolean
Remarks

When overriding this method remember to check if you need to override IsStackable.

ClearMaxStackSizeCache()

Clear the max stack size cache, typically called when item modifiers change

Declaration
public static void ClearMaxStackSizeCache()

Clone()

Declaration
public virtual Item Clone()
Returns
Type Description
Item

Create(Type)

Declaration
public static Item Create(Type itemType)
Parameters
Type Name Description
System.Type itemType
Returns
Type Description
Item

Create(Type, Int32)

Declaration
public static Item[] Create(Type itemType, int count = 1)
Parameters
Type Name Description
System.Type itemType
System.Int32 count
Returns
Type Description
Item[]

Create<T>()

Declaration
public static T Create<T>()
    where T : Item
Returns
Type Description
T
Type Parameters
Name Description
T

Create<T>(Int32)

Declaration
public static Item[] Create<T>(int count = 1)
    where T : Item
Parameters
Type Name Description
System.Int32 count
Returns
Type Description
Item[]
Type Parameters
Name Description
T

CreatingItem(Type)

Declaration
public static Item CreatingItem(Type type)
Parameters
Type Name Description
System.Type type
Returns
Type Description
Item

Destroy(Int32)

Declaration
public virtual void Destroy(int quantity = 1)
Parameters
Type Name Description
System.Int32 quantity

The quantity of the stack that's related to this item.

Get(IRepresentsItem)

Declaration
public static Item Get(IRepresentsItem itemProxy)
Parameters
Type Name Description
IRepresentsItem itemProxy
Returns
Type Description
Item

Get(Int32)

Declaration
public static Item Get(int itemTypeID)
Parameters
Type Name Description
System.Int32 itemTypeID
Returns
Type Description
Item

Get(String)

Declaration
public static Item Get(string typename)
Parameters
Type Name Description
System.String typename
Returns
Type Description
Item

Get(Type)

Declaration
public static Item Get(Type type)
Parameters
Type Name Description
System.Type type
Returns
Type Description
Item

Get<T>()

Declaration
public static T Get<T>()
    where T : Item
Returns
Type Description
T
Type Parameters
Name Description
T

GetCreatedObj(Type)

Declaration
public static Type GetCreatedObj(Type itemType)
Parameters
Type Name Description
System.Type itemType
Returns
Type Description
System.Type

GetID(Item)

Declaration
public static int GetID(Item item)
Parameters
Type Name Description
Item item
Returns
Type Description
System.Int32

GetID(Type)

Declaration
public static int GetID(Type itemType)
Parameters
Type Name Description
System.Type itemType
Returns
Type Description
System.Int32

GetID<T>()

Declaration
public static int GetID<T>()
Returns
Type Description
System.Int32
Type Parameters
Name Description
T

GetItemByString(User, String)

Declaration
public static Item GetItemByString(User user, string item)
Parameters
Type Name Description
User user
System.String item
Returns
Type Description
Item

GetMaxStackSize(Type)

Returns MaxStackSize with server stack size multiplier

Declaration
public static int GetMaxStackSize(Type itemType)
Parameters
Type Name Description
System.Type itemType
Returns
Type Description
System.Int32

GetMaxStackSizeRaw(Type)

Returns MaxStackSize without server stack size multiplier. As its cached - we remember raw values and only after caching we apply modifiers

Declaration
public static int GetMaxStackSizeRaw(Type itemType)
Parameters
Type Name Description
System.Type itemType
Returns
Type Description
System.Int32

GetNonUniqueOrClone(Int32)

If the item is unique, we create a new item and return it of that type. Otherwise, for non unique items where theyre all identical, we just reference the static item and return that.

Declaration
public static Item GetNonUniqueOrClone(int itemType)
Parameters
Type Name Description
System.Int32 itemType
Returns
Type Description
Item

GetNonUniqueOrClone(Type)

Declaration
public static Item GetNonUniqueOrClone(Type type)
Parameters
Type Name Description
System.Type type
Returns
Type Description
Item

GetSkillbookForSkillType(Type)

Declaration
public static SkillBook GetSkillbookForSkillType(Type type)
Parameters
Type Name Description
System.Type type
Returns
Type Description
SkillBook

GetType(Int32)

Declaration
public static Type GetType(int itemTypeID)
Parameters
Type Name Description
System.Int32 itemTypeID
Returns
Type Description
System.Type

GetType(String)

Declaration
public static Type GetType(string typename)
Parameters
Type Name Description
System.String typename
Returns
Type Description
System.Type

HasID(Type)

Declaration
public static bool HasID(Type type)
Parameters
Type Name Description
System.Type type
Returns
Type Description
System.Boolean

Initialize()

Declaration
public static void Initialize()

Merge(Item, Int32, Int32, Boolean)

Returns an item instance that should be used to represent this item in a stack created by merging this item's stack with another one.

Declaration
public virtual Item Merge(Item mergingInto, int thisCount, int otherCount, bool splittingStack)
Parameters
Type Name Description
Item mergingInto

Item stored in a stack into which the stack that contains this item is being merged.

System.Int32 thisCount

Count of this item that is stored in its stack.

System.Int32 otherCount

Count of the other item in its own stack.

System.Boolean splittingStack

Is stack in which this item is contained being split into two separate stacks?

Returns
Type Description
Item
Remarks

By default items are non unique and same instance is always used to represent them. Item types that have unique properties should override this method.

NameAndNum(Type, Int32)

Declaration
public static LocString NameAndNum(Type type, int count = 1)
Parameters
Type Name Description
System.Type type
System.Int32 count
Returns
Type Description
LocString

NameAndNum(Type, Single)

Declaration
public static LocString NameAndNum(Type type, float count)
Parameters
Type Name Description
System.Type type
System.Single count
Returns
Type Description
LocString

OnDeselected(Player)

Declaration
public virtual void OnDeselected(Player player)
Parameters
Type Name Description
Player player

OnLeftClicked(Player, ItemStack)

Declaration
public virtual void OnLeftClicked(Player player, ItemStack itemStack)
Parameters
Type Name Description
Player player
ItemStack itemStack

OnLinkClicked(TooltipOrigin, TooltipClickContext, User)

Declaration
public override void OnLinkClicked(TooltipOrigin origin, TooltipClickContext clickContext, User user)
Parameters
Type Name Description
TooltipOrigin origin
TooltipClickContext clickContext
User user
Overrides
ItemLinkable.OnLinkClicked(TooltipOrigin, TooltipClickContext, User)

OnSelected(Player)

Declaration
public virtual void OnSelected(Player player)
Parameters
Type Name Description
Player player

OnUsed(Player, ItemStack)

Declaration
public virtual string OnUsed(Player player, ItemStack itemStack)
Parameters
Type Name Description
Player player
ItemStack itemStack
Returns
Type Description
System.String

RepresentsItem(Item)

Checks if this instance has the same type and in case of unique items whether its unique properties, like durability level or associated settlement, match using rules defined for that specific item type.

Declaration
public override bool RepresentsItem(Item other)
Parameters
Type Name Description
Item other
Returns
Type Description
System.Boolean
Overrides
ItemRepresentation.RepresentsItem(Item)
Remarks

Use this method if you need custom comparison rules for unique items, like similar durability levels or same associated settlement. If only item type is relevant, use RepresentsItemType(Type) instead.

RepresentsItemType(Type)

Checks if this item instance represents item of the given type.

Declaration
public sealed override bool RepresentsItemType(Type itemType)
Parameters
Type Name Description
System.Type itemType
Returns
Type Description
System.Boolean
Overrides
ItemRepresentation.RepresentsItemType(Type)
Remarks

This method of checking for item match ignores any unique properties an item instance might have and only checks the type. If matching some conditions other than type for a unique item, like durability level or associated settlement, is necessary use RepresentsItem(Item) instead.

ShowName(Type, Int32)

Declaration
public static string ShowName(Type type, int count = 1)
Parameters
Type Name Description
System.Type type
System.Int32 count
Returns
Type Description
System.String

ShowName(Type, Single)

Declaration
public static string ShowName(Type type, float count = 1F)
Parameters
Type Name Description
System.Type type
System.Single count
Returns
Type Description
System.String

ShowName<T>(Int32)

Declaration
public static string ShowName<T>(int count = 1)
    where T : Item
Parameters
Type Name Description
System.Int32 count
Returns
Type Description
System.String
Type Parameters
Name Description
T

ToString()

Declaration
public override string ToString()
Returns
Type Description
System.String
Overrides
ItemLinkable.ToString()

TypeIsUnique(Type)

Declaration
public static bool TypeIsUnique(Type itemType)
Parameters
Type Name Description
System.Type itemType
Returns
Type Description
System.Boolean

UnsubscribeUnique()

This get called whenever a unique item is destroyed. This method will make sure that if the item is unique and has some subscriptions it will unsubscribe from them all.

Declaration
public virtual void UnsubscribeUnique()

Implements

IItem
ILinkableParameterized<T>
ILinkable
IHasIcon
IController
IViewController
IHasUniversalID

Extension Methods

ItemStackExtensions.NameAndNum(ItemRepresentation, Int32)
ItemUtils.CanItemExistInInventories(Item)
TagUtils.Tags(Item)
TagUtils.TagNames(Object, Boolean)
TagUtils.TagDisplayNames(Object, Boolean)
ClientSetViewExtensions.SetClassOfProperty(Object, Player, String, String, Int32)
MarketplaceExtensions.IsPaidItem(Item)
TypeTooltipExtensions.UILinkGeneric(Object)
ILinkableTooltipLibrary.ItemLinkClicked(Item, TooltipOrigin)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾