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