new method & function

getAllEntity() returns array of the all entities!

var entityArr=new Array();
var senseRange=10; //max distance
function entityAddedHook(e)
{
entityArr.push(e);
}
function entityRemovedHook(e)
{
var entityArrLength = entityArr.length;
for(var c=0;c<entityArrLength;c++)
{
if(e==entityArr[c])
{
entityArr.splice(c,1);
}
}
}
function modTick()
{
for(var c in entity)
{
if(Math.sqrt((Entity.getX(entityArr[c])-Player.getX())*(Entity.getX(entityArr[c])-Player.getX())+(Entity.getZ(entityArr[c])-Player.getZ())*(Entity.getZ(entityArr[c])-Player.getZ())+(Entity.getY(entityArr[c])-Player.getY())*(Entity.getY(entityArr[c])-Player.getY()))<=senseRange) //calculating distance
{
entitySensedHook(entityArr[c]);
}
}
}
function getAllEntity()
{
return entityArr;
}
function entitySensedHook(e)
{
//write down events!
}