matebottledrop.rs 783 Bytes
Newer Older
robert's avatar
robert committed
1
2
use crate::colliders;
use crate::components;
3
use crate::sprites;
robert's avatar
robert committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use crate::svg_loader;

use rand::seq::SliceRandom;

pub fn create_drop_points(world: &mut legion::World, level: &svg_loader::SvgLevel) {
    let spawn_locations = level
        .spawnpoints
        .get("bottledrop")
        .expect("no mate bottle drops spawn in this map");
    if spawn_locations.len() < 4 {
        panic!("to few bottledrops");
    }
    for droppoint in spawn_locations.choose_multiple(&mut rand::thread_rng(), 4) {
        world.push((
            components::Matebottledrop,
            components::Position::new(droppoint.x, droppoint.y),
20
            colliders::Collider::new_sensor_circle(50.0),
21
            components::Sprite::new(sprites::Sprite::BottleDropPointFull),
robert's avatar
robert committed
22
23
24
        ));
    }
}