* Added preferences backend * Gender -> Sex * ClientPreferencesManager properties * Username validation * Fixed client init * WIP db * Actually working sqlite db * Dropped shitty sqlite libraries, dropped DbUp, added MigrationManager * Added profile deletion, test * Docs, sanity, tests, cleanup * Cleaned up profile and appearance, fixed running on .net core Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
55 lines
1.5 KiB
C#
55 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Robust.Shared.Interfaces.Serialization;
|
|
using Robust.Shared.Serialization;
|
|
|
|
namespace Content.Shared.Preferences
|
|
{
|
|
/// <summary>
|
|
/// Contains all player characters and the index of the currently selected character.
|
|
/// Serialized both over the network and to disk.
|
|
/// </summary>
|
|
[Serializable, NetSerializable]
|
|
public class PlayerPreferences
|
|
{
|
|
public static PlayerPreferences Default()
|
|
{
|
|
return new PlayerPreferences
|
|
{
|
|
Characters = new List<ICharacterProfile>
|
|
{
|
|
HumanoidCharacterProfile.Default()
|
|
},
|
|
SelectedCharacterIndex = 0
|
|
};
|
|
}
|
|
|
|
private List<ICharacterProfile> _characters;
|
|
private int _selectedCharacterIndex;
|
|
|
|
/// <summary>
|
|
/// All player characters.
|
|
/// </summary>
|
|
public List<ICharacterProfile> Characters
|
|
{
|
|
get => _characters;
|
|
set => _characters = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Index of the currently selected character.
|
|
/// </summary>
|
|
public int SelectedCharacterIndex
|
|
{
|
|
get => _selectedCharacterIndex;
|
|
set => _selectedCharacterIndex = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Retrieves the currently selected character.
|
|
/// </summary>
|
|
public ICharacterProfile SelectedCharacter => Characters.ElementAtOrDefault(SelectedCharacterIndex);
|
|
}
|
|
}
|