I’ve started writing my own ECS, just to see how they work. But I’m also trying to work out how to use the Paradox ECS.
Now I have a MeleeComponent and HealthComponent so far, written in my own basic ECS which I’m trying to rework to use the EntityComponent instead. However I am getting a NotImplementedException, but strangely, I’m not being told what I haven’t implemented. I’m guessing that it’s the DefaultKey that needs to be overridden. But I don’t really know what to do here …
So my HealthComponent looks like this
public class HealthComponent : EntityComponent
{
public HealthComponent() : base()
{
DefaultKey = // ** What do i do here ? **
}
public int Max { get; set; }
public int Current { get; set; }
}
Edit : So if I setup a private field for my custom component
private PropertyKey defaultKey;
defaultKey = new PropertyKey<Components>("HealthComponent",typeof(Components), null);
then override PropertyKey DefaultKey with
public override PropertyKey DefaultKey { get { return defaultKey; } }
I get an invalid cast exception when i try to add the compoent to my entity. As you you can probably see, I don’t really know what I’m meant to be doing here.