Skip to content

Commit

Permalink
Add weapon & legend swap
Browse files Browse the repository at this point in the history
  • Loading branch information
Zerthox committed Dec 14, 2024
1 parent c2d6c29 commit b08758f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
18 changes: 18 additions & 0 deletions reffect/src/addon/ui/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ impl Addon {
debug_result(ui, own_skillbar.as_ref(), |skillbar| {
let passed = skillbar.passed(ctx.now);

if let Some(weapon) = &skillbar.weapon_swap {
ui.text(format!(
"{:<14} = {:.1}/{:.1}s",
"Weapon Swap",
to_secs(weapon.recharge_remaining(ctx.now)),
to_secs(weapon.recharge),
));
}

if let Some(legend) = &skillbar.legend_swap {
ui.text(format!(
"{:<14} = {:.1}/{:.1}s",
"Legend Swap",
to_secs(legend.recharge_remaining(ctx.now)),
to_secs(legend.recharge),
));
}

for slot in Slot::iter() {
if let Some(ability) = skillbar.slot(slot) {
ui.text(format!("{slot:<14} = {}x {:>5}", ability.ammo, ability.id));
Expand Down
7 changes: 5 additions & 2 deletions reffect_api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ pub enum Error {
#[error("Character endurance not found")]
EnduranceNotFound,

#[error("Character gear not found")]
GearNotFound,
#[error("Character inventory not found")]
InventoryNotFound,

#[error("Character profession not found")]
ProfNotFound,

#[error("Character specialization not found")]
SpecNotFound,
Expand Down
4 changes: 2 additions & 2 deletions reffect_api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
mod ability;
mod buff;
mod error;
mod player;
mod resource;
mod skillbar;
mod state;

pub use self::{ability::*, buff::*, error::*, player::*, resource::*, state::*};
pub use self::{buff::*, error::*, player::*, resource::*, skillbar::*, state::*};

/// Interface for API.
pub trait Interface {
Expand Down
24 changes: 24 additions & 0 deletions reffect_api/src/ability.rs → reffect_api/src/skillbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ pub struct Skillbar {

/// Skill entries.
pub skills: SkillSlots,

/// Weapon swap.
pub weapon_swap: Option<Recharge>,

/// Revenant legend swap.
pub legend_swap: Option<Recharge>,
}

impl Skillbar {
Expand Down Expand Up @@ -154,3 +160,21 @@ pub enum Slot {

Mount,
}

/// Recharge and timestmap.
#[derive(Debug, Default, Clone)]
pub struct Recharge {
/// Last update timestamp.
pub last_update: u32,

/// Recharge in milliseconds.
pub recharge: u32,
}

impl Recharge {
/// Returns the remaining recharge.
#[inline]
pub fn recharge_remaining(&self, now: u32) -> u32 {
(self.last_update + self.recharge).saturating_sub(now)
}
}

0 comments on commit b08758f

Please sign in to comment.