Skip to content

Commit 616ab7e

Browse files
committed
workspace improvements + support more platforms for hot reloading
1 parent df111b3 commit 616ab7e

File tree

10 files changed

+47
-61
lines changed

10 files changed

+47
-61
lines changed

Cargo.toml

+11
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,21 @@
22
members = ["editor", "executor", "game", "executor-wasm", "game-dylib"]
33
resolver = "2"
44

5+
# Separate build profiles for hot reloading. These profiles ensures that build artifacts for
6+
# hot reloading will be placed into their own folders and does not interfere with standard (static)
7+
# linking.
8+
[profile.dev-hot-reload]
9+
inherits = "dev"
10+
[profile.release-hot-reload]
11+
inherits = "release"
12+
513
[profile.dev.package."*"]
614
opt-level = 3
715

816
[workspace.dependencies.fyrox]
917
path = "../Fyrox/fyrox"
18+
default-features = false
1019
[workspace.dependencies.fyroxed_base]
1120
path = "../Fyrox/editor"
21+
default-features = false
22+

data/maps/drake.rgs

0 Bytes
Binary file not shown.

editor/Cargo.toml

+4-6
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
fish_fall = { path = "../game",optional = true }
7+
fish_fall = { path = "../game", optional = true }
88

99
[dependencies.fyroxed_base]
10-
version = "0.20.1"
11-
path = "../../Fyrox/editor"
12-
features = ["dylib_engine"]
10+
workspace = true
1311

1412
[features]
15-
default = ["fish_fall"]
16-
dylib = []
13+
default = ["fish_fall", "fyroxed_base/default"]
14+
dylib = ["fyroxed_base/dylib_engine"]

editor/src/main.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,20 @@ fn main() {
1010
}));
1111

1212
#[cfg(feature = "dylib")]
13-
editor
14-
.add_dynamic_plugin(
15-
// TODO: Windows-only
16-
"fish_fall_dylib.dll",
17-
true,
18-
true,
19-
)
20-
.unwrap();
13+
{
14+
#[cfg(target_os = "windows")]
15+
let file_name = "game_dylib.dll";
16+
#[cfg(target_os = "linux")]
17+
let file_name = "libgame_dylib.so";
18+
#[cfg(target_os = "macos")]
19+
let file_name = "libgame_dylib.dylib";
20+
editor.add_dynamic_plugin(file_name, true, true).unwrap();
21+
}
2122

2223
#[cfg(not(feature = "dylib"))]
2324
{
2425
use fish_fall::Game;
25-
editor.add_plugin(Game::new());
26+
editor.add_game_plugin(Game::new());
2627
}
2728

2829
editor.run(event_loop)

executor/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ edition = "2021"
66
[dependencies]
77
fyrox = { version = "0.33.1", path = "../../Fyrox/fyrox", default-features = false, features = ["dylib"] }
88
fish_fall = { path = "../game", optional = true }
9-
fish_fall_dylib = { path = "../game-dylib", optional = true }
9+
game_dylib = { path = "../game-dylib", optional = true }
1010

1111
[features]
1212
default = ["fish_fall"]
13-
dylib = ["fish_fall_dylib"]
13+
dylib = ["game_dylib"]

executor/src/main.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ fn main() {
1919
);
2020

2121
#[cfg(feature = "dylib")]
22-
executor
23-
.add_dynamic_plugin(
24-
// TODO: Windows-only
25-
"fish_fall_dylib.dll",
26-
true,
27-
true,
28-
)
29-
.unwrap();
22+
{
23+
#[cfg(target_os = "windows")]
24+
let file_name = "game_dylib.dll";
25+
#[cfg(target_os = "linux")]
26+
let file_name = "libgame_dylib.so";
27+
#[cfg(target_os = "macos")]
28+
let file_name = "libgame_dylib.dylib";
29+
executor.add_dynamic_plugin(file_name, true, true).unwrap();
30+
}
3031

3132
#[cfg(not(feature = "dylib"))]
3233
{

game-dylib/Cargo.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
[package]
2-
name = "fish_fall_dylib"
2+
name = "game_dylib"
33
version = "0.1.0"
44
edition = "2021"
55

66
[lib]
77
crate-type = ["cdylib"]
88

99
[dependencies]
10-
fish_fall = { path = "../game" }
10+
fish_fall = { path = "../game", default-features = false }
11+
12+
[features]
13+
default = ["fish_fall/default"]
14+
dylib-engine = ["fish_fall/dylib-engine"]

game/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ strum_macros = "0.26.1"
99
serde = { version = "1.0.174", features = ["derive"] }
1010
walkdir = "2.4.0"
1111
ron = "0.8.1"
12-
fyrox = { version = "0.33.1", path = "../../Fyrox/fyrox", default-features = false, features = ["dylib"] }
12+
fyrox = { workspace = true }
13+
14+
[features]
15+
default = ["fyrox/default"]
16+
dylib-engine = ["fyrox/dylib"]

game/src/player.rs

-31
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
//! Main player (host) script.
22
33
use crate::actor::ActorKind;
4-
use crate::net::{InstanceDescriptor, ServerMessage};
54
use crate::{
65
actor::{Actor, ActorMessage},
76
net::ClientMessage,
87
CameraController, Event, Game,
98
};
10-
use fyrox::core::futures::executor::block_on;
11-
use fyrox::resource::model::{Model, ModelResourceExtension};
129
use fyrox::{
1310
core::{
1411
algebra::{UnitQuaternion, Vector3},
@@ -206,33 +203,6 @@ impl ScriptTrait for Player {
206203
return;
207204
}
208205

209-
// Spawn a ball on left mouse button click.
210-
if let Event::WindowEvent { event, .. } = event {
211-
if let WindowEvent::MouseInput { button, state, .. } = event {
212-
if *button == MouseButton::Left && *state == ElementState::Pressed {
213-
if let Some(server) = game.server.as_mut() {
214-
if let Ok(ball_prefab) = block_on(
215-
ctx.resource_manager
216-
.request::<Model>("data/models/cannon_ball.rgs"),
217-
) {
218-
let rigid_body = &ctx.scene.graph[self.actor.rigid_body];
219-
let forward_vec = rigid_body.look_vector();
220-
let self_position = rigid_body.global_position();
221-
server.broadcast_message_to_clients(ServerMessage::Instantiate(vec![
222-
InstanceDescriptor {
223-
path: ball_prefab.kind().path().unwrap().to_path_buf(),
224-
position: self_position + forward_vec,
225-
rotation: Default::default(),
226-
velocity: Default::default(),
227-
ids: ball_prefab.generate_ids(),
228-
},
229-
]));
230-
}
231-
}
232-
}
233-
}
234-
}
235-
236206
let this = &ctx.scene.graph[ctx.handle];
237207
if self.input_controller.on_os_event(
238208
event,
@@ -376,7 +346,6 @@ impl ScriptTrait for Player {
376346

377347
ctx.scene.graph[self.model]
378348
.local_transform_mut()
379-
.set_scale(Vector3::repeat(0.01))
380349
.set_rotation(UnitQuaternion::from_axis_angle(
381350
&Vector3::y_axis(),
382351
180.0f32.to_radians() + self.model_angle.angle(),

game/src/trigger.rs

-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ pub enum Action {
3232
#[visit(optional)]
3333
pub struct Trigger {
3434
action: InheritableVariable<Action>,
35-
lulw: i32,
36-
azaza: i32,
3735
}
3836

3937
impl ScriptTrait for Trigger {

0 commit comments

Comments
 (0)