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); } } } }
public void CopyFrom(EcsComponentMask mask) { BitsCount = mask.BitsCount; if (Bits.Length < BitsCount) { Bits = new int[mask.Bits.Length]; } Array.Copy(mask.Bits, 0, Bits, 0, BitsCount); }
public bool IsIntersects(EcsComponentMask mask) { if (BitsCount > 0 && mask.BitsCount > 0) { for (var i = 0; i < BitsCount; i++) { var bit = Bits[i]; for (var j = 0; j < mask.BitsCount; j++) { if (mask.Bits[j] == bit) { return(true); } } } } return(false); }
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); } } } }
internal bool IsEquals(EcsComponentMask mask) { if (BitsCount != mask.BitsCount) { return(false); } for (var i = 0; i < BitsCount; i++) { var j = mask.BitsCount - 1; var bit = Bits[i]; for (; j >= 0; j--) { if (mask.Bits[j] == bit) { break; } } if (j == -1) { return(false); } } return(true); }