summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemThrowable.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Items/ItemThrowable.h')
-rw-r--r--src/Items/ItemThrowable.h87
1 files changed, 45 insertions, 42 deletions
diff --git a/src/Items/ItemThrowable.h b/src/Items/ItemThrowable.h
index 65f44c72a..06a5478ae 100644
--- a/src/Items/ItemThrowable.h
+++ b/src/Items/ItemThrowable.h
@@ -10,17 +10,13 @@
-class cItemThrowableHandler:
- public cItemHandler
+class cItemThrowableHandler : public cItemHandler
{
using Super = cItemHandler;
-public:
-
- constexpr cItemThrowableHandler(int a_ItemType, cProjectileEntity::eKind a_ProjectileKind, double a_SpeedCoeff):
- Super(a_ItemType),
- m_ProjectileKind(a_ProjectileKind),
- m_SpeedCoeff(a_SpeedCoeff)
+ public:
+ constexpr cItemThrowableHandler(int a_ItemType, cProjectileEntity::eKind a_ProjectileKind, double a_SpeedCoeff) :
+ Super(a_ItemType), m_ProjectileKind(a_ProjectileKind), m_SpeedCoeff(a_SpeedCoeff)
{
}
@@ -41,13 +37,26 @@ public:
auto Speed = a_Player->GetLookVector() * m_SpeedCoeff;
// Create the projectile:
- if (a_World->CreateProjectile(Pos.x, Pos.y, Pos.z, m_ProjectileKind, a_Player, &a_Player->GetEquippedItem(), &Speed) == cEntity::INVALID_ID)
+ if (a_World->CreateProjectile(
+ Pos.x,
+ Pos.y,
+ Pos.z,
+ m_ProjectileKind,
+ a_Player,
+ &a_Player->GetEquippedItem(),
+ &Speed
+ ) == cEntity::INVALID_ID)
{
return false;
}
// Play sound:
- a_World->BroadcastSoundEffect("entity.arrow.shoot", a_Player->GetPosition() - Vector3d(0, a_Player->GetHeight(), 0), 0.5f, 0.4f / GetRandomProvider().RandReal(0.8f, 1.2f));
+ a_World->BroadcastSoundEffect(
+ "entity.arrow.shoot",
+ a_Player->GetPosition() - Vector3d(0, a_Player->GetHeight(), 0),
+ 0.5f,
+ 0.4f / GetRandomProvider().RandReal(0.8f, 1.2f)
+ );
// Remove from inventory
if (!a_Player->IsGameModeCreative())
@@ -58,8 +67,7 @@ public:
return true;
}
-protected:
-
+ protected:
/** The kind of projectile to create when shooting */
cProjectileEntity::eKind m_ProjectileKind;
@@ -67,70 +75,62 @@ protected:
double m_SpeedCoeff;
~cItemThrowableHandler() = default;
-} ;
+};
-class cItemEggHandler final:
- public cItemThrowableHandler
+class cItemEggHandler final : public cItemThrowableHandler
{
using Super = cItemThrowableHandler;
-public:
-
- constexpr cItemEggHandler(int a_ItemType):
+ public:
+ constexpr cItemEggHandler(int a_ItemType) :
Super(a_ItemType, cProjectileEntity::pkEgg, 30)
{
}
-} ;
+};
-class cItemSnowballHandler final:
- public cItemThrowableHandler
+class cItemSnowballHandler final : public cItemThrowableHandler
{
using Super = cItemThrowableHandler;
-public:
-
- constexpr cItemSnowballHandler(int a_ItemType):
+ public:
+ constexpr cItemSnowballHandler(int a_ItemType) :
Super(a_ItemType, cProjectileEntity::pkSnowball, 30)
{
}
-} ;
+};
-class cItemEnderPearlHandler final:
- public cItemThrowableHandler
+class cItemEnderPearlHandler final : public cItemThrowableHandler
{
using Super = cItemThrowableHandler;
-public:
-
- constexpr cItemEnderPearlHandler(int a_ItemType):
+ public:
+ constexpr cItemEnderPearlHandler(int a_ItemType) :
Super(a_ItemType, cProjectileEntity::pkEnderPearl, 30)
{
}
-} ;
+};
-class cItemBottleOEnchantingHandler final :
- public cItemThrowableHandler
+class cItemBottleOEnchantingHandler final : public cItemThrowableHandler
{
using Super = cItemThrowableHandler;
-public:
-
- constexpr cItemBottleOEnchantingHandler(int a_ItemType):
+ public:
+ constexpr cItemBottleOEnchantingHandler(int a_ItemType) :
Super(a_ItemType, cProjectileEntity::pkExpBottle, 14)
{
}
@@ -140,14 +140,12 @@ public:
-class cItemFireworkHandler final:
- public cItemThrowableHandler
+class cItemFireworkHandler final : public cItemThrowableHandler
{
using Super = cItemThrowableHandler;
-public:
-
- constexpr cItemFireworkHandler(int a_ItemType):
+ public:
+ constexpr cItemFireworkHandler(int a_ItemType) :
Super(a_ItemType, cProjectileEntity::pkFirework, 0)
{
}
@@ -170,7 +168,12 @@ public:
return false;
}
- if (a_World->CreateProjectile(Vector3d(a_ClickedBlockPos) + Vector3d(0.5, 1, 0.5), m_ProjectileKind, a_Player, &a_Player->GetEquippedItem()) == 0)
+ if (a_World->CreateProjectile(
+ Vector3d(a_ClickedBlockPos) + Vector3d(0.5, 1, 0.5),
+ m_ProjectileKind,
+ a_Player,
+ &a_Player->GetEquippedItem()
+ ) == 0)
{
return false;
}