Ejemplo n.º 1
0
        private void ReadComponent(YamlMappingNode mapping, IComponentFactory factory)
        {
            string type = mapping.GetNode("type").AsString();

            // See if type exists to detect errors.
            switch (factory.GetComponentAvailability(type))
            {
            case ComponentAvailability.Available:
                break;

            case ComponentAvailability.Ignore:
                return;

            case ComponentAvailability.Unknown:
                Log.Logger.Error($"Unknown component '{type}' in prototype {ID}!");
                return;
            }

            var copy = new YamlMappingNode(mapping.AsEnumerable());

            // TODO: figure out a better way to exclude the type node.
            // Also maybe deep copy this? Right now it's pretty error prone.
            copy.Children.Remove(new YamlScalarNode("type"));

            Components[type] = copy;
        }