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
System.ComponentModel.INotifyPropertyChanged
Assembly: Eco.Gameplay.dll
Syntax
public class TradeOffer : Object, IController, IViewController, IHasUniversalID, INotifyPropertyChanged, IThreadSafeSubscriptions, ISubscriptions<ThreadSafeSubscriptions>, ISubscriptions
Constructors
TradeOffer()
Declaration
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
Properties
Buying
Declaration
public bool Buying { get; set; }
Property Value
| Type |
Description |
| System.Boolean |
|
Category
Declaration
public StoreCategory Category { get; }
Property Value
Color
Declaration
public ByteColor Color { get; set; }
Property Value
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
ShouldLimit
Declaration
public bool ShouldLimit { get; }
Property Value
| Type |
Description |
| System.Boolean |
|
Stack
Declaration
public ItemStack Stack { get; set; }
Property Value
Subscriptions
Declaration
public ref ThreadSafeSubscriptions Subscriptions { get; }
Property Value
Tag
Declaration
public Tag Tag { get; set; }
Property Value
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 |
|
True if all items in this tag support durability (e.g. food, tools).
Declaration
public bool TagSupportsDurability { get; }
Property Value
| Type |
Description |
| System.Boolean |
|
True if all items in this tag support integrity (e.g. tools).
Declaration
public bool TagSupportsIntegrity { get; }
Property Value
| Type |
Description |
| System.Boolean |
|
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
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
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
UpdateItemColor(ByteColor)
Declaration
public void UpdateItemColor(ByteColor color)
Parameters
UpdateItemSettlement(Settlement)
Declaration
public void UpdateItemSettlement(Settlement settlement)
Parameters
Events
PropertyChanged
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
| Type |
Description |
| System.ComponentModel.PropertyChangedEventHandler |
|
Implements
System.ComponentModel.INotifyPropertyChanged
Extension Methods