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 "../ChatColor.h"
$cfile "../ClientHandle.h"
$cfile "../Entities/ArrowEntity.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/GhastFireballEntity.h"
$cfile "../Entities/Pawn.h"
$cfile "../Entities/Player.h"
$cfile "../Entities/Painting.h"
$cfile "../Entities/Pickup.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/EntityEffect.h"
$cfile "../Entities/WitherSkullEntity.h"
$cfile "../Server.h"
$cfile "../World.h"
$cfile "../Inventory.h"

View File

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

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
@ -19,7 +24,7 @@ class cArrowEntity :
typedef cProjectileEntity super;
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
{
psNoPickup = 0,
@ -31,33 +36,33 @@ public:
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);
/// 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);
// 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; }
/// Sets a new pickup state
/** Sets a new pickup state */
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; }
/// Sets the damage modifier coeff
/** Sets the damage modifier coeff */
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;
/// 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; }
/// Sets the IsCritical flag
/** Sets the IsCritical flag */
void SetIsCritical(bool a_IsCritical) { m_IsCritical = a_IsCritical; }
/** Gets the block arrow is in */
@ -70,28 +75,28 @@ public:
protected:
/// Determines when the arrow can be picked up by players
/** Determines when the arrow can be picked up by players */
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;
/// If true, the arrow deals more damage
/** If true, the arrow deals more damage */
bool m_IsCritical;
/// Timer for pickup collection animation or five minute timeout
/** Timer for pickup collection animation or five minute timeout */
float m_Timer;
/// Timer for client arrow position confirmation via TeleportEntity
/** Timer for client arrow position confirmation via TeleportEntity */
float m_HitGroundTimer;
// Whether the arrow has already been teleported into the proper position in the ground.
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;
/// 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;
// cProjectileEntity overrides:

View File

@ -1,6 +1,11 @@
//
// ExpBottleEntity.h
//
// ExpBottleEntity.h
// Declares the cExpBottleEntity class representing the thrown exp bottle
#pragma once
@ -33,6 +38,10 @@ protected:
/** Breaks the bottle, fires its particle effects and sounds
@param a_HitPos The position where the bottle will break */
void Break(const Vector3d &a_HitPos);
void Break(const Vector3d & a_HitPos);
}; // 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
@ -34,3 +39,7 @@ protected:
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
} ; // 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) :
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)
{
}
@ -27,7 +27,9 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
if ((PosY < 0) || (PosY >= cChunkDef::Height))
{
goto setspeed;
AddSpeedY(1);
AddPosition(GetSpeed() * (a_Dt / 1000));
return;
}
if (m_IsInGround)
@ -50,7 +52,6 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
}
}
setspeed:
AddSpeedY(1);
AddPosition(GetSpeed() * (a_Dt / 1000));
}
@ -63,11 +64,13 @@ void cFireworkEntity::Tick(float a_Dt, cChunk & 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);
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
@ -24,7 +29,22 @@ public:
CLASS_PROTODEF(cFireworkEntity)
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; }
/** 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:
@ -34,7 +54,11 @@ protected:
private:
int m_ExplodeTimer;
int m_TicksToExplosion;
cItem m_FireworkItem;
}; // tolua_export

View File

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

View File

@ -11,15 +11,22 @@
class cPainting :
public cEntity
{
// tolua_end
typedef cEntity super;
public:
// tolua_end
CLASS_PROTODEF(cPainting)
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:

View File

@ -1,7 +1,7 @@
// 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;
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
{
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);
/// 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);
/// 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)
{
UNUSED(a_EntityHit);
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);
// 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; }
/** 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; }
/// 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;
/// 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; }
// 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; }
protected:
@ -114,7 +114,7 @@ protected:
*/
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;
// 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
@ -32,6 +37,7 @@ public:
const cItem & a_Item
);
// tolua_begin
cEntityEffect::eType GetEntityEffectType(void) const { return m_EntityEffectType; }
cEntityEffect GetEntityEffect(void) const { return m_EntityEffect; }
int GetPotionColor(void) const { return m_PotionColor; }
@ -39,6 +45,8 @@ public:
void SetEntityEffectType(cEntityEffect::eType a_EntityEffectType) { m_EntityEffectType = a_EntityEffectType; }
void SetEntityEffect(cEntityEffect a_EntityEffect) { m_EntityEffect = a_EntityEffect; }
void SetPotionColor(int a_PotionColor) { m_PotionColor = a_PotionColor; }
// tolua_end
protected:
@ -77,3 +85,7 @@ private:
/** Time in ticks to wait for the hit animation to begin before destroying */
int m_DestroyTimer;
} ; // 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)
{
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
@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) 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);
}
}
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
// Randomly decides whether to spawn a chicken where the egg lands.
void TrySpawnChicken(const Vector3d & a_HitPos);
@ -56,3 +46,7 @@ private:
int m_DestroyTimer;
} ; // tolua_export

View File

@ -1,3 +1,4 @@
#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
#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)
{
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
@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) 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);
}
}
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
/** Teleports the creator where the ender pearl lands */
void TeleportCreator(const Vector3d & a_HitPos);
@ -56,3 +46,7 @@ private:
int m_DestroyTimer;
} ; // tolua_export

View File

@ -43,3 +43,28 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d &
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
@ -29,23 +34,8 @@ protected:
// cProjectileEntity overrides:
virtual void OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace) override;
virtual void OnHitEntity (cEntity & a_EntityHit, const Vector3d & a_HitPos) 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);
}
}
virtual void OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos) override;
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
private:
@ -53,3 +43,7 @@ private:
int m_DestroyTimer;
} ; // 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
#pragma once
#include "ProjectileEntity.h"
@ -30,6 +34,10 @@ protected:
// cProjectileEntity overrides:
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