cash and enemy spawnpoints
This commit is contained in:
51
src/main.rs
51
src/main.rs
@@ -1,28 +1,15 @@
|
||||
mod alien;
|
||||
mod cash;
|
||||
mod tb_entities;
|
||||
|
||||
use avian3d::PhysicsPlugins;
|
||||
use avian3d::prelude::*;
|
||||
use bevy::core_pipeline::tonemapping::Tonemapping;
|
||||
use bevy::ecs::component::ComponentId;
|
||||
use bevy::ecs::world::DeferredWorld;
|
||||
use bevy::math::*;
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::view::ColorGrading;
|
||||
use bevy_flycam::prelude::*;
|
||||
use bevy_trenchbroom::prelude::*;
|
||||
|
||||
mod alien;
|
||||
|
||||
#[derive(SolidClass, Component, Reflect)]
|
||||
#[reflect(Component)]
|
||||
#[geometry(GeometryProvider::new().convex_collider().smooth_by_default_angle().render())]
|
||||
pub struct Worldspawn;
|
||||
|
||||
#[derive(SolidClass, Component, Reflect, Default)]
|
||||
#[reflect(Component)]
|
||||
#[geometry(GeometryProvider::new().convex_collider().smooth_by_default_angle().render())]
|
||||
pub struct NamedEntity {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[derive(Resource, Reflect, Debug)]
|
||||
#[reflect(Resource)]
|
||||
struct DebugVisuals {
|
||||
@@ -32,30 +19,6 @@ struct DebugVisuals {
|
||||
pub shadows: bool,
|
||||
}
|
||||
|
||||
#[derive(PointClass, Component, Reflect, Default)]
|
||||
#[reflect(Component)]
|
||||
#[require(Transform)]
|
||||
#[component(on_add = Self::on_add)]
|
||||
#[model({ "path": "models/spawn.glb" })]
|
||||
pub struct SpawnPoint {}
|
||||
|
||||
impl SpawnPoint {
|
||||
fn on_add(mut world: DeferredWorld, entity: Entity, _id: ComponentId) {
|
||||
let Some(asset_server) = world.get_resource::<AssetServer>() else {
|
||||
return;
|
||||
};
|
||||
|
||||
let mesh = asset_server.load(GltfAssetLabel::Scene(0).from_asset("models/spawn.glb"));
|
||||
|
||||
world.commands().entity(entity).insert((
|
||||
Name::new("spawn"),
|
||||
SceneRoot(mesh),
|
||||
RigidBody::Static,
|
||||
ColliderConstructorHierarchy::new(ColliderConstructor::TrimeshFromMesh),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut app = App::new();
|
||||
|
||||
@@ -72,12 +35,13 @@ fn main() {
|
||||
}));
|
||||
|
||||
app.add_plugins(PhysicsPlugins::default());
|
||||
app.add_plugins(PhysicsDebugPlugin::default());
|
||||
// app.add_plugins(PhysicsDebugPlugin::default());
|
||||
|
||||
// bevy_flycam setup so we can get a closer look at the scene, mainly for debugging
|
||||
app.add_plugins(PlayerPlugin);
|
||||
|
||||
app.add_plugins(alien::plugin);
|
||||
app.add_plugins(cash::plugin);
|
||||
|
||||
app.insert_resource(MovementSettings {
|
||||
sensitivity: 0.00005,
|
||||
@@ -119,7 +83,8 @@ fn setup_scene(mut commands: Commands, asset_server: Res<AssetServer>) {
|
||||
|
||||
commands.spawn((
|
||||
SceneRoot(
|
||||
asset_server.load(GltfAssetLabel::Scene(0).from_asset("models/angry_demonstrator.glb")),
|
||||
asset_server
|
||||
.load(GltfAssetLabel::Scene(0).from_asset("models/heads/angry_demonstrator.glb")),
|
||||
),
|
||||
Transform::from_xyz(0.0, 5.0, 0.0),
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user