aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
author1992414357@qq.com <1992414357@qq.com>2025-06-18 02:52:12 +0800
committer1992414357@qq.com <1992414357@qq.com>2025-06-18 02:52:12 +0800
commit768e2d50fdbf8a2de8b57e7363cf26d95dbdc015 (patch)
treeea4c3f8f5d2683765642dd53c133b859bd280ac3 /core/src
parent37f6816105f165610eca06432b798f99f9d4325a (diff)
Finished CBindings
Diffstat (limited to 'core/src')
-rw-r--r--core/src/data/controller/controller_data.rs11
-rw-r--r--core/src/data/game/game_data.rs6
2 files changed, 16 insertions, 1 deletions
diff --git a/core/src/data/controller/controller_data.rs b/core/src/data/controller/controller_data.rs
index a3f1c02..a40f49c 100644
--- a/core/src/data/controller/controller_data.rs
+++ b/core/src/data/controller/controller_data.rs
@@ -4,7 +4,7 @@ use crate::data::player::player_data::Player;
/// Controller-side Data
/// Describes the basic information of the controller side
-#[derive(Default)]
+#[derive(Default, Clone)]
pub struct ControllerData {
/// Player bound to the controller side
@@ -26,4 +26,13 @@ impl ControllerData {
};
Arc::new(Mutex::new(runtime))
}
+
+ /// Build the controller-side runtime using controller data (borrowed)
+ pub fn runtime_with_borrowed_data(&self) -> Arc<Mutex<ControllerRuntime>> {
+ let runtime = ControllerRuntime {
+ player: self.player.clone(),
+ ..Default::default()
+ };
+ Arc::new(Mutex::new(runtime))
+ }
} \ No newline at end of file
diff --git a/core/src/data/game/game_data.rs b/core/src/data/game/game_data.rs
index 35a5c0e..bc198df 100644
--- a/core/src/data/game/game_data.rs
+++ b/core/src/data/game/game_data.rs
@@ -91,6 +91,12 @@ impl GameData {
};
Arc::new(Mutex::new(runtime))
}
+
+ /// Build the game-side runtime using game data (borrowed)
+ pub fn runtime_with_borrowed_data(&self) -> Arc<Mutex<GameRuntime>> {
+ let runtime = self.clone().runtime();
+ runtime
+ }
}
impl From<GameRuntimeDataArchive> for GameRuntimeData {