Moved Effects.h to EntityEffects.h, added initial impl
This commit is contained in:
parent
c1692a2e3b
commit
87b1bfaf2a
@ -40,7 +40,7 @@ $cfile "../Entities/Painting.h"
|
|||||||
$cfile "../Entities/Pickup.h"
|
$cfile "../Entities/Pickup.h"
|
||||||
$cfile "../Entities/ProjectileEntity.h"
|
$cfile "../Entities/ProjectileEntity.h"
|
||||||
$cfile "../Entities/TNTEntity.h"
|
$cfile "../Entities/TNTEntity.h"
|
||||||
$cfile "../Entities/Effects.h"
|
$cfile "../Entities/EntityEffects.h"
|
||||||
$cfile "../Server.h"
|
$cfile "../Server.h"
|
||||||
$cfile "../World.h"
|
$cfile "../World.h"
|
||||||
$cfile "../Inventory.h"
|
$cfile "../Inventory.h"
|
||||||
|
@ -42,7 +42,7 @@ set(BINDING_DEPENDECIES
|
|||||||
Cuboid.h
|
Cuboid.h
|
||||||
Defines.h
|
Defines.h
|
||||||
Enchantments.h
|
Enchantments.h
|
||||||
Entities/Effects.h
|
Entities/EntityEffects.h
|
||||||
Entities/Entity.h
|
Entities/Entity.h
|
||||||
Entities/Floater.h
|
Entities/Floater.h
|
||||||
Entities/Pawn.h
|
Entities/Pawn.h
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
// tolua_begin
|
|
||||||
enum ENUM_ENTITY_EFFECT
|
|
||||||
{
|
|
||||||
E_EFFECT_SPEED = 1,
|
|
||||||
E_EFFECT_SLOWNESS = 2,
|
|
||||||
E_EFFECT_HASTE = 3,
|
|
||||||
E_EFFECT_MINING_FATIGUE = 4,
|
|
||||||
E_EFFECT_STENGTH = 5,
|
|
||||||
E_EFFECT_INSTANT_HEALTH = 6,
|
|
||||||
E_EFFECT_INSTANT_DAMAGE = 7,
|
|
||||||
E_EFFECT_JUMP_BOOST = 8,
|
|
||||||
E_EFFECT_NAUSEA = 9,
|
|
||||||
E_EFFECT_REGENERATION = 10,
|
|
||||||
E_EFFECT_RESISTANCE = 11,
|
|
||||||
E_EFFECT_FIRE_RESISTANCE = 12,
|
|
||||||
E_EFFECT_WATER_BREATHING = 13,
|
|
||||||
E_EFFECT_INVISIBILITY = 14,
|
|
||||||
E_EFFECT_BLINDNESS = 15,
|
|
||||||
E_EFFECT_NIGHT_VISION = 16,
|
|
||||||
E_EFFECT_HUNGER = 17,
|
|
||||||
E_EFFECT_WEAKNESS = 18,
|
|
||||||
E_EFFECT_POISON = 19,
|
|
||||||
E_EFFECT_WITHER = 20,
|
|
||||||
E_EFFECT_HEALTH_BOOST = 21,
|
|
||||||
E_EFFECT_ABSORPTION = 22,
|
|
||||||
E_EFFECT_SATURATION = 23,
|
|
||||||
} ;
|
|
||||||
// tolua_end
|
|
25
src/Entities/EntityEffects.cpp
Normal file
25
src/Entities/EntityEffects.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
|
||||||
|
|
||||||
|
#include "EntityEffects.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cEntityEffect::cEntityEffect():
|
||||||
|
m_Ticks(0),
|
||||||
|
m_Intensity(0)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cEntityEffect::cEntityEffect(int a_Ticks, short a_Intensity):
|
||||||
|
m_Ticks(a_Ticks),
|
||||||
|
m_Intensity(a_Intensity)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
53
src/Entities/EntityEffects.h
Normal file
53
src/Entities/EntityEffects.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// tolua_begin
|
||||||
|
class cEntityEffect {
|
||||||
|
public:
|
||||||
|
|
||||||
|
/** All types of entity effects (numbers correspond to IDs) */
|
||||||
|
enum eType
|
||||||
|
{
|
||||||
|
efSpeed = 1,
|
||||||
|
efSlowness = 2,
|
||||||
|
efHaste = 3,
|
||||||
|
efMiningFatigue = 4,
|
||||||
|
efStrength = 5,
|
||||||
|
efInstantHealth = 6,
|
||||||
|
efInstantDamage = 7,
|
||||||
|
efJumpBoost = 8,
|
||||||
|
efNausia = 9,
|
||||||
|
efRegeneration = 10,
|
||||||
|
efResistance = 11,
|
||||||
|
efFireResistance = 12,
|
||||||
|
efWaterBreathing = 13,
|
||||||
|
efInvisibility = 14,
|
||||||
|
efBlindness = 15,
|
||||||
|
efNightVision = 16,
|
||||||
|
efHunger = 17,
|
||||||
|
efWeakness = 18,
|
||||||
|
efPoison = 19,
|
||||||
|
efWither = 20,
|
||||||
|
efHealthBoost = 21,
|
||||||
|
efAbsorption = 22,
|
||||||
|
efSaturation = 23,
|
||||||
|
} ;
|
||||||
|
|
||||||
|
/** The duration of the effect */
|
||||||
|
int m_Ticks;
|
||||||
|
|
||||||
|
/** How strong the effect will be applied */
|
||||||
|
short m_Intensity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An empty entity effect
|
||||||
|
*/
|
||||||
|
cEntityEffect();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An entity effect
|
||||||
|
* @param a_Ticks The duration of the effect
|
||||||
|
* @param a_Intensity How strong the effect will be applied
|
||||||
|
*/
|
||||||
|
cEntityEffect(int a_Ticks, short a_Intensity);
|
||||||
|
};
|
||||||
|
// tolua_end
|
@ -10,6 +10,7 @@
|
|||||||
cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height)
|
cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height)
|
||||||
: cEntity(a_EntityType, 0, 0, 0, a_Width, a_Height)
|
: cEntity(a_EntityType, 0, 0, 0, a_Width, a_Height)
|
||||||
, m_bBurnable(true)
|
, m_bBurnable(true)
|
||||||
|
, m_EntityEffects(std::map<cEntityEffect::eType, cEntityEffect>())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,3 +18,27 @@ cPawn::cPawn(eEntityType a_EntityType, double a_Width, double a_Height)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cPawn::Tick(float a_Dt, cChunk & a_Chunk)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
super::Tick(a_Dt, a_Chunk);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cPawn::AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect)
|
||||||
|
{
|
||||||
|
m_EntityEffects[a_EffectType] = a_Effect;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cPawn::RemoveEntityEffect(cEntityEffect::eType a_EffectType)
|
||||||
|
{
|
||||||
|
m_EntityEffects.erase(a_EffectType);
|
||||||
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
|
#include "EntityEffects.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -18,9 +19,15 @@ public:
|
|||||||
CLASS_PROTODEF(cPawn);
|
CLASS_PROTODEF(cPawn);
|
||||||
|
|
||||||
cPawn(eEntityType a_EntityType, double a_Width, double a_Height);
|
cPawn(eEntityType a_EntityType, double a_Width, double a_Height);
|
||||||
|
|
||||||
|
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
|
||||||
|
|
||||||
|
void AddEntityEffect(cEntityEffect::eType a_EffectType, cEntityEffect a_Effect);
|
||||||
|
void RemoveEntityEffect(cEntityEffect::eType a_EffectType);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_bBurnable;
|
bool m_bBurnable;
|
||||||
|
std::map<cEntityEffect::eType, cEntityEffect> m_EntityEffects;
|
||||||
} ; // tolua_export
|
} ; // tolua_export
|
||||||
|
|
||||||
|
|
||||||
|
@ -584,12 +584,12 @@ void cPlayer::FoodPoison(int a_NumTicks)
|
|||||||
m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks);
|
m_FoodPoisonedTicksRemaining = std::max(m_FoodPoisonedTicksRemaining, a_NumTicks);
|
||||||
if (!HasBeenFoodPoisoned)
|
if (!HasBeenFoodPoisoned)
|
||||||
{
|
{
|
||||||
m_World->BroadcastRemoveEntityEffect(*this, E_EFFECT_HUNGER);
|
m_World->BroadcastRemoveEntityEffect(*this, cEntityEffect::efHunger);
|
||||||
SendHealth();
|
SendHealth();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_World->BroadcastEntityEffect(*this, E_EFFECT_HUNGER, 0, 400); // Give the player the "Hunger" effect for 20 seconds.
|
m_World->BroadcastEntityEffect(*this, cEntityEffect::efHunger, 0, 400); // Give the player the "Hunger" effect for 20 seconds.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1930,7 +1930,7 @@ void cPlayer::HandleFood(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_World->BroadcastRemoveEntityEffect(*this, E_EFFECT_HUNGER); // Remove the "Hunger" effect.
|
m_World->BroadcastRemoveEntityEffect(*this, cEntityEffect::efHunger); // Remove the "Hunger" effect.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply food exhaustion that has accumulated:
|
// Apply food exhaustion that has accumulated:
|
||||||
|
@ -368,6 +368,5 @@ T Clamp(T a_Value, T a_Min, T a_Max)
|
|||||||
#include "BiomeDef.h"
|
#include "BiomeDef.h"
|
||||||
#include "BlockID.h"
|
#include "BlockID.h"
|
||||||
#include "BlockInfo.h"
|
#include "BlockInfo.h"
|
||||||
#include "Entities/Effects.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user