public void SetGasMixture(int x, int y, GasMixture gm) { Vector2 vec = new Vector2(x, y); allGasMixtures.AddOrUpdate(vec, gm); }
public void CalculateNeighbours(GasMixture gm, int in_x = -1, int in_y = 1) { int x = -1; int y = -1; if (in_x >= 0) { x = in_x; if (in_y >= 0) { y = in_y; } } else { Vector2 vec = GetLocationForMixture(gm); x = (int)vec.X; y = (int)vec.Y; } if(gm != null ) { gm.NorthNeighbour = null; gm.SouthNeighbour = null; gm.EastNeighbour = null; gm.WestNeighbour = null; if (!relatedFloor.IsWallAt(x, y)) { GasMixture north = GetMixtureAt(x, y - 1); if (north != null && !relatedFloor.IsWallAt(x, y - 1)) { //north.SouthNeighbour = gm; gm.NorthNeighbour = north; gm.RecountNeighbours = true; north.RecountNeighbours = true; } GasMixture south = GetMixtureAt(x, y + 1); if (south != null && !relatedFloor.IsWallAt(x, y + 1)) { //south.NorthNeighbour = gm; gm.SouthNeighbour = south; gm.RecountNeighbours = true; south.RecountNeighbours = true; } GasMixture east = GetMixtureAt(x + 1, y); if (east != null && !relatedFloor.IsWallAt(x + 1, y)) { //east.WestNeighbour = gm; gm.EastNeighbour = east; gm.RecountNeighbours = true; east.RecountNeighbours = true; } GasMixture west = GetMixtureAt(x - 1, y); if (west != null && !relatedFloor.IsWallAt(x - 1, y)) { //west.EastNeighbour = gm; gm.WestNeighbour = west; gm.RecountNeighbours = true; west.RecountNeighbours = true; } } } }
public Vector2 GetLocationForMixture(GasMixture gm) { Vector2 outvec = new Vector2(-1, -1); foreach(var kvp in allGasMixtures) { if(kvp.Value == gm) { return kvp.Key; } } return outvec; }