Skip to content

Commit

Permalink
commit to switch devices
Browse files Browse the repository at this point in the history
  • Loading branch information
AnakinRaW committed Jun 2, 2024
1 parent e16726e commit d861003
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 81 deletions.
2 changes: 1 addition & 1 deletion src/ModVerify/ModVerify.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AnakinRaW.CommonUtilities.SimplePipeline" Version="12.0.2-beta" />
<PackageReference Include="AnakinRaW.CommonUtilities.SimplePipeline" Version="12.0.3-beta" />
<PackageReference Include="IsExternalInit" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
14 changes: 4 additions & 10 deletions src/ModVerify/Steps/GameVerificationStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
using Microsoft.Extensions.Logging;
using PG.StarWarsGame.Engine;
using PG.StarWarsGame.Engine.FileSystem;
using PG.StarWarsGame.Engine.Pipeline;

namespace AET.ModVerify.Steps;

public abstract class GameVerificationStep(
CreateGameDatabaseStep createDatabaseStep,
IGameRepository repository,
GameDatabase gameDatabase,
VerificationSettings settings,
IServiceProvider serviceProvider)
: PipelineStep(serviceProvider)
Expand All @@ -28,19 +26,16 @@ public abstract class GameVerificationStep(

protected VerificationSettings Settings { get; } = settings;

protected GameDatabase Database { get; private set; } = null!;
protected GameDatabase Database { get; } = gameDatabase ?? throw new ArgumentNullException(nameof(gameDatabase));

protected IGameRepository Repository => repository;
protected IGameRepository Repository => gameDatabase.GameRepository;

protected abstract string LogFileName { get; }

public abstract string Name { get; }

protected sealed override void RunCore(CancellationToken token)
{
createDatabaseStep.Wait();
Database = createDatabaseStep.GameDatabase;

Logger?.LogInformation($"Running verifier '{Name}'...");
try
{
Expand All @@ -57,12 +52,11 @@ protected sealed override void RunCore(CancellationToken token)

protected abstract void RunVerification(CancellationToken token);


protected void AddError(VerificationError error)
{
if (!OnError(error))
{
Logger?.LogTrace($"Error suppressed: '{error}'");
Logger?.LogTrace($"Error suppressed for verifier '{Name}': '{error}'");
return;
}
_verifyErrors.Add(error);
Expand Down
7 changes: 2 additions & 5 deletions src/ModVerify/Steps/VerifyReferencedModelsStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
using PG.Commons.Files;
using PG.Commons.Utilities;
using PG.StarWarsGame.Engine;
using PG.StarWarsGame.Engine.FileSystem;
using PG.StarWarsGame.Engine.Pipeline;
using PG.StarWarsGame.Files.ALO.Files.Models;
using PG.StarWarsGame.Files.ALO.Files.Particles;
using PG.StarWarsGame.Files.ALO.Services;
Expand All @@ -18,11 +16,10 @@
namespace AET.ModVerify.Steps;

internal sealed class VerifyReferencedModelsStep(
CreateGameDatabaseStep createDatabaseStep,
IGameRepository repository,
GameDatabase database,
VerificationSettings settings,
IServiceProvider serviceProvider)
: GameVerificationStep(createDatabaseStep, repository, settings, serviceProvider)
: GameVerificationStep(database, settings, serviceProvider)
{
public const string ModelNotFound = "ALO00";
public const string ModelBroken = "ALO01";
Expand Down
63 changes: 39 additions & 24 deletions src/ModVerify/VerifyGamePipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,42 @@
using System.Threading.Tasks;
using AET.ModVerify.Steps;
using AnakinRaW.CommonUtilities.SimplePipeline;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using PG.StarWarsGame.Engine.FileSystem;
using PG.StarWarsGame.Engine.Pipeline;

namespace AET.ModVerify;

public class VerifyGamePipeline : ParallelPipeline
public abstract class VerifyGamePipeline : Pipeline
{
private IList<GameVerificationStep> _verificationSteps = null!;
private readonly IGameRepository _repository;
private IList<GameVerificationStep> _verificationSteps = new List<GameVerificationStep>();
private readonly GameLocations _gameLocations;
private readonly VerificationSettings _settings;

public VerifyGamePipeline(IGameRepository gameRepository, VerificationSettings settings, IServiceProvider serviceProvider)
: base(serviceProvider, 4, false)
protected VerifyGamePipeline(GameLocations gameLocations, VerificationSettings settings, IServiceProvider serviceProvider)
: base(serviceProvider)
{
_repository = gameRepository;
_settings = settings;
_gameLocations = gameLocations ?? throw new ArgumentNullException(nameof(gameLocations));
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
}

protected override Task<IList<IStep>> BuildSteps()
{
var buildIndexStep = new CreateGameDatabaseStep(_repository, ServiceProvider);

_verificationSteps = new List<GameVerificationStep>
{
new VerifyReferencedModelsStep(buildIndexStep, _repository, _settings, ServiceProvider),
};

var allSteps = new List<IStep>
{
buildIndexStep
};
allSteps.AddRange(_verificationSteps);

return Task.FromResult<IList<IStep>>(allSteps);
protected override Task<bool> PrepareCoreAsync()
{
throw new NotImplementedException();
}

public override async Task RunAsync(CancellationToken token = default)
protected override async Task RunCoreAsync(CancellationToken token)
{
Logger?.LogInformation("Verifying game...");
try
{
await base.RunAsync(token).ConfigureAwait(false);
var databaseService = ServiceProvider.GetRequiredService<IGameDatabaseService>();

await databaseService.CreateDatabaseAsync()



var stepsWithVerificationErrors = _verificationSteps.Where(x => x.VerifyErrors.Any()).ToList();

Expand All @@ -69,4 +62,26 @@ public override async Task RunAsync(CancellationToken token = default)
Logger?.LogInformation("Finished game verification");
}
}


//protected sealed override async Task<IList<IStep>> BuildSteps()
//{
// var buildIndexStep = new CreateGameDatabaseStep(_repository, ServiceProvider);

// _verificationSteps = new List<GameVerificationStep>
// {
// new VerifyReferencedModelsStep(buildIndexStep, _repository, _settings, ServiceProvider),
// };

// var allSteps = new List<IStep>
// {
// buildIndexStep
// };
// allSteps.AddRange(CreateVeificationSteps());

// return allSteps;
//}


protected abstract IEnumerable<GameVerificationStep> CreateVerificationSteps();
}
3 changes: 2 additions & 1 deletion src/PetroglyphTools/PG.StarWarsGame.Engine/GameDatabase.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Collections.Generic;
using PG.StarWarsGame.Engine.DataTypes;
using PG.StarWarsGame.Engine.FileSystem;

namespace PG.StarWarsGame.Engine;

public class GameDatabase
{
public required GameEngineType EngineType { get; init; }
public required IGameRepository GameRepository { get; init; }

public required GameConstants GameConstants { get; init; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AnakinRaW.CommonUtilities.SimplePipeline" Version="12.0.2-beta" />
<PackageReference Include="AnakinRaW.CommonUtilities.SimplePipeline" Version="12.0.3-beta" />
<PackageReference Include="IsExternalInit" Version="1.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,28 @@
using System.Threading;
using System.Threading.Tasks;
using AnakinRaW.CommonUtilities.SimplePipeline;
using Microsoft.Extensions.Logging;
using PG.StarWarsGame.Engine.DataTypes;
using PG.StarWarsGame.Engine.FileSystem;

namespace PG.StarWarsGame.Engine.Pipeline;

internal class CreateGameDatabasePipeline(IGameRepository repository, IServiceProvider serviceProvider)
: ParallelPipeline(serviceProvider)
public interface IGameDatabaseService
{
Task<IGameDatabase> CreateDatabaseAsync(GameEngineType targetEngineType, GameLocations locations, CancellationToken cancellationToken = default);

Check failure on line 15 in src/PetroglyphTools/PG.StarWarsGame.Engine/Pipeline/CreateGameDatabasePipeline.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

The type or namespace name 'IGameDatabase' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 15 in src/PetroglyphTools/PG.StarWarsGame.Engine/Pipeline/CreateGameDatabasePipeline.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

The type or namespace name 'IGameDatabase' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 15 in src/PetroglyphTools/PG.StarWarsGame.Engine/Pipeline/CreateGameDatabasePipeline.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

The type or namespace name 'IGameDatabase' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 15 in src/PetroglyphTools/PG.StarWarsGame.Engine/Pipeline/CreateGameDatabasePipeline.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

The type or namespace name 'IGameDatabase' could not be found (are you missing a using directive or an assembly reference?)
}

internal class GameDatabaseService(IServiceProvider serviceProvider) : IGameDatabaseService
{
public async Task<IGameDatabase> CreateDatabaseAsync(GameEngineType targetEngineType, GameLocations locations, CancellationToken cancellationToken = default)

Check failure on line 20 in src/PetroglyphTools/PG.StarWarsGame.Engine/Pipeline/CreateGameDatabasePipeline.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

The type or namespace name 'IGameDatabase' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 20 in src/PetroglyphTools/PG.StarWarsGame.Engine/Pipeline/CreateGameDatabasePipeline.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

The type or namespace name 'IGameDatabase' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 20 in src/PetroglyphTools/PG.StarWarsGame.Engine/Pipeline/CreateGameDatabasePipeline.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

The type or namespace name 'IGameDatabase' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 20 in src/PetroglyphTools/PG.StarWarsGame.Engine/Pipeline/CreateGameDatabasePipeline.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

The type or namespace name 'IGameDatabase' could not be found (are you missing a using directive or an assembly reference?)
{
var pipeline = new GameDatabaseCreationPipeline(repository, serviceProvider, cancellationToken);
await pipeline.RunAsync(cancellationToken);
return pipeline.GameDatabase;
}
}

internal class GameDatabaseCreationPipeline(GameRepository repository, IServiceProvider serviceProvider) : ParallelPipeline(serviceProvider)

Check failure on line 28 in src/PetroglyphTools/PG.StarWarsGame.Engine/Pipeline/CreateGameDatabasePipeline.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

The type or namespace name 'GameRepository' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in src/PetroglyphTools/PG.StarWarsGame.Engine/Pipeline/CreateGameDatabasePipeline.cs

View workflow job for this annotation

GitHub Actions / Build & Test (windows-latest)

The type or namespace name 'GameRepository' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in src/PetroglyphTools/PG.StarWarsGame.Engine/Pipeline/CreateGameDatabasePipeline.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

The type or namespace name 'GameRepository' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in src/PetroglyphTools/PG.StarWarsGame.Engine/Pipeline/CreateGameDatabasePipeline.cs

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-latest)

The type or namespace name 'GameRepository' could not be found (are you missing a using directive or an assembly reference?)
{
private ParseSingletonXmlStep<GameConstants> _parseGameConstants = null!;
private ParseFromContainerStep<GameObject> _parseGameObjects = null!;
Expand Down Expand Up @@ -71,14 +86,22 @@ protected override Task<IList<IStep>> BuildSteps()

protected override async Task RunCoreAsync(CancellationToken token)
{
await base.RunCoreAsync(token);
Logger?.LogInformation("Creating Game Database...");

GameDatabase = new GameDatabase
try
{
EngineType = repository.EngineType,
GameConstants = _parseGameConstants.Database,
GameObjects = _parseGameObjects.Database
};
await base.RunCoreAsync(token);

GameDatabase = new GameDatabase
{
GameConstants = _parseGameConstants.Database,
GameObjects = _parseGameObjects.Database
};
}
finally
{
Logger?.LogInformation("Finished creating game database");
}
}

private sealed class ParseSingletonXmlStep<T>(string name, string xmlFile, IGameRepository repository, IServiceProvider serviceProvider)
Expand Down

This file was deleted.

0 comments on commit d861003

Please sign in to comment.