public LogicState RunLogicStep(LogicState state) { Logger.Write($"Turn number {state.TurnNumber}"); if (!state.IsInitialized) { var random = new Random(123); state.Map = new Map2D <int>(500, 500); for (var y = 0; y < state.Map.Height; y++) { for (var x = 0; x < state.Map.Width; x++) { state.Map[x, y] = random.Next(1, 4); } } state.IsInitialized = true; } state.TurnNumber++; Commands.Wait(); return(state); }
public void Draw(LogicState state, DrawingWindowState drawingWindowState) { _stopwatch.Restart(); using (Bitmap.GetBitmapContext()) { Bitmap.Clear(); var renderer = new MapRenderer(16, 16); renderer.Render(state.Map, Bitmap, ImageProvider, drawingWindowState); } var elapsed = _stopwatch.ElapsedMilliseconds; if (elapsed > 150) { Logger.Write($"Drawing takes {elapsed}ms! Consider disabling it!"); } }
public void UpdateGraph(LogicState state) { }
public static void Save(LogicState state, string serverName) { var json = state.ToJson(); File.WriteAllText($@"logic-{serverName}.json", json); }