Added HOOK_PROJECTILE_HIT_BLOCK.
This commit is contained in:
parent
a6ef40cb6e
commit
ec4638a228
@ -90,6 +90,7 @@ public:
|
|||||||
virtual bool OnPluginsLoaded (void) = 0;
|
virtual bool OnPluginsLoaded (void) = 0;
|
||||||
virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
|
virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
|
||||||
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
|
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) = 0;
|
||||||
|
virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile) = 0;
|
||||||
virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) = 0;
|
virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) = 0;
|
||||||
virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) = 0;
|
virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) = 0;
|
||||||
virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) = 0;
|
virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) = 0;
|
||||||
|
@ -1108,6 +1108,26 @@ bool cPluginLua::OnPreCrafting(const cPlayer * a_Player, const cCraftingGrid * a
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cPluginLua::OnProjectileHitBlock(cProjectileEntity & a_Projectile)
|
||||||
|
{
|
||||||
|
cCSLock Lock(m_CriticalSection);
|
||||||
|
bool res = false;
|
||||||
|
cLuaRefs & Refs = m_HookMap[cPluginManager::HOOK_PROJECTILE_HIT_BLOCK];
|
||||||
|
for (cLuaRefs::iterator itr = Refs.begin(), end = Refs.end(); itr != end; ++itr)
|
||||||
|
{
|
||||||
|
m_LuaState.Call((int)(**itr), &a_Projectile, cLuaState::Return, res);
|
||||||
|
if (res)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cPluginLua::OnProjectileHitEntity(cProjectileEntity & a_Projectile, cEntity & a_HitEntity)
|
bool cPluginLua::OnProjectileHitEntity(cProjectileEntity & a_Projectile, cEntity & a_HitEntity)
|
||||||
{
|
{
|
||||||
cCSLock Lock(m_CriticalSection);
|
cCSLock Lock(m_CriticalSection);
|
||||||
|
@ -113,6 +113,7 @@ public:
|
|||||||
virtual bool OnPluginsLoaded (void) override;
|
virtual bool OnPluginsLoaded (void) override;
|
||||||
virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
|
virtual bool OnPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
|
||||||
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
|
virtual bool OnPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe) override;
|
||||||
|
virtual bool OnProjectileHitBlock (cProjectileEntity & a_Projectile) override;
|
||||||
virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) override;
|
virtual bool OnProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity) override;
|
||||||
virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) override;
|
virtual bool OnSpawnedEntity (cWorld & a_World, cEntity & a_Entity) override;
|
||||||
virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) override;
|
virtual bool OnSpawnedMonster (cWorld & a_World, cMonster & a_Monster) override;
|
||||||
|
@ -1154,6 +1154,27 @@ bool cPluginManager::CallHookPreCrafting(const cPlayer * a_Player, const cCrafti
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool cPluginManager::CallHookProjectileHitBlock(cProjectileEntity & a_Projectile)
|
||||||
|
{
|
||||||
|
HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_BLOCK);
|
||||||
|
if (Plugins == m_Hooks.end())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (PluginList::iterator itr = Plugins->second.begin(); itr != Plugins->second.end(); ++itr)
|
||||||
|
{
|
||||||
|
if ((*itr)->OnProjectileHitBlock(a_Projectile))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool cPluginManager::CallHookProjectileHitEntity(cProjectileEntity & a_Projectile, cEntity & a_HitEntity)
|
bool cPluginManager::CallHookProjectileHitEntity(cProjectileEntity & a_Projectile, cEntity & a_HitEntity)
|
||||||
{
|
{
|
||||||
HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_ENTITY);
|
HookMap::iterator Plugins = m_Hooks.find(HOOK_PROJECTILE_HIT_ENTITY);
|
||||||
|
@ -105,6 +105,7 @@ public: // tolua_export
|
|||||||
HOOK_PLUGINS_LOADED,
|
HOOK_PLUGINS_LOADED,
|
||||||
HOOK_POST_CRAFTING,
|
HOOK_POST_CRAFTING,
|
||||||
HOOK_PRE_CRAFTING,
|
HOOK_PRE_CRAFTING,
|
||||||
|
HOOK_PROJECTILE_HIT_BLOCK,
|
||||||
HOOK_PROJECTILE_HIT_ENTITY,
|
HOOK_PROJECTILE_HIT_ENTITY,
|
||||||
HOOK_SPAWNED_ENTITY,
|
HOOK_SPAWNED_ENTITY,
|
||||||
HOOK_SPAWNED_MONSTER,
|
HOOK_SPAWNED_MONSTER,
|
||||||
@ -205,6 +206,7 @@ public: // tolua_export
|
|||||||
bool CallHookPluginsLoaded (void);
|
bool CallHookPluginsLoaded (void);
|
||||||
bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
bool CallHookPostCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
||||||
bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
bool CallHookPreCrafting (const cPlayer * a_Player, const cCraftingGrid * a_Grid, cCraftingRecipe * a_Recipe);
|
||||||
|
bool CallHookProjectileHitBlock (cProjectileEntity & a_Projectile);
|
||||||
bool CallHookProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity);
|
bool CallHookProjectileHitEntity (cProjectileEntity & a_Projectile, cEntity & a_HitEntity);
|
||||||
bool CallHookSpawnedEntity (cWorld & a_World, cEntity & a_Entity);
|
bool CallHookSpawnedEntity (cWorld & a_World, cEntity & a_Entity);
|
||||||
bool CallHookSpawnedMonster (cWorld & a_World, cMonster & a_Monster);
|
bool CallHookSpawnedMonster (cWorld & a_World, cMonster & a_Monster);
|
||||||
|
@ -67,6 +67,11 @@ protected:
|
|||||||
eBlockFace Face;
|
eBlockFace Face;
|
||||||
if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face))
|
if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face))
|
||||||
{
|
{
|
||||||
|
if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff;
|
Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff;
|
||||||
m_Projectile->OnHitSolidBlock(Intersection, Face);
|
m_Projectile->OnHitSolidBlock(Intersection, Face);
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user