Apply watcher properties more sensibly

This commit is contained in:
Joshua Barretto 2024-01-21 16:28:21 +00:00
parent e0ebe6939e
commit e231b8f9c1

View File

@ -139,85 +139,96 @@ impl BlocksOfInterest {
} }
}, },
BlockKind::Snow | BlockKind::Ice if rng.gen_range(0..16) == 0 => snow.push(pos), BlockKind::Snow | BlockKind::Ice if rng.gen_range(0..16) == 0 => snow.push(pos),
_ => match block.get_sprite() { _ => {
Some(SpriteKind::Ember) => { if let Some(sprite) = block.get_sprite() {
if sprite.category() == sprite::Category::Lamp {
if let Ok(sprite::LightDisabled(disabled)) = block.get_attr() {
interactables.push((pos, Interaction::LightToggle(disabled)));
}
}
if block.is_mountable() {
interactables.push((pos, Interaction::Mount));
}
match sprite {
SpriteKind::Ember => {
fires.push(pos); fires.push(pos);
smokers.push(SmokerProperties::new(pos, FireplaceType::House)); smokers.push(SmokerProperties::new(pos, FireplaceType::House));
}, },
// Offset positions to account for block height. // Offset positions to account for block height.
// TODO: Is this a good idea? // TODO: Is this a good idea?
Some(SpriteKind::StreetLamp) => fire_bowls.push(pos + Vec3::unit_z() * 2), SpriteKind::StreetLamp => fire_bowls.push(pos + Vec3::unit_z() * 2),
Some(SpriteKind::FireBowlGround) => fire_bowls.push(pos + Vec3::unit_z()), SpriteKind::FireBowlGround => fire_bowls.push(pos + Vec3::unit_z()),
Some(SpriteKind::StreetLampTall) => fire_bowls.push(pos + Vec3::unit_z() * 4), SpriteKind::StreetLampTall => fire_bowls.push(pos + Vec3::unit_z() * 4),
Some(SpriteKind::WallSconce) => fire_bowls.push(pos + Vec3::unit_z()), SpriteKind::WallSconce => fire_bowls.push(pos + Vec3::unit_z()),
Some(SpriteKind::Beehive) => beehives.push(pos), SpriteKind::Beehive => beehives.push(pos),
Some(SpriteKind::CrystalHigh) => fireflies.push(pos), SpriteKind::CrystalHigh => fireflies.push(pos),
Some(SpriteKind::Reed) => { SpriteKind::Reed => {
reeds.push(pos); reeds.push(pos);
fireflies.push(pos); fireflies.push(pos);
if rng.gen_range(0..12) == 0 { if rng.gen_range(0..12) == 0 {
frogs.push(pos); frogs.push(pos);
} }
}, },
Some(SpriteKind::CaveMushroom) => fireflies.push(pos), SpriteKind::CaveMushroom => fireflies.push(pos),
Some(SpriteKind::PinkFlower) => flowers.push(pos), SpriteKind::PinkFlower => flowers.push(pos),
Some(SpriteKind::PurpleFlower) => flowers.push(pos), SpriteKind::PurpleFlower => flowers.push(pos),
Some(SpriteKind::RedFlower) => flowers.push(pos), SpriteKind::RedFlower => flowers.push(pos),
Some(SpriteKind::WhiteFlower) => flowers.push(pos), SpriteKind::WhiteFlower => flowers.push(pos),
Some(SpriteKind::YellowFlower) => flowers.push(pos), SpriteKind::YellowFlower => flowers.push(pos),
Some(SpriteKind::Sunflower) => flowers.push(pos), SpriteKind::Sunflower => flowers.push(pos),
Some(SpriteKind::CraftingBench) => { SpriteKind::CraftingBench => {
interactables.push((pos, Interaction::Craft(CraftingTab::All))) interactables.push((pos, Interaction::Craft(CraftingTab::All)))
}, },
Some(SpriteKind::SmokeDummy) => { SpriteKind::SmokeDummy => {
smokers.push(SmokerProperties::new(pos, FireplaceType::Workshop)); smokers.push(SmokerProperties::new(pos, FireplaceType::Workshop));
}, },
Some(SpriteKind::Forge) => interactables SpriteKind::Forge => interactables
.push((pos, Interaction::Craft(CraftingTab::ProcessedMaterial))), .push((pos, Interaction::Craft(CraftingTab::ProcessedMaterial))),
Some(SpriteKind::TanningRack) => interactables SpriteKind::TanningRack => interactables
.push((pos, Interaction::Craft(CraftingTab::ProcessedMaterial))), .push((pos, Interaction::Craft(CraftingTab::ProcessedMaterial))),
Some(SpriteKind::SpinningWheel) => { SpriteKind::SpinningWheel => {
interactables.push((pos, Interaction::Craft(CraftingTab::All))) interactables.push((pos, Interaction::Craft(CraftingTab::All)))
}, },
Some(SpriteKind::Loom) => { SpriteKind::Loom => {
interactables.push((pos, Interaction::Craft(CraftingTab::All))) interactables.push((pos, Interaction::Craft(CraftingTab::All)))
}, },
Some(SpriteKind::Cauldron) => { SpriteKind::Cauldron => {
fires.push(pos); fires.push(pos);
interactables.push((pos, Interaction::Craft(CraftingTab::Potion))) interactables.push((pos, Interaction::Craft(CraftingTab::Potion)))
}, },
Some(SpriteKind::Anvil) => { SpriteKind::Anvil => {
interactables.push((pos, Interaction::Craft(CraftingTab::Weapon))) interactables.push((pos, Interaction::Craft(CraftingTab::Weapon)))
}, },
Some(SpriteKind::CookingPot) => { SpriteKind::CookingPot => {
fires.push(pos); fires.push(pos);
interactables.push((pos, Interaction::Craft(CraftingTab::Food))) interactables.push((pos, Interaction::Craft(CraftingTab::Food)))
}, },
Some(SpriteKind::DismantlingBench) => { SpriteKind::DismantlingBench => {
fires.push(pos); fires.push(pos);
interactables.push((pos, Interaction::Craft(CraftingTab::Dismantle))) interactables
.push((pos, Interaction::Craft(CraftingTab::Dismantle)))
}, },
Some(SpriteKind::RepairBench) => { SpriteKind::RepairBench => {
interactables.push((pos, Interaction::Craft(CraftingTab::All))) interactables.push((pos, Interaction::Craft(CraftingTab::All)))
}, },
Some(SpriteKind::OneWayWall) => one_way_walls.push(( SpriteKind::OneWayWall => one_way_walls.push((
pos, pos,
Vec2::unit_y() Vec2::unit_y()
.rotated_z( .rotated_z(
std::f32::consts::PI * 0.25 * block.get_ori().unwrap_or(0) as f32, std::f32::consts::PI
* 0.25
* block.get_ori().unwrap_or(0) as f32,
) )
.with_z(0.0), .with_z(0.0),
)), )),
Some(SpriteKind::Sign | SpriteKind::HangingSign) => { SpriteKind::Sign | SpriteKind::HangingSign => {
interactables.push((pos, Interaction::Read)) interactables.push((pos, Interaction::Read))
}, },
Some(sprite) if sprite.category() == sprite::Category::Lamp => {
if let Ok(sprite::LightDisabled(disabled)) = block.get_attr() {
interactables.push((pos, Interaction::LightToggle(disabled)));
}
},
_ if block.is_mountable() => interactables.push((pos, Interaction::Mount)),
_ => {}, _ => {},
}
}
}, },
} }
if block.collectible_id().is_some() { if block.collectible_id().is_some() {