Beispiel #1
0
        public void AddEntity(Entity entity)
        {
            // Made with a lot of help from stack overflow

            entities.Add(entity);
            nodesByEntity[entity] = new List <Node>();
            foreach (Type NodeType in nodeTypes)
            {
                Entity[] currentEntityList = { entity };
                if ((bool)NodeType.GetMethod("HasToBeCreated").Invoke(null, currentEntityList))
                {
                    Type[] constructorParameterTypes = { typeof(Entity) };
                    Node   node = (Node)NodeType.GetConstructor(constructorParameterTypes).Invoke(currentEntityList);
                    nodesByEntity[entity].Add(node);
                    nodesByType[NodeType].Add(node);
                }
            }
        }