public int AddDamage(int tileId, int damageAmount, bool updateAmount = true)
{
if (tileId < 0 || tileId > 20 || tileId == this.bufferLocation && damageAmount == 0)
return 0;
HitTile.HitTileObject hitTileObject = this.data[tileId];
if (!updateAmount)
return hitTileObject.damage + damageAmount;
hitTileObject.damage += damageAmount;
hitTileObject.timeToLive = 60;
if (tileId == this.bufferLocation)
{
this.bufferLocation = this.order[20];
this.data[this.bufferLocation].Clear();
for (int index = 20; index > 0; --index)
this.order[index] = this.order[index - 1];
this.order[0] = this.bufferLocation;
}
else
{
int index = 0;
while (index <= 20 && this.order[index] != tileId)
++index;
for (; index > 1; --index)
{
int num = this.order[index - 1];
this.order[index - 1] = this.order[index];
this.order[index] = num;
}
this.order[1] = tileId;
}
return hitTileObject.damage;
}