|
|
|
@ -22,7 +22,7 @@ use chemtorio::{Chem, Chemtorio, EntityTypeTag};
|
|
|
|
|
use hecs::Entity; |
|
|
|
|
use inventory::WeightFilter; |
|
|
|
|
use renderer::{ChemtorioRenderer, Overlay}; |
|
|
|
|
use sprites::{EntitySprite, SpriteAssets, SC_OVERLAYS_IDX, SC_TILES_IDX}; |
|
|
|
|
use sprites::{EntitySprite, SpriteAssets, SC_OVERLAYS_IDX, SC_TILES_IDX, SC_CLIPPY_IDX}; |
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy)] |
|
|
|
|
enum PlacementMode { |
|
|
|
@ -64,6 +64,17 @@ impl ChemtorioRenderer for QuadRenderer {
|
|
|
|
|
self.sprites.draw(&ground_id, pos.0 as f32, pos.1 as f32); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn render_clippy(&mut self, pos: (i32, i32), eyes_open: bool, frame: usize) { |
|
|
|
|
let base_idx = if eyes_open { |
|
|
|
|
0 |
|
|
|
|
} else { |
|
|
|
|
2 |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
self.sprites |
|
|
|
|
.draw_anim_frame(&(SC_CLIPPY_IDX, base_idx), frame, pos.0 as f32, pos.1 as f32); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fn render_overlay(&mut self, pos: (i32, i32), overlay: Overlay) { |
|
|
|
|
let id = match overlay { |
|
|
|
|
Overlay::EQ => Some(6), |
|
|
|
@ -178,6 +189,49 @@ impl QuadRenderer {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
struct Notification { |
|
|
|
|
delay_frames: u32, |
|
|
|
|
cur_frame: u32, |
|
|
|
|
message: String, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
impl Notification { |
|
|
|
|
pub fn new() -> Self { |
|
|
|
|
Self { |
|
|
|
|
delay_frames: 60, |
|
|
|
|
cur_frame: 0, |
|
|
|
|
message: String::from(""), |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn notify(&mut self, msg: &str) { |
|
|
|
|
self.cur_frame = self.delay_frames; |
|
|
|
|
self.message = msg.to_string(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn notify_frame(&self) -> usize { |
|
|
|
|
if self.cur_frame > (self.delay_frames / 2) { |
|
|
|
|
1 |
|
|
|
|
} else { |
|
|
|
|
0 |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn tick(&mut self) { |
|
|
|
|
if self.cur_frame > 0 { |
|
|
|
|
self.cur_frame -= 1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pub fn cur_message(&self) -> Option<&str> { |
|
|
|
|
if self.cur_frame > 0 { |
|
|
|
|
Some(&self.message[..]) |
|
|
|
|
} else { |
|
|
|
|
None |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
use egui::ColorImage; |
|
|
|
|
use egui_extras::RetainedImage; |
|
|
|
|
|
|
|
|
@ -375,6 +429,9 @@ async fn main() {
|
|
|
|
|
let zoom_level_max = 3; |
|
|
|
|
let zoom_level_min = -2; |
|
|
|
|
let mut zoom_level: i32 = 0; |
|
|
|
|
|
|
|
|
|
let mut notify = Notification::new(); |
|
|
|
|
|
|
|
|
|
loop { |
|
|
|
|
// belts.tick();
|
|
|
|
|
|
|
|
|
@ -384,6 +441,8 @@ async fn main() {
|
|
|
|
|
} |
|
|
|
|
sub += 1; |
|
|
|
|
|
|
|
|
|
notify.tick(); |
|
|
|
|
|
|
|
|
|
// (m_pos.x / 32.0).round() * 32.0 + 16.0,
|
|
|
|
|
// (m_pos.y / 32.0).round() * 32.0 + 16.0,
|
|
|
|
|
// );
|
|
|
|
@ -610,6 +669,7 @@ async fn main() {
|
|
|
|
|
cur = dir.offs_pos_by(cur, 1); |
|
|
|
|
if cur.0 >= min && cur.0 <= max { |
|
|
|
|
chemtorio.build_belt_at_tile(cur, *dir); |
|
|
|
|
notify.notify("Placed a fine belt there!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
last.0 = m_tile_pos.0; |
|
|
|
@ -622,6 +682,7 @@ async fn main() {
|
|
|
|
|
cur = dir.offs_pos_by(cur, 1); |
|
|
|
|
if cur.1 >= min && cur.1 <= max { |
|
|
|
|
chemtorio.build_belt_at_tile(cur, *dir); |
|
|
|
|
notify.notify("Placed a fine belt there!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
last.1 = m_tile_pos.1; |
|
|
|
@ -632,6 +693,7 @@ async fn main() {
|
|
|
|
|
*dir = Some(Dir::from_poses(*last, m_tile_pos)); |
|
|
|
|
chemtorio.build_belt_at_tile(*last, dir.unwrap()); |
|
|
|
|
chemtorio.build_belt_at_tile(m_tile_pos, dir.unwrap()); |
|
|
|
|
notify.notify("Placed a fine belt there!"); |
|
|
|
|
*last = m_tile_pos; |
|
|
|
|
placement_mode = PlacementMode::Belt(dir.unwrap()); |
|
|
|
|
} |
|
|
|
@ -655,13 +717,16 @@ async fn main() {
|
|
|
|
|
} |
|
|
|
|
PlacementMode::Source => { |
|
|
|
|
chemtorio.place_source_at(m_tile_pos, cur_chem); |
|
|
|
|
notify.notify("Placed a fine source there!"); |
|
|
|
|
} |
|
|
|
|
PlacementMode::Picker(dir) => { |
|
|
|
|
chemtorio.build_picker_at(m_tile_pos, dir); |
|
|
|
|
notify.notify("Oh my, you placed a picker, sweet!"); |
|
|
|
|
} |
|
|
|
|
PlacementMode::Belt(dir) => { |
|
|
|
|
if belt_draw.is_none() || belt_draw.unwrap().1.is_none() { |
|
|
|
|
chemtorio.build_belt_at_tile(m_tile_pos, dir); |
|
|
|
|
notify.notify("A very fine belt there!"); |
|
|
|
|
} |
|
|
|
|
belt_draw = None; |
|
|
|
|
} |
|
|
|
@ -773,6 +838,28 @@ async fn main() {
|
|
|
|
|
|
|
|
|
|
egui_macroquad::draw(); |
|
|
|
|
|
|
|
|
|
if let Some(msg) = notify.cur_message() { |
|
|
|
|
let y_top = screen_height() - 100.0; |
|
|
|
|
|
|
|
|
|
draw_rectangle( |
|
|
|
|
0.0, |
|
|
|
|
y_top, |
|
|
|
|
1024.0, |
|
|
|
|
60.0, |
|
|
|
|
Color::from_rgba(0xfb, 0x79, 0x91, 0x80), |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
draw_text(msg, 248.0 + 2.0, y_top + 40.0 + 2.0, 30.0, Color::new(0.0, 0.0, 0.0, 1.0)); |
|
|
|
|
draw_text(msg, 248.0, y_top + 40.0, 30.0, Color::new(1.0, 1.0, 1.0, 1.0)); |
|
|
|
|
|
|
|
|
|
// let clip = EntitySprite::clippy_happy_eyes_closed();
|
|
|
|
|
qrend.render_clippy((128, screen_height() as i32 - 128), false, notify.notify_frame()); |
|
|
|
|
} else { |
|
|
|
|
// let clip = EntitySprite::clippy_happy();
|
|
|
|
|
// qrend.render_entity((128, screen_height() as i32 - 128), &clip);
|
|
|
|
|
qrend.render_clippy((128, screen_height() as i32 - 128), true, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
next_frame().await |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|