public void CScoreTeamKillReq(GameSession session, CScoreTeamKillReqMessage message) { var plr = session.Player; plr.RoomInfo.PeerId = message.Score.Target; var room = plr.Room; var killer = room.Players.GetValueOrDefault(message.Score.Killer.AccountId); if (killer == null) { return; } killer.RoomInfo.PeerId = message.Score.Killer; room.GameRuleManager.GameRule.OnScoreKill(killer, null, plr, message.Score.Weapon); }
public void CScoreTeamKillReq(GameSession session, CScoreTeamKillReqMessage message) { var plr = session.Player; if (message.Score.Target != plr.RoomInfo.PeerId) { return; } var room = plr.Room; var killer = room.Players.Values.FirstOrDefault(p => p.RoomInfo.PeerId == message.Score.Killer); if (killer == null) { return; } room.GameRuleManager.GameRule.OnScoreKill(killer, null, plr, message.Score.Weapon); }
[Firewall(typeof(MustBeTimeState), GameTimeState.HalfTime, Invert = true)] // Must not be half time public Task <bool> OnHandle(MessageContext context, CScoreTeamKillReqMessage message) { var session = context.GetSession <Session>(); var plr = session.Player; var room = plr.Room; if (plr.State != PlayerState.Alive) { return(Task.FromResult(true)); } var killer = room.Players.GetValueOrDefault(message.Score.Killer.AccountId); if (killer == null) { return(Task.FromResult(true)); } room.GameRule.OnScoreTeamKill( new ScoreContext(killer, message.Score.Killer.PeerId.ObjectType != 1 ? message.Score.Killer : null), new ScoreContext(plr, message.Score.Target.PeerId.ObjectType != 1 ? message.Score.Target : null), message.Score.Weapon); return(Task.FromResult(true)); }