Distinguish getVisibleObjectsInRange from getVisibleObjects.

This commit is contained in:
MobiusDev
2018-09-07 17:02:53 +00:00
parent 49e03289d7
commit 1615c77aee
236 changed files with 337 additions and 337 deletions

View File

@ -358,7 +358,7 @@ public class L2AttackableAI extends L2CharacterAI
{
L2Character nearestTarget = null;
double closestDistance = Double.MAX_VALUE;
for (L2Character t : L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange()))
for (L2Character t : L2World.getInstance().getVisibleObjectsInRange(npc, L2Character.class, npc.getAggroRange()))
{
if ((t == _actor) || (t == null) || t.isDead())
{
@ -1118,7 +1118,7 @@ public class L2AttackableAI extends L2CharacterAI
}
else
{
stream = L2World.getInstance().getVisibleObjects(npc, L2Character.class, range, c -> checkSkillTarget(skill, c)).stream();
stream = L2World.getInstance().getVisibleObjectsInRange(npc, L2Character.class, range, c -> checkSkillTarget(skill, c)).stream();
// Maybe add self to the list of targets since getVisibleObjects doesn't return yourself.
if (checkSkillTarget(skill, npc))
@ -1149,7 +1149,7 @@ public class L2AttackableAI extends L2CharacterAI
// If npc is aggressive, add characters within aggro range too
if (npc.isAggressive())
{
stream = Stream.concat(stream, L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange(), this::checkTarget).stream());
stream = Stream.concat(stream, L2World.getInstance().getVisibleObjectsInRange(npc, L2Character.class, npc.getAggroRange(), this::checkTarget).stream());
}
return stream.findAny().orElse(null);
@ -1161,7 +1161,7 @@ public class L2AttackableAI extends L2CharacterAI
.sorted(Comparator.comparingInt(AggroInfo::getHate))
.map(AggroInfo::getAttacker)
.findFirst()
.orElse(npc.isAggressive() ? L2World.getInstance().getVisibleObjects(npc, L2Character.class, npc.getAggroRange(), this::checkTarget).stream().findAny().orElse(null) : null);
.orElse(npc.isAggressive() ? L2World.getInstance().getVisibleObjectsInRange(npc, L2Character.class, npc.getAggroRange(), this::checkTarget).stream().findAny().orElse(null) : null);
//@formatter:on
}

View File

@ -648,14 +648,14 @@ public final class L2World
}
}
public <T extends L2Object> List<T> getVisibleObjects(L2Object object, Class<T> clazz, int range)
public <T extends L2Object> List<T> getVisibleObjectsInRange(L2Object object, Class<T> clazz, int range)
{
final List<T> result = new ArrayList<>();
forEachVisibleObjectInRange(object, clazz, range, result::add);
return result;
}
public <T extends L2Object> List<T> getVisibleObjects(L2Object object, Class<T> clazz, int range, Predicate<T> predicate)
public <T extends L2Object> List<T> getVisibleObjectsInRange(L2Object object, Class<T> clazz, int range, Predicate<T> predicate)
{
final List<T> result = new ArrayList<>();
forEachVisibleObjectInRange(object, clazz, range, o ->

View File

@ -1173,7 +1173,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
final double headingAngle = Util.convertHeadingToDegree(getHeading());
final int maxRadius = _stat.getPhysicalAttackRadius();
final int physicalAttackAngle = _stat.getPhysicalAttackAngle();
for (L2Character obj : L2World.getInstance().getVisibleObjects(this, L2Character.class, maxRadius))
for (L2Character obj : L2World.getInstance().getVisibleObjectsInRange(this, L2Character.class, maxRadius))
{
// Skip main target.
if (obj == target)

View File

@ -173,7 +173,7 @@ public class L2DefenderInstance extends L2Attackable
{
L2Character target = this;
double lowestHpValue = Double.MAX_VALUE;
for (L2Character nearby : L2World.getInstance().getVisibleObjects(this, L2Character.class, skill.getCastRange()))
for (L2Character nearby : L2World.getInstance().getVisibleObjectsInRange(this, L2Character.class, skill.getCastRange()))
{
if ((nearby == null) || nearby.isDead() || !GeoEngine.getInstance().canSeeTarget(this, nearby))
{

View File

@ -4581,7 +4581,7 @@ public final class L2PcInstance extends L2Playable
{
if ((Config.SHOP_MIN_RANGE_FROM_NPC > 0) || (Config.SHOP_MIN_RANGE_FROM_PLAYER > 0))
{
for (L2Character cha : L2World.getInstance().getVisibleObjects(this, L2Character.class, 1000))
for (L2Character cha : L2World.getInstance().getVisibleObjectsInRange(this, L2Character.class, 1000))
{
if (Util.checkIfInRange(cha.getMinShopDistance(), this, cha, true))
{

View File

@ -49,7 +49,7 @@ public class ConditionPlayerRangeFromNpc extends Condition
boolean existNpc = false;
if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0))
{
for (L2Npc target : L2World.getInstance().getVisibleObjects(effector, L2Npc.class, _radius))
for (L2Npc target : L2World.getInstance().getVisibleObjectsInRange(effector, L2Npc.class, _radius))
{
if (CommonUtil.contains(_npcIds, target.getId()))
{

View File

@ -49,7 +49,7 @@ public class ConditionPlayerRangeFromSummonedNpc extends Condition
boolean existNpc = false;
if ((_npcIds != null) && (_npcIds.length > 0) && (_radius > 0))
{
for (L2Npc target : L2World.getInstance().getVisibleObjects(effector, L2Npc.class, _radius))
for (L2Npc target : L2World.getInstance().getVisibleObjectsInRange(effector, L2Npc.class, _radius))
{
if (CommonUtil.contains(_npcIds, target.getId()) && (effector == target.getSummoner()))
{

View File

@ -173,7 +173,7 @@ public class CubicInstance
Stream<L2Character> stream;
if (party != null)
{
stream = L2World.getInstance().getVisibleObjects(_owner, L2Character.class, Config.ALT_PARTY_RANGE, c -> (c.getParty() == party) && _template.validateConditions(this, _owner, c) && cubicSkill.validateConditions(this, _owner, c)).stream();
stream = L2World.getInstance().getVisibleObjectsInRange(_owner, L2Character.class, Config.ALT_PARTY_RANGE, c -> (c.getParty() == party) && _template.validateConditions(this, _owner, c) && cubicSkill.validateConditions(this, _owner, c)).stream();
}
else
{

View File

@ -77,7 +77,7 @@ public final class RequestDuelStart implements IClientIncomingPacket
return;
}
boolean npcInRange = false;
for (L2Npc npc : L2World.getInstance().getVisibleObjects(activeChar, L2Npc.class, 250))
for (L2Npc npc : L2World.getInstance().getVisibleObjectsInRange(activeChar, L2Npc.class, 250))
{
if (npc.getName().equals(name))
{

View File

@ -112,7 +112,7 @@ public final class TradeRequest implements IClientIncomingPacket
{
final String name = FakePlayerData.getInstance().getProperName(target.getName());
boolean npcInRange = false;
for (L2Npc npc : L2World.getInstance().getVisibleObjects(player, L2Npc.class, 150))
for (L2Npc npc : L2World.getInstance().getVisibleObjectsInRange(player, L2Npc.class, 150))
{
if (npc.getName().equals(name))
{