@@ -3,7 +3,7 @@ use std::path::Path;

use conrod::{Ui, UiBuilder};
use loader;
use specs::{Dispatcher, DispatcherBuilder, World};
use specs::{Dispatcher, DispatcherBuilder, LazyUpdate, Read, World};
use state::State;

use components::{ui::WalletUI, upgrade, upgrade::Buff, Button, CityPowerState, Color,
@@ -327,21 +327,14 @@ impl<'a> State for PlayState<'a> {
.insert("show_button_entity".to_string(), entity);

let entities = world.entities();
let mut color_storage = world.write_storage::<Color>();
let mut transform_storage = world.write_storage::<Transform>();
let mut text_storage = world.write_storage::<Text>();
let mut wallet_ui_storage = world.write_storage::<WalletUI>();

let mut text_storages = TextStorage {
entities: &entities,
color_storage: &mut color_storage,
text_storage: &mut text_storage,
transform_storage: &mut transform_storage,
};
let lazy: Read<LazyUpdate> = Read::<LazyUpdate>::from(world.read_resource::<LazyUpdate>());

// money text
let entity = create_text::create(
&mut text_storages,
&entities,
&lazy,
format!("Wallet: ${}", Wallet::start_amount()),
28.0,
33.0,
@@ -356,7 +349,8 @@ impl<'a> State for PlayState<'a> {
side_bar_container_node.add(entity);

let gathering_rate_label = create_text::create(
&mut text_storages,
&entities,
&lazy,
"Gathering Rate".to_string(),
22.0,
0.0,
@@ -370,7 +364,8 @@ impl<'a> State for PlayState<'a> {
gathering_rate_container_node.add(gathering_rate_label);

let coal_rate_label = create_text::create(
&mut text_storages,
&entities,
&lazy,
"Coal: 0".to_string(),
20.0,
0.0,
@@ -387,7 +382,8 @@ impl<'a> State for PlayState<'a> {
gathering_rate_container_node.add(coal_rate_label);

let oil_rate_label = create_text::create(
&mut text_storages,
&entities,
&lazy,
"Oil: 0".to_string(),
20.0,
0.0,
@@ -404,7 +400,8 @@ impl<'a> State for PlayState<'a> {
gathering_rate_container_node.add(oil_rate_label);

let hydro_rate_label = create_text::create(
&mut text_storages,
&entities,
&lazy,
"Hydro: 0".to_string(),
20.0,
0.0,
@@ -421,7 +418,8 @@ impl<'a> State for PlayState<'a> {
gathering_rate_container_node.add(hydro_rate_label);

let solar_rate_label = create_text::create(
&mut text_storages,
&entities,
&lazy,
"Solar: 0".to_string(),
20.0,
0.0,
@@ -438,7 +436,8 @@ impl<'a> State for PlayState<'a> {
gathering_rate_container_node.add(solar_rate_label);

let power_rate_label = create_text::create(
&mut text_storages,
&entities,
&lazy,
"Power: 0".to_string(),
20.0,
0.0,
@@ -455,7 +454,8 @@ impl<'a> State for PlayState<'a> {
gathering_rate_container_node.add(power_rate_label);

let money_rate_label = create_text::create(
&mut text_storages,
&entities,
&lazy,
"Income: $0, Tax: $0".to_string(),
20.0,
0.0,
@@ -473,7 +473,8 @@ impl<'a> State for PlayState<'a> {

// power gain text
let entity = create_text::create(
&mut text_storages,
&entities,
&lazy,
"Power: -40\n1 city".to_string(),
24.0,
30.0,
@@ -485,6 +486,7 @@ impl<'a> State for PlayState<'a> {
None,
);

println!("Power gain text {:?}", entity);
lookup
.entities
.insert("power_gain_text".to_string(), entity.clone());
@@ -1,29 +1,28 @@
use std::ops::{Deref, DerefMut};

use gfx_glyph::HorizontalAlign;
use specs::{Entities, Join, Read, System, Write, WriteStorage};
use specs::{Entities, Join, LazyUpdate, Read, System, Write, WriteStorage};
use state::play_state::PlayState;

use components::{Actions, Button, CityPowerState, Color, EntityLookup, Input, Node, Rect, Sprite,
use components::{Actions, Button, CityPowerState, Color, EntityLookup, Input, Node, Sprite,
StateChange, Text, Transform};
use entities::{create_colored_rect, create_text};
use renderer;
use storage_types::TextStorage;
use systems::logic;

pub struct EndScreen;

impl<'a> System<'a> for EndScreen {
type SystemData = (
Entities<'a>,
Read<'a, LazyUpdate>,
Write<'a, Actions>,
WriteStorage<'a, Button>,
Read<'a, CityPowerState>,
WriteStorage<'a, Color>,
Write<'a, EntityLookup>,
Read<'a, Input>,
WriteStorage<'a, Node>,
WriteStorage<'a, Rect>,
WriteStorage<'a, Sprite>,
Write<'a, StateChange>,
WriteStorage<'a, Text>,
@@ -33,14 +32,14 @@ impl<'a> System<'a> for EndScreen {
fn run(&mut self, data: Self::SystemData) {
let (
entities,
lazy,
mut actions_storage,
mut button_storage,
city_power_state_storage,
mut color_storage,
mut entity_lookup_storage,
input_storage,
mut node_storage,
mut rect_storage,
mut sprite_storage,
mut state_change_storage,
mut text_storage,
@@ -60,25 +59,17 @@ impl<'a> System<'a> for EndScreen {
640,
[0.0, 0.0, 0.0, 0.8],
&entities,
&mut transform_storage,
&mut color_storage,
&mut rect_storage,
&lazy,
);
lookup.entities.insert("pause_black".to_string(), entity);

root_node.add(entity);

{
let mut text_storage = TextStorage {
entities: &entities,
color_storage: &mut color_storage,
text_storage: &mut text_storage,
transform_storage: &mut transform_storage,
};

let dim = renderer::get_dimensions();
let text = create_text::create(
&mut text_storage,
&entities,
&lazy,
format!(
"You were able to provide power to {} cities",
city_power_state_storage.current_city_count
@@ -1,17 +1,17 @@
use gfx_glyph::HorizontalAlign;
use specs::{Entities, Join, Read, System, Write, WriteStorage};
use specs::{Entities, Join, Read, LazyUpdate, System, Write, WriteStorage};

use components::{Actions, Color, DeltaTime, EntityLookup, Error, Node, Text, Transform};
use entities::create_text;
use renderer::get_dimensions;
use storage_types::TextStorage;
use systems::logic;

pub struct Errors;

impl<'a> System<'a> for Errors {
type SystemData = (
Entities<'a>,
Read<'a, LazyUpdate>,
Write<'a, Actions>,
WriteStorage<'a, Color>,
Read<'a, DeltaTime>,
@@ -25,6 +25,7 @@ impl<'a> System<'a> for Errors {
fn run(&mut self, data: Self::SystemData) {
let (
entities,
lazy,
mut actions_storage,
mut color_storage,
delta_time_storage,
@@ -41,16 +42,11 @@ impl<'a> System<'a> for Errors {
.unwrap()
.clone();
actions_storage.remove("display_error".to_string());
let mut text_storage = TextStorage {
entities: &entities,
color_storage: &mut color_storage,
text_storage: &mut text_storage,
transform_storage: &mut transform_storage,
};

let dim = get_dimensions();
let text_entity = create_text::create(
&mut text_storage,
&entities,
&lazy,
payload.clone(),
28.0,
dim[0] / 2.0,
@@ -2,9 +2,8 @@ use components::{ui::TutorialUI, upgrade::Buff, Actions, Color, DeltaTime, Float
GathererType, GatheringRate, Node, ResearchedBuffs, Resources, Text, Transform,
TutorialStep};
use entities::{create_text, tutorial};
use specs::{Entities, Join, Read, ReadStorage, System, Write, WriteStorage};
use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, Write, WriteStorage};
use std::ops::{Deref, DerefMut};
use storage_types::TextStorage;
use systems::TICK_RATE;

pub struct Gathering {
@@ -31,6 +30,7 @@ impl Gathering {
impl<'a> System<'a> for Gathering {
type SystemData = (
Entities<'a>,
Read<'a, LazyUpdate>,
Write<'a, Actions>,
WriteStorage<'a, Color>,
Read<'a, DeltaTime>,
@@ -49,6 +49,7 @@ impl<'a> System<'a> for Gathering {
fn run(&mut self, data: Self::SystemData) {
let (
entities,
lazy,
mut actions_storage,
mut color_storage,
delta_time_storage,
@@ -110,15 +111,9 @@ impl<'a> System<'a> for Gathering {
gathering_rate.add_to_resource_amount(&gatherer.gatherer_type, amount);

let mut entity_node = node_storage.get_mut(entity).unwrap();
let mut text_storage = TextStorage {
entities: &entities,
color_storage: &mut color_storage,
text_storage: &mut text_storage,
transform_storage: &mut transform_storage,
};

let floating_text = create_text::create(
&mut text_storage,
&entities,
&lazy,
format!("{}", amount),
22.0,
0.0,
@@ -19,7 +19,7 @@ use entities::{create_text,
recursive_delete,
tech_tree::{get_color_from_status, Status, Upgrade},
tutorial};
use specs::{Entities, Entity, Join, Read, ReadStorage, System, Write, WriteStorage};
use specs::{Entities, Entity, Join, LazyUpdate, Read, ReadStorage, System, Write, WriteStorage};
use std::ops::{Deref, DerefMut};
use storage_types::*;
use systems::logic;
@@ -98,6 +98,7 @@ impl TechTree {
impl<'a> System<'a> for TechTree {
type SystemData = (
Entities<'a>,
Read<'a, LazyUpdate>,
Write<'a, Actions>,
WriteStorage<'a, Color>,
Read<'a, EntityLookup>,
@@ -121,6 +122,7 @@ impl<'a> System<'a> for TechTree {
fn run(&mut self, data: Self::SystemData) {
let (
entities,
lazy,
mut actions_storage,
mut color_storage,
entity_lookup_storage,
@@ -240,7 +242,8 @@ impl<'a> System<'a> for TechTree {
};

let text = create_text::create(
&mut text_storage_type,
&entities,
&lazy,
format!("lvl {}", level),
20.0,
80.0,
@@ -256,7 +259,8 @@ impl<'a> System<'a> for TechTree {

if upgrade.status == Status::Researched {
let text = create_text::create(
&mut text_storage_type,
&entities,
&lazy,
"Researched".to_string(),
20.0,
5.0,
@@ -270,7 +274,8 @@ impl<'a> System<'a> for TechTree {
tooltip_node.add(text);
} else {
let text = create_text::create(
&mut text_storage_type,
&entities,
&lazy,
format!("${}", upgrade.cost),
20.0,
5.0,
@@ -2,7 +2,7 @@ use components::{ui::TutorialUI, Actions, Button, Color, EffectedByPollutionTile
Gatherer, Input, Node, Rect, ResearchedBuffs, SelectedTile, Sprite, Text, Tile,
Transform, TutorialStep};
use entities::{create_build_ui, recursive_delete, tutorial};
use specs::{Entities, Entity, Join, Read, ReadStorage, System, Write, WriteStorage};
use specs::{Entities, Entity, Join, LazyUpdate, Read, ReadStorage, System, Write, WriteStorage};
use std::ops::Deref;
use systems::logic;

@@ -21,6 +21,7 @@ impl TileSelection {
impl<'a> System<'a> for TileSelection {
type SystemData = (
Entities<'a>,
Read<'a, LazyUpdate>,
Write<'a, Actions>,
WriteStorage<'a, Button>,
WriteStorage<'a, Color>,
@@ -43,6 +44,7 @@ impl<'a> System<'a> for TileSelection {
fn run(&mut self, data: Self::SystemData) {
let (
entities,
lazy,
mut actions_storage,
mut button_storage,
mut color_storage,
@@ -103,19 +105,13 @@ impl<'a> System<'a> for TileSelection {
self.build_ui_entity = None;
}
// create build ui
let entity = create_build_ui::create(
let (entity, x, y) = create_build_ui::create(
tile_mouse_x + Tile::get_size(),
tile_mouse_y,
&tile_type_selected.unwrap(),
&entities,
&mut button_storage,
&mut color_storage,
&lazy,
&mut node_storage,
&mut rect_storage,
&mut sprite_storage,
&mut text_storage,
&mut transform_storage,
&mut effected_by_pollution_tiles_storage,
&researched_buffs,
);
self.build_ui_entity = Some(entity);
@@ -127,16 +123,14 @@ impl<'a> System<'a> for TileSelection {
node.add(entity);
}

let build_entity_pos = transform_storage.get(entity).unwrap().get_pos();

let changed = tutorial::next_step(
&entities,
&mut actions_storage,
&mut tutorial_step_storage,
&tutorial_ui_storage,
&node_storage,
TutorialStep::SelectTile,
TutorialStep::BuildCoal(build_entity_pos.x, build_entity_pos.y),
TutorialStep::BuildCoal(x, y),
);

if !changed {
@@ -149,7 +143,7 @@ impl<'a> System<'a> for TileSelection {
&tutorial_ui_storage,
&node_storage,
TutorialStep::BuildCoal(10.0, 10.0),
TutorialStep::BuildCoal(build_entity_pos.x, build_entity_pos.y),
TutorialStep::BuildCoal(x, y),
);
}
}
@@ -1,8 +1,8 @@
use components::{Actions, Button, Color, CurrentState, EntityLookup, Input, InternalState, Node,
Rect, StateChange, Transform};
use components::{Actions, Button, CurrentState, EntityLookup, Input, InternalState, Node,
StateChange};
use entities::create_colored_rect;
use glutin::VirtualKeyCode;
use specs::{Entities, Join, Read, System, Write, WriteStorage};
use specs::{Entities, Join, LazyUpdate, Read, System, Write, WriteStorage};
use std::ops::{Deref, DerefMut};
use systems::logic;

@@ -11,33 +11,29 @@ pub struct TogglePause;
impl<'a> System<'a> for TogglePause {
type SystemData = (
Entities<'a>,
Read<'a, LazyUpdate>,
Write<'a, Actions>,
WriteStorage<'a, Button>,
WriteStorage<'a, Color>,
Read<'a, CurrentState>,
Write<'a, EntityLookup>,
Read<'a, Input>,
Read<'a, InternalState>,
WriteStorage<'a, Node>,
WriteStorage<'a, Rect>,
Write<'a, StateChange>,
WriteStorage<'a, Transform>,
);

fn run(&mut self, data: Self::SystemData) {
let (
entities,
lazy,
mut actions_storage,
mut button_storage,
mut color_storage,
current_state_storage,
mut entity_lookup_storage,
input,
internal_state_storage,
mut node_storage,
mut rect_storage,
mut state_change_storage,
mut transform_storage,
) = data;

let input: &Input = input.deref();
@@ -78,9 +74,7 @@ impl<'a> System<'a> for TogglePause {
640,
[16.0 / 256.0, 14.0 / 256.0, 22.0 / 256.0, 1.0],
&entities,
&mut transform_storage,
&mut color_storage,
&mut rect_storage,
&lazy,
);
let lookup: &mut EntityLookup = entity_lookup_storage.deref_mut();
lookup.entities.insert("pause_black".to_string(), entity);
@@ -1,7 +1,7 @@
use components::{ui::TutorialUI, upgrade::Buff, Actions, Button, Color, EntityLookup, Input, Node,
Rect, ResearchedBuffs, StateChange, Tile, Transform, TutorialStep, Wallet};
use components::{ui::TutorialUI, upgrade::Buff, Actions, Button, EntityLookup, Input, Node,
ResearchedBuffs, StateChange, Tile, Transform, TutorialStep, Wallet};
use entities::{create_colored_rect, tutorial};
use specs::{Entities, Join, Read, ReadStorage, System, Write, WriteStorage};
use specs::{Entities, Join, LazyUpdate, Read, ReadStorage, System, Write, WriteStorage};
use state::play_state::PlayState;
use std::ops::{Deref, DerefMut};
use systems::logic;
@@ -18,11 +18,10 @@ impl ToggleTechTree {
lookup: &mut EntityLookup,
input: &Input,
entities: &Entities,
lazy: &Read<LazyUpdate>,
actions_storage: &mut Write<Actions>,
button_storage: &mut WriteStorage<Button>,
color_storage: &mut WriteStorage<Color>,
node_storage: &mut WriteStorage<Node>,
rect_storage: &mut WriteStorage<Rect>,
transform_storage: &mut WriteStorage<Transform>,
tutorial_step_storage: &mut Write<TutorialStep>,
tutorial_ui_storage: &ReadStorage<TutorialUI>,
@@ -60,9 +59,7 @@ impl ToggleTechTree {
640,
[0.0, 0.0, 0.0, 0.8],
entities,
transform_storage,
color_storage,
rect_storage,
lazy,
);
lookup.entities.insert("pause_black".to_string(), rect);
let node = logic::get_root(&lookup, node_storage);
@@ -151,13 +148,12 @@ impl ToggleTechTree {
impl<'a> System<'a> for ToggleTechTree {
type SystemData = (
Entities<'a>,
Read<'a, LazyUpdate>,
Write<'a, Actions>,
WriteStorage<'a, Button>,
WriteStorage<'a, Color>,
Write<'a, EntityLookup>,
Read<'a, Input>,
WriteStorage<'a, Node>,
WriteStorage<'a, Rect>,
Read<'a, ResearchedBuffs>,
Write<'a, StateChange>,
ReadStorage<'a, Tile>,
@@ -170,13 +166,12 @@ impl<'a> System<'a> for ToggleTechTree {
fn run(&mut self, data: Self::SystemData) {
let (
entities,
lazy,
mut actions_storage,
mut button_storage,
mut color_storage,
mut lookup,
input,
mut node_storage,
mut rect_storage,
researched_buffs_storage,
mut state_change_res,
tile_storage,
@@ -220,11 +215,10 @@ impl<'a> System<'a> for ToggleTechTree {
&mut lookup,
&input,
&entities,
&lazy,
&mut actions_storage,
&mut button_storage,
&mut color_storage,
&mut node_storage,
&mut rect_storage,
&mut transform_storage,
&mut tutorial_step_storage,
&tutorial_ui_storage,