mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Implement basic battle arena functionality #32
This commit is contained in:
1 parent
1403a6e3d0
commit
7f9ed8bf35
41 files changed
+1836
-327
No files matched your search
@@ -15,6 +15,7 @@ mod kill_bonus;
|
||||
mod assist_bonus;
|
||||
mod damage_bonus;
|
||||
mod heal_bonus;
|
||||
mod player_leave;
|
||||
|
||||
pub async fn handler(init_ctx: &crate::InitConfig) -> crate::handler::LnlEventHandler {
|
||||
crate::handler::LnlEventHandler::new(init_ctx.users.clone(), crate::vehicle_motion::handler(init_ctx))
|
||||
@@ -175,6 +176,23 @@ pub async fn handler(init_ctx: &crate::InitConfig) -> crate::handler::LnlEventHa
|
||||
>::handler(init_ctx))
|
||||
.add(self_destruct_elimination::handler(init_ctx))
|
||||
.add(map_ping::handler(init_ctx))
|
||||
// battle arena
|
||||
.add(crate::handlers::GamemodeSpecific::<
|
||||
{rlnl::event_code::NetworkEvent::SendDamagedByEnemyShield as i16},
|
||||
{literustlib::packet::Property::ReliableOrdered as u8},
|
||||
rlnl::events::ingame::DamagedByEnemyShield,
|
||||
>::handler(init_ctx))
|
||||
.add(crate::handlers::GamemodeSpecific::<
|
||||
{rlnl::event_code::NetworkEvent::SurrenderRequest as i16},
|
||||
{literustlib::packet::Property::ReliableOrdered as u8},
|
||||
rlnl::events::ingame::InitiateSurrender,
|
||||
>::handler(init_ctx))
|
||||
.add(crate::handlers::GamemodeSpecific::<
|
||||
{rlnl::event_code::NetworkEvent::AwardTeamBaseProtoniumDestroyedRequest as i16},
|
||||
{literustlib::packet::Property::ReliableOrdered as u8},
|
||||
rlnl::events::ingame::AwardProtoniumDestroyedCubes,
|
||||
>::handler(init_ctx))
|
||||
.add(player_leave::handler(init_ctx))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -211,8 +229,17 @@ mod _broadcast_impls {
|
||||
impl Broadcastable for rlnl::events::ingame::UpdateVotingAfterBattle {}
|
||||
impl Broadcastable for rlnl::events::ingame::TeleportActivateEffect {}
|
||||
impl Broadcastable for rlnl::events::ingame::MapPing {}
|
||||
impl Broadcastable for rlnl::events::ingame::DamagedByEnemyShield {}
|
||||
impl Broadcastable for rlnl::events::ingame::InitiateSurrender {}
|
||||
impl Broadcastable for rlnl::events::ingame::AwardProtoniumDestroyedCubes {}
|
||||
|
||||
impl Broadcastable for rlnl::events::sync::UpdateGameModeSettings {}
|
||||
impl Broadcastable for rlnl::events::sync::GetTeamBase {}
|
||||
impl Broadcastable for rlnl::events::sync::GetCapturePoints {}
|
||||
impl Broadcastable for rlnl::events::sync::GetEqualizer {}
|
||||
impl Broadcastable for rlnl::events::sync::FusionShieldState {}
|
||||
impl Broadcastable for rlnl::events::sync::EqualizerNotification {}
|
||||
impl Broadcastable for rlnl::events::GameTime {}
|
||||
impl Broadcastable for rlnl::events::ingame::TeamBaseState {}
|
||||
impl Broadcastable for rlnl::events::ingame::GameEnd {}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
pub struct PlayerQuit {
|
||||
msg_router: tokio::sync::mpsc::Sender<crate::matches::GameMessage>,
|
||||
}
|
||||
|
||||
pub(super) fn handler(init_ctx: &crate::InitConfig) -> crate::handlers::Dataless<PlayerQuit> {
|
||||
crate::handlers::Dataless::new(PlayerQuit::new(init_ctx))
|
||||
}
|
||||
|
||||
impl PlayerQuit {
|
||||
fn new(init_ctx: &crate::InitConfig) -> Self {
|
||||
Self {
|
||||
msg_router: init_ctx.matches_chann.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl crate::handlers::DatalessEventCodeHandler for PlayerQuit {
|
||||
const CODE: rlnl::event_code::NetworkEvent = rlnl::event_code::NetworkEvent::PlayerQuitRequest;
|
||||
|
||||
async fn handle(&self, _peer: &std::sync::Arc<literustlib_server::Connection<crate::PacketData>>, user: &crate::UserData, _sender: &std::sync::Arc<literustlib_server::DataSender<crate::PacketData>>) {
|
||||
if let Some(user_info) = user.user().await {
|
||||
super::log_channel_send_failure(self.msg_router.send(crate::matches::GameMessage::RequestLeave {
|
||||
user_id: user_info.user_id(),
|
||||
}).await);
|
||||
} else {
|
||||
log::error!("Failed to handle sync loading request for unknown user");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user