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