Hi,
I am very brand new to ECS. In fact, have’t really touched it yet, other than read and watched multiple conferences and tutorials. But I am excited to look into porting my project, from OOP to ECS. Also, by implementing lua, I want keep game modable.
Basics Concept
In principles, I got many objects in scene, interacting with each other. For simplicity let them be boxes. Each has some behaviors. Some the same, some unique. Up to that point implementation (porting to) ECS seams feasible.
Lua
However, I got lua, moonsharp, which defines and drives behavior of my boxes. This is something I got working well with OOP. To keep simple, for example movement left right, or rotation. Problem I think, I may be facing, is integration of lua, which is OOP based, with ECS and Job System.
OOP System With Lua
Currently what I have, is simple for loop, iterating through my components and executing relevant lua script, which is calling exposed to lua methods.
For example:
List <Box> boxes ;
...
for ( int i = 0 ; i < boxes.count; i ++ )
{
box = boxes [i] ;
box.runLuaBrain () ;
}
...
public class Box
{
// method called by lua brain
public void _Rotate ( Vector3 angles )
{
... add rotation
}
}
Lua Integration With ECS?
Thing is, lua moonsharp is a third party library. And is quite extensive, to even attempt looking for transition into ECS.
I am not looking for strict code solution, but guidance, of what steps I would need to take (if possible), to make integration feasible, and actually porting my project itself into ECS worthwhile?
I can assume, something to do with Hybrid ECS? But I am not familiar with it, as of yet.
If I can not call from lua brain (OOP), directly to ECS components, one way of doing it, as I can think of, is to store called references and methods by lua. Which is with relevant inputs (angles) within array/list.
Then make ECS system, recall that array/methods/instructions back, within a JobSystem loop, to apply actual box physical behavior.
Any thoughts on the problem?
Many thanks