Beispiel #1
0
        public void RegisterImages(ImageWriter imageWriter)
        {
            // NOTE: This mutates the images as they are registered, to account for trimming that RegisterImage does.
            //       (Kinda ugly, but too late to come up with something better.)

            var cels = AllAnimations().SelectMany(a => a.Frames).SelectMany(f => f.layers);

            foreach (var cel in cels)
            {
                var sprite    = cel.spriteRef.ResolveRequire();
                var newSprite = imageWriter.RegisterImage(sprite);

                if (sprite != newSprite)
                {
                    cel.spriteRef = new SpriteRef(newSprite);
                }
            }

            if (shadowLayers != null)
            {
                for (int i = 0; i < shadowLayers.Count; i++)
                {
                    var sl              = shadowLayers[i];
                    var shadowSprite    = sl.shadowSpriteRef.ResolveRequire();
                    var newShadowSprite = imageWriter.RegisterImage(shadowSprite);

                    if (shadowSprite != newShadowSprite)
                    {
                        sl.shadowSpriteRef = new SpriteRef(newShadowSprite);
                        shadowLayers[i]    = sl;
                    }
                }
            }
        }