new version

This commit is contained in:
artem 2024-02-25 10:29:24 +03:00
parent dd3549216b
commit 062daf6743
10 changed files with 571 additions and 479 deletions

133
Cargo.lock generated
View File

@ -333,10 +333,42 @@ dependencies = [
]
[[package]]
name = "cc"
version = "1.0.86"
name = "camino"
version = "1.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f9fa1897e4325be0d68d48df6aa1a71ac2ed4d27723887e7754192705350730"
checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c"
dependencies = [
"serde",
]
[[package]]
name = "cargo-platform"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "694c8807f2ae16faecc43dc17d74b3eb042482789fd0eb64b39a2e04e087053f"
dependencies = [
"serde",
]
[[package]]
name = "cargo_metadata"
version = "0.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037"
dependencies = [
"camino",
"cargo-platform",
"semver",
"serde",
"serde_json",
"thiserror",
]
[[package]]
name = "cc"
version = "1.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3286b845d0fccbdd15af433f61c5970e711987036cb468f437ff6badd70f4e24"
dependencies = [
"libc",
]
@ -950,8 +982,9 @@ dependencies = [
[[package]]
name = "fyrox"
version = "0.33.1"
source = "git+https://github.com/FyroxEngine/Fyrox?branch=0.33.1#64eb12eebbf3fa6382d30ff1c2699f1071bafa8a"
source = "git+https://github.com/FyroxEngine/Fyrox#ba838bdcd4a6cad492984319176d44ac28456ab7"
dependencies = [
"base64",
"bitflags 2.4.2",
"clap",
"ddsfile",
@ -960,6 +993,7 @@ dependencies = [
"fyrox-animation",
"fyrox-core",
"fyrox-core-derive",
"fyrox-graph",
"fyrox-resource",
"fyrox-sound",
"fyrox-ui",
@ -986,7 +1020,7 @@ dependencies = [
[[package]]
name = "fyrox-animation"
version = "0.1.0"
source = "git+https://github.com/FyroxEngine/Fyrox?branch=0.33.1#64eb12eebbf3fa6382d30ff1c2699f1071bafa8a"
source = "git+https://github.com/FyroxEngine/Fyrox#ba838bdcd4a6cad492984319176d44ac28456ab7"
dependencies = [
"fxhash",
"fyrox-core",
@ -998,7 +1032,7 @@ dependencies = [
[[package]]
name = "fyrox-core"
version = "0.27.0"
source = "git+https://github.com/FyroxEngine/Fyrox?branch=0.33.1#64eb12eebbf3fa6382d30ff1c2699f1071bafa8a"
source = "git+https://github.com/FyroxEngine/Fyrox#ba838bdcd4a6cad492984319176d44ac28456ab7"
dependencies = [
"android-activity",
"arrayvec",
@ -1029,7 +1063,7 @@ dependencies = [
[[package]]
name = "fyrox-core-derive"
version = "0.22.0"
source = "git+https://github.com/FyroxEngine/Fyrox?branch=0.33.1#64eb12eebbf3fa6382d30ff1c2699f1071bafa8a"
source = "git+https://github.com/FyroxEngine/Fyrox#ba838bdcd4a6cad492984319176d44ac28456ab7"
dependencies = [
"convert_case",
"darling",
@ -1039,10 +1073,20 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "fyrox-graph"
version = "0.1.0"
source = "git+https://github.com/FyroxEngine/Fyrox#ba838bdcd4a6cad492984319176d44ac28456ab7"
dependencies = [
"fxhash",
"fyrox-core",
"fyrox-resource",
]
[[package]]
name = "fyrox-resource"
version = "0.11.0"
source = "git+https://github.com/FyroxEngine/Fyrox?branch=0.33.1#64eb12eebbf3fa6382d30ff1c2699f1071bafa8a"
source = "git+https://github.com/FyroxEngine/Fyrox#ba838bdcd4a6cad492984319176d44ac28456ab7"
dependencies = [
"fxhash",
"fyrox-core",
@ -1055,7 +1099,7 @@ dependencies = [
[[package]]
name = "fyrox-sound"
version = "0.34.0"
source = "git+https://github.com/FyroxEngine/Fyrox?branch=0.33.1#64eb12eebbf3fa6382d30ff1c2699f1071bafa8a"
source = "git+https://github.com/FyroxEngine/Fyrox#ba838bdcd4a6cad492984319176d44ac28456ab7"
dependencies = [
"fyrox-core",
"fyrox-resource",
@ -1072,12 +1116,14 @@ dependencies = [
[[package]]
name = "fyrox-ui"
version = "0.24.0"
source = "git+https://github.com/FyroxEngine/Fyrox?branch=0.33.1#64eb12eebbf3fa6382d30ff1c2699f1071bafa8a"
source = "git+https://github.com/FyroxEngine/Fyrox#ba838bdcd4a6cad492984319176d44ac28456ab7"
dependencies = [
"copypasta",
"fontdue",
"fxhash",
"fyrox-animation",
"fyrox-core",
"fyrox-graph",
"fyrox-resource",
"lazy_static",
"notify",
@ -1090,14 +1136,16 @@ dependencies = [
[[package]]
name = "fyroxed_base"
version = "0.20.1"
source = "git+https://github.com/FyroxEngine/Fyrox?branch=0.33.1#64eb12eebbf3fa6382d30ff1c2699f1071bafa8a"
source = "git+https://github.com/FyroxEngine/Fyrox#ba838bdcd4a6cad492984319176d44ac28456ab7"
dependencies = [
"cargo_metadata",
"fyrox",
"lazy_static",
"open",
"ron",
"rust-fuzzy-search",
"serde",
"serde_json",
"strum",
"strum_macros",
"toml",
@ -1277,9 +1325,9 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
version = "0.3.6"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd5256b483761cd23699d0da46cc6fd2ee3be420bbe6d020ae4a091e70b7e9fd"
checksum = "379dada1584ad501b383485dd706b8afb7a70fcbc7f4da7d780638a5a6124a60"
[[package]]
name = "hound"
@ -1410,6 +1458,12 @@ dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "jni"
version = "0.21.1"
@ -1765,17 +1819,6 @@ dependencies = [
"serde",
]
[[package]]
name = "num-derive"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "num-derive"
version = "0.4.2"
@ -1978,7 +2021,7 @@ dependencies = [
"downcast-rs",
"either",
"nalgebra",
"num-derive 0.4.2",
"num-derive",
"num-traits",
"rustc-hash",
"simba",
@ -1999,7 +2042,7 @@ dependencies = [
"downcast-rs",
"either",
"nalgebra",
"num-derive 0.4.2",
"num-derive",
"num-traits",
"rustc-hash",
"simba",
@ -2161,9 +2204,9 @@ dependencies = [
[[package]]
name = "rapier2d"
version = "0.17.2"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f94d294a9b96694c14888dd0e8ce77620dcc4f2f49264109ef835fa5e2285b84"
checksum = "48a3ec4ae89e0837c0ff6f29af32a8e5d78dfabe2273dcd945cfaf3f5d2b1501"
dependencies = [
"approx",
"arrayvec",
@ -2172,7 +2215,7 @@ dependencies = [
"crossbeam",
"downcast-rs",
"nalgebra",
"num-derive 0.3.3",
"num-derive",
"num-traits",
"parry2d",
"rustc-hash",
@ -2181,9 +2224,9 @@ dependencies = [
[[package]]
name = "rapier3d"
version = "0.17.2"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62a8a0bd9d3135f7b4eb45d0796540e7bab47b6b7c974f90567ccc5a0454f42b"
checksum = "92d07a833e0aa3bc57010caaa50bf75fa78afc03a74207607db740da4e4579a1"
dependencies = [
"approx",
"arrayvec",
@ -2192,7 +2235,7 @@ dependencies = [
"crossbeam",
"downcast-rs",
"nalgebra",
"num-derive 0.3.3",
"num-derive",
"num-traits",
"parry3d",
"rustc-hash",
@ -2369,6 +2412,12 @@ version = "1.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"
[[package]]
name = "ryu"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
[[package]]
name = "safe_arch"
version = "0.7.1"
@ -2412,6 +2461,15 @@ dependencies = [
"tiny-skia",
]
[[package]]
name = "semver"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca"
dependencies = [
"serde",
]
[[package]]
name = "serde"
version = "1.0.197"
@ -2432,6 +2490,17 @@ dependencies = [
"syn 2.0.50",
]
[[package]]
name = "serde_json"
version = "1.0.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "serde_spanned"
version = "0.6.5"

View File

@ -5,11 +5,9 @@ resolver = "2"
[workspace.dependencies.fyrox]
git = "https://github.com/FyroxEngine/Fyrox"
branch = "0.33.1"
[workspace.dependencies.fyroxed_base]
git = "https://github.com/FyroxEngine/Fyrox"
branch = "0.33.1"
# Optimize the engine in debug builds, but leave project's code non-optimized.
# By using this technique, you can still debug you code, but engine will be fully

View File

@ -12,13 +12,13 @@ export interface InitOutput {
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
readonly __wbindgen_export_2: WebAssembly.Table;
readonly wasm_bindgen__convert__closures__invoke1_mut__h761f80db2261695a: (a: number, b: number, c: number) => void;
readonly wasm_bindgen__convert__closures__invoke0_mut__hbe5d14e2e22b28eb: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures__invoke2_mut__h333a5ce695de4f4b: (a: number, b: number, c: number, d: number) => void;
readonly wasm_bindgen__convert__closures__invoke0_mut__h69a92aefef1d2d58: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures__invoke0_mut__h44bf917093f5f42c: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures__invoke1_mut__h03c4a4a2fd872977: (a: number, b: number, c: number) => void;
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hdb365bceaf562271: (a: number, b: number, c: number) => void;
readonly wasm_bindgen__convert__closures__invoke1_mut__h32b600599eb72778: (a: number, b: number, c: number) => void;
readonly wasm_bindgen__convert__closures__invoke0_mut__h28d66fed9b19a073: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures__invoke2_mut__hbd249abdb70ea846: (a: number, b: number, c: number, d: number) => void;
readonly wasm_bindgen__convert__closures__invoke0_mut__hf5e379825731d4b1: (a: number, b: number) => void;
readonly wasm_bindgen__convert__closures__invoke1_mut__h6fe9617391924dbe: (a: number, b: number, c: number) => void;
readonly wasm_bindgen__convert__closures__invoke0_mut__hcfc201bf4ebeee4e: (a: number, b: number) => void;
readonly _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h75b35f9fba66753d: (a: number, b: number, c: number) => void;
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
readonly __wbindgen_exn_store: (a: number) => void;
}

File diff suppressed because it is too large Load Diff

View File

@ -5,12 +5,12 @@ export function main(): void;
export function __wbindgen_malloc(a: number, b: number): number;
export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
export const __wbindgen_export_2: WebAssembly.Table;
export function wasm_bindgen__convert__closures__invoke1_mut__h761f80db2261695a(a: number, b: number, c: number): void;
export function wasm_bindgen__convert__closures__invoke0_mut__hbe5d14e2e22b28eb(a: number, b: number): void;
export function wasm_bindgen__convert__closures__invoke2_mut__h333a5ce695de4f4b(a: number, b: number, c: number, d: number): void;
export function wasm_bindgen__convert__closures__invoke0_mut__h69a92aefef1d2d58(a: number, b: number): void;
export function wasm_bindgen__convert__closures__invoke0_mut__h44bf917093f5f42c(a: number, b: number): void;
export function wasm_bindgen__convert__closures__invoke1_mut__h03c4a4a2fd872977(a: number, b: number, c: number): void;
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hdb365bceaf562271(a: number, b: number, c: number): void;
export function wasm_bindgen__convert__closures__invoke1_mut__h32b600599eb72778(a: number, b: number, c: number): void;
export function wasm_bindgen__convert__closures__invoke0_mut__h28d66fed9b19a073(a: number, b: number): void;
export function wasm_bindgen__convert__closures__invoke2_mut__hbd249abdb70ea846(a: number, b: number, c: number, d: number): void;
export function wasm_bindgen__convert__closures__invoke0_mut__hf5e379825731d4b1(a: number, b: number): void;
export function wasm_bindgen__convert__closures__invoke1_mut__h6fe9617391924dbe(a: number, b: number, c: number): void;
export function wasm_bindgen__convert__closures__invoke0_mut__hcfc201bf4ebeee4e(a: number, b: number): void;
export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h75b35f9fba66753d(a: number, b: number, c: number): void;
export function __wbindgen_free(a: number, b: number, c: number): void;
export function __wbindgen_exn_store(a: number): void;

View File

@ -52,6 +52,7 @@ pub fn main() {
GraphicsContextParams {
window_attributes,
vsync: true,
msaa_sample_count: Some(1)
},
);
executor.add_plugin_constructor(GameConstructor);

View File

@ -1,6 +1,13 @@
use crate::Player;
use fyrox::graph::SceneGraph;
use fyrox::{
core::{
algebra::{Point2, Vector2, Vector3}, impl_component_provider, pool::Handle, reflect::prelude::*, uuid_provider, visitor::prelude::*
algebra::{Point2, Vector2, Vector3},
impl_component_provider,
pool::Handle,
reflect::prelude::*,
uuid_provider,
visitor::prelude::*,
},
scene::{
animation::spritesheet::SpriteSheetAnimation,
@ -16,8 +23,6 @@ use fyrox::{
script::{ScriptContext, ScriptTrait},
};
use crate::Player;
impl_component_provider!(Enemy,);
uuid_provider!(Enemy = "a5671d19-9f1a-4286-8486-add4ebaadaec");
@ -84,7 +89,7 @@ impl Enemy {
if self.dead {
return false;
}
let self_node = match graph.try_get(self.handle) {
let self_node = match graph.try_get_mut(self.handle) {
Some(node) => node,
None => return false,
};
@ -131,19 +136,19 @@ impl Enemy {
return None;
}
// Get *this* node instance
let self_node = match graph.try_get(self.handle) {
let self_node = match graph.try_get_mut(self.handle) {
Some(node) => node,
None => return None,
};
let self_position = self_node.global_position();
// Get the player node
let player_node = match graph.try_get(self.player_handle) {
let player_node = match graph.try_get_mut(self.player_handle) {
Some(node) => node,
None => return None,
};
// Get the current position of *this* node and the player node
let self_position = self_node.global_position();
let player_position = player_node.global_position();
// Calculate the direction vector from *this* node to the player node
@ -182,7 +187,11 @@ impl Enemy {
if !self.fight {
return;
}
match ctx.scene.graph.try_get_script_of_mut::<Player>(self.player_handle) {
match ctx
.scene
.graph
.try_get_script_of_mut::<Player>(self.player_handle)
{
Some(script) => {
if script.get_health() <= 0.0 {
self.fight = false;
@ -198,19 +207,15 @@ impl Enemy {
}
fn distance_to_player(&self, context: &mut ScriptContext) -> f32 {
let mut graph_ctx = context.scene.graph.begin_multi_borrow::<2>();
let enemy_rigid_body = graph_ctx
.try_get(context.handle)
.unwrap()
.cast_mut::<RigidBody>();
let graph_ctx = context.scene.graph.begin_multi_borrow();
let enemy_binding = graph_ctx.try_get(context.handle).unwrap();
let enemy_rigid_body = enemy_binding.cast::<RigidBody>();
let enemy_rigid_data = match enemy_rigid_body {
Some(rigid_data) => rigid_data,
None => return 0.0,
};
let player_rigid_body = graph_ctx
.try_get(self.player_handle)
.unwrap()
.cast_mut::<RigidBody>();
let player_binding = graph_ctx.try_get(self.player_handle).unwrap();
let player_rigid_body = player_binding.cast::<RigidBody>();
let player_rigid_data = match player_rigid_body {
Some(rigid_body) => rigid_body,
None => return 0.0,
@ -357,27 +362,29 @@ impl Enemy {
let current_animation = self.animations.get_mut(cur_anim);
match current_animation {
Some(animation_data) => {
let mut graph_ctx = context.scene.graph.begin_multi_borrow::<2>();
let enemy_rigid_data = match graph_ctx.try_get(context.handle) {
Some(rigid_body) => rigid_body,
None => return,
};
for child in enemy_rigid_data.children().iter() {
if let Some(enemy) = graph_ctx.try_get(*child) {
if !enemy.is_rectangle() {
continue;
{
let graph_ctx = context.scene.graph.begin_multi_borrow();
let enemy_rigid_data = match graph_ctx.try_get(context.handle) {
Ok(rigid_body) => rigid_body,
Err(_) => return,
};
for child in enemy_rigid_data.children().iter() {
if let Ok(mut enemy) = graph_ctx.try_get_mut(*child) {
if !enemy.is_rectangle() {
continue;
}
let sprite: &mut Rectangle = enemy.cast_mut::<Rectangle>().unwrap();
animation_data.update(context.dt);
sprite
.material()
.data_ref()
.set_texture(&"diffuseTexture".into(), animation_data.texture())
.unwrap();
sprite.set_uv_rect(
animation_data.current_frame_uv_rect().unwrap_or_default(),
);
break;
}
let sprite = enemy.cast_mut::<Rectangle>().unwrap();
animation_data.update(context.dt);
sprite
.material()
.data_ref()
.set_texture(&"diffuseTexture".into(), animation_data.texture())
.unwrap();
sprite.set_uv_rect(
animation_data.current_frame_uv_rect().unwrap_or_default(),
);
break;
}
}

View File

@ -11,8 +11,9 @@ use fyrox::{
UiNode, UserInterface,
},
plugin::{Plugin, PluginConstructor, PluginContext, PluginRegistrationContext},
scene::{graph::Graph, Scene},
scene::{graph::Graph, Scene,},
};
use fyrox::graph::SceneGraph;
use std::path::Path;
mod enemy;
mod enemy_spawn;
@ -55,8 +56,8 @@ impl Game {
|result, game: &mut Game, ctx| match result {
Ok(menu) => {
*ctx.user_interface = menu;
game.new_game = ctx.user_interface.find_by_name_down_from_root("NewGame");
game.exit = ctx.user_interface.find_by_name_down_from_root("Exit");
(game.new_game, _) = ctx.user_interface.find_by_name_from_root("NewGame").unwrap();
(game.exit, _) = ctx.user_interface.find_by_name_from_root("Exit").unwrap();
}
Err(e) => Log::err(format!("Unable to load main menu! Reason: {:?}", e)),
// let ui = ctx.user_interface.clone();

View File

@ -2,6 +2,7 @@ use std::collections::VecDeque;
use crate::msg::Message;
use crate::Enemy;
use fyrox::graph::BaseSceneGraph;
use fyrox::{
core::{
algebra::{Point2, Vector2, Vector3},
@ -321,7 +322,7 @@ impl Player {
if !self.fight {
return;
}
let self_node = match context.scene.graph.try_get(context.handle) {
let self_node = match context.scene.graph.try_get_mut(context.handle) {
Some(node) => node,
None => return,
};
@ -352,11 +353,15 @@ impl Player {
if buffer[i].toi == 0.0 {
continue;
}
if let Some(d) = context.scene.graph.try_get(buffer[i].collider) {
let mut parent: Option<Handle<Node>> = None;
if let Some(d) = context.scene.graph.try_get_mut(buffer[i].collider) {
parent = Some(d.parent());
}
if let Some(d) = parent {
match context
.scene
.graph
.try_get_script_of_mut::<Enemy>(d.parent())
.try_get_script_of_mut::<Enemy>(d)
{
Some(script) => {
script.take_damage(&self.damage);