Rename and clean up MapleReactorStats
This commit is contained in:
@@ -45,7 +45,7 @@ import java.util.concurrent.locks.Lock;
|
|||||||
*/
|
*/
|
||||||
public class Reactor extends AbstractMapObject {
|
public class Reactor extends AbstractMapObject {
|
||||||
private final int rid;
|
private final int rid;
|
||||||
private final MapleReactorStats stats;
|
private final ReactorStats stats;
|
||||||
private byte state;
|
private byte state;
|
||||||
private byte evstate;
|
private byte evstate;
|
||||||
private int delay;
|
private int delay;
|
||||||
@@ -61,7 +61,7 @@ public class Reactor extends AbstractMapObject {
|
|||||||
private final Lock reactorLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.REACTOR, true);
|
private final Lock reactorLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.REACTOR, true);
|
||||||
private final Lock hitLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.REACTOR_HIT, true);
|
private final Lock hitLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.REACTOR_HIT, true);
|
||||||
|
|
||||||
public Reactor(MapleReactorStats stats, int rid) {
|
public Reactor(ReactorStats stats, int rid) {
|
||||||
this.evstate = (byte) 0;
|
this.evstate = (byte) 0;
|
||||||
this.stats = stats;
|
this.stats = stats;
|
||||||
this.rid = rid;
|
this.rid = rid;
|
||||||
@@ -110,7 +110,7 @@ public class Reactor extends AbstractMapObject {
|
|||||||
return evstate;
|
return evstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapleReactorStats getStats() {
|
public ReactorStats getStats() {
|
||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import provider.DataProvider;
|
|||||||
import provider.DataProviderFactory;
|
import provider.DataProviderFactory;
|
||||||
import provider.DataTool;
|
import provider.DataTool;
|
||||||
import provider.wz.WZFiles;
|
import provider.wz.WZFiles;
|
||||||
import server.maps.MapleReactorStats.StateData;
|
import server.maps.ReactorStats.StateData;
|
||||||
import tools.Pair;
|
import tools.Pair;
|
||||||
import tools.StringUtil;
|
import tools.StringUtil;
|
||||||
|
|
||||||
@@ -37,10 +37,10 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class ReactorFactory {
|
public class ReactorFactory {
|
||||||
private static final DataProvider data = DataProviderFactory.getDataProvider(WZFiles.REACTOR);
|
private static final DataProvider data = DataProviderFactory.getDataProvider(WZFiles.REACTOR);
|
||||||
private static final Map<Integer, MapleReactorStats> reactorStats = new HashMap<>();
|
private static final Map<Integer, ReactorStats> reactorStats = new HashMap<>();
|
||||||
|
|
||||||
public static final MapleReactorStats getReactorS(int rid) {
|
public static final ReactorStats getReactorS(int rid) {
|
||||||
MapleReactorStats stats = reactorStats.get(rid);
|
ReactorStats stats = reactorStats.get(rid);
|
||||||
if (stats == null) {
|
if (stats == null) {
|
||||||
int infoId = rid;
|
int infoId = rid;
|
||||||
Data reactorData = data.getData(StringUtil.getLeftPaddedStr(infoId + ".img", '0', 11));
|
Data reactorData = data.getData(StringUtil.getLeftPaddedStr(infoId + ".img", '0', 11));
|
||||||
@@ -50,7 +50,7 @@ public class ReactorFactory {
|
|||||||
stats = reactorStats.get(infoId);
|
stats = reactorStats.get(infoId);
|
||||||
}
|
}
|
||||||
if (stats == null) {
|
if (stats == null) {
|
||||||
stats = new MapleReactorStats();
|
stats = new ReactorStats();
|
||||||
reactorData = data.getData(StringUtil.getLeftPaddedStr(infoId + ".img", '0', 11));
|
reactorData = data.getData(StringUtil.getLeftPaddedStr(infoId + ".img", '0', 11));
|
||||||
if (reactorData == null) {
|
if (reactorData == null) {
|
||||||
return stats;
|
return stats;
|
||||||
@@ -93,8 +93,8 @@ public class ReactorFactory {
|
|||||||
return stats;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MapleReactorStats getReactor(int rid) {
|
public static ReactorStats getReactor(int rid) {
|
||||||
MapleReactorStats stats = reactorStats.get(rid);
|
ReactorStats stats = reactorStats.get(rid);
|
||||||
if (stats == null) {
|
if (stats == null) {
|
||||||
int infoId = rid;
|
int infoId = rid;
|
||||||
Data reactorData = data.getData(StringUtil.getLeftPaddedStr(infoId + ".img", '0', 11));
|
Data reactorData = data.getData(StringUtil.getLeftPaddedStr(infoId + ".img", '0', 11));
|
||||||
@@ -111,7 +111,7 @@ public class ReactorFactory {
|
|||||||
if (stats == null) {
|
if (stats == null) {
|
||||||
reactorData = data.getData(StringUtil.getLeftPaddedStr(infoId + ".img", '0', 11));
|
reactorData = data.getData(StringUtil.getLeftPaddedStr(infoId + ".img", '0', 11));
|
||||||
Data reactorInfoData = reactorData.getChildByPath("0");
|
Data reactorInfoData = reactorData.getChildByPath("0");
|
||||||
stats = new MapleReactorStats();
|
stats = new ReactorStats();
|
||||||
List<StateData> statedatas = new ArrayList<>();
|
List<StateData> statedatas = new ArrayList<>();
|
||||||
if (reactorInfoData != null) {
|
if (reactorInfoData != null) {
|
||||||
boolean areaSet = false;
|
boolean areaSet = false;
|
||||||
|
|||||||
@@ -21,22 +21,23 @@
|
|||||||
*/
|
*/
|
||||||
package server.maps;
|
package server.maps;
|
||||||
|
|
||||||
import java.awt.Point;
|
import tools.Pair;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import tools.Pair;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Lerk
|
* @author Lerk
|
||||||
* @author Ronan
|
* @author Ronan
|
||||||
*/
|
*/
|
||||||
public class MapleReactorStats {
|
public class ReactorStats {
|
||||||
private Point tl;
|
private Point tl;
|
||||||
private Point br;
|
private Point br;
|
||||||
private Map<Byte, List<StateData>> stateInfo = new HashMap<>();
|
private final Map<Byte, List<StateData>> stateInfo = new HashMap<>();
|
||||||
private Map<Byte, Integer> timeoutInfo = new HashMap<>();
|
private final Map<Byte, Integer> timeoutInfo = new HashMap<>();
|
||||||
|
|
||||||
public void setTL(Point tl) {
|
public void setTL(Point tl) {
|
||||||
this.tl = tl;
|
this.tl = tl;
|
||||||
@@ -56,7 +57,9 @@ public class MapleReactorStats {
|
|||||||
|
|
||||||
public void addState(byte state, List<StateData> data, int timeOut) {
|
public void addState(byte state, List<StateData> data, int timeOut) {
|
||||||
stateInfo.put(state, data);
|
stateInfo.put(state, data);
|
||||||
if(timeOut > -1) timeoutInfo.put(state, timeOut);
|
if (timeOut > -1) {
|
||||||
|
timeoutInfo.put(state, timeOut);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addState(byte state, int type, Pair<Integer, Integer> reactItem, byte nextState, int timeOut, byte canTouch) {
|
public void addState(byte state, int type, Pair<Integer, Integer> reactItem, byte nextState, int timeOut, byte canTouch) {
|
||||||
@@ -79,7 +82,9 @@ public class MapleReactorStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public byte getNextState(byte state, byte index) {
|
public byte getNextState(byte state, byte index) {
|
||||||
if (stateInfo.get(state) == null || stateInfo.get(state).size() < (index + 1)) return -1;
|
if (stateInfo.get(state) == null || stateInfo.get(state).size() < (index + 1)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
StateData nextState = stateInfo.get(state).get(index);
|
StateData nextState = stateInfo.get(state).get(index);
|
||||||
if (nextState != null) {
|
if (nextState != null) {
|
||||||
return nextState.getNextState();
|
return nextState.getNextState();
|
||||||
@@ -117,10 +122,10 @@ public class MapleReactorStats {
|
|||||||
|
|
||||||
|
|
||||||
public static class StateData {
|
public static class StateData {
|
||||||
private int type;
|
private final int type;
|
||||||
private Pair<Integer, Integer> reactItem;
|
private final Pair<Integer, Integer> reactItem;
|
||||||
private List<Integer> activeSkills;
|
private final List<Integer> activeSkills;
|
||||||
private byte nextState;
|
private final byte nextState;
|
||||||
|
|
||||||
public StateData(int type, Pair<Integer, Integer> reactItem, List<Integer> activeSkills, byte nextState) {
|
public StateData(int type, Pair<Integer, Integer> reactItem, List<Integer> activeSkills, byte nextState) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
Reference in New Issue
Block a user