It seems like you are trying to accomplish object-oriented programming here, and that’s not really what ECS is about. You can’t really abstract each MapObject like you’re talking about here - each piece of “data” has to have a purpose.
For example, here’s how you would lay out data instead (using the classic player-type OOP abstraction).
In OOP:
We have an abstract Character, which contains health, etc…
We have a Player, which extends off of Character, and adds functionality.
We have a Monster, which extends off of Character, and adds functionality.
In ECS:
We have 3 components, Character, Player, Monster.
For all entities with Character, we query it and do this “tick” method that you specified above.
For all entities with Character AND Player, we do a “specific functionality” that you mentioned above.
For all entities with Character AND Monster, we do a “specific functionality” that you mentioned above.
For the setup method, a really neat trick that I found to be very useful is you can use ScriptableObjects for initial setup, read them using Addressables and create entities with them (useful if you are the programmer, and have a non-programmer friend who you are working with, and would like to provide them an easy “object-oriented” way of creating stuff).
Here’s how it works:
public class PreloadCharactersSystem : ComponentSystem
{
protected override void OnCreate()
{
Addressables.LoadAssetsAsync<MonsterScriptableObject>("Characters", asset => { ... });
Addressables.LoadAssetsAsync<PlayerScriptableObject>("Characters", asset => { ... });
// OR instead of accessing specific ScriptableObjects, you can access every SO with a specific parent too:
Addressables.LoadAssetsAsync<CharacterScriptableObject>("Characters", asset => { ... });
}
protected override void OnUpdate()
{
}
}
This is how I would approach for the section that you mentioned “when the object is first created and placed into a cell”.
You can access “asset” like you would from a MonoBehaviour, which is pretty neat. From there, you would use the variables passed in your “PlayerScriptableObject” and create entities with them. The “Characters” string in the first parameter is just the label you used for the Addressables item (could be anything really).
I hope that helps. I recommend reading Data-Oriented Design. It really helps if you instead try to picture everything as a big “database” (if you’ve worked with databases before. if not, this book explains it really well).