mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-06-25 19:57:02 +00:00
Correct music playing
Now music correlated with game mode and dimension
This commit is contained in:
parent
9db673dc8d
commit
5ad092ea57
|
|
@ -116,6 +116,9 @@ const char *SoundEngine::m_szStreamFileA[eStream_Max]=
|
|||
"hal4",
|
||||
"nuance1",
|
||||
"nuance2",
|
||||
"piano1",
|
||||
"piano2",
|
||||
"piano3",
|
||||
|
||||
"creative1",
|
||||
"creative2",
|
||||
|
|
@ -123,15 +126,12 @@ const char *SoundEngine::m_szStreamFileA[eStream_Max]=
|
|||
"creative4",
|
||||
"creative5",
|
||||
"creative6",
|
||||
|
||||
"menu1",
|
||||
"menu2",
|
||||
"menu3",
|
||||
"menu4",
|
||||
|
||||
"piano1",
|
||||
"piano2",
|
||||
"piano3",
|
||||
|
||||
// Nether
|
||||
"nether1",
|
||||
"nether2",
|
||||
|
|
@ -332,7 +332,9 @@ void SoundEngine::updateMiniAudio()
|
|||
/////////////////////////////////////////////
|
||||
inline void SoundEngine::getGameModeMusicID(Minecraft* pMinecraft, unsigned int i)
|
||||
{
|
||||
if (pMinecraft->localplayers[i] != nullptr && pMinecraft->localplayers[i]->abilities.instabuild && pMinecraft->localplayers[i]->abilities.mayfly)
|
||||
auto player = pMinecraft->localplayers[i];
|
||||
|
||||
if (player != nullptr && ((player->abilities.instabuild && player->abilities.mayfly) || player->level->getLevelData()->getGameType()->isCreative()))
|
||||
m_musicID = getMusicID(eMusicType_Creative);
|
||||
// TODO(3UR): this is a part of minigames also in the future other minigame ids will need to be handled for now TU30 only checks for BATTLE
|
||||
//else if (pMinecraft->GetCustomGameMode() && CustomGameModeInst::GetId() == EMiniGameId::BATTLE) // @3UR: thanks https://github.com/GRAnimated/MinecraftLCE/blob/6947670d152582457bfe02bd909ee30a7ab7eb55/src/Minecraft.World/net/minecraft/world/level/gamemode/minigames/EMiniGameId.h#L3
|
||||
|
|
@ -812,27 +814,37 @@ void SoundEngine::playStreaming(const wstring& name, float x, float y, float z,
|
|||
|
||||
Minecraft *pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
bool playerInEnd = false;
|
||||
bool playerInNether = false;
|
||||
|
||||
unsigned int i = 0;
|
||||
for(i = 0; i < MAX_LOCAL_PLAYERS; i++)
|
||||
if (!pMinecraft || !pMinecraft->level)
|
||||
{
|
||||
if(pMinecraft->localplayers[i] != nullptr)
|
||||
{
|
||||
if(pMinecraft->localplayers[i]->dimension == LevelData::DIMENSION_END)
|
||||
playerInEnd = true;
|
||||
else if(pMinecraft->localplayers[i]->dimension == LevelData::DIMENSION_NETHER)
|
||||
playerInNether = true;
|
||||
}
|
||||
m_musicID = getMusicID(eMusicType_Menu);
|
||||
return;
|
||||
}
|
||||
|
||||
if(playerInEnd)
|
||||
bool inEnd = false, inNether = false, creative = false;
|
||||
|
||||
for (unsigned int i = 0; i < MAX_LOCAL_PLAYERS; ++i)
|
||||
{
|
||||
auto player = pMinecraft->localplayers[i];
|
||||
if (!player || !player->level) continue;
|
||||
|
||||
if (player->dimension == LevelData::DIMENSION_END)
|
||||
inEnd = true;
|
||||
else if (player->dimension == LevelData::DIMENSION_NETHER)
|
||||
inNether = true;
|
||||
|
||||
if (player->level->getLevelData() &&
|
||||
(player->level->getLevelData()->getGameType()->isCreative() || (player->abilities.instabuild && player->abilities.mayfly)))
|
||||
creative = true;
|
||||
}
|
||||
|
||||
if (inEnd)
|
||||
m_musicID = getMusicID(eMusicType_End);
|
||||
else if(playerInNether)
|
||||
else if (inNether)
|
||||
m_musicID = getMusicID(eMusicType_Nether);
|
||||
else if (creative)
|
||||
m_musicID = getMusicID(eMusicType_Creative);
|
||||
else
|
||||
getGameModeMusicID(pMinecraft, i);
|
||||
m_musicID = getMusicID(eMusicType_Overworld);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1125,7 +1137,6 @@ void SoundEngine::playMusicUpdate()
|
|||
strcpy((char *)m_szStreamName,m_szMusicPath);
|
||||
#endif
|
||||
// are we using a mash-up pack?
|
||||
//if(pMinecraft && !pMinecraft->skins->isUsingDefaultSkin() && pMinecraft->skins->getSelected()->hasAudio())
|
||||
if(Minecraft::GetInstance()->skins->getSelected()->hasAudio())
|
||||
{
|
||||
// It's a mash-up - need to use the DLC path for the music
|
||||
|
|
@ -1389,101 +1400,115 @@ void SoundEngine::playMusicUpdate()
|
|||
}
|
||||
if(GetIsPlayingStreamingGameMusic())
|
||||
{
|
||||
//if(m_MusicInfo.pCue!=nullptr)
|
||||
bool inEnd = false, inNether = false, creative = false, menu = false;
|
||||
Minecraft *pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if (!pMinecraft || !pMinecraft->level)
|
||||
{
|
||||
bool playerInEnd = false;
|
||||
bool playerInNether=false;
|
||||
Minecraft *pMinecraft = Minecraft::GetInstance();
|
||||
unsigned int i = 0;
|
||||
for(i = 0; i < MAX_LOCAL_PLAYERS; ++i)
|
||||
menu = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i = 0; i < MAX_LOCAL_PLAYERS; ++i)
|
||||
{
|
||||
if(pMinecraft->localplayers[i]!=nullptr)
|
||||
{
|
||||
if(pMinecraft->localplayers[i]->dimension==LevelData::DIMENSION_END)
|
||||
{
|
||||
playerInEnd=true;
|
||||
}
|
||||
else if(pMinecraft->localplayers[i]->dimension==LevelData::DIMENSION_NETHER)
|
||||
{
|
||||
playerInNether=true;
|
||||
}
|
||||
}
|
||||
auto player = pMinecraft->localplayers[i];
|
||||
if (!player || !player->level) continue;
|
||||
|
||||
if (player->dimension == LevelData::DIMENSION_END)
|
||||
inEnd = true;
|
||||
else if (player->dimension == LevelData::DIMENSION_NETHER)
|
||||
inNether = true;
|
||||
|
||||
if (player->level->getLevelData() &&
|
||||
(player->level->getLevelData()->getGameType()->isCreative() || (player->abilities.instabuild && player->abilities.mayfly)))
|
||||
creative = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(playerInEnd && !GetIsPlayingEndMusic())
|
||||
if (menu)
|
||||
{
|
||||
bool isPlayingMenu = (m_musicID >= m_iStream_Menu_Min && m_musicID <= m_iStream_Menu_Max);
|
||||
if (!isPlayingMenu)
|
||||
{
|
||||
m_StreamState=eMusicStreamState_Stop;
|
||||
|
||||
// Set the end track
|
||||
m_musicID = getMusicID(eMusicType_End);
|
||||
SetIsPlayingEndMusic(true);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
m_StreamState = eMusicStreamState_Stop;
|
||||
m_musicID = getMusicID(eMusicType_Menu);
|
||||
SetIsPlayingEndMusic(false);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
}
|
||||
else if(!playerInEnd && GetIsPlayingEndMusic())
|
||||
}
|
||||
else if (inEnd && !GetIsPlayingEndMusic())
|
||||
{
|
||||
m_StreamState = eMusicStreamState_Stop;
|
||||
m_musicID = getMusicID(eMusicType_End);
|
||||
SetIsPlayingEndMusic(true);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
}
|
||||
else if (!inEnd && GetIsPlayingEndMusic())
|
||||
{
|
||||
m_StreamState = eMusicStreamState_Stop;
|
||||
if (inNether)
|
||||
{
|
||||
if(playerInNether)
|
||||
{
|
||||
m_StreamState=eMusicStreamState_Stop;
|
||||
|
||||
// Set the end track
|
||||
m_musicID = getMusicID(eMusicType_Nether);
|
||||
SetIsPlayingEndMusic(false);
|
||||
SetIsPlayingNetherMusic(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_StreamState=eMusicStreamState_Stop;
|
||||
|
||||
// Set the end track
|
||||
m_musicID = getMusicID(eMusicType_Overworld);
|
||||
SetIsPlayingEndMusic(false);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
}
|
||||
}
|
||||
else if (playerInNether && !GetIsPlayingNetherMusic())
|
||||
{
|
||||
m_StreamState=eMusicStreamState_Stop;
|
||||
// set the Nether track
|
||||
m_musicID = getMusicID(eMusicType_Nether);
|
||||
m_musicID = getMusicID(eMusicType_Nether);
|
||||
SetIsPlayingEndMusic(false);
|
||||
SetIsPlayingNetherMusic(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_musicID = creative ? getMusicID(eMusicType_Creative)
|
||||
: getMusicID(eMusicType_Overworld);
|
||||
SetIsPlayingEndMusic(false);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
}
|
||||
}
|
||||
else if (inNether && !GetIsPlayingNetherMusic())
|
||||
{
|
||||
m_StreamState = eMusicStreamState_Stop;
|
||||
m_musicID = getMusicID(eMusicType_Nether);
|
||||
SetIsPlayingNetherMusic(true);
|
||||
SetIsPlayingEndMusic(false);
|
||||
}
|
||||
else if (!inNether && GetIsPlayingNetherMusic())
|
||||
{
|
||||
m_StreamState = eMusicStreamState_Stop;
|
||||
if (inEnd)
|
||||
{
|
||||
m_musicID = getMusicID(eMusicType_End);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
SetIsPlayingEndMusic(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_musicID = creative ? getMusicID(eMusicType_Creative)
|
||||
: getMusicID(eMusicType_Overworld);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
SetIsPlayingEndMusic(false);
|
||||
}
|
||||
else if(!playerInNether && GetIsPlayingNetherMusic())
|
||||
}
|
||||
else if (!inEnd && !inNether)
|
||||
{
|
||||
bool isPlayingCreative = (m_musicID >= m_iStream_Creative_Min &&
|
||||
m_musicID <= m_iStream_Creative_Max);
|
||||
if (creative && !isPlayingCreative)
|
||||
{
|
||||
if(playerInEnd)
|
||||
{
|
||||
m_StreamState=eMusicStreamState_Stop;
|
||||
// set the Nether track
|
||||
m_musicID = getMusicID(eMusicType_End);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
SetIsPlayingEndMusic(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_StreamState=eMusicStreamState_Stop;
|
||||
// set the Nether track
|
||||
m_musicID = getMusicID(eMusicType_Overworld);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
SetIsPlayingEndMusic(false);
|
||||
}
|
||||
m_StreamState = eMusicStreamState_Stop;
|
||||
m_musicID = getMusicID(eMusicType_Creative);
|
||||
}
|
||||
else if(!playerInEnd && !playerInNether)
|
||||
getGameModeMusicID(pMinecraft, i);
|
||||
|
||||
// volume change required?
|
||||
if (m_musicStreamActive)
|
||||
else if (!creative && isPlayingCreative)
|
||||
{
|
||||
float finalVolume = m_StreamingAudioInfo.volume * fMusicVol;
|
||||
|
||||
ma_sound_set_volume(&m_musicStream, finalVolume);
|
||||
m_StreamState = eMusicStreamState_Stop;
|
||||
m_musicID = getMusicID(eMusicType_Overworld);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_musicStreamActive)
|
||||
{
|
||||
float finalVolume = m_StreamingAudioInfo.volume * fMusicVol;
|
||||
ma_sound_set_volume(&m_musicStream, finalVolume);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Music disc playing - if it's a 3D stream, then set the position - we don't have any streaming audio in the world that moves, so this isn't
|
||||
// required unless we have more than one listener, and are setting the listening position to the origin and setting a fake position
|
||||
// for the sound down the z axis
|
||||
// Music disc playing - if it's a 3D stream, then set the position
|
||||
if (m_StreamingAudioInfo.bIs3D && m_validListenerCount > 1)
|
||||
{
|
||||
int iClosestListener = 0;
|
||||
|
|
@ -1522,47 +1547,60 @@ void SoundEngine::playMusicUpdate()
|
|||
case eMusicStreamState_Completed:
|
||||
{
|
||||
// random delay of up to 3 minutes for music
|
||||
m_iMusicDelay = random->nextInt(20 * 60 * 3);//random->nextInt(20 * 60 * 10) + 20 * 60 * 10;
|
||||
// Check if we have a local player in The Nether or in The End, and play that music if they are
|
||||
Minecraft *pMinecraft=Minecraft::GetInstance();
|
||||
bool playerInEnd=false;
|
||||
bool playerInNether=false;
|
||||
m_iMusicDelay = random->nextInt(20 * 60 * 3);
|
||||
|
||||
unsigned int i=0;
|
||||
for(i=0;i<MAX_LOCAL_PLAYERS;i++)
|
||||
bool inEnd = false, inNether = false, creative = false, menu = false;
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
|
||||
if (!pMinecraft || !pMinecraft->level)
|
||||
{
|
||||
if(pMinecraft->localplayers[i]!=nullptr)
|
||||
menu = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (unsigned int i = 0; i < MAX_LOCAL_PLAYERS; ++i)
|
||||
{
|
||||
if(pMinecraft->localplayers[i]->dimension==LevelData::DIMENSION_END)
|
||||
{
|
||||
playerInEnd=true;
|
||||
}
|
||||
else if(pMinecraft->localplayers[i]->dimension==LevelData::DIMENSION_NETHER)
|
||||
{
|
||||
playerInNether=true;
|
||||
}
|
||||
auto player = pMinecraft->localplayers[i];
|
||||
if (!player || !player->level) continue;
|
||||
|
||||
if (player->dimension == LevelData::DIMENSION_END)
|
||||
inEnd = true;
|
||||
else if (player->dimension == LevelData::DIMENSION_NETHER)
|
||||
inNether = true;
|
||||
|
||||
if (player->level->getLevelData() &&
|
||||
(player->level->getLevelData()->getGameType()->isCreative() || (player->abilities.instabuild && player->abilities.mayfly)))
|
||||
creative = true;
|
||||
}
|
||||
}
|
||||
if(playerInEnd)
|
||||
|
||||
if (inEnd)
|
||||
{
|
||||
m_musicID = getMusicID(eMusicType_End);
|
||||
m_musicID = getMusicID(eMusicType_End);
|
||||
SetIsPlayingEndMusic(true);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
}
|
||||
else if(playerInNether)
|
||||
else if (inNether)
|
||||
{
|
||||
m_musicID = getMusicID(eMusicType_Nether);
|
||||
m_musicID = getMusicID(eMusicType_Nether);
|
||||
SetIsPlayingNetherMusic(true);
|
||||
SetIsPlayingEndMusic(false);
|
||||
}
|
||||
else if(menu)
|
||||
{
|
||||
m_musicID = getMusicID(eMusicType_Menu);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
SetIsPlayingEndMusic(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_musicID = getMusicID(eMusicType_Overworld);
|
||||
m_musicID = creative ? getMusicID(eMusicType_Creative)
|
||||
: getMusicID(eMusicType_Overworld);
|
||||
SetIsPlayingNetherMusic(false);
|
||||
SetIsPlayingEndMusic(false);
|
||||
}
|
||||
|
||||
m_StreamState=eMusicStreamState_Idle;
|
||||
m_StreamState = eMusicStreamState_Idle;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ constexpr float SFX_MAX_GAIN = 1.5f;
|
|||
|
||||
enum eMusicFiles
|
||||
{
|
||||
// Survival domain tracks
|
||||
eStream_Overworld_Calm1 = 0,
|
||||
eStream_Overworld_Calm2,
|
||||
eStream_Overworld_Calm3,
|
||||
|
|
@ -23,7 +24,11 @@ enum eMusicFiles
|
|||
eStream_Overworld_hal4,
|
||||
eStream_Overworld_nuance1,
|
||||
eStream_Overworld_nuance2,
|
||||
// Add the new music tracks
|
||||
eStream_Overworld_piano1,
|
||||
eStream_Overworld_piano2,
|
||||
eStream_Overworld_piano3, // <-- make piano3 the last survival one
|
||||
|
||||
// Creative domain tracks
|
||||
eStream_Overworld_Creative1,
|
||||
eStream_Overworld_Creative2,
|
||||
eStream_Overworld_Creative3,
|
||||
|
|
@ -34,22 +39,23 @@ enum eMusicFiles
|
|||
eStream_Overworld_Menu2,
|
||||
eStream_Overworld_Menu3,
|
||||
eStream_Overworld_Menu4,
|
||||
eStream_Overworld_piano1,
|
||||
eStream_Overworld_piano2,
|
||||
eStream_Overworld_piano3, // <-- make piano3 the last overworld one
|
||||
|
||||
// Nether
|
||||
eStream_Nether1,
|
||||
eStream_Nether2,
|
||||
eStream_Nether3,
|
||||
eStream_Nether4,
|
||||
|
||||
// The End
|
||||
eStream_end_dragon,
|
||||
eStream_end_end,
|
||||
|
||||
// Battle
|
||||
eStream_BattleMode1,
|
||||
eStream_BattleMode2,
|
||||
eStream_BattleMode3,
|
||||
eStream_BattleMode4,
|
||||
|
||||
eStream_CD_1,
|
||||
eStream_CD_2,
|
||||
eStream_CD_3,
|
||||
|
|
|
|||
Loading…
Reference in a new issue