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
70
71
72
73
74
75
76
77
use crate::Nano9Plugin;
use bevy::{
app::{PluginGroup, PluginGroupBuilder},
audio::{AudioPlugin, Volume},
image::ImagePlugin,
prelude::*,
window::ExitCondition,
};
/// Nano-9 plugins
#[derive(Debug, Default)]
pub struct Nano9Plugins;
// impl Nano9Plugins {
// pub fn new(config: Config) -> Self {
// Nano9Plugins {
// config,
// config_path: None,
// }
// }
// }
impl PluginGroup for Nano9Plugins {
fn build(self) -> PluginGroupBuilder {
let group = PluginGroupBuilder::start::<Self>();
// TODO: Get rid of this n9mem directory.
// let group = group.add(MemoryDir::new("n9mem"));
let nano9_plugin = Nano9Plugin;
// {
// config: self.config,
// config_path: self.config_path,
// };
let group = group.add_group(
DefaultPlugins
// .set(AssetPlugin {
// mode: AssetMode::Processed,
// ..default()
// })
// Preserve crisp pixel art by default.
//
// TODO: I don't necessarily want to do this because it's a
// global setting. But currently the images that I use with
// bevy_ecs_tilemap do not seem to be using nearest, so this is
// the fix for now.
.set(ImagePlugin::default_nearest())
.set(AudioPlugin {
global_volume: GlobalVolume {
volume: Volume::Linear(0.4),
},
..default()
})
.set(WindowPlugin {
primary_window: None,
exit_condition: ExitCondition::OnPrimaryClosed,
..default()
}),
);
group.add(nano9_plugin)
}
}
/// Headless plugin set for tests: no window, no winit event loop.
/// Use this in tests to avoid "EventLoop must be created on the main thread" on macOS.
#[derive(Debug, Default)]
pub struct HeadlessNano9Plugins;
impl PluginGroup for HeadlessNano9Plugins {
fn build(self) -> PluginGroupBuilder {
PluginGroupBuilder::start::<Self>()
.add_group(MinimalPlugins)
.add(bevy::state::app::StatesPlugin)
.add(AssetPlugin::default())
.add(ImagePlugin::default_nearest())
.add(Nano9Plugin)
}
}