public void StartGeneration() { if (running) { return; } if (started) { StopGeneration(); } tileOutput?.ClearTiles(); var generator = GetComponent <TesseraGenerator>(); helper = generator.CreateTesseraGeneratorHelper(); helper.Setup(); // TODO: Should be *all tiles* to start with lastTiles = helper.Propagator.ToValueSets <ModelTile>(); lastStepTime = GetTime(); tileOutput = generator.GetComponent <ITesseraTileOutput>() ?? new UpdatableInstantiateOutput(transform); if (!tileOutput.SupportsIncremental) { throw new Exception($"Output {tileOutput} does not support animations"); } supportsCubes = generator.GetComponent <ITesseraTileOutput>() == null; hasObject = new bool[helper.Propagator.Topology.IndexCount]; cubesByIndex = new GameObject[helper.Propagator.Topology.IndexCount]; started = true; ResumeGeneration(); }
private void HandleComplete(TesseraGenerateOptions options, TesseraCompletion completion) { if (!completion.success) { if (completion.contradictionLocation != null) { var loc = completion.contradictionLocation; Debug.LogError($"Failed to complete generation, issue at tile {loc}"); } else { Debug.LogError("Failed to complete generation"); } return; } ITesseraTileOutput to = null; if (options.onCreate != null) { to = new ForEachOutput(options.onCreate); } else { to = GetComponent <ITesseraTileOutput>() ?? new InstantiateOutput(transform); } to.UpdateTiles(completion.tileInstances); }
public void StopGeneration() { if (!started) { return; } PauseGeneration(); tileOutput?.ClearTiles(); tileOutput = null; if (helper != null) { foreach (var i in helper.Propagator.Topology.GetIndices()) { ClearCube(i); } } started = false; }
public RegisterUndo(UnityEngine.Object go, ITesseraTileOutput underlying) { this.go = go; this.underlying = underlying; }