2022-01-20 11:48:58 -05:00
|
|
|
#[macro_use]
|
|
|
|
extern crate lazy_static;
|
|
|
|
|
2022-01-11 09:24:20 -05:00
|
|
|
mod ai;
|
2021-12-17 16:35:30 -05:00
|
|
|
pub mod camera;
|
2022-01-14 12:19:46 -05:00
|
|
|
mod colors;
|
2021-10-22 10:05:06 -04:00
|
|
|
mod components;
|
2021-11-03 16:04:36 -04:00
|
|
|
mod damage_system;
|
2022-01-20 11:48:58 -05:00
|
|
|
mod effects;
|
2021-11-04 10:44:52 -04:00
|
|
|
mod game_log;
|
2022-01-03 15:21:12 -05:00
|
|
|
mod gamesystem;
|
2021-11-03 16:04:36 -04:00
|
|
|
mod gui;
|
2021-11-18 10:28:49 -05:00
|
|
|
mod hunger_system;
|
2021-11-03 16:04:36 -04:00
|
|
|
mod inventory_system;
|
2022-01-10 10:21:19 -05:00
|
|
|
mod lighting_system;
|
2021-10-22 10:05:06 -04:00
|
|
|
mod map;
|
2021-12-01 10:47:41 -05:00
|
|
|
pub mod map_builders;
|
2021-11-03 16:04:36 -04:00
|
|
|
mod map_indexing_system;
|
|
|
|
mod melee_combat_system;
|
2022-01-18 11:00:13 -05:00
|
|
|
mod movement_system;
|
2021-11-16 11:33:58 -05:00
|
|
|
mod particle_system;
|
2021-10-22 10:05:06 -04:00
|
|
|
mod player;
|
2022-01-20 11:48:58 -05:00
|
|
|
mod random_table;
|
|
|
|
mod raws;
|
2021-10-22 10:05:06 -04:00
|
|
|
mod rect;
|
2021-11-29 14:59:46 -05:00
|
|
|
mod rex_assets;
|
2022-01-20 11:48:58 -05:00
|
|
|
mod saveload_system;
|
2022-01-12 10:45:13 -05:00
|
|
|
mod spatial;
|
2021-11-03 16:04:36 -04:00
|
|
|
mod spawner;
|
2022-01-18 11:40:31 -05:00
|
|
|
mod state;
|
2021-11-29 16:00:07 -05:00
|
|
|
mod trigger_system;
|
2021-10-25 15:26:39 -04:00
|
|
|
mod visibility_system;
|
2021-11-03 16:04:36 -04:00
|
|
|
|
2021-12-24 10:20:29 -05:00
|
|
|
use ::specs::prelude::*;
|
|
|
|
use ::specs::saveload::{SimpleMarker, SimpleMarkerAllocator};
|
2021-11-05 14:32:14 -04:00
|
|
|
use components::*;
|
2021-11-04 10:44:52 -04:00
|
|
|
pub use game_log::GameLog;
|
2021-11-03 16:04:36 -04:00
|
|
|
pub use map::*;
|
|
|
|
pub use rect::Rect;
|
2022-01-18 11:40:31 -05:00
|
|
|
pub use state::*;
|
2021-10-25 15:26:39 -04:00
|
|
|
|
2021-11-04 11:27:44 -04:00
|
|
|
/// Cut down on the amount of syntax to register components
|
|
|
|
macro_rules! register {
|
2022-01-19 09:38:41 -05:00
|
|
|
// $state is needed to get the scope at the usage point
|
2021-11-04 11:27:44 -04:00
|
|
|
// $Type is the Component type that is being registered
|
2022-01-19 09:38:41 -05:00
|
|
|
($state: ident <- $( $Type: ty ),*,) => {
|
2021-11-04 11:27:44 -04:00
|
|
|
$(
|
2022-01-19 09:38:41 -05:00
|
|
|
$state.ecs.register::<$Type>();
|
2021-11-04 11:27:44 -04:00
|
|
|
)*
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-24 10:38:44 -05:00
|
|
|
fn main() -> ::rltk::BError {
|
2022-01-04 12:12:08 -05:00
|
|
|
let context = ::rltk::RltkBuilder::simple(80, 60)
|
|
|
|
.unwrap()
|
2021-10-20 12:01:15 -04:00
|
|
|
.with_title("Roguelike Tutorial")
|
|
|
|
.build()?;
|
|
|
|
|
2022-01-19 09:38:41 -05:00
|
|
|
let mut state = State::new();
|
2021-10-21 12:54:39 -04:00
|
|
|
|
2021-11-04 11:27:44 -04:00
|
|
|
register!(
|
2022-01-19 09:38:41 -05:00
|
|
|
state <-
|
2022-01-18 11:00:13 -05:00
|
|
|
ApplyMove,
|
|
|
|
ApplyTeleport,
|
2021-11-05 13:12:22 -04:00
|
|
|
AreaOfEffect,
|
2022-01-05 11:46:39 -05:00
|
|
|
Attributes,
|
|
|
|
BlocksTile,
|
|
|
|
BlocksVisibility,
|
2022-01-11 15:35:59 -05:00
|
|
|
Chasing,
|
2021-11-05 14:32:14 -04:00
|
|
|
Confusion,
|
2022-01-05 11:46:39 -05:00
|
|
|
Consumable,
|
|
|
|
Door,
|
2022-01-06 10:00:42 -05:00
|
|
|
DMSerializationHelper,
|
2022-01-05 11:46:39 -05:00
|
|
|
EntityMoved,
|
|
|
|
EntryTrigger,
|
2021-11-15 09:19:22 -05:00
|
|
|
Equippable,
|
2021-11-15 09:45:12 -05:00
|
|
|
Equipped,
|
2022-01-13 10:14:13 -05:00
|
|
|
EquipmentChanged,
|
2022-01-11 14:16:23 -05:00
|
|
|
Faction,
|
2022-01-05 11:46:39 -05:00
|
|
|
Hidden,
|
|
|
|
HungerClock,
|
2022-01-19 11:04:10 -05:00
|
|
|
IdentifiedItem,
|
2022-01-05 11:46:39 -05:00
|
|
|
InBackpack,
|
|
|
|
InflictsDamage,
|
2022-01-11 09:28:45 -05:00
|
|
|
Initiative,
|
2022-01-05 11:46:39 -05:00
|
|
|
Item,
|
2022-01-10 10:21:19 -05:00
|
|
|
LightSource,
|
2022-01-05 11:46:39 -05:00
|
|
|
LootTable,
|
2022-01-19 09:38:41 -05:00
|
|
|
MagicItem,
|
2022-01-05 11:46:39 -05:00
|
|
|
MagicMapper,
|
2022-01-04 10:08:06 -05:00
|
|
|
MeleeWeapon,
|
2022-01-11 14:16:23 -05:00
|
|
|
MoveMode,
|
2022-01-11 09:33:21 -05:00
|
|
|
MyTurn,
|
2022-01-05 11:46:39 -05:00
|
|
|
Name,
|
|
|
|
NaturalAttackDefense,
|
2022-01-19 10:15:51 -05:00
|
|
|
ObfuscatedName,
|
2022-01-06 09:34:17 -05:00
|
|
|
OtherLevelPosition,
|
2021-11-16 11:33:58 -05:00
|
|
|
ParticleLifetime,
|
2022-01-05 11:46:39 -05:00
|
|
|
Player,
|
|
|
|
Pools,
|
|
|
|
Position,
|
2021-11-18 15:25:29 -05:00
|
|
|
ProvidesFood,
|
2022-01-05 11:46:39 -05:00
|
|
|
ProvidesHealing,
|
2022-01-03 10:49:12 -05:00
|
|
|
Quips,
|
2022-01-05 11:46:39 -05:00
|
|
|
Ranged,
|
|
|
|
Renderable,
|
|
|
|
SerializationHelper,
|
|
|
|
SimpleMarker<SerializeMe>,
|
|
|
|
SingleActivation,
|
2022-01-03 15:24:38 -05:00
|
|
|
Skills,
|
2022-01-05 11:46:39 -05:00
|
|
|
SufferDamage,
|
2022-01-18 11:00:13 -05:00
|
|
|
TeleportTo,
|
|
|
|
TownPortal,
|
2022-01-13 11:29:20 -05:00
|
|
|
Vendor,
|
2022-01-05 11:46:39 -05:00
|
|
|
Viewshed,
|
2022-01-11 14:16:23 -05:00
|
|
|
WantsToApproach,
|
2022-01-05 11:46:39 -05:00
|
|
|
WantsToDropItem,
|
2022-01-11 14:16:23 -05:00
|
|
|
WantsToFlee,
|
2022-01-05 11:46:39 -05:00
|
|
|
WantsToMelee,
|
|
|
|
WantsToPickupItem,
|
|
|
|
WantsToRemoveItem,
|
|
|
|
WantsToUseItem,
|
|
|
|
Wearable,
|
2021-11-04 11:27:44 -04:00
|
|
|
);
|
2021-10-21 12:54:39 -04:00
|
|
|
|
2022-01-19 09:38:41 -05:00
|
|
|
state
|
|
|
|
.ecs
|
|
|
|
.insert(SimpleMarkerAllocator::<SerializeMe>::new());
|
2021-11-08 13:58:40 -05:00
|
|
|
|
2021-12-23 11:00:37 -05:00
|
|
|
raws::load_raws();
|
|
|
|
|
2022-01-19 09:38:41 -05:00
|
|
|
state.ecs.insert(MasterDungeonMap::new());
|
|
|
|
state.ecs.insert(Map::new(1, 64, 64, "New Map"));
|
|
|
|
state.ecs.insert(::rltk::Point::zero());
|
|
|
|
state.ecs.insert(::rltk::RandomNumberGenerator::new());
|
2021-12-02 14:59:35 -05:00
|
|
|
|
2022-01-19 09:38:41 -05:00
|
|
|
let player_entity = spawner::player(&mut state.ecs, 0, 0);
|
|
|
|
state.ecs.insert(player_entity);
|
2021-12-02 14:59:35 -05:00
|
|
|
|
2022-01-19 09:38:41 -05:00
|
|
|
state.ecs.insert(RunState::MapGeneration {});
|
|
|
|
state.ecs.insert(GameLog::new("Welcome to Rusty Roguelike"));
|
|
|
|
state.ecs.insert(particle_system::ParticleBuilder::new());
|
|
|
|
state.ecs.insert(rex_assets::RexAssets::new());
|
2021-10-26 14:38:30 -04:00
|
|
|
|
2022-01-19 09:38:41 -05:00
|
|
|
state.generate_world_map(1, 0);
|
2021-12-01 14:45:27 -05:00
|
|
|
|
2022-01-19 09:38:41 -05:00
|
|
|
::rltk::main_loop(context, state)
|
2021-10-21 12:54:39 -04:00
|
|
|
}
|