Major Changes including Options menu, logic blocks, modding system, and more.
This commit is contained in:
@@ -57,8 +57,8 @@ IProvide<IItemRenderer>,
|
||||
IProvide<IRecipes>,
|
||||
IProvide<IBlueprintManger>,
|
||||
IProvide<World>,
|
||||
IProvide<IFoodFactoryApi>,
|
||||
IProvide<ISaveChunk<GameData>>
|
||||
IProvide<IFoodFactoryApi>//,
|
||||
// IProvide<ISaveChunk<GameData>>
|
||||
{
|
||||
public override void _Notification(int what) => this.Notify(what);
|
||||
|
||||
@@ -74,7 +74,7 @@ IProvide<ISaveChunk<GameData>>
|
||||
IRecipes IProvide<IRecipes>.Value() => _recipes;
|
||||
private IItemRenderer _itemRenderer = default!;
|
||||
IItemRenderer IProvide<IItemRenderer>.Value() => _itemRenderer;
|
||||
public ISaveChunk<GameData> Value() => SaveFile.Root;
|
||||
// public ISaveChunk<GameData> Value() => SaveFile.Root;
|
||||
public static string SavePath => $"{OS.GetUserDataDir()}/SaveFile.json";
|
||||
JsonSerializerOptions _options;
|
||||
public void Setup()
|
||||
@@ -89,47 +89,47 @@ IProvide<ISaveChunk<GameData>>
|
||||
|
||||
var test = "gg";
|
||||
GD.Print(SavePath);
|
||||
SaveFile = new SaveFile<GameData>(
|
||||
new SaveChunk<GameData>(
|
||||
onSave: (chunk) =>
|
||||
{
|
||||
// SaveFile = new SaveFile<GameData>(
|
||||
// new SaveChunk<GameData>(
|
||||
// onSave: (chunk) =>
|
||||
// {
|
||||
|
||||
var gameData = new GameData()
|
||||
{
|
||||
World = _world,
|
||||
// Equipments = chunk.GetChunkSaveData<EquipmentsData>()
|
||||
};
|
||||
return gameData;
|
||||
},
|
||||
onLoad: (chunk, data) =>
|
||||
{
|
||||
World.Destroy(_world);
|
||||
_world = data.World;
|
||||
// chunk.LoadChunkSaveData(data.Equipments);
|
||||
}
|
||||
),
|
||||
onSave: async data =>
|
||||
{
|
||||
// var gameData = new GameData()
|
||||
// {
|
||||
// World = _world,
|
||||
// // Equipments = chunk.GetChunkSaveData<EquipmentsData>()
|
||||
// };
|
||||
// return gameData;
|
||||
// },
|
||||
// onLoad: (chunk, data) =>
|
||||
// {
|
||||
// World.Destroy(_world);
|
||||
// _world = data.World;
|
||||
// // chunk.LoadChunkSaveData(data.Equipments);
|
||||
// }
|
||||
// ),
|
||||
// onSave: async data =>
|
||||
// {
|
||||
|
||||
var yaml = JsonSerializer.Serialize(data, _options);
|
||||
|
||||
GD.Print(SavePath);
|
||||
await File.WriteAllTextAsync(SavePath, yaml);
|
||||
},
|
||||
onLoad: async () =>
|
||||
{
|
||||
if (!File.Exists(SavePath))
|
||||
{
|
||||
GD.PushWarning("Save does nto exist");
|
||||
return null;
|
||||
}
|
||||
// var yaml = JsonSerializer.Serialize(data, _options);
|
||||
// GD.Print(SavePath);
|
||||
// await File.WriteAllTextAsync(SavePath, yaml);
|
||||
// },
|
||||
// onLoad: async () =>
|
||||
// {
|
||||
// if (!File.Exists(SavePath))
|
||||
// {
|
||||
// GD.PushWarning("Save does nto exist");
|
||||
// return null;
|
||||
// }
|
||||
|
||||
var data = JsonSerializer.Deserialize<GameData>(await File.ReadAllTextAsync(SavePath), _options);
|
||||
return data;
|
||||
}
|
||||
);
|
||||
// var data = JsonSerializer.Deserialize<GameData>(await File.ReadAllTextAsync(SavePath), _options);
|
||||
// return data;
|
||||
// }
|
||||
// );
|
||||
}
|
||||
public ISaveFile<GameData> SaveFile { get; set; } = default!;
|
||||
// public ISaveFile<GameData> SaveFile { get; set; } = default!;
|
||||
Group<float> _systems;
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -190,12 +190,12 @@ IProvide<ISaveChunk<GameData>>
|
||||
}
|
||||
if (@event.IsActionPressed("ui_right"))
|
||||
{
|
||||
SaveFile.Save();
|
||||
// SaveFile.Save();
|
||||
|
||||
}
|
||||
if (@event.IsActionPressed("ui_left"))
|
||||
{
|
||||
SaveFile.Load();
|
||||
// SaveFile.Load();
|
||||
}
|
||||
}
|
||||
public override void _ExitTree()
|
||||
|
||||
Reference in New Issue
Block a user