♻️ refactored field code to work with the new id system
This commit is contained in:
@@ -16,8 +16,8 @@ namespace Babushka.scripts.CSharp.Common.Farming;
|
||||
public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
||||
{
|
||||
[ExportGroup("Persistence")]
|
||||
[Export] public string SaveId = "";
|
||||
[Export] private VariableNode _fieldIndex;
|
||||
[Export] private Node _saveIdHolder;
|
||||
[Export] public VariableResource _sceneKeyProvider;
|
||||
[Export] public FieldState FieldState = FieldState.Tilled;
|
||||
|
||||
@@ -78,8 +78,6 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
||||
_currentPlant = PlantingPlaceholder.GetChild<PlantBehaviour2D>(0);
|
||||
UpdateFieldState(FieldState);
|
||||
|
||||
FieldService.Instance.TryAddEntry(_sceneKeyProvider.Payload.AsString(),_fieldIndex.Payload.AsInt32(), this);
|
||||
|
||||
int randomIndex = new Random().Next(0, _maskTexture.Length);
|
||||
_maskSprite.Texture = _maskTexture[randomIndex];
|
||||
_outlineSprite.Texture = _maskOutlineTextures[randomIndex];
|
||||
@@ -202,12 +200,13 @@ public partial class FieldBehaviour2D : Sprite2D, ISaveable
|
||||
);
|
||||
}
|
||||
|
||||
SavegameService.AppendDataToSave(SaveId + _fieldIndex.Payload.AsString(), payloadData);
|
||||
string id = _saveIdHolder.GetMeta("SaveID").AsString();
|
||||
SavegameService.AppendDataToSave(id, payloadData);
|
||||
}
|
||||
|
||||
public void LoadFromSaveData()
|
||||
{
|
||||
var id = SaveId + _fieldIndex.Payload.AsString();
|
||||
string id = _saveIdHolder.GetMeta("SaveID").AsString();
|
||||
|
||||
Dictionary<string, Variant> save = SavegameService.GetSaveData(id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user