Distinguish birthday from finish events

This allows us to give birthdays a different effect in the future if we
want to.
This commit is contained in:
heinrich5991 2024-08-13 11:02:25 +02:00
parent c0ec918721
commit 585a36dd9d
8 changed files with 25 additions and 7 deletions

View file

@ -345,6 +345,8 @@ Objects = [
NetIntAny("m_Angle"),
]),
NetEventEx("Birthday:Common", "birthday@netevent.ddnet.org", []),
NetEventEx("Finish:Common", "finish@netevent.ddnet.org", []),
NetObjectEx("MyOwnEvent", "my-own-event@heinrich5991.de", [

View file

@ -226,7 +226,7 @@ void CEffects::PlayerDeath(vec2 Pos, int ClientId, float Alpha)
}
}
void CEffects::FinishConfetti(vec2 Pos, float Alpha)
void CEffects::Confetti(vec2 Pos, float Alpha)
{
ColorRGBA Red(1.0f, 0.4f, 0.4f);
ColorRGBA Green(0.4f, 1.0f, 0.4f);

View file

@ -30,7 +30,7 @@ public:
void PlayerDeath(vec2 Pos, int ClientId, float Alpha = 1.0f);
void PowerupShine(vec2 Pos, vec2 Size, float Alpha = 1.0f);
void FreezingFlakes(vec2 Pos, vec2 Size, float Alpha = 1.0f);
void FinishConfetti(vec2 Pos, float Alpha = 1.0f);
void Confetti(vec2 Pos, float Alpha = 1.0f);
void Update();
};

View file

@ -1183,10 +1183,15 @@ void CGameClient::ProcessEvents()
const CNetEvent_HammerHit *pEvent = (const CNetEvent_HammerHit *)Item.m_pData;
m_Effects.HammerHit(vec2(pEvent->m_X, pEvent->m_Y), Alpha);
}
else if(Item.m_Type == NETEVENTTYPE_BIRTHDAY)
{
const CNetEvent_Birthday *pEvent = (const CNetEvent_Birthday *)Item.m_pData;
m_Effects.Confetti(vec2(pEvent->m_X, pEvent->m_Y), Alpha);
}
else if(Item.m_Type == NETEVENTTYPE_FINISH)
{
const CNetEvent_Finish *pEvent = (const CNetEvent_Finish *)Item.m_pData;
m_Effects.FinishConfetti(vec2(pEvent->m_X, pEvent->m_Y), Alpha);
m_Effects.Confetti(vec2(pEvent->m_X, pEvent->m_Y), Alpha);
}
else if(Item.m_Type == NETEVENTTYPE_SPAWN)
{

View file

@ -345,7 +345,17 @@ void CGameContext::CreateDeath(vec2 Pos, int ClientId, CClientMask Mask)
}
}
void CGameContext::CreateFinishConfetti(vec2 Pos, CClientMask Mask)
void CGameContext::CreateBirthdayEffect(vec2 Pos, CClientMask Mask)
{
CNetEvent_Birthday *pEvent = m_Events.Create<CNetEvent_Birthday>(Mask);
if(pEvent)
{
pEvent->m_X = (int)Pos.x;
pEvent->m_Y = (int)Pos.y;
}
}
void CGameContext::CreateFinishEffect(vec2 Pos, CClientMask Mask)
{
CNetEvent_Finish *pEvent = m_Events.Create<CNetEvent_Finish>(Mask);
if(pEvent)

View file

@ -239,7 +239,8 @@ public:
void CreateHammerHit(vec2 Pos, CClientMask Mask = CClientMask().set());
void CreatePlayerSpawn(vec2 Pos, CClientMask Mask = CClientMask().set());
void CreateDeath(vec2 Pos, int ClientId, CClientMask Mask = CClientMask().set());
void CreateFinishConfetti(vec2 Pos, CClientMask Mask = CClientMask().set());
void CreateBirthdayEffect(vec2 Pos, CClientMask Mask = CClientMask().set());
void CreateFinishEffect(vec2 Pos, CClientMask Mask = CClientMask().set());
void CreateSound(vec2 Pos, int Sound, CClientMask Mask = CClientMask().set());
void CreateSoundGlobal(int Sound, int Target = -1) const;

View file

@ -937,7 +937,7 @@ void CPlayer::ProcessScoreResult(CScorePlayerResult &Result)
GameServer()->SendBroadcast(aBuf, m_ClientId);
m_BirthdayAnnounced = true;
GameServer()->CreateFinishConfetti(GetCharacter()->m_Pos, GetCharacter()->TeamMask());
GameServer()->CreateBirthdayEffect(GetCharacter()->m_Pos, GetCharacter()->TeamMask());
}
GameServer()->SendRecord(m_ClientId);
break;

View file

@ -854,7 +854,7 @@ void CGameTeams::OnFinish(CPlayer *Player, int TimeTicks, const char *pTimestamp
// Confetti
CCharacter *pChar = Player->GetCharacter();
m_pGameContext->CreateFinishConfetti(pChar->m_Pos, pChar->TeamMask());
m_pGameContext->CreateFinishEffect(pChar->m_Pos, pChar->TeamMask());
}
void CGameTeams::RequestTeamSwap(CPlayer *pPlayer, CPlayer *pTargetPlayer, int Team)