Class GorgonV1AnimationCodec
A codec used to import sprite animations from version 1 of Gorgon.
Inherited Members
Namespace: Gorgon.IO
Assembly: Gorgon.IO.Gorgon2D.dll
Syntax
public class GorgonV1AnimationCodec : GorgonAnimationCodecCommon, IGorgonAnimationCodec, IGorgonNamedObject
Constructors
| Edit this page View SourceGorgonV1AnimationCodec(Gorgon2D)
Initializes a new instance of the GorgonV1AnimationCodec class.
Declaration
public GorgonV1AnimationCodec(Gorgon2D renderer)
Parameters
Type | Name | Description |
---|---|---|
Gorgon2D | renderer | The renderer used for resource handling. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
Properties
| Edit this page View SourceCanDecode
Property to return whether or not the codec can decode animation data.
Declaration
public override bool CanDecode { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceCanEncode
Property to return whether or not the codec can encode animation data.
Declaration
public override bool CanEncode { get; }
Property Value
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceVersion
Property to return the version of animation data that the codec supports.
Declaration
public override Version Version { get; }
Property Value
Type | Description |
---|---|
Version |
Overrides
Methods
| Edit this page View SourceAllFromFile(string)
Function to read all animations from a file if it contains more than one.
Declaration
public IReadOnlyList<IGorgonAnimation> AllFromFile(string filePath)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | The path to the file to read. |
Returns
Type | Description |
---|---|
IReadOnlyList<IGorgonAnimation> | A list of IGorgonAnimation objects. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentEmptyException | Thrown when the |
AllFromStream(Stream, int?)
Function to read all animations from a stream if it contains more than one.
Declaration
public IReadOnlyList<IGorgonAnimation> AllFromStream(Stream stream, int? byteCount = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream containing the animation. |
int? | byteCount | [Optional] The number of bytes to read from the stream. |
Returns
Type | Description |
---|---|
IReadOnlyList<IGorgonAnimation> | A list of IGorgonAnimation objects. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
GorgonException | Thrown if the |
EndOfStreamException | Thrown if the current |
GetAnimationCount(Stream)
Function to determine the number of animations in the sprite.
Declaration
public int GetAnimationCount(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream containing the sprite data. |
Returns
Type | Description |
---|---|
int | The number of animations in the sprite. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
GorgonException | Thrown if the |
EndOfStreamException | Thrown if the current |
OnGetAssociatedTextureNames(Stream)
Function to retrieve the names of the associated textures.
Declaration
protected override IReadOnlyList<string> OnGetAssociatedTextureNames(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream containing the texture data. |
Returns
Type | Description |
---|---|
IReadOnlyList<string> | The names of the texture associated with the animations, or an empty list if no textures were found. |
Overrides
Remarks
This implementation does not do anything.
OnIsReadable(Stream)
Function to determine if the data in a stream is readable by this codec.
Declaration
protected override bool OnIsReadable(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream containing the data. |
Returns
Type | Description |
---|---|
bool | true if the data can be read, or false if not. |
Overrides
| Edit this page View SourceOnReadFromStream(string, Stream, int, IEnumerable<GorgonTexture2DView>)
Function to read the animation data from a stream.
Declaration
protected override IGorgonAnimation OnReadFromStream(string name, Stream stream, int byteCount, IEnumerable<GorgonTexture2DView> textureOverrides)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the animation. |
Stream | stream | The stream containing the animation. |
int | byteCount | The number of bytes to read from the stream. |
IEnumerable<GorgonTexture2DView> | textureOverrides | [Optional] Textures to use in a texture animation track. |
Returns
Type | Description |
---|---|
IGorgonAnimation | A new IGorgonAnimation. |
Overrides
Remarks
Implementors should handle the textureOverrides
parameter by matching the textures by name, and, if the texture is not found in the override list, fall back to whatever scheme
is used to retrieve the texture for codec.
OnSaveToStream(IGorgonAnimation, Stream)
Function to save the animation data to a stream.
Declaration
protected override void OnSaveToStream(IGorgonAnimation animation, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
IGorgonAnimation | animation | The animation to serialize into the stream. |
Stream | stream | The stream that will contain the animation. |