Skip to content

Commit

Permalink
Made CellularAutomaton.Config into a struct
Browse files Browse the repository at this point in the history
  • Loading branch information
BasmanovDaniil committed Jan 9, 2021
1 parent 55873c8 commit fc073d5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
21 changes: 15 additions & 6 deletions Runtime/CellularAutomaton/CellularAutomaton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,22 @@ namespace ProceduralToolkit.CellularAutomata
public class CellularAutomaton
{
[Serializable]
public class Config
public struct Config
{
public int width = 128;
public int height = 128;
public Ruleset ruleset = Ruleset.life;
public float startNoise = 0.25f;
public bool aliveBorders = false;
public int width;
public int height;
public Ruleset ruleset;
public float startNoise;
public bool aliveBorders;

public static Config life = new Config
{
width = 128,
height = 128,
ruleset = Ruleset.life,
startNoise = 0.25f,
aliveBorders = false,
};
}

private bool[,] _cells;
Expand Down
6 changes: 3 additions & 3 deletions Samples/CellularAutomata/CellularAutomatonExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CellularAutomatonExample : ConfiguratorBase
public ToggleGroup toggleGroup;
public RawImage image;
[Space]
public CellularAutomaton.Config config = new CellularAutomaton.Config();
public CellularAutomaton.Config config = CellularAutomaton.Config.life;

private enum RulesetName
{
Expand Down Expand Up @@ -117,11 +117,11 @@ private void DrawCells()
{
if (automaton.cells[x, y])
{
pixels[y*config.width + x] = aliveColor;
pixels.SetXY(x, y, config.width, aliveColor);
}
else
{
pixels[y*config.width + x] = deadColor;
pixels.SetXY(x, y, config.width, deadColor);
}
}
}
Expand Down

0 comments on commit fc073d5

Please sign in to comment.