This repository has been archived by the owner on Oct 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
main.rs
99 lines (89 loc) · 3.18 KB
/
main.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#[macro_use]
extern crate log;
use amethyst::assets::PrefabLoaderSystemDesc;
use amethyst::{
audio::{AudioBundle, DjSystem},
core::frame_limiter::FrameRateLimitStrategy,
core::transform::TransformBundle,
gltf::GltfSceneLoaderSystemDesc,
input::{InputBundle, StringBindings},
prelude::*,
renderer::types::DefaultBackend,
ui::{RenderUi, UiBundle},
utils::application_root_dir,
window::DisplayConfig,
};
use amethyst::renderer::plugins::{RenderPbr3D, RenderToWindow};
use amethyst::renderer::RenderingBundle;
mod components;
mod render_graph;
mod resources;
mod states;
mod systems;
mod utils;
use crate::components::{combat, creatures};
use crate::resources::audio::Music;
use crate::states::loading::LoadingState;
fn main() -> amethyst::Result<()> {
amethyst::start_logger(Default::default());
let resources = application_root_dir()
.unwrap()
.into_os_string()
.into_string()
.unwrap()
+ "/resources";
let display_config_path = resources.clone() + "/display_config.ron";
let key_bindings_path = resources.clone() + "/input.ron";
let _display_config = DisplayConfig::load(display_config_path)?;
let render_display_config = DisplayConfig {
title: "Evoli".to_string(),
dimensions: Some((1024, 768)),
..Default::default()
};
// The global game data. Here we register all systems and bundles that will run for every game state. The game states
// will define additional dispatchers for state specific systems. Note that the dispatchers will run in sequence,
// so this setup sacrifices performance for modularity (for now).
let game_data = GameDataBuilder::default()
.with_bundle(TransformBundle::new())?
.with_bundle(
InputBundle::<StringBindings>::new().with_bindings_from_file(&key_bindings_path)?,
)?
.with_system_desc(
PrefabLoaderSystemDesc::<creatures::CreaturePrefabData>::default(),
"creature_loader",
&[],
)
.with_system_desc(
GltfSceneLoaderSystemDesc::default(),
"gltf_loader",
&["creature_loader"],
)
.with_system_desc(
PrefabLoaderSystemDesc::<combat::FactionPrefabData>::default(),
"",
&[],
)
.with(
DjSystem::new(|music: &mut Music| music.music.next()),
"dj",
&[],
)
.with_bundle(AudioBundle::default())?
.with_bundle(UiBundle::<StringBindings>::new())?
.with_bundle(
RenderingBundle::<DefaultBackend>::new()
.with_plugin(
RenderToWindow::from_config(render_display_config)
.with_clear([0.0, 0.0, 0.0, 1.0]), //rgba background
)
.with_plugin(RenderPbr3D::default())
.with_plugin(RenderUi::default()),
)?;
// Set up the core application.
let mut game: Application<GameData> =
CoreApplication::build(resources.clone(), LoadingState::new(resources))?
.with_frame_limit(FrameRateLimitStrategy::Sleep, 60)
.build(game_data)?;
game.run();
Ok(())
}