First adjustments to the Entity System to make it work with different types
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user