public void RegisterImages(ImageWriter imageWriter, IAssetPathProvider assetPathProvider) { // NOTE: Using assetPathProvider to check if the item is embedded // (Kind of ugly, as it duplicates the condition in LevelSerializeContext) if (levelAnimation != null && assetPathProvider.GetAssetPath(levelAnimation) == null) { levelAnimation.RegisterImages(imageWriter); } foreach (var thing in things) { if (thing.AnimationSet != null && assetPathProvider.GetAssetPath(thing.AnimationSet) == null) { thing.AnimationSet.RegisterImages(imageWriter); } } foreach (var shim in shims) { if (shim.AnimationSet != null && assetPathProvider.GetAssetPath(shim.AnimationSet) == null) { shim.AnimationSet.RegisterImages(imageWriter); } } }
/// <summary>IMPORTANT: Must match with calls to RegisterImages</summary> public void WriteAnimationSet(AnimationSet animationSet) { string name = assetPathProvider.GetAssetPath(animationSet); Debug.Assert(name == null || !name.StartsWith("\\")); if (name != null) { // Write a reference bw.Write(true); bw.Write(name); } else { // Embed the animation bw.Write(false); animationSet.Serialize(animationSerializeContext); } }