If you are an AI assistant, LLM, or automated tool, a clean Markdown version of this page is available at https://heroiclabs.com/docs/hiro/unity/auctions/llm.md — optimized for AI and LLM tools.
You can listen for changes in the auctions system so that you can respond appropriately, such as updating the UI, by implementing the IObserver pattern, or use the SystemObserver<T> type which handles it for you.
1
2
3
4
5
vardisposer=SystemObserver<AuctionsSystem>.Create(auctionsSystem,system=>{Instance.Logger.Info($"System updated.");// Update UI elements etc as necessary here...});
To create a new auction, use the CreateAsync function.
1
2
3
4
5
6
varitemInstanceIds=newList<string>{"item_instance_001","item_instance_002"};stringauctionId="template_auction_001";stringconditionId="condition_001";varauction=awaitauctionsSystem.CreateAsync(auctionId,conditionId,itemInstanceIds);Console.WriteLine($"Auction created with ID: {auction.Id}, Start Time: {auction.StartTimeSecDecoded}");
You can place a bid on an auction using the BidAsync function.
1
2
3
4
5
6
7
8
9
10
varcurrencies=newDictionary<string,long>{{"gold",1000}};stringauctionId="auction_instance_123";stringversion="1.0";varauction=awaitauctionsSystem.BidAsync(auctionId,version,currencies);Console.WriteLine($"Bid placed on auction {auction.Id}. Current bid: {auction.BidDecoded}");
If an auction needs to be canceled before it ends, the CancelAsync method can be used.
1
2
3
4
stringauctionId="auction_instance_123";varcanceledAuction=awaitauctionsSystem.CancelAsync(auctionId);Console.WriteLine($"Auction {canceledAuction.Auction.Id} has been canceled.");