Struct veloren_common_net::synced_components::inner::SkillSet
pub struct SkillSet {
skill_groups: HashMap<SkillGroupKind, SkillGroup>,
skills: HashMap<Skill, u16>,
}
Expand description
Contains all of a player’s skill groups and skills. Provides methods for manipulating assigned skills and skill groups including unlocking skills, refunding skills etc.
Fields§
§skill_groups: HashMap<SkillGroupKind, SkillGroup>
§skills: HashMap<Skill, u16>
Implementations§
§impl SkillSet
impl SkillSet
pub fn initial_skills() -> HashMap<Skill, u16>
pub fn load_from_database(
skill_groups: HashMap<SkillGroupKind, SkillGroup>,
all_skills: HashMap<SkillGroupKind, Result<Vec<Skill>, SkillsPersistenceError>>,
) -> (SkillSet, Option<SkillsPersistenceError>)
pub fn load_from_database( skill_groups: HashMap<SkillGroupKind, SkillGroup>, all_skills: HashMap<SkillGroupKind, Result<Vec<Skill>, SkillsPersistenceError>>, ) -> (SkillSet, Option<SkillsPersistenceError>)
NOTE: This does not return an error on failure, since we can partially recover from some failures. Instead, it returns the error in the second return value; make sure to handle it if present!
pub fn skill_group_accessible(&self, skill_group_kind: SkillGroupKind) -> bool
pub fn skill_group_accessible(&self, skill_group_kind: SkillGroupKind) -> bool
Checks if a particular skill group is accessible for an entity
pub fn skill_groups(&self) -> impl Iterator<Item = &SkillGroup>
pub fn skill_groups(&self) -> impl Iterator<Item = &SkillGroup>
Returns an iterator over skill groups
pub fn add_experience(
&mut self,
skill_group_kind: SkillGroupKind,
amount: u32,
) -> Option<u16>
pub fn add_experience( &mut self, skill_group_kind: SkillGroupKind, amount: u32, ) -> Option<u16>
Adds experience to the skill group within an entity’s skill set, will attempt to earn a skill point while doing so. If a skill point was earned, returns the number of earned skill points in the skill group.
pub fn available_experience(&self, skill_group: SkillGroupKind) -> u32
pub fn available_experience(&self, skill_group: SkillGroupKind) -> u32
Gets the available experience for a particular skill group
pub fn skill_point_cost(&self, skill_group: SkillGroupKind) -> u32
pub fn skill_point_cost(&self, skill_group: SkillGroupKind) -> u32
Checks how much experience is needed for the next skill point in a tree
pub fn add_skill_points(
&mut self,
skill_group_kind: SkillGroupKind,
number_of_skill_points: u16,
)
pub fn add_skill_points( &mut self, skill_group_kind: SkillGroupKind, number_of_skill_points: u16, )
Adds skill points to a skill group as long as the player has that skill group type.
pub fn available_sp(&self, skill_group: SkillGroupKind) -> u16
pub fn available_sp(&self, skill_group: SkillGroupKind) -> u16
Gets the available points for a particular skill group
pub fn earned_sp(&self, skill_group: SkillGroupKind) -> u16
pub fn earned_sp(&self, skill_group: SkillGroupKind) -> u16
Gets the total earned points for a particular skill group
pub fn prerequisites_met(&self, skill: Skill) -> bool
pub fn prerequisites_met(&self, skill: Skill) -> bool
Checks that the skill set contains all prerequisite skills of the required level for a particular skill
pub fn skill_cost(&self, skill: Skill) -> u16
pub fn skill_cost(&self, skill: Skill) -> u16
Gets skill point cost to purchase skill of next level
pub fn sufficient_skill_points(&self, skill: Skill) -> bool
pub fn sufficient_skill_points(&self, skill: Skill) -> bool
Checks if player has sufficient skill points to purchase a skill
pub fn unlock_skill_cow<'a, B, C>(
this_: &'a mut B,
skill: Skill,
to_mut: impl FnOnce(&'a mut B) -> &'a mut C,
) -> Result<(), SkillUnlockError>
pub fn unlock_skill_cow<'a, B, C>( this_: &'a mut B, skill: Skill, to_mut: impl FnOnce(&'a mut B) -> &'a mut C, ) -> Result<(), SkillUnlockError>
Unlocks a skill for a player, assuming they have the relevant skill group unlocked and available SP in that skill group.
NOTE: Please don’t use pathological or clever implementations of to_mut here.
pub fn unlock_skill(&mut self, skill: Skill) -> Result<(), SkillUnlockError>
pub fn unlock_skill(&mut self, skill: Skill) -> Result<(), SkillUnlockError>
Convenience function for the case where you have mutable access to the skill.
pub fn has_available_sp(&self) -> bool
pub fn has_available_sp(&self) -> bool
Checks if the player has available SP to spend
pub fn is_at_max_level(&self, skill: Skill) -> bool
pub fn is_at_max_level(&self, skill: Skill) -> bool
Checks if the skill is at max level in a skill set
pub fn skill_level(&self, skill: Skill) -> Result<u16, SkillError>
pub fn skill_level(&self, skill: Skill) -> Result<u16, SkillError>
Returns the level of the skill
Trait Implementations§
§impl<'de> Deserialize<'de> for SkillSet
impl<'de> Deserialize<'de> for SkillSet
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SkillSet, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SkillSet, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl From<SkillSet> for EcsCompPacket
impl From<SkillSet> for EcsCompPacket
source§fn from(other: SkillSet) -> EcsCompPacket
fn from(other: SkillSet) -> EcsCompPacket
source§impl NetSync for SkillSet
impl NetSync for SkillSet
source§const SYNC_FROM: SyncFrom = SyncFrom::AnyEntity
const SYNC_FROM: SyncFrom = SyncFrom::AnyEntity
source§fn pre_insert(&mut self, world: &World)
fn pre_insert(&mut self, world: &World)
source§fn pre_modify(&mut self, world: &World)
fn pre_modify(&mut self, world: &World)
§impl Serialize for SkillSet
impl Serialize for SkillSet
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
source§impl TryFrom<EcsCompPacket> for SkillSet
impl TryFrom<EcsCompPacket> for SkillSet
impl Eq for SkillSet
impl StructuralPartialEq for SkillSet
Auto Trait Implementations§
impl Freeze for SkillSet
impl RefUnwindSafe for SkillSet
impl Send for SkillSet
impl Sync for SkillSet
impl Unpin for SkillSet
impl UnwindSafe for SkillSet
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<C, M> ConvertSaveload<M> for C
impl<C, M> ConvertSaveload<M> for C
§type Error = Infallible
type Error = Infallible
§fn convert_into<F>(
&self,
_: F,
) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
fn convert_into<F>( &self, _: F, ) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
Data
) using
entity to marker mapping function§fn convert_from<F>(
data: <C as ConvertSaveload<M>>::Data,
_: F,
) -> Result<C, <C as ConvertSaveload<M>>::Error>
fn convert_from<F>( data: <C as ConvertSaveload<M>>::Data, _: F, ) -> Result<C, <C as ConvertSaveload<M>>::Error>
Data
) using
entity to marker mapping function§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<Context> SubContext<Context> for Context
impl<Context> SubContext<Context> for Context
fn sub_context(self) -> Context
§impl<T> TryDefault for Twhere
T: Default,
impl<T> TryDefault for Twhere
T: Default,
§fn try_default() -> Result<T, String>
fn try_default() -> Result<T, String>
§fn unwrap_default() -> Self
fn unwrap_default() -> Self
try_default
and panics on an error case.