Explosions no longer change block colours within the radius of a safe zone. Doubled the radius of the safe zone in the /home town.

This commit is contained in:
Ben Wallis 2021-08-20 08:44:34 +01:00
parent ef21c433dc
commit 9e35f5ec33
3 changed files with 46 additions and 5 deletions

View File

@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Can now tilt glider while only wielding it
- Experimental terrain persistence (see server documentation)
- Add GPU filtering using WGPU_ADAPTER environment variable
- Explosions no longer change block colours within safe zones
### Changed
@ -53,6 +54,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Glider dimensions now depend on character height
- Glider dimensions somewhat increased overall
- Dungeon difficulty level starts at 1 instead of 0
- The radius of the safe zone around the starting town has been doubled
### Removed

View File

@ -4,9 +4,10 @@ use crate::{
agent::{Agent, AgentEvent, Sound, SoundKind},
biped_large, bird_large, quadruped_low, quadruped_medium, quadruped_small,
skills::SkillGroupKind,
theropod, PhysicsState,
theropod, BuffKind, BuffSource, PhysicsState,
},
rtsim::RtSim,
sys::terrain::SAFE_ZONE_RADIUS,
Server, SpawnPoint, StateExt,
};
use common::{
@ -16,8 +17,9 @@ use common::{
self, aura, buff,
chat::{KillSource, KillType},
inventory::item::MaterialStatManifest,
object, Alignment, Body, CharacterState, Energy, EnergyChange, Group, Health, HealthChange,
HealthSource, Inventory, Player, Poise, PoiseChange, PoiseSource, Pos, SkillSet, Stats,
object, Alignment, Auras, Body, CharacterState, Energy, EnergyChange, Group, Health,
HealthChange, HealthSource, Inventory, Player, Poise, PoiseChange, PoiseSource, Pos,
SkillSet, Stats,
},
event::{EventBus, ServerEvent},
lottery::{LootSpec, Lottery},
@ -741,11 +743,46 @@ pub fn handle_explosion(server: &Server, pos: Vec3<f32>, explosion: Explosion, o
// TODO: Faster RNG?
let mut rng = rand::thread_rng();
for effect in explosion.effects {
'effects: for effect in explosion.effects {
match effect {
RadiusEffect::TerrainDestruction(power) => {
const RAYS: usize = 500;
let spatial_grid = ecs.read_resource::<common::CachedSpatialGrid>();
let auras = ecs.read_storage::<Auras>();
let positions = ecs.read_storage::<Pos>();
// Prevent block colour changes within the radius of a safe zone aura
if spatial_grid
.0
.in_circle_aabr(pos.xy(), SAFE_ZONE_RADIUS)
.filter_map(|entity| {
auras
.get(entity)
.and_then(|entity_auras| {
positions.get(entity).map(|pos| (entity_auras, pos))
})
.and_then(|(entity_auras, pos)| {
entity_auras
.auras
.iter()
.find(|(_, aura)| {
matches!(aura.aura_kind, aura::AuraKind::Buff {
kind: BuffKind::Invulnerability,
source: BuffSource::World,
..
})
})
.map(|(_, aura)| (*pos, aura.radius))
})
})
.any(|(aura_pos, aura_radius)| {
pos.distance_squared(aura_pos.0) < aura_radius.powi(2)
})
{
continue 'effects;
}
// Color terrain
let mut touched_blocks = Vec::new();
let color_range = power * 2.7;

View File

@ -36,6 +36,8 @@ pub(crate) struct LazyTerrainMessage {
lazy_msg_hi: Option<crate::client::PreparedMsg>,
}
pub const SAFE_ZONE_RADIUS: f32 = 200.0;
impl LazyTerrainMessage {
#[allow(clippy::new_without_default)]
pub(crate) fn new() -> Self {
@ -241,7 +243,7 @@ impl<'a> System<'a> for Sys {
// Insert a safezone if chunk contains the spawn position
if server_settings.safe_spawn && is_spawn_chunk(key, *spawn_point, &terrain) {
server_emitter.emit(ServerEvent::CreateSafezone {
range: Some(100.0),
range: Some(SAFE_ZONE_RADIUS),
pos: Pos(spawn_point.0),
});
}