mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-07-07 00:32:06 +00:00
This update resolves dginovker/2006rebotted#166
Added proper object size calculations. Removed old objectDistance code. Added current task support, allows easy creation of player tasks that cannot duplicate.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package redone.game.objects;
|
||||
|
||||
import redone.world.clip.ObjectDef;
|
||||
|
||||
public class Objects {
|
||||
|
||||
public long delay, oDelay;
|
||||
@@ -36,6 +38,33 @@ public class Objects {
|
||||
objectTicks = ticks;
|
||||
}
|
||||
|
||||
public int[] getObjectSize() {
|
||||
ObjectDef def = ObjectDef.getObjectDef(objectId);
|
||||
if (def == null)
|
||||
return new int[] {1, 1};
|
||||
int xLength;
|
||||
int yLength;
|
||||
if (objectFace != 1 && objectFace != 3) {
|
||||
xLength = def.xLength();
|
||||
yLength = def.yLength();
|
||||
} else {
|
||||
xLength = def.yLength();
|
||||
yLength = def.xLength();
|
||||
}
|
||||
|
||||
return new int[] {xLength, yLength};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Objects{" +
|
||||
"objectId=" + objectId +
|
||||
", objectX=" + objectX +
|
||||
", objectY=" + objectY +
|
||||
", objectHeight=" + objectHeight +
|
||||
'}';
|
||||
}
|
||||
|
||||
public int getObjectHeight() {
|
||||
return objectHeight;
|
||||
}
|
||||
|
||||
@@ -139,8 +139,7 @@ public class Client extends Player {
|
||||
private Mining mining = new Mining();
|
||||
private ChallengePlayer challengePlayer = new ChallengePlayer();
|
||||
private DwarfCannon dwarfCannon = new DwarfCannon(this);
|
||||
|
||||
|
||||
private CycleEventContainer currentTask;
|
||||
|
||||
public DwarfCannon getCannon() {
|
||||
return dwarfCannon;
|
||||
@@ -322,14 +321,6 @@ public class Client extends Player {
|
||||
return witchsPotion;
|
||||
}
|
||||
|
||||
public void setCurrentTask(Future<?> task) {
|
||||
currentTask = task;
|
||||
}
|
||||
|
||||
public Future<?> getCurrentTask() {
|
||||
return currentTask;
|
||||
}
|
||||
|
||||
public synchronized Stream getInStream() {
|
||||
return inStream;
|
||||
}
|
||||
@@ -397,7 +388,19 @@ public class Client extends Player {
|
||||
public Food getFood() {
|
||||
return food;
|
||||
}
|
||||
|
||||
|
||||
public void startCurrentTask(int ticksBetweenExecution, CycleEvent event) {
|
||||
endCurrentTask();
|
||||
currentTask = CycleEventHandler.getSingleton().addEvent(this, event, ticksBetweenExecution);
|
||||
}
|
||||
|
||||
public void endCurrentTask() {
|
||||
if (currentTask != null && currentTask.isRunning()) {
|
||||
currentTask.stop();
|
||||
currentTask = null;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<Integer, TinterfaceText> interfaceText = new HashMap<Integer, TinterfaceText>();
|
||||
|
||||
public class TinterfaceText {
|
||||
@@ -427,7 +430,6 @@ public class Client extends Player {
|
||||
public int lowMemoryVersion = 0;
|
||||
public int timeOutCounter = 0;
|
||||
public int returnCode = 2;
|
||||
private Future<?> currentTask;
|
||||
|
||||
public Client(IoSession s, int _playerId) {
|
||||
super(_playerId);
|
||||
|
||||
@@ -401,7 +401,7 @@ public abstract class Player {
|
||||
totalDamageDealt, globalDamageDealt, oldNpcIndex, fightMode, attackTimer;
|
||||
public boolean magicFailed, oldMagicFailed;
|
||||
public int bowSpecShot, clickNpcType, clickObjectType, objectId, objectX,
|
||||
objectY, objectXOffset, objectYOffset, objectDistance;
|
||||
objectY;
|
||||
public int pItemX, pItemY, pItemId;
|
||||
public boolean isMoving, walkingToItem;
|
||||
public boolean isShopping, updateShop;
|
||||
|
||||
Reference in New Issue
Block a user