mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-23 13:48:23 +00:00
Data driven char select grid positions
This commit is contained in:
parent
16a6dba9df
commit
7e39687994
|
@ -38,6 +38,12 @@ class PlayerData
|
|||
@:optional
|
||||
public var freeplayDJ:Null<PlayerFreeplayDJData> = null;
|
||||
|
||||
/**
|
||||
* Data for displaying this character in the Character Select menu.
|
||||
* If null, exclude from Character Select.
|
||||
*/
|
||||
@:optional
|
||||
public var charSelect:Null<PlayerCharSelectData> = null;
|
||||
|
||||
/**
|
||||
* Data for displaying this character in the results screen.
|
||||
|
@ -233,6 +239,18 @@ class PlayerFreeplayDJData
|
|||
}
|
||||
}
|
||||
|
||||
class PlayerCharSelectData
|
||||
{
|
||||
/**
|
||||
* A zero-indexed number for the character's preferred position in the grid.
|
||||
* 0 = top left, 4 = center, 8 = bottom right
|
||||
* In the event of a conflict, the first character alphabetically gets it,
|
||||
* and others get shifted over.
|
||||
*/
|
||||
@:optional
|
||||
public var position:Null<Int>;
|
||||
}
|
||||
|
||||
typedef PlayerResultsData =
|
||||
{
|
||||
var perfect:Array<PlayerResultsAnimationData>;
|
||||
|
|
|
@ -67,8 +67,29 @@ class CharSelectSubState extends MusicBeatSubState
|
|||
{
|
||||
super();
|
||||
|
||||
availableChars.set(4, "bf");
|
||||
availableChars.set(3, "pico");
|
||||
loadAvailableCharacters();
|
||||
}
|
||||
|
||||
function loadAvailableCharacters():Void
|
||||
{
|
||||
var playerIds:Array<String> = PlayerRegistry.instance.listEntryIds();
|
||||
|
||||
for (playerId in playerIds)
|
||||
{
|
||||
var player:Null<PlayableCharacter> = PlayerRegistry.instance.fetchEntry(playerId);
|
||||
if (player == null) continue;
|
||||
var playerData = player.getCharSelectData();
|
||||
if (playerData == null) continue;
|
||||
|
||||
var targetPosition:Int = playerData.position ?? 0;
|
||||
while (availableChars.exists(targetPosition))
|
||||
{
|
||||
targetPosition += 1;
|
||||
}
|
||||
|
||||
trace('Placing player ${playerId} at position ${targetPosition}');
|
||||
availableChars.set(targetPosition, playerId);
|
||||
}
|
||||
}
|
||||
|
||||
override public function create():Void
|
||||
|
|
|
@ -88,6 +88,11 @@ class PlayableCharacter implements IRegistryEntry<PlayerData>
|
|||
return _data.freeplayDJ.getFreeplayDJText(index);
|
||||
}
|
||||
|
||||
public function getCharSelectData():PlayerCharSelectData
|
||||
{
|
||||
return _data.charSelect;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rank Which rank to get info for
|
||||
* @return An array of animations. For example, BF Great has two animations, one for BF and one for GF
|
||||
|
|
Loading…
Reference in a new issue