mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 15:20:52 +01:00
Feature: InteractionPetToy
This commit is contained in:
parent
0cc5b5cb73
commit
f54d185772
@ -1,14 +1,12 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions.pets;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
|
||||
import com.eu.habbo.habbohotel.pets.Pet;
|
||||
import com.eu.habbo.habbohotel.pets.PetTasks;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
|
||||
import com.eu.habbo.habbohotel.rooms.*;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.threading.runnables.PetClearPosture;
|
||||
|
||||
@ -26,13 +24,30 @@ public class InteractionPetToy extends InteractionDefault {
|
||||
this.setExtradata("0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) {}
|
||||
@Override
|
||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||
for (Pet pet : room.getPetsAt(oldLocation)) {
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.packetUpdate = true;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onPickUp(Room room) {
|
||||
for (Pet pet : room.getPetsOnItem(this)) {
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.packetUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
super.onWalkOn(roomUnit, room, objects);
|
||||
|
||||
Pet pet = room.getPet(roomUnit);
|
||||
|
||||
if (pet != null) {
|
||||
if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem()) && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoal())) {
|
||||
if (pet.getEnergy() <= 35) {
|
||||
return;
|
||||
}
|
||||
@ -41,15 +56,16 @@ public class InteractionPetToy extends InteractionDefault {
|
||||
pet.getRoomUnit().setGoalLocation(room.getLayout().getTile(this.getX(), this.getY()));
|
||||
pet.getRoomUnit().setRotation(RoomUserRotation.values()[this.getRotation()]);
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.PLAY, "0");
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.PLAY, pet.getRoomUnit().getCurrentLocation().getStackHeight() + "");
|
||||
pet.packetUpdate = true;
|
||||
HabboItem item = this;
|
||||
Emulator.getThreading().run(() -> {
|
||||
pet.addHappyness(25);
|
||||
item.setExtradata("0");
|
||||
room.updateItem(item);
|
||||
pet.getRoomUnit().clearStatus();
|
||||
new PetClearPosture(pet, RoomUnitStatus.PLAY, null, true).run();
|
||||
pet.packetUpdate = true;
|
||||
}, 2500 + (Emulator.getRandom().nextInt(20) * 500));
|
||||
this.setExtradata("1");
|
||||
room.updateItemState(this);
|
||||
@ -63,11 +79,17 @@ public class InteractionPetToy extends InteractionDefault {
|
||||
Pet pet = room.getPet(roomUnit);
|
||||
|
||||
if (pet != null) {
|
||||
this.setExtradata("0");
|
||||
room.updateItemState(this);
|
||||
pet.getRoomUnit().clearStatus();
|
||||
pet.packetUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
Pet pet = room.getPet(roomUnit);
|
||||
return roomUnit.getRoomUnitType() == RoomUnitType.PET && pet != null && pet.getPetData().haveToyItem(this.getBaseItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowWiredResetState() {
|
||||
return false;
|
||||
|
@ -2390,6 +2390,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.roomSpecialTypes.addPetDrink((InteractionPetDrink) item);
|
||||
} else if (item instanceof InteractionPetFood) {
|
||||
this.roomSpecialTypes.addPetFood((InteractionPetFood) item);
|
||||
} else if (item instanceof InteractionPetToy) {
|
||||
this.roomSpecialTypes.addPetToy((InteractionPetToy) item);
|
||||
} else if (item instanceof InteractionPetTree) {
|
||||
this.roomSpecialTypes.addUndefined(item);
|
||||
} else if (item instanceof InteractionMoodLight) {
|
||||
@ -2542,6 +2544,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
this.roomSpecialTypes.removePetDrink((InteractionPetDrink) item);
|
||||
} else if (item instanceof InteractionPetFood) {
|
||||
this.roomSpecialTypes.removePetFood((InteractionPetFood) item);
|
||||
} else if (item instanceof InteractionPetToy) {
|
||||
this.roomSpecialTypes.removePetToy((InteractionPetToy) item);
|
||||
} else if (item instanceof InteractionPetTree) {
|
||||
this.roomSpecialTypes.removeUndefined(item);
|
||||
} else if (item instanceof InteractionMoodLight) {
|
||||
|
Loading…
Reference in New Issue
Block a user