-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsam.rs
69 lines (63 loc) · 1.93 KB
/
sam.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use bevy::prelude::*;
use bevy_rapier3d::prelude::*;
use crate::coalition::{CoalitionType, Coalition};
use crate::definitions::*;
use crate::radar::*;
use crate::targeting::Targetable;
use crate::vehicle::*;
#[derive(Debug, Eq, PartialEq, Hash)]
pub enum SAMType {
SA6
}
#[derive(Component)]
pub struct SAM {
pub name: String,
pub sam_type: SAMType,
pub health: f32,
}
impl Default for SAM {
fn default() -> Self {
SAM {
name: String::from("Default SAM"),
sam_type: SAMType::SA6,
health: 100.0,
}
}
}
pub fn spawn_sam(commands: &mut Commands,
asset_server: &Res<AssetServer>,
xpos: f32,
zpos: f32,
side: CoalitionType,
) {
// let mesh: Handle<Mesh> = asset_server.load("models/planes/f117a.gltf#Scene0");
// let m = &meshes.get(&mesh);
// let x_shape = Collider::from_bevy_mesh(m.unwrap(), &ComputedColliderShape::TriMesh).unwrap();
commands.spawn(SceneBundle {
scene: asset_server.load("models/vehicles/SA6.gltf#Scene0"),
// transform: Transform::from_xyz(0.0, -1.0, 0.0),
..default()
})
.insert(Vehicle{..default()})
.insert(Coalition{side: side})
.insert(SAM{name: String::from("SA-6 #1"), ..default() })
.insert(Collider::cuboid(0.25, 0.35, 0.4))
.insert(CollisionGroups::new(Group::from_bits_truncate(COLLISION_MASK_GROUNDVEHICLE),
Group::from_bits_truncate(
COLLISION_MASK_TERRAIN |
COLLISION_MASK_AIRCRAFT |
COLLISION_MASK_GROUNDVEHICLE |
COLLISION_MASK_MISSILE |
COLLISION_MASK_PLAYER
)))
.insert(RigidBody::Dynamic)
.insert(ColliderMassProperties::Density(100.0))
.insert(TransformBundle::from(Transform::from_xyz(xpos, 0.0, zpos)))
.insert(Targetable)
.insert(RadarEmitter{
radar_type: RadarEmitterType::PULSE,
radar_gain: 10.0,
scan_interval: 3.0,
..default()
});
}