range indicators, limit tower placement to within range of core
This commit is contained in:
parent
9c4787f5e2
commit
6a4978041c
16 changed files with 350 additions and 60 deletions
|
|
@ -9,6 +9,7 @@ bevy = { workspace = true }
|
|||
combat = { path = "../combat" }
|
||||
building = { path = "../building" }
|
||||
state = { path = "../state" }
|
||||
ui_range_indicator = { path = "../ui_range_indicator" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@
|
|||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
use bevy::prelude::*;
|
||||
use building::{BuildingInfo, BuildingPreview, PREVIEW_ALPHA, PopulatePlacedBuilding};
|
||||
use combat::{Defense, Health};
|
||||
use building::{BuildingInfo, BuildingPreview, Core, PREVIEW_ALPHA, PopulatePlacedBuilding};
|
||||
use combat::{Defense, Health, Range};
|
||||
use ui_range_indicator::{CustomRangeIndicator, DisplayCustomRangeIndicator};
|
||||
|
||||
pub struct BuildingCorePlugin;
|
||||
|
||||
|
|
@ -14,9 +15,6 @@ impl Plugin for BuildingCorePlugin {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct Core;
|
||||
|
||||
#[derive(Resource)]
|
||||
struct CoreResources {
|
||||
mesh: Handle<Mesh>,
|
||||
|
|
@ -72,6 +70,7 @@ fn register(
|
|||
fn populate(
|
||||
trigger: Trigger<PopulatePlacedBuilding>,
|
||||
mut commands: Commands,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
res: Res<CoreResources>,
|
||||
) {
|
||||
if trigger.event().info != res.info_entity {
|
||||
|
|
@ -81,7 +80,15 @@ fn populate(
|
|||
Core,
|
||||
Health::new(100.0),
|
||||
Defense::new(5.0),
|
||||
Range(20.0),
|
||||
Mesh3d(res.mesh.clone()),
|
||||
MeshMaterial3d(res.material.clone()),
|
||||
CustomRangeIndicator::new(materials.add(StandardMaterial {
|
||||
alpha_mode: AlphaMode::Blend,
|
||||
base_color: Color::srgba(0.6, 0.2, 0.2, 0.4),
|
||||
unlit: true,
|
||||
double_sided: true,
|
||||
..default()
|
||||
})),
|
||||
));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue