Moved AnimationData into the data package

This commit is contained in:
EliteMasterEric 2023-07-13 20:25:01 -04:00
parent 70584c6e88
commit 883ab87931
7 changed files with 56 additions and 5 deletions

View file

@ -1,14 +1,60 @@
package funkin.play; package funkin.data.animation;
class AnimationDataUtil
{
public static function toNamed(data:UnnamedAnimationData, ?name:String = ""):AnimationData
{
return {
name: name,
prefix: data.prefix,
assetPath: data.assetPath,
offsets: data.offsets,
looped: data.looped,
flipX: data.flipX,
flipY: data.flipY,
frameRate: data.frameRate,
frameIndices: data.frameIndices
};
}
public static function toUnnamed(data:AnimationData):UnnamedAnimationData
{
return {
prefix: data.prefix,
assetPath: data.assetPath,
offsets: data.offsets,
looped: data.looped,
flipX: data.flipX,
flipY: data.flipY,
frameRate: data.frameRate,
frameIndices: data.frameIndices
};
}
}
/**
* A data structure representing an animation in a spritesheet.
* This is a generic data structure used by characters, stage props, and more!
* BE CAREFUL when changing it.
*/
typedef AnimationData = typedef AnimationData =
{ {
> UnnamedAnimationData,
/** /**
* The name for the animation. * The name for the animation.
* This should match the animation name queried by the game; * This should match the animation name queried by the game;
* for example, characters need animations with names `idle`, `singDOWN`, `singUPmiss`, etc. * for example, characters need animations with names `idle`, `singDOWN`, `singUPmiss`, etc.
*/ */
var name:String; var name:String;
}
/**
* A data structure representing an animation in a spritesheet.
* This animation doesn't specify a name, that's presumably specified by the parent data structure.
*/
typedef UnnamedAnimationData =
{
/** /**
* The prefix for the frames of the animation as defined by the XML file. * The prefix for the frames of the animation as defined by the XML file.
* This will may or may not differ from the `name` of the animation, * This will may or may not differ from the `name` of the animation,

View file

@ -1,6 +1,6 @@
package funkin.data.level; package funkin.data.level;
import funkin.play.AnimationData; import funkin.data.animation.AnimationData;
/** /**
* A type definition for the data in a story mode level JSON file. * A type definition for the data in a story mode level JSON file.

View file

@ -1,5 +1,6 @@
package funkin.play.character; package funkin.play.character;
import funkin.data.animation.AnimationData;
import funkin.modding.events.ScriptEvent; import funkin.modding.events.ScriptEvent;
import funkin.modding.events.ScriptEventDispatcher; import funkin.modding.events.ScriptEventDispatcher;
import funkin.play.character.ScriptedCharacter.ScriptedAnimateAtlasCharacter; import funkin.play.character.ScriptedCharacter.ScriptedAnimateAtlasCharacter;

View file

@ -1,5 +1,6 @@
package funkin.play.cutscene.dialogue; package funkin.play.cutscene.dialogue;
import funkin.data.animation.AnimationData;
import funkin.util.SerializerUtil; import funkin.util.SerializerUtil;
/** /**

View file

@ -1,5 +1,7 @@
package funkin.play.cutscene.dialogue; package funkin.play.cutscene.dialogue;
import funkin.data.animation.AnimationData;
/** /**
* Data about a conversation. * Data about a conversation.
* Includes what speakers are in the conversation, and what phrases they say. * Includes what speakers are in the conversation, and what phrases they say.

View file

@ -1,5 +1,6 @@
package funkin.play.stage; package funkin.play.stage;
import funkin.data.animation.AnimationData;
import flixel.util.typeLimit.OneOfTwo; import flixel.util.typeLimit.OneOfTwo;
import funkin.play.stage.ScriptedStage; import funkin.play.stage.ScriptedStage;
import funkin.play.stage.Stage; import funkin.play.stage.Stage;

View file

@ -2,12 +2,12 @@ package funkin.util.assets;
import flixel.FlxSprite; import flixel.FlxSprite;
import flixel.graphics.frames.FlxFramesCollection; import flixel.graphics.frames.FlxFramesCollection;
import funkin.play.AnimationData; import funkin.data.animation.AnimationData;
class FlxAnimationUtil class FlxAnimationUtil
{ {
/** /**
* Properly adds an animation to a sprite based on JSON data. * Properly adds an animation to a sprite based on the provided animation data.
*/ */
public static function addAtlasAnimation(target:FlxSprite, anim:AnimationData) public static function addAtlasAnimation(target:FlxSprite, anim:AnimationData)
{ {
@ -31,7 +31,7 @@ class FlxAnimationUtil
} }
/** /**
* Properly adds multiple animations to a sprite based on JSON data. * Properly adds multiple animations to a sprite based on the provided animation data.
*/ */
public static function addAtlasAnimations(target:FlxSprite, animations:Array<AnimationData>) public static function addAtlasAnimations(target:FlxSprite, animations:Array<AnimationData>)
{ {