Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
All campaign loader tasks now inherit from the same base class
Browse files Browse the repository at this point in the history
  • Loading branch information
REHERC committed Apr 26, 2021
1 parent 9ceaf74 commit 9fa8153
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Centrifuge.Distance
3 changes: 2 additions & 1 deletion Distance.AdventureMaker/Distance.AdventureMaker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@
<Compile Include="ApplicationArguments.cs" />
<Compile Include="Loader\CampaignLoaderLogic.cs" />
<Compile Include="Entry.cs" />
<Compile Include="Loader\Steps\CampaignReader.cs" />
<Compile Include="Loader\Steps\CampaignImporter.cs" />
<Compile Include="Loader\Steps\CampaignExtractor.cs" />
<Compile Include="Loader\Steps\CampaignListing.cs" />
<Compile Include="Loader\Steps\CampaignWorkspaceSetup.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
60 changes: 56 additions & 4 deletions Distance.AdventureMaker/Loader/CampaignLoaderLogic.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,64 @@
using Distance.AdventureMaker.Loader.Steps;
using Centrifuge.Distance.Game;
using Distance.AdventureMaker.Loader.Steps;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Distance.AdventureMaker.Loader
{
public class CampaignLoaderLogic : MonoBehaviour
{
private CampaignListing listing;
private CampaignExtractor extractor;
private CampaignReader reader;
private CampaignLoader loader;

public void Start()
{
loader = new CampaignLoader();
}

public IEnumerator Run(Task.Status status)
{
foreach (LoaderTask task in loader)
{
yield return Task.Wrap(task.Run(status, loader));
}
}

public abstract class LoaderTask
{
public abstract IEnumerator Run(Task.Status status, CampaignLoader loader);
}

public sealed class CampaignLoader : IEnumerable<LoaderTask>
{
private readonly Queue<LoaderTask> tasks;

public CampaignWorkspaceSetup WorkspaceSetup { get; }

public CampaignListing Listing { get; }

public CampaignExtractor Extractor { get; }

public CampaignImporter Importer { get; }

public CampaignLoader()
{
tasks = new Queue<LoaderTask>();

tasks.Enqueue(WorkspaceSetup = new CampaignWorkspaceSetup());
tasks.Enqueue(Listing = new CampaignListing());
tasks.Enqueue(Extractor = new CampaignExtractor());
tasks.Enqueue(Importer = new CampaignImporter());
}

public IEnumerator<LoaderTask> GetEnumerator()
{
return tasks.GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
}
}
}
12 changes: 10 additions & 2 deletions Distance.AdventureMaker/Loader/Steps/CampaignExtractor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
namespace Distance.AdventureMaker.Loader.Steps
using Centrifuge.Distance.Game;
using System.Collections;
using static Distance.AdventureMaker.Loader.CampaignLoaderLogic;

namespace Distance.AdventureMaker.Loader.Steps
{
public class CampaignExtractor
public class CampaignExtractor : LoaderTask
{
public override IEnumerator Run(Task.Status status, CampaignLoader loader)
{
throw new System.NotImplementedException();
}
}
}
14 changes: 14 additions & 0 deletions Distance.AdventureMaker/Loader/Steps/CampaignImporter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Centrifuge.Distance.Game;
using System.Collections;
using static Distance.AdventureMaker.Loader.CampaignLoaderLogic;

namespace Distance.AdventureMaker.Loader.Steps
{
public class CampaignImporter : LoaderTask
{
public override IEnumerator Run(Task.Status status, CampaignLoader loader)
{
throw new System.NotImplementedException();
}
}
}
12 changes: 10 additions & 2 deletions Distance.AdventureMaker/Loader/Steps/CampaignListing.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
namespace Distance.AdventureMaker.Loader.Steps
using Centrifuge.Distance.Game;
using System.Collections;
using static Distance.AdventureMaker.Loader.CampaignLoaderLogic;

namespace Distance.AdventureMaker.Loader.Steps
{
public class CampaignListing
public class CampaignListing : LoaderTask
{
public override IEnumerator Run(Task.Status status, CampaignLoader loader)
{
throw new System.NotImplementedException();
}
}
}
6 changes: 0 additions & 6 deletions Distance.AdventureMaker/Loader/Steps/CampaignReader.cs

This file was deleted.

14 changes: 14 additions & 0 deletions Distance.AdventureMaker/Loader/Steps/CampaignWorkspaceSetup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Centrifuge.Distance.Game;
using System.Collections;
using static Distance.AdventureMaker.Loader.CampaignLoaderLogic;

namespace Distance.AdventureMaker.Loader.Steps
{
public class CampaignWorkspaceSetup : LoaderTask
{
public override IEnumerator Run(Task.Status status, CampaignLoader loader)
{
throw new System.NotImplementedException();
}
}
}

0 comments on commit 9fa8153

Please sign in to comment.