Refactor GameObject -> Scenery
This commit is contained in:
@@ -49,8 +49,8 @@ public final class PacketRepository {
|
||||
OUTGOING_PACKETS.put(InterfaceConfig.class, new InterfaceConfig()); //
|
||||
OUTGOING_PACKETS.put(PingPacket.class, new PingPacket()); //
|
||||
OUTGOING_PACKETS.put(UpdateAreaPosition.class, new UpdateAreaPosition()); //
|
||||
OUTGOING_PACKETS.put(ConstructObject.class, new ConstructObject()); //
|
||||
OUTGOING_PACKETS.put(ClearObject.class, new ClearObject()); //
|
||||
OUTGOING_PACKETS.put(ConstructScenery.class, new ConstructScenery()); //
|
||||
OUTGOING_PACKETS.put(ClearScenery.class, new ClearScenery()); //
|
||||
OUTGOING_PACKETS.put(HintIcon.class, new HintIcon()); //
|
||||
OUTGOING_PACKETS.put(ClearMinimapFlag.class, new ClearMinimapFlag()); //
|
||||
OUTGOING_PACKETS.put(InteractionOption.class, new InteractionOption()); //
|
||||
|
||||
+9
-9
@@ -1,7 +1,7 @@
|
||||
package core.net.packet.context;
|
||||
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.object.GameObject;
|
||||
import core.game.node.object.Scenery;
|
||||
import core.net.packet.Context;
|
||||
|
||||
/**
|
||||
@@ -9,7 +9,7 @@ import core.net.packet.Context;
|
||||
* construct/clear object outgoing packet.
|
||||
* @author Emperor
|
||||
*/
|
||||
public final class BuildObjectContext implements Context {
|
||||
public final class BuildSceneryContext implements Context {
|
||||
|
||||
/**
|
||||
* The player.
|
||||
@@ -17,18 +17,18 @@ public final class BuildObjectContext implements Context {
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* The list of game objects to send.
|
||||
* The list of scenerys to send.
|
||||
*/
|
||||
private final GameObject gameObject;
|
||||
private final Scenery scenery;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code BuildObjectContext} {@code Object}.
|
||||
* @param player The player
|
||||
* @param gameObject the game object to send.
|
||||
* @param scenery the scenery to send.
|
||||
*/
|
||||
public BuildObjectContext(Player player, GameObject gameObject) {
|
||||
public BuildSceneryContext(Player player, Scenery scenery) {
|
||||
this.player = player;
|
||||
this.gameObject = gameObject;
|
||||
this.scenery = scenery;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,8 +40,8 @@ public final class BuildObjectContext implements Context {
|
||||
* Gets the gameObject.
|
||||
* @return The gameObject.
|
||||
*/
|
||||
public GameObject getGameObject() {
|
||||
return gameObject;
|
||||
public Scenery getScenery() {
|
||||
return scenery;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import core.game.node.entity.npc.NPC;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.GroundItem;
|
||||
import core.game.node.item.GroundItemManager;
|
||||
import core.game.node.object.GameObject;
|
||||
import core.game.node.object.Scenery;
|
||||
import core.game.world.map.Location;
|
||||
import core.game.world.map.RegionManager;
|
||||
import core.net.packet.IncomingPacket;
|
||||
@@ -226,7 +226,7 @@ public final class InteractionPacket implements IncomingPacket {
|
||||
* @param objectId The object id.
|
||||
*/
|
||||
public static void handleObjectInteraction(final Player player, int optionIndex, int x, int y, int objectId) {
|
||||
GameObject object = RegionManager.getObject(player.getLocation().getZ(), x, y, objectId);
|
||||
Scenery object = RegionManager.getObject(player.getLocation().getZ(), x, y, objectId);
|
||||
if (objectId == 29735) {//player safety.
|
||||
player.getPulseManager().run(new MovementPulse(player, Location.create(x, y, player .getLocation().getZ())) {
|
||||
@Override
|
||||
@@ -239,12 +239,12 @@ public final class InteractionPacket implements IncomingPacket {
|
||||
return;
|
||||
}
|
||||
if (objectId == 6898) {
|
||||
object = new GameObject(6898, new Location(3219, 9618));
|
||||
object = new Scenery(6898, new Location(3219, 9618));
|
||||
} else if (objectId == 6899) {
|
||||
object = new GameObject(6899, new Location(3221, 9618));
|
||||
object = new Scenery(6899, new Location(3221, 9618));
|
||||
}
|
||||
if (object == null || object.getId() != objectId) {
|
||||
player.debug("GameObject(" + objectId + ") interaction was " + object + " at location " + x + ", " + y + ".");
|
||||
player.debug("Scenery(" + objectId + ") interaction was " + object + " at location " + x + ", " + y + ".");
|
||||
PacketRepository.send(ClearMinimapFlag.class, new PlayerContext(player));
|
||||
Interaction.handleInvalidInteraction(player, object, Option.NULL);
|
||||
return;
|
||||
|
||||
@@ -10,7 +10,7 @@ import core.game.node.entity.player.Player;
|
||||
import core.game.node.entity.player.link.SpellBookManager;
|
||||
import core.game.node.item.GroundItemManager;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.object.GameObject;
|
||||
import core.game.node.object.Scenery;
|
||||
import rs09.game.node.entity.skill.magic.SpellListener;
|
||||
import rs09.game.node.entity.skill.magic.SpellListeners;
|
||||
import rs09.game.node.entity.skill.magic.SpellUtils;
|
||||
@@ -141,7 +141,7 @@ public class InterfaceUseOnPacket implements IncomingPacket {
|
||||
componentId = payload & 0xFFFF;
|
||||
int objectId = buffer.getShortA();
|
||||
player.debug("Option usage [inter=" + interfaceId + ", child=" + componentId + ", target=(" + objectId + "," + x + "," + y + "), item=" + itemId + "].");
|
||||
GameObject object = RegionManager.getObject(player.getLocation().getZ(), x, y);
|
||||
Scenery object = RegionManager.getObject(player.getLocation().getZ(), x, y);
|
||||
if (object == null) {
|
||||
object = RegionManager.getObject(Location.create(x, y, 0));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import core.game.interaction.UseWithHandler;
|
||||
import core.game.node.entity.npc.NPC;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.object.GameObject;
|
||||
import core.game.node.object.Scenery;
|
||||
import core.game.world.map.RegionManager;
|
||||
import core.net.packet.IncomingPacket;
|
||||
import core.net.packet.IoBuffer;
|
||||
@@ -157,7 +157,7 @@ public class ItemActionPacket implements IncomingPacket {
|
||||
buffer.getShort();
|
||||
int objectId = buffer.getShortA();
|
||||
int z = player.getLocation().getZ();
|
||||
GameObject object = RegionManager.getObject(z, x, y);
|
||||
Scenery object = RegionManager.getObject(z, x, y);
|
||||
if(objectId != 6898) {
|
||||
if (object == null || object.getId() != objectId) {
|
||||
PacketRepository.send(ClearMinimapFlag.class, new PlayerContext(player));
|
||||
@@ -169,7 +169,7 @@ public class ItemActionPacket implements IncomingPacket {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
object = new GameObject(6898,x,y,z);
|
||||
object = new Scenery(6898,x,y,z);
|
||||
}
|
||||
used = player.getInventory().get(slot);
|
||||
if (used == null || used.getId() != id) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package core.net.packet.out;
|
||||
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.object.GameObject;
|
||||
import core.game.node.object.Scenery;
|
||||
import core.game.world.map.Location;
|
||||
import core.game.world.update.flag.context.Animation;
|
||||
import core.net.packet.IoBuffer;
|
||||
@@ -20,7 +20,7 @@ public class AnimateObjectPacket implements OutgoingPacket<AnimateObjectContext>
|
||||
* @param buffer The buffer.
|
||||
*/
|
||||
public static IoBuffer write(IoBuffer buffer, Animation animation) {
|
||||
GameObject object = animation.getObject();
|
||||
Scenery object = animation.getObject();
|
||||
Location l = object.getLocation();
|
||||
buffer.put(20);
|
||||
buffer.putS((l.getChunkOffsetX() << 4) | (l.getChunkOffsetY() & 0x7));
|
||||
@@ -32,7 +32,7 @@ public class AnimateObjectPacket implements OutgoingPacket<AnimateObjectContext>
|
||||
@Override
|
||||
public void send(AnimateObjectContext context) {
|
||||
Player player = context.getPlayer();
|
||||
GameObject object = context.getAnimation().getObject();
|
||||
Scenery object = context.getAnimation().getObject();
|
||||
IoBuffer buffer = write(UpdateAreaPosition.getBuffer(player, object.getLocation().getChunkBase()), context.getAnimation());
|
||||
buffer.cypherOpcode(context.getPlayer().getSession().getIsaacPair().getOutput());player.getSession().write(buffer);
|
||||
}
|
||||
|
||||
+7
-7
@@ -1,24 +1,24 @@
|
||||
package core.net.packet.out;
|
||||
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.object.GameObject;
|
||||
import core.game.node.object.Scenery;
|
||||
import core.game.world.map.Location;
|
||||
import core.net.packet.IoBuffer;
|
||||
import core.net.packet.OutgoingPacket;
|
||||
import core.net.packet.context.BuildObjectContext;
|
||||
import core.net.packet.context.BuildSceneryContext;
|
||||
|
||||
/**
|
||||
* The clear game object outgoing packet.
|
||||
* The clear scenery outgoing packet.
|
||||
* @author Emperor
|
||||
*/
|
||||
public final class ClearObject implements OutgoingPacket<BuildObjectContext> {
|
||||
public final class ClearScenery implements OutgoingPacket<BuildSceneryContext> {
|
||||
|
||||
/**
|
||||
* Writes the packet.
|
||||
* @param buffer The buffer.
|
||||
* @param object The object.
|
||||
*/
|
||||
public static IoBuffer write(IoBuffer buffer, GameObject object) {
|
||||
public static IoBuffer write(IoBuffer buffer, Scenery object) {
|
||||
Location l = object.getLocation();
|
||||
buffer.put(195) // Opcode
|
||||
.putC((object.getType() << 2) + (object.getRotation() & 3)).put((l.getChunkOffsetX() << 4) | (l.getChunkOffsetY() & 0x7));
|
||||
@@ -26,9 +26,9 @@ public final class ClearObject implements OutgoingPacket<BuildObjectContext> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(BuildObjectContext context) {
|
||||
public void send(BuildSceneryContext context) {
|
||||
Player player = context.getPlayer();
|
||||
GameObject o = context.getGameObject();
|
||||
Scenery o = context.getScenery();
|
||||
IoBuffer buffer = write(UpdateAreaPosition.getBuffer(player, o.getLocation().getChunkBase()), o);
|
||||
buffer.cypherOpcode(context.getPlayer().getSession().getIsaacPair().getOutput());player.getSession().write(buffer);
|
||||
|
||||
+7
-7
@@ -1,33 +1,33 @@
|
||||
package core.net.packet.out;
|
||||
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.object.GameObject;
|
||||
import core.game.node.object.Scenery;
|
||||
import core.game.world.map.Location;
|
||||
import core.net.packet.IoBuffer;
|
||||
import core.net.packet.OutgoingPacket;
|
||||
import core.net.packet.context.BuildObjectContext;
|
||||
import core.net.packet.context.BuildSceneryContext;
|
||||
|
||||
/**
|
||||
* The construct game object packet.
|
||||
* The construct scenery packet.
|
||||
* @author Emperor
|
||||
*/
|
||||
public final class ConstructObject implements OutgoingPacket<BuildObjectContext> {
|
||||
public final class ConstructScenery implements OutgoingPacket<BuildSceneryContext> {
|
||||
|
||||
/**
|
||||
* Writes the packet.
|
||||
* @param buffer The buffer.
|
||||
* @param object The object.
|
||||
*/
|
||||
public static IoBuffer write(IoBuffer buffer, GameObject object) {
|
||||
public static IoBuffer write(IoBuffer buffer, Scenery object) {
|
||||
Location l = object.getLocation();
|
||||
buffer.put(179).putA((object.getType() << 2) | (object.getRotation() & 0x3)).put((l.getChunkOffsetX() << 4) | (l.getChunkOffsetY() & 0x7)).putShortA(object.getId());
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(BuildObjectContext context) {
|
||||
public void send(BuildSceneryContext context) {
|
||||
Player player = context.getPlayer();
|
||||
GameObject o = context.getGameObject();
|
||||
Scenery o = context.getScenery();
|
||||
IoBuffer buffer = write(UpdateAreaPosition.getBuffer(player, o.getLocation().getChunkBase()), o);
|
||||
buffer.cypherOpcode(context.getPlayer().getSession().getIsaacPair().getOutput());player.getSession().write(buffer);
|
||||
|
||||
Reference in New Issue
Block a user