Skip to content

Commit

Permalink
Merge pull request #54 from benpollarduk/template-refactor
Browse files Browse the repository at this point in the history
Template refactor
  • Loading branch information
benpollarduk authored Jan 19, 2024
2 parents 05ed1bb + e19922c commit 1f21558
Show file tree
Hide file tree
Showing 76 changed files with 507 additions and 1,029 deletions.
12 changes: 6 additions & 6 deletions BP.AdventureFramework.Examples/Assets/Items/Knife.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using BP.AdventureFramework.Assets;
using BP.AdventureFramework.Utilities.Templates;
using BP.AdventureFramework.Utilities;

namespace BP.AdventureFramework.Examples.Assets.Items
{
public class Knife : ItemTemplate<Knife>
public class Knife : IAssetTemplate<Item>
{
#region Constants

Expand All @@ -12,13 +12,13 @@ public class Knife : ItemTemplate<Knife>

#endregion

#region Overrides of ItemTemplate<Knife>
#region Implementation of IAssetTemplate<out Item>

/// <summary>
/// Create a new instance of the item.
/// Instantiate a new instance of the templated asset.
/// </summary>
/// <returns>The region.</returns>
protected override Item OnCreate()
/// <returns>The asset.</returns>
public Item Instantiate()
{
return new Item(Name, Description, true);
}
Expand Down
14 changes: 7 additions & 7 deletions BP.AdventureFramework.Examples/Assets/Player/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
using BP.AdventureFramework.Examples.Assets.Items;
using BP.AdventureFramework.Examples.Assets.Regions.Flat.Items;
using BP.AdventureFramework.Extensions;
using BP.AdventureFramework.Utilities.Templates;
using BP.AdventureFramework.Utilities;

namespace BP.AdventureFramework.Examples.Assets.Player
{
public class Player : PlayableCharacterTemplate<Player>
public class Player : IAssetTemplate<PlayableCharacter>
{
#region Constants

Expand All @@ -16,15 +16,15 @@ public class Player : PlayableCharacterTemplate<Player>

#endregion

#region Overrides of PlayableCharacterTemplate<Player>
#region Implementation of IAssetTemplate<PlayableCharacter>

/// <summary>
/// Create a new instance of the playable character.
/// Instantiate a new instance of the asset.
/// </summary>
/// <returns>The playable character.</returns>
protected override PlayableCharacter OnCreate()
/// <returns>The asset.</returns>
public PlayableCharacter Instantiate()
{
var player = new PlayableCharacter(Name, Description, Knife.Create())
var player = new PlayableCharacter(Name, Description, new Knife().Instantiate())
{
Interaction = (i, _) =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using BP.AdventureFramework.Assets.Characters;
using BP.AdventureFramework.Assets.Locations;
using BP.AdventureFramework.Assets.Locations;
using BP.AdventureFramework.Examples.Assets.Regions.Everglades.Rooms;
using BP.AdventureFramework.Utilities;
using BP.AdventureFramework.Utilities.Templates;

namespace BP.AdventureFramework.Examples.Assets.Regions.Everglades
{
internal class Everglades : RegionTemplate<Everglades>
internal class Everglades : IAssetTemplate<Region>
{
#region Constants

Expand All @@ -15,24 +13,23 @@ internal class Everglades : RegionTemplate<Everglades>

#endregion

#region Overrides of RegionTemplate<Everglades>
#region Implementation of IAssetTemplate<Region>

/// <summary>
/// Create a new instance of the region.
/// Instantiate a new instance of the asset.
/// </summary>
/// <param name="pC">The playable character.</param>
/// <returns>The region.</returns>
protected override Region OnCreate(PlayableCharacter pC)
/// <returns>The asset.</returns>
public Region Instantiate()
{
var regionMaker = new RegionMaker(Name, Description)
{
[2, 0, 0] = ForestEntrance.Create(),
[2, 1, 0] = ForestFloor.Create(),
[2, 2, 0] = CaveMouth.Create(),
[1, 2, 0] = GreatWesternOcean.Create(),
[2, 3, 0] = Cave.Create(),
[3, 3, 0] = InnerCave.Create(),
[3, 4, 0] = Outskirts.Create()
[2, 0, 0] = new ForestEntrance().Instantiate(),
[2, 1, 0] = new ForestFloor().Instantiate(),
[2, 2, 0] = new CaveMouth().Instantiate(),
[1, 2, 0] = new GreatWesternOcean().Instantiate(),
[2, 3, 0] = new Cave().Instantiate(),
[3, 3, 0] = new InnerCave().Instantiate(),
[3, 4, 0] = new Outskirts().Instantiate()
};


Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using BP.AdventureFramework.Assets;
using BP.AdventureFramework.Assets.Interaction;
using BP.AdventureFramework.Examples.Assets.Items;
using BP.AdventureFramework.Utilities.Templates;
using BP.AdventureFramework.Utilities;

namespace BP.AdventureFramework.Examples.Assets.Regions.Everglades.Items
{
public class ConchShell : ItemTemplate<ConchShell>
public class ConchShell : IAssetTemplate<Item>
{
#region Constants

Expand All @@ -14,13 +14,13 @@ public class ConchShell : ItemTemplate<ConchShell>

#endregion

#region Overrides of ItemTemplate<ConchShell>
#region Implementation of IAssetTemplate<Item>

/// <summary>
/// Create a new instance of the item.
/// Instantiate a new instance of the asset.
/// </summary>
/// <returns>The region.</returns>
protected override Item OnCreate()
/// <returns>The item.</returns>
public Item Instantiate()
{
var conchShell = new Item(Name, Description, true)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using BP.AdventureFramework.Assets.Locations;
using BP.AdventureFramework.Utilities.Templates;
using BP.AdventureFramework.Utilities;

namespace BP.AdventureFramework.Examples.Assets.Regions.Everglades.Rooms
{
internal class Cave : RoomTemplate<Cave>
internal class Cave : IAssetTemplate<Room>
{
#region Constants

Expand All @@ -12,13 +12,13 @@ internal class Cave : RoomTemplate<Cave>

#endregion

#region Overrides of RoomTemplate<Cave>
#region Implementation of IAssetTemplate<Room>

/// <summary>
/// Create a new instance of the room.
/// Instantiate a new instance of the asset.
/// </summary>
/// <returns>The room.</returns>
protected override Room OnCreate()
/// <returns>The asset.</returns>
public Room Instantiate()
{
return new Room(Name, Description, new Exit(Direction.East), new Exit(Direction.South));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using BP.AdventureFramework.Assets.Locations;
using BP.AdventureFramework.Utilities.Templates;
using BP.AdventureFramework.Utilities;

namespace BP.AdventureFramework.Examples.Assets.Regions.Everglades.Rooms
{
internal class CaveMouth : RoomTemplate<CaveMouth>
internal class CaveMouth : IAssetTemplate<Room>
{
#region Constants

Expand All @@ -12,13 +12,13 @@ internal class CaveMouth : RoomTemplate<CaveMouth>

#endregion

#region Overrides of RoomTemplate<CaveMouth>
#region Implementation of IAssetTemplate<Room>

/// <summary>
/// Create a new instance of the room.
/// Instantiate a new instance of the asset.
/// </summary>
/// <returns>The room.</returns>
protected override Room OnCreate()
/// <returns>The asset.</returns>
public Room Instantiate()
{
return new Room(Name, Description, new Exit(Direction.North), new Exit(Direction.South), new Exit(Direction.West));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using BP.AdventureFramework.Assets.Locations;
using BP.AdventureFramework.Utilities.Templates;
using BP.AdventureFramework.Utilities;

namespace BP.AdventureFramework.Examples.Assets.Regions.Everglades.Rooms
{
internal class ForestEntrance : RoomTemplate<ForestEntrance>
internal class ForestEntrance : IAssetTemplate<Room>
{
#region Constants

Expand All @@ -12,13 +12,13 @@ internal class ForestEntrance : RoomTemplate<ForestEntrance>

#endregion

#region Overrides of RoomTemplate<ForestEntrance>
#region Implementation of IAssetTemplate<Room>

/// <summary>
/// Create a new instance of the room.
/// Instantiate a new instance of the asset.
/// </summary>
/// <returns>The room.</returns>
protected override Room OnCreate()
/// <returns>The asset.</returns>
public Room Instantiate()
{
return new Room(Name, Description, new Exit(Direction.North));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using BP.AdventureFramework.Assets.Locations;
using BP.AdventureFramework.Utilities.Templates;
using BP.AdventureFramework.Utilities;

namespace BP.AdventureFramework.Examples.Assets.Regions.Everglades.Rooms
{
internal class ForestFloor : RoomTemplate<ForestFloor>
internal class ForestFloor : IAssetTemplate<Room>
{
#region Constants

Expand All @@ -12,13 +12,13 @@ internal class ForestFloor : RoomTemplate<ForestFloor>

#endregion

#region Overrides of RoomTemplate<ForestFloor>
#region Implementation of IAssetTemplate<Room>

/// <summary>
/// Create a new instance of the room.
/// Instantiate a new instance of the asset.
/// </summary>
/// <returns>The room.</returns>
protected override Room OnCreate()
/// <returns>The asset.</returns>
public Room Instantiate()
{
return new Room(Name, Description, new Exit(Direction.North), new Exit(Direction.South));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using BP.AdventureFramework.Assets.Locations;
using BP.AdventureFramework.Examples.Assets.Regions.Everglades.Items;
using BP.AdventureFramework.Utilities.Templates;
using BP.AdventureFramework.Utilities;

namespace BP.AdventureFramework.Examples.Assets.Regions.Everglades.Rooms
{
internal class GreatWesternOcean : RoomTemplate<GreatWesternOcean>
internal class GreatWesternOcean : IAssetTemplate<Room>
{
#region Constants

Expand All @@ -13,16 +13,16 @@ internal class GreatWesternOcean : RoomTemplate<GreatWesternOcean>

#endregion

#region Overrides of RoomTemplate<GreatWesternOcean>
#region Implementation of IAssetTemplate<Room>

/// <summary>
/// Create a new instance of the room.
/// Instantiate a new instance of the asset.
/// </summary>
/// <returns>The room.</returns>
protected override Room OnCreate()
/// <returns>The asset.</returns>
public Room Instantiate()
{
var room = new Room(Name, Description, new Exit(Direction.East));
room.AddItem(ConchShell.Create());
room.AddItem(new ConchShell().Instantiate());
return room;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
using BP.AdventureFramework.Examples.Assets.Items;
using BP.AdventureFramework.Examples.Assets.Regions.Everglades.Items;
using BP.AdventureFramework.Extensions;
using BP.AdventureFramework.Utilities.Templates;
using BP.AdventureFramework.Utilities;

namespace BP.AdventureFramework.Examples.Assets.Regions.Everglades.Rooms
{
internal class InnerCave : RoomTemplate<InnerCave>
internal class InnerCave : IAssetTemplate<Room>
{
#region Constants

private const string Name = "Inner Cave";

#endregion

#region Overrides of RoomTemplate<InnerCave>
#region Implementation of IAssetTemplate<Room>

/// <summary>
/// Create a new instance of the room.
/// Instantiate a new instance of the asset.
/// </summary>
/// <returns>The room.</returns>
protected override Room OnCreate()
/// <returns>The asset.</returns>
public Room Instantiate()
{
var room = new Room(Name, string.Empty, new Exit(Direction.West), new Exit(Direction.North, true));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using BP.AdventureFramework.Assets.Locations;
using BP.AdventureFramework.Utilities.Templates;
using BP.AdventureFramework.Utilities;


namespace BP.AdventureFramework.Examples.Assets.Regions.Everglades.Rooms
{
internal class Outskirts : RoomTemplate<Outskirts>
internal class Outskirts : IAssetTemplate<Room>
{
#region Constants

Expand All @@ -12,13 +13,13 @@ internal class Outskirts : RoomTemplate<Outskirts>

#endregion

#region Overrides of RoomTemplate<Outskirts>
#region Implementation of IAssetTemplate<Room>

/// <summary>
/// Create a new instance of the room.
/// Instantiate a new instance of the asset.
/// </summary>
/// <returns>The room.</returns>
protected override Room OnCreate()
/// <returns>The asset.</returns>
public Room Instantiate()
{
return new Room(Name, Description, new Exit(Direction.South));
}
Expand Down
Loading

0 comments on commit 1f21558

Please sign in to comment.