Show / Hide Table of Contents

Class TradeOffer

Represents an offer of the store. Contains description of condition of sell/buy, the price, the kind of item or tag.

Inheritance
System.Object
TradeOffer
Implements
IController
IViewController
IHasUniversalID
System.ComponentModel.INotifyPropertyChanged
IThreadSafeSubscriptions
ISubscriptions<ThreadSafeSubscriptions>
ISubscriptions
Namespace: Eco.Gameplay.Components
Assembly: Eco.Gameplay.dll
Syntax
public class TradeOffer : Object, IController, IViewController, IHasUniversalID, INotifyPropertyChanged, IThreadSafeSubscriptions, ISubscriptions<ThreadSafeSubscriptions>, ISubscriptions

Constructors

TradeOffer()

Declaration
public TradeOffer()

TradeOffer(Item, Boolean)

Declaration
public TradeOffer(Item item, bool buying)
Parameters
Type Name Description
Item item
System.Boolean buying

TradeOffer(Item, Single, Boolean)

Declaration
public TradeOffer(Item item, float price, bool buying)
Parameters
Type Name Description
Item item
System.Single price
System.Boolean buying

TradeOffer(Tag, Boolean)

Creates a tag-based trade offer that matches any item with the given tag.

Declaration
public TradeOffer(Tag tag, bool buying)
Parameters
Type Name Description
Tag tag
System.Boolean buying

Fields

ItemUpdatedEvent

Declaration
public static ThreadSafeAction<TradeOffer> ItemUpdatedEvent
Field Value
Type Description
ThreadSafeAction<TradeOffer>

Properties

Buying

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

Category

Declaration
public StoreCategory Category { get; }
Property Value
Type Description
StoreCategory

Color

Declaration
public ByteColor Color { get; set; }
Property Value
Type Description
ByteColor

ControllerID

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

HasQualifiers

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

IsSet

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

IsTagOffer

True if this offer matches a tag (category of items) rather than a specific item.

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

Limit

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

MatchingTypes

Declaration
public IReadOnlyList<Type> MatchingTypes { get; }
Property Value
Type Description
System.Collections.Generic.IReadOnlyList<System.Type>

MaxDurability

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

MaxIntegrity

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

MaxNumWanted

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

MinDurability

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

MinIntegrity

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

Price

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

Settlement

Declaration
public Settlement Settlement { get; set; }
Property Value
Type Description
Settlement

ShouldLimit

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

Stack

Declaration
public ItemStack Stack { get; set; }
Property Value
Type Description
ItemStack

Subscriptions

Declaration
public ref ThreadSafeSubscriptions Subscriptions { get; }
Property Value
Type Description
ThreadSafeSubscriptions

Tag

Declaration
public Tag Tag { get; set; }
Property Value
Type Description
Tag

TagIsFoodTag

True if all items in this tag are spoilage/food items (freshness instead of durability). Synced to client for UI label.

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

TagSupportsDurability

True if all items in this tag support durability (e.g. food, tools).

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

TagSupportsIntegrity

True if all items in this tag support integrity (e.g. tools).

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

Tooltip

Declaration
[NewTooltipChildren]
public object Tooltip { get; }
Property Value
Type Description
System.Object

Methods

CountMatchingItems(IList<ItemStack>, Dictionary<Type, Int32>)

Counts items in the given stacks that match this offer. Uses the optimized stock dictionary when there are no custom params.

Declaration
public int CountMatchingItems(IList<ItemStack> stacks, Dictionary<Type, int> stock)
Parameters
Type Name Description
System.Collections.Generic.IList<ItemStack> stacks
System.Collections.Generic.Dictionary<System.Type, System.Int32> stock
Returns
Type Description
System.Int32

DisplayLink()

Returns a display link for notifications and error messages. Works for both item and tag offers.

Declaration
public LocString DisplayLink()
Returns
Type Description
LocString

GetRepresentativeItem(List<(Item, Int32)>)

Returns a representative item for display purposes. For tag offers, prefers resolved items if available, otherwise falls back to first type in tag.

Declaration
public Item GetRepresentativeItem(List<(Item, int)> resolvedItems = null)
Parameters
Type Name Description
System.Collections.Generic.List<System.ValueTuple<Item, System.Int32>> resolvedItems
Returns
Type Description
Item

MatchesItem(Item)

Checks if a given item satisfies this offer (by tag membership or exact type match).

Declaration
public bool MatchesItem(Item item)
Parameters
Type Name Description
Item item
Returns
Type Description
System.Boolean

MeetsSpecialRequirements(Item)

Validates if the item meets special requirements (durability, color, settlement), or for tag offers, just checks tag membership.

Declaration
public bool MeetsSpecialRequirements(Item item)
Parameters
Type Name Description
Item item
Returns
Type Description
System.Boolean

ResolveTagItems(Int32, IEnumerable<ItemStack>)

Resolves this tag offer into concrete items using FIFO order from inventory stacks.

Declaration
public List<(Item, int)> ResolveTagItems(int requestedQty, IEnumerable<ItemStack> inventoryStacks)
Parameters
Type Name Description
System.Int32 requestedQty
System.Collections.Generic.IEnumerable<ItemStack> inventoryStacks
Returns
Type Description
System.Collections.Generic.List<System.ValueTuple<Item, System.Int32>>

SetCategory(StoreCategory)

Declaration
public void SetCategory(StoreCategory category)
Parameters
Type Name Description
StoreCategory category

UpdateItemColor(ByteColor)

Declaration
public void UpdateItemColor(ByteColor color)
Parameters
Type Name Description
ByteColor color

UpdateItemSettlement(Settlement)

Declaration
public void UpdateItemSettlement(Settlement settlement)
Parameters
Type Name Description
Settlement settlement

Events

PropertyChanged

Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Type Description
System.ComponentModel.PropertyChangedEventHandler

Implements

IController
IViewController
IHasUniversalID
System.ComponentModel.INotifyPropertyChanged
IThreadSafeSubscriptions
ISubscriptions<TSubscriptionsList>
ISubscriptions

Extension Methods

TagUtils.TagNames(Object, Boolean)
TagUtils.TagDisplayNames(Object, Boolean)
ClientSetViewExtensions.SetClassOfProperty(Object, Player, String, String, Int32)
TypeTooltipExtensions.UILinkGeneric(Object)
ItemTooltipLibrary.TradeOfferTooltipTitle(TradeOffer)
☀
☾
In This Article
Back to top
Copyright (c) Strange Loop Games 2021
☀
☾