/* * $HeadURL: $ * * $Author: $ * $Date: $ * $Revision: $ * * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. * * http://www.gnu.org/copyleft/gpl.html */package net.sf.l2j.gameserver.model.actor.knownlist;import java.util.LinkedList;import net.sf.l2j.gameserver.model.L2Character;import net.sf.l2j.gameserver.model.L2Object;import net.sf.l2j.gameserver.model.actor.instance.L2DoorInstance;import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;import net.sf.l2j.gameserver.util.Util;/** * This class ... * * @version $Revision: $ $Date: $ * @author la2 */public final class SightPipe{ private LinkedList<L2Object> _dequeue = new LinkedList<L2Object>(); private L2Character _owner; public SightPipe(L2Character actor) { _owner = actor; } public void Update() { forgetObjects(); } public void addObject(L2Object obj) { _dequeue.addLast(obj); } public boolean removeObject(L2Object obj) { synchronized(_dequeue) { int sp = _dequeue.indexOf(obj); if(sp >= 0) { _dequeue.remove(sp); return true; } } return false; } private void forgetObjects() { for (int i=0;i<_dequeue.size();i++) { if(_dequeue.size()<=0) break; L2Object obj = _dequeue.poll(); if(!obj.isVisible() || !Util.checkIfInRange(getDistanceToForgetObject(obj),_owner,obj,true)) continue; } } private int getDistanceToForgetObject(L2Object obj) { if(_owner instanceof L2PcInstance) return 6000; else if(_owner instanceof L2DoorInstance) return 4000; return 1000; }}