refactor(runtime): extract the live object frame
This commit is contained in:
parent
99a3e819c4
commit
4e4aac2c5a
27 changed files with 1217 additions and 371 deletions
|
|
@ -0,0 +1,84 @@
|
|||
using AcDream.App.Rendering.Vfx;
|
||||
using AcDream.App.Update;
|
||||
using AcDream.UI.Abstractions.Input;
|
||||
using AcDream.UI.Abstractions.Panels.Settings;
|
||||
using Silk.NET.Input;
|
||||
|
||||
namespace AcDream.App.Tests.World;
|
||||
|
||||
public sealed class LiveObjectFrameControllerTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(ParticleRange.Retail, 1f)]
|
||||
[InlineData(
|
||||
ParticleRange.Extended,
|
||||
ParticleVisibilityController.ExtendedRangeMultiplier)]
|
||||
public void ParticleRange_NullSettingsUsesConfiguredFallback(
|
||||
ParticleRange fallback,
|
||||
float expected)
|
||||
{
|
||||
var source = new SettingsParticleRangeSource(null, fallback);
|
||||
|
||||
Assert.Equal(expected, source.RangeMultiplier);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ParticleRange_LiveSettingsDraftOverridesFallbackAndUpdatesImmediately()
|
||||
{
|
||||
SettingsVM settings = CreateSettings();
|
||||
var source = new SettingsParticleRangeSource(settings, ParticleRange.Retail);
|
||||
|
||||
settings.SetDisplay(settings.DisplayDraft with { ParticleRange = ParticleRange.Retail });
|
||||
Assert.Equal(1f, source.RangeMultiplier);
|
||||
|
||||
settings.SetDisplay(settings.DisplayDraft with { ParticleRange = ParticleRange.Extended });
|
||||
Assert.Equal(
|
||||
ParticleVisibilityController.ExtendedRangeMultiplier,
|
||||
source.RangeMultiplier);
|
||||
}
|
||||
|
||||
private static SettingsVM CreateSettings()
|
||||
{
|
||||
var dispatcher = new InputDispatcher(
|
||||
new NullKeyboardSource(),
|
||||
new NullMouseSource(),
|
||||
new KeyBindings());
|
||||
return new SettingsVM(
|
||||
new KeyBindings(),
|
||||
dispatcher,
|
||||
static _ => { },
|
||||
DisplaySettings.Default,
|
||||
static _ => { },
|
||||
AudioSettings.Default,
|
||||
static _ => { },
|
||||
GameplaySettings.Default,
|
||||
static _ => { },
|
||||
ChatSettings.Default,
|
||||
static _ => { },
|
||||
CharacterSettings.Default,
|
||||
static _ => { });
|
||||
}
|
||||
|
||||
private sealed class NullKeyboardSource : IKeyboardSource
|
||||
{
|
||||
#pragma warning disable CS0067
|
||||
public event Action<Key, ModifierMask>? KeyDown;
|
||||
public event Action<Key, ModifierMask>? KeyUp;
|
||||
#pragma warning restore CS0067
|
||||
public bool IsHeld(Key key) => false;
|
||||
public ModifierMask CurrentModifiers => ModifierMask.None;
|
||||
}
|
||||
|
||||
private sealed class NullMouseSource : IMouseSource
|
||||
{
|
||||
#pragma warning disable CS0067
|
||||
public event Action<MouseButton, ModifierMask>? MouseDown;
|
||||
public event Action<MouseButton, ModifierMask>? MouseUp;
|
||||
public event Action<float, float>? MouseMove;
|
||||
public event Action<float>? Scroll;
|
||||
#pragma warning restore CS0067
|
||||
public bool IsHeld(MouseButton button) => false;
|
||||
public bool WantCaptureMouse => false;
|
||||
public bool WantCaptureKeyboard => false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue