Rename and clean up MapleReactor
This commit is contained in:
@@ -32,8 +32,8 @@ import server.life.Monster;
|
||||
import server.life.SpawnPoint;
|
||||
import server.maps.MapObject;
|
||||
import server.maps.MapObjectType;
|
||||
import server.maps.MapleReactor;
|
||||
import server.maps.Portal;
|
||||
import server.maps.Reactor;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
@@ -124,7 +124,7 @@ public class DebugCommand extends Command {
|
||||
player.dropMessage(6, "Current reactor states on map " + player.getMapId() + ":");
|
||||
|
||||
for (MapObject mmo : player.getMap().getReactors()) {
|
||||
MapleReactor mr = (MapleReactor) mmo;
|
||||
Reactor mr = (Reactor) mmo;
|
||||
player.dropMessage(6, "Id: " + mr.getId() + " Oid: " + mr.getObjectId() + " name: '" + mr.getName() + "' -> Type: " + mr.getReactorType() + " State: " + mr.getState() + " Event State: " + mr.getEventState() + " Position: x " + mr.getPosition().getX() + " y " + mr.getPosition().getY() + ".");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -24,7 +24,7 @@ package net.server.channel.handlers;
|
||||
import client.Client;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import server.maps.MapleReactor;
|
||||
import server.maps.Reactor;
|
||||
|
||||
/**
|
||||
* @author Lerk
|
||||
@@ -40,7 +40,7 @@ public final class ReactorHitHandler extends AbstractPacketHandler {
|
||||
short stance = p.readShort();
|
||||
p.skip(4);
|
||||
int skillid = p.readInt();
|
||||
MapleReactor reactor = c.getPlayer().getMap().getReactorByOid(oid);
|
||||
Reactor reactor = c.getPlayer().getMap().getReactorByOid(oid);
|
||||
if (reactor != null) {
|
||||
reactor.hitReactor(true, charPos, stance, skillid, c);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import client.Client;
|
||||
import net.AbstractPacketHandler;
|
||||
import net.packet.InPacket;
|
||||
import scripting.reactor.ReactorScriptManager;
|
||||
import server.maps.MapleReactor;
|
||||
import server.maps.Reactor;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -36,7 +36,7 @@ public final class TouchReactorHandler extends AbstractPacketHandler {
|
||||
@Override
|
||||
public final void handlePacket(InPacket p, Client c) {
|
||||
int oid = p.readInt();
|
||||
MapleReactor reactor = c.getPlayer().getMap().getReactorByOid(oid);
|
||||
Reactor reactor = c.getPlayer().getMap().getReactorByOid(oid);
|
||||
if (reactor != null) {
|
||||
if (p.readByte() != 0) {
|
||||
ReactorScriptManager.getInstance().touch(c, reactor);
|
||||
|
||||
@@ -46,8 +46,8 @@ import server.life.Monster;
|
||||
import server.life.NPC;
|
||||
import server.maps.MapManager;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.MapleReactor;
|
||||
import server.maps.Portal;
|
||||
import server.maps.Reactor;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
@@ -1350,7 +1350,7 @@ public class EventInstanceManager {
|
||||
public boolean activatedAllReactorsOnMap(MapleMap map, int minReactorId, int maxReactorId) {
|
||||
if(map == null) return true;
|
||||
|
||||
for(MapleReactor mr : map.getReactorsByIdRange(minReactorId, maxReactorId)) {
|
||||
for(Reactor mr : map.getReactorsByIdRange(minReactorId, maxReactorId)) {
|
||||
if(mr.getReactorType() != -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import server.life.LifeFactory;
|
||||
import server.life.Monster;
|
||||
import server.maps.MapMonitor;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.MapleReactor;
|
||||
import server.maps.Reactor;
|
||||
import server.maps.ReactorDropEntry;
|
||||
import server.partyquest.MapleCarnivalFactory;
|
||||
import server.partyquest.MapleCarnivalFactory.MCSkill;
|
||||
@@ -53,11 +53,11 @@ import java.util.concurrent.ScheduledFuture;
|
||||
* @author Ronan
|
||||
*/
|
||||
public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
private final MapleReactor reactor;
|
||||
private final Reactor reactor;
|
||||
private final Invocable iv;
|
||||
private ScheduledFuture<?> sprayTask = null;
|
||||
|
||||
public ReactorActionManager(Client c, MapleReactor reactor, Invocable iv) {
|
||||
public ReactorActionManager(Client c, Reactor reactor, Invocable iv) {
|
||||
super(c);
|
||||
this.reactor = reactor;
|
||||
this.iv = iv;
|
||||
@@ -185,7 +185,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
final MapleReactor r = reactor;
|
||||
final Reactor r = reactor;
|
||||
final List<ReactorDropEntry> dropItems = items;
|
||||
final int worldMesoRate = c.getWorldServer().getMesoRate();
|
||||
|
||||
@@ -299,7 +299,7 @@ public class ReactorActionManager extends AbstractPlayerInteraction {
|
||||
}
|
||||
}
|
||||
|
||||
public MapleReactor getReactor() {
|
||||
public Reactor getReactor() {
|
||||
return reactor;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ package scripting.reactor;
|
||||
|
||||
import client.Client;
|
||||
import scripting.AbstractScriptManager;
|
||||
import server.maps.MapleReactor;
|
||||
import server.maps.Reactor;
|
||||
import server.maps.ReactorDropEntry;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
@@ -51,7 +51,7 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void onHit(Client c, MapleReactor reactor) {
|
||||
public void onHit(Client c, Reactor reactor) {
|
||||
try {
|
||||
Invocable iv = initializeInvocable(c, reactor);
|
||||
if (iv == null) {
|
||||
@@ -66,7 +66,7 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void act(Client c, MapleReactor reactor) {
|
||||
public void act(Client c, Reactor reactor) {
|
||||
try {
|
||||
Invocable iv = initializeInvocable(c, reactor);
|
||||
if (iv == null) {
|
||||
@@ -104,15 +104,15 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
||||
drops.clear();
|
||||
}
|
||||
|
||||
public void touch(Client c, MapleReactor reactor) {
|
||||
public void touch(Client c, Reactor reactor) {
|
||||
touching(c, reactor, true);
|
||||
}
|
||||
|
||||
public void untouch(Client c, MapleReactor reactor) {
|
||||
public void untouch(Client c, Reactor reactor) {
|
||||
touching(c, reactor, false);
|
||||
}
|
||||
|
||||
private void touching(Client c, MapleReactor reactor, boolean touching) {
|
||||
private void touching(Client c, Reactor reactor, boolean touching) {
|
||||
try {
|
||||
Invocable iv = initializeInvocable(c, reactor);
|
||||
if (iv == null) {
|
||||
@@ -129,7 +129,7 @@ public class ReactorScriptManager extends AbstractScriptManager {
|
||||
}
|
||||
}
|
||||
|
||||
private Invocable initializeInvocable(Client c, MapleReactor reactor) {
|
||||
private Invocable initializeInvocable(Client c, Reactor reactor) {
|
||||
ScriptEngine engine = getInvocableScriptEngine("reactor/" + reactor.getId() + ".js", c);
|
||||
if (engine == null) {
|
||||
return null;
|
||||
|
||||
@@ -293,7 +293,7 @@ public class MapFactory {
|
||||
for (Data reactor : mapData.getChildByPath("reactor")) {
|
||||
String id = DataTool.getString(reactor.getChildByPath("id"));
|
||||
if (id != null) {
|
||||
MapleReactor newReactor = loadReactor(reactor, id, (byte) DataTool.getInt(reactor.getChildByPath("f"), 0));
|
||||
Reactor newReactor = loadReactor(reactor, id, (byte) DataTool.getInt(reactor.getChildByPath("f"), 0));
|
||||
map.spawnReactor(newReactor);
|
||||
}
|
||||
}
|
||||
@@ -351,8 +351,8 @@ public class MapFactory {
|
||||
return myLife;
|
||||
}
|
||||
|
||||
private static MapleReactor loadReactor(Data reactor, String id, final byte FacingDirection) {
|
||||
MapleReactor myReactor = new MapleReactor(MapleReactorFactory.getReactor(Integer.parseInt(id)), Integer.parseInt(id));
|
||||
private static Reactor loadReactor(Data reactor, String id, final byte FacingDirection) {
|
||||
Reactor myReactor = new Reactor(MapleReactorFactory.getReactor(Integer.parseInt(id)), Integer.parseInt(id));
|
||||
int x = DataTool.getInt(reactor.getChildByPath("x"));
|
||||
int y = DataTool.getInt(reactor.getChildByPath("y"));
|
||||
myReactor.setFacingDirection(FacingDirection);
|
||||
|
||||
@@ -297,12 +297,12 @@ public class MapleMap {
|
||||
public void setReactorState() {
|
||||
for (MapObject o : getMapObjects()) {
|
||||
if (o.getType() == MapObjectType.REACTOR) {
|
||||
if (((MapleReactor) o).getState() < 1) {
|
||||
MapleReactor mr = (MapleReactor) o;
|
||||
if (((Reactor) o).getState() < 1) {
|
||||
Reactor mr = (Reactor) o;
|
||||
mr.lockReactor();
|
||||
try {
|
||||
mr.resetReactorActions(1);
|
||||
broadcastMessage(PacketCreator.triggerReactor((MapleReactor) o, 1));
|
||||
broadcastMessage(PacketCreator.triggerReactor((Reactor) o, 1));
|
||||
} finally {
|
||||
mr.unlockReactor();
|
||||
}
|
||||
@@ -312,11 +312,11 @@ public class MapleMap {
|
||||
}
|
||||
|
||||
public final void limitReactor(final int rid, final int num) {
|
||||
List<MapleReactor> toDestroy = new ArrayList<>();
|
||||
List<Reactor> toDestroy = new ArrayList<>();
|
||||
Map<Integer, Integer> contained = new LinkedHashMap<>();
|
||||
|
||||
for (MapObject obj : getReactors()) {
|
||||
MapleReactor mr = (MapleReactor) obj;
|
||||
Reactor mr = (Reactor) obj;
|
||||
if (contained.containsKey(mr.getId())) {
|
||||
if (contained.get(mr.getId()) >= num) {
|
||||
toDestroy.add(mr);
|
||||
@@ -328,14 +328,14 @@ public class MapleMap {
|
||||
}
|
||||
}
|
||||
|
||||
for (MapleReactor mr : toDestroy) {
|
||||
for (Reactor mr : toDestroy) {
|
||||
destroyReactor(mr.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAllReactorState(final int reactorId, final int state) {
|
||||
for (MapObject mo : getReactors()) {
|
||||
MapleReactor r = (MapleReactor) mo;
|
||||
Reactor r = (Reactor) mo;
|
||||
|
||||
if (r.getId() == reactorId && r.getState() != state) {
|
||||
return false;
|
||||
@@ -757,7 +757,7 @@ public class MapleMap {
|
||||
dropFromMonster(chr, mob, true);
|
||||
}
|
||||
|
||||
public void dropFromReactor(final Character chr, final MapleReactor reactor, Item drop, Point dropPos, short questid) {
|
||||
public void dropFromReactor(final Character chr, final Reactor reactor, Item drop, Point dropPos, short questid) {
|
||||
spawnDrop(drop, this.calcDropPos(dropPos, reactor.getPosition()), reactor, chr, (byte) (chr.getParty() != null ? 1 : 0), questid);
|
||||
}
|
||||
|
||||
@@ -1202,10 +1202,10 @@ public class MapleMap {
|
||||
return getMapObjectsInRange(new Point(0, 0), Double.POSITIVE_INFINITY, Arrays.asList(MapObjectType.MONSTER));
|
||||
}
|
||||
|
||||
public final List<MapleReactor> getAllReactors() {
|
||||
List<MapleReactor> list = new LinkedList<>();
|
||||
public final List<Reactor> getAllReactors() {
|
||||
List<Reactor> list = new LinkedList<>();
|
||||
for (MapObject mmo : getReactors()) {
|
||||
list.add((MapleReactor) mmo);
|
||||
list.add((Reactor) mmo);
|
||||
}
|
||||
|
||||
return list;
|
||||
@@ -1535,23 +1535,23 @@ public class MapleMap {
|
||||
}
|
||||
|
||||
public final void destroyReactors(final int first, final int last) {
|
||||
List<MapleReactor> toDestroy = new ArrayList<>();
|
||||
List<Reactor> toDestroy = new ArrayList<>();
|
||||
List<MapObject> reactors = getReactors();
|
||||
|
||||
for (MapObject obj : reactors) {
|
||||
MapleReactor mr = (MapleReactor) obj;
|
||||
Reactor mr = (Reactor) obj;
|
||||
if (mr.getId() >= first && mr.getId() <= last) {
|
||||
toDestroy.add(mr);
|
||||
}
|
||||
}
|
||||
|
||||
for (MapleReactor mr : toDestroy) {
|
||||
for (Reactor mr : toDestroy) {
|
||||
destroyReactor(mr.getObjectId());
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyReactor(int oid) {
|
||||
final MapleReactor reactor = getReactorByOid(oid);
|
||||
final Reactor reactor = getReactorByOid(oid);
|
||||
|
||||
if (reactor != null) {
|
||||
if (reactor.destroy()) {
|
||||
@@ -1561,13 +1561,13 @@ public class MapleMap {
|
||||
}
|
||||
|
||||
public void resetReactors() {
|
||||
List<MapleReactor> list = new ArrayList<>();
|
||||
List<Reactor> list = new ArrayList<>();
|
||||
|
||||
objectRLock.lock();
|
||||
try {
|
||||
for (MapObject o : mapobjects.values()) {
|
||||
if (o.getType() == MapObjectType.REACTOR) {
|
||||
final MapleReactor r = ((MapleReactor) o);
|
||||
final Reactor r = ((Reactor) o);
|
||||
list.add(r);
|
||||
}
|
||||
}
|
||||
@@ -1578,8 +1578,8 @@ public class MapleMap {
|
||||
resetReactors(list);
|
||||
}
|
||||
|
||||
public final void resetReactors(List<MapleReactor> list) {
|
||||
for (MapleReactor r : list) {
|
||||
public final void resetReactors(List<Reactor> list) {
|
||||
for (Reactor r : list) {
|
||||
if (r.forceDelayedRespawn()) { // thanks Conrad for suggesting reactor with delay respawning immediately
|
||||
continue;
|
||||
}
|
||||
@@ -1621,7 +1621,7 @@ public class MapleMap {
|
||||
List<MapObject> targets = new LinkedList<>();
|
||||
|
||||
for (MapObject obj : reactors) {
|
||||
MapleReactor mr = (MapleReactor) obj;
|
||||
Reactor mr = (Reactor) obj;
|
||||
if (mr.getId() >= first && mr.getId() <= last) {
|
||||
points.add(mr.getPosition());
|
||||
targets.add(obj);
|
||||
@@ -1629,7 +1629,7 @@ public class MapleMap {
|
||||
}
|
||||
Collections.shuffle(points);
|
||||
for (MapObject obj : targets) {
|
||||
MapleReactor mr = (MapleReactor) obj;
|
||||
Reactor mr = (Reactor) obj;
|
||||
mr.setPosition(points.remove(points.size() - 1));
|
||||
}
|
||||
}
|
||||
@@ -1655,14 +1655,14 @@ public class MapleMap {
|
||||
}
|
||||
|
||||
for (MapObject obj : listObjects) {
|
||||
MapleReactor mr = (MapleReactor) obj;
|
||||
Reactor mr = (Reactor) obj;
|
||||
|
||||
points.add(mr.getPosition());
|
||||
targets.add(obj);
|
||||
}
|
||||
Collections.shuffle(points);
|
||||
for (MapObject obj : targets) {
|
||||
MapleReactor mr = (MapleReactor) obj;
|
||||
Reactor mr = (Reactor) obj;
|
||||
mr.setPosition(points.remove(points.size() - 1));
|
||||
}
|
||||
}
|
||||
@@ -1755,18 +1755,18 @@ public class MapleMap {
|
||||
return (mmo != null && mmo.getType() == MapObjectType.MONSTER) ? (Monster) mmo : null;
|
||||
}
|
||||
|
||||
public MapleReactor getReactorByOid(int oid) {
|
||||
public Reactor getReactorByOid(int oid) {
|
||||
MapObject mmo = getMapObject(oid);
|
||||
return (mmo != null && mmo.getType() == MapObjectType.REACTOR) ? (MapleReactor) mmo : null;
|
||||
return (mmo != null && mmo.getType() == MapObjectType.REACTOR) ? (Reactor) mmo : null;
|
||||
}
|
||||
|
||||
public MapleReactor getReactorById(int Id) {
|
||||
public Reactor getReactorById(int Id) {
|
||||
objectRLock.lock();
|
||||
try {
|
||||
for (MapObject obj : mapobjects.values()) {
|
||||
if (obj.getType() == MapObjectType.REACTOR) {
|
||||
if (((MapleReactor) obj).getId() == Id) {
|
||||
return (MapleReactor) obj;
|
||||
if (((Reactor) obj).getId() == Id) {
|
||||
return (Reactor) obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1776,14 +1776,14 @@ public class MapleMap {
|
||||
}
|
||||
}
|
||||
|
||||
public List<MapleReactor> getReactorsByIdRange(final int first, final int last) {
|
||||
List<MapleReactor> list = new LinkedList<>();
|
||||
public List<Reactor> getReactorsByIdRange(final int first, final int last) {
|
||||
List<Reactor> list = new LinkedList<>();
|
||||
|
||||
objectRLock.lock();
|
||||
try {
|
||||
for (MapObject obj : mapobjects.values()) {
|
||||
if (obj.getType() == MapObjectType.REACTOR) {
|
||||
MapleReactor mr = (MapleReactor) obj;
|
||||
Reactor mr = (Reactor) obj;
|
||||
|
||||
if (mr.getId() >= first && mr.getId() <= last) {
|
||||
list.add(mr);
|
||||
@@ -1797,13 +1797,13 @@ public class MapleMap {
|
||||
}
|
||||
}
|
||||
|
||||
public MapleReactor getReactorByName(String name) {
|
||||
public Reactor getReactorByName(String name) {
|
||||
objectRLock.lock();
|
||||
try {
|
||||
for (MapObject obj : mapobjects.values()) {
|
||||
if (obj.getType() == MapObjectType.REACTOR) {
|
||||
if (((MapleReactor) obj).getName().equals(name)) {
|
||||
return (MapleReactor) obj;
|
||||
if (((Reactor) obj).getName().equals(name)) {
|
||||
return (Reactor) obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2036,7 +2036,7 @@ public class MapleMap {
|
||||
updateBossSpawn(monster);
|
||||
}
|
||||
|
||||
public void spawnReactor(final MapleReactor reactor) {
|
||||
public void spawnReactor(final Reactor reactor) {
|
||||
reactor.setMap(this);
|
||||
spawnAndAddRangedMapObject(reactor, c -> c.sendPacket(reactor.makeSpawnData()));
|
||||
}
|
||||
@@ -2212,7 +2212,7 @@ public class MapleMap {
|
||||
final Item item = drop.getItem();
|
||||
|
||||
for (final MapObject o : getReactors()) {
|
||||
final MapleReactor react = (MapleReactor) o;
|
||||
final Reactor react = (Reactor) o;
|
||||
|
||||
if (react.getReactorType() == 100) {
|
||||
if (react.getReactItem(react.getEventState()).getLeft() == item.getItemId() && react.getReactItem(react.getEventState()).getRight() == item.getQuantity()) {
|
||||
@@ -2226,7 +2226,7 @@ public class MapleMap {
|
||||
}
|
||||
}
|
||||
|
||||
public void searchItemReactors(final MapleReactor react) {
|
||||
public void searchItemReactors(final Reactor react) {
|
||||
if (react.getReactorType() == 100) {
|
||||
Pair<Integer, Integer> reactProp = react.getReactItem(react.getEventState());
|
||||
int reactItem = reactProp.getLeft(), reactQty = reactProp.getRight();
|
||||
@@ -2958,7 +2958,7 @@ public class MapleMap {
|
||||
if (chr != null) {
|
||||
for (MapObject o : getMapObjectsInRange(chr.getPosition(), getRangedDistance(), rangedMapobjectTypes)) {
|
||||
if (o.getType() == MapObjectType.REACTOR) {
|
||||
if (((MapleReactor) o).isAlive()) {
|
||||
if (((Reactor) o).isAlive()) {
|
||||
o.sendSpawnData(chr.getClient());
|
||||
chr.addVisibleMapObject(o);
|
||||
}
|
||||
@@ -3413,10 +3413,10 @@ public class MapleMap {
|
||||
private class ActivateItemReactor implements Runnable {
|
||||
|
||||
private final MapItem mapitem;
|
||||
private final MapleReactor reactor;
|
||||
private final Reactor reactor;
|
||||
private final Client c;
|
||||
|
||||
public ActivateItemReactor(MapItem mapitem, MapleReactor reactor, Client c) {
|
||||
public ActivateItemReactor(MapItem mapitem, Reactor reactor, Client c) {
|
||||
this.mapitem = mapitem;
|
||||
this.reactor = reactor;
|
||||
this.c = c;
|
||||
@@ -4299,7 +4299,7 @@ public class MapleMap {
|
||||
return -1;
|
||||
}
|
||||
int reactorID = 9980000 + team;
|
||||
MapleReactor reactor = new MapleReactor(MapleReactorFactory.getReactorS(reactorID), reactorID);
|
||||
Reactor reactor = new Reactor(MapleReactorFactory.getReactorS(reactorID), reactorID);
|
||||
pt.setTaken(true);
|
||||
reactor.setPosition(pt.getPosition());
|
||||
reactor.setName(team + "" + num); //lol
|
||||
|
||||
@@ -40,14 +40,12 @@ import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Lerk
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MapleReactor extends AbstractMapObject {
|
||||
|
||||
private int rid;
|
||||
private MapleReactorStats stats;
|
||||
public class Reactor extends AbstractMapObject {
|
||||
private final int rid;
|
||||
private final MapleReactorStats stats;
|
||||
private byte state;
|
||||
private byte evstate;
|
||||
private int delay;
|
||||
@@ -60,10 +58,10 @@ public class MapleReactor extends AbstractMapObject {
|
||||
private Runnable delayedRespawnRun = null;
|
||||
private GuardianSpawnPoint guardian = null;
|
||||
private byte facingDirection = 0;
|
||||
private Lock reactorLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.REACTOR, true);
|
||||
private Lock hitLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.REACTOR_HIT, true);
|
||||
private final Lock reactorLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.REACTOR, true);
|
||||
private final Lock hitLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.REACTOR_HIT, true);
|
||||
|
||||
public MapleReactor(MapleReactorStats stats, int rid) {
|
||||
public Reactor(MapleReactorStats stats, int rid) {
|
||||
this.evstate = (byte) 0;
|
||||
this.stats = stats;
|
||||
this.rid = rid;
|
||||
@@ -85,7 +83,7 @@ public class MapleReactor extends AbstractMapObject {
|
||||
public void unlockReactor() {
|
||||
reactorLock.unlock();
|
||||
}
|
||||
|
||||
|
||||
public void hitLockReactor() {
|
||||
hitLock.lock();
|
||||
reactorLock.lock();
|
||||
@@ -323,11 +321,12 @@ public class MapleReactor extends AbstractMapObject {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean destroy() {
|
||||
if (reactorLock.tryLock()) {
|
||||
try {
|
||||
boolean alive = this.isAlive();
|
||||
// reactor neither alive nor in delayed respawn, remove map object allowed
|
||||
if (alive) {
|
||||
this.setAlive(false);
|
||||
this.cancelReactorTimeout();
|
||||
@@ -335,20 +334,16 @@ public class MapleReactor extends AbstractMapObject {
|
||||
if (this.getDelay() > 0) {
|
||||
this.delayedRespawn();
|
||||
}
|
||||
} else if (this.inDelayedRespawn()) {
|
||||
return false;
|
||||
} else {
|
||||
return true; // reactor neither alive nor in delayed respawn, remove map object allowed
|
||||
}
|
||||
} else return !this.inDelayedRespawn();
|
||||
} finally {
|
||||
reactorLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
map.broadcastMessage(PacketCreator.destroyReactor(this));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void respawn() {
|
||||
this.lockReactor();
|
||||
try {
|
||||
@@ -357,25 +352,25 @@ public class MapleReactor extends AbstractMapObject {
|
||||
} finally {
|
||||
this.unlockReactor();
|
||||
}
|
||||
|
||||
|
||||
map.broadcastMessage(this.makeSpawnData());
|
||||
}
|
||||
|
||||
|
||||
public void delayedRespawn() {
|
||||
Runnable r = () -> {
|
||||
delayedRespawnRun = null;
|
||||
respawn();
|
||||
};
|
||||
|
||||
|
||||
delayedRespawnRun = r;
|
||||
|
||||
|
||||
OverallService service = (OverallService) map.getChannelServer().getServiceAccess(ChannelServices.OVERALL);
|
||||
service.registerOverallAction(map.getId(), r, this.getDelay());
|
||||
}
|
||||
|
||||
|
||||
public boolean forceDelayedRespawn() {
|
||||
Runnable r = delayedRespawnRun;
|
||||
|
||||
|
||||
if (r != null) {
|
||||
OverallService service = (OverallService) map.getChannelServer().getServiceAccess(ChannelServices.OVERALL);
|
||||
service.forceRunOverallAction(map.getId(), r);
|
||||
@@ -384,7 +379,7 @@ public class MapleReactor extends AbstractMapObject {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public boolean inDelayedRespawn() {
|
||||
return delayedRespawnRun != null;
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import net.server.world.Party;
|
||||
import net.server.world.PartyCharacter;
|
||||
import server.TimerManager;
|
||||
import server.maps.MapleMap;
|
||||
import server.maps.MapleReactor;
|
||||
import server.maps.Reactor;
|
||||
import tools.PacketCreator;
|
||||
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
@@ -170,7 +170,7 @@ public class MonsterCarnival {
|
||||
|
||||
public boolean canGuardianR() {
|
||||
int teamReactors = 0;
|
||||
for (MapleReactor react : map.getAllReactors()) {
|
||||
for (Reactor react : map.getAllReactors()) {
|
||||
if (react.getName().substring(0, 1).contentEquals("0")) {
|
||||
teamReactors += 1;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public class MonsterCarnival {
|
||||
|
||||
public boolean canGuardianB() {
|
||||
int teamReactors = 0;
|
||||
for (MapleReactor react : map.getAllReactors()) {
|
||||
for (Reactor react : map.getAllReactors()) {
|
||||
if (react.getName().substring(0, 1).contentEquals("1")) {
|
||||
teamReactors += 1;
|
||||
}
|
||||
|
||||
@@ -4117,7 +4117,7 @@ public class PacketCreator {
|
||||
}
|
||||
|
||||
// is there a way to spawn reactors non-animated?
|
||||
public static Packet spawnReactor(MapleReactor reactor) {
|
||||
public static Packet spawnReactor(Reactor reactor) {
|
||||
OutPacket p = OutPacket.create(SendOpcode.REACTOR_SPAWN);
|
||||
p.writeInt(reactor.getObjectId());
|
||||
p.writeInt(reactor.getId());
|
||||
@@ -4129,7 +4129,7 @@ public class PacketCreator {
|
||||
}
|
||||
|
||||
// is there a way to trigger reactors without performing the hit animation?
|
||||
public static Packet triggerReactor(MapleReactor reactor, int stance) {
|
||||
public static Packet triggerReactor(Reactor reactor, int stance) {
|
||||
OutPacket p = OutPacket.create(SendOpcode.REACTOR_HIT);
|
||||
p.writeInt(reactor.getObjectId());
|
||||
p.writeByte(reactor.getState());
|
||||
@@ -4140,7 +4140,7 @@ public class PacketCreator {
|
||||
return p;
|
||||
}
|
||||
|
||||
public static Packet destroyReactor(MapleReactor reactor) {
|
||||
public static Packet destroyReactor(Reactor reactor) {
|
||||
OutPacket p = OutPacket.create(SendOpcode.REACTOR_DESTROY);
|
||||
p.writeInt(reactor.getObjectId());
|
||||
p.writeByte(reactor.getState());
|
||||
|
||||
Reference in New Issue
Block a user