Il progetto adotta il nome «Rail Enterprise» ovunque (codice RailEnterprise.*, variabili RE_*, intestazioni RESV/RECL, immagine rail-enterprise-server) per allinearsi al repository Gitea. Aggiunge Gitea Actions sul modello di Chronos: CI su PR e main, rilascio da tag con gioco Windows (client Godot + server in server/), server Windows/Linux e immagine Docker nel registro Gitea, nightly. Aggiunge i riferimenti visivi 06–09, i modelli di PR e issue, l'ADR 0014 e aggiorna README (comandi locali), STATE e CLAUDE.md. 120 test verdi. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
2.0 KiB
C#
45 lines
2.0 KiB
C#
using RailEnterprise.Core.Map;
|
|
|
|
namespace RailEnterprise.Tests.Rail;
|
|
|
|
/// <summary>Terreni costruiti a mano per i test del pianificatore (celle da 100 m).</summary>
|
|
public static class SyntheticTerrain
|
|
{
|
|
public static Terrain Build(int width, int height, Func<double, double, double> heightAtMeters, Func<int, int, CellType>? type = null)
|
|
{
|
|
var t = new Terrain(width, height, 100, 64);
|
|
for (int y = 0; y < height; y++)
|
|
{
|
|
for (int x = 0; x < width; x++)
|
|
{
|
|
double hx = (x + 0.5) * 100, hy = (y + 0.5) * 100;
|
|
t.Heights[t.Index(x, y)] = Terrain.ToDecimeters(heightAtMeters(hx, hy));
|
|
t.Types[t.Index(x, y)] = (byte)(type?.Invoke(x, y) ?? CellType.Plain);
|
|
}
|
|
}
|
|
return t;
|
|
}
|
|
|
|
public static Terrain Flat(int size = 60, double h = 100) => Build(size, size, (_, _) => h);
|
|
|
|
/// <summary>Collina a cupola centrata in (cx, cy) metri.</summary>
|
|
public static Func<double, double, double> Hill(double cx, double cy, double radiusM, double heightM, double baseM = 100) =>
|
|
(x, y) =>
|
|
{
|
|
double r = Math.Sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / radiusM;
|
|
return baseM + (r >= 1 ? 0 : heightM * (1 - r * r) * (1 - r * r));
|
|
};
|
|
|
|
/// <summary>Pianura con un fiume nord-sud largo «widthCells» celle intorno a x = riverX metri.</summary>
|
|
public static Terrain River(int size, double riverXm, int widthCells, double baseM = 100, double waterM = 96)
|
|
{
|
|
int x0 = (int)(riverXm / 100) - widthCells / 2;
|
|
var t = Build(size, size, (x, _) => (int)(x / 100) >= x0 && (int)(x / 100) < x0 + widthCells ? waterM : baseM,
|
|
(x, _) => x >= x0 && x < x0 + widthCells ? CellType.Water : CellType.Plain);
|
|
for (int y = 0; y < size; y++)
|
|
for (int x = x0; x < x0 + widthCells; x++)
|
|
t.RiverWidth[t.Index(x, y)] = (byte)Math.Min(4, widthCells);
|
|
return t;
|
|
}
|
|
}
|