Fixed some status issue when walking

This commit is contained in:
Stankman 2023-08-02 16:22:46 -05:00
parent 13a05d1c07
commit a56abbed35
3 changed files with 37 additions and 34 deletions

View File

@ -6,7 +6,7 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum RoomUnitStatus {
MOVE("mv", true),
MOVE("mv"),
// SIT
SIT_IN("sit-in"),

View File

@ -108,13 +108,18 @@ public abstract class RoomUnit extends RoomEntity {
//RoomHabbo
this.isKicked = false;
this.overridableTiles = new THashSet<>();
this.statusUpdateNeeded = false;
}
public RoomItem getCurrentItem() {
return this.room.getRoomItemManager().getTopItemAt(this.currentPosition);
}
public abstract void cycle();
public void cycle() {
if(this.isWalking()) {
this.processWalking();
}
};
@Override
public RoomUnit setCurrentPosition(RoomTile tile) {
@ -291,7 +296,7 @@ public abstract class RoomUnit extends RoomEntity {
RoomItem item = this.room.getRoomItemManager().getTopItemAt(this.currentPosition.getX(), this.currentPosition.getY());
if (item == null || !item.getBaseItem().allowSit() || !item.getBaseItem().allowLay()) {
this.cmdStandEnabled = true;
this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]);
this.bodyRotation = RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2];
this.removeStatus(RoomUnitStatus.SIT);
this.instantUpdate();
}
@ -303,7 +308,7 @@ public abstract class RoomUnit extends RoomEntity {
}
this.cmdSitEnabled = true;
this.setBodyRotation(RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2]);
this.bodyRotation = RoomRotation.values()[this.getBodyRotation().getValue() - this.getBodyRotation().getValue() % 2];
this.addStatus(RoomUnitStatus.SIT, "0.5");
if(this instanceof RoomAvatar roomAvatar) {
@ -474,7 +479,6 @@ public abstract class RoomUnit extends RoomEntity {
* Note: This method is typically called in a loop to facilitate continuous character movement.
*/
public void processWalking() {
if(this.isWalking()) {
this.statuses.entrySet().removeIf(entry -> entry.getKey().isRemoveWhenWalking());
if(this.getNextPosition() != null) {
@ -511,7 +515,6 @@ public abstract class RoomUnit extends RoomEntity {
this.stopWalking();
}
}
}
private RoomRotation handleNextRotation(RoomTile next) {
return RoomRotation.values()[Rotation.Calculate(this.currentPosition.getX(), this.currentPosition.getY(), next.getX(), next.getY())];

View File

@ -53,7 +53,7 @@ public class RoomAvatar extends RoomUnit {
@Override
public void cycle() {
this.handleSignStatus();
this.processWalking();
super.cycle();
}
@Override