Skip to content

Commit

Permalink
added field instance string getters
Browse files Browse the repository at this point in the history
  • Loading branch information
stinkytoe committed Feb 8, 2025
1 parent 32ad330 commit f407205
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/item/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ impl EntityItem<'_, '_> {
.map(|value| TilesetRectangle::new(value.clone()))
}

// FIXME: Explore returning an iterator instead of allocating a vec?
pub fn get_field_array_tiles(&self, identifier: &str) -> Option<Vec<TilesetRectangle>> {
self.get_asset()
.get_field_instance(identifier)?
Expand All @@ -113,6 +114,20 @@ impl EntityItem<'_, '_> {
.collect()
})
}

pub fn get_field_string(&self, identifier: &str) -> Option<&str> {
self.get_asset()
.get_field_instance(identifier)?
.get_string()
.map(|str| str.as_str())
}

pub fn get_field_array_string(&self, identifier: &str) -> Option<Vec<&str>> {
self.get_asset()
.get_field_instance(identifier)?
.get_array_string()
.map(|value| value.iter().map(|str| str.as_str()).collect())
}
}

impl EntityItem<'_, '_> {
Expand Down

0 comments on commit f407205

Please # to comment.