private int MergeCollisionData(int sectorX, int sectorY, Grid <TileCollisionShape> target) { Point2 beginTile = new Point2(sectorX * SectorSize, sectorY * SectorSize); Point2 endTile = new Point2((sectorX + 1) * SectorSize, (sectorY + 1) * SectorSize); endTile.X = Math.Min(endTile.X, this.tileCount.X); endTile.Y = Math.Min(endTile.Y, this.tileCount.Y); TileInfo[][] tileData = GetRawTileData(this.sourceTilemaps); // Start with a non-zero checksum, so it doesn't equal the uninitialized sector checksum int checksum = 1; for (int y = beginTile.Y; y < endTile.Y; y++) { for (int x = beginTile.X; x < endTile.X; x++) { TileCollisionShape mergedCollision = TileCollisionShape.Free; for (int i = 0; i < this.sourceTilemaps.Length; i++) { if (this.sourceTilemaps[i] == null) { continue; } if (tileData[i] == null) { continue; } Tile tile = this.sourceTilemaps[i].Tiles[x, y]; TileCollisionShape collision = tileData[i][tile.Index].Collision[this.source[i].Layers]; mergedCollision |= collision; } target[x - beginTile.X, y - beginTile.Y] = mergedCollision; MathF.CombineHashCode(ref checksum, (int)mergedCollision); } } return(checksum); }
private static int GetTileArrayCompileHash <T>(T[] data, int count) where T : struct { int hash = 17; int defaultTileHash = default(T).GetHashCode(); for (int i = 0; i < count; i++) { int tileHash = data[i].GetHashCode(); // Exclude hashes from default inputs so they're considered equal // to not being defined in the input data array. if (tileHash == defaultTileHash) { continue; } // Due to the above rule, we'll have to include each tiles index in the // has, so leading defaults will still affect following non-defaults MathF.CombineHashCode(ref hash, i); MathF.CombineHashCode(ref hash, tileHash); } return(hash); }
/// <summary> /// Determines the <see cref="Compile"/>-relevant hash code of the specified <see cref="Tileset"/>. /// This value is used internally to determine whether a <see cref="Tileset"/> needs to be recompiled. /// </summary> public int GetCompileHashCode() { int hash = 17; if (this.baseMaterial != null) { MathF.CombineHashCode(ref hash, this.baseMaterial.GetHashCode()); } MathF.CombineHashCode(ref hash, this.tileSize.GetHashCode()); foreach (TilesetRenderInput input in this.renderConfig) { MathF.CombineHashCode(ref hash, input.Id.GetHashCode()); MathF.CombineHashCode(ref hash, input.Name.GetHashCode()); MathF.CombineHashCode(ref hash, input.SourceData.GetHashCode()); MathF.CombineHashCode(ref hash, input.SourceTileSize.GetHashCode()); MathF.CombineHashCode(ref hash, input.SourceTileSpacing.GetHashCode()); MathF.CombineHashCode(ref hash, input.TargetFormat.GetHashCode()); MathF.CombineHashCode(ref hash, input.TargetMagFilter.GetHashCode()); MathF.CombineHashCode(ref hash, input.TargetMinFilter.GetHashCode()); MathF.CombineHashCode(ref hash, input.TargetTileMargin.GetHashCode()); } foreach (TilesetAutoTileInput autoTile in this.autoTileConfig) { MathF.CombineHashCode(ref hash, autoTile.BaseTileIndex); MathF.CombineHashCode(ref hash, GetTileArrayCompileHash(autoTile.TileInput.Data, autoTile.TileInput.Count)); } { MathF.CombineHashCode(ref hash, GetTileArrayCompileHash(this.tileInput.Data, this.tileInput.Count)); } return(hash); }
public override int GetHashCode() { return(MathF.CombineHashCode( this.IntField.GetHashCode(), this.FloatField.GetHashCode())); }
public override int GetHashCode() { return(MathF.CombineHashCode(this.MinValue.GetHashCode(), this.MaxValue.GetHashCode())); }