Example #1
0
        public ActorInfo(ObjectCreator creator, string name, MiniYaml node, Dictionary <string, MiniYaml> allUnits)
        {
            try
            {
                Name = name;

                var allParents        = new HashSet <string>();
                var abstractActorType = name.StartsWith("^");

                // Guard against circular inheritance
                allParents.Add(name);

                var partial = MergeWithParents(node, allUnits, allParents);
                foreach (var t in MiniYaml.ApplyRemovals(partial.Nodes))
                {
                    if (t.Key != "Inherits" && !t.Key.StartsWith("Inherits@"))
                    {
                        try
                        {
                            traits.Add(LoadTraitInfo(creator, t.Key.Split('@')[0], t.Value));
                        }
                        catch (FieldLoader.MissingFieldsException e)
                        {
                            if (!abstractActorType)
                            {
                                throw new YamlException(e.Message);
                            }
                        }
                    }
                }
            }
            catch (YamlException e)
            {
                throw new YamlException("Actor type {0}: {1}".F(name, e.Message));
            }
        }