Add MagicItem component
This commit is contained in:
parent
41c0ae7eab
commit
b0bdd44e18
@ -374,6 +374,11 @@ pub struct ApplyTeleport {
|
|||||||
pub dest_depth: i32,
|
pub dest_depth: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Component, Debug, Serialize, Deserialize, Clone)]
|
||||||
|
pub struct MagicItem {
|
||||||
|
pub class: MagicItemClass,
|
||||||
|
}
|
||||||
|
|
||||||
// Serialization helper code. We need to implement ConvertSaveLoad for each type that contains an
|
// Serialization helper code. We need to implement ConvertSaveLoad for each type that contains an
|
||||||
// Entity.
|
// Entity.
|
||||||
|
|
||||||
|
@ -41,3 +41,10 @@ pub enum WeaponAttribute {
|
|||||||
Might,
|
Might,
|
||||||
Quickness,
|
Quickness,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq, Hash)]
|
||||||
|
pub enum MagicItemClass {
|
||||||
|
Common,
|
||||||
|
Rare,
|
||||||
|
Legendary,
|
||||||
|
}
|
||||||
|
40
src/main.rs
40
src/main.rs
@ -30,7 +30,6 @@ mod visibility_system;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
use ::rltk::{Point, RandomNumberGenerator};
|
|
||||||
use ::specs::prelude::*;
|
use ::specs::prelude::*;
|
||||||
use ::specs::saveload::{SimpleMarker, SimpleMarkerAllocator};
|
use ::specs::saveload::{SimpleMarker, SimpleMarkerAllocator};
|
||||||
use components::*;
|
use components::*;
|
||||||
@ -41,11 +40,11 @@ pub use state::*;
|
|||||||
|
|
||||||
/// Cut down on the amount of syntax to register components
|
/// Cut down on the amount of syntax to register components
|
||||||
macro_rules! register {
|
macro_rules! register {
|
||||||
// $gs is needed to get the scope at the usage point
|
// $state is needed to get the scope at the usage point
|
||||||
// $Type is the Component type that is being registered
|
// $Type is the Component type that is being registered
|
||||||
($gs: ident <- $( $Type: ty ),*,) => {
|
($state: ident <- $( $Type: ty ),*,) => {
|
||||||
$(
|
$(
|
||||||
$gs.ecs.register::<$Type>();
|
$state.ecs.register::<$Type>();
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -56,10 +55,10 @@ fn main() -> ::rltk::BError {
|
|||||||
.with_title("Roguelike Tutorial")
|
.with_title("Roguelike Tutorial")
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let mut gs = State::new();
|
let mut state = State::new();
|
||||||
|
|
||||||
register!(
|
register!(
|
||||||
gs <-
|
state <-
|
||||||
ApplyMove,
|
ApplyMove,
|
||||||
ApplyTeleport,
|
ApplyTeleport,
|
||||||
AreaOfEffect,
|
AreaOfEffect,
|
||||||
@ -85,6 +84,7 @@ fn main() -> ::rltk::BError {
|
|||||||
Item,
|
Item,
|
||||||
LightSource,
|
LightSource,
|
||||||
LootTable,
|
LootTable,
|
||||||
|
MagicItem,
|
||||||
MagicMapper,
|
MagicMapper,
|
||||||
MeleeWeapon,
|
MeleeWeapon,
|
||||||
MoveMode,
|
MoveMode,
|
||||||
@ -120,24 +120,26 @@ fn main() -> ::rltk::BError {
|
|||||||
Wearable,
|
Wearable,
|
||||||
);
|
);
|
||||||
|
|
||||||
gs.ecs.insert(SimpleMarkerAllocator::<SerializeMe>::new());
|
state
|
||||||
|
.ecs
|
||||||
|
.insert(SimpleMarkerAllocator::<SerializeMe>::new());
|
||||||
|
|
||||||
raws::load_raws();
|
raws::load_raws();
|
||||||
|
|
||||||
gs.ecs.insert(map::MasterDungeonMap::new());
|
state.ecs.insert(MasterDungeonMap::new());
|
||||||
gs.ecs.insert(Map::new(1, 64, 64, "New Map"));
|
state.ecs.insert(Map::new(1, 64, 64, "New Map"));
|
||||||
gs.ecs.insert(Point::zero());
|
state.ecs.insert(::rltk::Point::zero());
|
||||||
gs.ecs.insert(RandomNumberGenerator::new());
|
state.ecs.insert(::rltk::RandomNumberGenerator::new());
|
||||||
|
|
||||||
let player_entity = spawner::player(&mut gs.ecs, 0, 0);
|
let player_entity = spawner::player(&mut state.ecs, 0, 0);
|
||||||
gs.ecs.insert(player_entity);
|
state.ecs.insert(player_entity);
|
||||||
|
|
||||||
gs.ecs.insert(RunState::MapGeneration {});
|
state.ecs.insert(RunState::MapGeneration {});
|
||||||
gs.ecs.insert(GameLog::new("Welcome to Rusty Roguelike"));
|
state.ecs.insert(GameLog::new("Welcome to Rusty Roguelike"));
|
||||||
gs.ecs.insert(particle_system::ParticleBuilder::new());
|
state.ecs.insert(particle_system::ParticleBuilder::new());
|
||||||
gs.ecs.insert(rex_assets::RexAssets::new());
|
state.ecs.insert(rex_assets::RexAssets::new());
|
||||||
|
|
||||||
gs.generate_world_map(1, 0);
|
state.generate_world_map(1, 0);
|
||||||
|
|
||||||
::rltk::main_loop(context, gs)
|
::rltk::main_loop(context, state)
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,7 @@ pub fn save_game(ecs: &mut World) {
|
|||||||
Item,
|
Item,
|
||||||
LightSource,
|
LightSource,
|
||||||
LootTable,
|
LootTable,
|
||||||
|
MagicItem,
|
||||||
MagicMapper,
|
MagicMapper,
|
||||||
MeleeWeapon,
|
MeleeWeapon,
|
||||||
MoveMode,
|
MoveMode,
|
||||||
@ -199,6 +200,7 @@ pub fn load_game(ecs: &mut World) {
|
|||||||
Item,
|
Item,
|
||||||
LightSource,
|
LightSource,
|
||||||
LootTable,
|
LootTable,
|
||||||
|
MagicItem,
|
||||||
MagicMapper,
|
MagicMapper,
|
||||||
MeleeWeapon,
|
MeleeWeapon,
|
||||||
MoveMode,
|
MoveMode,
|
||||||
|
Loading…
Reference in New Issue
Block a user