diff options
| author | 1992414357@qq.com <1992414357@qq.com> | 2025-06-09 01:44:36 +0800 |
|---|---|---|
| committer | 1992414357@qq.com <1992414357@qq.com> | 2025-06-09 01:44:36 +0800 |
| commit | 49192dbb98e0ab1f2a66b4786fac86d63f69be64 (patch) | |
| tree | 7cdf27c7cab5fb6b1aabc2ac7c44b7b492558945 /core/src/data/player/structs.rs | |
| parent | c9dbba0d288becb7f05cebe526be25c76e5a850a (diff) | |
重构所有部分
Diffstat (limited to 'core/src/data/player/structs.rs')
| -rw-r--r-- | core/src/data/player/structs.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/core/src/data/player/structs.rs b/core/src/data/player/structs.rs new file mode 100644 index 0000000..cc3d7c9 --- /dev/null +++ b/core/src/data/player/structs.rs @@ -0,0 +1,45 @@ +use bincode::{Decode, Encode}; +use serde::{Deserialize, Serialize}; +use std::hash::{Hash}; + +/// Player information +/// Describes a player's specific details, which are frequently exchanged between the controller and game pad_client. +#[derive(Default, Clone, Encode, Decode, Serialize, Deserialize, Debug)] +pub struct Player { + + /// Account information + pub account: Account, + + /// Custom information (Optional) + pub customize: Option<Customize> +} + +/// Account information +/// Essential data for verifying player uniqueness, including the player's hash value and account ID. +#[derive(Default, Clone, Encode, Decode, Serialize, Deserialize, Eq, Hash, PartialEq, Debug)] +pub struct Account { + + /// Player name stored in data, allowing only lowercase letters and underscores + pub id: String, + + /// Player hash value proving player uniqueness + pub player_hash: String +} + +/// Custom information +/// Describes personalized player details displayed in-game, such as name, color, or other customizations. +#[derive(Default, Clone, Encode, Decode, Serialize, Deserialize, PartialEq, Debug)] +pub struct Customize { + + /// Player name displayed in the game + pub nickname: String, + + /// HSV Color - Hue (Range: 0 - 360) + pub color_hue: i32, + + /// HSV Color - Saturation (Range: 0 - 1) + pub color_saturation: f64, + + /// HSV Color - Value (Range: 0 - 1) + pub color_value: f64 +}
\ No newline at end of file |
