"new id" and "add thing" functions
This commit is contained in:
parent
7405090009
commit
67628e4879
30
src/game.rs
30
src/game.rs
|
@ -393,6 +393,18 @@ impl Game {
|
|||
new_unique_id(ids)
|
||||
}
|
||||
|
||||
pub fn new_sprite_id(&self) -> String {
|
||||
new_unique_id(self.sprite_ids())
|
||||
}
|
||||
|
||||
pub fn new_room_id(&self) -> String {
|
||||
new_unique_id(self.room_ids())
|
||||
}
|
||||
|
||||
pub fn new_item_id(&self) -> String {
|
||||
new_unique_id(self.item_ids())
|
||||
}
|
||||
|
||||
/// adds a tile safely and returns the new tile ID
|
||||
#[inline]
|
||||
pub fn add_tile(&mut self, mut tile: Tile) -> String {
|
||||
|
@ -402,6 +414,24 @@ impl Game {
|
|||
new_id
|
||||
}
|
||||
|
||||
/// adds a sprite safely and returns the new sprite ID
|
||||
#[inline]
|
||||
pub fn add_sprite(&mut self, mut sprite: Sprite) -> String {
|
||||
let new_id = self.new_sprite_id();
|
||||
sprite.id = new_id.clone();
|
||||
self.sprites.push(sprite);
|
||||
new_id
|
||||
}
|
||||
|
||||
/// adds a sprite safely and returns the new sprite ID
|
||||
#[inline]
|
||||
pub fn add_item(&mut self, mut item: Item) -> String {
|
||||
let new_id = self.new_item_id();
|
||||
item.id = new_id.clone();
|
||||
self.items.push(item);
|
||||
new_id
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn version_line(&self) -> String {
|
||||
if self.version.is_some() {
|
||||
|
|
Loading…
Reference in New Issue