Ejemplo n.º 1
0
 public void AddRules(Dimension dimension, ISpawnRule rules)
 {
     if (!SpawnRules.ContainsKey(dimension))
     {
         SpawnRules[dimension] = new List <ISpawnRule>();
     }
     SpawnRules[dimension].Add(rules);
 }
Ejemplo n.º 2
0
        private static void RegisterSpawnRules()
        {
            // Use reflection to get all of SpawnRule implementations.
            var classes = Assembly.GetCallingAssembly().GetTypes()
                          .Where(p => typeof(ISpawnRule).IsAssignableFrom(p) && p.IsClass && !p.IsAbstract).ToArray();

            foreach (var type in classes)
            {
                ISpawnRule instance = Activator.CreateInstance(type) as ISpawnRule;
                if (instance == null)
                {
                    throw new NullReferenceException("Unable to activate instance of type: " + type);
                }
                _spawnRules.Add(type.Name, instance);
            }
        }
Ejemplo n.º 3
0
 public void AddRules(Dimension dimension, ISpawnRule rules)
 {
     if (!SpawnRules.ContainsKey(dimension))
         SpawnRules[dimension] = new List<ISpawnRule>();
     SpawnRules[dimension].Add(rules);
 }