mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Use Depot instead of Store for BuildArea
This commit is contained in:
parent
f08c4e6585
commit
21f794f84c
@ -14,9 +14,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- You can now jump out of rolls for a slight jump boost
|
- You can now jump out of rolls for a slight jump boost
|
||||||
- Dungeons now have multiple kinds of stairs.
|
- Dungeons now have multiple kinds of stairs.
|
||||||
- Trades now display item prices in tooltips.
|
- Trades now display item prices in tooltips.
|
||||||
|
- Admin designated build areas
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
- Permission to build is no longer tied to being an admin
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
use crate::depot::Id;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use specs::{Component, DerefFlaggedStorage};
|
use specs::{Component, DerefFlaggedStorage};
|
||||||
use specs_idvs::IdvStorage;
|
use specs_idvs::IdvStorage;
|
||||||
use vek::geom::Aabb;
|
use vek::geom::Aabb;
|
||||||
use crate::store::Id;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct CanBuild {
|
pub struct CanBuild {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd},
|
cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd},
|
||||||
fmt, hash,
|
fmt, hash,
|
||||||
@ -6,6 +7,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// Type safe index into Depot
|
/// Type safe index into Depot
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct Id<T> {
|
pub struct Id<T> {
|
||||||
idx: u32,
|
idx: u32,
|
||||||
gen: u32,
|
gen: u32,
|
||||||
|
@ -6,11 +6,11 @@ use crate::plugin::PluginMgr;
|
|||||||
use common::uid::UidAllocator;
|
use common::uid::UidAllocator;
|
||||||
use common::{
|
use common::{
|
||||||
comp,
|
comp,
|
||||||
|
depot::{Depot, Id},
|
||||||
event::{EventBus, LocalEvent, ServerEvent},
|
event::{EventBus, LocalEvent, ServerEvent},
|
||||||
region::RegionMap,
|
region::RegionMap,
|
||||||
resources::{DeltaTime, GameMode, PlayerEntity, Time, TimeOfDay},
|
resources::{DeltaTime, GameMode, PlayerEntity, Time, TimeOfDay},
|
||||||
slowjob::SlowJobPool,
|
slowjob::SlowJobPool,
|
||||||
store::{Id, Store},
|
|
||||||
terrain::{Block, TerrainChunk, TerrainGrid},
|
terrain::{Block, TerrainChunk, TerrainGrid},
|
||||||
time::DayPeriod,
|
time::DayPeriod,
|
||||||
trade::Trades,
|
trade::Trades,
|
||||||
@ -42,14 +42,14 @@ const MAX_DELTA_TIME: f32 = 1.0;
|
|||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct BuildAreas {
|
pub struct BuildAreas {
|
||||||
pub areas: Store<geom::Aabb<i32>>,
|
pub areas: Depot<geom::Aabb<i32>>,
|
||||||
pub area_names: HashMap<String, Id<Aabb<i32>>>,
|
pub area_names: HashMap<String, Id<Aabb<i32>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BuildAreas {
|
impl BuildAreas {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
areas: Store::default(),
|
areas: Depot::default(),
|
||||||
area_names: HashMap::new(),
|
area_names: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1404,8 +1404,8 @@ fn handle_build_area_remove(
|
|||||||
let ecs = server.state.ecs();
|
let ecs = server.state.ecs();
|
||||||
let mut build_areas = ecs.write_resource::<BuildAreas>();
|
let mut build_areas = ecs.write_resource::<BuildAreas>();
|
||||||
|
|
||||||
let bb_id = match &build_areas.area_names.get(&area_name) {
|
let bb_id = match build_areas.area_names.get(&area_name) {
|
||||||
Some(x) => *x.clone(),
|
Some(x) => *x,
|
||||||
None => {
|
None => {
|
||||||
server.notify_client(
|
server.notify_client(
|
||||||
client,
|
client,
|
||||||
|
@ -106,10 +106,8 @@ impl Sys {
|
|||||||
if let Some(comp_can_build) = can_build.get(entity) {
|
if let Some(comp_can_build) = can_build.get(entity) {
|
||||||
if comp_can_build.building_is_on {
|
if comp_can_build.building_is_on {
|
||||||
for area in comp_can_build.build_areas.iter() {
|
for area in comp_can_build.build_areas.iter() {
|
||||||
if build_areas.areas.contains(*area) {
|
if let Some(aabb) = build_areas.areas.get(*area) {
|
||||||
println!("build area exists!");
|
if aabb.contains_point(pos) {
|
||||||
if build_areas.areas.get(*area).contains_point(pos) {
|
|
||||||
println!("got build area!");
|
|
||||||
if let Ok(block) = terrain.get(pos) {
|
if let Ok(block) = terrain.get(pos) {
|
||||||
block_changes.set(pos, block.into_vacant());
|
block_changes.set(pos, block.into_vacant());
|
||||||
}
|
}
|
||||||
@ -123,8 +121,8 @@ impl Sys {
|
|||||||
if let Some(comp_can_build) = can_build.get(entity) {
|
if let Some(comp_can_build) = can_build.get(entity) {
|
||||||
if comp_can_build.building_is_on {
|
if comp_can_build.building_is_on {
|
||||||
for area in comp_can_build.build_areas.iter() {
|
for area in comp_can_build.build_areas.iter() {
|
||||||
if build_areas.areas.contains(*area) {
|
if let Some(aabb) = build_areas.areas.get(*area) {
|
||||||
if build_areas.areas.get(*area).contains_point(pos) {
|
if aabb.contains_point(pos) {
|
||||||
block_changes.try_set(pos, block);
|
block_changes.try_set(pos, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user