diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index 73659ecc9..d31cbcd30 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -190,6 +190,10 @@ + + ..\packages\System.Linq.Dynamic.1.0.6\lib\net40\System.Linq.Dynamic.dll + True + @@ -249,6 +253,9 @@ Code + + + @@ -269,6 +276,8 @@ + + diff --git a/Artemis/Artemis/Components/Abstract/LayerComponent.cs b/Artemis/Artemis/Components/Abstract/LayerComponent.cs new file mode 100644 index 000000000..c2b224c61 --- /dev/null +++ b/Artemis/Artemis/Components/Abstract/LayerComponent.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using Artemis.Models; +using Artemis.Models.Interfaces; + +namespace Artemis.Components.Abstract +{ + public abstract class LayerComponent + { + public string Name { get; set; } + public List ConditionModels { get; set; } + + public bool ConditionsMet(IGameDataModel dataModel) + { + return ConditionModels.All(cm => cm.ConditionMet(dataModel)); + } + + public abstract void Draw(Graphics g); + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Components/Layer.cs b/Artemis/Artemis/Components/Layer.cs new file mode 100644 index 000000000..a1beb3b86 --- /dev/null +++ b/Artemis/Artemis/Components/Layer.cs @@ -0,0 +1,13 @@ +using System.Drawing; +using Artemis.Components.Abstract; + +namespace Artemis.Components +{ + public class Layer : LayerComponent + { + public override void Draw(Graphics g) + { + // Read properties and draw accordingly + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Components/LayerComposite.cs b/Artemis/Artemis/Components/LayerComposite.cs new file mode 100644 index 000000000..775a707c5 --- /dev/null +++ b/Artemis/Artemis/Components/LayerComposite.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; +using System.Drawing; +using Artemis.Components.Abstract; + +namespace Artemis.Components +{ + public class LayerComposite : LayerComponent + { + public List LayerComponents { get; set; } + + public override void Draw(Graphics g) + { + foreach (var layerComponent in LayerComponents) + layerComponent.Draw(g); + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Models/Interfaces/IGameDataModel.cs b/Artemis/Artemis/Models/Interfaces/IGameDataModel.cs new file mode 100644 index 000000000..3dd99c183 --- /dev/null +++ b/Artemis/Artemis/Models/Interfaces/IGameDataModel.cs @@ -0,0 +1,6 @@ +namespace Artemis.Models.Interfaces +{ + public interface IGameDataModel + { + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Models/LayerConditionModel.cs b/Artemis/Artemis/Models/LayerConditionModel.cs new file mode 100644 index 000000000..3a2896cd2 --- /dev/null +++ b/Artemis/Artemis/Models/LayerConditionModel.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using System.Linq.Dynamic; + +namespace Artemis.Models +{ + public class LayerConditionModel + { + public string Field { get; set; } + public string Value { get; set; } + public string Operator { get; set; } + + public bool ConditionMet(object subject) + { + // Put the subject in a list, allowing Dynamic Linq to be used. + var subjectList = new List {subject}; + var res = subjectList.Where($"s => s.{Field} {Operator} {Value}").Any(); + return res; + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionDataModel.cs b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionDataModel.cs index f2a6390d5..b89b74583 100644 --- a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionDataModel.cs +++ b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionDataModel.cs @@ -1,8 +1,9 @@ using System.Collections.Generic; +using Artemis.Models.Interfaces; namespace Artemis.Modules.Games.TheDivision { - public class TheDivisionDataModel + public class TheDivisionDataModel : IGameDataModel { public List DivisionPlayers { get; set; } public GrenadeState GrenadeState { get; set; } diff --git a/Artemis/Artemis/packages.config b/Artemis/Artemis/packages.config index 8cb94cea7..8a610c1e7 100644 --- a/Artemis/Artemis/packages.config +++ b/Artemis/Artemis/packages.config @@ -18,6 +18,7 @@ + \ No newline at end of file