Entity Rewrite Possibilities
I guess I wasn't too clear. I think the entity should have its data stored either in the entity class itself, or in the individual subsystem classes (whatever makes more sense for the particular kind of data), but it is each subsystem's responsibility to know how to save and load that data from / to NBT, *when serializing the entity*. So when the entity gets loaded, its subsystems load their internal data from the entity's NBT, and when it's saved, the subsystems save the data. They store the data within themselves, as they see fit. If there is need to share the data between multiple subsystems, that needs individual consideration. In a general case, such a sharing means the subsystems are not designed properly.

From this, you can see that a subsystem cannot be a class with a single operator(), but instead many virtual methods. For example:
/** The interface of the high-level AI subclasses */
class cEntity::IBehavior
  /** Called when aAttacker has attacked this entity. */
  virtual void OnAttacked(const cEntity & aAttacker) = 0;

  /** Called when sight of the tracked target was lost (such as when targeting a player, or hunting) */
  virtual void OnLostSightOfTarget(const cEntity & aTarget) = 0;

  /** Called when a new entity comes into the sight range.
  This doesn\'t mean the entity can be seen, it is only close enough to actually check the line-of-sight, if desired. */
  virtual void OnEntityInSightRange(const cEntity & aEntity) = 0;

  // ...

  /** Saves the behavior\'s data to the NBT */
  virtual void SaveToNBT(...) = 0;

  /** Loads the behavior\'s data to the NTB. */
  virtual void LoadFromNBT(...) = 0;
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: 1 Guest(s)