void ApplyAlteration(ref NodeAlteration alteration) { int xLen = alteration.alterations.GetLength(0); int yLen = alteration.alterations.GetLength(1); for (int y = 0; y < yLen; y++) { for (int x = 0; x < xLen; x++) { bool alterAtPos = alteration.alterations[x, y]; if (alterAtPos) { Vector2Int pos = alteration.topLeftNodePos + new Vector2Int(x, y); if (IsNodeInMap(pos)) { //data.nodes[pos.x, pos.y] = alteration.subtract ? !alterAtPos : alterAtPos; AlterNode(pos, alteration.subtract ? !alterAtPos : alterAtPos); } } } } int startX = alteration.topLeftNodePos.x - 1; int startY = alteration.topLeftNodePos.y - 1; int endX = startX + xLen + 2; int endY = startY + yLen + 2; RecalculateChunksInAlteration(startX, endX, startY, endY); }
public void AlterNodes(ref NodeAlteration alteration) { ApplyAlteration(ref alteration); }