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
+12 -8
View File
@@ -1,23 +1,27 @@
using System;
using Babushka.scripts.CSharp.GameEntity.LoadSave;
using Babushka.scripts.CSharp.GameEntity.Types;
using Godot;
using Newtonsoft.Json.Linq;
namespace Babushka.scripts.CSharp.GameEntity.Entities;
public partial class Entity : Node2D
public class Entity
{
private long _id;
protected virtual EntityType Type => EntityType.None;
public long id;
public virtual string EntityType => "";
public Entity()
{
id = new Random().NextInt64();
}
protected virtual void SaveEntity(JObject json)
{
json["id"] = _id;
json["type"] = (int)Type;
json["id"] = id;
json["type"] = EntityType;
}
protected virtual void LoadEntity(JObject json)
{
_id = json.GetLongValue("id");
id = json.GetLongValue("id");
}
}