void UpdateFilters(int entity, EcsComponentMask oldMask, EcsComponentMask newMask) { for (var i = _filtersCount - 1; i >= 0; i--) { var filter = _filters[i]; var isNewMaskCompatible = newMask.IsCompatible(filter); if (oldMask.IsCompatible(filter)) { if (!isNewMaskCompatible) { #if DEBUG var ii = filter.EntitiesCount - 1; for (; ii >= 0; ii--) { if (filter.Entities[ii] == entity) { break; } } EcsHelpers.Assert(ii != -1, string.Format("Something wrong - entity {0} should be in filter {1}, but not exits.", entity, filter)); #endif filter.RaiseOnRemoveEvent(entity); } } else { if (isNewMaskCompatible) { filter.RaiseOnAddEvent(entity); } } } }
protected void UpdateFilters(int entity, EcsComponentMask oldMask, EcsComponentMask newMask) { for (int i = 0, iMax = _filtersCount; i < iMax; i++) { var filter = _filters[i]; var isNewMaskCompatible = newMask.IsCompatible(filter); if (oldMask.IsCompatible(filter)) { if (!isNewMaskCompatible) { #if DEBUG var ii = filter._entitiesCount - 1; for (; ii >= 0; ii--) { if (filter.Entities[ii] == entity) { break; } } if (ii == -1) { throw new Exception(string.Format("Something wrong - entity {0} should be in filter {1}, but not exits.", entity, filter)); } #endif filter.RaiseOnRemoveEvent(entity); } } else { if (isNewMaskCompatible) { filter.RaiseOnAddEvent(entity); } } } }