Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
cEntityEffect Class Reference

#include <EntityEffect.h>

Inheritance diagram for cEntityEffect:
Inheritance graph
[legend]

Public Types

enum  eType {
  effNoEffect = 0, effSpeed = 1, effSlowness = 2, effHaste = 3,
  effMiningFatigue = 4, effStrength = 5, effInstantHealth = 6, effInstantDamage = 7,
  effJumpBoost = 8, effNausea = 9, effRegeneration = 10, effResistance = 11,
  effFireResistance = 12, effWaterBreathing = 13, effInvisibility = 14, effBlindness = 15,
  effNightVision = 16, effHunger = 17, effWeakness = 18, effPoison = 19,
  effWither = 20, effHealthBoost = 21, effAbsorption = 22, effSaturation = 23
}
 All types of entity effects (numbers correspond to protocol / storage types) More...
 

Public Member Functions

 cEntityEffect (void)
 Creates an empty entity effect. More...
 
 cEntityEffect (int a_Duration, short a_Intensity, double a_DistanceModifier=1)
 Creates an entity effect of the specified type. More...
 
 cEntityEffect (const cEntityEffect &a_OtherEffect)
 Creates an entity effect by copying another. More...
 
double GetDistanceModifier (void) const
 Returns the distance modifier for affecting potency. More...
 
int GetDuration (void) const
 Returns the duration of the effect. More...
 
short GetIntensity (void) const
 Returns how strong the effect will be applied. More...
 
int GetTicks (void) const
 Returns how many ticks this effect has been active for. More...
 
virtual void OnActivate (cPawn &a_Target)
 Called when the effect is first added to an entity. More...
 
virtual void OnDeactivate (cPawn &a_Target)
 Called when the effect is removed from an entity. More...
 
virtual void OnTick (cPawn &a_Target)
 Called on each tick. More...
 
cEntityEffectoperator= (cEntityEffect a_OtherEffect)
 Creates an entity effect by copying another. More...
 
void SetDistanceModifier (double a_DistanceModifier)
 
void SetDuration (int a_Duration)
 
void SetIntensity (short a_Intensity)
 
void SetTicks (int a_Ticks)
 
virtual ~cEntityEffect (void)
 

Static Public Member Functions

static std::unique_ptr< cEntityEffectCreateEntityEffect (cEntityEffect::eType a_EffectType, int a_Duration, short a_Intensity, double a_DistanceModifier)
 Creates a pointer to the proper entity effect from the effect type. More...
 
static int GetPotionColor (short a_ItemDamage)
 Returns the potion color (used by the client for visuals), based on the potion's damage value. More...
 
static int GetPotionEffectDuration (short a_ItemDamage)
 Returns the effect duration, in ticks, based on the potion's damage value. More...
 
static short GetPotionEffectIntensity (short a_ItemDamage)
 Retrieves the intensity level from the potion's damage value. More...
 
static cEntityEffect::eType GetPotionEffectType (short a_ItemDamage)
 Translates the potion's damage value into the entity effect that the potion gives. More...
 
static bool IsPotionDrinkable (short a_ItemDamage)
 Returns true if the potion with the given damage is drinkable. More...
 

Protected Attributes

double m_DistanceModifier
 The distance modifier for affecting potency. More...
 
int m_Duration
 How long this effect will last, in ticks. More...
 
short m_Intensity
 How strong the effect will be applied. More...
 
int m_Ticks
 How many ticks this effect has been active for. More...
 

Detailed Description

Definition at line 6 of file EntityEffect.h.

Member Enumeration Documentation

All types of entity effects (numbers correspond to protocol / storage types)

Enumerator
effNoEffect 
effSpeed 
effSlowness 
effHaste 
effMiningFatigue 
effStrength 
effInstantHealth 
effInstantDamage 
effJumpBoost 
effNausea 
effRegeneration 
effResistance 
effFireResistance 
effWaterBreathing 
effInvisibility 
effBlindness 
effNightVision 
effHunger 
effWeakness 
effPoison 
effWither 
effHealthBoost 
effAbsorption 
effSaturation 

Definition at line 11 of file EntityEffect.h.

Constructor & Destructor Documentation

cEntityEffect::cEntityEffect ( void  )

Creates an empty entity effect.

Definition at line 138 of file EntityEffect.cpp.

cEntityEffect::cEntityEffect ( int  a_Duration,
short  a_Intensity,
double  a_DistanceModifier = 1 
)

Creates an entity effect of the specified type.

Parameters
a_DurationHow long this effect will last, in ticks
a_IntensityHow strong the effect will be applied
a_DistanceModifierThe distance modifier for affecting potency, defaults to 1

Definition at line 151 of file EntityEffect.cpp.

cEntityEffect::cEntityEffect ( const cEntityEffect a_OtherEffect)

Creates an entity effect by copying another.

Parameters
a_OtherEffectThe other effect to copy

Definition at line 164 of file EntityEffect.cpp.

virtual cEntityEffect::~cEntityEffect ( void  )
inlinevirtual

Definition at line 76 of file EntityEffect.h.

Member Function Documentation

std::unique_ptr< cEntityEffect > cEntityEffect::CreateEntityEffect ( cEntityEffect::eType  a_EffectType,
int  a_Duration,
short  a_Intensity,
double  a_DistanceModifier 
)
static

Creates a pointer to the proper entity effect from the effect type.

Warning
This function creates raw pointers that must be manually managed.
Parameters
a_EffectTypeThe effect type to create the effect from
a_DurationHow long this effect will last, in ticks
a_IntensityHow strong the effect will be applied
a_DistanceModifierThe distance modifier for affecting potency, defaults to 1

Definition at line 190 of file EntityEffect.cpp.

double cEntityEffect::GetDistanceModifier ( void  ) const
inline

Returns the distance modifier for affecting potency.

Definition at line 96 of file EntityEffect.h.

int cEntityEffect::GetDuration ( void  ) const
inline

Returns the duration of the effect.

Definition at line 90 of file EntityEffect.h.

short cEntityEffect::GetIntensity ( void  ) const
inline

Returns how strong the effect will be applied.

Definition at line 93 of file EntityEffect.h.

int cEntityEffect::GetPotionColor ( short  a_ItemDamage)
static

Returns the potion color (used by the client for visuals), based on the potion's damage value.

Definition at line 12 of file EntityEffect.cpp.

int cEntityEffect::GetPotionEffectDuration ( short  a_ItemDamage)
static

Returns the effect duration, in ticks, based on the potion's damage value.

Definition at line 68 of file EntityEffect.cpp.

short cEntityEffect::GetPotionEffectIntensity ( short  a_ItemDamage)
static

Retrieves the intensity level from the potion's damage value.

Returns 0 for level I potions, 1 for level II potions.

Definition at line 58 of file EntityEffect.cpp.

cEntityEffect::eType cEntityEffect::GetPotionEffectType ( short  a_ItemDamage)
static

Translates the potion's damage value into the entity effect that the potion gives.

Definition at line 22 of file EntityEffect.cpp.

int cEntityEffect::GetTicks ( void  ) const
inline

Returns how many ticks this effect has been active for.

Definition at line 87 of file EntityEffect.h.

bool cEntityEffect::IsPotionDrinkable ( short  a_ItemDamage)
static

Returns true if the potion with the given damage is drinkable.

Definition at line 126 of file EntityEffect.cpp.

virtual void cEntityEffect::OnActivate ( cPawn a_Target)
inlinevirtual

Called when the effect is first added to an entity.

Reimplemented in cEntityEffectInvisibility, cEntityEffectInstantDamage, cEntityEffectInstantHealth, cEntityEffectSlowness, and cEntityEffectSpeed.

Definition at line 108 of file EntityEffect.h.

virtual void cEntityEffect::OnDeactivate ( cPawn a_Target)
inlinevirtual

Called when the effect is removed from an entity.

Reimplemented in cEntityEffectInvisibility, cEntityEffectSlowness, and cEntityEffectSpeed.

Definition at line 111 of file EntityEffect.h.

void cEntityEffect::OnTick ( cPawn a_Target)
virtual

Called on each tick.

By default increases the m_Ticks, descendants may override to provide additional processing.

Reimplemented in cEntityEffectSaturation, cEntityEffectWither, cEntityEffectPoison, cEntityEffectWeakness, cEntityEffectHunger, and cEntityEffectRegeneration.

Definition at line 227 of file EntityEffect.cpp.

cEntityEffect & cEntityEffect::operator= ( cEntityEffect  a_OtherEffect)

Creates an entity effect by copying another.

Parameters
a_OtherEffectThe other effect to copy

Definition at line 177 of file EntityEffect.cpp.

void cEntityEffect::SetDistanceModifier ( double  a_DistanceModifier)
inline

Definition at line 101 of file EntityEffect.h.

void cEntityEffect::SetDuration ( int  a_Duration)
inline

Definition at line 99 of file EntityEffect.h.

void cEntityEffect::SetIntensity ( short  a_Intensity)
inline

Definition at line 100 of file EntityEffect.h.

void cEntityEffect::SetTicks ( int  a_Ticks)
inline

Definition at line 98 of file EntityEffect.h.

Member Data Documentation

double cEntityEffect::m_DistanceModifier
protected

The distance modifier for affecting potency.

Definition at line 124 of file EntityEffect.h.

int cEntityEffect::m_Duration
protected

How long this effect will last, in ticks.

Definition at line 118 of file EntityEffect.h.

short cEntityEffect::m_Intensity
protected

How strong the effect will be applied.

Definition at line 121 of file EntityEffect.h.

int cEntityEffect::m_Ticks
protected

How many ticks this effect has been active for.

Definition at line 115 of file EntityEffect.h.


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