Add live runtime assembly reload
This commit is contained in:
parent
4c6cb24f4c
commit
d594e0803b
18 changed files with 375 additions and 31 deletions
|
|
@ -0,0 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
6
src/Aquarium.Engine.Contracts/AquariumFrame.cs
Normal file
6
src/Aquarium.Engine.Contracts/AquariumFrame.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
using System.Numerics;
|
||||
|
||||
namespace Aquarium.Engine;
|
||||
|
||||
public readonly record struct AquariumFrame(GridFrame Grid, Vector3 CameraPosition, float TimeSeconds);
|
||||
|
||||
22
src/Aquarium.Engine.Contracts/AquariumRuntimeContracts.cs
Normal file
22
src/Aquarium.Engine.Contracts/AquariumRuntimeContracts.cs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
using Aquarium.Engine.Input;
|
||||
|
||||
namespace Aquarium.Engine;
|
||||
|
||||
public interface IAquariumRuntime : IDisposable
|
||||
{
|
||||
AquariumRuntimeOptions Options { get; }
|
||||
|
||||
AquariumFrame Frame { get; }
|
||||
|
||||
void Start();
|
||||
|
||||
void Update(float deltaSeconds, InputState input);
|
||||
}
|
||||
|
||||
public interface IAquariumRuntimeFactory
|
||||
{
|
||||
IAquariumRuntime Create(AquariumRuntimeOptions options);
|
||||
}
|
||||
|
||||
public readonly record struct AquariumRuntimeOptions(bool Headless, string? CultCachePath);
|
||||
|
||||
76
src/Aquarium.Engine.Contracts/Input/InputState.cs
Normal file
76
src/Aquarium.Engine.Contracts/Input/InputState.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
using System.Numerics;
|
||||
|
||||
namespace Aquarium.Engine.Input;
|
||||
|
||||
public sealed class InputState
|
||||
{
|
||||
private readonly HashSet<KeyCode> downKeys = [];
|
||||
|
||||
public Vector2 MousePosition { get; private set; }
|
||||
|
||||
public Vector2 MouseDelta { get; private set; }
|
||||
|
||||
public float WheelDelta { get; private set; }
|
||||
|
||||
public bool MiddleMouseDown { get; private set; }
|
||||
|
||||
public bool RightMouseDown { get; private set; }
|
||||
|
||||
public bool IsKeyDown(KeyCode key) => downKeys.Contains(key);
|
||||
|
||||
public void BeginFrame()
|
||||
{
|
||||
MouseDelta = Vector2.Zero;
|
||||
WheelDelta = 0.0f;
|
||||
}
|
||||
|
||||
public void SetMousePosition(Vector2 position)
|
||||
{
|
||||
MouseDelta += position - MousePosition;
|
||||
MousePosition = position;
|
||||
}
|
||||
|
||||
public void AddWheelDelta(float delta)
|
||||
{
|
||||
WheelDelta += delta;
|
||||
}
|
||||
|
||||
public void SetMouseButton(MouseButton button, bool isDown)
|
||||
{
|
||||
switch (button)
|
||||
{
|
||||
case MouseButton.Middle:
|
||||
MiddleMouseDown = isDown;
|
||||
break;
|
||||
case MouseButton.Right:
|
||||
RightMouseDown = isDown;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetKey(KeyCode key, bool isDown)
|
||||
{
|
||||
if (isDown)
|
||||
{
|
||||
downKeys.Add(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
downKeys.Remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum MouseButton
|
||||
{
|
||||
Middle,
|
||||
Right,
|
||||
}
|
||||
|
||||
public enum KeyCode
|
||||
{
|
||||
W,
|
||||
A,
|
||||
S,
|
||||
D,
|
||||
}
|
||||
11
src/Aquarium.Engine.Contracts/World/GridFrame.cs
Normal file
11
src/Aquarium.Engine.Contracts/World/GridFrame.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using System.Numerics;
|
||||
|
||||
namespace Aquarium.Engine;
|
||||
|
||||
public readonly record struct GridFrame(Vector2 Center, float Radius)
|
||||
{
|
||||
public static GridFrame FromCamera(Vector2 target, float distance)
|
||||
{
|
||||
return new GridFrame(target, distance);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue