Entity Rewrite Possibilities
#3
(04-06-2020, 07:27 PM)xoft Wrote: How about this:

Single class, cEntity. Contains fields for plugging "subsystems" - a subsystem for pathfinding, a subsystem for physics, a subsystem for handling interactions, a subsystem dictating the graphical look of the entity, a subsystem for handling sounds, etc. Basically what your interaction functions do, I'd put into a subsystem (an interface, a class with virtual functions, descendants implement actual behavior). Each of these subsystems can also load and save specific NBT data; only the subsystem knows what NBT data it can load or save.
Each cEntity also has a dictionary / hashmap for storing custom values.
So by "load and save" NBT data, you mean that the data an entity needs to use is only loaded into memory when the subsystem needs it? Or at least, it will be fetched from the chunk region file every time (which could or could not already be loaded). That's not what happens currently as far as I can tell by the code. This seems like it would be very inefficient. I was going to bring up the point of multiple subsystems needing the same piece of data, which this would seem to fix, but if the load-save method isn't very efficient, I think that having each component deal with its own NBT data just isn't a very simple solution. There it seems like there needs to be faster-to-access source of data than just the chunks.

Also, what do you mean by "custom values"? Do you mean non-default NBT data?

I think this is a generally a good idea; I can definitely see how things like path finding should have some kind of internal state that just can't be easily encapsulated in a function. So I will revise the proposal to:
  • cSubSys : none
    • operator()
  • cEntity : none
    • use = cSubSys | subsystem called when the player tries using the entity; e.g. boats, villagers
    • entityIntersection = cSubSys | subsystem that dictates behavior when this entity intersects with another entity
    • blockIntersection = cSubSys | subsystem that dictates behavior when this entity intersects with a block
    • burning = cSubSys | subsystem dictates behavior of entity when it is caught on fire
    • pathfinding = cSubSys | subsystem that dictates if/how this entity seeks out new positions
    • placement = cSubSys | subsystem that dictates how this entities coordinates exist; e.g. minecarts on rails? paintings, leads, etc.
    • gravity = cSubSys | subsystem that dictates if/how gravity affects this entity
    • statusEffect = cSubSys | subsystem that dictates how status effects affect this entity
    • Entity data = ??? | unclear
I think the NBT is going to end up being the largest part of this system. The current system is very tidy and fast with how it handles data in memory, so approaching that would be nice.
Reply
Thanks given by:


Messages In This Thread
Entity Rewrite Possibilities - by Lazauya - 04-06-2020, 08:29 AM
RE: Entity Rewrite Possibilities - by xoft - 04-06-2020, 07:27 PM
RE: Entity Rewrite Possibilities - by Lazauya - 04-07-2020, 06:34 AM
RE: Entity Rewrite Possibilities - by Lazauya - 04-09-2020, 06:35 AM
RE: Entity Rewrite Possibilities - by xoft - 04-12-2020, 12:51 AM



Users browsing this thread: 2 Guest(s)