Skip to content

Commit

Permalink
Improve sounds
Browse files Browse the repository at this point in the history
Knock Knock Wellspring
  • Loading branch information
timoschwarzer committed May 31, 2024
1 parent 5e37044 commit 3edb8cd
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions projects/Core/enums/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
enum class SoundEventID : uint32_t {
// Randomizer
LeagueSubmitted = 2697705149,
KnockKnockWellspring = 965810158,
};

NLOHMANN_JSON_SERIALIZE_ENUM(SoundEventID, {
Expand Down
1 change: 1 addition & 0 deletions projects/Randomizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ set(
"features/difficulty.cpp"
"features/keyboard_multibind.cpp"
"features/keystone_door.cpp"
"features/knock_knock_wellspring.cpp"
"features/map.cpp"
"features/npcs/lupo_everywhere.cpp"
"features/npcs/opher_everywhere.cpp"
Expand Down
32 changes: 32 additions & 0 deletions projects/Randomizer/features/knock_knock_wellspring.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@


#include <thread>
#include <Core/api/audio.h>
#include <Core/api/uber_states/uber_state_handlers.h>
#include <Core/events/task.h>
#include <Randomizer/tracking/game_tracker.h>

namespace {
core::api::uber_states::UberState knock_knock_wellspring_enabled_state(UberStateGroup::RandoConfig, 102);

[[maybe_unused]]
auto uber_state_bus_handle = core::api::uber_states::single_notification_bus().register_handler(
core::api::uber_states::UberState(53632, 18181),
[](const core::api::uber_states::UberStateCallbackParams& params, auto) {
if (params.value > 0.5 && params.previous_value < 0.5 && knock_knock_wellspring_enabled_state.get<bool>()) {
const auto stats = randomizer::timing::get_save_file_game_stats();

if (stats.area_stats.contains(GameArea::Wellspring) && stats.area_stats.at(GameArea::Wellspring).in_game_time_spent > 0.f) {
return;
}

using namespace std::chrono_literals;
core::api::audio::play_sound(SoundEventID::KnockKnockWellspring);

core::events::schedule_task_for_next_update([] {
std::this_thread::sleep_for(2100ms);
});
}
}
);
}
12 changes: 8 additions & 4 deletions projects/Randomizer/tracking/game_tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <Core/api/game/player.h>
#include <Core/api/uber_states/uber_state_handlers.h>
#include <Core/enums/world_events.h>
#include <Core/events/async_update.h>
#include <Core/ipc/ipc.h>
#include <Core/save_meta/save_meta.h>
#include <Modloader/app/methods/GameStateMachine.h>
Expand All @@ -15,11 +14,8 @@
#include <Modloader/windows_api/console.h>
#include <Randomizer/tracking/game_tracker.h>
#include <Randomizer/randomizer.h>
#include <Randomizer/stats/game_stats.h>

#include <format>
#include <atomic>
#include <mutex>
#include <unordered_set>

using namespace app::classes;
Expand Down Expand Up @@ -331,4 +327,12 @@ namespace randomizer::timing {
void force_set_game_finished(bool value) {
game_finished = value;
}

const SaveFileGameStats& get_save_file_game_stats() {
return *save_stats;
}

const CheckpointGameStats& get_checkpoint_game_stats() {
return *checkpoint_stats;
}
} // namespace randomizer::timing
3 changes: 3 additions & 0 deletions projects/Randomizer/tracking/game_tracker.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <Core/enums/game_areas.h>
#include <Randomizer/stats/game_stats.h>

namespace randomizer::timing {
extern bool disable_ability_tracking;
Expand All @@ -9,4 +10,6 @@ namespace randomizer::timing {
void override_in_game_time(float in_game_time);
float get_in_game_time();
void force_set_game_finished(bool value);
const SaveFileGameStats& get_save_file_game_stats();
const CheckpointGameStats& get_checkpoint_game_stats();
}
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ namespace randomizer {
add_state<app::SerializedBooleanUberState>(UberStateGroup::RandoConfig, "disableWillowHeartCutscenes", 20, false),
add_state<app::SerializedBooleanUberState>(UberStateGroup::RandoConfig, "removeShriekEscapeSand", 100, false),
add_state<app::SerializedBooleanUberState>(UberStateGroup::RandoConfig, "removeFeedingGroundsToElevatorSand", 101, false),
add_state<app::SerializedBooleanUberState>(UberStateGroup::RandoConfig, "knockKnockWellspring", 102, false),

add_state<app::SerializedIntUberState>(UberStateGroup::RandoConfig, "forceNoAirDecelerationFlag", FORCE_AIR_NO_DECELERATION_ID, 0),

Expand Down

0 comments on commit 3edb8cd

Please sign in to comment.