mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Implement healing events; fix #63
This commit is contained in:
1 parent
838508ca66
commit
4297622aa9
5 files changed
+83
-2
No files matched your search
@@ -0,0 +1,32 @@
|
||||
pub struct HealBonus {
|
||||
msg_router: tokio::sync::mpsc::Sender<crate::matches::GameMessage>,
|
||||
}
|
||||
|
||||
pub(super) fn handler(init_ctx: &crate::InitConfig) -> crate::handlers::SimpleRlnl<rlnl::events::ingame::HealAssistBonus, HealBonus> {
|
||||
crate::handlers::SimpleRlnl::new(HealBonus::new(init_ctx))
|
||||
}
|
||||
|
||||
impl HealBonus {
|
||||
fn new(init_ctx: &crate::InitConfig) -> Self {
|
||||
Self {
|
||||
msg_router: init_ctx.matches_chann.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl crate::handlers::RlnlEventCodeHandler for HealBonus {
|
||||
type In = rlnl::events::ingame::HealAssistBonus;
|
||||
const CODE: rlnl::event_code::NetworkEvent = rlnl::event_code::NetworkEvent::HeallingAssistBonusRequest;
|
||||
|
||||
async fn handle(&self, data: Self::In, _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 {
|
||||
log::info!("Heal assist for player {}", data.healing_player_id);
|
||||
super::log_channel_send_failure(self.msg_router.send(crate::matches::GameMessage::HealAssistBonus {
|
||||
user_id: user_info.user_id(),
|
||||
healer: data.healing_player_id,
|
||||
healee: data.healed_player_id,
|
||||
}).await);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ impl crate::handlers::RlnlEventCodeHandler for HealBonus {
|
||||
|
||||
async fn handle(&self, data: Self::In, _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::DestroyCubesBonus {
|
||||
super::log_channel_send_failure(self.msg_router.send(crate::matches::GameMessage::HealCubesBonus {
|
||||
user_id: user_info.user_id(),
|
||||
info: data,
|
||||
}).await);
|
||||
|
||||
@@ -16,6 +16,7 @@ mod assist_bonus;
|
||||
mod damage_bonus;
|
||||
mod heal_bonus;
|
||||
mod player_leave;
|
||||
mod heal_assist_bonus;
|
||||
|
||||
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))
|
||||
@@ -202,6 +203,21 @@ pub async fn handler(init_ctx: &crate::InitConfig) -> crate::handler::LnlEventHa
|
||||
rlnl::events::ingame::DestroyedHealedCubesBonus,
|
||||
>::handler(init_ctx))
|
||||
.add(player_leave::handler(init_ctx))
|
||||
.add(crate::handlers::Broadcaster::<
|
||||
false,
|
||||
{rlnl::event_code::NetworkEvent::LockOnNotification as i16},
|
||||
{rlnl::event_code::NetworkEvent::LockOnNotificationBroadcast as i16},
|
||||
{literustlib::packet::Property::ReliableOrdered as u8},
|
||||
rlnl::events::ingame::LockOnNotifier,
|
||||
>::handler(init_ctx))
|
||||
.add(crate::handlers::Broadcaster::<
|
||||
false,
|
||||
{rlnl::event_code::NetworkEvent::HealAlly as i16},
|
||||
{rlnl::event_code::NetworkEvent::HealAllyResponse as i16},
|
||||
{literustlib::packet::Property::ReliableOrdered as u8},
|
||||
rlnl::events::ingame::HealAllyCubes,
|
||||
>::handler(init_ctx))
|
||||
.add(heal_assist_bonus::handler(init_ctx))
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -242,6 +258,8 @@ mod _broadcast_impls {
|
||||
impl Broadcastable for rlnl::events::ingame::InitiateSurrender {}
|
||||
impl Broadcastable for rlnl::events::ingame::SurrenderVoteCast {}
|
||||
impl Broadcastable for rlnl::events::ingame::AwardProtoniumDestroyedCubes {}
|
||||
impl Broadcastable for rlnl::events::ingame::LockOnNotifier {}
|
||||
impl Broadcastable for rlnl::events::ingame::HealAllyCubes {}
|
||||
|
||||
impl Broadcastable for rlnl::events::sync::UpdateGameModeSettings {}
|
||||
impl Broadcastable for rlnl::events::sync::GetTeamBase {}
|
||||
|
||||
Reference in new issue
Block a user