Skip to content

Commit

Permalink
Implement other monsters
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanRJohnston committed Feb 28, 2024
1 parent ca2cc6b commit a7e7111
Show file tree
Hide file tree
Showing 28 changed files with 409 additions and 352 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ opt-level = 3
[profile.release]
lto = true
opt-level = 's'
strip = true

[[workspace.metadata.leptos]]
name = "deep-space-derby"
Expand Down
34 changes: 34 additions & 0 deletions assets/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -9112,6 +9112,21 @@
"type": "int",
"typeInfo": "Value"
},
"simulation::plugins::monster::Monster": {
"isComponent": false,
"isResource": false,
"oneOf": [
"Idle",
"Jumping",
"Recovering",
"Dancing",
"Dead"
],
"short_name": "Monster",
"title": "simulation::plugins::monster::Monster",
"type": "string",
"typeInfo": "Enum"
},
"smallvec::SmallVec<[bevy_ecs::Entity; 8]>": {
"isComponent": false,
"isResource": false,
Expand Down Expand Up @@ -9166,6 +9181,25 @@
"type": "object",
"typeInfo": "Struct"
},
"test::RaceSpawnPoint": {
"additionalProperties": false,
"isComponent": true,
"isResource": false,
"properties": {
"id": {
"type": {
"$ref": "#/$defs/u32"
}
}
},
"required": [
"id"
],
"short_name": "RaceSpawnPoint",
"title": "test::RaceSpawnPoint",
"type": "object",
"typeInfo": "Struct"
},
"test::RotateSpeed": {
"additionalProperties": false,
"isComponent": true,
Expand Down
4 changes: 2 additions & 2 deletions shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ im = "15.1.0"
quickcheck = "1.0.3"
quickcheck_macros = "1.0.0"
rand = "0.8.5"
serde = "1.0.197"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
uuid = "1.7.0"
uuid = { version = "1.7.0", features = ["v4", "serde", "js"] }
46 changes: 25 additions & 21 deletions shared/src/models/monsters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,64 +9,64 @@ use uuid::Uuid;
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Monster {
pub name: &'static str,
pub asset_name: &'static str,
pub blueprint_name: &'static str,
pub uuid: Uuid,
pub speed: i32,
}

pub const MONSTERS: [Monster; 9] = [
Monster {
name: "Loser",
name: "Cactoro",
uuid: Uuid::from_u128(0xb19768d8fce94b66a2d7ea84799c0101u128),
asset_name: "animated/Cactoro.glb",
blueprint_name: "Monster_Cactoro",
speed: 7,
},
Monster {
name: "Will",
name: "Purglehorn",
uuid: Uuid::from_u128(0x99a7c5d8c06744eeb856df9d6b04c4e8u128),
asset_name: "animated/Alien.glb",
blueprint_name: "Monster_Alien",
speed: 3,
},
Monster {
name: "Hate",
name: "Mawshroom",
uuid: Uuid::from_u128(0xf8a2f4560fa44e89b915f0b0de101a1au128),
asset_name: "animated/Mushnub Evolved.glb",
blueprint_name: "Monster_Mushnub",
speed: 6,
},
Monster {
name: "Machine",
name: "Mechapanda",
uuid: Uuid::from_u128(0x0ef5f3373cea4c9ca6655bd3e7bc4c63u128),
asset_name: "animated/Mech.glb",
blueprint_name: "Monster_Mech",
speed: 6,
},
Monster {
name: "Fido",
name: "Finflare",
uuid: Uuid::from_u128(0x6cb10197a7234cf980f7fb957f7eb9f1u128),
asset_name: "animated/Fish.glb",
blueprint_name: "Monster_Fish",
speed: 4,
},
Monster {
name: "Mind",
name: "Green Spiky Thing",
uuid: Uuid::from_u128(0xcbde634a2d3648f383b3c7e45cc864b7u128),
asset_name: "animated/Green Spiky Blob.glb",
blueprint_name: "Monster_Green_Spiky",
speed: 6,
},
Monster {
name: "Void",
name: "Gallus Cranium",
uuid: Uuid::from_u128(0x73c68289e1334859a0f4e45883076e10u128),
asset_name: "animated/Pink Slime.glb",
blueprint_name: "Monster_Pink_Slime",
speed: 6,
},
Monster {
name: "Parasite",
name: "Cluckerhead",
uuid: Uuid::from_u128(0x9f987f8ff320446e8930740aca46954fu128),
asset_name: "animated/Chicken.glb",
blueprint_name: "Monster_Chicken",
speed: 3,
},
Monster {
name: "Gambler",
name: "Fangmaw",
uuid: Uuid::from_u128(0xb4775b5b2e1f42debe985d3d7890db0du128),
asset_name: "animated/Yeti.glb",
blueprint_name: "Monster_Yeti",
speed: 4,
},
];
Expand All @@ -82,7 +82,7 @@ pub struct Results {
pub rounds: Vec<Round>,
}

pub fn race(monsters: &[&'static Monster; 3], seed: u32) -> Results {
pub fn race(monsters: &[&Monster; 3], seed: u32) -> Results {
let dist = Bernoulli::new(1.0 / 6.0).unwrap();
let mut rng = StdRng::seed_from_u64(seed as u64);

Expand Down Expand Up @@ -126,8 +126,12 @@ pub fn race(monsters: &[&'static Monster; 3], seed: u32) -> Results {

#[cfg(test)]
mod test {
use super::{race, MONSTERS};
use std::collections::HashMap;

use super::{race, Monster, MONSTERS};
use quickcheck_macros::quickcheck;
use rand::{thread_rng, RngCore};
use uuid::Uuid;

#[quickcheck]
pub fn same_outcome_for_same_seed(seed: u32) -> bool {
Expand Down
1 change: 1 addition & 0 deletions simulation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ bevy_asset_loader = { version = "0.19.1", features = ["progress_tracking"] }
bevy_gltf_blueprints = "0.7.3"
bevy_gltf_components = "0.3.2"
bevy_registry_export = "0.1.1"
bevy_tweening = "0.9.0"
crossbeam-channel = "0.5.11"
iyes_progress = { version = "0.10.0", features = ["assets"] }
lazy_static = "1.4.0"
Expand Down
Binary file modified simulation/assets/Scene.glb
Binary file not shown.
Binary file added simulation/assets/library/Monster_Alien.glb
Binary file not shown.
Binary file added simulation/assets/library/Monster_Cactoro.glb
Binary file not shown.
Binary file added simulation/assets/library/Monster_Chicken.glb
Binary file not shown.
Binary file added simulation/assets/library/Monster_Fish.glb
Binary file not shown.
Binary file not shown.
Binary file added simulation/assets/library/Monster_Mech.glb
Binary file not shown.
Binary file added simulation/assets/library/Monster_Mushnub.glb
Binary file not shown.
Binary file added simulation/assets/library/Monster_Pink_Slime.glb
Binary file not shown.
Binary file added simulation/assets/library/Monster_Yeti.glb
Binary file not shown.
Binary file modified simulation/assets/library/Platform_2x2.glb
Binary file not shown.
Binary file modified simulation/assets/library/Platform_4x1.glb
Binary file not shown.
Binary file added simulation/assets/library/Platform_4x2.glb
Binary file not shown.
Binary file modified simulation/assets/library/Platform_4x4.glb
Binary file not shown.
Binary file added simulation/assets/library/Race_Spawn_Point.glb
Binary file not shown.
Binary file modified simulation/game.blend
Binary file not shown.
53 changes: 49 additions & 4 deletions simulation/src/bin/test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use bevy::{gltf::Gltf, pbr::CascadeShadowConfigBuilder, prelude::*, utils::HashMap};
use bevy_asset_loader::prelude::*;
use bevy_gltf_blueprints::{BluePrintBundle, BlueprintName, GltfBlueprintsSet};
use bevy_registry_export::*;
use simulation::start;
use simulation::{
plugins::monster::{MonsterBundle, Speed, Stats},
start,
};

#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, States)]
enum SceneState {
Expand All @@ -14,6 +18,7 @@ fn main() {
start(|app| {
app.register_type::<RotateSpeed>()
.register_type::<OrbitPoint>()
.register_type::<RaceSpawnPoint>()
.add_plugins(bevy_gltf_blueprints::BlueprintsPlugin {
library_folder: "library".into(),
material_library: false,
Expand All @@ -31,7 +36,8 @@ fn main() {
.add_systems(OnEnter(SceneState::Loaded), setup)
.add_plugins(bevy_inspector_egui::quick::WorldInspectorPlugin::default())
.add_systems(Update, rotate)
.add_systems(Update, orbit);
.add_systems(Update, orbit)
.add_systems(Update, find_spawn.in_set(GltfBlueprintsSet::AfterSpawn));
});
}

Expand Down Expand Up @@ -61,10 +67,49 @@ pub struct OrbitPoint {

#[derive(Debug, Component, Reflect, Default)]
#[reflect(Component)]
pub struct SpawnPoint {
pub struct RaceSpawnPoint {
pub id: u32,
}

fn find_spawn(
mut commands: Commands,
query: Query<(&RaceSpawnPoint, &Transform), Added<RaceSpawnPoint>>,
) {
for (spawn_point, transform) in &query {
if spawn_point.id == 0 {
continue;
}

println!(
"Found race spawn point {:?} at {:?}",
spawn_point, transform
);

let mut name = "Monster_Alien";

if spawn_point.id == 2 {
name = "Monster_Chicken";
}

if spawn_point.id == 3 {
name = "Monster_Mushnub";
}

commands.spawn((
BluePrintBundle {
blueprint: BlueprintName(name.into()),
..default()
},
MonsterBundle {
speed: Speed(1.0),
stats: Stats { recovery_time: 2.0 },
..default()
},
*transform,
));
}
}

fn setup(
mut commands: Commands,
game_assets: Res<Scene>,
Expand All @@ -80,7 +125,7 @@ fn setup(
ambient_light.brightness = 0.1;

commands.spawn(DirectionalLightBundle {
transform: Transform::from_rotation(Quat::from_euler(EulerRot::XYZ, -2.5, 1.1, 0.0)),
transform: Transform::from_rotation(Quat::from_euler(EulerRot::XYZ, -4.1, 2.1, 0.0)),
directional_light: DirectionalLight {
illuminance: 75000.0,
shadows_enabled: true,
Expand Down
39 changes: 0 additions & 39 deletions simulation/src/plugins/animation_link/mod.rs

This file was deleted.

2 changes: 1 addition & 1 deletion simulation/src/plugins/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pub mod animation_link;
pub mod asset_loader;
pub mod async_task;
pub mod event_stream;
pub mod fetch_data;
pub mod menus;
pub mod monster;
pub mod pallet;
pub mod spectators;

Loading

0 comments on commit a7e7111

Please sign in to comment.