Skip to content

Commit

Permalink
Update tiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankopf committed Aug 21, 2023
1 parent a243844 commit 0c34edb
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 126 deletions.
Binary file modified assets/AllSprites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 9 additions & 76 deletions src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,18 +148,18 @@ pub enum TileType {
impl TileType {
pub fn sprite_row_and_col(&self) -> (usize, usize) {
match self {
TileType::Grass => (9, 11),
TileType::Grass => (0, 0),
TileType::Cave => (13, 7),
TileType::Dirt => (4, 1),
TileType::Gravel => (7, 42),
TileType::Sand => (7, 42),
TileType::Dirt => (1, 0),
TileType::Gravel => (3, 1),
TileType::Sand => (6, 42),
TileType::Stone => (3, 61),
TileType::Water => (5, 12),
TileType::WallGame => (7, 20),
TileType::WallStone => (7, 21),
TileType::WallWood => (7, 22),
TileType::WallBrick => (4, 10),
TileType::WallMetal => (7, 24),
TileType::WallGame => (2, 10),
TileType::WallStone => (3, 10),
TileType::WallWood => (6, 32),
TileType::WallBrick => (8, 0),
TileType::WallMetal => (1, 61),
}
}
pub fn sprite_index(&self) -> usize {
Expand Down Expand Up @@ -660,73 +660,6 @@ pub enum Motivation { // Sorted in order of prioritization.
Crisis, Rage, Order, Danger, Hunger, Thirst, Tired, Injured, Sick, Bored, Happy, Sad, Angry, Lonely, Love, Fear, Hate, Work, Personality, Meander, Idle
}

// #[derive(Component, PartialEq, Copy, Clone, Debug)]
// pub enum PlantType {
// Aloe,
// Azalea,
// Bush,
// Cabbage,
// CactusRound,
// CactusUp,
// Carrot,
// CedarTree,
// FlowerBush,
// PineTree,
// OakTree,
// ThornBush,
// Vine,
// Weed,
// }

// impl PlantType {
// pub fn is_edible(&self) -> bool {
// matches!(self, PlantType::Cabbage)
// }
// pub fn sprite_row_and_col(&self) -> (usize, usize) {
// match self {
// PlantType::Aloe => (67, 57),
// PlantType::Azalea => (67, 57),
// PlantType::Bush => (67, 57),
// PlantType::Cabbage => (94, 32),
// PlantType::CactusRound => (67, 57),
// PlantType::CactusUp => (67, 57),
// PlantType::Carrot => (94, 31),
// PlantType::CedarTree => (13, 15),
// PlantType::PineTree => (13, 13),
// PlantType::OakTree => (13, 14),
// PlantType::ThornBush => (67, 57),
// PlantType::FlowerBush => (67, 57),
// PlantType::Vine => (67, 57),
// PlantType::Weed => (67, 57),
// }
// }
// pub fn sprite_index(&self) -> usize {
// let (row, col) = self.sprite_row_and_col();
// row * 64 + col
// }
// pub fn growth_speed(&self) -> f32 {
// match self {
// PlantType::Cabbage => 0.001,
// _ => 0.01
// }
// }
// pub fn is_forageable(&self) -> (Option<ItemType>, i32, ForageType) {
// match self {
// PlantType::Cabbage => (Some(ItemType::Cabbage), 1, ForageType::Once),
// PlantType::Carrot => (Some(ItemType::Carrot), 1, ForageType::Once),
// _ => (None, 0, ForageType::Once),
// }
// }
// pub fn is_choppable(&self) -> (Option<ItemType>, i32) {
// match self {
// PlantType::PineTree => (Some(ItemType::PineLog), 1),
// PlantType::OakTree => (Some(ItemType::OakLog), 1),
// PlantType::CedarTree => (Some(ItemType::CedarLog), 1),
// _ => (None, 0),
// }
// }
// }

#[derive(Component, PartialEq, Copy, Clone, Debug)]
pub enum ForageType {
Once, Repeat
Expand Down
2 changes: 1 addition & 1 deletion src/initializations/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn startup(
..default()
})
.insert(position)
.insert(SizeXYZ::cube(1.1))
.insert(SizeXYZ::cube(1.0))
.insert(MonsterGenerator { monsters: vec![(UnitTemplate::rat(),1),(UnitTemplate::spider(),5),(UnitTemplate::cyclops(),1)] })
.insert(position.to_transform_layer(1.0))
;
Expand Down
4 changes: 3 additions & 1 deletion src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ pub use click::*;
mod input;
pub use input::*;
mod pause;
pub use pause::*;
pub use pause::*;
mod main_menu;
pub use main_menu::*;
2 changes: 1 addition & 1 deletion src/main_menu.rs → src/interface/main_menu.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::prelude::*;
use crate::prelude::*;

pub struct MainMenusPlugin;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::prelude::*;
use crate::prelude::*;

struct MainMenuPlugin;

Expand Down
3 changes: 1 addition & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ use initializations::*;
mod interface;
use interface::*;
mod objects;
mod main_menu;
use main_menu::*;
mod monstergenerator_system;
use monstergenerator_system::*;
mod moverandom_system;
Expand Down Expand Up @@ -49,6 +47,7 @@ use unitgenerator_system::*;
fn main() {
//println!("Hello, world!");
App::new()
.insert_resource(Msaa::Off)
.add_plugins((DefaultPlugins, BiomePlugin, StartupPlugin))
.add_systems(
PreStartup, (load_sprites, load_font, load_sfx)
Expand Down
90 changes: 48 additions & 42 deletions src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ pub enum ItemType {
LeafyDebris2,
LeafyDebris3,
LeafyDebris4,
WallBrick,
WallMetal,
WallStone,
WallWood,
Aloe,
Azalea,
Expand All @@ -173,44 +176,44 @@ impl ItemType {
ItemType::CedarLog => (94, 30),
ItemType::PineLog => (94, 30),
ItemType::OakLog => (94, 30),
ItemType::StatuePillar1 => (12, 12),
ItemType::StatuePillar2 => (12, 13),
ItemType::StatuePillar3 => (12, 14),
ItemType::StatuePillar4 => (12, 15),
ItemType::StatuePillar5 => (12, 16),
ItemType::StatuePillar6 => (12, 17),
ItemType::StatuePillar7 => (12, 18),
ItemType::StatueElephant => (12, 19),
ItemType::StatueHead => (12, 20),
ItemType::StatueIDK1 => (12, 21),
ItemType::StatueIDK2 => (12, 22),
ItemType::StatueGold => (12, 23),
ItemType::StatueMan => (12, 24),
ItemType::StatuePlatform => (12, 25),
ItemType::StatueAnd => (12, 26),
ItemType::StatueAt => (12, 27),
ItemType::StatueAngel => (12, 28),
ItemType::StatueArcher => (12, 29),
ItemType::StatueHover => (12, 30),
ItemType::StatueCat => (12, 31),
ItemType::StatueCentaur => (12, 32),
ItemType::StatueKing => (12, 33),
ItemType::StatueKnight => (12, 34),
ItemType::StatueDragon => (12, 35),
ItemType::StatueDwarf => (12, 36),
ItemType::StatueMastodon => (12, 37),
ItemType::StatueHydra => (12, 38),
ItemType::StatueSpearman => (12, 39),
ItemType::StatueBall => (12, 40),
ItemType::StatueBigfoot => (12, 41),
ItemType::StatuePrincess => (12, 42),
ItemType::StatueDeath => (12, 43),
ItemType::StatueSnail => (12, 44),
ItemType::StatueSword => (12, 45),
ItemType::StatueDragon2 => (12, 46),
ItemType::StatueTriangle => (12, 47),
ItemType::StatueWizard => (12, 48),
ItemType::StatueGhost => (12, 49),
ItemType::StatuePillar1 => (19, 12),
ItemType::StatuePillar2 => (19, 13),
ItemType::StatuePillar3 => (19, 14),
ItemType::StatuePillar4 => (19, 15),
ItemType::StatuePillar5 => (19, 16),
ItemType::StatuePillar6 => (19, 17),
ItemType::StatuePillar7 => (19, 18),
ItemType::StatueElephant => (19, 19),
ItemType::StatueHead => (19, 20),
ItemType::StatueIDK1 => (19, 21),
ItemType::StatueIDK2 => (19, 22),
ItemType::StatueGold => (19, 23),
ItemType::StatueMan => (19, 24),
ItemType::StatuePlatform => (19, 25),
ItemType::StatueAnd => (19, 26),
ItemType::StatueAt => (19, 27),
ItemType::StatueAngel => (19, 28),
ItemType::StatueArcher => (19, 29),
ItemType::StatueHover => (19, 30),
ItemType::StatueCat => (19, 31),
ItemType::StatueCentaur => (19, 32),
ItemType::StatueKing => (19, 33),
ItemType::StatueKnight => (19, 34),
ItemType::StatueDragon => (19, 35),
ItemType::StatueDwarf => (19, 36),
ItemType::StatueMastodon => (19, 37),
ItemType::StatueHydra => (19, 38),
ItemType::StatueSpearman => (19, 39),
ItemType::StatueBall => (19, 40),
ItemType::StatueBigfoot => (19, 41),
ItemType::StatuePrincess => (19, 42),
ItemType::StatueDeath => (19, 43),
ItemType::StatueSnail => (19, 44),
ItemType::StatueSword => (19, 45),
ItemType::StatueDragon2 => (19, 46),
ItemType::StatueTriangle => (19, 47),
ItemType::StatueWizard => (19, 48),
ItemType::StatueGhost => (19, 49),
ItemType::Moss1 => (51, 3),
ItemType::Moss2 => (51, 4),
ItemType::Moss3 => (51, 5),
Expand All @@ -227,17 +230,20 @@ impl ItemType {
ItemType::LeafyDebris2 => (50, 16),
ItemType::LeafyDebris3 => (50, 17),
ItemType::LeafyDebris4 => (50, 18),
ItemType::WallWood => (7, 32),
ItemType::WallBrick => (8, 0),
ItemType::WallMetal => (1, 61),
ItemType::WallStone => (3, 10),
ItemType::WallWood => (6, 32),
ItemType::Aloe => (67, 57),
ItemType::Azalea => (67, 57),
ItemType::Bush => (67, 57),
ItemType::Cabbage => (94, 32),
ItemType::CactusRound => (67, 57),
ItemType::CactusUp => (67, 57),
ItemType::Carrot => (94, 31),
ItemType::CedarTree => (13, 15),
ItemType::PineTree => (13, 13),
ItemType::OakTree => (13, 14),
ItemType::CedarTree => (20, 14),
ItemType::PineTree => (20, 15),
ItemType::OakTree => (20, 16),
ItemType::ThornBush => (67, 57),
ItemType::FlowerBush => (67, 57),
ItemType::Vine => (67, 57),
Expand Down
5 changes: 3 additions & 2 deletions src/task_system/forage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::prelude::*;
pub fn task_system_forage(
mut commands: Commands,
mut entities_that_might_forage: Query<(Entity, &mut Brain, &Position, Option<&Pathing>, Option<&Targeting>)>,
mut foragables: Query<(Entity, &Position, &Foragable, &mut Plant)>,
mut foragables: Query<(Entity, &Position, &Foragable, &mut Plant, Option<&WorkTarget>)>,
sprite_sheet: Res<SpriteSheet>,
) {
let mut already_targeted = crate::set_already_targetted(&entities_that_might_forage);
Expand All @@ -12,7 +12,8 @@ pub fn task_system_forage(
if brain.task != Some(Task::Forage) { continue; }
let mut did_foraging = false;
let mut nearest_entity: Option<NearestEntity> = None;
for (foragable_entity, foragable_position, _, mut plant) in foragables.iter_mut() {
for (foragable_entity, foragable_position, _, mut plant, worktarget) in foragables.iter_mut() {
if brain.motivation != Some(Motivation::Hunger) && worktarget.is_none() { continue; }
// If you are already next to it, forage it, if you are targetting it.
let distance = position.distance(foragable_position);
if distance <= 1 && targeting.is_some() && targeting.unwrap().target == foragable_entity {
Expand Down

0 comments on commit 0c34edb

Please sign in to comment.