Separating DanceType from RoomUnit

This commit is contained in:
Stankman 2023-07-18 15:24:46 -05:00
parent 1c5e1cde61
commit ab529344ef
6 changed files with 33 additions and 35 deletions

View File

@ -1265,7 +1265,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
update = true;
}
} else if (thisTile.getState() == RoomTileState.SIT && (!unit.hasStatus(RoomUnitStatus.SIT) || unit.isSitUpdate())) {
this.dance(unit, DanceType.NONE);
if(unit instanceof RoomAvatar roomAvatar) {
roomAvatar.setDance(DanceType.NONE);
}
unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem)) + "");
unit.setCurrentZ(topItem.getZ());
unit.setRotation(RoomRotation.values()[topItem.getRotation()]);
@ -2852,7 +2854,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return;
}
this.dance(habbo, DanceType.NONE);
habbo.getRoomUnit().setDance(DanceType.NONE);
habbo.getRoomUnit().setCmdSitEnabled(true);
habbo.getRoomUnit().setBodyRotation(RoomRotation.values()[habbo.getRoomUnit().getBodyRotation().getValue() - habbo.getRoomUnit().getBodyRotation().getValue() % 2]);
habbo.getRoomUnit().setStatus(RoomUnitStatus.SIT, 0.5 + "");
@ -3082,7 +3084,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
habbo.getRoomUnit().setIdle();
if (habbo.getRoomUnit().getDanceType() != DanceType.NONE) {
this.dance(habbo, DanceType.NONE);
habbo.getRoomUnit().setDance(DanceType.NONE);
}
this.sendComposer(new SleepMessageComposer(habbo.getRoomUnit()).compose());
@ -3096,24 +3098,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
WiredHandler.handle(WiredTriggerType.UNIDLES, habbo.getRoomUnit(), this, new Object[]{habbo});
}
public void dance(Habbo habbo, DanceType danceType) {
this.dance(habbo.getRoomUnit(), danceType);
}
public void dance(RoomUnit unit, DanceType danceType) {
if (unit.getDanceType() != danceType) {
boolean isDancing = !unit.getDanceType().equals(DanceType.NONE);
unit.setDanceType(danceType);
this.sendComposer(new DanceMessageComposer(unit).compose());
if (danceType.equals(DanceType.NONE) && isDancing) {
WiredHandler.handle(WiredTriggerType.STOPS_DANCING, unit, this, new Object[]{unit});
} else if (!danceType.equals(DanceType.NONE) && !isDancing) {
WiredHandler.handle(WiredTriggerType.STARTS_DANCING, unit, this, new Object[]{unit});
}
}
}
public void addToWordFilter(String word) {
synchronized (this.wordFilterWords) {
if (this.wordFilterWords.contains(word))

View File

@ -16,6 +16,7 @@ import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomTileState;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
import com.eu.habbo.habbohotel.users.DanceType;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
@ -263,9 +264,11 @@ public abstract class RoomItem implements Runnable, IEventTriggers {
WiredHandler.handle(WiredTriggerType.WALKS_ON_FURNI, roomUnit, room, new Object[]{this});
if ((this.getBaseItem().allowSit() || this.getBaseItem().allowLay()) && !roomUnit.getDanceType().equals(DanceType.NONE)) {
roomUnit.setDanceType(DanceType.NONE);
room.sendComposer(new DanceMessageComposer(roomUnit).compose());
if(roomUnit instanceof RoomAvatar roomAvatar) {
if ((this.getBaseItem().allowSit() || this.getBaseItem().allowLay()) && !roomAvatar.getDanceType().equals(DanceType.NONE)) {
roomAvatar.setDanceType(DanceType.NONE);
room.sendComposer(new DanceMessageComposer(roomAvatar).compose());
}
}
if (!this.getBaseItem().getClothingOnWalk().isEmpty() && roomUnit.getPreviousLocation() != roomUnit.getGoalLocation() && roomUnit.getGoalLocation() == room.getLayout().getTile(this.x, this.y)) {

View File

@ -11,7 +11,6 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.rooms.entities.RoomEntity;
import com.eu.habbo.habbohotel.rooms.entities.RoomRotation;
import com.eu.habbo.habbohotel.rooms.entities.items.RoomItem;
import com.eu.habbo.habbohotel.users.DanceType;
import com.eu.habbo.plugin.Event;
import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent;
import com.eu.habbo.plugin.events.roomunit.RoomUnitSetGoalEvent;
@ -103,9 +102,6 @@ public abstract class RoomUnit extends RoomEntity {
private boolean invisible = false;
@Setter
private boolean canLeaveRoomByDoor = true;
@Getter
@Setter
private DanceType danceType;
private int walkTimeOut;
private int previousEffectId;
private int previousEffectEndTimestamp;
@ -135,7 +131,6 @@ public abstract class RoomUnit extends RoomEntity {
this.timeInRoom = 0;
//RoomAvatar
this.danceType = DanceType.NONE;
this.previousEffectId = 0;
this.previousEffectEndTimestamp = -1;
@ -425,7 +420,6 @@ public abstract class RoomUnit extends RoomEntity {
this.fastWalkEnabled = false;
this.cmdTeleportEnabled = false;
this.clearStatuses();
this.danceType = DanceType.NONE;
this.previousEffectId = 0;
this.previousEffectEndTimestamp = -1;
this.isKicked = false;

View File

@ -11,6 +11,9 @@ import com.eu.habbo.habbohotel.rooms.entities.items.types.RoomFloorItem;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.users.DanceType;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.outgoing.rooms.users.DanceMessageComposer;
import com.eu.habbo.messages.outgoing.rooms.users.UserUpdateComposer;
import com.eu.habbo.plugin.Event;
import com.eu.habbo.plugin.events.users.UserIdleEvent;
@ -275,6 +278,20 @@ public class RoomAvatar extends RoomUnit {
return false;
}
}
public void setDance(DanceType danceType) {
if (this.danceType != danceType) {
boolean isDancing = !this.danceType.equals(DanceType.NONE);
this.danceType = danceType;
this.getRoom().sendComposer(new DanceMessageComposer(this).compose());
if (danceType.equals(DanceType.NONE) && isDancing) {
WiredHandler.handle(WiredTriggerType.STOPS_DANCING, this, this.getRoom(), new Object[]{this});
} else if (!danceType.equals(DanceType.NONE) && !isDancing) {
WiredHandler.handle(WiredTriggerType.STARTS_DANCING, this, this.getRoom(), new Object[]{this});
}
}
}
public RoomAvatar setHandItem(int handItem) {
this.handItem = handItem;

View File

@ -468,7 +468,7 @@ public class Habbo extends Unit implements Runnable {
AchievementManager.progressAchievement(target, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectEarned"));
this.client.getHabbo().getRoomUnit().getRoom().unIdle(this.client.getHabbo());
this.client.getHabbo().getRoomUnit().getRoom().dance(this.client.getHabbo().getRoomUnit(), DanceType.NONE);
this.client.getHabbo().getRoomUnit().setDance(DanceType.NONE);
}
}

View File

@ -1,6 +1,6 @@
package com.eu.habbo.messages.outgoing.rooms.users;
import com.eu.habbo.habbohotel.rooms.entities.units.RoomUnit;
import com.eu.habbo.habbohotel.rooms.entities.units.types.RoomAvatar;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
@ -8,14 +8,14 @@ import lombok.AllArgsConstructor;
@AllArgsConstructor
public class DanceMessageComposer extends MessageComposer {
private final RoomUnit roomUnit;
private final RoomAvatar roomAvatar;
@Override
protected ServerMessage composeInternal() {
this.response.init(Outgoing.danceMessageComposer);
this.response.appendInt(this.roomUnit.getVirtualId());
this.response.appendInt(this.roomUnit.getDanceType().getType());
this.response.appendInt(this.roomAvatar.getVirtualId());
this.response.appendInt(this.roomAvatar.getDanceType().getType());
return this.response;
}
}