Save and load map data
This commit is contained in:
@@ -94,6 +94,7 @@ public partial class Game : Node3D, IGame
|
||||
GameLogic.Set(AppRepo);
|
||||
GameLogic.Set(GameEventDepot);
|
||||
GameLogic.Set(Player);
|
||||
GameLogic.Set(Map);
|
||||
Instantiator = new Instantiator(GetTree());
|
||||
RescuedItems = new RescuedItemDatabase();
|
||||
|
||||
@@ -137,14 +138,21 @@ public partial class Game : Node3D, IGame
|
||||
Luck = Player.Stats.Luck.Value
|
||||
},
|
||||
Inventory = Player.Inventory
|
||||
}
|
||||
},
|
||||
MapData = new MapData()
|
||||
{
|
||||
FloorScenes = Map.FloorScenes
|
||||
},
|
||||
RescuedItems = new RescuedItemDatabase() { Items = RescuedItems.Items }
|
||||
};
|
||||
|
||||
return gameData;
|
||||
},
|
||||
onLoad: (chunk, data) =>
|
||||
{
|
||||
RescuedItems = data.RescuedItems;
|
||||
chunk.LoadChunkSaveData(data.PlayerData);
|
||||
chunk.LoadChunkSaveData(data.MapData);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,4 +8,10 @@ public partial record GameData
|
||||
{
|
||||
[Save("player_data")]
|
||||
public required PlayerData PlayerData { get; init; }
|
||||
|
||||
[Save("map_data")]
|
||||
public required MapData MapData { get; init; }
|
||||
|
||||
[Save("rescued_items")]
|
||||
public required RescuedItemDatabase RescuedItems { get; init; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user