-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/master' into batching
# Conflicts: # Hypercube.Example.Client/Example.cs
- Loading branch information
Showing
44 changed files
with
534 additions
and
109 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,13 @@ | ||
using Hypercube.Client.Runtimes; | ||
using Hypercube.Shared; | ||
using Hypercube.Shared.Dependency; | ||
using Hypercube.Shared.Entities.Realisation.Systems; | ||
using Hypercube.Shared.Utilities.ArgumentsParser; | ||
|
||
namespace Hypercube.Client; | ||
|
||
public static class EntryPoint | ||
public sealed class EntryPoint : SharedEntryPoint | ||
{ | ||
/// <summary> | ||
/// The entry point to the engine, starts it in the current thread, | ||
/// once started, the thread will be frozen by the execution of the loop, | ||
/// until the engine is shut down. | ||
/// </summary> | ||
/// <param name="args"> | ||
/// Input arguments to the engine. | ||
/// </param> | ||
/// <param name="callback"> | ||
/// Callback that will be called after the current <see cref="DependencyManager"/> thread is initialized, | ||
/// allowing its dependencies to be used, but before entering the game loop. | ||
/// This is the only way to get into the engine, | ||
/// not through the <see cref="IEntitySystem"/>. | ||
/// </param> | ||
public static void Enter(string[] args, Action<string[], DependenciesContainer>? callback = null) | ||
protected override void Enter(ArgumentParser parser, DependenciesContainer rootContainer) | ||
{ | ||
var parser = new ArgumentParser(args); | ||
parser.TryParse(); | ||
|
||
var rootContainer = DependencyManager.InitThread(); | ||
Dependencies.Register(rootContainer); | ||
|
||
callback?.Invoke(args, rootContainer); | ||
|
||
var runtime = rootContainer.Resolve<IRuntime>(); | ||
runtime.Run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Hypercube.Example/Camera/CameraComponent.cs → ....Example.Client/Camera/CameraComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ube.Example/Controls/ControlsComponent.cs → ...mple.Client/Controls/ControlsComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
using Hypercube.Shared.Entities.Realisation.Components; | ||
|
||
namespace Hypercube.Example.Controls; | ||
namespace Hypercube.Example.Client.Controls; | ||
|
||
public sealed class ControlsComponent : Component | ||
{ | ||
public float Speed = 10; | ||
public float Speed = 60; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
Hypercube.Example/ExampleComponent.cs → Hypercube.Example.Client/ExampleComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Hypercube.Shared.EventBus; | ||
|
||
namespace Hypercube.Example.Client; | ||
|
||
internal class Program : IEventSubscriber | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var example = new Example(); | ||
var entry = new Hypercube.Client.EntryPoint(); | ||
entry.Enter(args, example.Start); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Hypercube.Server\Hypercube.Server.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Hypercube.Shared.EventBus; | ||
|
||
namespace Hypercube.Example.Server; | ||
|
||
internal class Program : IEventSubscriber | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var entry = new Hypercube.Server.EntryPoint(); | ||
entry.Enter(args); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Hypercube.Server.Runtimes; | ||
using Hypercube.Server.Runtimes.Loop; | ||
using Hypercube.Shared; | ||
using Hypercube.Shared.Dependency; | ||
using Hypercube.Shared.Runtimes; | ||
using Hypercube.Shared.Runtimes.Loop; | ||
|
||
namespace Hypercube.Server; | ||
|
||
/// <summary> | ||
/// Provide all server hypercube dependencies for registration. | ||
/// </summary> | ||
public static class Dependencies | ||
{ | ||
public static void Register(DependenciesContainer rootContainer) | ||
{ | ||
SharedDependencies.Register(rootContainer); | ||
|
||
// Runtime | ||
rootContainer.Register<IRuntimeLoop, RuntimeLoop>(); | ||
rootContainer.Register<IRuntime, Runtime>(); | ||
|
||
rootContainer.InstantiateAll(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Hypercube.Shared; | ||
using Hypercube.Shared.Dependency; | ||
using Hypercube.Shared.Utilities.ArgumentsParser; | ||
|
||
namespace Hypercube.Server; | ||
|
||
public sealed class EntryPoint : SharedEntryPoint | ||
{ | ||
protected override void Enter(ArgumentParser parser, DependenciesContainer rootContainer) | ||
{ | ||
Dependencies.Register(rootContainer); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Hypercube.Shared\Hypercube.Shared.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using Hypercube.Shared.Dependency; | ||
using Hypercube.Shared.EventBus; | ||
using Hypercube.Shared.Runtimes.Loop; | ||
using Hypercube.Shared.Runtimes.Loop.Event; | ||
using Hypercube.Shared.Timing; | ||
|
||
namespace Hypercube.Server.Runtimes.Loop; | ||
|
||
public class RuntimeLoop : IRuntimeLoop | ||
{ | ||
[Dependency] private readonly ITiming _timing = default!; | ||
[Dependency] private readonly IEventBus _eventBus = default!; | ||
|
||
public bool Running { get; private set; } | ||
|
||
public void Run() | ||
{ | ||
if (Running) | ||
throw new InvalidOperationException(); | ||
|
||
Running = true; | ||
while (Running) | ||
{ | ||
_timing.StartFrame(); | ||
|
||
var deltaTime = (float)_timing.RealFrameTime.TotalSeconds; | ||
|
||
_eventBus.Raise(new TickFrameEvent(deltaTime)); | ||
_eventBus.Raise(new UpdateFrameEvent(deltaTime)); | ||
} | ||
} | ||
|
||
public void Shutdown() | ||
{ | ||
Running = false; | ||
} | ||
} |
Oops, something went wrong.