The sprite system currently works by splitting an entire character's spritesheet into separate pieces called **vanity items**. These items are created by each vanity factory ([example](https://gitlab.engr.ship.edu/merlin/freshmanrpgsuite/-/blob/main/FreshmanRPG/GameClient/src/main/java/view/player/PlayerHatFactory.java)), then added as actors to the worldstage and moved individually each time the player moves.
# Layering
Since all the sprites are rendered as separate pieces, they must be layered in the game world in a specific order so they show up correct. For example, when facing north a character's hat should appear behind them and their hair below the hat. However, when facing south, the opposite should occur. This problem is solved in the system by a comparable function in [Vanity](https://gitlab.engr.ship.edu/merlin/freshmanrpgsuite/-/blob/main/FreshmanRPG/GameClient/src/main/java/view/player/Vanity.java) which uses the order of vanities in the [Direction](https://gitlab.engr.ship.edu/merlin/freshmanrpgsuite/-/blob/main/FreshmanRPG/GameClient/src/main/java/view/player/Direction.java) enum to order them in the worldstage.
# PlayerSprite and Vanity relationship
PlayerSprite is a class that holds each and every vanity the player is currently wearing, holds general information about the player's current facing, position, etc, and allows the vanity items to be controlled as a whole, rather than individual pieces. This functionality is most useful for teleportation or for gathering quick information about the player's sprites without having to know about each vanity item.
# How Vanity Items Are Stored
Vanity items are stored in multiple different formats. The player can own a wide variety of vanity items, but may not have them all equipped at that time, so those items must be stored in the player's inventory table in the database. There is also a table for vanity items that are only obtainable from the shop, allowing the player to buy these items and add them to their inventory. Lastly, there is another table for vanity items that are obtainable from quests or other means.