Skip to content

Commit

Permalink
[Editor|Bug] Doors Not Updating Mesh Orientation When Turning Right (#…
Browse files Browse the repository at this point in the history
…161)

* 💄

* Fixing door rotation not honoring right orientation

* Fixing NullRef in some cases

* Fixing string comparsion
  • Loading branch information
Felix Siebeneicker authored Mar 20, 2021
1 parent 5d88393 commit 0f71e64
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
41 changes: 26 additions & 15 deletions Dungeoneer/src/com/interrupt/dungeoneer/entities/Door.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.interrupt.dungeoneer.Audio;
import com.interrupt.dungeoneer.annotations.EditorProperty;
Expand All @@ -15,17 +14,16 @@
import com.interrupt.dungeoneer.game.Game;
import com.interrupt.dungeoneer.game.Level;
import com.interrupt.dungeoneer.game.Level.Source;
import com.interrupt.dungeoneer.gfx.GlRenderer;
import com.interrupt.dungeoneer.gfx.drawables.DrawableMesh;
import com.interrupt.dungeoneer.gfx.drawables.DrawableSprite;
import com.interrupt.dungeoneer.tiles.Tile;
import com.interrupt.managers.StringManager;

public class Door extends Entity {
public enum DoorState {CLOSED, OPENING, OPEN, CLOSING, STUCK};
public enum DoorOpenType {SLIDE, SLIDE_UP, ROTATE, ROTATE_UP};
public enum DoorDirection {NORTH, SOUTH, EAST, WEST};
public enum DoorType {NORMAL, TRAPDOOR};
public enum DoorState {CLOSED, OPENING, OPEN, CLOSING, STUCK}
public enum DoorOpenType {SLIDE, SLIDE_UP, ROTATE, ROTATE_UP}
public enum DoorDirection {NORTH, SOUTH, EAST, WEST}
public enum DoorType {NORMAL, TRAPDOOR}

/** Door mesh filepath. */
@EditorProperty(type = "FILE_PICKER", params = "meshes")
Expand Down Expand Up @@ -515,7 +513,7 @@ else if (triggerMode == DoorTriggerMode.LOCK_UNLOCK) {
public void updateDrawable() {
// init the drawable
DrawableMesh doorDrawable = null;
if(drawable == null || !(drawable instanceof DrawableMesh) || lastMeshFile != doorMesh ) {
if(!(drawable instanceof DrawableMesh) || (lastMeshFile != null && !lastMeshFile.equals(doorMesh))) {
doorDrawable = new DrawableMesh(doorMesh, doorTexture);
drawable = doorDrawable;
lastMeshFile = doorMesh;
Expand Down Expand Up @@ -600,24 +598,37 @@ else if(doorType == DoorType.TRAPDOOR)
tempDir.set(offset);
}
}

@Override
public void rotate90() {
if(doorDirection == DoorDirection.NORTH) {
if (doorDirection == DoorDirection.NORTH) {
doorDirection = DoorDirection.EAST;
}
else if(doorDirection == DoorDirection.EAST) {
} else if (doorDirection == DoorDirection.EAST) {
doorDirection = DoorDirection.SOUTH;
}
else if(doorDirection == DoorDirection.SOUTH) {
} else if (doorDirection == DoorDirection.SOUTH) {
doorDirection = DoorDirection.WEST;
}
else if(doorDirection == DoorDirection.WEST) {
} else if (doorDirection == DoorDirection.WEST) {
doorDirection = DoorDirection.NORTH;
}

super.rotate90();
}

@Override
public void rotate90Reversed() {
if (doorDirection == DoorDirection.NORTH) {
doorDirection = DoorDirection.WEST;
} else if (doorDirection == DoorDirection.WEST) {
doorDirection = DoorDirection.SOUTH;
} else if (doorDirection == DoorDirection.SOUTH) {
doorDirection = DoorDirection.EAST;
} else if (doorDirection == DoorDirection.EAST) {
doorDirection = DoorDirection.NORTH;
}

super.rotate90Reversed();
}

public String getUseText() {
if(doorState == DoorState.OPEN || doorState == DoorState.OPENING) return StringManager.get("entities.Door.closeUseText");
return StringManager.get("entities.Door.openUseText");
Expand Down
9 changes: 4 additions & 5 deletions Dungeoneer/src/com/interrupt/dungeoneer/game/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,6 @@ else if(marker.type == Markers.boss) {
}
}
else if(marker.type == Markers.door) {
// make a door
Door door = null;

if(genTheme != null && genTheme.doors != null && genTheme.doors.size > 0) {
Expand All @@ -1306,9 +1305,9 @@ else if(marker.type == Markers.door) {
SpawnEntity(door);
door.placeFromPrefab(this);

if(canMakeTrap != null) {
if (x >= 0 && x < width && y >= 0 && y < height)
canMakeTrap[x + y * width] = false;
// Make sure traps cannot spawn around door locations.
if(canMakeTrap != null && x >= 0 && x < width && y >= 0 && y < height) {
canMakeTrap[x + y * width] = false;
}
}
else if(marker.type == Markers.decor || (marker.type == Markers.decorPile && genTheme != null && genTheme.decorations != null)) {
Expand Down Expand Up @@ -1613,7 +1612,7 @@ public Tile getTile(int x, int y)
if(tiles[x + y * width] == null) return Tile.solidWall;
return tiles[x + y * width];
}

public void setTile(int x, int y, Tile t) {
if(x >= 0 && x < width && y >= 0 && y < height) {
tiles[x + y * width] = t;
Expand Down

0 comments on commit 0f71e64

Please sign in to comment.