Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Fixes zones in player floor's apartment (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
porkbrain authored Jul 27, 2024
1 parent 1349a2f commit 352e716
Show file tree
Hide file tree
Showing 20 changed files with 3,643 additions and 3,703 deletions.
6,586 changes: 3,293 additions & 3,293 deletions main_game/assets/maps/building1_player_floor.ron

Large diffs are not rendered by default.

301 changes: 162 additions & 139 deletions main_game/assets/scenes/building1_player_floor.tscn

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions main_game_lib/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,12 @@ impl WhichTopDownScene {
GlobalGameState::LeavingTopDownScene(self)
}
}

impl WhichTopDownScene {
/// Returns snake case version of the scene name.
/// We use this name to load scene assets because the name matches names
/// of .ron and .tscn files.
pub fn snake_case(self) -> String {
untools::camel_to_snake(self.as_ref(), false)
}
}
16 changes: 8 additions & 8 deletions main_game_lib/src/top_down.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ pub mod cameras;
pub mod environmental_objects;
pub mod inspect_and_interact;
pub mod layout;
pub mod scene_configs;

use actor::{emit_movement_events, BeginDialogEvent};
pub use actor::{npc, player::Player, Actor, ActorMovementEvent, ActorTarget};
use bevy::prelude::*;
pub use inspect_and_interact::{InspectLabel, InspectLabelCategory};
pub use layout::{TileKind, TileMap};
pub use layout::{TileKind, TileMap, ZoneTileKind};
use leafwing_input_manager::plugin::InputManagerSystem;

use self::inspect_and_interact::ChangeHighlightedInspectLabelEvent;
Expand Down Expand Up @@ -217,18 +216,19 @@ impl bevy::app::Plugin for Plugin {
use bevy_inspector_egui::quick::ResourceInspectorPlugin;
use layout::map_maker::TileMapMakerToolbar as Toolbar;

app.register_type::<Toolbar>()
.register_type::<Actor>()
.register_type::<ActorTarget>()
.register_type::<TileKind>()
app.register_type::<Actor>()
.register_type::<ActorMovementEvent>()
.register_type::<ActorTarget>()
.register_type::<InspectLabel>()
.register_type::<InspectLabelCategory>()
.register_type::<npc::BehaviorLeaf>()
.register_type::<npc::BehaviorPaused>()
.register_type::<npc::NpcInTheMap>()
.register_type::<npc::PlanPathEvent>()
.register_type::<TileKind>()
.register_type::<TileMap>()
.register_type::<npc::BehaviorLeaf>()
.register_type::<npc::BehaviorPaused>();
.register_type::<Toolbar>()
.register_type::<ZoneTileKind>();

app.add_plugins(
ResourceInspectorPlugin::<Toolbar>::new()
Expand Down
66 changes: 64 additions & 2 deletions main_game_lib/src/top_down/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ use serde::{Deserialize, Serialize};
use smallvec::SmallVec;
use strum::IntoEnumIterator;

use super::scene_configs::ZoneTileKind;

/// Each scene adheres to the same layout definition.
/// That's because the amount of space the character takes in the tile grid
/// is constant and tailored to the square size.
Expand Down Expand Up @@ -123,6 +121,70 @@ pub enum TileKind {
Zone(ZoneTileKind),
}

/// Named zones in the .ron files that are used in particular's scene logic to
/// achieve some behavior specific to that scene.
/// The zones can be re-used in multiple scenes.
#[derive(
Clone,
Copy,
Debug,
Default,
Deserialize,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
Reflect,
Serialize,
strum::Display,
strum::EnumIter,
strum::EnumString,
)]
#[reflect(Default)]
#[allow(missing_docs)]
pub enum ZoneTileKind {
/// Arbitrarily the default value.
#[default]
Exit,

Aisle1,
Aisle2,
Aisle3,
Aisle4,

/// In interior scenes there might be multiple apartments.
/// This represents a second apartment in such scenes.
Apartment2,
Apartment2BathroomDoor,
Apartment2Door,

BasementDoor,
Bed,
Building1Entrance,
ClinicEntrance,
ClinicWardEntrance,
CompoundEntrance,
Door,
Elevator,
Fridges,
FruitsAndVeggies,
GoodWater,
GoToDowntown,
Hallway,
MallEntrance,
Meditation,
PlantShopEntrance,
PlayerApartment,
PlayerDoor,
SewersEntrance,
Tea,
TowerEntrance,
TwinpeaksApartmentEntrance,
UpperApartmentDoor,
UpperApartmentWallHidden,
}

/// Useful for pathfinding to prefer some tiles over others.
#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Debug)]
pub enum TileWalkCost {
Expand Down
69 changes: 0 additions & 69 deletions main_game_lib/src/top_down/scene_configs.rs

This file was deleted.

2 changes: 0 additions & 2 deletions scenes/top_down/src/building1_basement2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use common_visuals::camera::render_layer;
use main_game_lib::{
common_ext::QueryExt,
cutscene::{enter_dark_door::EnterDarkDoor, in_cutscene, IntoCutscene},
top_down::scene_configs::ZoneTileKind,
};
use rscn::{NodeName, TscnSpawner, TscnTree, TscnTreeHandle};
use top_down::{
actor::{CharacterBundleBuilder, CharacterExt},
inspect_and_interact::ZoneToInspectLabelEntity,
Expand Down
19 changes: 4 additions & 15 deletions scenes/top_down/src/building1_player_floor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ use main_game_lib::{
ChangeHighlightedInspectLabelEventConsumer,
SpawnLabelBgAndTextParams, LIGHT_RED,
},
scene_configs::ZoneTileKind,
ActorMovementEvent,
},
};
use rscn::{NodeName, TscnSpawner, TscnTree, TscnTreeHandle};
use top_down::{
actor::{
self, movement_event_emitted, CharacterBundleBuilder, CharacterExt,
Expand Down Expand Up @@ -256,23 +254,14 @@ impl<'a> TscnSpawner for Spawner<'a> {
.build_and_insert_obstacle(self.tilemap);
cmd.entity(who).insert(door);
}
"BottomLeftApartmentDoor" => {
"Apartment2Door" => {
cmd.entity(who).insert(
DoorBuilder::new(ZoneTileKind::BottomLeftApartmentDoor)
.build(),
);
}
"BottomLeftApartmentBathroomDoor" => {
cmd.entity(who).insert(
DoorBuilder::new(
ZoneTileKind::BottomLeftApartmentBathroomDoor,
)
.build(),
DoorBuilder::new(ZoneTileKind::Apartment2Door).build(),
);
}
"BottomRightApartmentDoor" => {
"Apartment2BathroomDoor" => {
cmd.entity(who).insert(
DoorBuilder::new(ZoneTileKind::BottomRightApartmentDoor)
DoorBuilder::new(ZoneTileKind::Apartment2BathroomDoor)
.build(),
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use common_visuals::BeginInterpolationEvent;
use main_game_lib::{
common_ext::QueryExt,
top_down::{actor::Who, scene_configs::ZoneTileKind, TileKind},
top_down::{actor::Who, TileKind},
};
use top_down::{Actor, ActorMovementEvent, TileMap};

Expand Down Expand Up @@ -40,10 +40,7 @@ pub(super) fn system(
Who {
is_player: true, ..
},
zone:
TileKind::Zone(
Hallway | BottomLeftApartment | BottomRightApartment,
),
zone: TileKind::Zone(Hallway | Apartment2),
} => {
on_player_entered_hallway(&mut lerp_event, &hallway_entities);
}
Expand All @@ -52,10 +49,7 @@ pub(super) fn system(
Who {
is_player: true, ..
},
zone:
TileKind::Zone(
Hallway | BottomLeftApartment | BottomRightApartment,
),
zone: TileKind::Zone(Hallway | Apartment2),
} => {
on_player_left_hallway(&mut lerp_event, &hallway_entities);
}
Expand All @@ -66,10 +60,7 @@ pub(super) fn system(
entity,
..
},
zone:
TileKind::Zone(
Hallway | BottomLeftApartment | BottomRightApartment,
),
zone: TileKind::Zone(Hallway | Apartment2),
} => {
on_npc_entered_hallway(
&tilemap,
Expand All @@ -86,10 +77,7 @@ pub(super) fn system(
entity,
..
},
zone:
TileKind::Zone(
Hallway | BottomLeftApartment | BottomRightApartment,
),
zone: TileKind::Zone(Hallway | Apartment2),
} => {
on_npc_left_hallway(&mut cmd, &mut lerp_event, *entity);
}
Expand Down
7 changes: 2 additions & 5 deletions scenes/top_down/src/clinic.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
use bevy::render::view::RenderLayers;
use common_visuals::camera::render_layer;
use main_game_lib::{
cutscene::in_cutscene,
hud::notification::NotificationFifo,
cutscene::in_cutscene, hud::notification::NotificationFifo,
player_stats::PlayerStats,
top_down::{
environmental_objects::door::DoorBuilder, scene_configs::ZoneTileKind,
},
top_down::environmental_objects::door::DoorBuilder,
};
use rscn::{NodeName, TscnSpawner, TscnTree, TscnTreeHandle};
use top_down::{
Expand Down
3 changes: 1 addition & 2 deletions scenes/top_down/src/clinic_ward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use bevy::render::view::RenderLayers;
use common_visuals::camera::render_layer;
use main_game_lib::{
cutscene::in_cutscene, hud::notification::NotificationFifo,
player_stats::PlayerStats, top_down::scene_configs::ZoneTileKind,
player_stats::PlayerStats,
};
use rscn::{NodeName, TscnSpawner, TscnTree, TscnTreeHandle};
use top_down::{
actor::{CharacterBundleBuilder, CharacterExt},
inspect_and_interact::ZoneToInspectLabelEntity,
Expand Down
3 changes: 1 addition & 2 deletions scenes/top_down/src/compound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ use main_game_lib::{
cutscene::in_cutscene,
hud::{daybar::UpdateDayBarEvent, notification::NotificationFifo},
player_stats::PlayerStats,
top_down::{layout::LAYOUT, scene_configs::ZoneTileKind},
top_down::layout::LAYOUT,
};
use rscn::{NodeName, TscnSpawner, TscnTree, TscnTreeHandle};
use top_down::{
actor::{CharacterBundleBuilder, CharacterExt},
inspect_and_interact::ZoneToInspectLabelEntity,
Expand Down
3 changes: 1 addition & 2 deletions scenes/top_down/src/compound_tower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use bevy::render::view::RenderLayers;
use common_visuals::camera::render_layer;
use main_game_lib::{
cutscene::in_cutscene, hud::notification::NotificationFifo,
player_stats::PlayerStats, top_down::scene_configs::ZoneTileKind,
player_stats::PlayerStats,
};
use rscn::{NodeName, TscnSpawner, TscnTree, TscnTreeHandle};
use top_down::{
actor::{CharacterBundleBuilder, CharacterExt},
inspect_and_interact::ZoneToInspectLabelEntity,
Expand Down
2 changes: 0 additions & 2 deletions scenes/top_down/src/downtown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ use main_game_lib::{
SpawnLabelBgAndTextParams, ZoneToInspectLabelEntity, LIGHT_RED,
},
npc::behaviors::PatrolSequence,
scene_configs::ZoneTileKind,
},
};
use rscn::{NodeName, TscnSpawner, TscnTree, TscnTreeHandle};
use top_down::{
actor::{CharacterBundleBuilder, CharacterExt},
layout::LAYOUT,
Expand Down
4 changes: 1 addition & 3 deletions scenes/top_down/src/mall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ use main_game_lib::{
hud::notification::NotificationFifo,
player_stats::PlayerStats,
top_down::{
actor::BeginDialogEvent, layout::LAYOUT,
npc::behaviors::PatrolSequence, scene_configs::ZoneTileKind,
actor::BeginDialogEvent, layout::LAYOUT, npc::behaviors::PatrolSequence,
},
};
use rand::prelude::SliceRandom;
use rscn::{NodeName, TscnSpawner, TscnTree, TscnTreeHandle};
use top_down::{
actor::{CharacterBundleBuilder, CharacterExt},
inspect_and_interact::ZoneToInspectLabelEntity,
Expand Down
3 changes: 1 addition & 2 deletions scenes/top_down/src/plant_shop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use bevy::render::view::RenderLayers;
use common_visuals::camera::render_layer;
use main_game_lib::{
cutscene::in_cutscene, hud::notification::NotificationFifo,
player_stats::PlayerStats, top_down::scene_configs::ZoneTileKind,
player_stats::PlayerStats,
};
use rscn::{NodeName, TscnSpawner, TscnTree, TscnTreeHandle};
use top_down::{
actor::{CharacterBundleBuilder, CharacterExt},
inspect_and_interact::ZoneToInspectLabelEntity,
Expand Down
Loading

0 comments on commit 352e716

Please sign in to comment.