Show / Hide Table of Contents

Class FoodItem

Food Items are items that spoil over time, See DurabilityItems.md

Inheritance
System.Object
ItemLinkable
ItemRepresentation
Item
DurabilityItem
FoodItem
SeedItem
Implements
IItem
ILinkableParameterized<LinkConfig>
ILinkable
IHasIcon
System.ComponentModel.INotifyPropertyChanged
IInteractor
IHasInteractions
IPlaceableItem
IController
IViewController
IHasUniversalID
Inherited Members
DurabilityItem.GetQualityGroup()
DurabilityItem.CanStack(Item)
DurabilityItem.RepresentsItem(Item)
DurabilityItem.RepresentativeHash()
DurabilityItem.Merge(Item, Int32, Int32, Boolean)
DurabilityItem.OriginalMaxDurability
DurabilityItem.Decays
DurabilityItem.DurabilityPercent
DurabilityItem.PercentBrokenFromOriginal
DurabilityItem.DisplayDurability
DurabilityItem.Broken
DurabilityItem.IsStackable
DurabilityItem.StackingHash
DurabilityItem.BrokenDescription
DurabilityItem.PropertyChanged
Item.ItemsInitialized
Item.RepresentsItemType(Type)
Item.OnLinkClicked(TooltipOrigin, TooltipClickContext, User)
Item.ClearMaxStackSizeCache()
Item.GetMaxStackSize(Type)
Item.Destroy(Int32)
Item.ToString()
Item.UnsubscribeUnique()
Item.OnLeftClicked(Player, ItemStack)
Item.OnSelected(Player)
Item.OnDeselected(Player)
Item.Get(IRepresentsItem)
Item.Get(Int32)
Item.Get<T>()
Item.Get(Type)
Item.Get(String)
Item.ShowName(Type, Single)
Item.ShowName(Type, Int32)
Item.ShowName<T>(Int32)
Item.NameAndNum(Type, Int32)
Item.GetSkillbookForSkillType(Type)
Item.CreatingItem(Type)
Item.GetCreatedObj(Type)
Item.TypeIsUnique(Type)
Item.GetNonUniqueOrClone(Int32)
Item.GetNonUniqueOrClone(Type)
Item.NameAndNum(Type, Single)
Item.Initialize()
Item.GetItemByString(User, String)
Item.GetID(Item)
Item.GetID(Type)
Item.HasID(Type)
Item.GetID<T>()
Item.GetType(Int32)
Item.GetType(String)
Item.Create<T>(Int32)
Item.Create(Type, Int32)
Item.Create<T>()
Item.Create(Type)
Item.IconName
Item.IconComment
Item.TypeID
Item.Type
Item.DisplayName
Item.Name
Item.IsUnique
Item.Fuel
Item.IsFuel
Item.WeightWithoutModifiers
Item.Weight
Item.HasWeight
Item.IsCarried
Item.IgnoreAuth
Item.Yield
Item.HasYield
Item.HasCrop
Item.CanBeCurrency
Item.MakesRoads
Item.Compostable
Item.ResourcePile
Item.CanAirInteraction
Item.Category
Item.Hidden
Item.Group
Item.MaxStackSize
Item.IsWasteProduct
Item.GetDescription
Item.HandOrigin
Item.IsTool
Item.CustomHighlight
Item.AllItemsIncludingHidden
Item.AllItemsExceptHidden
Item.RandomItem
ItemRepresentation.RepresentsItemType(Item)
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
[Compostable]
[ItemGroup("Food")]
public abstract class FoodItem : DurabilityItem, IItem, ILinkableParameterized<LinkConfig>, ILinkable, IHasIcon, INotifyPropertyChanged, IInteractor, IHasInteractions, IPlaceableItem, IController, IViewController, IHasUniversalID

Constructors

FoodItem()

Declaration
protected FoodItem()

Properties

BaseShelfLife

Declaration
protected abstract float BaseShelfLife { get; }
Property Value
Type Description
System.Single

Calories

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

CanBeHeld

Declaration
public override bool CanBeHeld { get; }
Property Value
Type Description
System.Boolean
Overrides
Item.CanBeHeld

DefaultMinRequiredDurabilityInTradeOffers

Declaration
public override float DefaultMinRequiredDurabilityInTradeOffers { get; }
Property Value
Type Description
System.Single
Overrides
DurabilityItem.DefaultMinRequiredDurabilityInTradeOffers

Nutrition

Declaration
public abstract Nutrients Nutrition { get; }
Property Value
Type Description
Nutrients

SpoilageTime

Declaration
public ImmutableCountdown SpoilageTime { get; set; }
Property Value
Type Description
ImmutableCountdown

Methods

Clone()

Declaration
public override Item Clone()
Returns
Type Description
Item
Overrides
DurabilityItem.Clone()

Consume(Player)

RPC that is called by client when its time to actually remove food item from inventory an eat it

Declaration
public virtual string Consume(Player player)
Parameters
Type Name Description
Player player
Returns
Type Description
System.String

GetDurability()

Declaration
public override float GetDurability()
Returns
Type Description
System.Single
Overrides
DurabilityItem.GetDurability()

GetSpoilageTimeBasedOnDurability(Single, Boolean)

Create a new immutable countdown based on the given durability value and the current storage modifier.

Declaration
public ImmutableCountdown GetSpoilageTimeBasedOnDurability(float durability, bool paused = false)
Parameters
Type Name Description
System.Single durability
System.Boolean paused
Returns
Type Description
ImmutableCountdown

OnUsed(Player, ItemStack)

On food item right click - we point toolbar override slot with this item stack of food. for client so it knows what item will be used Also we immediately call consume (so item will be eaten with calories and removed from inventory)

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

SetDurability(Single)

Declaration
public override void SetDurability(float d)
Parameters
Type Name Description
System.Single d
Overrides
DurabilityItem.SetDurability(Single)

SetSpoilageTimeBasedOnDurability(Single)

Declaration
public void SetSpoilageTimeBasedOnDurability(float durability)
Parameters
Type Name Description
System.Single durability

UpdateSpoilageTime(Single)

Sets the spoilage time based on durability or updates the durability with spoilage progress if the storage is still the same.

Declaration
public void UpdateSpoilageTime(float shelfLifeMultiplier = 1F)
Parameters
Type Name Description
System.Single shelfLifeMultiplier

Implements

IItem
ILinkableParameterized<T>
ILinkable
IHasIcon
System.ComponentModel.INotifyPropertyChanged
IInteractor
IHasInteractions
IPlaceableItem
IController
IViewController
IHasUniversalID

Extension Methods

ItemStackExtensions.NameAndNum(ItemRepresentation, Int32)
ItemUtils.CanItemExistInInventories(Item)
ItemUtils.CloneIfNeeded(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)
EconomyTooltipLibrary.BuyItTooltip(Item, User, TooltipOrigin)
EconomyTooltipLibrary.SellItTooltip(Item, User, TooltipOrigin)
ILinkableTooltipLibrary.ItemLinkClicked(Item, TooltipOrigin)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾