private void MapBlocks <T1>(EntityCommandGrouper <T1> changes) { _beforeBlocksCursor = 0; _afterBlocksCursor = 0; while (true) { Command.PropertyCommand change = changes.nextProperty(); if (change == null) { break; } foreach (PropertyBlock block in change.Before) { if (_beforeBlocksCursor == _beforeBlocks.Length) { _beforeBlocks = Arrays.copyOf(_beforeBlocks, _beforeBlocksCursor * 2); } _beforeBlocks[_beforeBlocksCursor++] = block; } foreach (PropertyBlock block in change.After) { if (_afterBlocksCursor == _afterBlocks.Length) { _afterBlocks = Arrays.copyOf(_afterBlocks, _afterBlocksCursor * 2); } _afterBlocks[_afterBlocksCursor++] = block; } } Arrays.sort(_beforeBlocks, 0, _beforeBlocksCursor, _blockComparator); Arrays.sort(_afterBlocks, 0, _afterBlocksCursor, _blockComparator); }
/// <summary> /// Converts physical changes to PropertyRecords for a entity into logical updates /// </summary> public virtual void ConvertPropertyRecord <T1>(EntityCommandGrouper <T1> changes, EntityUpdates.Builder properties) { MapBlocks(changes); int bc = 0; int ac = 0; while (bc < _beforeBlocksCursor || ac < _afterBlocksCursor) { PropertyBlock beforeBlock = null; PropertyBlock afterBlock = null; int beforeKey = int.MaxValue; int afterKey = int.MaxValue; int key; if (bc < _beforeBlocksCursor) { beforeBlock = _beforeBlocks[bc]; beforeKey = beforeBlock.KeyIndexId; } if (ac < _afterBlocksCursor) { afterBlock = _afterBlocks[ac]; afterKey = afterBlock.KeyIndexId; } if (beforeKey < afterKey) { afterBlock = null; key = beforeKey; bc++; } else if (beforeKey > afterKey) { beforeBlock = null; key = afterKey; ac++; } else { // They are the same key = afterKey; bc++; ac++; } if (beforeBlock != null && afterBlock != null) { // CHANGE if (!beforeBlock.HasSameContentsAs(afterBlock)) { Value beforeVal = ValueOf(beforeBlock); Value afterVal = ValueOf(afterBlock); properties.Changed(key, beforeVal, afterVal); } } else { // ADD/REMOVE if (afterBlock != null) { properties.Added(key, ValueOf(afterBlock)); } else { properties.Removed(key, ValueOf(beforeBlock)); } } } }
public Cursor(EntityCommandGrouper <ENTITY> outerInstance) { this._outerInstance = outerInstance; }