Matching random animation task manager name.
This commit is contained in:
@@ -25,7 +25,7 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationManager;
|
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||||
|
|
||||||
public final class WorldRegion
|
public final class WorldRegion
|
||||||
{
|
{
|
||||||
@@ -105,11 +105,11 @@ public final class WorldRegion
|
|||||||
mob.getAI().stopAITask();
|
mob.getAI().stopAITask();
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAnimationManager.getInstance().remove(mob);
|
RandomAnimationTaskManager.getInstance().remove(mob);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().remove((Npc) o);
|
RandomAnimationTaskManager.getInstance().remove((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ public final class WorldRegion
|
|||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) o).getStatus().startHpMpRegeneration();
|
((Attackable) o).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,11 +29,11 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
|||||||
/**
|
/**
|
||||||
* @author Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class RandomAnimationManager
|
public class RandomAnimationTaskManager
|
||||||
{
|
{
|
||||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public RandomAnimationManager()
|
public RandomAnimationTaskManager()
|
||||||
{
|
{
|
||||||
ThreadPool.scheduleAtFixedRate(() ->
|
ThreadPool.scheduleAtFixedRate(() ->
|
||||||
{
|
{
|
||||||
@@ -78,13 +78,13 @@ public class RandomAnimationManager
|
|||||||
PENDING_ANIMATIONS.remove(npc);
|
PENDING_ANIMATIONS.remove(npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RandomAnimationManager getInstance()
|
public static RandomAnimationTaskManager getInstance()
|
||||||
{
|
{
|
||||||
return SingletonHolder.INSTANCE;
|
return SingletonHolder.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SingletonHolder
|
private static class SingletonHolder
|
||||||
{
|
{
|
||||||
protected static final RandomAnimationManager INSTANCE = new RandomAnimationManager();
|
protected static final RandomAnimationTaskManager INSTANCE = new RandomAnimationTaskManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -25,7 +25,7 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationManager;
|
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||||
|
|
||||||
public final class WorldRegion
|
public final class WorldRegion
|
||||||
{
|
{
|
||||||
@@ -105,11 +105,11 @@ public final class WorldRegion
|
|||||||
mob.getAI().stopAITask();
|
mob.getAI().stopAITask();
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAnimationManager.getInstance().remove(mob);
|
RandomAnimationTaskManager.getInstance().remove(mob);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().remove((Npc) o);
|
RandomAnimationTaskManager.getInstance().remove((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ public final class WorldRegion
|
|||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) o).getStatus().startHpMpRegeneration();
|
((Attackable) o).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,11 +29,11 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
|||||||
/**
|
/**
|
||||||
* @author Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class RandomAnimationManager
|
public class RandomAnimationTaskManager
|
||||||
{
|
{
|
||||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public RandomAnimationManager()
|
public RandomAnimationTaskManager()
|
||||||
{
|
{
|
||||||
ThreadPool.scheduleAtFixedRate(() ->
|
ThreadPool.scheduleAtFixedRate(() ->
|
||||||
{
|
{
|
||||||
@@ -78,13 +78,13 @@ public class RandomAnimationManager
|
|||||||
PENDING_ANIMATIONS.remove(npc);
|
PENDING_ANIMATIONS.remove(npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RandomAnimationManager getInstance()
|
public static RandomAnimationTaskManager getInstance()
|
||||||
{
|
{
|
||||||
return SingletonHolder.INSTANCE;
|
return SingletonHolder.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SingletonHolder
|
private static class SingletonHolder
|
||||||
{
|
{
|
||||||
protected static final RandomAnimationManager INSTANCE = new RandomAnimationManager();
|
protected static final RandomAnimationTaskManager INSTANCE = new RandomAnimationTaskManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -25,7 +25,7 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationManager;
|
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||||
|
|
||||||
public final class WorldRegion
|
public final class WorldRegion
|
||||||
{
|
{
|
||||||
@@ -105,11 +105,11 @@ public final class WorldRegion
|
|||||||
mob.getAI().stopAITask();
|
mob.getAI().stopAITask();
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAnimationManager.getInstance().remove(mob);
|
RandomAnimationTaskManager.getInstance().remove(mob);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().remove((Npc) o);
|
RandomAnimationTaskManager.getInstance().remove((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ public final class WorldRegion
|
|||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) o).getStatus().startHpMpRegeneration();
|
((Attackable) o).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,11 +29,11 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
|||||||
/**
|
/**
|
||||||
* @author Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class RandomAnimationManager
|
public class RandomAnimationTaskManager
|
||||||
{
|
{
|
||||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public RandomAnimationManager()
|
public RandomAnimationTaskManager()
|
||||||
{
|
{
|
||||||
ThreadPool.scheduleAtFixedRate(() ->
|
ThreadPool.scheduleAtFixedRate(() ->
|
||||||
{
|
{
|
||||||
@@ -78,13 +78,13 @@ public class RandomAnimationManager
|
|||||||
PENDING_ANIMATIONS.remove(npc);
|
PENDING_ANIMATIONS.remove(npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RandomAnimationManager getInstance()
|
public static RandomAnimationTaskManager getInstance()
|
||||||
{
|
{
|
||||||
return SingletonHolder.INSTANCE;
|
return SingletonHolder.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SingletonHolder
|
private static class SingletonHolder
|
||||||
{
|
{
|
||||||
protected static final RandomAnimationManager INSTANCE = new RandomAnimationManager();
|
protected static final RandomAnimationTaskManager INSTANCE = new RandomAnimationTaskManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -25,7 +25,7 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationManager;
|
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||||
|
|
||||||
public final class WorldRegion
|
public final class WorldRegion
|
||||||
{
|
{
|
||||||
@@ -105,11 +105,11 @@ public final class WorldRegion
|
|||||||
mob.getAI().stopAITask();
|
mob.getAI().stopAITask();
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAnimationManager.getInstance().remove(mob);
|
RandomAnimationTaskManager.getInstance().remove(mob);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().remove((Npc) o);
|
RandomAnimationTaskManager.getInstance().remove((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ public final class WorldRegion
|
|||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) o).getStatus().startHpMpRegeneration();
|
((Attackable) o).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,11 +29,11 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
|||||||
/**
|
/**
|
||||||
* @author Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class RandomAnimationManager
|
public class RandomAnimationTaskManager
|
||||||
{
|
{
|
||||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public RandomAnimationManager()
|
public RandomAnimationTaskManager()
|
||||||
{
|
{
|
||||||
ThreadPool.scheduleAtFixedRate(() ->
|
ThreadPool.scheduleAtFixedRate(() ->
|
||||||
{
|
{
|
||||||
@@ -78,13 +78,13 @@ public class RandomAnimationManager
|
|||||||
PENDING_ANIMATIONS.remove(npc);
|
PENDING_ANIMATIONS.remove(npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RandomAnimationManager getInstance()
|
public static RandomAnimationTaskManager getInstance()
|
||||||
{
|
{
|
||||||
return SingletonHolder.INSTANCE;
|
return SingletonHolder.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SingletonHolder
|
private static class SingletonHolder
|
||||||
{
|
{
|
||||||
protected static final RandomAnimationManager INSTANCE = new RandomAnimationManager();
|
protected static final RandomAnimationTaskManager INSTANCE = new RandomAnimationTaskManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -25,7 +25,7 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationManager;
|
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||||
|
|
||||||
public final class WorldRegion
|
public final class WorldRegion
|
||||||
{
|
{
|
||||||
@@ -105,11 +105,11 @@ public final class WorldRegion
|
|||||||
mob.getAI().stopAITask();
|
mob.getAI().stopAITask();
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAnimationManager.getInstance().remove(mob);
|
RandomAnimationTaskManager.getInstance().remove(mob);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().remove((Npc) o);
|
RandomAnimationTaskManager.getInstance().remove((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ public final class WorldRegion
|
|||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) o).getStatus().startHpMpRegeneration();
|
((Attackable) o).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.l2jmobius.gameserver.taskmanager;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
|
||||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class RandomAnimationManager
|
|
||||||
{
|
|
||||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
public RandomAnimationManager()
|
|
||||||
{
|
|
||||||
ThreadPool.scheduleAtFixedRate(() ->
|
|
||||||
{
|
|
||||||
final long time = System.currentTimeMillis();
|
|
||||||
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
|
||||||
{
|
|
||||||
if (time > entry.getValue())
|
|
||||||
{
|
|
||||||
final Npc npc = entry.getKey();
|
|
||||||
if (!npc.isInActiveRegion())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
|
||||||
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!npc.isDead() && !npc.hasBlockActions())
|
|
||||||
{
|
|
||||||
npc.onRandomAnimation(Rnd.get(2, 3));
|
|
||||||
}
|
|
||||||
|
|
||||||
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 0, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(Npc npc)
|
|
||||||
{
|
|
||||||
if (npc.hasRandomAnimation())
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(Npc npc)
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.remove(npc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RandomAnimationManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final RandomAnimationManager INSTANCE = new RandomAnimationManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.l2jmobius.gameserver.taskmanager;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
|
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class RandomAnimationTaskManager
|
||||||
|
{
|
||||||
|
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public RandomAnimationTaskManager()
|
||||||
|
{
|
||||||
|
ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
final long time = System.currentTimeMillis();
|
||||||
|
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
||||||
|
{
|
||||||
|
if (time > entry.getValue())
|
||||||
|
{
|
||||||
|
final Npc npc = entry.getKey();
|
||||||
|
if (!npc.isInActiveRegion())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
||||||
|
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!npc.isDead() && !npc.hasBlockActions())
|
||||||
|
{
|
||||||
|
npc.onRandomAnimation(Rnd.get(2, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Npc npc)
|
||||||
|
{
|
||||||
|
if (npc.hasRandomAnimation())
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(Npc npc)
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.remove(npc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RandomAnimationTaskManager getInstance()
|
||||||
|
{
|
||||||
|
return SingletonHolder.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SingletonHolder
|
||||||
|
{
|
||||||
|
protected static final RandomAnimationTaskManager INSTANCE = new RandomAnimationTaskManager();
|
||||||
|
}
|
||||||
|
}
|
@@ -25,7 +25,7 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationManager;
|
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||||
|
|
||||||
public final class WorldRegion
|
public final class WorldRegion
|
||||||
{
|
{
|
||||||
@@ -105,11 +105,11 @@ public final class WorldRegion
|
|||||||
mob.getAI().stopAITask();
|
mob.getAI().stopAITask();
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAnimationManager.getInstance().remove(mob);
|
RandomAnimationTaskManager.getInstance().remove(mob);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().remove((Npc) o);
|
RandomAnimationTaskManager.getInstance().remove((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ public final class WorldRegion
|
|||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) o).getStatus().startHpMpRegeneration();
|
((Attackable) o).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.l2jmobius.gameserver.taskmanager;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
|
||||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class RandomAnimationManager
|
|
||||||
{
|
|
||||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
public RandomAnimationManager()
|
|
||||||
{
|
|
||||||
ThreadPool.scheduleAtFixedRate(() ->
|
|
||||||
{
|
|
||||||
final long time = System.currentTimeMillis();
|
|
||||||
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
|
||||||
{
|
|
||||||
if (time > entry.getValue())
|
|
||||||
{
|
|
||||||
final Npc npc = entry.getKey();
|
|
||||||
if (!npc.isInActiveRegion())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
|
||||||
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!npc.isDead() && !npc.hasBlockActions())
|
|
||||||
{
|
|
||||||
npc.onRandomAnimation(Rnd.get(2, 3));
|
|
||||||
}
|
|
||||||
|
|
||||||
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 0, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(Npc npc)
|
|
||||||
{
|
|
||||||
if (npc.hasRandomAnimation())
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(Npc npc)
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.remove(npc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RandomAnimationManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final RandomAnimationManager INSTANCE = new RandomAnimationManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.l2jmobius.gameserver.taskmanager;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
|
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class RandomAnimationTaskManager
|
||||||
|
{
|
||||||
|
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public RandomAnimationTaskManager()
|
||||||
|
{
|
||||||
|
ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
final long time = System.currentTimeMillis();
|
||||||
|
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
||||||
|
{
|
||||||
|
if (time > entry.getValue())
|
||||||
|
{
|
||||||
|
final Npc npc = entry.getKey();
|
||||||
|
if (!npc.isInActiveRegion())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
||||||
|
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!npc.isDead() && !npc.hasBlockActions())
|
||||||
|
{
|
||||||
|
npc.onRandomAnimation(Rnd.get(2, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Npc npc)
|
||||||
|
{
|
||||||
|
if (npc.hasRandomAnimation())
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(Npc npc)
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.remove(npc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RandomAnimationTaskManager getInstance()
|
||||||
|
{
|
||||||
|
return SingletonHolder.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SingletonHolder
|
||||||
|
{
|
||||||
|
protected static final RandomAnimationTaskManager INSTANCE = new RandomAnimationTaskManager();
|
||||||
|
}
|
||||||
|
}
|
@@ -25,7 +25,7 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationManager;
|
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||||
|
|
||||||
public final class WorldRegion
|
public final class WorldRegion
|
||||||
{
|
{
|
||||||
@@ -105,11 +105,11 @@ public final class WorldRegion
|
|||||||
mob.getAI().stopAITask();
|
mob.getAI().stopAITask();
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAnimationManager.getInstance().remove(mob);
|
RandomAnimationTaskManager.getInstance().remove(mob);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().remove((Npc) o);
|
RandomAnimationTaskManager.getInstance().remove((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ public final class WorldRegion
|
|||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) o).getStatus().startHpMpRegeneration();
|
((Attackable) o).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.l2jmobius.gameserver.taskmanager;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
|
||||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class RandomAnimationManager
|
|
||||||
{
|
|
||||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
public RandomAnimationManager()
|
|
||||||
{
|
|
||||||
ThreadPool.scheduleAtFixedRate(() ->
|
|
||||||
{
|
|
||||||
final long time = System.currentTimeMillis();
|
|
||||||
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
|
||||||
{
|
|
||||||
if (time > entry.getValue())
|
|
||||||
{
|
|
||||||
final Npc npc = entry.getKey();
|
|
||||||
if (!npc.isInActiveRegion())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
|
||||||
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!npc.isDead() && !npc.hasBlockActions())
|
|
||||||
{
|
|
||||||
npc.onRandomAnimation(Rnd.get(2, 3));
|
|
||||||
}
|
|
||||||
|
|
||||||
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 0, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(Npc npc)
|
|
||||||
{
|
|
||||||
if (npc.hasRandomAnimation())
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(Npc npc)
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.remove(npc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RandomAnimationManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final RandomAnimationManager INSTANCE = new RandomAnimationManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.l2jmobius.gameserver.taskmanager;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
|
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class RandomAnimationTaskManager
|
||||||
|
{
|
||||||
|
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public RandomAnimationTaskManager()
|
||||||
|
{
|
||||||
|
ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
final long time = System.currentTimeMillis();
|
||||||
|
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
||||||
|
{
|
||||||
|
if (time > entry.getValue())
|
||||||
|
{
|
||||||
|
final Npc npc = entry.getKey();
|
||||||
|
if (!npc.isInActiveRegion())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
||||||
|
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!npc.isDead() && !npc.hasBlockActions())
|
||||||
|
{
|
||||||
|
npc.onRandomAnimation(Rnd.get(2, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Npc npc)
|
||||||
|
{
|
||||||
|
if (npc.hasRandomAnimation())
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(Npc npc)
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.remove(npc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RandomAnimationTaskManager getInstance()
|
||||||
|
{
|
||||||
|
return SingletonHolder.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SingletonHolder
|
||||||
|
{
|
||||||
|
protected static final RandomAnimationTaskManager INSTANCE = new RandomAnimationTaskManager();
|
||||||
|
}
|
||||||
|
}
|
@@ -37,7 +37,7 @@ import org.l2jmobius.gameserver.model.spawn.Spawn;
|
|||||||
import org.l2jmobius.gameserver.model.zone.ZoneManager;
|
import org.l2jmobius.gameserver.model.zone.ZoneManager;
|
||||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||||
import org.l2jmobius.gameserver.model.zone.type.PeaceZone;
|
import org.l2jmobius.gameserver.model.zone.type.PeaceZone;
|
||||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationManager;
|
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||||
|
|
||||||
public final class WorldRegion
|
public final class WorldRegion
|
||||||
{
|
{
|
||||||
@@ -224,11 +224,11 @@ public final class WorldRegion
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAnimationManager.getInstance().remove(mob);
|
RandomAnimationTaskManager.getInstance().remove(mob);
|
||||||
}
|
}
|
||||||
else if (o instanceof NpcInstance)
|
else if (o instanceof NpcInstance)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().remove((NpcInstance) o);
|
RandomAnimationTaskManager.getInstance().remove((NpcInstance) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,11 +240,11 @@ public final class WorldRegion
|
|||||||
{
|
{
|
||||||
// Start HP/MP/CP Regeneration task
|
// Start HP/MP/CP Regeneration task
|
||||||
((Attackable) o).getStatus().startHpMpRegeneration();
|
((Attackable) o).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationManager.getInstance().add((NpcInstance) o);
|
RandomAnimationTaskManager.getInstance().add((NpcInstance) o);
|
||||||
}
|
}
|
||||||
else if (o instanceof NpcInstance)
|
else if (o instanceof NpcInstance)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().add((NpcInstance) o);
|
RandomAnimationTaskManager.getInstance().add((NpcInstance) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,11 +30,11 @@ import org.l2jmobius.gameserver.model.actor.instance.NpcInstance;
|
|||||||
/**
|
/**
|
||||||
* @author Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class RandomAnimationManager
|
public class RandomAnimationTaskManager
|
||||||
{
|
{
|
||||||
private static final Map<NpcInstance, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
private static final Map<NpcInstance, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public RandomAnimationManager()
|
public RandomAnimationTaskManager()
|
||||||
{
|
{
|
||||||
ThreadPool.scheduleAtFixedRate(() ->
|
ThreadPool.scheduleAtFixedRate(() ->
|
||||||
{
|
{
|
||||||
@@ -79,13 +79,13 @@ public class RandomAnimationManager
|
|||||||
PENDING_ANIMATIONS.remove(npc);
|
PENDING_ANIMATIONS.remove(npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RandomAnimationManager getInstance()
|
public static RandomAnimationTaskManager getInstance()
|
||||||
{
|
{
|
||||||
return SingletonHolder.INSTANCE;
|
return SingletonHolder.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SingletonHolder
|
private static class SingletonHolder
|
||||||
{
|
{
|
||||||
protected static final RandomAnimationManager INSTANCE = new RandomAnimationManager();
|
protected static final RandomAnimationTaskManager INSTANCE = new RandomAnimationTaskManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -25,7 +25,7 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationManager;
|
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||||
|
|
||||||
public final class WorldRegion
|
public final class WorldRegion
|
||||||
{
|
{
|
||||||
@@ -105,11 +105,11 @@ public final class WorldRegion
|
|||||||
mob.getAI().stopAITask();
|
mob.getAI().stopAITask();
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAnimationManager.getInstance().remove(mob);
|
RandomAnimationTaskManager.getInstance().remove(mob);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().remove((Npc) o);
|
RandomAnimationTaskManager.getInstance().remove((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ public final class WorldRegion
|
|||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) o).getStatus().startHpMpRegeneration();
|
((Attackable) o).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,11 +29,11 @@ import org.l2jmobius.gameserver.model.actor.Npc;
|
|||||||
/**
|
/**
|
||||||
* @author Mobius
|
* @author Mobius
|
||||||
*/
|
*/
|
||||||
public class RandomAnimationManager
|
public class RandomAnimationTaskManager
|
||||||
{
|
{
|
||||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public RandomAnimationManager()
|
public RandomAnimationTaskManager()
|
||||||
{
|
{
|
||||||
ThreadPool.scheduleAtFixedRate(() ->
|
ThreadPool.scheduleAtFixedRate(() ->
|
||||||
{
|
{
|
||||||
@@ -78,13 +78,13 @@ public class RandomAnimationManager
|
|||||||
PENDING_ANIMATIONS.remove(npc);
|
PENDING_ANIMATIONS.remove(npc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RandomAnimationManager getInstance()
|
public static RandomAnimationTaskManager getInstance()
|
||||||
{
|
{
|
||||||
return SingletonHolder.INSTANCE;
|
return SingletonHolder.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SingletonHolder
|
private static class SingletonHolder
|
||||||
{
|
{
|
||||||
protected static final RandomAnimationManager INSTANCE = new RandomAnimationManager();
|
protected static final RandomAnimationTaskManager INSTANCE = new RandomAnimationTaskManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -25,7 +25,7 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationManager;
|
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||||
|
|
||||||
public final class WorldRegion
|
public final class WorldRegion
|
||||||
{
|
{
|
||||||
@@ -105,11 +105,11 @@ public final class WorldRegion
|
|||||||
mob.getAI().stopAITask();
|
mob.getAI().stopAITask();
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAnimationManager.getInstance().remove(mob);
|
RandomAnimationTaskManager.getInstance().remove(mob);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().remove((Npc) o);
|
RandomAnimationTaskManager.getInstance().remove((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ public final class WorldRegion
|
|||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) o).getStatus().startHpMpRegeneration();
|
((Attackable) o).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.l2jmobius.gameserver.taskmanager;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
|
||||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class RandomAnimationManager
|
|
||||||
{
|
|
||||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
public RandomAnimationManager()
|
|
||||||
{
|
|
||||||
ThreadPool.scheduleAtFixedRate(() ->
|
|
||||||
{
|
|
||||||
final long time = System.currentTimeMillis();
|
|
||||||
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
|
||||||
{
|
|
||||||
if (time > entry.getValue())
|
|
||||||
{
|
|
||||||
final Npc npc = entry.getKey();
|
|
||||||
if (!npc.isInActiveRegion())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
|
||||||
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!npc.isDead() && !npc.hasBlockActions())
|
|
||||||
{
|
|
||||||
npc.onRandomAnimation(Rnd.get(2, 3));
|
|
||||||
}
|
|
||||||
|
|
||||||
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 0, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(Npc npc)
|
|
||||||
{
|
|
||||||
if (npc.hasRandomAnimation())
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(Npc npc)
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.remove(npc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RandomAnimationManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final RandomAnimationManager INSTANCE = new RandomAnimationManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.l2jmobius.gameserver.taskmanager;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
|
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class RandomAnimationTaskManager
|
||||||
|
{
|
||||||
|
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public RandomAnimationTaskManager()
|
||||||
|
{
|
||||||
|
ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
final long time = System.currentTimeMillis();
|
||||||
|
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
||||||
|
{
|
||||||
|
if (time > entry.getValue())
|
||||||
|
{
|
||||||
|
final Npc npc = entry.getKey();
|
||||||
|
if (!npc.isInActiveRegion())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
||||||
|
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!npc.isDead() && !npc.hasBlockActions())
|
||||||
|
{
|
||||||
|
npc.onRandomAnimation(Rnd.get(2, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Npc npc)
|
||||||
|
{
|
||||||
|
if (npc.hasRandomAnimation())
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(Npc npc)
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.remove(npc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RandomAnimationTaskManager getInstance()
|
||||||
|
{
|
||||||
|
return SingletonHolder.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SingletonHolder
|
||||||
|
{
|
||||||
|
protected static final RandomAnimationTaskManager INSTANCE = new RandomAnimationTaskManager();
|
||||||
|
}
|
||||||
|
}
|
@@ -25,7 +25,7 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationManager;
|
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||||
|
|
||||||
public final class WorldRegion
|
public final class WorldRegion
|
||||||
{
|
{
|
||||||
@@ -105,11 +105,11 @@ public final class WorldRegion
|
|||||||
mob.getAI().stopAITask();
|
mob.getAI().stopAITask();
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAnimationManager.getInstance().remove(mob);
|
RandomAnimationTaskManager.getInstance().remove(mob);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().remove((Npc) o);
|
RandomAnimationTaskManager.getInstance().remove((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ public final class WorldRegion
|
|||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) o).getStatus().startHpMpRegeneration();
|
((Attackable) o).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.l2jmobius.gameserver.taskmanager;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
|
||||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class RandomAnimationManager
|
|
||||||
{
|
|
||||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
public RandomAnimationManager()
|
|
||||||
{
|
|
||||||
ThreadPool.scheduleAtFixedRate(() ->
|
|
||||||
{
|
|
||||||
final long time = System.currentTimeMillis();
|
|
||||||
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
|
||||||
{
|
|
||||||
if (time > entry.getValue())
|
|
||||||
{
|
|
||||||
final Npc npc = entry.getKey();
|
|
||||||
if (!npc.isInActiveRegion())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
|
||||||
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!npc.isDead() && !npc.hasBlockActions())
|
|
||||||
{
|
|
||||||
npc.onRandomAnimation(Rnd.get(2, 3));
|
|
||||||
}
|
|
||||||
|
|
||||||
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 0, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(Npc npc)
|
|
||||||
{
|
|
||||||
if (npc.hasRandomAnimation())
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(Npc npc)
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.remove(npc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RandomAnimationManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final RandomAnimationManager INSTANCE = new RandomAnimationManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.l2jmobius.gameserver.taskmanager;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
|
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class RandomAnimationTaskManager
|
||||||
|
{
|
||||||
|
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public RandomAnimationTaskManager()
|
||||||
|
{
|
||||||
|
ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
final long time = System.currentTimeMillis();
|
||||||
|
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
||||||
|
{
|
||||||
|
if (time > entry.getValue())
|
||||||
|
{
|
||||||
|
final Npc npc = entry.getKey();
|
||||||
|
if (!npc.isInActiveRegion())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
||||||
|
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!npc.isDead() && !npc.hasBlockActions())
|
||||||
|
{
|
||||||
|
npc.onRandomAnimation(Rnd.get(2, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Npc npc)
|
||||||
|
{
|
||||||
|
if (npc.hasRandomAnimation())
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(Npc npc)
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.remove(npc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RandomAnimationTaskManager getInstance()
|
||||||
|
{
|
||||||
|
return SingletonHolder.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SingletonHolder
|
||||||
|
{
|
||||||
|
protected static final RandomAnimationTaskManager INSTANCE = new RandomAnimationTaskManager();
|
||||||
|
}
|
||||||
|
}
|
@@ -25,7 +25,7 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationManager;
|
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||||
|
|
||||||
public final class WorldRegion
|
public final class WorldRegion
|
||||||
{
|
{
|
||||||
@@ -105,11 +105,11 @@ public final class WorldRegion
|
|||||||
mob.getAI().stopAITask();
|
mob.getAI().stopAITask();
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAnimationManager.getInstance().remove(mob);
|
RandomAnimationTaskManager.getInstance().remove(mob);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().remove((Npc) o);
|
RandomAnimationTaskManager.getInstance().remove((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ public final class WorldRegion
|
|||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) o).getStatus().startHpMpRegeneration();
|
((Attackable) o).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.l2jmobius.gameserver.taskmanager;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
|
||||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class RandomAnimationManager
|
|
||||||
{
|
|
||||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
public RandomAnimationManager()
|
|
||||||
{
|
|
||||||
ThreadPool.scheduleAtFixedRate(() ->
|
|
||||||
{
|
|
||||||
final long time = System.currentTimeMillis();
|
|
||||||
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
|
||||||
{
|
|
||||||
if (time > entry.getValue())
|
|
||||||
{
|
|
||||||
final Npc npc = entry.getKey();
|
|
||||||
if (!npc.isInActiveRegion())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
|
||||||
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!npc.isDead() && !npc.hasBlockActions())
|
|
||||||
{
|
|
||||||
npc.onRandomAnimation(Rnd.get(2, 3));
|
|
||||||
}
|
|
||||||
|
|
||||||
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 0, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(Npc npc)
|
|
||||||
{
|
|
||||||
if (npc.hasRandomAnimation())
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(Npc npc)
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.remove(npc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RandomAnimationManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final RandomAnimationManager INSTANCE = new RandomAnimationManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.l2jmobius.gameserver.taskmanager;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
|
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class RandomAnimationTaskManager
|
||||||
|
{
|
||||||
|
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public RandomAnimationTaskManager()
|
||||||
|
{
|
||||||
|
ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
final long time = System.currentTimeMillis();
|
||||||
|
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
||||||
|
{
|
||||||
|
if (time > entry.getValue())
|
||||||
|
{
|
||||||
|
final Npc npc = entry.getKey();
|
||||||
|
if (!npc.isInActiveRegion())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
||||||
|
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!npc.isDead() && !npc.hasBlockActions())
|
||||||
|
{
|
||||||
|
npc.onRandomAnimation(Rnd.get(2, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Npc npc)
|
||||||
|
{
|
||||||
|
if (npc.hasRandomAnimation())
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(Npc npc)
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.remove(npc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RandomAnimationTaskManager getInstance()
|
||||||
|
{
|
||||||
|
return SingletonHolder.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SingletonHolder
|
||||||
|
{
|
||||||
|
protected static final RandomAnimationTaskManager INSTANCE = new RandomAnimationTaskManager();
|
||||||
|
}
|
||||||
|
}
|
@@ -25,7 +25,7 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationManager;
|
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||||
|
|
||||||
public final class WorldRegion
|
public final class WorldRegion
|
||||||
{
|
{
|
||||||
@@ -105,11 +105,11 @@ public final class WorldRegion
|
|||||||
mob.getAI().stopAITask();
|
mob.getAI().stopAITask();
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAnimationManager.getInstance().remove(mob);
|
RandomAnimationTaskManager.getInstance().remove(mob);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().remove((Npc) o);
|
RandomAnimationTaskManager.getInstance().remove((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ public final class WorldRegion
|
|||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) o).getStatus().startHpMpRegeneration();
|
((Attackable) o).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.l2jmobius.gameserver.taskmanager;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
|
||||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class RandomAnimationManager
|
|
||||||
{
|
|
||||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
public RandomAnimationManager()
|
|
||||||
{
|
|
||||||
ThreadPool.scheduleAtFixedRate(() ->
|
|
||||||
{
|
|
||||||
final long time = System.currentTimeMillis();
|
|
||||||
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
|
||||||
{
|
|
||||||
if (time > entry.getValue())
|
|
||||||
{
|
|
||||||
final Npc npc = entry.getKey();
|
|
||||||
if (!npc.isInActiveRegion())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
|
||||||
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!npc.isDead() && !npc.hasBlockActions())
|
|
||||||
{
|
|
||||||
npc.onRandomAnimation(Rnd.get(2, 3));
|
|
||||||
}
|
|
||||||
|
|
||||||
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 0, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(Npc npc)
|
|
||||||
{
|
|
||||||
if (npc.hasRandomAnimation())
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(Npc npc)
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.remove(npc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RandomAnimationManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final RandomAnimationManager INSTANCE = new RandomAnimationManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.l2jmobius.gameserver.taskmanager;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
|
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class RandomAnimationTaskManager
|
||||||
|
{
|
||||||
|
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public RandomAnimationTaskManager()
|
||||||
|
{
|
||||||
|
ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
final long time = System.currentTimeMillis();
|
||||||
|
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
||||||
|
{
|
||||||
|
if (time > entry.getValue())
|
||||||
|
{
|
||||||
|
final Npc npc = entry.getKey();
|
||||||
|
if (!npc.isInActiveRegion())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
||||||
|
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!npc.isDead() && !npc.hasBlockActions())
|
||||||
|
{
|
||||||
|
npc.onRandomAnimation(Rnd.get(2, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Npc npc)
|
||||||
|
{
|
||||||
|
if (npc.hasRandomAnimation())
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(Npc npc)
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.remove(npc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RandomAnimationTaskManager getInstance()
|
||||||
|
{
|
||||||
|
return SingletonHolder.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SingletonHolder
|
||||||
|
{
|
||||||
|
protected static final RandomAnimationTaskManager INSTANCE = new RandomAnimationTaskManager();
|
||||||
|
}
|
||||||
|
}
|
@@ -25,7 +25,7 @@ import org.l2jmobius.Config;
|
|||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
import org.l2jmobius.gameserver.model.actor.Attackable;
|
import org.l2jmobius.gameserver.model.actor.Attackable;
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
import org.l2jmobius.gameserver.taskmanager.RandomAnimationManager;
|
import org.l2jmobius.gameserver.taskmanager.RandomAnimationTaskManager;
|
||||||
|
|
||||||
public final class WorldRegion
|
public final class WorldRegion
|
||||||
{
|
{
|
||||||
@@ -105,11 +105,11 @@ public final class WorldRegion
|
|||||||
mob.getAI().stopAITask();
|
mob.getAI().stopAITask();
|
||||||
}
|
}
|
||||||
|
|
||||||
RandomAnimationManager.getInstance().remove(mob);
|
RandomAnimationTaskManager.getInstance().remove(mob);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().remove((Npc) o);
|
RandomAnimationTaskManager.getInstance().remove((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,11 +121,11 @@ public final class WorldRegion
|
|||||||
{
|
{
|
||||||
// Start HP/MP/CP regeneration task.
|
// Start HP/MP/CP regeneration task.
|
||||||
((Attackable) o).getStatus().startHpMpRegeneration();
|
((Attackable) o).getStatus().startHpMpRegeneration();
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
else if (o instanceof Npc)
|
else if (o instanceof Npc)
|
||||||
{
|
{
|
||||||
RandomAnimationManager.getInstance().add((Npc) o);
|
RandomAnimationTaskManager.getInstance().add((Npc) o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is part of the L2J Mobius project.
|
|
||||||
*
|
|
||||||
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.l2jmobius.gameserver.taskmanager;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
|
||||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
|
||||||
import org.l2jmobius.commons.util.Rnd;
|
|
||||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
|
||||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Mobius
|
|
||||||
*/
|
|
||||||
public class RandomAnimationManager
|
|
||||||
{
|
|
||||||
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
|
||||||
|
|
||||||
public RandomAnimationManager()
|
|
||||||
{
|
|
||||||
ThreadPool.scheduleAtFixedRate(() ->
|
|
||||||
{
|
|
||||||
final long time = System.currentTimeMillis();
|
|
||||||
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
|
||||||
{
|
|
||||||
if (time > entry.getValue())
|
|
||||||
{
|
|
||||||
final Npc npc = entry.getKey();
|
|
||||||
if (!npc.isInActiveRegion())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
|
||||||
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!npc.isDead() && !npc.hasBlockActions())
|
|
||||||
{
|
|
||||||
npc.onRandomAnimation(Rnd.get(2, 3));
|
|
||||||
}
|
|
||||||
|
|
||||||
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 0, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void add(Npc npc)
|
|
||||||
{
|
|
||||||
if (npc.hasRandomAnimation())
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remove(Npc npc)
|
|
||||||
{
|
|
||||||
PENDING_ANIMATIONS.remove(npc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static RandomAnimationManager getInstance()
|
|
||||||
{
|
|
||||||
return SingletonHolder.INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SingletonHolder
|
|
||||||
{
|
|
||||||
protected static final RandomAnimationManager INSTANCE = new RandomAnimationManager();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the L2J Mobius project.
|
||||||
|
*
|
||||||
|
* 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.l2jmobius.gameserver.taskmanager;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.l2jmobius.Config;
|
||||||
|
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||||
|
import org.l2jmobius.commons.util.Rnd;
|
||||||
|
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||||
|
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Mobius
|
||||||
|
*/
|
||||||
|
public class RandomAnimationTaskManager
|
||||||
|
{
|
||||||
|
private static final Map<Npc, Long> PENDING_ANIMATIONS = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public RandomAnimationTaskManager()
|
||||||
|
{
|
||||||
|
ThreadPool.scheduleAtFixedRate(() ->
|
||||||
|
{
|
||||||
|
final long time = System.currentTimeMillis();
|
||||||
|
for (Entry<Npc, Long> entry : PENDING_ANIMATIONS.entrySet())
|
||||||
|
{
|
||||||
|
if (time > entry.getValue())
|
||||||
|
{
|
||||||
|
final Npc npc = entry.getKey();
|
||||||
|
if (!npc.isInActiveRegion())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel further animation schedules until intention is changed to ACTIVE again.
|
||||||
|
if (npc.isAttackable() && (npc.getAI().getIntention() != CtrlIntention.AI_INTENTION_ACTIVE))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!npc.isDead() && !npc.hasBlockActions())
|
||||||
|
{
|
||||||
|
npc.onRandomAnimation(Rnd.get(2, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
PENDING_ANIMATIONS.put(npc, time + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(Npc npc)
|
||||||
|
{
|
||||||
|
if (npc.hasRandomAnimation())
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.putIfAbsent(npc, System.currentTimeMillis() + (Rnd.get((npc.isAttackable() ? Config.MIN_MONSTER_ANIMATION : Config.MIN_NPC_ANIMATION), (npc.isAttackable() ? Config.MAX_MONSTER_ANIMATION : Config.MAX_NPC_ANIMATION)) * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(Npc npc)
|
||||||
|
{
|
||||||
|
PENDING_ANIMATIONS.remove(npc);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RandomAnimationTaskManager getInstance()
|
||||||
|
{
|
||||||
|
return SingletonHolder.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SingletonHolder
|
||||||
|
{
|
||||||
|
protected static final RandomAnimationTaskManager INSTANCE = new RandomAnimationTaskManager();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user