Route loadout restore through checkpoints
This commit is contained in:
parent
f58e738cf8
commit
8d802ce1e0
5 changed files with 99 additions and 11 deletions
|
|
@ -1306,6 +1306,36 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
public bool CommitRuntimeLoadoutRestore(AetheriaRuntimeLoadoutTemplateSnapshot template, out Entity entity)
|
||||
{
|
||||
entity = null;
|
||||
var blueprint = CreateEntityConstructionBlueprint(template);
|
||||
if (blueprint == null ||
|
||||
Zone == null ||
|
||||
DockedEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var price = blueprint.Price(ItemManager);
|
||||
if (price > Credits)
|
||||
return false;
|
||||
|
||||
entity = EntityConstructionBlueprintProjector.InstantiateFromBlueprint(ItemManager, Zone, blueprint, true);
|
||||
entity.SetParent(DockedEntity);
|
||||
Credits -= price;
|
||||
CurrentEntity = entity;
|
||||
if (entity is Ship ship)
|
||||
{
|
||||
ship.IsPlayerShip = true;
|
||||
if (DockingBay != null)
|
||||
DockingBay.DockedShip = ship;
|
||||
}
|
||||
|
||||
QueueRunCheckpoint("loadout-restore");
|
||||
return true;
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeLoadoutTemplateSnapshot CreateRuntimeLoadoutTemplateSnapshot(
|
||||
AetheriaRuntimeLoadoutTemplateCommit template)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -198,16 +198,8 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
var price = blueprint.Price(GameManager.ItemManager);
|
||||
return ($"{template.Name} - {price:n0}", () =>
|
||||
{
|
||||
var entity = EntityConstructionBlueprintProjector.InstantiateFromBlueprint(GameManager.ItemManager, GameManager.Zone, blueprint, true);
|
||||
entity.SetParent(GameManager.DockedEntity);
|
||||
GameManager.Credits -= price;
|
||||
GameManager.CurrentEntity = entity;
|
||||
if(entity is Ship ship)
|
||||
{
|
||||
ship.IsPlayerShip = true;
|
||||
GameManager.DockingBay.DockedShip = ship;
|
||||
}
|
||||
Display(entity);
|
||||
if (GameManager.CommitRuntimeLoadoutRestore(template, out var entity))
|
||||
Display(entity);
|
||||
}, price < GameManager.Credits);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue