convert core to new format, improve tower placement
This commit is contained in:
parent
2808f6dd2c
commit
bc02db7b26
12 changed files with 250 additions and 107 deletions
|
|
@ -5,8 +5,7 @@
|
|||
use avian3d::prelude::*;
|
||||
use bevy::prelude::*;
|
||||
use building::{
|
||||
ActiveBuildingPreview, Building, BuildingInfo, BuildingPreview, PREVIEW_ALPHA,
|
||||
PopulatePlacedBuilding,
|
||||
ActiveBuildingPreview, BuildingInfo, BuildingPreview, PREVIEW_ALPHA, PopulatePlacedBuilding,
|
||||
};
|
||||
use combat::{Defense, Health};
|
||||
use combat_damagers::ContactDamage;
|
||||
|
|
@ -20,7 +19,6 @@ impl Plugin for BuildingImpalerPlugin {
|
|||
}
|
||||
|
||||
#[derive(Component)]
|
||||
#[require(Building)]
|
||||
pub struct Impaler;
|
||||
|
||||
#[derive(Resource)]
|
||||
|
|
@ -30,6 +28,8 @@ struct ImpalerResources {
|
|||
info_entity: Entity,
|
||||
}
|
||||
|
||||
const SIZE: UVec3 = UVec3::ONE;
|
||||
|
||||
fn register(
|
||||
mut commands: Commands,
|
||||
mut meshes: ResMut<Assets<Mesh>>,
|
||||
|
|
@ -53,11 +53,7 @@ fn register(
|
|||
let preview = commands
|
||||
.spawn((
|
||||
BuildingPreview { info },
|
||||
ActiveBuildingPreview, // Visibility::Hidden,
|
||||
Mesh3d::default(),
|
||||
))
|
||||
.with_child((
|
||||
Transform::from_xyz(0., 0.5, 0.),
|
||||
ActiveBuildingPreview::default(), // Visibility::Hidden,
|
||||
Mesh3d(mesh.clone()),
|
||||
MeshMaterial3d(preview_material),
|
||||
))
|
||||
|
|
@ -65,7 +61,7 @@ fn register(
|
|||
commands.entity(info).insert((
|
||||
BuildingInfo {
|
||||
preview,
|
||||
size: UVec2::new(1, 1),
|
||||
size: SIZE,
|
||||
},
|
||||
Name::new("Impaler"),
|
||||
));
|
||||
|
|
@ -84,26 +80,14 @@ fn populate(
|
|||
if trigger.event().info != res.info_entity {
|
||||
return;
|
||||
}
|
||||
commands
|
||||
.entity(trigger.target())
|
||||
.insert((
|
||||
RigidBody::Static,
|
||||
Impaler,
|
||||
Health::new(20.0),
|
||||
Defense::new(5.0),
|
||||
ContactDamage { amount: 5.0 },
|
||||
Name::from("Impaler"),
|
||||
Mesh3d::default(),
|
||||
Collider::compound(vec![(
|
||||
Vec3::Y * 0.5,
|
||||
Quat::IDENTITY,
|
||||
Collider::cuboid(1.0, 1.0, 1.0),
|
||||
)]),
|
||||
))
|
||||
.with_child((
|
||||
// don't think I'll need this with actual models
|
||||
Transform::from_xyz(0., 0.5, 0.),
|
||||
Mesh3d(res.mesh.clone()),
|
||||
MeshMaterial3d(res.material.clone()),
|
||||
));
|
||||
commands.entity(trigger.target()).insert((
|
||||
RigidBody::Static,
|
||||
Impaler,
|
||||
Health::new(20.0),
|
||||
Defense::new(5.0),
|
||||
ContactDamage { amount: 5.0 },
|
||||
Name::from("Impaler"),
|
||||
Mesh3d(res.mesh.clone()),
|
||||
MeshMaterial3d(res.material.clone()),
|
||||
));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue