diff options
| author | 1992414357@qq.com <1992414357@qq.com> | 2025-06-11 19:14:04 +0800 |
|---|---|---|
| committer | 1992414357@qq.com <1992414357@qq.com> | 2025-06-11 19:14:04 +0800 |
| commit | 9e48af01ae56fe813869ada24de291ab98b361e2 (patch) | |
| tree | 82b56adecbeb260ebbf2c512d78fe2d63805eb36 /core/src/data/controller/controller_data.rs | |
| parent | aa326e69b18a4390ffbc97268eaec4793761f083 (diff) | |
组合模块中 structs.rs 和 implements.rs 文件
Diffstat (limited to 'core/src/data/controller/controller_data.rs')
| -rw-r--r-- | core/src/data/controller/controller_data.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/core/src/data/controller/controller_data.rs b/core/src/data/controller/controller_data.rs new file mode 100644 index 0000000..a3f1c02 --- /dev/null +++ b/core/src/data/controller/controller_data.rs @@ -0,0 +1,29 @@ +use std::sync::{Arc, Mutex}; +use crate::data::controller::controller_runtime::ControllerRuntime; +use crate::data::player::player_data::Player; + +/// Controller-side Data +/// Describes the basic information of the controller side +#[derive(Default)] +pub struct ControllerData { + + /// Player bound to the controller side + pub(crate) player: Player +} + +impl ControllerData { + + pub fn bind_player(&mut self, player: Player) -> &mut ControllerData { + self.player = player; + self + } + + /// Build the controller-side runtime using controller data + pub fn runtime(self) -> Arc<Mutex<ControllerRuntime>> { + let runtime = ControllerRuntime { + player: self.player, + ..Default::default() + }; + Arc::new(Mutex::new(runtime)) + } +}
\ No newline at end of file |
