diff --git a/main_game/assets/maps/building1_player_floor.ron b/main_game/assets/maps/building1_player_floor.ron index 783c90c9..1c267da9 100644 --- a/main_game/assets/maps/building1_player_floor.ron +++ b/main_game/assets/maps/building1_player_floor.ron @@ -146,10 +146,10 @@ (x: -66, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -66, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -66, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -66, y: -24): [Trail, Empty, Local(HallwayZone)], - (x: -66, y: -23): [Empty, Empty, Local(HallwayZone)], - (x: -66, y: -22): [Empty, Empty, Local(HallwayZone)], - (x: -66, y: -21): [Wall, Empty, Local(HallwayZone)], + (x: -66, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], + (x: -66, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], + (x: -66, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], + (x: -66, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], (x: -66, y: -20): [Empty, Empty, Local(HallwayZone)], (x: -66, y: -19): [Empty, Empty, Local(HallwayZone)], (x: -66, y: -18): [Empty, Empty, Local(HallwayZone)], @@ -160,8 +160,8 @@ (x: -65, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -65, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -65, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -65, y: -24): [Trail, Empty, Local(HallwayZone)], - (x: -65, y: -23): [Empty, Empty, Local(HallwayZone)], + (x: -65, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], + (x: -65, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -65, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -65, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], (x: -65, y: -20): [Empty, Empty, Local(HallwayZone)], @@ -174,7 +174,7 @@ (x: -64, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -64, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -64, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -64, y: -24): [Trail, Empty, Local(HallwayZone)], + (x: -64, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -64, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -64, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -64, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], @@ -188,7 +188,7 @@ (x: -63, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -63, y: -26): [Trail, Empty, Local(HallwayZone)], (x: -63, y: -25): [Trail, Empty, Local(HallwayZone)], - (x: -63, y: -24): [Trail, Empty, Local(HallwayZone)], + (x: -63, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -63, y: -23): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -63, y: -22): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -63, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], @@ -202,7 +202,7 @@ (x: -62, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -62, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -62, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -62, y: -24): [Trail, Empty, Local(HallwayZone)], + (x: -62, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -62, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -62, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -62, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], @@ -216,7 +216,7 @@ (x: -61, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -61, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -61, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -61, y: -24): [Trail, Empty, Local(HallwayZone)], + (x: -61, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -61, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -61, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -61, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], @@ -230,7 +230,7 @@ (x: -60, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -60, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -60, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -60, y: -24): [Trail, Empty, Local(HallwayZone)], + (x: -60, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -60, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -60, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -60, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], @@ -244,7 +244,7 @@ (x: -59, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -59, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -59, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -59, y: -24): [Trail, Empty, Local(HallwayZone)], + (x: -59, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -59, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -59, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -59, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], @@ -258,7 +258,7 @@ (x: -58, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -58, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -58, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -58, y: -24): [Trail, Empty, Local(HallwayZone)], + (x: -58, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -58, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -58, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -58, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], @@ -289,7 +289,7 @@ (x: -57, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -57, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -57, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -57, y: -24): [Trail, Empty, Local(HallwayZone)], + (x: -57, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -57, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -57, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -57, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], @@ -320,7 +320,7 @@ (x: -56, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -56, y: -26): [Trail, Empty, Local(HallwayZone)], (x: -56, y: -25): [Trail, Empty, Local(HallwayZone)], - (x: -56, y: -24): [Trail, Empty, Local(HallwayZone)], + (x: -56, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -56, y: -23): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -56, y: -22): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -56, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], @@ -351,7 +351,7 @@ (x: -55, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -55, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -55, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -55, y: -24): [Trail, Empty, Local(HallwayZone)], + (x: -55, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -55, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -55, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -55, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], @@ -382,7 +382,7 @@ (x: -54, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -54, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -54, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -54, y: -24): [Trail, Empty, Local(HallwayZone)], + (x: -54, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -54, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -54, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -54, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], @@ -413,7 +413,7 @@ (x: -53, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -53, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -53, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -53, y: -24): [Trail, Empty, Local(HallwayZone)], + (x: -53, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -53, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -53, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -53, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], @@ -444,7 +444,7 @@ (x: -52, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -52, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -52, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -52, y: -24): [Trail, Empty, Local(HallwayZone)], + (x: -52, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -52, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -52, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -52, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], @@ -471,7 +471,7 @@ (x: -51, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -51, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -51, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -51, y: -24): [Trail, Empty, Local(HallwayZone)], + (x: -51, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], (x: -51, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -51, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -51, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], @@ -498,8 +498,8 @@ (x: -50, y: -27): [Trail, Empty, Local(HallwayZone)], (x: -50, y: -26): [Empty, Empty, Local(HallwayZone)], (x: -50, y: -25): [Empty, Empty, Local(HallwayZone)], - (x: -50, y: -24): [Trail, Empty, Local(HallwayZone)], - (x: -50, y: -23): [Empty, Empty, Local(HallwayZone)], + (x: -50, y: -24): [Trail, Local(ElevatorZone), Local(HallwayZone)], + (x: -50, y: -23): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -50, y: -22): [Empty, Local(ElevatorZone), Local(HallwayZone)], (x: -50, y: -21): [Wall, Local(ElevatorZone), Local(HallwayZone)], (x: -50, y: 3): [Wall], @@ -2551,10 +2551,10 @@ (x: -7, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: -7, y: 8): [Empty, Empty, Local(PlayerApartmentZone)], (x: -7, y: 9): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -7, y: 10): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -7, y: 11): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -7, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -7, y: 13): [Wall, Empty, Local(PlayerApartmentZone)], + (x: -7, y: 10): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -7, y: 11): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -7, y: 12): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -7, y: 13): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -7, y: 14): [Wall, Empty, Local(PlayerApartmentZone)], (x: -7, y: 15): [Wall, Empty, Local(PlayerApartmentZone)], (x: -7, y: 16): [Wall, Empty, Local(PlayerApartmentZone)], @@ -2602,10 +2602,10 @@ (x: -6, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: -6, y: 8): [Empty, Empty, Local(PlayerApartmentZone)], (x: -6, y: 9): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -6, y: 10): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -6, y: 11): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -6, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -6, y: 13): [Empty, Empty, Local(PlayerApartmentZone)], + (x: -6, y: 10): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -6, y: 11): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -6, y: 12): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -6, y: 13): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -6, y: 14): [Wall, Empty, Local(PlayerApartmentZone)], (x: -6, y: 15): [Wall, Empty, Local(PlayerApartmentZone)], (x: -6, y: 16): [Wall, Empty, Local(PlayerApartmentZone)], @@ -2632,9 +2632,9 @@ (x: -5, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: -5, y: 8): [Empty, Empty, Local(PlayerApartmentZone)], (x: -5, y: 9): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -5, y: 10): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -5, y: 11): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -5, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], + (x: -5, y: 10): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -5, y: 11): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -5, y: 12): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -5, y: 13): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -5, y: 14): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -5, y: 15): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], @@ -2662,9 +2662,9 @@ (x: -4, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: -4, y: 8): [Empty, Empty, Local(PlayerApartmentZone)], (x: -4, y: 9): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -4, y: 10): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -4, y: 11): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -4, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], + (x: -4, y: 10): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -4, y: 11): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -4, y: 12): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -4, y: 13): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -4, y: 14): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -4, y: 15): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], @@ -2692,9 +2692,9 @@ (x: -3, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: -3, y: 8): [Empty, Empty, Local(PlayerApartmentZone)], (x: -3, y: 9): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -3, y: 10): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -3, y: 11): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -3, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], + (x: -3, y: 10): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -3, y: 11): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -3, y: 12): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -3, y: 13): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -3, y: 14): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -3, y: 15): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], @@ -2722,9 +2722,9 @@ (x: -2, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: -2, y: 8): [Empty, Empty, Local(PlayerApartmentZone)], (x: -2, y: 9): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -2, y: 10): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -2, y: 11): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -2, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], + (x: -2, y: 10): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -2, y: 11): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -2, y: 12): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -2, y: 13): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -2, y: 14): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -2, y: 15): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], @@ -2752,9 +2752,9 @@ (x: -1, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: -1, y: 8): [Empty, Empty, Local(PlayerApartmentZone)], (x: -1, y: 9): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -1, y: 10): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -1, y: 11): [Empty, Empty, Local(PlayerApartmentZone)], - (x: -1, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], + (x: -1, y: 10): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -1, y: 11): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: -1, y: 12): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -1, y: 13): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -1, y: 14): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: -1, y: 15): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], @@ -2782,9 +2782,9 @@ (x: 0, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: 0, y: 8): [Empty, Empty, Local(PlayerApartmentZone)], (x: 0, y: 9): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 0, y: 10): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 0, y: 11): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 0, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], + (x: 0, y: 10): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 0, y: 11): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 0, y: 12): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 0, y: 13): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 0, y: 14): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 0, y: 15): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], @@ -2812,9 +2812,9 @@ (x: 1, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: 1, y: 8): [Wall, Empty, Local(PlayerApartmentZone)], (x: 1, y: 9): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 1, y: 10): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 1, y: 11): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 1, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], + (x: 1, y: 10): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 1, y: 11): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 1, y: 12): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 1, y: 13): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 1, y: 14): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 1, y: 15): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], @@ -2842,9 +2842,9 @@ (x: 2, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: 2, y: 8): [Wall, Empty, Local(PlayerApartmentZone)], (x: 2, y: 9): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 2, y: 10): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 2, y: 11): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 2, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], + (x: 2, y: 10): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 2, y: 11): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 2, y: 12): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 2, y: 13): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 2, y: 14): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 2, y: 15): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], @@ -2872,9 +2872,9 @@ (x: 3, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: 3, y: 8): [Wall, Empty, Local(PlayerApartmentZone)], (x: 3, y: 9): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 3, y: 10): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 3, y: 11): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 3, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], + (x: 3, y: 10): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 3, y: 11): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 3, y: 12): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 3, y: 13): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 3, y: 14): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 3, y: 15): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], @@ -2902,9 +2902,9 @@ (x: 4, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: 4, y: 8): [Wall, Empty, Local(PlayerApartmentZone)], (x: 4, y: 9): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 4, y: 10): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 4, y: 11): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 4, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], + (x: 4, y: 10): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 4, y: 11): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 4, y: 12): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 4, y: 13): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 4, y: 14): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 4, y: 15): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], @@ -2932,9 +2932,9 @@ (x: 5, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: 5, y: 8): [Empty, Empty, Local(PlayerApartmentZone)], (x: 5, y: 9): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 5, y: 10): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 5, y: 11): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 5, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], + (x: 5, y: 10): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 5, y: 11): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 5, y: 12): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 5, y: 13): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 5, y: 14): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 5, y: 15): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], @@ -2962,9 +2962,9 @@ (x: 6, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: 6, y: 8): [Empty, Empty, Local(PlayerApartmentZone)], (x: 6, y: 9): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 6, y: 10): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 6, y: 11): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 6, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], + (x: 6, y: 10): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 6, y: 11): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 6, y: 12): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 6, y: 13): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 6, y: 14): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 6, y: 15): [Empty, Local(MeditationZone), Local(PlayerApartmentZone)], @@ -2992,9 +2992,9 @@ (x: 7, y: 7): [Empty, Empty, Local(PlayerApartmentZone)], (x: 7, y: 8): [Wall, Empty, Local(PlayerApartmentZone)], (x: 7, y: 9): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 7, y: 10): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 7, y: 11): [Wall, Empty, Local(PlayerApartmentZone)], - (x: 7, y: 12): [Wall, Empty, Local(PlayerApartmentZone)], + (x: 7, y: 10): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 7, y: 11): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], + (x: 7, y: 12): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 7, y: 13): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 7, y: 14): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], (x: 7, y: 15): [Wall, Local(MeditationZone), Local(PlayerApartmentZone)], @@ -3387,11 +3387,11 @@ (x: 20, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], (x: 20, y: 13): [Empty, Empty, Local(PlayerApartmentZone)], (x: 20, y: 14): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 20, y: 15): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 20, y: 16): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 20, y: 17): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 20, y: 18): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 20, y: 19): [Wall, Empty, Local(PlayerApartmentZone)], + (x: 20, y: 15): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 20, y: 16): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 20, y: 17): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 20, y: 18): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 20, y: 19): [Wall, Local(TeaZone), Local(PlayerApartmentZone)], (x: 20, y: 20): [Empty, Empty, Local(PlayerApartmentZone)], (x: 21, y: -30): [Empty, Empty, Local(HallwayZone)], (x: 21, y: -29): [Empty, Empty, Local(HallwayZone)], @@ -3417,8 +3417,8 @@ (x: 21, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], (x: 21, y: 13): [Empty, Empty, Local(PlayerApartmentZone)], (x: 21, y: 14): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 21, y: 15): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 21, y: 16): [Empty, Empty, Local(PlayerApartmentZone)], + (x: 21, y: 15): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 21, y: 16): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 21, y: 17): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 21, y: 18): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 21, y: 19): [Wall, Local(TeaZone), Local(PlayerApartmentZone)], @@ -3447,8 +3447,8 @@ (x: 22, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], (x: 22, y: 13): [Empty, Empty, Local(PlayerApartmentZone)], (x: 22, y: 14): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 22, y: 15): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 22, y: 16): [Empty, Empty, Local(PlayerApartmentZone)], + (x: 22, y: 15): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 22, y: 16): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 22, y: 17): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 22, y: 18): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 22, y: 19): [Wall, Local(TeaZone), Local(PlayerApartmentZone)], @@ -3477,8 +3477,8 @@ (x: 23, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], (x: 23, y: 13): [Empty, Empty, Local(PlayerApartmentZone)], (x: 23, y: 14): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 23, y: 15): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 23, y: 16): [Empty, Empty, Local(PlayerApartmentZone)], + (x: 23, y: 15): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 23, y: 16): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 23, y: 17): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 23, y: 18): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 23, y: 19): [Wall, Local(TeaZone), Local(PlayerApartmentZone)], @@ -3507,8 +3507,8 @@ (x: 24, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], (x: 24, y: 13): [Empty, Empty, Local(PlayerApartmentZone)], (x: 24, y: 14): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 24, y: 15): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 24, y: 16): [Empty, Empty, Local(PlayerApartmentZone)], + (x: 24, y: 15): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 24, y: 16): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 24, y: 17): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 24, y: 18): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 24, y: 19): [Wall, Local(TeaZone), Local(PlayerApartmentZone)], @@ -3537,8 +3537,8 @@ (x: 25, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], (x: 25, y: 13): [Empty, Empty, Local(PlayerApartmentZone)], (x: 25, y: 14): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 25, y: 15): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 25, y: 16): [Empty, Empty, Local(PlayerApartmentZone)], + (x: 25, y: 15): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 25, y: 16): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 25, y: 17): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 25, y: 18): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 25, y: 19): [Wall, Local(TeaZone), Local(PlayerApartmentZone)], @@ -3567,8 +3567,8 @@ (x: 26, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], (x: 26, y: 13): [Empty, Empty, Local(PlayerApartmentZone)], (x: 26, y: 14): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 26, y: 15): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 26, y: 16): [Empty, Empty, Local(PlayerApartmentZone)], + (x: 26, y: 15): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 26, y: 16): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 26, y: 17): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 26, y: 18): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 26, y: 19): [Wall, Local(TeaZone), Local(PlayerApartmentZone)], @@ -3597,8 +3597,8 @@ (x: 27, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], (x: 27, y: 13): [Empty, Empty, Local(PlayerApartmentZone)], (x: 27, y: 14): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 27, y: 15): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 27, y: 16): [Empty, Empty, Local(PlayerApartmentZone)], + (x: 27, y: 15): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 27, y: 16): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 27, y: 17): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 27, y: 18): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], (x: 27, y: 19): [Wall, Local(TeaZone), Local(PlayerApartmentZone)], @@ -3627,11 +3627,11 @@ (x: 28, y: 12): [Empty, Empty, Local(PlayerApartmentZone)], (x: 28, y: 13): [Empty, Empty, Local(PlayerApartmentZone)], (x: 28, y: 14): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 28, y: 15): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 28, y: 16): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 28, y: 17): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 28, y: 18): [Empty, Empty, Local(PlayerApartmentZone)], - (x: 28, y: 19): [Wall, Empty, Local(PlayerApartmentZone)], + (x: 28, y: 15): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 28, y: 16): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 28, y: 17): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 28, y: 18): [Empty, Local(TeaZone), Local(PlayerApartmentZone)], + (x: 28, y: 19): [Wall, Local(TeaZone), Local(PlayerApartmentZone)], (x: 28, y: 20): [Empty, Empty, Local(PlayerApartmentZone)], (x: 29, y: -30): [Empty, Empty, Local(HallwayZone)], (x: 29, y: -29): [Empty, Empty, Local(HallwayZone)], diff --git a/main_game/assets/scenes/building1_player_floor.tscn b/main_game/assets/scenes/building1_player_floor.tscn index 20c80a25..b97122e8 100644 --- a/main_game/assets/scenes/building1_player_floor.tscn +++ b/main_game/assets/scenes/building1_player_floor.tscn @@ -444,17 +444,17 @@ metadata/zone = "MeditationZone" metadata/action = "StartMeditation" metadata/label = "Meditate" -[node name="WinnieSleeping" type="Sprite2D" parent="BackwallFurniture"] +[node name="WinnieMeditating" type="Sprite2D" parent="BackwallFurniture/MeditationChair"] visible = false self_modulate = Color(1, 1, 1, 0.823529) -position = Vector2(-70, -67.5) -texture = ExtResource("5_u86a4") +position = Vector2(3, 0) +texture = ExtResource("6_5id1h") -[node name="WinnieMeditating" type="Sprite2D" parent="BackwallFurniture"] +[node name="WinnieSleeping" type="Sprite2D" parent="BackwallFurniture"] visible = false self_modulate = Color(1, 1, 1, 0.823529) -position = Vector2(41, -84) -texture = ExtResource("6_5id1h") +position = Vector2(-70, -67.5) +texture = ExtResource("5_u86a4") [node name="Toilet" type="Sprite2D" parent="."] z_index = 2 diff --git a/main_game_lib/src/top_down.rs b/main_game_lib/src/top_down.rs index aaaef414..0869e4d8 100644 --- a/main_game_lib/src/top_down.rs +++ b/main_game_lib/src/top_down.rs @@ -135,21 +135,19 @@ where app.register_type::() .add_systems( Update, - inspect_and_interact::show_all_in_vicinity - .run_if(in_state(running)) - .run_if(common_action::inspect_pressed()), + ( + inspect_and_interact::highlight_what_would_be_interacted_with, + inspect_and_interact::show_all_in_vicinity + .run_if(common_action::inspect_pressed()), + ) + .chain() // easier to think about + .run_if(in_state(running)), ) .add_systems( Update, inspect_and_interact::schedule_hide_all .run_if(in_state(running)) .run_if(common_action::inspect_just_released()), - ) - .add_systems( - Update, - inspect_and_interact::cancel_hide_all - .run_if(in_state(running)) - .run_if(common_action::inspect_just_pressed()), ); debug!("Adding interaction systems for {}", T::type_path()); diff --git a/main_game_lib/src/top_down/inspect_and_interact.rs b/main_game_lib/src/top_down/inspect_and_interact.rs index bc78de43..58765e4c 100644 --- a/main_game_lib/src/top_down/inspect_and_interact.rs +++ b/main_game_lib/src/top_down/inspect_and_interact.rs @@ -20,11 +20,13 @@ use std::{borrow::Cow, time::Duration}; use bevy::{prelude::*, utils::HashMap}; +use common_action::{ActionState, GlobalAction}; use common_ext::QueryExt; use common_store::{GlobalStore, InspectAbilityStore}; use common_visuals::{ camera::PIXEL_ZOOM, BeginInterpolationEvent, ColorInterpolation, }; +use lazy_static::lazy_static; use strum::EnumString; use super::actor::player::TakeAwayPlayerControl; @@ -77,6 +79,17 @@ pub struct InspectLabel { emit_event_on_interacted: Option>, } +/// Present in those entities with [`InspectLabel`] that have their label +/// currently displayed. +#[derive(Component, Reflect)] +pub(crate) struct InspectLabelDisplayed { + bg: Entity, + text: Entity, + category_color: Color, + /// It's a fade out animation + being_hidden: bool, +} + /// Entities with [`InspectLabel`] and this component are considered when the /// player hits the interact button. /// The closest entity is chosen by default, but the player can change their @@ -88,6 +101,13 @@ pub struct InspectLabel { #[derive(Component)] pub struct ReadyForInteraction; +/// What entity with [`ReadyForInteraction`] component is the one that would +/// be interacted with if the player pressed the interact button. +/// +/// Only one entity can be highlighted at a time. +#[derive(Component)] +pub struct HighlightedForInteraction; + /// Different categories can have different radius of visibility based on the /// player's experience. #[derive(Default, Reflect, Clone, Copy, Debug, EnumString)] @@ -152,175 +172,274 @@ pub(crate) fn match_interact_label_with_action_event( } } -/// This is registered in [`crate::top_down::default_setup_for_scene`]. +/// We want the player to know what would be interacted with if they clicked +/// the interact button. /// -/// Any logic that listens to [`ActionEvent`]s should be ordered _after_ this. -pub fn interact( +/// 1. Find the closest entity with [`InspectLabel`] +/// 2. Set that entity as highlighted +pub(crate) fn highlight_what_would_be_interacted_with( mut cmd: Commands, + asset_server: Res, + mut begin_interpolation: EventWriter, + controls: Res>, player: Query< &GlobalTransform, (With, Without), >, - inspectable_objects: Query< - (&InspectLabel, &GlobalTransform), + highlighted: Query< + (Entity, &InspectLabel, &InspectLabelDisplayed), + With, + >, + inspectable: Query< + ( + Entity, + &InspectLabel, + Option<&InspectLabelDisplayed>, + &GlobalTransform, + ), With, >, ) { + let mut remove_old_highlight_if_present = || { + if let Some((highlighted, label, old_displayed)) = + highlighted.get_single_or_none() + { + cmd.entity(highlighted) + .remove::(); + + cmd.entity(old_displayed.bg).despawn(); + cmd.entity(old_displayed.text).despawn(); + + let mut new_displayed = + spawn_label_bg_and_text(&mut cmd, &asset_server, label, false); + if !controls.pressed(&GlobalAction::Inspect) { + new_displayed + .schedule_hide(&mut begin_interpolation, highlighted); + } + cmd.entity(highlighted) + .add_child(new_displayed.bg) + .add_child(new_displayed.text) + .insert(new_displayed); + } + }; + + // + // 1. + // let Some(player) = player.get_single_or_none() else { return; }; let player = player.translation().truncate(); - let closest = inspectable_objects + let Some((closest, label, displayed, _)) = inspectable .iter() - .filter(|(label, _)| label.emit_event_on_interacted.is_some()) // ! - .map(|(label, transform)| { + // important to filter out entities without an event because those can + // never be interacted with + // + // the system [`interact`] assumes on this condition + .filter(|(_, label, _, _)| label.emit_event_on_interacted.is_some()) + .map(|(entity, label, displayed, transform)| { let distance = transform.translation().truncate().distance(player); - (label, distance) + (entity, label, displayed, distance) }) - .min_by(|(_, a), (_, b)| { + .min_by(|(_, _, _, a), (_, _, _, b)| { a.partial_cmp(b).expect("distance is always a number") }) - .map(|(label, _)| label); + else { + remove_old_highlight_if_present(); + return; + }; + + // + // 2. + // + + let highlighted_matches_closest = + highlighted.get_single_or_none().is_some_and( + |(highlighted_entity, _, _)| highlighted_entity == closest, + ); + if highlighted_matches_closest { + // nothing to do, already in the state we want + return; + } - if let Some(closest) = closest { - let event = closest.emit_event_on_interacted.as_ref().unwrap(); // ! + remove_old_highlight_if_present(); - event.send_deferred(&mut cmd); + if let Some(InspectLabelDisplayed { bg, text, .. }) = displayed { + cmd.entity(*bg).despawn(); + cmd.entity(*text).despawn(); } + + let displayed = + spawn_label_bg_and_text(&mut cmd, &asset_server, label, true); + cmd.entity(closest) + // Q: What if interpolation just finished in this frame and removed this + // component? + // Don't we need to order this system after the interpolation system? + // A: No, because interpolation runs on FixedUpdate schedule. + .insert(HighlightedForInteraction) + .add_child(displayed.bg) + .add_child(displayed.text) + .insert(displayed); +} + +/// This is registered in [`crate::top_down::default_setup_for_scene`]. +/// +/// Any logic that listens to [`ActionEvent`]s should be ordered _after_ this. +pub fn interact( + mut cmd: Commands, + + label: Query<&InspectLabel, With>, +) { + let Some(InspectLabel { + // this will always be Some because we only insert the component + // HighlightedForInteraction to inspect labels with an event + emit_event_on_interacted: Some(event), + .. + }) = label.get_single_or_none() + else { + return; + }; + + event.send_deferred(&mut cmd); } /// Run this when action [`GlobalAction::Inspect`] is pressed. /// It updates labels that come into the vicinity of the player. +#[allow(clippy::too_many_arguments)] pub(crate) fn show_all_in_vicinity( mut cmd: Commands, store: Res, asset_server: Res, + mut begin_interpolation: EventWriter, player: Query<&GlobalTransform, With>, - inspectable_objects: Query<( + mut inspectable_objects: Query<( Entity, &InspectLabel, &GlobalTransform, - Option<&Children>, + Option<&mut InspectLabelDisplayed>, + Option<&ReadyForInteraction>, )>, + mut texts: Query<&mut Text, With>, + mut bgs: Query<&mut Sprite, With>, ) { let Some(player) = player.get_single_or_none() else { return; }; let player = player.translation().truncate(); - for (entity, label, position, children) in inspectable_objects.iter() { + for (entity, label, position, displayed, ready_for_interaction) in + inspectable_objects.iter_mut() + { store.mark_as_seen(&label.display); let distance = player.distance(position.translation().truncate()); - let should_be_shown = distance <= label.category.max_distance(); + let should_be_shown = distance <= label.category.max_distance() + || ready_for_interaction.is_some(); - match (should_be_shown, children) { + match (should_be_shown, displayed) { // should not be shown and it's not, do nothing (false, None) => {} - // should be shown and is, we don't have to do anything here because - // `cancel_hide_all` got us covered + // should be shown, but is scheduled to be hidden, cancel that + (true, Some(mut displayed)) if displayed.being_hidden => { + displayed.cancel_hide(&mut cmd, &mut texts, &mut bgs); + } + // should be shown and is, we don't have to do anything here (true, Some(_)) => {} + // should not be shown and it is scheduled to be hidden, do nothing + (false, Some(displayed)) if displayed.being_hidden => {} // should not be shown and it is, hide it - (false, Some(children)) => { - trace!("Label {} going out of the view", label.display); - - cmd.entity(entity).remove::(); - for child in children { - cmd.entity(*child).despawn(); - } + (false, Some(mut displayed)) => { + displayed.schedule_hide(&mut begin_interpolation, entity); } // should be shown and it's not, show it (true, None) => { - trace!("Displaying label {}", label.display); - - let font_size = label.category.font_zone(); - - // bit of padding and then a few pixels per character - // this is easier than waiting for the text to be rendered and - // then using the logical size, and the impression doesn't - // matter for such a short text - let bg_box_width = - font_size + font_size / 7.0 * label.display.len() as f32; - let bg = cmd - .spawn(InspectLabelBg) - .insert(SpriteBundle { - transform: Transform::from_translation(Vec3::Z), - sprite: Sprite { - color: HALF_TRANSPARENT, - custom_size: Some(Vec2::new( - bg_box_width, - font_size / 2.0, - )), - ..default() - }, - ..default() - }) - .id(); - - // make it stand above others with zindex - let txt = cmd - .spawn(InspectLabelText) - .insert(Text2dBundle { - // We invert the pixel camera zoom, otherwise we'd end - // up with pixelated text. - // We end up using larger font size instead. - transform: Transform::from_translation(Vec3::Z * 2.0) - .with_scale(Vec3::splat(1.0 / PIXEL_ZOOM as f32)), - text: Text { - sections: vec![TextSection::new( - label.display.clone(), - TextStyle { - font: asset_server.load( - common_assets::fonts::TINY_PIXEL1, - ), - font_size, - color: label.category.color(), - }, - )], - linebreak_behavior: bevy::text::BreakLineOn::NoWrap, - ..default() - }, - ..default() - }) - .id(); - - cmd.entity(entity).insert_children(0, &[bg, txt]); + let displayed = spawn_label_bg_and_text( + &mut cmd, + &asset_server, + label, + false, + ); + cmd.entity(entity) + .add_child(displayed.bg) + .add_child(displayed.text) + .insert(displayed); } } - - if distance >= label.category.max_distance() { - continue; - } } } -/// Run this when action [`GlobalAction::Inspect`] is just pressed. -/// It cancels eventual [`schedule_hide_all`] call that scheduled the fade out -/// and removal of the box. -pub(crate) fn cancel_hide_all( - mut cmd: Commands, - - inspectable_objects: Query<&InspectLabel>, - mut text: Query<(Entity, &Parent, &mut Text), With>, - mut bg: Query<(Entity, &mut Sprite), With>, -) { - for (entity, parent, mut text) in text.iter_mut() { - let parent = parent.get(); - let color = inspectable_objects.get(parent).unwrap().category.color(); - text.sections[0].style.color = color; - - cmd.entity(entity).remove::(); - } +/// Attach the result as a component to the label's entity and the bg and text +/// children to the labels' entity. +fn spawn_label_bg_and_text( + cmd: &mut Commands, + asset_server: &Res, + label: &InspectLabel, + highlighted: bool, +) -> InspectLabelDisplayed { + trace!("Displaying label {}", label.display); + + let font_size = + label.category.font_zone() + if highlighted { 3.0 } else { 0.0 }; + + // We set this to be the zindex of the bg and text. + // This is a dirty hack that puts the label always in front of everything. + const Z_INDEX: f32 = 10.0; + + // bit of padding and then a few pixels per character + // this is easier than waiting for the text to be rendered and + // then using the logical size, and the impression doesn't + // matter for such a short text + let bg_box_width = font_size + font_size / 7.0 * label.display.len() as f32; + let bg = cmd + .spawn(InspectLabelBg) + .insert(SpriteBundle { + transform: Transform::from_translation(Vec3::Z * Z_INDEX), + sprite: Sprite { + color: HALF_TRANSPARENT * if highlighted { 1.5 } else { 1.0 }, + custom_size: Some(Vec2::new(bg_box_width, font_size / 2.0)), + ..default() + }, + ..default() + }) + .id(); + + // make it stand above others with zindex + let text = cmd + .spawn(InspectLabelText) + .insert(Text2dBundle { + // We invert the pixel camera zoom, otherwise we'd end + // up with pixelated text. + // We end up using larger font size instead. + transform: Transform::from_translation(Vec3::Z * Z_INDEX * 1.01) + .with_scale(Vec3::splat(1.0 / PIXEL_ZOOM as f32)), + text: Text { + sections: vec![TextSection::new( + label.display.clone(), + TextStyle { + font: asset_server + .load(common_assets::fonts::TINY_PIXEL1), + font_size, + color: label.category.color(), + }, + )], + linebreak_behavior: bevy::text::BreakLineOn::NoWrap, + ..default() + }, + ..default() + }) + .id(); - for (entity, mut sprite) in bg.iter_mut() { - sprite.color = HALF_TRANSPARENT; - cmd.entity(entity).remove::(); + InspectLabelDisplayed { + bg, + text, + category_color: label.category.color(), + being_hidden: false, } } @@ -329,44 +448,78 @@ pub(crate) fn cancel_hide_all( pub(crate) fn schedule_hide_all( mut begin_interpolation: EventWriter, - inspectable_objects: Query<&InspectLabel>, - text: Query<(Entity, &Parent), With>, - bg: Query>, + mut inspectable_objects: Query< + (Entity, &mut InspectLabelDisplayed), + Without, + >, ) { - // looks better when the text fades out faster than the bg - let text_animation_curve = - CubicSegment::new_bezier((0.9, 0.05), (0.9, 1.0)); - let bg_animation_curve = - CubicSegment::new_bezier((0.95, 0.01), (0.95, 1.0)); - - for (entity, parent) in text.iter() { - let parent = parent.get(); + for (entity, mut displayed) in inspectable_objects.iter_mut() { + displayed.schedule_hide(&mut begin_interpolation, entity); + } +} + +impl InspectLabelDisplayed { + fn schedule_hide( + &mut self, + begin_interpolation: &mut EventWriter, + label_entity: Entity, + ) { + self.being_hidden = true; + let bg = self.bg; + let text = self.text; let to_color = { - let mut c = - inspectable_objects.get(parent).unwrap().category.color(); + let mut c = self.category_color; c.set_a(0.0); c }; + // looks better when the text fades out faster than the bg + lazy_static! { + static ref TEXT_ANIMATION_CURVE: CubicSegment = + CubicSegment::new_bezier((0.9, 0.05), (0.9, 1.0)); + static ref BG_ANIMATION_CURVE: CubicSegment = + CubicSegment::new_bezier((0.95, 0.01), (0.95, 1.0)); + } + begin_interpolation.send( - BeginInterpolationEvent::of_color(entity, None, to_color) + BeginInterpolationEvent::of_color(text, None, to_color) .over(FADE_OUT_IN) - .with_animation_curve(text_animation_curve.clone()) + .with_animation_curve(TEXT_ANIMATION_CURVE.clone()) .when_finished_do(move |cmd| { - cmd.entity(parent).remove::(); - cmd.entity(entity).despawn(); + cmd.entity(label_entity).remove::(); + cmd.entity(text).despawn(); }), ); - } - for entity in bg.iter() { begin_interpolation.send( - BeginInterpolationEvent::of_color(entity, None, Color::NONE) + BeginInterpolationEvent::of_color(bg, None, Color::NONE) .over(FADE_OUT_IN) - .with_animation_curve(bg_animation_curve.clone()) + .with_animation_curve(BG_ANIMATION_CURVE.clone()) .when_finished_despawn_itself(), ); } + + fn cancel_hide( + &mut self, + cmd: &mut Commands, + texts: &mut Query<&mut Text, With>, + bgs: &mut Query<&mut Sprite, With>, + ) { + cmd.entity(self.bg).remove::(); + bgs.get_mut(self.bg) + .expect("BG must exist if display exists") + .color = HALF_TRANSPARENT; + + cmd.entity(self.text).remove::(); + texts + .get_mut(self.text) + .expect("Text must exist if display exists") + .sections[0] + .style + .color = self.category_color; + + self.being_hidden = false; + } } impl InspectLabelCategory { diff --git a/main_game_lib/src/top_down/layout/map_maker.rs b/main_game_lib/src/top_down/layout/map_maker.rs index 9795f0d9..ffdf62ba 100644 --- a/main_game_lib/src/top_down/layout/map_maker.rs +++ b/main_game_lib/src/top_down/layout/map_maker.rs @@ -68,8 +68,6 @@ pub(crate) struct DebugLayoutGrid; pub(crate) fn update_ui( mut contexts: EguiContexts, mut toolbar: ResMut>, - - mut grid_root: Query<&mut Visibility, With>, ) where T::LocalTileKind: Ord, { @@ -81,17 +79,7 @@ pub(crate) fn update_ui( // 1. // if ui.button("Toggle square grid").clicked() { - let mut visibility = grid_root.single_mut(); - *visibility = match *visibility { - Visibility::Visible | Visibility::Inherited => { - toolbar.display_grid = false; - Visibility::Hidden - } - Visibility::Hidden => { - toolbar.display_grid = true; - Visibility::Visible - } - }; + toolbar.display_grid = !toolbar.display_grid; } // @@ -207,6 +195,7 @@ pub(crate) fn change_square_kind( } let ctrl_pressed = keyboard.pressed(KeyCode::ControlLeft); + let esc_pressed = keyboard.just_pressed(KeyCode::Escape); let just_pressed_left = mouse.just_pressed(MouseButton::Left); let just_released_left = mouse.just_released(MouseButton::Left); let just_pressed_right = mouse.just_pressed(MouseButton::Right); @@ -217,11 +206,19 @@ pub(crate) fn change_square_kind( // b) if painting rect, release left to stop painting let stop_painting_rect = toolbar.begin_rect_at.is_some() && just_released_left; - // c) press right to paint single square - let paint_single_square = just_pressed_right; + // c) press right to paint single square (unless in rect mode) + let paint_single_square = + just_pressed_right && toolbar.begin_rect_at.is_none(); + // d) cancel painting rect on esc + let cancel_painting = + esc_pressed && !stop_painting_rect && toolbar.begin_rect_at.is_some(); // if neither of these, then early return - if !start_painting_rect && !stop_painting_rect && !paint_single_square { + if !start_painting_rect + && !stop_painting_rect + && !paint_single_square + && !cancel_painting + { return; } @@ -239,6 +236,8 @@ pub(crate) fn change_square_kind( } } else if paint_single_square { try_paint(&mut toolbar, &mut map, clicked_at); + } else if cancel_painting { + toolbar.begin_rect_at.take(); } } diff --git a/scenes/building1_player_floor/src/autogen/zone_tile_impl.rs b/scenes/building1_player_floor/src/autogen/zone_tile_impl.rs index 197a7f59..c29fa3ef 100644 --- a/scenes/building1_player_floor/src/autogen/zone_tile_impl.rs +++ b/scenes/building1_player_floor/src/autogen/zone_tile_impl.rs @@ -20,10 +20,10 @@ Self::TeaZone => Some(ZoneGroup(0)), { Self::HallwayZone => Some(1266), Self::PlayerApartmentZone => Some(2725), Self::BedZone => Some(30), -Self::ElevatorZone => Some(46), +Self::ElevatorZone => Some(68), Self::PlayerDoorZone => Some(64), -Self::MeditationZone => Some(78), -Self::TeaZone => Some(21), +Self::MeditationZone => Some(125), +Self::TeaZone => Some(45), #[allow(unreachable_patterns)] _ => None, } } type Successors = Self; #[inline] fn zone_successors(&self) -> Option<&'static [Self::Successors]> diff --git a/wiki/src/ability_to_inspect.md b/wiki/src/ability_to_inspect.md index 5796cbb4..03511ab7 100644 --- a/wiki/src/ability_to_inspect.md +++ b/wiki/src/ability_to_inspect.md @@ -48,7 +48,7 @@ A natural solution is to gamify the inspection mode, making it feel less like a Each category has its own radius, and the curiosity level would be combined with other factors to determine the radius. - [ ] There would gadgets that could be attached to the [phone](phone.md). Their purpose would be to alter the inspection mode in some way. -- [ ] We would highlight the object that was closest to you. +- [x] We highlight the object that is the closest to you. That would be the object you would interact with if you pressed the interaction button. - [ ] To avoid repositioning you could also change the highlighted object with directional input. Pressing up would change selection to the next object closest to the highlighted object in the upward direction.