Browse Source

started working on items

master
Thomas Johnson 6 months ago
parent
commit
581fc407b7
  1. 9
      src/world/inventory.rs
  2. 14
      src/world/item.rs
  3. 2
      src/world/mod.rs

9
src/world/inventory.rs

@ -0,0 +1,9 @@
use std::rc::Rc;
use std::cell::RefCell;
use super::item::{Item, ItemRef};
pub struct Inventory {
items: Vec<Rc<RefCell<dyn Item>>>,
}

14
src/world/item.rs

@ -0,0 +1,14 @@
use std::cell::RefCell;
use std::rc::{Rc, Weak};
pub type ItemRef = Rc<RefCell<dyn Item>>;
pub type ItemWeak = Weak<RefCell<dyn Item>>;
pub trait Item {
}
pub fn item_ref<I: Item + 'static>(item: I) -> ItemRef{
Rc::new(RefCell::new(item))
}

2
src/world/mod.rs

@ -1,6 +1,8 @@
pub mod render;
pub mod gen;
pub mod entity;
pub mod item;
pub mod inventory;
use rogue_util::{coord::*, grid::{Grid, region::{Region, RegionConfig}, path::Traversable}};
use std::cell::RefCell;

Loading…
Cancel
Save