mirror of
https://github.com/SpaceManiac/SpacemanDMM.git
synced 2025-12-23 05:36:47 +00:00
Fix gravity generator expansion
This commit is contained in:
parent
4d5973d6fb
commit
17b29e9bd6
1 changed files with 28 additions and 36 deletions
|
|
@ -40,48 +40,40 @@ impl RenderPass for Spawners {
|
|||
#[derive(Default)]
|
||||
pub struct GravityGen;
|
||||
impl RenderPass for GravityGen {
|
||||
fn expand<'a>(&self,
|
||||
atom: &Atom<'a>,
|
||||
objtree: &'a ObjectTree,
|
||||
output: &mut Vec<Atom<'a>>,
|
||||
) -> bool {
|
||||
if !atom.istype("/obj/machinery/gravity_generator/main/station/") {
|
||||
return false;
|
||||
}
|
||||
|
||||
for &(count, icon_state, x, y) in &[
|
||||
(1, "on_1", 1, -2),
|
||||
(2, "on_2", 0, -2),
|
||||
(3, "on_3", -1, -2),
|
||||
(4, "on_4", 1, -1),
|
||||
(5, "on_5", 0, -1),
|
||||
(6, "on_6", -1, -1),
|
||||
(7, "on_7", 1, 0),
|
||||
(9, "on_9", -1, 0),
|
||||
] {
|
||||
let new_loc = ((atom.loc.0 as i32 + x) as u32, (atom.loc.1 as i32 + y) as u32);
|
||||
let mut new_atom = Atom::from_type(objtree, "/obj/machinery/gravity_generator/part", new_loc).unwrap();
|
||||
new_atom.set_var("icon_state", Constant::string(icon_state));
|
||||
if count <= 3 {
|
||||
new_atom.set_var("layer", Constant::from(4.25)); // WALL_OBJ_LAYER
|
||||
}
|
||||
output.push(new_atom);
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// Apply overlays and underlays to an atom, in the form of pseudo-atoms.
|
||||
fn overlays<'a>(&self,
|
||||
atom: &Atom<'a>,
|
||||
objtree: &'a ObjectTree,
|
||||
_underlays: &mut Vec<Sprite<'a>>,
|
||||
overlays: &mut Vec<Sprite<'a>>,
|
||||
) {
|
||||
// energy overlay goes above the middle part
|
||||
if atom.istype("/obj/machinery/gravity_generator/part/") &&
|
||||
atom.get_var("icon_state", objtree) == &Constant::string("on_5")
|
||||
{
|
||||
add_to(overlays, atom, "activated");
|
||||
if !atom.istype("/obj/machinery/gravity_generator/main/station/") {
|
||||
return;
|
||||
}
|
||||
|
||||
for &(count, icon_state, x, y) in &[
|
||||
(1, "on_1", 1, 2),
|
||||
(2, "on_2", 0, 2),
|
||||
(3, "on_3", -1, 2),
|
||||
(4, "on_4", 1, 1),
|
||||
(5, "on_5", 0, 1),
|
||||
(6, "on_6", -1, 1),
|
||||
(7, "on_7", 1, 0),
|
||||
(9, "on_9", -1, 0),
|
||||
] {
|
||||
let mut sprite = Sprite::from_vars(objtree, &objtree.expect("/obj/machinery/gravity_generator/part"));
|
||||
sprite.ofs_x += 32 * x;
|
||||
sprite.ofs_y += 32 * y;
|
||||
sprite.icon_state = icon_state;
|
||||
sprite.plane = 0; // TODO: figure out plane handling for real
|
||||
if count <= 3 {
|
||||
sprite.layer = 4_250; // WALL_OBJ_LAYER
|
||||
}
|
||||
if count == 5 {
|
||||
// energy overlay goes above the middle part
|
||||
overlays.push(sprite.clone());
|
||||
sprite.icon_state = "activated";
|
||||
}
|
||||
overlays.push(sprite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue