コード例 #1
0
        //here we get all generic types from system and create matcher out of them
        public void Initialize(IMatcherSystem _system)
        {
            system = _system;
            var interfaces = system.GetType().GetInterfaces();

            foreach (var type in interfaces)
            {
                if (!type.IsGenericType)
                {
                    continue;
                }
                Type gendef = type.GetGenericTypeDefinition();
                if (
                    gendef == typeof(IMatcherSystem <>) ||
                    gendef == typeof(IMatcherSystem <,>) ||
                    gendef == typeof(IMatcherSystem <, ,>) ||
                    gendef == typeof(IMatcherSystem <, , ,>))
                {
                    systemTypes.AddRange(type.GetGenericArguments());
                }
            }

            matcher = new Matcher();
            matcher.OnMatchAdded   += system.OnMatchAdded;
            matcher.OnMatchRemoved += system.OnMatchRemoved;

            matcher.SetIs(systemTypes.ToArray());
        }
コード例 #2
0
ファイル: Systems.cs プロジェクト: xJayLee/JECSu
 static void RegisterMatcherSystem(IMatcherSystem system)
 {
     if (matcherSystems.Contains(system))
     {
         throw new Exception("Trying to register already existing react system which is well, and error.");
     }
     else
     {
         //Matcher systems are wrapped into a controller
         MatcherSystemController controller = new MatcherSystemController();
         controller.Initialize(system);
     }
 }