- Enclosing class:
- DefaultEntitySet
protected class DefaultEntitySet.Transaction
extends java.lang.Object
Keeps accumulated data about a set of changes. This buffers
the changes and finalizes them all at once which should be
a more efficient and simpler design than the deeply nested
loop I used to have in applyChanges().
Logic design is as follows:
// Keep a map of the entities that we got components for that
// we applied... so a DefaultEntity just kept there.
//
// Keep a map of the entities that we have changed for other
// reasons (or just the set).
//
// Go through the adds and complete any that are incomplete.
// Remove any that don't match the filter.
//
// Go through the otherwise changed entities and check them
// against the filter. If no longer matching then they
// are removes. Otherwise, they are really changes.
//
// In the adds, there is a slight race condition of sorts
// since when we go to fully retrieve the entity then we
// may see state that we haven't applied changes for yet.
// I think that's ok. We still give an accurate state upon
// return from this method and the next changes will just
// be redundant.
//
// The other benefit of the above is that in the cases
// where all of the entity components have changed (like when
// forwarding a new entity over the network) then we don't
// redundantly pull its whole info and we no longer stress
// the cache we put in to worry about that case.