Creating a stable and fast modual communications Infrastructure.,
Members - Reputation: 607
Posted 29 January 2001 - 04:16 AM
Posted 29 January 2001 - 05:31 AM
-Modules will need precedent (order of update within 1 tick)
-Modules need a way to communicate to each other, i use:
a)event system similar to windows events. A message loop within an update queries a central message repository for that entity, responding to events of a particular nature.
b)indirectly through the use of a special type of module class i call the interface module.
Within an interface module, the calling module can invoke a stored callback within the interface module, which was registered by another module at creation time of the entity. The callback is nessecary for performance reasons (as the event system takes 1 tick to process which can add significant latency if a tick is greater than 100ms.)
Interface modules are special in that an entity can only have 1 of a particular type. I have various interface modules for collision, AI, etc..
They also serve as a repositroy information, usually stored in tables with logical name id mapping scheme. (a constant such as AI_TRACK_TARGET which maps into a hastable etc..)
-Use refrence counting for entites stored within the various lists/tables of the modules. It''s impossible to keep track of all the entites within such a dynamic system, best design for it from the begining.
-Balance modularity with complexity. If you can get a behaviour you want out of a minimum number interconnecting of modules and they are reuseable then thats good. Don''t try to get complex behavior through many small modules, rather a large customizeable one is better.
-You''ll need to instantiate your entity classes at start time, you''ll need a way to convert the text name of a module into its logical class. Name each module uniquely.
-You''ll need to implement a save/load function for each module. This function saves/loads data between loading/saving games. It doenst have to save any data but some updates do need to.