Botcraft 1.21.4
Loading...
Searching...
No Matches
Botcraft::EntityAttribute Class Reference

#include <EntityAttribute.hpp>

Classes

struct  Modifier
 

Public Types

enum class  Type : char {
  Unknown = -1 , Armor , ArmorToughness , AttackDamage ,
  AttackKnockback , AttackSpeed , PlayerBlockBreakSpeed , PlayerBlockInteractionRange ,
  BurningTime , ExplosionKnockbackResistance , PlayerEntityInteractionRange , FallDamageMultiplier ,
  FlyingSpeed , FollowRange , Gravity , JumpStrength ,
  KnockbackResistance , Luck , MaxAbsorption , MaxHealth ,
  PlayerMiningEfficiency , MovementEfficiency , MovementSpeed , OxygenBonus ,
  SafeFallDistance , Scale , PlayerSneakingSpeed , ZombieSpawnReinforcementsChance ,
  StepHeight , PlayerSubmergedMiningSpeed , PlayerSweepingDamageRatio , TemptRange ,
  WaterMovementEfficiency , NUM_ENTITY_ATTRIBUTES
}
 
using ModifierKey = std::string
 

Public Member Functions

 EntityAttribute (const Type type_, const double base_value_)
 
 EntityAttribute ()=delete
 
void SetBaseValue (const double new_value)
 
void ClearModifiers ()
 
void RemoveModifier (const ModifierKey &key)
 
void SetModifier (const ModifierKey &key, const Modifier &modifier)
 
Type GetType () const
 
double GetBaseValue () const
 
const std::map< ModifierKey, Modifier > & GetModifiers () const
 
double GetValue () const
 
std::optional< ModifierGetModifier (const ModifierKey &key)
 

Private Member Functions

void UpdateValue () const
 

Private Attributes

Type type
 
double base_value
 
double current_value
 
bool up_to_date
 
std::map< ModifierKey, Modifiermodifiers
 

Detailed Description

Definition at line 12 of file EntityAttribute.hpp.

Member Typedef Documentation

◆ ModifierKey

Definition at line 18 of file EntityAttribute.hpp.

Member Enumeration Documentation

◆ Type

enum class Botcraft::EntityAttribute::Type : char
strong
Enumerator
Unknown 
Armor 
ArmorToughness 
AttackDamage 
AttackKnockback 
AttackSpeed 
PlayerBlockBreakSpeed 
PlayerBlockInteractionRange 
BurningTime 
ExplosionKnockbackResistance 
PlayerEntityInteractionRange 
FallDamageMultiplier 
FlyingSpeed 
FollowRange 
Gravity 
JumpStrength 
KnockbackResistance 
Luck 
MaxAbsorption 
MaxHealth 
PlayerMiningEfficiency 
MovementEfficiency 
MovementSpeed 
OxygenBonus 
SafeFallDistance 
Scale 
PlayerSneakingSpeed 
ZombieSpawnReinforcementsChance 
StepHeight 
PlayerSubmergedMiningSpeed 
PlayerSweepingDamageRatio 
TemptRange 
WaterMovementEfficiency 
NUM_ENTITY_ATTRIBUTES 

Definition at line 21 of file EntityAttribute.hpp.

Constructor & Destructor Documentation

◆ EntityAttribute() [1/2]

Botcraft::EntityAttribute::EntityAttribute ( const Type  type_,
const double  base_value_ 
)

Definition at line 6 of file EntityAttribute.cpp.

References base_value, current_value, type, and up_to_date.

◆ EntityAttribute() [2/2]

Botcraft::EntityAttribute::EntityAttribute ( )
delete

Member Function Documentation

◆ ClearModifiers()

void Botcraft::EntityAttribute::ClearModifiers ( )

Definition at line 24 of file EntityAttribute.cpp.

References modifiers, and up_to_date.

◆ GetBaseValue()

double Botcraft::EntityAttribute::GetBaseValue ( ) const

Definition at line 47 of file EntityAttribute.cpp.

References base_value.

◆ GetModifier()

std::optional< EntityAttribute::Modifier > Botcraft::EntityAttribute::GetModifier ( const ModifierKey key)

Definition at line 66 of file EntityAttribute.cpp.

References modifiers.

◆ GetModifiers()

const std::map< EntityAttribute::ModifierKey, EntityAttribute::Modifier > & Botcraft::EntityAttribute::GetModifiers ( ) const

Definition at line 52 of file EntityAttribute.cpp.

References modifiers.

◆ GetType()

EntityAttribute::Type Botcraft::EntityAttribute::GetType ( ) const

Definition at line 42 of file EntityAttribute.cpp.

References type.

Referenced by Botcraft::LivingEntity::AddAttribute().

◆ GetValue()

double Botcraft::EntityAttribute::GetValue ( ) const

Definition at line 57 of file EntityAttribute.cpp.

References current_value, up_to_date, and UpdateValue().

◆ RemoveModifier()

void Botcraft::EntityAttribute::RemoveModifier ( const ModifierKey key)

Definition at line 30 of file EntityAttribute.cpp.

References modifiers, and up_to_date.

◆ SetBaseValue()

void Botcraft::EntityAttribute::SetBaseValue ( const double  new_value)

Definition at line 14 of file EntityAttribute.cpp.

References base_value, and up_to_date.

◆ SetModifier()

void Botcraft::EntityAttribute::SetModifier ( const ModifierKey key,
const Modifier modifier 
)

Definition at line 36 of file EntityAttribute.cpp.

References modifiers, and up_to_date.

Referenced by Botcraft::EntityManager::Handle().

◆ UpdateValue()

Member Data Documentation

◆ base_value

double Botcraft::EntityAttribute::base_value
private

Definition at line 124 of file EntityAttribute.hpp.

Referenced by EntityAttribute(), GetBaseValue(), SetBaseValue(), and UpdateValue().

◆ current_value

double Botcraft::EntityAttribute::current_value
mutableprivate

Definition at line 125 of file EntityAttribute.hpp.

Referenced by EntityAttribute(), GetValue(), and UpdateValue().

◆ modifiers

std::map<ModifierKey, Modifier> Botcraft::EntityAttribute::modifiers
private

◆ type

Type Botcraft::EntityAttribute::type
private

Definition at line 123 of file EntityAttribute.hpp.

Referenced by EntityAttribute(), GetType(), and UpdateValue().

◆ up_to_date

bool Botcraft::EntityAttribute::up_to_date
mutableprivate

The documentation for this class was generated from the following files: