From ffe456c70366da2d5282f3ced62419132b37e573 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 22 Sep 2020 18:37:17 -0500 Subject: [PATCH] Fixed what broke after rebasing. --- common/src/comp/inventory/item/mod.rs | 18 +- common/src/states/combo_melee.rs | 13 +- common/src/states/dash_melee.rs | 3 +- common/src/states/spin_melee.rs | 3 +- common/src/states/triple_strike.rs | 221 ----------------------- server/src/events/entity_creation.rs | 4 +- server/src/events/entity_manipulation.rs | 20 +- voxygen/src/hud/skillbar.rs | 4 +- 8 files changed, 37 insertions(+), 249 deletions(-) delete mode 100644 common/src/states/triple_strike.rs diff --git a/common/src/comp/inventory/item/mod.rs b/common/src/comp/inventory/item/mod.rs index 05ffbb5f92..ccb22bb5d0 100644 --- a/common/src/comp/inventory/item/mod.rs +++ b/common/src/comp/inventory/item/mod.rs @@ -147,27 +147,21 @@ impl PartialEq for Item { } impl Asset for ItemDef { - -} - -impl Asset for ItemSet { const ENDINGS: &'static [&'static str] = &["ron"]; fn parse(buf_reader: BufReader, specifier: &str) -> Result { let item: Result = ron::de::from_reader(buf_reader).map_err(Error::parse_error); - - let asset_specifier = specifier.replace('\\', "."); - let db_specifier = + + // Some commands like /give_item provide the asset specifier separated with \ + // instead of . + let specifier = specifier.replace('\\', "."); item.map(|item| ItemDef { - asset_path_to_db: specifier, - db_to_asset_path: + item_definition_id: specifier, + ..item }) } - /*fn reverse_path() -> Self { - self.asset_path_to_db = self.db_to_asset_path.iter().map(|(key, value)| (value, key)).collect(); - }*/ } impl Item { diff --git a/common/src/states/combo_melee.rs b/common/src/states/combo_melee.rs index 7de105803f..cc671158f4 100644 --- a/common/src/states/combo_melee.rs +++ b/common/src/states/combo_melee.rs @@ -126,13 +126,12 @@ impl CharacterBehavior for Data { // Hit attempt data.updater.insert(data.entity, Attacking { - base_healthchange: -((self.static_data.stage_data[stage_index] - .max_damage - .min( - self.static_data.stage_data[stage_index].base_damage - + self.combo / self.static_data.num_stages - * self.static_data.stage_data[stage_index].damage_increase, - )) as i32), + base_damage: self.static_data.stage_data[stage_index].max_damage.min( + self.static_data.stage_data[stage_index].base_damage + + self.combo / self.static_data.num_stages + * self.static_data.stage_data[stage_index].damage_increase, + ), + base_heal: 0, range: self.static_data.stage_data[stage_index].range, max_angle: self.static_data.stage_data[stage_index].angle.to_radians(), applied: false, diff --git a/common/src/states/dash_melee.rs b/common/src/states/dash_melee.rs index ce120d68e2..556a4a40ea 100644 --- a/common/src/states/dash_melee.rs +++ b/common/src/states/dash_melee.rs @@ -121,7 +121,8 @@ impl CharacterBehavior for Data { * charge_frac + self.static_data.base_knockback; data.updater.insert(data.entity, Attacking { - base_healthchange: -damage as i32, + base_damage: damage as u32, + base_heal: 0, range: self.static_data.range, max_angle: self.static_data.angle.to_radians(), applied: false, diff --git a/common/src/states/spin_melee.rs b/common/src/states/spin_melee.rs index dd1064cb44..111930c26a 100644 --- a/common/src/states/spin_melee.rs +++ b/common/src/states/spin_melee.rs @@ -106,7 +106,8 @@ impl CharacterBehavior for Data { }); // Hit attempt data.updater.insert(data.entity, Attacking { - base_healthchange: -(self.static_data.base_damage as i32), + base_damage: self.static_data.base_damage, + base_heal: 0, range: self.static_data.range, max_angle: 180_f32.to_radians(), applied: false, diff --git a/common/src/states/triple_strike.rs b/common/src/states/triple_strike.rs deleted file mode 100644 index 57f1dcbcd7..0000000000 --- a/common/src/states/triple_strike.rs +++ /dev/null @@ -1,221 +0,0 @@ -use crate::{ - comp::{Attacking, CharacterState, EnergySource, StateUpdate}, - states::utils::*, - sys::character_behavior::{CharacterBehavior, JoinData}, -}; -use serde::{Deserialize, Serialize}; -use std::time::Duration; -use vek::vec::Vec3; -use HoldingState::*; -use TimingState::*; -use TransitionStyle::*; - -// In millis -const STAGE_DURATION: u64 = 700; -const TIMING_DELAY: u64 = 350; -const INITIAL_ACCEL: f32 = 90.0; -const BASE_SPEED: f32 = 25.0; - -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub enum Stage { - First, - Second, - Third, -} - -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub enum TimingState { - NotPressed, - PressedEarly, - Success, -} - -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub enum HoldingState { - Holding, - Released, -} - -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub enum TransitionStyle { - /// Player must time a button press properly to transition - Timed(TimingState), - /// Player must hold button for whole move - Hold(HoldingState), -} - -/// ### A sequence of 3 incrementally increasing attacks. -/// -/// While holding down the `primary` button, perform a series of 3 attacks, -/// each one pushes the player forward as the character steps into the swings. -/// The player can let go of the left mouse button at any time -/// and stop their attacks by interrupting the attack animation. -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] -pub struct Data { - /// The tool this state will read to handle damage, etc. - pub base_damage: u32, - /// What stage (of 3) the attack is in - pub stage: Stage, - /// How long current stage has been active - pub stage_time_active: Duration, - /// Whether current stage has exhausted its attack - pub stage_exhausted: bool, - /// Whether state has performed initialization logic - pub initialized: bool, - /// What this instance's current transition stat is - pub transition_style: TransitionStyle, -} - -impl CharacterBehavior for Data { - fn behavior(&self, data: &JoinData) -> StateUpdate { - let mut update = StateUpdate::from(data); - - handle_move(data, &mut update, 0.3); - - #[allow(clippy::or_fun_call)] // TODO: Pending review in #587 - let stage_time_active = self - .stage_time_active - .checked_add(Duration::from_secs_f32(data.dt.0)) - .unwrap_or(Duration::default()); - - if !self.initialized { - update.vel.0 = Vec3::zero(); - if let Some(dir) = data.inputs.look_dir.try_normalized() { - update.ori.0 = dir.into(); - } - } - let initialized = true; - - // Update transition - let transition_style = match self.transition_style { - Timed(state) => match state { - NotPressed => { - if data.inputs.primary.is_just_pressed() { - if stage_time_active > Duration::from_millis(TIMING_DELAY) { - Timed(Success) - } else { - Timed(PressedEarly) - } - } else { - self.transition_style - } - }, - _ => self.transition_style, - }, - Hold(_) => { - if !data.inputs.primary.is_pressed() { - Hold(Released) - } else { - self.transition_style - } - }, - }; - - // Handling movement - if stage_time_active < Duration::from_millis(STAGE_DURATION / 3) { - let adjusted_accel = match (self.stage, data.physics.touch_entities.is_empty()) { - (Stage::First, true) => INITIAL_ACCEL, - (Stage::Second, true) => INITIAL_ACCEL * 0.75, - (Stage::Third, true) => INITIAL_ACCEL * 0.75, - (_, _) => 0.0, - }; - - // Move player forward while in first third of each stage - if update.vel.0.magnitude_squared() < BASE_SPEED.powf(2.0) { - update.vel.0 += data.dt.0 * (adjusted_accel * Vec3::from(data.ori.0.xy())); - let mag2 = update.vel.0.magnitude_squared(); - if mag2 > BASE_SPEED.powf(2.0) { - update.vel.0 = update.vel.0.normalized() * BASE_SPEED; - } - }; - } else { - handle_orientation(data, &mut update, 50.0); - } - - // Handling attacking - update.character = if stage_time_active > Duration::from_millis(STAGE_DURATION / 2) - && !self.stage_exhausted - { - let dmg = match self.stage { - Stage::First => self.base_damage / 2, - Stage::Second => self.base_damage, - Stage::Third => (self.base_damage as f32 * 1.5) as u32, - }; - - update.vel.0 = Vec3::new(data.inputs.move_dir.x, data.inputs.move_dir.y, 0.0) * 5.0; - - // Try to deal damage in second half of stage - data.updater.insert(data.entity, Attacking { - base_damage: dmg, - base_heal: 0, - range: 3.5, - max_angle: 45_f32.to_radians(), - applied: false, - hit_count: 0, - knockback: 10.0, - }); - - CharacterState::TripleStrike(Data { - base_damage: self.base_damage, - stage: self.stage, - stage_time_active, - stage_exhausted: true, - initialized, - transition_style, - }) - } else if stage_time_active > Duration::from_millis(STAGE_DURATION) { - let next_stage = - // Determine whether stage can transition based on TransitionStyle - if let Hold(Holding) | Timed(Success) = transition_style { - // Determine what stage to transition to - match self.stage { - Stage::First => Some(Stage::Second), - Stage::Second => Some(Stage::Third), - Stage::Third => None, - } - } - // Player messed up inputs, don't transition - else { None }; - - update.vel.0 = Vec3::new(data.inputs.move_dir.x, data.inputs.move_dir.y, 0.0) * 5.0; - - if let Some(stage) = next_stage { - CharacterState::TripleStrike(Data { - base_damage: self.base_damage, - stage, - stage_time_active: Duration::default(), - stage_exhausted: false, - initialized, - transition_style: match transition_style { - Hold(_) => Hold(Holding), - Timed(_) => Timed(NotPressed), - }, - }) - } else { - // Make sure attack component is removed - data.updater.remove::(data.entity); - // Done - CharacterState::Wielding - } - } else { - CharacterState::TripleStrike(Data { - base_damage: self.base_damage, - stage: self.stage, - stage_time_active, - stage_exhausted: self.stage_exhausted, - initialized, - transition_style, - }) - }; - - // Grant energy on successful hit - if let Some(attack) = data.attacking { - if attack.applied && attack.hit_count > 0 { - data.updater.remove::(data.entity); - update.energy.change_by(50, EnergySource::HitEnemy); - } - } - - update - } -} diff --git a/server/src/events/entity_creation.rs b/server/src/events/entity_creation.rs index 3cc271f19d..9f52028e5c 100644 --- a/server/src/events/entity_creation.rs +++ b/server/src/events/entity_creation.rs @@ -2,8 +2,8 @@ use crate::{sys, Server, StateExt}; use common::{ character::CharacterId, comp::{ - self, beam, humanoid::DEFAULT_HUMANOID_EYE_HEIGHT, shockwave, Agent, Alignment, Body, Gravity, - Item, ItemDrop, LightEmitter, Loadout, Ori, Pos, Projectile, Scale, Stats, Vel, + self, beam, humanoid::DEFAULT_HUMANOID_EYE_HEIGHT, shockwave, Agent, Alignment, Body, + Gravity, Item, ItemDrop, LightEmitter, Loadout, Ori, Pos, Projectile, Scale, Stats, Vel, WaypointArea, }, outcome::Outcome, diff --git a/server/src/events/entity_manipulation.rs b/server/src/events/entity_manipulation.rs index d41dab793c..d9272540e6 100644 --- a/server/src/events/entity_manipulation.rs +++ b/server/src/events/entity_manipulation.rs @@ -614,6 +614,7 @@ pub fn handle_explosion( } let terrain = ecs.read_resource::(); +<<<<<<< HEAD let _ = terrain .ray(pos, pos + dir * power) // TODO: Faster RNG @@ -621,6 +622,21 @@ pub fn handle_explosion( .for_each(|block: &Block, pos| { if block.is_explodable() { block_change.set(pos, block.into_vacant()); +======= + let mut block_change = ecs.write_resource::(); + for block_pos in touched_blocks { + if let Ok(block) = terrain.get(block_pos) { + let diff2 = block_pos.map(|b| b as f32).distance_squared(pos); + let fade = (1.0 - diff2 / color_range.powi(2)).max(0.0); + if let Some(mut color) = block.get_color() { + let r = color[0] as f32 + (fade * (color[0] as f32 * 0.5 - color[0] as f32)); + let g = color[1] as f32 + (fade * (color[1] as f32 * 0.3 - color[1] as f32)); + let b = color[2] as f32 + (fade * (color[2] as f32 * 0.3 - color[2] as f32)); + color[0] = r as u8; + color[1] = g as u8; + color[2] = b as u8; + block_change.set(block_pos, Block::new(block.kind(), color)); +>>>>>>> 2487c8ac5... Fixed what broke after rebasing. } } } @@ -637,10 +653,10 @@ pub fn handle_explosion( let terrain = ecs.read_resource::(); let _ = terrain .ray(pos, pos + dir * power) - .until(|block| block.is_fluid() || rand::random::() < 0.05) + .until(|block| block.is_liquid() || rand::random::() < 0.05) .for_each(|block: &Block, pos| { if block.is_explodable() { - block_change.set(pos, Block::empty()); + block_change.set(pos, block.into_vacant()); } }) .cast(); diff --git a/voxygen/src/hud/skillbar.rs b/voxygen/src/hud/skillbar.rs index 8d8499bbf8..7c6957aefe 100644 --- a/voxygen/src/hud/skillbar.rs +++ b/voxygen/src/hud/skillbar.rs @@ -724,9 +724,7 @@ impl<'a> Widget for Skillbar<'a> { Color::Rgba(0.3, 0.3, 0.3, 0.8) } }, - _ => { - Color::Rgba(1.0, 1.0, 1.0, 1.0) - }, + _ => Color::Rgba(1.0, 1.0, 1.0, 1.0), }) .set(state.ids.m2_content, ui); // Slots