Skip to content

Commit

Permalink
Merge pull request FunkinCrew#3 from lemz1/feature/multisparrow-rework
Browse files Browse the repository at this point in the history
Multisparrow Character "Rework"
  • Loading branch information
lemz1 authored Nov 1, 2024
2 parents c113333 + 2ebd681 commit 09abe61
Show file tree
Hide file tree
Showing 37 changed files with 684 additions and 395 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "assets"]
path = assets
url = https://github.com/JustKolosaki/FunkinAssetsContrib/tree/char-creator-ui
url = https://github.com/FunkinCrew/funkin.assets
[submodule "art"]
path = art
url = https://github.com/FunkinCrew/Funkin.art
2 changes: 1 addition & 1 deletion assets
6 changes: 3 additions & 3 deletions source/funkin/InitState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import funkin.data.event.SongEventRegistry;
import funkin.data.stage.StageRegistry;
import funkin.data.story.level.LevelRegistry;
import funkin.modding.module.ModuleHandler;
import funkin.play.character.CharacterData.CharacterDataParser;
import funkin.data.character.CharacterRegistry;
import funkin.play.notes.notekind.NoteKindManager;
import funkin.play.PlayStatePlaylist;
import funkin.ui.debug.charting.ChartEditorState;
Expand Down Expand Up @@ -177,9 +177,9 @@ class InitState extends FlxState
AlbumRegistry.instance.loadEntries();
StageRegistry.instance.loadEntries();

// TODO: CharacterDataParser doesn't use json2object, so it's way slower than the other parsers and more prone to syntax errors.
// TODO: CharacterRegistry doesn't use json2object, so it's way slower than the other parsers and more prone to syntax errors.
// Move it to use a BaseRegistry.
CharacterDataParser.loadCharacterCache();
CharacterRegistry.loadCharacterCache();

NoteKindManager.loadScripts();

Expand Down
10 changes: 0 additions & 10 deletions source/funkin/data/animation/AnimationData.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class AnimationDataUtil
return {
name: name,
prefix: data.prefix,
assetPath: data.assetPath,
offsets: data.offsets,
looped: data.looped,
flipX: data.flipX,
Expand All @@ -21,7 +20,6 @@ class AnimationDataUtil
{
return {
prefix: data.prefix,
assetPath: data.assetPath,
offsets: data.offsets,
looped: data.looped,
flipX: data.flipX,
Expand Down Expand Up @@ -65,14 +63,6 @@ typedef UnnamedAnimationData =
@:optional
var prefix:String;

/**
* Optionally specify an asset path to use for this specific animation.
* ONLY for use by MultiSparrow characters.
* @default The assetPath of the parent sprite
*/
@:optional
var assetPath:Null<String>;

/**
* Offset the character's position by this amount when playing this animation.
* @default [0, 0]
Expand Down
227 changes: 227 additions & 0 deletions source/funkin/data/character/CharacterData.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
package funkin.data.character;

import funkin.data.animation.AnimationData;

/**
* Describes the available rendering types for a character.
*/
enum abstract CharacterRenderType(String) from String to String
{
/**
* Renders the character using a single spritesheet and XML data.
*/
public var Sparrow = 'sparrow';

/**
* Renders the character using a single spritesheet and TXT data.
*/
public var Packer = 'packer';

/**
* Renders the character using multiple spritesheets and XML data.
*/
public var MultiSparrow = 'multisparrow';

/**
* Renders the character using a spritesheet of symbols and JSON data.
*/
public var AnimateAtlas = 'animateatlas';

/**
* Renders the character using a custom method.
*/
public var Custom = 'custom';
}

/**
* The JSON data schema used to define a character.
*/
typedef CharacterData =
{
/**
* The sematic version number of the character data JSON format.
*/
var version:String;

/**
* The readable name of the character.
*/
var name:String;

/**
* The type of rendering system to use for the character.
* @default sparrow
*/
@:optional
@:default('sparrow')
var renderType:CharacterRenderType;

/**
* Behavior varies by render type:
* - SPARROW: Path to retrieve both the spritesheet and the XML data from.
* - PACKER: Path to retrieve both the spritsheet and the TXT data from.
*/
var assetPaths:Array<String>;

/**
* The scale of the graphic as a float.
* Pro tip: On pixel-art levels, save the sprites small and set this value to 6 or so to save memory.
* @default 1
*/
@:optional
@:default(1.0)
var scale:Null<Float>;

/**
* Optional data about the health icon for the character.
*/
@:optional
var healthIcon:Null<HealthIconData>;

@:optional
var death:Null<DeathData>;

/**
* The global offset to the character's position, in pixels.
* @default [0, 0]
*/
@:optional
@:default([0, 0])
var offsets:Null<Array<Float>>;

/**
* The amount to offset the camera by while focusing on this character.
* Default value focuses on the character directly.
* @default [0, 0]
*/
@:optional
@:default([0, 0])
var cameraOffsets:Array<Float>;

/**
* Setting this to true disables anti-aliasing for the character.
* @default false
*/
@:optional
@:default(false)
var isPixel:Null<Bool>;

/**
* The frequency at which the character will play its idle animation, in beats.
* Increasing this number will make the character dance less often.
* Supports up to `0.25` precision.
* @default `1.0` on characters
*/
@:optional
@:default(1.0)
var danceEvery:Null<Float>;

/**
* The minimum duration that a character will play a note animation for, in beats.
* If this number is too low, you may see the character start playing the idle animation between notes.
* If this number is too high, you may see the the character play the sing animation for too long after the notes are gone.
*
* Examples:
* - Daddy Dearest uses a value of `1.525`.
* @default 8.0
*/
@:optional
@:default(8.0)
var singTime:Null<Float>;

/**
* An optional array of animations which the character can play.
*/
var animations:Array<AnimationData>;

/**
* If animations are used, this is the name of the animation to play first.
* @default idle
*/
@:optional
@:default('idle')
var startingAnimation:Null<String>;

/**
* Whether or not the whole ass sprite is flipped by default.
* Useful for characters that could also be played (Pico)
*
* @default false
*/
@:optional
@:default(false)
var flipX:Null<Bool>;
};

/**
* The JSON data schema used to define the health icon for a character.
*/
typedef HealthIconData =
{
/**
* The ID to use for the health icon.
* @default The character's ID
*/
@:optional
var id:Null<String>;

/**
* The scale of the health icon.
*/
@:optional
@:default(1.0)
var scale:Null<Float>;

/**
* Whether to flip the health icon horizontally.
* @default false
*/
@:optional
@:default(false)
var flipX:Null<Bool>;

/**
* Multiply scale by 6 and disable antialiasing
* @default false
*/
@:optional
@:default(false)
var isPixel:Null<Bool>;

/**
* The offset of the health icon, in pixels.
* @default [0, 25]
*/
@:optional
@:default([0, 25])
var offsets:Null<Array<Float>>;
}

typedef DeathData =
{
/**
* The amount to offset the camera by while focusing on this character as they die.
* Default value focuses on the character's graphic midpoint.
* @default [0, 0]
*/
@:optional
@:default([0, 0])
var ?cameraOffsets:Array<Float>;

/**
* The amount to zoom the camera by while focusing on this character as they die.
* Value is a multiplier of the default camera zoom for the stage.
* @default 1.0
*/
@:optional
@:default(1.0)
var ?cameraZoom:Float;

/**
* Impose a delay between when the character reaches `0` health and when the death animation plays.
* @default 0.0
*/
@:optional
@:default(0.0)
var ?preTransitionDelay:Float;
}
Loading

0 comments on commit 09abe61

Please sign in to comment.