#include "classes.h" #include "boss_ai.h" #include "entity_bomb.h" #include "entity_effect_combat.h" #include "entity_npc.h" #include "entity_pickup.h" #include "entity_player.h" #include "game.h" #include "game_end.h" #include "grid_entity_trap_door.h" #include "hud.h" #include "item_pool.h" #include "lua_api.h" #include "manager.h" #include "music_manager.h" #include "npc_basement.h" #include "room.h" #include "room_special.h" #include "room_transition.h" #include "seeds.h" #include "sfx_manager.h" #include "stage_transition.h" #include // The reach of a Fart a script leaves out. constexpr float FART_RADIUS = 85; // The last stage the run's stage counters keep. constexpr int STAGE_COUNTER_MAX = 13; // Making this many devil deals in one run unlocks Azazel. constexpr int AZAZEL_DEALS = 3; constexpr int ACHIEVEMENT_AZAZEL = 79; // A Greed run's waves, bosses and the devil's included (one more in Greedier). constexpr int GREED_WAVE_TOTAL = 11; // The argument past the last line HUD:ShowFortuneText reads. constexpr int FORTUNE_ARGUMENT_END = 34; // 006fe2f0 Moves the players into a room of the floor at once: each leaves the room, the level changes room, the new // room updates once and the item pool takes the room's pool. A Random() is drawn and dropped on the way. void Game::ChangeRoom(int roomIndex, int dimension) { for (Entity_Player* player : playerManager.playerList) player->room_exit(false); Level::ChangeRoom(roomIndex, dimension); room->Update(); Random(); int pool = itemPool.get_pool_from_room_entities(room->roomType, *room->descriptor, room->bossId); itemPool.lastPool = pool == POOL_NONE ? POOL_TREASURE : pool; } // 00703850 A random player within a radius of a position, else the last of the shuffled players. // The original reads before an empty player list. Here there is no player then. static Entity_Player* game_random_player(Game& game, Vector position, float radius) { std::vector players = game.playerManager.playerList; if (players.empty()) return nullptr; for (size_t index = players.size() - 1; index > 0; index--) std::swap(players[index], players[Random() % (index + 1)]); for (Entity_Player* player : players) if (vector_length_squared(vector_sub(position, player->pos)) < radius * radius) return player; return players.back(); } // 00704b70 Rerolls the collectibles the floor's other rooms keep: each saved pedestal of an item that may be rerolled // becomes a fresh, untouched one. static void game_level_collectibles_reroll(Game& game) { for (int index = 0; index < game.nbRooms; index++) for (EntitySaveState& saved : game.roomList[index].savedEntities) { bool isRerollable = Entity_Pickup::CanRerollVariant(PICKUP_COLLECTIBLE, saved.subtype); if (saved.type != ENTITY_PICKUP || saved.variant != PICKUP_COLLECTIBLE || saved.subtype == 0 || !isRerollable) continue; saved.subtype = 0; saved.boolStorage1 = false; } } // (00704b10, 00704b30, 00704b40, 0065d000, 007e92c0, 00738310, 00738320, 007e9330, 007e9370, 0085e3c0, 0085e3d0, // 0085e3f0, 0085e400, 00753c50, 007e92d0, 00753c80, 00753cb0, 0085e370, 00703560) Registers Game's run counters: the // devil deals and donations, and the stages cleared without damage, hearts or half health. // The original pushes the last levels with damage or without half health as an unregistered class. static void game_counters_register(lua_State* state) { lua_method(state, "AddDevilRoomDeal", [](Game& game) { if (++game.devilRoomDeals >= AZAZEL_DEALS) g_manager->persistentGameData.TryUnlock(ACHIEVEMENT_AZAZEL); }); lua_method(state, "DonateGreed", [](Game& game, int amount) { game.donationModGreed += amount; }); lua_method(state, "DonateAngel", [](Game& game, int amount) { game.donationModAngel += amount; }); lua_method(state, "GetDonationModGreed", [](Game& game) { return game.donationModGreed; }); lua_method(state, "GetDonationModAngel", [](Game& game) { return game.donationModAngel; }); lua_method(state, "ClearDonationModGreed", [](Game& game) { game.donationModGreed = 0; }); lua_method(state, "ClearDonationModAngel", [](Game& game) { game.donationModAngel = 0; }); lua_method(state, "SetLastDevilRoomStage", [](Game& game, int stage) { game.lastDevilRoomStage = std::clamp(stage, 0, STAGE_COUNTER_MAX); }); lua_method(state, "AddTreasureRoomsVisited", [](Game& game) { game.treasureRoomsVisited++; }); lua_method(state, "AddStageWithoutHeartsPicked", [](Game& game) { game.stagesWithoutHeartsPicked++; }); lua_method(state, "ClearStagesWithoutHeartsPicked", [](Game& game) { game.stagesWithoutHeartsPicked = 0; }); lua_method(state, "AddStageWithoutDamage", [](Game& game) { game.stagesWithoutDamage++; }); lua_method(state, "ClearStagesWithoutDamage", [](Game& game) { game.stagesWithoutDamage = 0; }); lua_method(state, "SetLastLevelWithDamage", [](Game& game, int stage) { game.lastLevelWithDamage = std::clamp(stage, 0, STAGE_COUNTER_MAX); }); lua_method(state, "GetLastLevelWithDamage", [](Game&) { return LuaOpaque{}; }); lua_method(state, "SetLastLevelWithoutHalfHp", [](Game& game, int stage) { game.lastLevelWithoutHalfHp = std::clamp(stage, 0, STAGE_COUNTER_MAX); }); lua_method(state, "GetLastLevelWithoutHalfHp", [](Game&) { return LuaOpaque{}; }); lua_method(state, "AddEncounteredBoss", [](Game&, int type, int variant) { game_encountered_boss_add(type, variant); }); lua_method(state, "GetNumEncounteredBosses", [](Game& game) { return (int)game.encounteredBosses.size(); }); lua_method(state, "GetGreedWavesNum", [](Game& game) { return GREED_WAVE_TOTAL + (game.difficulty == DIFFICULTY_GREEDIER); }); } // (00440ee0, 00440620, 00753cc0, 004a5d00, 00703460, 005b1860, 00456860, 0085e390) Registers Game's screen and world // effects: explosions, particles, shockwaves, darkness, pixelation, hallucinations, fades and the HUD font. // The original pushes the ambush and the item overlay as unregistered classes. static void game_effects_register(lua_State* state) { lua_method(state, "BombDamage", [](Game&, Vector position, float damage, float radius, bool isLineCheck, Entity* source, TearFlags flags, int64_t damageFlags, bool isDamageSource) { explosion_damage({.tearFlags = flags, .position = position, .source = source, .damageFlags = (uint64_t)damageFlags, .damage = damage, .radius = radius, .isDamageSource = isDamageSource, .isLineCheck = isLineCheck}); }); lua_method(state, "BombExplosionEffects", [](Game&, Vector position, float damage, TearFlags flags, const ColorMod& color, Entity* source, float radiusMultiplier, bool isLineCheck, int64_t damageFlags, bool isDamageSource) { explosion_effects({.tearFlags = flags, .color = color, .position = position, .source = source, .damageFlags = (uint64_t)damageFlags, .damage = damage, .radiusMultiplier = radiusMultiplier, .isDamageSource = isDamageSource, .isLineCheck = isLineCheck}); }); lua_method(state, "BombTearflagEffects", [](Game&, Vector position, float radius, TearFlags flags, Entity* source, float radiusMultiplier) { explosion_tear_flag_effects({.tearFlags = flags, .position = position, .source = source, .radius = radius, .radiusMultiplier = radiusMultiplier}); }); lua_method(state, "SpawnParticles", [](Game&, Vector position, int variant, int count, float speed, const ColorMod& color, float height, int subType) { game_particles_spawn({.color = color, .position = position, .height = height, .speed = speed, .count = count, .subType = subType, .variant = variant}); }); lua_method(state, "MakeShockwave", [](Game&, Vector position, float amplitude, float speed, int duration) { shockwave_make(position, amplitude, speed, duration); }); lua_method(state, "UpdateStrangeAttractor", [](Game&, Vector, float, float) { reconstruction_missing("Game::AttractEntities 00705b90"); }); lua_method(state, "CharmFart", [](Game&, Vector, float, Entity*) { reconstruction_missing("Game::CharmFart 00703f90"); }); lua_method(state, "Darken", [](Game& game, float strength, int timeout) { game.darknessStrength = strength; game.darknessTimeout = timeout; }); lua_method(state, "GetTargetDarkness", [](Game& game) { return game.darknessStrength; }); lua_method(state, "AddPixelation", [](Game& game, int duration) { game.pixelationTimer = std::max(duration, game.pixelationTimer); game.pixelationDuration = game.pixelationTimer; }); lua_method(state, "ShowHallucination", [](Game& game, int frames, int backdrop) { game.ShowHallucination(frames, backdrop); }); lua_method(state, "HasHallucination", [](Game& game) { return game.hallucinationTimer > 0; }); lua_method(state, "Fadein", [](Game& game, float speed, bool isShowIcon, KColor color) { game.Fadein(speed, isShowIcon ? FADE_ICON_SHOW : FADE_ICON_HIDE, color); }); lua_method(state, "Fadeout", [](Game& game, float speed, FadeOutTarget target, KColor color) { game.Fadeout(speed, target, color); }); lua_method(state, "GetFont", [](Game&) { return &g_manager->font2_TeamMeatEx12; }); lua_method(state, "GetAmbush", [](Game&) { return LuaOpaque{}; }); lua_method(state, "GetItemOverlay", [](Game&) { return LuaOpaque{}; }); lua_method(state, "ShowFortune", [](Game&) { reconstruction_missing("Game::ShowFortuneText 009807a0"); }); lua_method(state, "ShowRule", [](Game&) { reconstruction_missing("Game::ShowFortuneText 009807a0"); }); } // (00704f20, 006f9770) Registers how Game moves the run on: its frame and draw, room and floor changes, rerolls, // the ending and the next victory lap. // The original hands StartStageTransition a player from its stack. Here it has none. static void game_flow_register(lua_State* state) { lua_method(state, "Update", [](Game& game) { game.Update(); }); lua_method(state, "Render", [](Game& game) { game.Render(); }); lua_method(state, "ChangeRoom", [](Game& game, int roomIndex, int dimension) { game.ChangeRoom(roomIndex, dimension); }); lua_method(state, "MoveToRandomRoom", [](Game& game, bool isErrorRoom, uint32_t seed, Entity_Player* player) { game_random_room_move(game, isErrorRoom, seed, player); }); lua_method(state, "StartStageTransition", [](Game& game, bool isSameStage, StageTransitionType type) { game.stageTransition.start({.type = type, .isSameStage = isSameStage}); }); lua_method(state, "GetRandomPlayer", game_random_player); lua_method(state, "RerollLevelCollectibles", game_level_collectibles_reroll); lua_method(state, "RerollLevelPickups", [](Game&, uint32_t) { reconstruction_missing("Game::RerollLevelPickups 00704c50"); }); lua_method(state, "RerollEnemy", [](Game&, Entity*, bool) { reconstruction_missing("Game::RerollEnemy 007050c0"); return false; }); lua_method(state, "SpawnEntityDesc", [](Game&, LuaIgnored, Vector, Entity*) { reconstruction_missing("Game::SpawnEntityDesc 006fece0"); }); lua_method(state, "End", [](Game&, GameEnding ending) { game_end(ending); }); lua_method(state, "FinishChallenge", [](Game&) { challenge_finish(); }); lua_method(state, "NextVictoryLap", [](Game&) { reconstruction_missing("Game::NextVictoryLap 006f7ac0"); }); } // (00703510, 00703570) Registers Lua's Game: the run's level, room, players, pools, seeds and HUD, spawning, room // transitions and farts, and its state flags and counters. Game is also the Level it derives from. static void game_register(lua_State* state) { lua_class_begin(state, "Game", LUA_CLASS_GAME); lua_method(state, "GetLevel", [](Game& game) -> Level& { return game; }); lua_method(state, "GetRoom", [](Game& game) { return game.room.get(); }); lua_method(state, "GetPlayer", [](Game& game, int index) { return game.GetPlayer(index); }); lua_method(state, "GetNumPlayers", [](Game& game) { return (int)game.playerManager.playerList.size(); }); lua_method(state, "GetNearestPlayer", [](Game&, Vector position) { return game_nearest_player(position); }); lua_method(state, "GetItemPool", [](Game& game) -> ItemPool& { return game.itemPool; }); lua_method(state, "GetHUD", [](Game& game) -> HUD& { return game.hud; }); lua_method(state, "GetSeeds", [](Game& game) -> Seeds& { return game.seedEffects; }); lua_method(state, "GetFrameCount", [](Game& game) { return game.frameCount; }); lua_method(state, "IsPaused", [](Game& game) { return game.IsPaused(); }); lua_method(state, "IsGreedMode", [](Game& game) { return game.IsGreedMode(); }); lua_method(state, "GetStateFlag", [](Game& game, GameStateFlag flag) { return game.GetStateFlag(flag); }); lua_method(state, "SetStateFlag", [](Game& game, int flag, bool isSet) { game.gameStateFlags = isSet ? game.gameStateFlags | 1ull << flag : game.gameStateFlags & ~(1ull << flag); }); lua_method(state, "ShakeScreen", [](Game&, int timeout) { game_shake_screen(timeout); }); lua_method(state, "Spawn", [](Game& game, int type, int variant, Vector position, Vector velocity, Entity* spawner, int subType, uint32_t seed) { return game.Spawn({position, velocity, spawner, subType, type, variant, seed}); }); lua_method(state, "StartRoomTransition", [](Game& game, int roomIndex, Direction direction, LuaDefault animation, Entity_Player* player, LuaDefault dimension) { game.StartRoomTransition({.player = player, .animation = (RoomTransitionAnim)animation.value, .direction = direction, .dimension = dimension.value, .roomIndex = roomIndex}); }); lua_method(state, "HasEncounteredBoss", [](Game& game, int type, int variant) { return std::ranges::any_of(game.encounteredBosses, [&](BossId& boss) { return boss.type == type && boss.variant == variant; }); }); lua_method(state, "GetGreedBossWaveNum", [](Game& game) { return GREED_BOSS_WAVE + (game.difficulty == DIFFICULTY_GREEDIER); }); lua_method(state, "Fart", [](Game&, Vector position, LuaDefault radius, Entity* source, LuaDefault scale, LuaDefault subType, ColorMod* color) { game_fart({.position = position, .source = source, .color = color ? *color : COLOR_DEFAULT, .radius = radius.value, .scale = scale.value, .subType = subType.value}); }); lua_method(state, "ButterBeanFart", [](Game&, Vector position, float radius, Entity* source, LuaDefault isShowEffect, bool isSuperKnockback) { game_butter_bean_fart({.position = position, .source = source, .radius = radius, .isShowEffect = isShowEffect.value, .isSuperKnockback = isSuperKnockback}); }); lua_method(state, "GetVictoryLap", [](Game& game) { return game.victoryLap; }); lua_method(state, "GetDevilRoomDeals", [](Game& game) { return game.devilRoomDeals; }); lua_method(state, "GetLastDevilRoomStage", [](Game& game) { return game.lastDevilRoomStage; }); lua_method(state, "GetTreasureRoomVisitCount", [](Game& game) { return game.treasureRoomsVisited; }); lua_method(state, "GetStagesWithoutDamage", [](Game& game) { return game.stagesWithoutDamage; }); lua_method(state, "GetStagesWithoutHeartsPicked", [](Game& game) { return game.stagesWithoutHeartsPicked; }); lua_method(state, "GetDarknessModifier", [](Game& game) { return game.darknessModifier; }); lua_method(state, "GetScreenShakeCountdown", [](Game& game) { return game.screenShakeTimer; }); lua_field<&Game::challenge>(state, "Challenge"); lua_field<&Game::difficulty>(state, "Difficulty"); lua_field<&Game::timeCounter>(state, "TimeCounter"); lua_field<&Game::blueWombParTime>(state, "BlueWombParTime"); lua_field<&Game::bossRushParTime>(state, "BossRushParTime"); lua_field<&Game::screenShakeOffset>(state, "ScreenShakeOffset"); game_counters_register(state); game_effects_register(state); game_flow_register(state); lua_class_end(state); } // HUD:ShowFortuneText: the string arguments after the HUD, up to the first that is not one, as a fortune's lines. static int hud_fortune_text_show(lua_State* state) { HUD& hud = *static_cast(lua_object_check(state, 1, LUA_CLASS_HUD)); std::vector lines; for (int index = 2; index < FORTUNE_ARGUMENT_END && lua_type(state, index) == LUA_TSTRING; index++) lines.emplace_back(lua_tostring(state, index)); hud.ShowFortuneText(lines); return 0; } // Registers Lua's HUD, ItemPool and Seeds, the parts of a run Game hands out. static void game_parts_register(lua_State* state) { lua_class_begin(state, "HUD", LUA_CLASS_HUD); lua_method(state, "IsVisible", [](HUD& hud) { return hud.IsVisible(); }); lua_method(state, "SetVisible", [](HUD& hud, bool isShown) { hud.SetVisible(isShown); }); lua_method(state, "FlashChargeBar", [](HUD& hud, Entity_Player* player, int slot) { hud.FlashChargeBar(player, slot); }); lua_method(state, "InvalidateActiveItem", [](HUD& hud, Entity_Player* player, int slot) { hud.InvalidateActiveItem(player, slot); }); lua_method(state, "InvalidateCraftingItem", [](HUD& hud, Entity_Player* player) { hud.InvalidateCraftingItem(player); }); lua_method(state, "ShowItemText", [](HUD& hud, Entity_Player* player, ItemConfig_Item* item) { hud.ShowItemText(player, item); }); lua_method(state, "AssignPlayerHUDs", [](HUD& hud) { hud.AssignPlayerHUDs(); }); lua_method(state, "Update", [](HUD& hud) { hud.Update(); }); lua_method(state, "PostUpdate", [](HUD& hud) { hud.PostUpdate(); }); lua_method(state, "Render", [](HUD& hud) { hud.Render(); }); lua_pushcfunction(state, hud_fortune_text_show); lua_table_set(state, -2, "ShowFortuneText"); lua_class_end(state); lua_class_begin(state, "ItemPool", LUA_CLASS_ITEM_POOL); lua_method(state, "GetCollectible", [](ItemPool& pool, ItemPoolType poolType, uint32_t seed, uint32_t flags, int defaultItem, int fallbackPool) { return pool.GetCollectible(poolType, seed, flags, defaultItem, fallbackPool); }); lua_method(state, "RemoveCollectible", [](ItemPool& pool, int collectible) { return pool.RemoveCollectible(collectible, REMOVE_ANY, REMOVE_APPLY); }); lua_method(state, "GetTrinket", [](ItemPool& pool, bool isPeek) { return pool.GetTrinket(isPeek ? TRINKET_DRAW_PEEK : TRINKET_DRAW_TAKE); }); lua_method(state, "RemoveTrinket", [](ItemPool& pool, int trinket) { return pool.RemoveTrinket(trinket); }); lua_method(state, "ResetTrinkets", [](ItemPool& pool) { pool.ResetTrinkets(); }); lua_method(state, "GetCard", [](ItemPool&, uint32_t seed, bool isPlaying, bool isRunes, bool isOnlyRunes) { return ItemPool::GetCard(seed, isPlaying, isRunes, isOnlyRunes); }); lua_method(state, "GetPill", [](ItemPool&, uint32_t seed) { return ItemPool::GetPill(seed); }); lua_method(state, "GetPillEffect", [](ItemPool& pool, uint32_t color, Entity_Player* player) { return pool.GetPillEffect(color, player); }); lua_method(state, "IdentifyPill", [](ItemPool& pool, uint32_t color) { pool.IdentifyPill(color); }); lua_method(state, "IsPillIdentified", [](ItemPool& pool, uint32_t color) { return pool.IsPillIdentified(color); }); lua_method(state, "ForceAddPillEffect", [](ItemPool& pool, int effect) { return pool.ForceAddPillEffect(effect); }); lua_method(state, "GetLastPool", [](ItemPool& pool) { return pool.GetLastPool(); }); lua_method(state, "GetPoolForRoom", [](ItemPool& pool, int roomType, uint32_t seed) { return pool.GetPoolForRoom(roomType, seed); }); lua_method(state, "AddRoomBlacklist", [](ItemPool& pool, int collectible) { pool.AddRoomBlacklist(collectible); }); lua_method(state, "ResetRoomBlacklist", [](ItemPool& pool) { pool.ResetRoomBlacklist(); }); lua_method(state, "AddBibleUpgrade", [](ItemPool& pool, int add, int poolType) { pool.AddBibleUpgrade(add, poolType); }); lua_class_end(state); lua_class_begin(state, "Seeds", LUA_CLASS_SEEDS); lua_method(state, "GetStartSeed", [](Seeds& seeds) { return seeds.GetStartSeed(); }); lua_method(state, "IsCustomRun", [](Seeds& seeds) { return seeds.isCustomRun; }); lua_method(state, "IsInitialized", [](Seeds& seeds) { return seeds.gameStartSeed != 0; }); lua_method(state, "GetStartSeedString", [](Seeds& seeds) { return seeds.GetStartSeedString(); }); lua_method(state, "GetNextSeed", [](Seeds& seeds) { return seeds.GetNextSeed(); }); lua_method(state, "GetStageSeed", [](Seeds& seeds, int stage) { return seeds.GetStageSeed(stage); }); lua_method(state, "GetPlayerInitSeed", [](Seeds& seeds) { return seeds.GetPlayerInitSeed(); }); lua_method(state, "HasSeedEffect", [](Seeds& seeds, uint32_t effect) { return seeds.HasSeedEffect(effect); }); lua_method(state, "AddSeedEffect", [](Seeds& seeds, int effect) { seeds.AddSeedEffect(effect); }); lua_method(state, "RemoveSeedEffect", [](Seeds& seeds, int effect) { seeds.RemoveSeedEffect(effect); }); lua_method(state, "CanAddSeedEffect", [](Seeds& seeds, uint32_t effect) { return seeds.CanAddSeedEffect(effect); }); lua_method(state, "SetStartSeed", [](Seeds& seeds, std::string_view seed) { seeds.SetStartSeed(seed); }); lua_method(state, "ClearStartSeed", [](Seeds& seeds) { seeds.ClearStartSeed(); }); lua_method(state, "Reset", [](Seeds& seeds) { seeds.Reset(); }); lua_method(state, "Restart", [](Seeds& seeds, int challenge) { seeds.Restart(challenge); }); lua_method(state, "ForgetStageSeed", [](Seeds& seeds, int stage) { seeds.ForgetStageSeed(stage); }); lua_method(state, "RemoveBlockingSeedEffects", [](Seeds& seeds, int effect) { seeds.RemoveBlockingSeedEffects(effect); }); lua_method(state, "ClearSeedEffects", [](Seeds& seeds) { seeds.ClearSeedEffects(); }); lua_method(state, "CountSeedEffects", [](Seeds& seeds) { return seeds.CountSeedEffects(); }); lua_static(state, "GetSeedEffect", [](std::string_view seed) { return Seeds::GetSeedEffect(seed); }); lua_static(state, "IsSpecialSeed", [](std::string_view seed) { return Seeds::IsSpecialSeed(seed); }); lua_static(state, "IsSeedComboBanned", [](int effectA, int effectB) { return Seeds::IsSeedComboBanned(effectA, effectB); }); lua_static(state, "InitSeedInfo", []() { Seeds::InitSeedInfo(); }); lua_static(state, "CountUnlockedSeedEffects", []() { return Seeds::CountUnlockedSeedEffects(); }); lua_static(state, "Seed2String", [](uint32_t seed) { return Seeds::Seed2String(seed); }); lua_static(state, "String2Seed", [](std::string_view seed) { return Seeds::String2Seed(seed); }); lua_static(state, "IsStringValidSeed", [](std::string_view seed) { return Seeds::IsStringValidSeed(seed); }); lua_class_end(state); } // Registers Lua's SFXManager and MusicManager, the sound effects and music the scripts reach through the global // functions of the same names. static void sound_register(lua_State* state) { lua_class_begin(state, "SFXManager", LUA_CLASS_SFX_MANAGER); lua_method(state, "Play", [](SFXManager& sfx, int sound, float volume, int frameDelay, bool isLooped, float pitch, float pan) { sfx.Play(sound, {volume, frameDelay, isLooped ? SOUND_LOOP : SOUND_ONCE, pitch, pan}); }); lua_method(state, "Stop", [](SFXManager& sfx, int sound) { sfx.Stop(sound); }); lua_method(state, "IsPlaying", [](SFXManager& sfx, int sound) { return sfx.IsPlaying(sound); }); lua_method(state, "Preload", [](SFXManager& sfx, int sound) { sfx.Preload(sound); }); lua_method(state, "AdjustVolume", [](SFXManager& sfx, int sound, float volume) { sfx.AdjustVolume(sound, volume); }); lua_method(state, "AdjustPitch", [](SFXManager& sfx, int sound, float pitch) { sfx.AdjustPitch(sound, pitch); }); lua_method(state, "StopLoopingSounds", [](SFXManager& sfx) { sfx.StopLoopingSounds(); }); lua_method(state, "SetAmbientSound", [](SFXManager& sfx, int sound, float volume, float pitch) { sfx.SetAmbientSound(sound, volume, pitch); }); lua_method(state, "GetAmbientSoundVolume", [](SFXManager& sfx, int sound) { return sfx.GetAmbientSoundVolume(sound); }); lua_class_end(state); lua_class_begin(state, "MusicManager", LUA_CLASS_MUSIC_MANAGER); lua_method(state, "Play", [](MusicManager& music, int track, float volume) { music.Play(track, volume); }); lua_method(state, "Fadein", [](MusicManager& music, int track, float volume, float rate) { music.Fadein(track, volume, rate); }); lua_method(state, "Crossfade", [](MusicManager& music, int track, float rate) { music.Crossfade(track, rate); }); lua_method(state, "Fadeout", [](MusicManager& music, float rate) { music.Fadeout(rate); }); lua_method(state, "Queue", [](MusicManager& music, int track) { music.Queue(track); }); lua_method(state, "Pause", [](MusicManager& music) { music.Pause(); }); lua_method(state, "Resume", [](MusicManager& music) { music.Resume(); }); lua_method(state, "EnableLayer", [](MusicManager& music, int layer, bool isInstant) { music.EnableLayer(layer, isInstant ? LAYER_INSTANT : LAYER_FADE); }); lua_method(state, "DisableLayer", [](MusicManager& music, int layer) { music.DisableLayer(layer); }); lua_method(state, "IsLayerEnabled", [](MusicManager& music, int layer) { return music.IsLayerEnabled(layer); }); lua_method(state, "Enable", [](MusicManager& music) { music.Enable(); }); lua_method(state, "Disable", [](MusicManager& music) { music.Disable(); }); lua_method(state, "IsEnabled", [](MusicManager& music) { return music.IsEnabled(); }); lua_method(state, "PitchSlide", [](MusicManager& music, float pitch) { music.PitchSlide(pitch); }); lua_method(state, "ResetPitch", [](MusicManager& music) { music.ResetPitch(); }); lua_method(state, "VolumeSlide", [](MusicManager& music, float volume, float rate) { music.VolumeSlide(volume, rate); }); lua_method(state, "UpdateVolume", [](MusicManager& music) { music.UpdateVolume(); }); lua_method(state, "GetCurrentMusicID", [](MusicManager& music) { return music.GetCurrentMusicID(); }); lua_method(state, "GetQueuedMusicID", [](MusicManager& music) { return music.GetQueuedMusicID(); }); lua_class_end(state); } void lua_api_game_register(lua_State* state) { game_register(state); game_parts_register(state); sound_register(state); }