Delay creation of inverse entity updates

This fixes the recording of projectile updates in a region.
This commit is contained in:
Gary Tierney
2017-12-31 07:10:52 +00:00
parent 1c57818885
commit 6818fff6ed
@@ -400,7 +400,7 @@ public final class Region {
*/ */
private <T extends Entity & GroupableEntity> void record(T entity, EntityUpdateType update) { private <T extends Entity & GroupableEntity> void record(T entity, EntityUpdateType update) {
UpdateOperation<?> operation = entity.toUpdateOperation(this, update); UpdateOperation<?> operation = entity.toUpdateOperation(this, update);
RegionUpdateMessage message = operation.toMessage(), inverse = operation.inverse(); RegionUpdateMessage message = operation.toMessage();
int height = entity.getPosition().getHeight(); int height = entity.getPosition().getHeight();
Set<RegionUpdateMessage> updates = this.updates.get(height); Set<RegionUpdateMessage> updates = this.updates.get(height);
@@ -411,12 +411,12 @@ public final class Region {
if (update == EntityUpdateType.REMOVE) { if (update == EntityUpdateType.REMOVE) {
removedObjects.get(height).add(message); removedObjects.get(height).add(message);
} else { // TODO should this really be possible? } else { // TODO should this really be possible?
removedObjects.get(height).remove(inverse); removedObjects.get(height).remove(operation.inverse());
} }
} }
if (update == EntityUpdateType.REMOVE && !type.isTransient()) { if (update == EntityUpdateType.REMOVE && !type.isTransient()) {
updates.remove(inverse); updates.remove(operation.inverse());
} }
updates.add(message); updates.add(message);