mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-03-31 14:49:08 +03:00
Fixed inventory NRE
This commit is contained in:
parent
3a4bb29f7e
commit
0beef36548
@ -96,6 +96,7 @@ namespace Facepunch.Steamworks
|
|||||||
Id = id;
|
Id = id;
|
||||||
|
|
||||||
SetupCommonProperties();
|
SetupCommonProperties();
|
||||||
|
UpdatePrice();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -219,6 +220,20 @@ namespace Facepunch.Steamworks
|
|||||||
|
|
||||||
IngredientFor = list.ToArray();
|
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>
|
/// <summary>
|
||||||
|
@ -440,22 +440,16 @@ namespace Facepunch.Steamworks
|
|||||||
if (IsServer)
|
if (IsServer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
inventory.RequestPrices((result, b) =>
|
inventory.RequestPrices((result, b) =>
|
||||||
{
|
{
|
||||||
Currency = result.Currency;
|
Currency = result.Currency;
|
||||||
|
|
||||||
|
if ( Definitions == null )
|
||||||
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < Definitions.Length; i++)
|
for (int i = 0; i < Definitions.Length; i++)
|
||||||
{
|
{
|
||||||
if (inventory.GetItemPrice(Definitions[i].Id, out ulong price))
|
Definitions[i].UpdatePrice();
|
||||||
{
|
|
||||||
Definitions[i].LocalPrice = price / 100.0;
|
|
||||||
Definitions[i].LocalPriceFormatted = Utility.FormatPrice( Currency, price );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Definitions[i].LocalPrice = 0;
|
|
||||||
Definitions[i].LocalPriceFormatted = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user