First adjustments to the Entity System to make it work with different types

This commit is contained in:
Katharina Ziolkowski
2026-02-03 13:55:13 +01:00
parent 745f54b375
commit bcbc074c86
33 changed files with 12822 additions and 107 deletions
@@ -4,24 +4,30 @@ using Newtonsoft.Json.Linq;
namespace Babushka.scripts.CSharp.GameEntity.Entities;
public partial class PositionalEntity : Entity
public abstract class PositionalEntity : Entity
{
private Node2D _positionalNodeRef;
public Vector2 position;
public string sceneName = "none";
protected override void SaveEntity(JObject json)
{
base.SaveEntity(json);
json["posx"] = Position.X;
json["posy"] = Position.Y;
json["posx"] = _positionalNodeRef.Position.X;
json["posy"] = _positionalNodeRef.Position.Y;
json["scene"] = sceneName;
}
protected override void LoadEntity(JObject json)
{
base.LoadEntity(json);
Position = new Vector2(
_positionalNodeRef.Position = new Vector2(
json.GetFloatValue("posx"),
json.GetFloatValue("posy"));
sceneName = json.GetStringValue("scene");
}
// Deals with Instantiation of the node
public abstract void AddEntity(Node2D parent);
}