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

Commit

Permalink
Adding wiki entry for daybar (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
porkbrain authored Apr 1, 2024
1 parent 474cbbf commit 0b915de
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 5 deletions.
3 changes: 3 additions & 0 deletions main_game_lib/src/hud/daybar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ pub struct DayBar {
pub enum IncreaseDayBarEvent {
/// Non trivial scene transition, such as leaving a building.
ChangedScene,
/// Finished meditating.
Meditated,
}

#[derive(Component)]
Expand Down Expand Up @@ -87,6 +89,7 @@ pub(crate) fn increase(
for event in events.read() {
let amount = match event {
IncreaseDayBarEvent::ChangedScene => 0.01,
IncreaseDayBarEvent::Meditated => 0.05,
};

daybar.progress = (daybar.progress + amount).clamp(0.0, 1.0);
Expand Down
6 changes: 6 additions & 0 deletions scenes/building1_player_floor/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use main_game_lib::{
cutscene::enter_an_elevator::{
start_with_open_elevator_and_close_it, STEP_TIME_ON_EXIT_ELEVATOR,
},
hud::daybar::IncreaseDayBarEvent,
top_down::actor::player::TakeAwayPlayerControl,
};
use rscn::{NodeName, TscnSpawner, TscnTree, TscnTreeHandle};
Expand Down Expand Up @@ -84,6 +85,7 @@ struct Spawner<'a> {
player_builder: &'a mut CharacterBundleBuilder,
asset_server: &'a AssetServer,
atlases: &'a mut Assets<TextureAtlasLayout>,
daybar_event: &'a mut Events<IncreaseDayBarEvent>,
tilemap: &'a mut TileMap<Building1PlayerFloor>,
zone_to_inspect_label_entity:
&'a mut ZoneToInspectLabelEntity<Building1PlayerFloorTileKind>,
Expand All @@ -98,6 +100,7 @@ fn spawn(
mut tscn: ResMut<Assets<TscnTree>>,
mut atlas_layouts: ResMut<Assets<TextureAtlasLayout>>,
mut tilemap: ResMut<TileMap<Building1PlayerFloor>>,
mut daybar_event: ResMut<Events<IncreaseDayBarEvent>>,

mut q: Query<&mut TscnTreeHandle<Building1PlayerFloor>>,
) {
Expand All @@ -114,6 +117,7 @@ fn spawn(
player_entity: player,
player_builder: &mut player_builder,
asset_server: &asset_server,
daybar_event: &mut daybar_event,
atlases: &mut atlas_layouts,
tilemap: &mut tilemap,
zone_to_inspect_label_entity: &mut zone_to_inspect_label_entity,
Expand Down Expand Up @@ -208,6 +212,8 @@ impl<'a> TscnSpawner for Spawner<'a> {
));
self.player_builder
.initial_step_time(STEP_TIME_ONLOAD_FROM_MEDITATION);

self.daybar_event.send(IncreaseDayBarEvent::Meditated);
}
"NewGameSpawn"
if self.transition == NewGameToBuilding1PlayerFloor =>
Expand Down
11 changes: 6 additions & 5 deletions scenes/downtown/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bevy_grid_squared::sq;
use common_loading_screen::{LoadingScreenSettings, LoadingScreenState};
use common_visuals::camera::render_layer;
use main_game_lib::{
cutscene::in_cutscene, hud::daybar,
cutscene::in_cutscene, hud::daybar::IncreaseDayBarEvent,
top_down::inspect_and_interact::ZoneToInspectLabelEntity,
};
use rscn::{NodeName, TscnSpawner, TscnTree, TscnTreeHandle};
Expand Down Expand Up @@ -53,7 +53,7 @@ struct Spawner<'a> {
player_builder: &'a mut CharacterBundleBuilder,
player_entity: Entity,
transition: GlobalGameStateTransition,
daybar_event: &'a mut Events<daybar::IncreaseDayBarEvent>,
daybar_event: &'a mut Events<IncreaseDayBarEvent>,
zone_to_inspect_label_entity:
&'a mut ZoneToInspectLabelEntity<DowntownTileKind>,
}
Expand All @@ -66,7 +66,7 @@ fn spawn(
mut tscn: ResMut<Assets<TscnTree>>,
mut atlas_layouts: ResMut<Assets<TextureAtlasLayout>>,
transition: Res<GlobalGameStateTransition>,
mut daybar_event: ResMut<Events<daybar::IncreaseDayBarEvent>>,
mut daybar_event: ResMut<Events<IncreaseDayBarEvent>>,

mut q: Query<&mut TscnTreeHandle<Downtown>>,
) {
Expand Down Expand Up @@ -135,15 +135,16 @@ impl<'a> TscnSpawner for Spawner<'a> {
+ sq(0, -2),
));

self.daybar_event
.send(daybar::IncreaseDayBarEvent::ChangedScene);
self.daybar_event.send(IncreaseDayBarEvent::ChangedScene);
}
"MallEntrance" if self.transition == MallToDowntown => {
self.player_builder.initial_position(translation.truncate());
self.player_builder.walking_to(top_down::ActorTarget::new(
LAYOUT.world_pos_to_square(translation.truncate())
+ sq(0, -2),
));

self.daybar_event.send(IncreaseDayBarEvent::ChangedScene);
}
_ => {}
}
Expand Down
2 changes: 2 additions & 0 deletions wiki/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- [Introduction](intro.md)
- [Phone](phone.md)
- [The Daybar](daybar.md)
- [Traits](traits.md)
- [Top down scenes](top_down.md)
- [Inspect ability](ability_to_inspect.md)
- [Devtools](devtools.md)
Expand Down
38 changes: 38 additions & 0 deletions wiki/src/daybar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# The Daybar

The daybar is a HUD element resembling a progress bar.
It shows how much of the day has passed and how much remains.

Before defining how time works in _Don't Count the Sheep_, let's take a look at how time is measured in other games.

## Time Measurement in Other Games

In Stardew Valley, the game operates on a day-night cycle starting at 6:00 AM and ending at 2:00 AM.
Each in-game day lasts approximately 10 minutes, during which players must manage their daily energy expenditure by performing various actions.

Baldur's Gate 3 does not utilize a traditional time measurement system.
Instead, players are provided with 3 short rests per day, followed by the option to conclude the day with a long rest.
Action points are expended throughout the day, with some resetting after short rests and others after long rests.

Skyrim also incorporates a day-night cycle, affecting gameplay such as shop availability and merchant restocking.
Players have the option to rest or sleep, allowing them to choose the number of hours to pass.

In Knight of Honour 2, time management is flexible, allowing players to pause or accelerate time according to their preferences.
This feature enables players to strategize and plan their actions at their own pace.

## Time Measurement in _Don't Count the Sheep_

In _Don't Count the Sheep_, time is primarily segmented into days, with each day commencing when the character wakes up and concluding when the character goes to sleep.
Unlike traditional clock-based systems, there is no constant ticking of seconds; instead, time progresses as the player takes actions.
Essentially, we intertwine the concept of energy with time, granting players greater control over the pace of time advancement.
For example, players can reorganize their inventory in peace at the end of the day, a task that would be stressful in Stardew Valley.

NPCs within the game adhere to their own schedules, often influenced by the time of day.
Since time progression is contingent upon player actions, NPC behavior dynamically adjusts based on the player's activities throughout the day.

- [ ] There would be various instruments that could change how much time would be consumed by specific actions.
Instruments could include [traits][traits], consumables, events, quests, etc.

<!-- List of References -->

[traits]: traits.md
1 change: 1 addition & 0 deletions wiki/src/traits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TODO

0 comments on commit 0b915de

Please sign in to comment.