pub struct EntityActionsQueue { /* private fields */ }Implementations§
Source§impl EntityActionsQueue
impl EntityActionsQueue
pub fn new(entity_id: EntityId) -> Self
pub fn push(&mut self, action_with_deadline: &ActionWithDeadline)
pub fn append_start_cast_ability_result_actions( &mut self, actions_with_deadlines: &Vec<ActionWithDeadline>, current_tick: u64, ability_id: AbilityId, ability_cooldown: u64, )
Sourcepub fn pop(&mut self, current_tick: u64) -> Option<ActionWithDeadline>
pub fn pop(&mut self, current_tick: u64) -> Option<ActionWithDeadline>
Drains the next due action, provenance included — the rebuilt event
inherits ActionWithDeadline::origin instead of resetting to Core.
pub fn remove_start_cast_ability_action( &mut self, ability_id_to_remove: AbilityId, )
pub fn remove_cast_effect_action(&mut self, effect_id_to_remove: EffectId)
pub fn get_closest_start_cast_action_deadline(&self) -> Option<u64>
Sourcepub fn rescale_cooldowns(
&mut self,
old_speed: i64,
new_speed: i64,
current_tick: u64,
baseline_speed: u64,
)
pub fn rescale_cooldowns( &mut self, old_speed: i64, new_speed: i64, current_tick: u64, baseline_speed: u64, )
Rescales every StartCastAbility (cooldown) entry in the queue to reflect a change in
the entity’s speed attribute.
At speed S, a cooldown that was originally C ticks long elapses in C * baseline / S
game-ticks. So when speed changes from S_old to S_new, the still-remaining game-ticks
for each in-flight cooldown become (deadline - current_tick) * S_old / S_new.
baseline_speed falls in for non-positive speed values.
In-flight casts (CastAbility / CastBasicAbility cast animations) are intentionally not
touched here — speed scales cooldowns, not cast time.
Sourcepub fn push_start_cast_replacing(
&mut self,
ability_id: AbilityId,
deadline_tick: u64,
)
pub fn push_start_cast_replacing( &mut self, ability_id: AbilityId, deadline_tick: u64, )
Applies stun semantics to a single ability:
- If the ability is currently mid-cast (
CastAbility/CastBasicAbilityqueued), cancels the cast and sets the cooldown deadline tocurrent_tick + full_cooldown_ticks + duration_ticks— full cooldown plus the stun freeze on top. - Otherwise, if the ability already has a cooldown entry, extends its deadline by
duration_ticks(the cooldown effectively pauses for the stun duration). - Otherwise (off cooldown), pushes a fresh cooldown entry of
duration_ticksso the ability stays unusable while stunned.
full_cooldown_ticks is the ability’s full cooldown (already scaled for entity speed if
the caller wants speed to apply).
Push the cooldown entry (StartCastAbility) for ability_id, replacing any entry
already queued for it and keeping the LATER deadline. One ability must never hold two
self-rescheduling cooldown entries: a stun landing on the exact tick the previous entry
was popped (event in flight) used to add a second one, permanently doubling the
ability’s attack loop.
Sourcepub fn start_cast_entries(&self) -> Vec<(AbilityId, u64)>
pub fn start_cast_entries(&self) -> Vec<(AbilityId, u64)>
Every queued cooldown entry as (ability_id, deadline_tick).
The read counterpart of Self::adjust_ability_cooldown: a consumer
that wants “the longest remaining cooldown” (laws RL-03, RL-11,
FL-04, FL-11) needs the whole set, not one ability’s deadlines.
Sourcepub fn ability_cooldowns(&self, current_tick: u64) -> Vec<(AbilityId, u64)>
pub fn ability_cooldowns(&self, current_tick: u64) -> Vec<(AbilityId, u64)>
Remaining cooldown of every ability that is not ready yet, longest
first. Ties break on ability_id so the order is deterministic.
A StartCastAbility entry IS the ability’s cooldown: it is the
self-rescheduling metronome that lets the ability swing again at
deadline_tick. That is why the three helpers below are enough to
express every “shorten / reset a Skill cooldown” Effect Stone without
any new state.
Sourcepub fn shorten_cooldowns_of(
&mut self,
current_tick: u64,
ability_ids: &[AbilityId],
by_ticks: u64,
) -> usize
pub fn shorten_cooldowns_of( &mut self, current_tick: u64, ability_ids: &[AbilityId], by_ticks: u64, ) -> usize
Brings EVERY remaining cooldown of the named abilities forward by
by_ticks and returns how many entries actually moved.
The named-set sibling of Self::shorten_longest_cooldowns, which takes
the count longest ones instead. PET-01 Head Start needs this shape:
its wording is “ALL remaining Skill cooldowns”, and the caller — not this
queue, which cannot tell a Skill from a class Basic Attack — decides
which abilities are Skills.
Sourcepub fn shorten_longest_cooldowns(
&mut self,
current_tick: u64,
count: usize,
by_ticks: u64,
) -> usize
pub fn shorten_longest_cooldowns( &mut self, current_tick: u64, count: usize, by_ticks: u64, ) -> usize
Brings the count longest remaining cooldowns forward by by_ticks and
returns how many entries actually moved.
A cooldown is never pushed before current_tick: the ability becomes
ready, it does not become ready in the past.
Sourcepub fn clear_ability_cooldowns(&mut self, current_tick: u64) -> usize
pub fn clear_ability_cooldowns(&mut self, current_tick: u64) -> usize
Makes every ability ready at current_tick and returns how many
cooldowns were cleared.
Sourcepub fn start_cast_deadlines(&self, ability_id: AbilityId) -> Vec<u64>
pub fn start_cast_deadlines(&self, ability_id: AbilityId) -> Vec<u64>
Deadlines of every StartCastAbility entry queued for ability_id.
Load-bearing: push_start_cast_replacing uses the max to never shorten
an existing (e.g. stun-extended) cooldown entry.
pub fn stun_ability( &mut self, ability_id: AbilityId, duration_ticks: u64, full_cooldown_ticks: u64, current_tick: u64, )
Sourcepub fn cancel_cast_and_set_cooldown(
&mut self,
ability_id_to_cancel: AbilityId,
new_deadline_tick: u64,
) -> bool
pub fn cancel_cast_and_set_cooldown( &mut self, ability_id_to_cancel: AbilityId, new_deadline_tick: u64, ) -> bool
Cancels any in-flight cast (CastAbility / CastBasicAbility) for ability_id_to_cancel
and replaces the cooldown entry (StartCastAbility) with a new one at new_deadline_tick.
Returns true when an in-flight cast was found and removed.
Sourcepub fn adjust_ability_cooldown(
&mut self,
ability_id_to_adjust: AbilityId,
delta_ticks: i64,
current_tick: u64,
) -> bool
pub fn adjust_ability_cooldown( &mut self, ability_id_to_adjust: AbilityId, delta_ticks: i64, current_tick: u64, ) -> bool
Adjusts the cooldown for a specific ability by delta_ticks.
Positive delta extends the cooldown, negative shortens it (saturating at current_tick,
i.e. no remaining cooldown). Returns true when an entry was found and adjusted.
pub fn view(&self) -> HashMap<ActionPriority, Vec<ActionWithDeadline>>
Trait Implementations§
Source§impl Clone for EntityActionsQueue
impl Clone for EntityActionsQueue
Source§fn clone(&self) -> EntityActionsQueue
fn clone(&self) -> EntityActionsQueue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more