WIP reworking the field behaviour to implement watering. Broken state.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Babushka.scripts.CSharp.Common.Farming;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class FieldService : Node3D
|
||||
{
|
||||
[Export] private Dictionary<Vector2I, FieldState> fields = new Dictionary<Vector2I, FieldState>();
|
||||
|
||||
//Create
|
||||
|
||||
public void AddEntry(Vector2I key, FieldState state)
|
||||
{
|
||||
fields.Add(key, state);
|
||||
}
|
||||
|
||||
// Read
|
||||
|
||||
public FieldState Get(Vector2I key)
|
||||
{
|
||||
return fields[key];
|
||||
}
|
||||
|
||||
//Update
|
||||
public void UpdateEntry(Vector2I fieldPosition, FieldState state)
|
||||
{
|
||||
if (fields.ContainsKey(fieldPosition))
|
||||
{
|
||||
fields[fieldPosition] = state;
|
||||
}
|
||||
else
|
||||
{
|
||||
AddEntry(fieldPosition, state);
|
||||
}
|
||||
}
|
||||
|
||||
//Delete
|
||||
|
||||
public void RemoveEntry(Vector2I fieldPosition)
|
||||
{
|
||||
if (fields.ContainsKey(fieldPosition))
|
||||
{
|
||||
fields.Remove(fieldPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user