mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Removed bomb timeout
This commit is contained in:
parent
fd39ee97bc
commit
43f75f2f54
@ -39,7 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Added new animals
|
- Added new animals
|
||||||
- Better pathfinding
|
- Better pathfinding
|
||||||
- Bombs
|
- Bombs
|
||||||
- Training dummies
|
- Training dummy items
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
use crate::sync::Uid;
|
use crate::sync::Uid;
|
||||||
use specs::Component;
|
use specs::Component;
|
||||||
use specs_idvs::IDVStorage;
|
use specs_idvs::IDVStorage;
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum Object {
|
pub enum Object {
|
||||||
Bomb {
|
Bomb { owner: Option<Uid> },
|
||||||
timeout: Duration,
|
|
||||||
owner: Option<Uid>,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Component for Object {
|
impl Component for Object {
|
||||||
|
@ -78,6 +78,15 @@ pub struct PhysicsState {
|
|||||||
pub in_fluid: bool,
|
pub in_fluid: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PhysicsState {
|
||||||
|
pub fn on_surface(&self) -> Option<Vec3<f32>> {
|
||||||
|
self.on_ground
|
||||||
|
.then_some(-Vec3::unit_z())
|
||||||
|
.or_else(|| self.on_ceiling.then_some(Vec3::unit_z()))
|
||||||
|
.or(self.on_wall)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Component for PhysicsState {
|
impl Component for PhysicsState {
|
||||||
type Storage = FlaggedStorage<Self, IDVStorage<Self>>;
|
type Storage = FlaggedStorage<Self, IDVStorage<Self>>;
|
||||||
}
|
}
|
||||||
|
@ -96,11 +96,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
{
|
{
|
||||||
let mut physics_state = physics_states.get(entity).cloned().unwrap_or_default();
|
let mut physics_state = physics_states.get(entity).cloned().unwrap_or_default();
|
||||||
|
|
||||||
if sticky.is_some()
|
if sticky.is_some() && physics_state.on_surface().is_some() {
|
||||||
&& (physics_state.on_ground
|
|
||||||
|| physics_state.on_ceiling
|
|
||||||
|| physics_state.on_wall.is_some())
|
|
||||||
{
|
|
||||||
vel.0 = Vec3::zero();
|
vel.0 = Vec3::zero();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -34,12 +34,7 @@ impl<'a> System<'a> for Sys {
|
|||||||
stats.set_event_emission(true);
|
stats.set_event_emission(true);
|
||||||
|
|
||||||
// Update stats
|
// Update stats
|
||||||
for (entity, mut stats) in (
|
for (entity, mut stats) in (&entities, &mut stats.restrict_mut()).join() {
|
||||||
&entities,
|
|
||||||
&mut stats.restrict_mut(),
|
|
||||||
)
|
|
||||||
.join()
|
|
||||||
{
|
|
||||||
let (set_dead, level_up) = {
|
let (set_dead, level_up) = {
|
||||||
let stat = stats.get_unchecked();
|
let stat = stats.get_unchecked();
|
||||||
(
|
(
|
||||||
@ -74,11 +69,8 @@ impl<'a> System<'a> for Sys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update energies
|
// Update energies
|
||||||
for (character_state, mut energy) in (
|
for (character_state, mut energy) in
|
||||||
&character_states,
|
(&character_states, &mut energies.restrict_mut()).join()
|
||||||
&mut energies.restrict_mut(),
|
|
||||||
)
|
|
||||||
.join()
|
|
||||||
{
|
{
|
||||||
match character_state {
|
match character_state {
|
||||||
// Accelerate recharging energy.
|
// Accelerate recharging energy.
|
||||||
|
@ -11,7 +11,6 @@ use common::{
|
|||||||
};
|
};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use specs::{join::Join, world::WorldExt, Builder, Entity as EcsEntity, WriteStorage};
|
use specs::{join::Join, world::WorldExt, Builder, Entity as EcsEntity, WriteStorage};
|
||||||
use std::time::Duration;
|
|
||||||
use tracing::{debug, error};
|
use tracing::{debug, error};
|
||||||
use vek::Vec3;
|
use vek::Vec3;
|
||||||
|
|
||||||
@ -177,7 +176,7 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
|||||||
.get(entity)
|
.get(entity)
|
||||||
.copied()
|
.copied()
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
kind.clone(),
|
*kind,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
Some(comp::InventoryUpdateEvent::Used)
|
Some(comp::InventoryUpdateEvent::Used)
|
||||||
@ -363,14 +362,10 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
|||||||
|
|
||||||
match kind {
|
match kind {
|
||||||
item::Throwable::Bomb => {
|
item::Throwable::Bomb => {
|
||||||
new_entity = new_entity.with(comp::Object::Bomb {
|
new_entity = new_entity.with(comp::Object::Bomb { owner: uid });
|
||||||
timeout: Duration::from_secs_f32(1.0),
|
|
||||||
owner: uid,
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
item::Throwable::TrainingDummy => {
|
item::Throwable::TrainingDummy => {
|
||||||
new_entity = new_entity
|
new_entity = new_entity.with(comp::Stats::new(
|
||||||
.with(comp::Stats::new(
|
|
||||||
"Training Dummy".to_string(),
|
"Training Dummy".to_string(),
|
||||||
comp::object::Body::TrainingDummy.into(),
|
comp::object::Body::TrainingDummy.into(),
|
||||||
));
|
));
|
||||||
|
@ -4,7 +4,6 @@ use common::{
|
|||||||
state::DeltaTime,
|
state::DeltaTime,
|
||||||
};
|
};
|
||||||
use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage};
|
use specs::{Entities, Join, Read, ReadStorage, System, WriteStorage};
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
/// This system is responsible for handling misc object behaviours
|
/// This system is responsible for handling misc object behaviours
|
||||||
pub struct Sys;
|
pub struct Sys;
|
||||||
@ -21,19 +20,17 @@ impl<'a> System<'a> for Sys {
|
|||||||
|
|
||||||
fn run(
|
fn run(
|
||||||
&mut self,
|
&mut self,
|
||||||
(entities, dt, server_bus, positions, physics_states, mut objects): Self::SystemData,
|
(entities, _dt, server_bus, positions, physics_states, mut objects): Self::SystemData,
|
||||||
) {
|
) {
|
||||||
let mut server_emitter = server_bus.emitter();
|
let mut server_emitter = server_bus.emitter();
|
||||||
|
|
||||||
// Objects
|
// Objects
|
||||||
for (entity, pos, _physics, object) in
|
for (entity, pos, physics, object) in
|
||||||
(&entities, &positions, &physics_states, &mut objects).join()
|
(&entities, &positions, &physics_states, &mut objects).join()
|
||||||
{
|
{
|
||||||
match object {
|
match object {
|
||||||
Object::Bomb { owner, timeout } => {
|
Object::Bomb { owner } => {
|
||||||
if let Some(t) = timeout.checked_sub(Duration::from_secs_f32(dt.0)) {
|
if physics.on_surface().is_some() {
|
||||||
*timeout = t;
|
|
||||||
} else {
|
|
||||||
server_emitter.emit(ServerEvent::Destroy {
|
server_emitter.emit(ServerEvent::Destroy {
|
||||||
entity,
|
entity,
|
||||||
cause: HealthSource::Suicide,
|
cause: HealthSource::Suicide,
|
||||||
|
@ -330,10 +330,7 @@ impl<'a> Widget for Overhead<'a> {
|
|||||||
let energy_factor = energy.current() as f64 / energy.maximum() as f64;
|
let energy_factor = energy.current() as f64 / energy.maximum() as f64;
|
||||||
|
|
||||||
Rectangle::fill_with(
|
Rectangle::fill_with(
|
||||||
[
|
[72.0 * energy_factor * BARSIZE, MANA_BAR_HEIGHT],
|
||||||
72.0 * energy_factor * BARSIZE,
|
|
||||||
MANA_BAR_HEIGHT,
|
|
||||||
],
|
|
||||||
MANA_COLOR,
|
MANA_COLOR,
|
||||||
)
|
)
|
||||||
.x_y(
|
.x_y(
|
||||||
|
@ -10,7 +10,7 @@ use crate::{
|
|||||||
use common::{
|
use common::{
|
||||||
assets,
|
assets,
|
||||||
astar::Astar,
|
astar::Astar,
|
||||||
comp::{self, bird_medium, humanoid, quadruped_small, object},
|
comp::{self, bird_medium, humanoid, object, quadruped_small},
|
||||||
generation::{ChunkSupplement, EntityInfo},
|
generation::{ChunkSupplement, EntityInfo},
|
||||||
path::Path,
|
path::Path,
|
||||||
spiral::Spiral2d,
|
spiral::Spiral2d,
|
||||||
@ -789,7 +789,8 @@ impl Settlement {
|
|||||||
&& RandomField::new(self.seed).chance(Vec3::from(wpos2d), 1.0 / (50.0 * 50.0))
|
&& RandomField::new(self.seed).chance(Vec3::from(wpos2d), 1.0 / (50.0 * 50.0))
|
||||||
{
|
{
|
||||||
let is_human: bool;
|
let is_human: bool;
|
||||||
let is_dummy = RandomField::new(self.seed + 1).chance(Vec3::from(wpos2d), 1.0 / 15.0);
|
let is_dummy =
|
||||||
|
RandomField::new(self.seed + 1).chance(Vec3::from(wpos2d), 1.0 / 15.0);
|
||||||
let entity = EntityInfo::at(entity_wpos)
|
let entity = EntityInfo::at(entity_wpos)
|
||||||
.with_body(match rng.gen_range(0, 4) {
|
.with_body(match rng.gen_range(0, 4) {
|
||||||
_ if is_dummy => {
|
_ if is_dummy => {
|
||||||
|
Loading…
Reference in New Issue
Block a user