-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now we have entities this brings more extensions to lower levels
This functionality used to exist in the `OpenRpg.Genres` layer but it has now been pulled down into this layer to make things a bit more extensible and composable from lower layers of the library.
- Loading branch information
Showing
17 changed files
with
118 additions
and
35 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
21 changes: 21 additions & 0 deletions
21
src/OpenRpg.Combat/Extensions/IItemEntityVariableExtensions.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,21 @@ | ||
using OpenRpg.Combat.Effects; | ||
using OpenRpg.Combat.Types; | ||
using OpenRpg.Core.Variables.Entity; | ||
|
||
namespace OpenRpg.Combat.Extensions | ||
{ | ||
/// <summary> | ||
/// This allows you to extend the underlying entity to add active effects onto them | ||
/// </summary> | ||
public static class CombatEntityVariableExtensions | ||
{ | ||
public static bool HasActiveEffects(this IEntityVariables vars) | ||
{ return vars.ContainsKey(CombatEntityVariableTypes.ActiveEffects); } | ||
|
||
public static IActiveEffects ActiveEffects(this IEntityVariables vars) | ||
{ return vars[CombatEntityVariableTypes.ActiveEffects] as IActiveEffects; } | ||
|
||
public static void ActiveEffects(this IEntityVariables vars, IActiveEffects activeEffects) | ||
{ vars[CombatEntityVariableTypes.ActiveEffects] = activeEffects; } | ||
} | ||
} |
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,9 @@ | ||
using OpenRpg.Core.Types; | ||
|
||
namespace OpenRpg.Combat.Types | ||
{ | ||
public interface CombatEntityVariableTypes : EntityVariableTypes | ||
{ | ||
public static readonly int ActiveEffects = 10; | ||
} | ||
} |
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,8 @@ | ||
namespace OpenRpg.Core.Types | ||
{ | ||
public interface EntityVariableTypes | ||
{ | ||
// Unknown | ||
public static readonly int Unknown = 0; | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
src/OpenRpg.Items/Extensions/IItemEntityVariableExtensions.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,31 @@ | ||
using OpenRpg.Core.Variables.Entity; | ||
using OpenRpg.Items.Equipment; | ||
using OpenRpg.Items.Inventory; | ||
using OpenRpg.Items.Types; | ||
|
||
namespace OpenRpg.Items.Extensions | ||
{ | ||
/// <summary> | ||
/// This allows you to extend the underlying entity to add equipment or inventory responsibilities onto them | ||
/// </summary> | ||
public static class ItemEntityVariableExtensions | ||
{ | ||
public static bool HasEquipment(this IEntityVariables vars) | ||
{ return vars.ContainsKey(ItemEntityVariableTypes.Equipment); } | ||
|
||
public static IEquipment Equipment(this IEntityVariables vars) | ||
{ return vars[ItemEntityVariableTypes.Equipment] as IEquipment; } | ||
|
||
public static void Equipment(this IEntityVariables vars, IEquipment equipment) | ||
{ vars[ItemEntityVariableTypes.Equipment] = equipment; } | ||
|
||
public static bool HasInventory(this IEntityVariables vars) | ||
{ return vars.ContainsKey(ItemEntityVariableTypes.Inventory); } | ||
|
||
public static IInventory Inventory(this IEntityVariables vars) | ||
{ return vars[ItemEntityVariableTypes.Inventory] as IInventory; } | ||
|
||
public static void Inventory(this IEntityVariables vars, IInventory inventory) | ||
{ vars[ItemEntityVariableTypes.Inventory] = inventory; } | ||
} | ||
} |
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
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 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,14 @@ | ||
using OpenRpg.Core.Types; | ||
|
||
namespace OpenRpg.Items.Types | ||
{ | ||
public interface ItemCoreVariableTypes : CoreVariableTypes | ||
{ | ||
public static int ItemTemplateVariables = 20; | ||
public static int InventoryVariables = 21; | ||
public static int ItemVariables = 23; | ||
public static int EquipmentVariables = 24; | ||
public static int LootTableEntryVariables = 25; | ||
public static int EquipmentSlotVariables = 26; | ||
} | ||
} |
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 @@ | ||
using OpenRpg.Core.Types; | ||
|
||
namespace OpenRpg.Items.Types | ||
{ | ||
public interface ItemEntityVariableTypes : EntityVariableTypes | ||
{ | ||
public static readonly int Equipment = 1; | ||
public static readonly int Inventory = 2; | ||
} | ||
} |
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,14 +1,10 @@ | ||
using OpenRpg.Core.Types; | ||
|
||
namespace OpenRpg.Items.Types | ||
{ | ||
public interface ItemVariableTypes : CoreVariableTypes | ||
public interface ItemVariableTypes | ||
{ | ||
public static int ItemTemplateVariables = 20; | ||
public static int InventoryVariables = 21; | ||
public static int ItemVariables = 23; | ||
public static int EquipmentVariables = 24; | ||
public static int LootTableEntryVariables = 25; | ||
public static int EquipmentSlotVariables = 26; | ||
public static int Unknown = 0; | ||
|
||
public static int Amount = 1; | ||
public static int Weight = 2; | ||
} | ||
} |
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