package l2p.gameserver.model.instances;
import java.util.ArrayList;
import java.util.List;
import l2p.gameserver.ai.CtrlIntention;
import l2p.gameserver.config.NpcConfig;
import l2p.gameserver.config.OtherConfig;
import l2p.gameserver.enums.StatisticTopType;
import l2p.gameserver.holders.statistic.StatisticData;
import l2p.gameserver.holders.statistic.StatueTemplate;
import l2p.gameserver.managers.StatisticManager;
import l2p.gameserver.model.Creature;
import l2p.gameserver.model.GameObject;
import l2p.gameserver.model.Location;
import l2p.gameserver.model.Player;
import l2p.gameserver.model.skills.Skill;
import l2p.gameserver.network.s2c.ActionFail;
import l2p.gameserver.network.s2c.ExLoadStatHotLink;
import l2p.gameserver.network.s2c.L2GameServerPacket;
import l2p.gameserver.network.s2c.ServerObjectInfo;
public final class StatueInstance extends GameObject
{
private StatueTemplate _template;
private int _heading;
public StatueInstance(int objectId, StatueTemplate template)
{
super(objectId);
_template = template;
}
public StatueTemplate getTemplate()
{
return _template;
}
@Override
public boolean isAttackable(Creature creature, Skill skill)
{
return false;
}
@Override
public double getColRadius()
{
return 30.;
}
@Override
public double getColHeight()
{
return 40.;
}
@Override
public void setLoc(Location loc)
{
super.setLoc(loc);
_heading = loc.getH();
}
@Override
public int getHeading()
{
return _heading;
}
@Override
public List<L2GameServerPacket> addPacketList(Player forPlayer, Creature dropper)
{
List<L2GameServerPacket> list = new ArrayList<>(1);
list.add(new ServerObjectInfo(this, forPlayer));
return list;
}
@Override
public void onAction(Player player, boolean shift)
{
if (!isInRange(player, NpcConfig.MAX_INTERACTION_RANGE))
{
if (player.getAI().getIntention() != CtrlIntention.AI_INTENTION_INTERACT)
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this, null);
return;
}
player.stopMove(false);
List<StatisticData> global = StatisticManager.getTop(_template.getType(), StatisticTopType.STATUE_GLOBAL, OtherConfig.STATISTIC_STATUE_TOP_LIMIT);
List<StatisticData> monthly = StatisticManager.getTop(_template.getType(), StatisticTopType.STATUE_MONTHLY, OtherConfig.STATISTIC_STATUE_TOP_LIMIT);
player.sendPacket(new ExLoadStatHotLink(_template.getType().getId(), _template.getType().getSubId(), global, monthly), ActionFail.STATIC);
}
}