From acea7b2e728787a0d83bbf83c8c1f042d2c32e7e Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Mon, 3 Jun 2024 10:15:45 +0800 Subject: + plugins project --- .../source/MonoGame.Extended.Entities/Aspect.cs | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Plugins/MonoGame.Extended/source/MonoGame.Extended.Entities/Aspect.cs (limited to 'Plugins/MonoGame.Extended/source/MonoGame.Extended.Entities/Aspect.cs') diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Entities/Aspect.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Entities/Aspect.cs new file mode 100644 index 0000000..e6fb606 --- /dev/null +++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Entities/Aspect.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Specialized; + +namespace MonoGame.Extended.Entities +{ + public class Aspect + { + internal Aspect() + { + AllSet = new BitVector32(); + ExclusionSet = new BitVector32(); + OneSet = new BitVector32(); + } + + public BitVector32 AllSet; + public BitVector32 ExclusionSet; + public BitVector32 OneSet; + + public static AspectBuilder All(params Type[] types) + { + return new AspectBuilder().All(types); + } + + public static AspectBuilder One(params Type[] types) + { + return new AspectBuilder().One(types); + } + + public static AspectBuilder Exclude(params Type[] types) + { + return new AspectBuilder().Exclude(types); + } + + public bool IsInterested(BitVector32 componentBits) + { + if (AllSet.Data != 0 && (componentBits.Data & AllSet.Data) != AllSet.Data) + return false; + + if (ExclusionSet.Data != 0 && (componentBits.Data & ExclusionSet.Data) != 0) + return false; + + if (OneSet.Data != 0 && (componentBits.Data & OneSet.Data) == 0) + return false; + + return true; + } + } +} \ No newline at end of file -- cgit v1.1-26-g67d0