mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 06:05:46 +03:00
Fixed inventory NRE
This commit is contained in:
parent
3a4bb29f7e
commit
0beef36548
@ -96,6 +96,7 @@ internal Definition( Inventory i, int id )
|
||||
Id = id;
|
||||
|
||||
SetupCommonProperties();
|
||||
UpdatePrice();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -219,6 +220,20 @@ internal void InRecipe( Recipe r )
|
||||
|
||||
IngredientFor = list.ToArray();
|
||||
}
|
||||
|
||||
internal void UpdatePrice()
|
||||
{
|
||||
if ( inventory.inventory.GetItemPrice( Id, out ulong price) )
|
||||
{
|
||||
LocalPrice = price / 100.0;
|
||||
LocalPriceFormatted = Utility.FormatPrice( inventory.Currency, price );
|
||||
}
|
||||
else
|
||||
{
|
||||
LocalPrice = 0;
|
||||
LocalPriceFormatted = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -440,22 +440,16 @@ public void UpdatePrices()
|
||||
if (IsServer)
|
||||
return;
|
||||
|
||||
inventory.RequestPrices((result, b) =>
|
||||
inventory.RequestPrices((result, b) =>
|
||||
{
|
||||
Currency = result.Currency;
|
||||
|
||||
if ( Definitions == null )
|
||||
return;
|
||||
|
||||
for (int i = 0; i < Definitions.Length; i++)
|
||||
{
|
||||
if (inventory.GetItemPrice(Definitions[i].Id, out ulong price))
|
||||
{
|
||||
Definitions[i].LocalPrice = price / 100.0;
|
||||
Definitions[i].LocalPriceFormatted = Utility.FormatPrice( Currency, price );
|
||||
}
|
||||
else
|
||||
{
|
||||
Definitions[i].LocalPrice = 0;
|
||||
Definitions[i].LocalPriceFormatted = null;
|
||||
}
|
||||
Definitions[i].UpdatePrice();
|
||||
}
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user