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