Пример #1
0
        // TODO: fixme with an ActorInit (ASAP)
        void LoadActorTypes(string filename)
        {
            var rules = MetadataTree.NodesFromFile(filename);

            foreach (var actorDef in rules)
            {
                var name = actorDef.Key.ToLowerInvariant();
                var info = new ActorInfo(name, actorDef);

                if (ActorRules.ContainsKey(name))
                {
                    throw new ArgumentException("Duplicate definition for `{0}`.".F(name));
                }

                ActorRules.Add(name, info);

                // This is where the bogosity starts
                // Just because we load the rules doesn't mean we want an instance

                var actor = new Actor(world, name);

                foreach (var traitInfo in info.TraitInfos)
                {
                    actor.AddTrait(traitInfo.CreateTrait(actor) as ITrait);
                }

                world.AddActor(actor);
            }
        }
Пример #2
0
        protected override void LoadContent()
        {
            // 1) Parse data tree (get filenames to load)
            // 2) Load image files as Texture2D
            // 3) Construct Sprite -> Animation relationship

            var anims = Directory.EnumerateFiles("rules/anims", "*.meta");

            foreach (var animFile in anims)
            {
                var metaNodes = MetadataTree.NodesFromFile(animFile);
                foreach (var node in metaNodes)
                {
                    Animations.Add(node.Key, new Animation(world, node.Key, node.ChildTree.Nodes));
                }
            }

            var rules = Directory.EnumerateFiles("rules", "*.meta");

            // TODO: This also creates an instance of the actor
            // which is required because we don't have an intermediate ActorInit
            foreach (var ruleFile in rules)
            {
                LoadActorTypes(ruleFile);
            }
        }
Пример #3
0
 public MetadataNode(string key, string value, MetadataTree childTree)
 {
     Key = key;
     Value = value;
     ChildTree = childTree;
 }
Пример #4
0
 public MetadataNode(string key, string value, MetadataTree childTree)
 {
     Key       = key;
     Value     = value;
     ChildTree = childTree;
 }