Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

112 Neutral

About CogOfHate

  • Rank
  1. CogOfHate

    Component based system, doing it right?

      Your second implementation is how I'm implementing my ES as well.  Systems contain the logic, components hold the data and entities are nothing more than an identifier.   I too am using message passing in which the Systems subscribe to which messages they are interested in.   The reason I chose to break the components and systems up in this manner was to make it easier to thread them.  The systems are self-contained and components don't know about other components making this job a little easier.
  2. Thanks for the suggestion.  I think you were right and I was thinking about stuff in all the wrong way.  I have since moved away from polymorphism in favour of a better approach.  I think I can achieve what I want through proper message passing instead of the convoluted way I was previously using.
  3. CogOfHate

    Component based system, doing it right?

      Would it make sense in that case to have the cannons as separate entities? They could be attached to the parent and inherit all transform properties and what not.
  4. CogOfHate

    Component based system, doing it right?

    I too am trying to design a entity system in this manner.  I am also faced with the same problems.  The one one article that I read and I thought was really good at explaining the idea to me was http://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/   In designing a component system, I gather that the idea is to have all the systems keep a local copy of the components that it will use in some locally allocated array.  This way, the process of iterating over all components within the system will make it more cache coherent.   I would try to avoid calling methods on entities as this will incur a LHS (load hit store) and cache misses.  The system should have all the information it needs.  In doing it this way, it should be trivial to start threading the systems on different processes.   An idea I am playing around with is having a message queue that is maintained within the engine (or equivalent).   Queue looks like:   ____________________________________ | <EntityID, Component> | <Read|Write> Bit | ____________________________________ | ...                                   |                              | ____________________________________   First time through, the queue is empty.  The queue is copied to the system before the update method is called.  If a system modifies a component, it places a message in the queue setting the WRITE bit.   The queue is copied back and sent over to the next system.  The next system if it requires the updatd information will check the message queue.  If it reads the component for the entity in question it will set the READ bit.   At the end of the frame, after all systems have had their go, we purge all entries in the queue that are marked READ and keep the ones that are marked WRITE.  This way, the previous systems in the big loop through will get the messages from the previous frame.    I'm not sure this is the best way, it's just an approach I'm trying to take.   Another good resource is: https://docs.google.com/presentation/d/1mOZCf8u9rg-nnJfo4sZwnuIMXSFigKjqvofwkAiksHI/edit?pli=1#slide=id.i0
  5. Hello Everyone,   I have a problem I am currently facing and I'm wondering if the community could help me out.  I find it's probably easier to explain with an example. struct Base { }; struct Derived : public Base {     Derived(float newX) : x(newX)     {     }          float x; }; struct Unrelated : public Base {     Unrelated(char val) : v(val)     {     }          char v; } ...   // How to copy the data that's in mBaseArray into another struct? // Don't want pointer copy as it's not thread safe.   // Below is a very simple example.   Module1 ----------- class Module1 { ...     Array<Base*> mBaseArray; };    - mBaseArray is populate in some fashion.  Notice the use of polymorphism here.   mBaseArray.push_back(new Derived(10)); mBaseArray.push_back(new Unrelated('c'));     ... Some sync point here ... After this point, I want to copy the information that is in mBaseArray into Module2's mWorkingArray.   Module2 ----------- class Module2 { ...     Array<Base*> mWorkingArray; };   - Want to copy the data from mBaseArray into Module2's own array. - Copied data from mBaseArray without the use of pointers.  Want only data. - Module2 contains a similar declaration to mBaseArray.   Is there a way to accomplish this?  Or is there some other method that will solve this problem?   If there are better ways of doing what I'm trying to accomplish, I am more than welcome to suggestions.   Thanks.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!