-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a server. SharedDependencies. SharedEntry. EntryPoint replaced with a Program #36
Merged
Tornado-Technology
merged 4 commits into
technologists-team:master
from
noverd:server_client_start
Jul 30, 2024
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion
2
...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
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kekw