Price loadout restores with runtime queries
This commit is contained in:
parent
0504ca6287
commit
931272495e
5 changed files with 170 additions and 30 deletions
|
|
@ -181,11 +181,15 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
|
||||
private (string text, Action action, bool enabled) LoadoutOption(AetheriaRuntimeLoadoutTemplateSnapshot template)
|
||||
{
|
||||
var blueprint = GameManager.CreateEntityConstructionBlueprint(template);
|
||||
if (blueprint == null)
|
||||
if (!AetheriaRuntimeDaemonTradeItemQueries.TryProjectLoadoutTemplatePrice(
|
||||
template,
|
||||
ActionGameManager.RuntimeCatalog,
|
||||
GameManager.ObservedTradeValueSettings(),
|
||||
out var price))
|
||||
{
|
||||
return ($"{template.Name} - unavailable", () => { }, false);
|
||||
}
|
||||
|
||||
var price = blueprint.Price(GameManager.ItemManager);
|
||||
return ($"{template.Name} - {price:n0}", () =>
|
||||
{
|
||||
GameManager.RequestRuntimeLoadoutRestore(template);
|
||||
|
|
@ -371,8 +375,11 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
foreach (var loadoutEntry in GameManager.ObservedLoadoutTemplates().Select((template, templateIndex) => (template, templateIndex)))
|
||||
{
|
||||
var restoreCommand = AetheriaRuntimeInventoryDropdownSurfaceBuilder.LoadoutCommand(loadoutEntry.templateIndex);
|
||||
var blueprint = GameManager.CreateEntityConstructionBlueprint(loadoutEntry.template);
|
||||
if (blueprint == null)
|
||||
if (!AetheriaRuntimeDaemonTradeItemQueries.TryProjectLoadoutTemplatePrice(
|
||||
loadoutEntry.template,
|
||||
ActionGameManager.RuntimeCatalog,
|
||||
GameManager.ObservedTradeValueSettings(),
|
||||
out var price))
|
||||
{
|
||||
loadoutOptions.Add(new AetheriaRuntimeInventoryDropdownOption(
|
||||
$"{AetheriaRuntimeInventoryDropdownSurfaceBuilder.SurfaceId}.loadouts.unavailable_{loadoutEntry.templateIndex}",
|
||||
|
|
@ -381,7 +388,6 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
continue;
|
||||
}
|
||||
|
||||
var price = blueprint.Price(GameManager.ItemManager);
|
||||
if (_dropdownCommands.ContainsKey(restoreCommand))
|
||||
{
|
||||
loadoutOptions.Add(new AetheriaRuntimeInventoryDropdownOption(
|
||||
|
|
|
|||
|
|
@ -279,13 +279,13 @@ public class TradeMenu : MonoBehaviour
|
|||
return ActionGameManager.RuntimeCatalog?.FindItem(item?.ItemKey ?? "");
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeTradeItemProjection ProjectTradeItem(ItemInstance item)
|
||||
private AetheriaRuntimeTradeItemProjection ProjectTradeItem(ItemInstance item)
|
||||
{
|
||||
var typedItem = FindTypedTradeItem(item);
|
||||
return AetheriaRuntimeDaemonTradeItemQueries.ProjectTradeItem(
|
||||
typedItem,
|
||||
ProjectTradeItemCommit(item),
|
||||
ProjectTradeValueSettings());
|
||||
GameManager.ObservedTradeValueSettings());
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeLoadoutItemCommit? ProjectTradeItemCommit(ItemInstance item)
|
||||
|
|
@ -300,25 +300,6 @@ public class TradeMenu : MonoBehaviour
|
|||
durability);
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeTradeValueSettings ProjectTradeValueSettings()
|
||||
{
|
||||
var source = ActionGameManager.Settings.GameplaySettings;
|
||||
var priceModifier = source.QualityPriceModifier;
|
||||
return new AetheriaRuntimeTradeValueSettings(
|
||||
new AetheriaRuntimeExponentialLerp(
|
||||
priceModifier.Exponent,
|
||||
priceModifier.Minimum,
|
||||
priceModifier.Maximum),
|
||||
(source.Tiers ?? Array.Empty<RarityTier>())
|
||||
.Select(tier => new AetheriaRuntimeItemRarityTier(
|
||||
tier.Name,
|
||||
tier.Quality,
|
||||
tier.Color.x,
|
||||
tier.Color.y,
|
||||
tier.Color.z))
|
||||
.ToArray());
|
||||
}
|
||||
|
||||
private static double GetTypedBehaviorNumber(TradeRow row, BehaviorFilter behaviorFilter, AetheriaRuntimeBehaviorFieldMetadata field)
|
||||
{
|
||||
var payload = FindTypedBehaviorPayload(row.TypedItem, behaviorFilter);
|
||||
|
|
@ -476,7 +457,7 @@ public class TradeMenu : MonoBehaviour
|
|||
return AetheriaRuntimeDaemonTradeItemQueries.ProjectTradeItem(
|
||||
typedItem,
|
||||
ProjectTradeItemCommit(item),
|
||||
ProjectTradeValueSettings()).Price;
|
||||
GameManager.ObservedTradeValueSettings()).Price;
|
||||
}
|
||||
|
||||
private void ShowUnableToBuy(string reason)
|
||||
|
|
|
|||
Loading…
Reference in a new issue