Addition of Instance getAliveNpcCount methods.

This commit is contained in:
MobiusDevelopment
2021-12-25 23:04:14 +00:00
parent 9e7f8fbba7
commit 33b35efb3c
196 changed files with 2052 additions and 1317 deletions

View File

@@ -578,23 +578,6 @@ public class Instance implements IIdentifiable, INamable
return _npcs;
}
/**
* Get alive NPCs from instance.
* @return set of NPCs from instance
*/
public List<Npc> getAliveNpcs()
{
final List<Npc> result = new ArrayList<>();
for (Npc npc : _npcs)
{
if (npc.getCurrentHp() > 0)
{
result.add(npc);
}
}
return result;
}
/**
* Get spawned NPCs from instance with specific IDs.
* @param id IDs of NPCs which should be found
@@ -635,6 +618,41 @@ public class Instance implements IIdentifiable, INamable
return result;
}
/**
* Get alive NPCs from instance.
* @return set of NPCs from instance
*/
public List<Npc> getAliveNpcs()
{
final List<Npc> result = new ArrayList<>();
for (Npc npc : _npcs)
{
if (npc.getCurrentHp() > 0)
{
result.add(npc);
}
}
return result;
}
/**
* Get alive NPCs from instance with specific IDs.
* @param id IDs of NPCs which should be found
* @return list of filtered NPCs from instance
*/
public List<Npc> getAliveNpcs(int... id)
{
final List<Npc> result = new ArrayList<>();
for (Npc npc : _npcs)
{
if ((npc.getCurrentHp() > 0) && CommonUtil.contains(id, npc.getId()))
{
result.add(npc);
}
}
return result;
}
/**
* Get spawned and alive NPCs from instance with specific IDs and class type.
* @param <T>
@@ -658,21 +676,38 @@ public class Instance implements IIdentifiable, INamable
}
/**
* Get alive NPCs from instance with specific IDs.
* @param id IDs of NPCs which should be found
* @return list of filtered NPCs from instance
* Get alive NPC count from instance.
* @return count of filtered NPCs from instance
*/
public List<Npc> getAliveNpcs(int... id)
public int getAliveNpcCount()
{
final List<Npc> result = new ArrayList<>();
int count = 0;
for (Npc npc : _npcs)
{
if (npc.getCurrentHp() > 0)
{
count++;
}
}
return count;
}
/**
* Get alive NPC count from instance with specific IDs.
* @param id IDs of NPCs which should be counted
* @return count of filtered NPCs from instance
*/
public int getAliveNpcCount(int... id)
{
int count = 0;
for (Npc npc : _npcs)
{
if ((npc.getCurrentHp() > 0) && CommonUtil.contains(id, npc.getId()))
{
result.add(npc);
count++;
}
}
return result;
return count;
}
/**