Fix underwater campfires.

This commit is contained in:
Avi Weinstock 2021-06-30 17:51:28 -04:00
parent 398b658524
commit 110aa17642
2 changed files with 29 additions and 2 deletions

View File

@ -40,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Cases where no audio output could be produced before. - Cases where no audio output could be produced before.
- Significantly improved the performance of playing sound effects - Significantly improved the performance of playing sound effects
- Dismantle and Material crafting tabs don't have duplicated recipes - Dismantle and Material crafting tabs don't have duplicated recipes
- Campfires now despawn when underwater
## [0.10.0] - 2021-06-12 ## [0.10.0] - 2021-06-12

View File

@ -1,11 +1,13 @@
use common::{ use common::{
comp::{ comp::{
body::{object, Body},
buff::{ buff::{
Buff, BuffCategory, BuffChange, BuffData, BuffEffect, BuffId, BuffKind, BuffSource, Buff, BuffCategory, BuffChange, BuffData, BuffEffect, BuffId, BuffKind, BuffSource,
Buffs, Buffs,
}, },
fluid_dynamics::{Fluid, LiquidKind}, fluid_dynamics::{Fluid, LiquidKind},
Energy, Health, HealthChange, HealthSource, Inventory, ModifierKind, PhysicsState, Stats, Energy, Health, HealthChange, HealthSource, Inventory, LightEmitter, ModifierKind,
PhysicsState, Stats,
}, },
event::{EventBus, ServerEvent}, event::{EventBus, ServerEvent},
resources::DeltaTime, resources::DeltaTime,
@ -37,18 +39,42 @@ impl<'a> System<'a> for Sys {
ReadData<'a>, ReadData<'a>,
WriteStorage<'a, Buffs>, WriteStorage<'a, Buffs>,
WriteStorage<'a, Stats>, WriteStorage<'a, Stats>,
WriteStorage<'a, Body>,
WriteStorage<'a, LightEmitter>,
); );
const NAME: &'static str = "buff"; const NAME: &'static str = "buff";
const ORIGIN: Origin = Origin::Common; const ORIGIN: Origin = Origin::Common;
const PHASE: Phase = Phase::Create; const PHASE: Phase = Phase::Create;
fn run(_job: &mut Job<Self>, (read_data, mut buffs, mut stats): Self::SystemData) { fn run(
_job: &mut Job<Self>,
(read_data, mut buffs, mut stats, mut bodies, mut light_emitters): Self::SystemData,
) {
let mut server_emitter = read_data.server_bus.emitter(); let mut server_emitter = read_data.server_bus.emitter();
let dt = read_data.dt.0; let dt = read_data.dt.0;
// Set to false to avoid spamming server // Set to false to avoid spamming server
buffs.set_event_emission(false); buffs.set_event_emission(false);
stats.set_event_emission(false); stats.set_event_emission(false);
for (entity, mut body, physics_state) in
(&read_data.entities, &mut bodies, &read_data.physics_states).join()
{
// Put out underwater campfires. Logically belongs here since this system also
// removes burning, but campfires don't have healths/stats/energies/buffs, so
// this needs a separate loop.
if matches!(*body, Body::Object(object::Body::CampfireLit))
&& matches!(
physics_state.in_fluid,
Some(Fluid::Liquid {
kind: LiquidKind::Water,
..
})
)
{
*body = Body::Object(object::Body::Campfire);
light_emitters.remove(entity);
}
}
for (entity, mut buff_comp, energy, mut stat, health, physics_state) in ( for (entity, mut buff_comp, energy, mut stat, health, physics_state) in (
&read_data.entities, &read_data.entities,
&mut buffs, &mut buffs,