CharacterCreateSystem - jimdroberts/FishMMO GitHub Wiki
CharacterCreateSystem
handles character creation requests on the server in FishMMO. It validates input, creates new characters and their initial data, and notifies the client of the result.
-
public WorldSceneDetailsCache WorldSceneDetailsCache
Cached world scene details used for validating spawn positions and initial character creation.
-
public int MaxCharacters
Maximum number of characters allowed per account.
-
public List StartingAbilities
List of ability templates to grant to new characters on creation.
-
public List StartingInventoryItems
List of item templates to add to new characters' inventory on creation.
-
public List StartingEquipment
List of equipment templates to equip on new characters at creation.
-
public override void InitializeOnce()
Initializes the character creation system, registering broadcast handlers for character creation requests.
-
public override void Destroying()
Cleans up the character creation system, unregistering broadcast handlers for character creation requests.
-
private void OnServerCharacterCreateBroadcastReceived(NetworkConnection conn, CharacterCreateBroadcast msg, Channel channel)
Handles broadcast to create a new character, validates input, creates character and initial data, and notifies the client. Parameters: - NetworkConnection conn: Network connection of the client. - CharacterCreateBroadcast msg: Message containing character creation data. - Channel channel: Network channel used for the broadcast.
-
private void AddStartingAbilities(NpgsqlDbContext dbContext, long characterID, List startingAbilities)
Adds starting abilities to the character in the database.
-
private void AddStartingItems(NpgsqlDbContext dbContext, long characterID, List startingItems)
Adds starting items to the character's inventory in the database.
-
private void AddStartingEquipment(NpgsqlDbContext dbContext, long characterID, List startingEquipment, Dictionary<int, CharacterAttributeEntity> initialAttributes)
Adds starting equipment to the character in the database and updates initial attributes.
- Attach
CharacterCreateSystem
to the login server and ensure it is initialized before accepting character creation requests. - The system will automatically handle incoming character creation broadcasts from clients.
- Input is validated and initial character data is created in the database.
// Example 1: Initialization
characterCreateSystem.InitializeOnce();
// Example 2: Cleanup on shutdown
characterCreateSystem.Destroying();
- Always validate character names, race, and spawn positions before creating characters.
- Enforce maximum character limits per account.
- Clean up broadcast handlers on shutdown to prevent resource leaks.
- Use secure and consistent logic for initial character data and equipment.