Added basic entity scripts
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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
|
||||
{
|
||||
private long _id;
|
||||
protected virtual EntityType Type => EntityType.None;
|
||||
|
||||
protected virtual void SaveEntity(JObject json)
|
||||
{
|
||||
json["id"] = _id;
|
||||
json["type"] = (int)Type;
|
||||
}
|
||||
|
||||
protected virtual void LoadEntity(JObject json)
|
||||
{
|
||||
_id = json.GetLongValue("id");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://hnmpt23ovfgl
|
||||
@@ -0,0 +1,27 @@
|
||||
using Babushka.scripts.CSharp.GameEntity.LoadSave;
|
||||
using Godot;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Babushka.scripts.CSharp.GameEntity.Entities;
|
||||
|
||||
public partial class PositionalEntity : Entity
|
||||
{
|
||||
public string sceneName = "none";
|
||||
|
||||
protected override void SaveEntity(JObject json)
|
||||
{
|
||||
base.SaveEntity(json);
|
||||
json["posx"] = Position.X;
|
||||
json["posy"] = Position.Y;
|
||||
json["scene"] = sceneName;
|
||||
}
|
||||
|
||||
protected override void LoadEntity(JObject json)
|
||||
{
|
||||
base.LoadEntity(json);
|
||||
Position = new Vector2(
|
||||
json.GetFloatValue("posx"),
|
||||
json.GetFloatValue("posy"));
|
||||
sceneName = json.GetStringValue("scene");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://bs38dulqv7sop
|
||||
Reference in New Issue
Block a user