Beacon now checks for players in surrounding square (#4972)
* Beacon now check for players in surrounding square not every player * added proper BoundingBox Co-authored-by: Alexander Harkness <me@bearbin.net> * one symbol to change everything one symbol to break the whole build Co-authored-by: 12xx12 <12xx12100@gmail.com> Co-authored-by: Alexander Harkness <me@bearbin.net>
This commit is contained in:
parent
6ddc03db09
commit
d3255b3014
@ -225,7 +225,7 @@ void cBeaconEntity::GiveEffects(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Radius = m_BeaconLevel * 10 + 10;
|
double Radius = static_cast<double>(m_BeaconLevel) * 10 + 10;
|
||||||
short EffectLevel = 0;
|
short EffectLevel = 0;
|
||||||
if ((m_BeaconLevel >= 4) && (m_PrimaryEffect == m_SecondaryEffect))
|
if ((m_BeaconLevel >= 4) && (m_PrimaryEffect == m_SecondaryEffect))
|
||||||
{
|
{
|
||||||
@ -234,28 +234,22 @@ void cBeaconEntity::GiveEffects(void)
|
|||||||
|
|
||||||
bool HasSecondaryEffect = (m_BeaconLevel >= 4) && (m_PrimaryEffect != m_SecondaryEffect) && (m_SecondaryEffect > 0);
|
bool HasSecondaryEffect = (m_BeaconLevel >= 4) && (m_PrimaryEffect != m_SecondaryEffect) && (m_SecondaryEffect > 0);
|
||||||
|
|
||||||
Vector3d BeaconPosition(m_Pos);
|
auto Area = cBoundingBox(m_Pos, Radius, Radius + static_cast<double>(cChunkDef::Height), -Radius);
|
||||||
GetWorld()->ForEachPlayer([=](cPlayer & a_Player)
|
GetWorld()->ForEachEntityInBox(Area, [&](cEntity & a_Entity)
|
||||||
|
{
|
||||||
|
if (!a_Entity.IsPlayer())
|
||||||
{
|
{
|
||||||
auto PlayerPosition = a_Player.GetPosition();
|
|
||||||
if (PlayerPosition.y > BeaconPosition.y)
|
|
||||||
{
|
|
||||||
PlayerPosition.y = BeaconPosition.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Vanilla minecraft uses an AABB check instead of a radius one
|
|
||||||
if ((PlayerPosition - BeaconPosition).Length() <= Radius)
|
|
||||||
{
|
|
||||||
a_Player.AddEntityEffect(m_PrimaryEffect, 180, EffectLevel);
|
|
||||||
|
|
||||||
if (HasSecondaryEffect)
|
|
||||||
{
|
|
||||||
a_Player.AddEntityEffect(m_SecondaryEffect, 180, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
);
|
auto & Player = static_cast<cPlayer &>(a_Entity);
|
||||||
|
Player.AddEntityEffect(m_PrimaryEffect, 180, EffectLevel);
|
||||||
|
|
||||||
|
if (HasSecondaryEffect)
|
||||||
|
{
|
||||||
|
Player.AddEntityEffect(m_SecondaryEffect, 180, 0);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -325,4 +319,3 @@ bool cBeaconEntity::UsedBy(cPlayer * a_Player)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user