Small polish commit: - Clamp ClearColor inputs to [0, 1] because retail keyframes store sun/fog colors pre-multiplied by their brightness scalars, which can exceed 1.0; some drivers treat ClearColor > 1 as a saturate-bright hint and produce visible color shifts at the edges. - 4 new tests cover WorldTimeService.SetDebugTime / ClearDebugTime / SyncFromServer-clears-override / SetProvider hot-swap. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using System;
|
|
using AcDream.Core.World;
|
|
using Xunit;
|
|
|
|
namespace AcDream.Core.Tests.World;
|
|
|
|
public sealed class WorldTimeDebugTests
|
|
{
|
|
[Fact]
|
|
public void SetDebugTime_OverridesDayFraction()
|
|
{
|
|
var service = new WorldTimeService(SkyStateProvider.Default());
|
|
service.SyncFromServer(0); // midnight
|
|
|
|
service.SetDebugTime(0.5f); // force noon
|
|
Assert.InRange(service.DayFraction, 0.499, 0.501);
|
|
}
|
|
|
|
[Fact]
|
|
public void ClearDebugTime_RestoresServerTime()
|
|
{
|
|
var service = new WorldTimeService(SkyStateProvider.Default());
|
|
service.SyncFromServer(DerethDateTime.DayTicks * 0.25); // dawn
|
|
service.SetDebugTime(0.5f);
|
|
service.ClearDebugTime();
|
|
|
|
Assert.InRange(service.DayFraction, 0.24, 0.26);
|
|
}
|
|
|
|
[Fact]
|
|
public void SyncFromServer_ClearsDebugOverride()
|
|
{
|
|
var service = new WorldTimeService(SkyStateProvider.Default());
|
|
service.SetDebugTime(0.75f);
|
|
service.SyncFromServer(0); // midnight — this should clear the override
|
|
|
|
Assert.InRange(service.DayFraction, 0.0, 0.01);
|
|
}
|
|
|
|
[Fact]
|
|
public void SetProvider_AcceptsNewKeyframes()
|
|
{
|
|
var service = new WorldTimeService(SkyStateProvider.Default());
|
|
var custom = new SkyStateProvider(new[]
|
|
{
|
|
new SkyKeyframe(
|
|
Begin: 0f,
|
|
SunHeadingDeg: 0f,
|
|
SunPitchDeg: 90f,
|
|
SunColor: System.Numerics.Vector3.One,
|
|
AmbientColor: System.Numerics.Vector3.One,
|
|
FogColor: System.Numerics.Vector3.Zero,
|
|
FogDensity: 0f),
|
|
});
|
|
service.SetProvider(custom);
|
|
Assert.Equal(1, custom.KeyframeCount);
|
|
}
|
|
}
|