Files
Babushka/scripts/CSharp/GameEntity/Entities/PositionalEntity.cs
T

32 lines
835 B
C#
Raw Normal View History

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;
public abstract class PositionalEntity : Entity
2025-12-18 14:27:27 +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");
}
// Deals with Instantiation of the node
public abstract void InstantiateEntityNode(Node2D parent);
2025-12-18 14:27:27 +01:00
}