1
0
Fork 0

Exported individual projectile classes to Lua API.

They used to be exported, but then they were moved to separate files and those werent' added to the ToLua processing list.
This commit is contained in:
Mattes D 2014-10-21 21:25:52 +02:00
parent bcb839d07b
commit 0c0c762412
18 changed files with 367 additions and 221 deletions

View File

@ -33,15 +33,25 @@ $cfile "../StringUtils.h"
$cfile "../Defines.h" $cfile "../Defines.h"
$cfile "../ChatColor.h" $cfile "../ChatColor.h"
$cfile "../ClientHandle.h" $cfile "../ClientHandle.h"
$cfile "../Entities/ArrowEntity.h"
$cfile "../Entities/Entity.h" $cfile "../Entities/Entity.h"
$cfile "../Entities/EntityEffect.h"
$cfile "../Entities/ExpBottleEntity.h"
$cfile "../Entities/FireChargeEntity.h"
$cfile "../Entities/FireworkEntity.h"
$cfile "../Entities/Floater.h" $cfile "../Entities/Floater.h"
$cfile "../Entities/GhastFireballEntity.h"
$cfile "../Entities/Pawn.h" $cfile "../Entities/Pawn.h"
$cfile "../Entities/Player.h" $cfile "../Entities/Player.h"
$cfile "../Entities/Painting.h" $cfile "../Entities/Painting.h"
$cfile "../Entities/Pickup.h" $cfile "../Entities/Pickup.h"
$cfile "../Entities/ProjectileEntity.h" $cfile "../Entities/ProjectileEntity.h"
$cfile "../Entities/SplashPotionEntity.h"
$cfile "../Entities/ThrownEggEntity.h"
$cfile "../Entities/ThrownEnderPearlEntity.h"
$cfile "../Entities/ThrownSnowballEntity.h"
$cfile "../Entities/TNTEntity.h" $cfile "../Entities/TNTEntity.h"
$cfile "../Entities/EntityEffect.h" $cfile "../Entities/WitherSkullEntity.h"
$cfile "../Server.h" $cfile "../Server.h"
$cfile "../World.h" $cfile "../World.h"
$cfile "../Inventory.h" $cfile "../Inventory.h"

View File

@ -5,131 +5,131 @@ include_directories ("${PROJECT_SOURCE_DIR}/../")
include_directories (".") include_directories (".")
SET (SRCS SET (SRCS
Bindings.cpp Bindings.cpp
DeprecatedBindings.cpp DeprecatedBindings.cpp
LuaChunkStay.cpp LuaChunkStay.cpp
LuaState.cpp LuaState.cpp
LuaWindow.cpp LuaWindow.cpp
ManualBindings.cpp ManualBindings.cpp
ManualBindings_RankManager.cpp ManualBindings_RankManager.cpp
Plugin.cpp Plugin.cpp
PluginLua.cpp PluginLua.cpp
PluginManager.cpp PluginManager.cpp
WebPlugin.cpp WebPlugin.cpp
) )
SET (HDRS SET (HDRS
Bindings.h Bindings.h
DeprecatedBindings.h DeprecatedBindings.h
LuaChunkStay.h LuaChunkStay.h
LuaFunctions.h LuaFunctions.h
LuaState.h LuaState.h
LuaWindow.h LuaWindow.h
ManualBindings.h ManualBindings.h
Plugin.h Plugin.h
PluginLua.h PluginLua.h
PluginManager.h PluginManager.h
WebPlugin.h WebPlugin.h
tolua++.h tolua++.h
) )
# List all the files that are generated as part of the Bindings build process # List all the files that are generated as part of the Bindings build process
set (BINDING_OUTPUTS set (BINDING_OUTPUTS
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
) )
set(BINDING_DEPENDENCIES set(BINDING_DEPENDENCIES
tolua tolua
../Bindings/virtual_method_hooks.lua ../Bindings/virtual_method_hooks.lua
../Bindings/AllToLua.pkg ../Bindings/AllToLua.pkg
../Bindings/LuaFunctions.h ../Bindings/LuaFunctions.h
../Bindings/LuaWindow.h ../Bindings/LuaWindow.h
../Bindings/Plugin.h ../Bindings/Plugin.h
../Bindings/PluginLua.h ../Bindings/PluginLua.h
../Bindings/PluginManager.h ../Bindings/PluginManager.h
../Bindings/WebPlugin.h ../Bindings/WebPlugin.h
../BiomeDef.h ../BiomeDef.h
../BlockArea.h ../BlockArea.h
../BlockEntities/BeaconEntity.h ../BlockEntities/BeaconEntity.h
../BlockEntities/BlockEntity.h ../BlockEntities/BlockEntity.h
../BlockEntities/BlockEntityWithItems.h ../BlockEntities/BlockEntityWithItems.h
../BlockEntities/ChestEntity.h ../BlockEntities/ChestEntity.h
../BlockEntities/DispenserEntity.h ../BlockEntities/DispenserEntity.h
../BlockEntities/DropSpenserEntity.h ../BlockEntities/DropSpenserEntity.h
../BlockEntities/DropperEntity.h ../BlockEntities/DropperEntity.h
../BlockEntities/FurnaceEntity.h ../BlockEntities/FurnaceEntity.h
../BlockEntities/HopperEntity.h ../BlockEntities/HopperEntity.h
../BlockEntities/JukeboxEntity.h ../BlockEntities/JukeboxEntity.h
../BlockEntities/NoteEntity.h ../BlockEntities/NoteEntity.h
../BlockEntities/SignEntity.h ../BlockEntities/SignEntity.h
../BlockEntities/MobHeadEntity.h ../BlockEntities/MobHeadEntity.h
../BlockEntities/FlowerPotEntity.h ../BlockEntities/FlowerPotEntity.h
../BlockID.h ../BlockID.h
../BoundingBox.h ../BoundingBox.h
../ChatColor.h ../ChatColor.h
../ChunkDef.h ../ChunkDef.h
../ClientHandle.h ../ClientHandle.h
../CraftingRecipes.h ../CraftingRecipes.h
../Cuboid.h ../Cuboid.h
../Defines.h ../Defines.h
../Enchantments.h ../Enchantments.h
../Entities/EntityEffect.h ../Entities/ArrowEntity.h
../Entities/Entity.h ../Entities/Entity.h
../Entities/Floater.h ../Entities/EntityEffect.h
../Entities/Pawn.h ../Entities/ExpBottleEntity.h
../Entities/Painting.h ../Entities/FireChargeEntity.h
../Entities/Pickup.h ../Entities/FireworkEntity.h
../Entities/Player.h ../Entities/Floater.h
../Entities/ProjectileEntity.h ../Entities/GhastFireballEntity.h
../Entities/ArrowEntity.h ../Entities/Pawn.h
../Entities/ThrownEggEntity.h ../Entities/Player.h
../Entities/ThrownEnderPearlEntity.h ../Entities/Painting.h
../Entities/ExpBottleEntity.h ../Entities/Pickup.h
../Entities/ThrownSnowballEntity.h ../Entities/ProjectileEntity.h
../Entities/FireChargeEntity.h ../Entities/SplashPotionEntity.h
../Entities/FireworkEntity.h ../Entities/ThrownEggEntity.h
../Entities/GhastFireballEntity.h ../Entities/ThrownEnderPearlEntity.h
../Entities/TNTEntity.h ../Entities/ThrownSnowballEntity.h
../Entities/ExpOrb.h ../Entities/TNTEntity.h
../Entities/HangingEntity.h ../Entities/WitherSkullEntity.h
../Entities/ItemFrame.h ../Generating/ChunkDesc.h
../Generating/ChunkDesc.h ../Inventory.h
../Inventory.h ../Item.h
../Item.h ../ItemGrid.h
../ItemGrid.h ../Mobs/Monster.h
../Mobs/Monster.h ../OSSupport/File.h
../OSSupport/File.h ../Root.h
../Root.h ../Server.h
../Server.h ../StringUtils.h
../StringUtils.h ../Tracer.h
../Tracer.h ../UI/Window.h
../UI/Window.h ../Vector3.h
../Vector3.h ../WebAdmin.h
../WebAdmin.h ../World.h
../World.h
) )
if (NOT MSVC) if (NOT MSVC)
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
# add any new generated bindings here # add any new generated bindings here
OUTPUT ${BINDING_OUTPUTS} OUTPUT ${BINDING_OUTPUTS}
# Regenerate bindings: # Regenerate bindings:
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
# add any new generation dependencies here # add any new generation dependencies here
DEPENDS ${BINDING_DEPENDENCIES} DEPENDS ${BINDING_DEPENDENCIES}
) )
endif () endif ()
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES GENERATED TRUE) set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.h PROPERTIES GENERATED TRUE) set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.h PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error) set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error)
if(NOT MSVC) if(NOT MSVC)
add_library(Bindings ${SRCS} ${HDRS}) add_library(Bindings ${SRCS} ${HDRS})
target_link_libraries(Bindings lua sqlite tolualib polarssl) target_link_libraries(Bindings lua sqlite tolualib polarssl)
endif() endif()

View File

@ -1,6 +1,11 @@
//
// ArrowEntity.h // ArrowEntity.h
//
// Declares the cArrowEntity representing the arrow that has been shot by the player or by a skeleton
#pragma once #pragma once
@ -19,7 +24,7 @@ class cArrowEntity :
typedef cProjectileEntity super; typedef cProjectileEntity super;
public: public:
/// Determines when the arrow can be picked up (depending on player gamemode). Corresponds to the MCA file "pickup" field /** Determines when the arrow can be picked up (depending on player gamemode). Corresponds to the MCA file "pickup" field */
enum ePickupState enum ePickupState
{ {
psNoPickup = 0, psNoPickup = 0,
@ -31,33 +36,33 @@ public:
CLASS_PROTODEF(cArrowEntity) CLASS_PROTODEF(cArrowEntity)
/// Creates a new arrow with psNoPickup state and default damage modifier coeff /** Creates a new arrow with psNoPickup state and default damage modifier coeff */
cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed); cArrowEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const Vector3d & a_Speed);
/// Creates a new arrow as shot by a player, initializes it from the player object /** Creates a new arrow as shot by a player, initializes it from the player object */
cArrowEntity(cPlayer & a_Player, double a_Force); cArrowEntity(cPlayer & a_Player, double a_Force);
// tolua_begin // tolua_begin
/// Returns whether the arrow can be picked up by players /** Returns whether the arrow can be picked up by players */
ePickupState GetPickupState(void) const { return m_PickupState; } ePickupState GetPickupState(void) const { return m_PickupState; }
/// Sets a new pickup state /** Sets a new pickup state */
void SetPickupState(ePickupState a_PickupState) { m_PickupState = a_PickupState; } void SetPickupState(ePickupState a_PickupState) { m_PickupState = a_PickupState; }
/// Returns the damage modifier coeff. /** Returns the damage modifier coeff. */
double GetDamageCoeff(void) const { return m_DamageCoeff; } double GetDamageCoeff(void) const { return m_DamageCoeff; }
/// Sets the damage modifier coeff /** Sets the damage modifier coeff */
void SetDamageCoeff(double a_DamageCoeff) { m_DamageCoeff = a_DamageCoeff; } void SetDamageCoeff(double a_DamageCoeff) { m_DamageCoeff = a_DamageCoeff; }
/// Returns true if the specified player can pick the arrow up /** Returns true if the specified player can pick the arrow up */
bool CanPickup(const cPlayer & a_Player) const; bool CanPickup(const cPlayer & a_Player) const;
/// Returns true if the arrow is set as critical /** Returns true if the arrow is set as critical */
bool IsCritical(void) const { return m_IsCritical; } bool IsCritical(void) const { return m_IsCritical; }
/// Sets the IsCritical flag /** Sets the IsCritical flag */
void SetIsCritical(bool a_IsCritical) { m_IsCritical = a_IsCritical; } void SetIsCritical(bool a_IsCritical) { m_IsCritical = a_IsCritical; }
/** Gets the block arrow is in */ /** Gets the block arrow is in */
@ -70,28 +75,28 @@ public:
protected: protected:
/// Determines when the arrow can be picked up by players /** Determines when the arrow can be picked up by players */
ePickupState m_PickupState; ePickupState m_PickupState;
/// The coefficient applied to the damage that the arrow will deal, based on the bow enchantment. 2.0 for normal arrow /** The coefficient applied to the damage that the arrow will deal, based on the bow enchantment. 2.0 for normal arrow */
double m_DamageCoeff; double m_DamageCoeff;
/// If true, the arrow deals more damage /** If true, the arrow deals more damage */
bool m_IsCritical; bool m_IsCritical;
/// Timer for pickup collection animation or five minute timeout /** Timer for pickup collection animation or five minute timeout */
float m_Timer; float m_Timer;
/// Timer for client arrow position confirmation via TeleportEntity /** Timer for client arrow position confirmation via TeleportEntity */
float m_HitGroundTimer; float m_HitGroundTimer;
// Whether the arrow has already been teleported into the proper position in the ground. // Whether the arrow has already been teleported into the proper position in the ground.
bool m_HasTeleported; bool m_HasTeleported;
/// If true, the arrow is in the process of being collected - don't go to anyone else /** If true, the arrow is in the process of being collected - don't go to anyone else */
bool m_bIsCollected; bool m_bIsCollected;
/// Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air /** Stores the block position that arrow is lodged into, sets m_IsInGround to false if it becomes air */
Vector3i m_HitBlockPos; Vector3i m_HitBlockPos;
// cProjectileEntity overrides: // cProjectileEntity overrides:

View File

@ -1,6 +1,11 @@
//
// ExpBottleEntity.h // ExpBottleEntity.h
//
// Declares the cExpBottleEntity class representing the thrown exp bottle
#pragma once #pragma once
@ -33,6 +38,10 @@ protected:
/** Breaks the bottle, fires its particle effects and sounds /** Breaks the bottle, fires its particle effects and sounds
@param a_HitPos The position where the bottle will break */ @param a_HitPos The position where the bottle will break */
void Break(const Vector3d &a_HitPos); void Break(const Vector3d & a_HitPos);
}; // tolua_export }; // tolua_export

View File

@ -1,6 +1,11 @@
//
// FireChargeEntity.h // FireChargeEntity.h
//
// Declares the cFireChargeEntity representing the fire charge shot by the blaze
#pragma once #pragma once
@ -34,3 +39,7 @@ protected:
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override; virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
} ; // tolua_export } ; // tolua_export

View File

@ -10,7 +10,7 @@
cFireworkEntity::cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item) : cFireworkEntity::cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item) :
super(pkFirework, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25), super(pkFirework, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
m_ExplodeTimer(0), m_TicksToExplosion(a_Item.m_FireworkItem.m_FlightTimeInTicks),
m_FireworkItem(a_Item) m_FireworkItem(a_Item)
{ {
} }
@ -27,7 +27,9 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
if ((PosY < 0) || (PosY >= cChunkDef::Height)) if ((PosY < 0) || (PosY >= cChunkDef::Height))
{ {
goto setspeed; AddSpeedY(1);
AddPosition(GetSpeed() * (a_Dt / 1000));
return;
} }
if (m_IsInGround) if (m_IsInGround)
@ -50,7 +52,6 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
} }
} }
setspeed:
AddSpeedY(1); AddSpeedY(1);
AddPosition(GetSpeed() * (a_Dt / 1000)); AddPosition(GetSpeed() * (a_Dt / 1000));
} }
@ -63,11 +64,13 @@ void cFireworkEntity::Tick(float a_Dt, cChunk & a_Chunk)
{ {
super::Tick(a_Dt, a_Chunk); super::Tick(a_Dt, a_Chunk);
if (m_ExplodeTimer == m_FireworkItem.m_FireworkItem.m_FlightTimeInTicks) if (m_TicksToExplosion <= 0)
{ {
// TODO: Notify the plugins
m_World->BroadcastEntityStatus(*this, esFireworkExploding); m_World->BroadcastEntityStatus(*this, esFireworkExploding);
Destroy(); Destroy();
return;
} }
m_ExplodeTimer++; m_TicksToExplosion -= 1;
} }

View File

@ -1,6 +1,11 @@
//
// FireworkEntity.h // FireworkEntity.h
//
// Declares the cFireworkEntity class representing the flying firework rocket
#pragma once #pragma once
@ -24,7 +29,22 @@ public:
CLASS_PROTODEF(cFireworkEntity) CLASS_PROTODEF(cFireworkEntity)
cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item); cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item);
// tolua_begin
/** Returns the item used to create the rocket (has all the firework effects on it) */
const cItem & GetItem(void) const { return m_FireworkItem; } const cItem & GetItem(void) const { return m_FireworkItem; }
/** Sets the item that is used to create the rocket (has all the firework effects on it) */
void SetItem(const cItem & a_Item) { m_FireworkItem = a_Item; }
/** Returns the number of ticks left until the firework explosion. */
int GetTicksToExplosion(void) const { return m_TicksToExplosion; }
/** Sets the number of ticks left until the firework explosion. */
void SetTicksToExplosion(int a_TicksToExplosion) { m_TicksToExplosion = a_TicksToExplosion; }
// tolua_end
protected: protected:
@ -34,7 +54,11 @@ protected:
private: private:
int m_ExplodeTimer; int m_TicksToExplosion;
cItem m_FireworkItem; cItem m_FireworkItem;
}; // tolua_export }; // tolua_export

View File

@ -1,6 +1,11 @@
//
// GhastFireballEntity.h // GhastFireballEntity.h
//
// Declares the cGhastFireballEntity class representing the ghast fireball in flight.
#pragma once #pragma once
@ -36,3 +41,7 @@ protected:
// TODO: Deflecting the fireballs by arrow- or sword- hits // TODO: Deflecting the fireballs by arrow- or sword- hits
} ; // tolua_export } ; // tolua_export

View File

@ -11,15 +11,22 @@
class cPainting : class cPainting :
public cEntity public cEntity
{ {
// tolua_end
typedef cEntity super; typedef cEntity super;
public: public:
// tolua_end
CLASS_PROTODEF(cPainting) CLASS_PROTODEF(cPainting)
cPainting(const AString & a_Name, int a_Direction, double a_X, double a_Y, double a_Z); cPainting(const AString & a_Name, int a_Direction, double a_X, double a_Y, double a_Z);
const AString & GetName(void) const { return m_Name; } // tolua_export
int GetDirection(void) const { return m_Direction; } // tolua_export // tolua_begin
const AString & GetName(void) const { return m_Name; }
int GetDirection(void) const { return m_Direction; }
// tolua_end
private: private:

View File

@ -1,7 +1,7 @@
// ProjectileEntity.h // ProjectileEntity.h
// Declares the cProjectileEntity class representing the common base class for projectiles, as well as individual projectile types // Declares the cProjectileEntity class representing the common base class for projectiles
@ -23,7 +23,7 @@ class cProjectileEntity :
typedef cEntity super; typedef cEntity super;
public: public:
/// The kind of the projectile. The numbers correspond to the network type ID used for spawning via the 0x17 packet. /** The kind of the projectile. The numbers correspond to the network type ID used for spawning them in the protocol. */
enum eKind enum eKind
{ {
pkArrow = 60, pkArrow = 60,
@ -48,22 +48,22 @@ public:
static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed = NULL); static cProjectileEntity * Create(eKind a_Kind, cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem * a_Item, const Vector3d * a_Speed = NULL);
/// Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given /** Called by the physics blocktracer when the entity hits a solid block, the hit position and the face hit (BLOCK_FACE_) is given */
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace); virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace);
/// Called by the physics blocktracer when the entity hits another entity /** Called by the physics blocktracer when the entity hits another entity */
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
{ {
UNUSED(a_EntityHit); UNUSED(a_EntityHit);
UNUSED(a_HitPos); UNUSED(a_HitPos);
} }
/// Called by Chunk when the projectile is eligible for player collection /** Called by Chunk when the projectile is eligible for player collection */
virtual void CollectedBy(cPlayer & a_Dest); virtual void CollectedBy(cPlayer & a_Dest);
// tolua_begin // tolua_begin
/// Returns the kind of the projectile (fast class identification) /** Returns the kind of the projectile (fast class identification) */
eKind GetProjectileKind(void) const { return m_ProjectileKind; } eKind GetProjectileKind(void) const { return m_ProjectileKind; }
/** Returns the unique ID of the entity who created this projectile /** Returns the unique ID of the entity who created this projectile
@ -76,15 +76,15 @@ public:
*/ */
AString GetCreatorName(void) const { return m_CreatorData.m_Name; } AString GetCreatorName(void) const { return m_CreatorData.m_Name; }
/// Returns the string that is used as the entity type (class name) in MCA files /** Returns the string that is used as the entity type (class name) in MCA files */
AString GetMCAClassName(void) const; AString GetMCAClassName(void) const;
/// Returns true if the projectile has hit the ground and is stuck there /** Returns true if the projectile has hit the ground and is stuck there */
bool IsInGround(void) const { return m_IsInGround; } bool IsInGround(void) const { return m_IsInGround; }
// tolua_end // tolua_end
/// Sets the internal InGround flag. To be used by MCA loader only! /** Sets the internal InGround flag. To be used by MCA loader only! */
void SetIsInGround(bool a_IsInGround) { m_IsInGround = a_IsInGround; } void SetIsInGround(bool a_IsInGround) { m_IsInGround = a_IsInGround; }
protected: protected:
@ -114,7 +114,7 @@ protected:
*/ */
CreatorData m_CreatorData; CreatorData m_CreatorData;
/// True if the projectile has hit the ground and is stuck there /** True if the projectile has hit the ground and is stuck there */
bool m_IsInGround; bool m_IsInGround;
// cEntity overrides: // cEntity overrides:

View File

@ -1,6 +1,11 @@
//
// SplashPotionEntity.h // SplashPotionEntity.h
//
// Declares the cSplashPotionEntity class representing a splash potion that has been thrown
#pragma once #pragma once
@ -32,6 +37,7 @@ public:
const cItem & a_Item const cItem & a_Item
); );
// tolua_begin
cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; } cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; }
cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; } cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; }
int GetPotionColor(void) const { return m_PotionColor; } int GetPotionColor(void) const { return m_PotionColor; }
@ -39,6 +45,8 @@ public:
void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; } void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; }
void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; } void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; } void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; }
// tolua_end
protected: protected:
@ -77,3 +85,7 @@ private:
/** Time in ticks to wait for the hit animation to begin before destroying */ /** Time in ticks to wait for the hit animation to begin before destroying */
int m_DestroyTimer; int m_DestroyTimer;
} ; // tolua_export } ; // tolua_export

View File

@ -44,6 +44,27 @@ void cThrownEggEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_Hit
void cThrownEggEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
if (m_DestroyTimer > 0)
{
m_DestroyTimer--;
if (m_DestroyTimer == 0)
{
Destroy();
return;
}
}
else
{
super::Tick(a_Dt, a_Chunk);
}
}
void cThrownEggEntity::TrySpawnChicken(const Vector3d & a_HitPos) void cThrownEggEntity::TrySpawnChicken(const Vector3d & a_HitPos)
{ {
if (m_World->GetTickRandomNumber(7) == 1) if (m_World->GetTickRandomNumber(7) == 1)

View File

@ -1,6 +1,11 @@
//
// ThrownEggEntity.h // ThrownEggEntity.h
//
// Declares the cThrownEggEntity class representing a regular thrown egg
#pragma once #pragma once
@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides: // cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void Tick (float a_Dt, cChunk & a_Chunk) override virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
{
if (m_DestroyTimer > 0)
{
m_DestroyTimer--;
if (m_DestroyTimer == 0)
{
Destroy();
return;
}
}
else
{
super::Tick(a_Dt, a_Chunk);
}
}
// Randomly decides whether to spawn a chicken where the egg lands. // Randomly decides whether to spawn a chicken where the egg lands.
void TrySpawnChicken(const Vector3d & a_HitPos); void TrySpawnChicken(const Vector3d & a_HitPos);
@ -56,3 +46,7 @@ private:
int m_DestroyTimer; int m_DestroyTimer;
} ; // tolua_export } ; // tolua_export

View File

@ -1,3 +1,4 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules #include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#include "ThrownEnderPearlEntity.h" #include "ThrownEnderPearlEntity.h"
@ -45,6 +46,27 @@ void cThrownEnderPearlEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d
void cThrownEnderPearlEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
if (m_DestroyTimer > 0)
{
m_DestroyTimer--;
if (m_DestroyTimer == 0)
{
Destroy();
return;
}
}
else
{
super::Tick(a_Dt, a_Chunk);
}
}
void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos) void cThrownEnderPearlEntity::TeleportCreator(const Vector3d & a_HitPos)
{ {
if (m_CreatorData.m_Name.empty()) if (m_CreatorData.m_Name.empty())

View File

@ -1,6 +1,11 @@
//
// ThrownEnderPearlEntity.h // ThrownEnderPearlEntity.h
//
// Declares the cThrownEnderPeralEntity class representing an ender pearl being thrown
#pragma once #pragma once
@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides: // cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void Tick (float a_Dt, cChunk & a_Chunk) override virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
{
if (m_DestroyTimer > 0)
{
m_DestroyTimer--;
if (m_DestroyTimer == 0)
{
Destroy();
return;
}
}
else
{
super::Tick(a_Dt, a_Chunk);
}
}
/** Teleports the creator where the ender pearl lands */ /** Teleports the creator where the ender pearl lands */
void TeleportCreator(const Vector3d & a_HitPos); void TeleportCreator(const Vector3d & a_HitPos);
@ -56,3 +46,7 @@ private:
int m_DestroyTimer; int m_DestroyTimer;
} ; // tolua_export } ; // tolua_export

View File

@ -43,3 +43,28 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d &
m_DestroyTimer = 5; m_DestroyTimer = 5;
} }
void cThrownSnowballEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
if (m_DestroyTimer > 0)
{
m_DestroyTimer--;
if (m_DestroyTimer == 0)
{
Destroy();
return;
}
}
else
{
super::Tick(a_Dt, a_Chunk);
}
}

View File

@ -1,6 +1,11 @@
//
// ThrownSnowballEntity.h // ThrownSnowballEntity.h
//
// Declares the cThrownSnowballEntity representing a snowball that has been thrown
#pragma once #pragma once
@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides: // cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void Tick (float a_Dt, cChunk & a_Chunk) override virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
{
if (m_DestroyTimer > 0)
{
m_DestroyTimer--;
if (m_DestroyTimer == 0)
{
Destroy();
return;
}
}
else
{
super::Tick(a_Dt, a_Chunk);
}
}
private: private:
@ -53,3 +43,7 @@ private:
int m_DestroyTimer; int m_DestroyTimer;
} ; // tolua_export } ; // tolua_export

View File

@ -1,8 +1,12 @@
// WitherSkullEntity.h // WitherSkullEntity.h
// Declares the cWitherSkullEntity class representing the entity used by both blue and black wither skulls // Declares the cWitherSkullEntity class representing the entity used by both blue and black wither skulls
#pragma once #pragma once
#include "ProjectileEntity.h" #include "ProjectileEntity.h"
@ -30,6 +34,10 @@ protected:
// cProjectileEntity overrides: // cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override; virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) override; virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
} ; // tolua_export } ; // tolua_export