Improvements to save and loading
Improvements to Chinthe animation logic Fix broken Godot Tool system and just use a more manual approach to setting map nodes Remove ItemDatabase from individual room scenes
This commit is contained in:
@@ -60,12 +60,19 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
public RescuedItemDatabase RescuedItems { get; set; } = default!;
|
||||
|
||||
public QuestData QuestData { get; private set; }
|
||||
|
||||
private EffectService _effectService;
|
||||
|
||||
private IInstantiator _instantiator;
|
||||
private Player _player;
|
||||
private Map _map;
|
||||
|
||||
public Game()
|
||||
{
|
||||
QuestData = new QuestData();
|
||||
}
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
_container = new SimpleInjector.Container();
|
||||
@@ -91,30 +98,24 @@ public partial class Game : Node3D, IGame
|
||||
{
|
||||
var gameData = new GameData()
|
||||
{
|
||||
|
||||
PlayerData = new PlayerData()
|
||||
{
|
||||
Inventory = (Inventory)_player.Inventory,
|
||||
HealthComponent = (HealthComponent)_player.HealthComponent,
|
||||
},
|
||||
MapData = new MapData()
|
||||
{
|
||||
},
|
||||
RescuedItems = new RescuedItemDatabase()
|
||||
{
|
||||
Items = RescuedItems.Items
|
||||
},
|
||||
QuestData = new QuestData()
|
||||
{
|
||||
QuestMarker1 = QuestData.QuestMarker1
|
||||
}
|
||||
};
|
||||
return gameData;
|
||||
},
|
||||
onLoad:
|
||||
(chunk, data) =>
|
||||
{
|
||||
RescuedItems = data.RescuedItems;
|
||||
chunk.LoadChunkSaveData(data.PlayerData);
|
||||
chunk.LoadChunkSaveData(data.MapData);
|
||||
}
|
||||
);
|
||||
{
|
||||
RescuedItems = data.RescuedItems;
|
||||
QuestData = data.QuestData;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
@@ -127,7 +128,7 @@ public partial class Game : Node3D, IGame
|
||||
{
|
||||
try
|
||||
{
|
||||
var gameData = await saveFileManager.Load() as GameData;
|
||||
var gameData = await saveFileManager.Load<GameData>();
|
||||
return gameData;
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
@@ -200,6 +201,7 @@ public partial class Game : Node3D, IGame
|
||||
{
|
||||
FloorClearMenu.FadeOut();
|
||||
Task.Run(() => _map.LoadFloor());
|
||||
Task.Run(() => Save());
|
||||
if (_player.EquipmentComponent.EquippedWeapon.Value.ItemTag == ItemTag.BreaksOnChange)
|
||||
{
|
||||
var itemToDestroy = _player.EquipmentComponent.EquippedWeapon.Value;
|
||||
@@ -248,6 +250,7 @@ public partial class Game : Node3D, IGame
|
||||
public void OnReady()
|
||||
{
|
||||
InitializeGame();
|
||||
SaveFile.Load();
|
||||
_map.LoadFloor();
|
||||
GameRepo.Resume();
|
||||
InGameUI.Show();
|
||||
@@ -272,6 +275,8 @@ public partial class Game : Node3D, IGame
|
||||
_map.InitializeMapData();
|
||||
}
|
||||
|
||||
public async Task Save() => await SaveFile.Save();
|
||||
|
||||
public void FloorExitReached()
|
||||
{
|
||||
GameState.Input(new GameState.Input.FloorExitEntered());
|
||||
|
||||
Reference in New Issue
Block a user