2025-12-18 14:27:27 +01:00
|
|
|
using Babushka.scripts.CSharp.GameEntity.LoadSave;
|
|
|
|
|
using Godot;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Babushka.scripts.CSharp.GameEntity.Entities;
|
|
|
|
|
|
2026-02-03 13:55:13 +01:00
|
|
|
public abstract class PositionalEntity : Entity
|
2025-12-18 14:27:27 +01:00
|
|
|
{
|
2026-02-03 13:55:13 +01:00
|
|
|
public Vector2 position;
|
2025-12-18 14:27:27 +01:00
|
|
|
public string sceneName = "none";
|
|
|
|
|
|
2026-02-03 17:30:35 +01:00
|
|
|
public override void SaveEntity(JObject json)
|
2025-12-18 14:27:27 +01:00
|
|
|
{
|
|
|
|
|
base.SaveEntity(json);
|
2026-02-03 17:30:35 +01:00
|
|
|
json["posx"] = position.X;
|
|
|
|
|
json["posy"] = position.Y;
|
2025-12-18 14:27:27 +01:00
|
|
|
json["scene"] = sceneName;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-03 17:30:35 +01:00
|
|
|
public override void LoadEntity(JObject json)
|
2025-12-18 14:27:27 +01:00
|
|
|
{
|
|
|
|
|
base.LoadEntity(json);
|
2026-02-03 17:30:35 +01:00
|
|
|
position = new Vector2(
|
2025-12-18 14:27:27 +01:00
|
|
|
json.GetFloatValue("posx"),
|
|
|
|
|
json.GetFloatValue("posy"));
|
|
|
|
|
sceneName = json.GetStringValue("scene");
|
|
|
|
|
}
|
2026-02-03 13:55:13 +01:00
|
|
|
|
|
|
|
|
// Deals with Instantiation of the node
|
2026-02-03 15:36:59 +01:00
|
|
|
public abstract void InstantiateEntityNode(Node2D parent);
|
2026-02-03 13:55:13 +01:00
|
|
|
|
2025-12-18 14:27:27 +01:00
|
|
|
}
|