-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5f9b15
commit a6261b4
Showing
221 changed files
with
4,823 additions
and
647 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -29,8 +29,4 @@ | |
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="Components\Core\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
32 changes: 32 additions & 0 deletions
32
FinalEngine.Editor.Common/Extensions/ServiceCollectionExtensions.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// <copyright file="ServiceCollectionExtensions.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.Common.Extensions; | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using FinalEngine.Editor.Common.Services.Factories; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
[ExcludeFromCodeCoverage(Justification = "Extensions")] | ||
public static class ServiceCollectionExtensions | ||
{ | ||
public static void AddFactory<TService, TImplementation>(this IServiceCollection services) | ||
where TService : class | ||
where TImplementation : class, TService | ||
{ | ||
ArgumentNullException.ThrowIfNull(services, nameof(services)); | ||
|
||
services.AddTransient<TService, TImplementation>(); | ||
services.AddSingleton<Func<TService>>(x => | ||
{ | ||
return () => | ||
{ | ||
return x.GetRequiredService<TService>(); | ||
}; | ||
}); | ||
|
||
services.AddSingleton<IFactory<TService>, Factory<TService>>(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
FinalEngine.Editor.Common/FinalEngine.Editor.Common.csproj
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,40 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<AnalysisMode>All</AnalysisMode> | ||
<NoWarn>SA0001</NoWarn> | ||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> | ||
<Platforms>x64</Platforms> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<AdditionalFiles Include="..\Styling\StyleCop\Other\stylecop.json" Link="stylecop.json" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\GlobalSuppressions.cs" Link="GlobalSuppressions.cs" /> | ||
<Compile Include="..\SharedAssemblyInfo.cs" Link="Properties\SharedAssemblyInfo.cs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" /> | ||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="System.IO.Abstractions" Version="20.0.4" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\FinalEngine.ECS\FinalEngine.ECS.csproj" /> | ||
<ProjectReference Include="..\FinalEngine.Rendering.Components\FinalEngine.Rendering.Components.csproj" /> | ||
<ProjectReference Include="..\FinalEngine.Rendering\FinalEngine.Rendering.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,20 @@ | ||
// <copyright file="IScene.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.Common.Models.Scenes; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using FinalEngine.ECS; | ||
|
||
public interface IScene | ||
{ | ||
IReadOnlyCollection<Entity> Entities { get; } | ||
|
||
void AddEntity(string tag, Guid uniqueID); | ||
|
||
void RemoveEntity(Guid uniqueIdentifier); | ||
|
||
void Render(); | ||
} |
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,83 @@ | ||
// <copyright file="Scene.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.Common.Models.Scenes; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using FinalEngine.ECS; | ||
using FinalEngine.ECS.Components.Core; | ||
using FinalEngine.ECS.Exceptions; | ||
using FinalEngine.Rendering.Components.Core; | ||
using Microsoft.Extensions.Logging; | ||
|
||
public sealed class Scene : IScene | ||
{ | ||
private readonly ObservableCollection<Entity> entities; | ||
|
||
private readonly ILogger<Scene> logger; | ||
|
||
private readonly IEntityWorld world; | ||
|
||
public Scene(ILogger<Scene> logger, IEntityWorld world) | ||
{ | ||
this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); | ||
this.world = world ?? throw new ArgumentNullException(nameof(world)); | ||
this.entities = []; | ||
} | ||
|
||
public IReadOnlyCollection<Entity> Entities | ||
{ | ||
get { return this.entities; } | ||
} | ||
|
||
public void AddEntity(string tag, Guid uniqueID) | ||
{ | ||
this.logger.LogInformation($"Adding new {nameof(Entity)} to {nameof(Scene)} with ID: '{uniqueID}'."); | ||
|
||
ArgumentException.ThrowIfNullOrWhiteSpace(tag, nameof(tag)); | ||
|
||
var entity = new Entity(uniqueID); | ||
|
||
entity.AddComponent(new TagComponent() | ||
{ | ||
Name = tag, | ||
}); | ||
|
||
entity.AddComponent(new TransformComponent()); | ||
|
||
this.world.AddEntity(entity); | ||
this.entities.Add(entity); | ||
|
||
this.logger.LogInformation($"Added {nameof(Entity)} to {nameof(Scene)} with ID: '{uniqueID}'."); | ||
} | ||
|
||
public void RemoveEntity(Guid uniqueIdentifier) | ||
{ | ||
this.logger.LogInformation($"Removing {nameof(Entity)} from {nameof(Scene)} with ID: '{uniqueIdentifier}'."); | ||
|
||
var entity = this.entities.FirstOrDefault(x => | ||
{ | ||
return x.UniqueIdentifier == uniqueIdentifier; | ||
}); | ||
|
||
if (entity == null) | ||
{ | ||
this.logger.LogError($"Failed to locate entity with ID: '{uniqueIdentifier}'."); | ||
throw new EntityNotFoundException(uniqueIdentifier); | ||
} | ||
|
||
this.world.RemoveEntity(entity); | ||
this.entities.Remove(entity); | ||
|
||
this.logger.LogInformation($"Removed {nameof(Entity)} from {nameof(Scene)} with ID: '{uniqueIdentifier}'."); | ||
} | ||
|
||
public void Render() | ||
{ | ||
this.world.ProcessAll(GameLoopType.Render); | ||
} | ||
} |
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 @@ | ||
// <copyright file="AssemblyInfo.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
using System; | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
|
||
[assembly: CLSCompliant(true)] | ||
[assembly: ComVisible(false)] | ||
[assembly: AssemblyTitle("FinalEngine.Editor.Common")] | ||
[assembly: AssemblyDescription("A common library containing services to connect view models to view for the Final Engine editor.")] | ||
[assembly: Guid("3D606010-8CAF-4781-98D1-EB67BCDD8CC1")] |
48 changes: 48 additions & 0 deletions
48
FinalEngine.Editor.Common/Services/Application/ApplicationContext.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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// <copyright file="ApplicationContext.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.Common.Services.Application; | ||
|
||
using System; | ||
using System.IO.Abstractions; | ||
using System.Reflection; | ||
using FinalEngine.Editor.Common.Services.Environment; | ||
|
||
public sealed class ApplicationContext : IApplicationContext | ||
{ | ||
private readonly IEnvironmentContext environment; | ||
|
||
private readonly IFileSystem fileSystem; | ||
|
||
public ApplicationContext(IFileSystem fileSystem, IEnvironmentContext environment) | ||
{ | ||
this.fileSystem = fileSystem ?? throw new ArgumentNullException(nameof(fileSystem)); | ||
this.environment = environment ?? throw new ArgumentNullException(nameof(environment)); | ||
} | ||
|
||
public string DataDirectory | ||
{ | ||
get | ||
{ | ||
string directory = this.fileSystem.Path.Combine(this.environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Final Engine"); | ||
|
||
if (!this.fileSystem.Directory.Exists(directory)) | ||
{ | ||
this.fileSystem.Directory.CreateDirectory(directory); | ||
} | ||
|
||
return directory; | ||
} | ||
} | ||
|
||
public string Title | ||
{ | ||
get { return $"Final Engine - {this.Version}"; } | ||
} | ||
|
||
public Version Version | ||
{ | ||
get { return Assembly.GetExecutingAssembly().GetName().Version!; } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
FinalEngine.Editor.Common/Services/Application/IApplicationContext.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// <copyright file="IApplicationContext.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.Common.Services.Application; | ||
|
||
using System; | ||
|
||
public interface IApplicationContext | ||
{ | ||
string DataDirectory { get; } | ||
|
||
string Title { get; } | ||
|
||
Version Version { get; } | ||
} |
17 changes: 17 additions & 0 deletions
17
FinalEngine.Editor.Common/Services/Environment/EnvironmentContext.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// <copyright file="EnvironmentContext.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.Common.Services.Environment; | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
[ExcludeFromCodeCoverage(Justification = "Invocation")] | ||
public sealed class EnvironmentContext : IEnvironmentContext | ||
{ | ||
public string GetFolderPath(Environment.SpecialFolder folder) | ||
{ | ||
return Environment.GetFolderPath(folder); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
FinalEngine.Editor.Common/Services/Environment/IEnvironmentContext.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// <copyright file="IEnvironmentContext.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.Common.Services.Environment; | ||
|
||
using System; | ||
|
||
public interface IEnvironmentContext | ||
{ | ||
string GetFolderPath(Environment.SpecialFolder folder); | ||
} |
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,22 @@ | ||
// <copyright file="Factory.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.Common.Services.Factories; | ||
|
||
using System; | ||
|
||
public sealed class Factory<T> : IFactory<T> | ||
{ | ||
private readonly Func<T> factory; | ||
|
||
public Factory(Func<T> factory) | ||
{ | ||
this.factory = factory ?? throw new ArgumentNullException(nameof(factory)); | ||
} | ||
|
||
public T Create() | ||
{ | ||
return this.factory(); | ||
} | ||
} |
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,10 @@ | ||
// <copyright file="IFactory.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.Common.Services.Factories; | ||
|
||
public interface IFactory<out T> | ||
{ | ||
T Create(); | ||
} |
12 changes: 12 additions & 0 deletions
12
FinalEngine.Editor.Common/Services/Scenes/ISceneManager.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// <copyright file="ISceneManager.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.Common.Services.Scenes; | ||
|
||
using FinalEngine.Editor.Common.Models.Scenes; | ||
|
||
public interface ISceneManager | ||
{ | ||
IScene ActiveScene { get; } | ||
} |
10 changes: 10 additions & 0 deletions
10
FinalEngine.Editor.Common/Services/Scenes/ISceneRenderer.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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// <copyright file="ISceneRenderer.cs" company="Software Antics"> | ||
// Copyright (c) Software Antics. All rights reserved. | ||
// </copyright> | ||
|
||
namespace FinalEngine.Editor.Common.Services.Scenes; | ||
|
||
public interface ISceneRenderer | ||
{ | ||
void Render(); | ||
} |
Oops, something went wrong.