Removed per-level dungeon waypoints

This commit is contained in:
Joshua Barretto 2020-11-16 20:53:17 +00:00
parent e09c22f9cc
commit 28b0a00b44
5 changed files with 47 additions and 20 deletions

View File

@ -25,11 +25,10 @@ use common::{
},
event::{EventBus, LocalEvent},
msg::{
validate_chat_msg, ChatMsgValidationError, ClientGeneral, ClientMsg, ClientRegister,
ClientType, DisconnectReason, InviteAnswer, Notification, PingMsg, PlayerInfo,
PlayerListUpdate, PresenceKind, RegisterError, ServerGeneral, ServerInfo, ServerInit,
ServerRegisterAnswer, MAX_BYTES_CHAT_MSG,
world_msg::SiteInfo,
validate_chat_msg, world_msg::SiteInfo, ChatMsgValidationError, ClientGeneral, ClientMsg,
ClientRegister, ClientType, DisconnectReason, InviteAnswer, Notification, PingMsg,
PlayerInfo, PlayerListUpdate, PresenceKind, RegisterError, ServerGeneral, ServerInfo,
ServerInit, ServerRegisterAnswer, MAX_BYTES_CHAT_MSG,
},
outcome::Outcome,
recipe::RecipeBook,
@ -646,9 +645,7 @@ impl Client {
}
/// Unstable, likely to be removed in a future release
pub fn sites(&self) -> &[SiteInfo] {
&self.sites
}
pub fn sites(&self) -> &[SiteInfo] { &self.sites }
pub fn enable_lantern(&mut self) {
self.send_msg(ClientGeneral::ControlEvent(ControlEvent::EnableLantern));

View File

@ -42,9 +42,9 @@ use crate::{
data_dir::DataDir,
login_provider::LoginProvider,
presence::{Presence, RegionSubscription},
rtsim::RtSim,
state_ext::StateExt,
sys::sentinel::{DeletedEntities, TrackedComps},
rtsim::RtSim,
};
use common::{
assets::Asset,
@ -52,16 +52,17 @@ use common::{
comp::{self, ChatType},
event::{EventBus, ServerEvent},
msg::{
ClientType, DisconnectReason, ServerGeneral, ServerInfo, ServerInit, ServerMsg, WorldMapMsg,
world_msg::{SiteInfo, SiteKind},
ClientType, DisconnectReason, ServerGeneral, ServerInfo, ServerInit, ServerMsg,
WorldMapMsg,
},
outcome::Outcome,
recipe::default_recipe_book,
rtsim::RtSimEntity,
state::{State, TimeOfDay},
sync::WorldSyncExt,
terrain::TerrainChunkSize,
vol::{ReadVol, RectVolSize},
rtsim::RtSimEntity,
};
use futures_executor::block_on;
use metrics::{PhysicsMetrics, ServerMetrics, StateTickMetrics, TickMetrics};
@ -559,8 +560,17 @@ impl Server {
for entity in to_delete {
// Assimilate entities that are part of the real-time world simulation
if let Some(rtsim_entity) = self.state.ecs().read_storage::<RtSimEntity>().get(entity).copied() {
self.state.ecs().write_resource::<RtSim>().assimilate_entity(rtsim_entity.0);
if let Some(rtsim_entity) = self
.state
.ecs()
.read_storage::<RtSimEntity>()
.get(entity)
.copied()
{
self.state
.ecs()
.write_resource::<RtSim>()
.assimilate_entity(rtsim_entity.0);
}
if let Err(e) = self.state.delete_entity_recorded(entity) {

View File

@ -109,6 +109,15 @@ impl<'a> System<'a> for Sys {
// Handle chunk supplement
for entity in supplement.entities {
// Check this because it's a common source of weird bugs
assert!(
terrain
.pos_key(entity.pos.map(|e| e.floor() as i32))
.map2(key, |e, tgt| (e - tgt).abs() <= 1)
.reduce_and(),
"Chunk spawned entity that wasn't nearby",
);
if entity.is_waypoint {
server_emitter.emit(ServerEvent::CreateWaypoint(entity.pos));
continue;

View File

@ -20,11 +20,11 @@ mod column;
pub mod config;
pub mod index;
pub mod layer;
pub mod pathfinding;
pub mod sim;
pub mod sim2;
pub mod site;
pub mod util;
pub mod pathfinding;
// Reexports
pub use crate::{

View File

@ -175,6 +175,17 @@ impl Dungeon {
max: rpos + TerrainChunkSize::RECT_SIZE.map(|e| e as i32),
};
// Add waypoint
let pos = self.origin.map2(FLOOR_SIZE, |e, sz| e + sz as i32 / 2);
if area.contains_point(pos - self.origin) {
supplement.add_entity(EntityInfo::at(Vec3::new(
pos.x as f32,
pos.y as f32,
self.alt as f32,
) + 0.5)
.into_waypoint());
}
let mut z = self.alt + ALT_OFFSET;
for floor in &self.floors {
z -= floor.total_depth();
@ -452,12 +463,12 @@ impl Floor {
.try_normalized()
.unwrap_or_else(Vec2::unit_y)
* (TILE_SIZE as f32 / 2.0 - 4.0);
if !self.final_level {
supplement.add_entity(
EntityInfo::at((origin + stair_rcenter).map(|e| e as f32) + Vec3::from(offs))
.into_waypoint(),
);
}
// if !self.final_level {
// supplement.add_entity(
// EntityInfo::at((origin + stair_rcenter).map(|e| e as f32)
// + Vec3::from(offs)) .into_waypoint(),
// );
// }
}
for x in area.min.x..area.max.x {