mirror of
https://github.com/SpaceManiac/SpacemanDMM.git
synced 2025-12-23 05:36:47 +00:00
Port some functionality to adjust_sprite
This commit is contained in:
parent
a521fbac39
commit
457dbbabd9
2 changed files with 24 additions and 8 deletions
|
|
@ -202,12 +202,13 @@ impl RenderPass for FakeGlass {
|
|||
#[derive(Default)]
|
||||
pub struct Pretty;
|
||||
impl RenderPass for Pretty {
|
||||
fn adjust_vars<'a>(&self,
|
||||
atom: &mut Atom<'a>,
|
||||
fn adjust_sprite<'a>(&self,
|
||||
atom: &Atom<'a>,
|
||||
sprite: &mut Sprite<'a>,
|
||||
_: &'a ObjectTree,
|
||||
) {
|
||||
if atom.istype("/obj/structure/bookcase/") {
|
||||
atom.set_var("icon_state", Constant::string("book-0"));
|
||||
sprite.icon_state = "book-0";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use super::*;
|
||||
|
||||
use rand::Rng;
|
||||
use rand::seq::SliceRandom;
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -59,7 +60,6 @@ impl RenderPass for Random {
|
|||
atom: &mut Atom<'a>,
|
||||
objtree: &'a ObjectTree,
|
||||
) {
|
||||
use rand::Rng;
|
||||
let mut rng = ::rand::thread_rng();
|
||||
|
||||
const CONTRABAND_POSTERS: u32 = 44;
|
||||
|
|
@ -103,12 +103,27 @@ impl RenderPass for Random {
|
|||
atom.set_var("icon_state", c.clone());
|
||||
}
|
||||
}
|
||||
} else if atom.istype("/obj/item/lipstick/random/") {
|
||||
atom.set_var("icon_state", Constant::string("lipstick"));
|
||||
}
|
||||
}
|
||||
|
||||
fn adjust_sprite<'a>(&self,
|
||||
atom: &Atom<'a>,
|
||||
sprite: &mut Sprite<'a>,
|
||||
_: &'a ObjectTree,
|
||||
) {
|
||||
let mut rng = ::rand::thread_rng();
|
||||
|
||||
if atom.istype("/obj/item/lipstick/random/") {
|
||||
sprite.icon_state = "lipstick";
|
||||
// random color is not outwardly visible
|
||||
} else if atom.istype("/obj/item/device/tape/random/") {
|
||||
let icon = format!("tape_{}", ["white", "blue", "red", "yellow", "purple"].choose(&mut rng).unwrap());
|
||||
atom.set_var("icon_state", Constant::string(icon));
|
||||
sprite.icon_state = [
|
||||
"tape_white",
|
||||
"tape_blue",
|
||||
"tape_red",
|
||||
"tape_yellow",
|
||||
"tape_purple",
|
||||
].choose(&mut rng).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue