Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
SpriteGroupCompiler.cs
Go to the documentation of this file.
1 using System.Collections.Generic;
2 
3 using SiliconStudio.Assets.Compiler;
4 using SiliconStudio.Core.IO;
5 using SiliconStudio.Core.Mathematics;
6 using SiliconStudio.Paradox.Graphics.Data;
7 
8 namespace SiliconStudio.Paradox.Assets.Sprite
9 {
10  /// <summary>
11  /// Texture asset compiler.
12  /// </summary>
13  internal class SpriteGroupCompiler : ImageGroupCompiler<SpriteGroupAsset, SpriteInfo>
14  {
15  protected override void Compile(AssetCompilerContext context, string urlInStorage, UFile assetAbsolutePath, SpriteGroupAsset asset, AssetCompilerResult result)
16  {
17  base.Compile(context, urlInStorage, assetAbsolutePath, asset, result);
18 
19  if (!result.HasErrors)
20  result.BuildSteps.Add(new SpriteGroupCommand(urlInStorage, new ImageGroupParameters<SpriteGroupAsset>(asset, context.Platform), SpriteToTextureIndex, SeparateAlphaTexture));
21  }
22 
23  internal class SpriteGroupCommand : ImageGroupCommand<SpriteGroupAsset, SpriteInfo, SpriteGroupData, SpriteData>
24  {
25  public SpriteGroupCommand(string url, ImageGroupParameters<SpriteGroupAsset> asset, Dictionary<SpriteInfo, int> imageToTextureIndex, bool separateAlpha)
26  : base(url, asset, imageToTextureIndex, separateAlpha)
27  {
28  }
29 
30  protected override void SetImageSpecificFields(SpriteInfo imageInfo, SpriteData newImage)
31  {
32  base.SetImageSpecificFields(imageInfo, newImage);
33 
34  newImage.Center = imageInfo.Center + (imageInfo.CenterFromMiddle ? +new Vector2(imageInfo.TextureRegion.Width, imageInfo.TextureRegion.Height) / 2 : Vector2.Zero);
35  }
36  }
37  }
38 }
SiliconStudio.Paradox.Games.Mathematics.Vector2 Vector2
Result of a compilation of assets when using IAssetCompiler.Compile
The context used when compiling an asset in a Package.
bool HasErrors
Gets or sets a value indicating whether this instance has errors.
Definition: Logger.cs:46
Data type for SiliconStudio.Paradox.Graphics.Sprite.
Definition: GraphicsData.cs:78
Defines a normalized file path. See UPath for details. This class cannot be inherited.
Definition: UFile.cs:13