Climate (Core) layers a continuous seasonal-plus-daily temperature and the current season over the Calendar, registered via context.UseClimate. A new Lighting module (Graphics) adds DayNight: a daylight factor and ambient color from the calendar's time of day, pushed into the renderer's new AmbientLight (multiplied into world-space sprites only, so the scene darkens at night while screen-space overlays stay readable) and exposed as a sampleable SampleAt for the simulation. Both deterministic and GPU-free, covered by tests; docs updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
f39ee9e787
commit
a684c23cd9
@@ -0,0 +1,54 @@
|
||||
using MrGameEng.Core;
|
||||
using MrGameEng.Lighting;
|
||||
using Xunit;
|
||||
|
||||
namespace MrGameEng.Lighting.Tests;
|
||||
|
||||
public class DayNightTests
|
||||
{
|
||||
private static (GameClock Clock, DayNight DayNight) Make()
|
||||
{
|
||||
var clock = new GameClock();
|
||||
var calendar = new Calendar(clock, secondsPerDay: 24f); // 1 second = 1 in-game hour
|
||||
return (clock, new DayNight(calendar, DayNightSettings.Default));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Daylight_ZeroAtMidnight_OneAtNoon()
|
||||
{
|
||||
var (clock, dayNight) = Make();
|
||||
|
||||
Assert.Equal(0f, dayNight.Daylight, 3); // 00:00
|
||||
|
||||
clock.Advance(12f); // 12:00
|
||||
Assert.Equal(1f, dayNight.Daylight, 3);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Daylight_RisesFromDawnToNoon()
|
||||
{
|
||||
var (clock, dayNight) = Make();
|
||||
|
||||
clock.Advance(6f); // 06:00
|
||||
var dawn = dayNight.Daylight;
|
||||
clock.Advance(3f); // 09:00
|
||||
var mid = dayNight.Daylight;
|
||||
clock.Advance(3f); // 12:00
|
||||
var noon = dayNight.Daylight;
|
||||
|
||||
Assert.True(dawn < mid && mid < noon, "daylight should rise from dawn to noon");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Ambient_DarkerAtNightThanAtNoon()
|
||||
{
|
||||
var (clock, dayNight) = Make();
|
||||
|
||||
var night = dayNight.Ambient; // 00:00
|
||||
clock.Advance(12f); // 12:00
|
||||
var noon = dayNight.Ambient;
|
||||
|
||||
Assert.True(night.R < noon.R && night.G < noon.G && night.B < noon.B);
|
||||
Assert.Equal(255, noon.R); // day color is white at noon
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user