示例#1
0
        internal void HandleFlagGrab(ServerPlayer player, MsgGrabFlag message)
        {
            if (message == null || !player.CanDoPlayActions())
            {
                return;
            }

            int flagID = message.FlagData.FlagID;

            FlagInstance candidateFlag = FindFlagByID(flagID);

            if (candidateFlag == null || !candidateFlag.Grabable())
            {
                return;
            }

            float dist = Vector3F.Distance(player.Info.LastSentUpdate.Position, candidateFlag.Position);

            if (false && dist > GetFlagGrabDistance(player))
            {
                return;
            }

            Logger.Log4("Player " + player.Callsign + " wants to grab flag " + candidateFlag.FlagID.ToString() + " " + candidateFlag.ToString());

            GrantFlag(player, candidateFlag);
        }
示例#2
0
        public void TransferFlag(ServerPlayer from, ServerPlayer to)
        {
            if (from == null || !from.CanDoPlayActions() || from.Info.CariedFlag == null)
            {
                return;
            }
            if (to == null || !to.CanDoPlayActions())
            {
                return;
            }

            FlagTransferEventArgs args = new FlagTransferEventArgs();

            args.From = from;
            args.To   = to;
            args.Flag = from.Info.CariedFlag;

            FlagPreTransfer?.Invoke(this, args);
            if (!args.Allow)
            {
                return;
            }

            DropFlag(to);
            from.Info.CariedFlag = null;
            to.Info.CariedFlag   = args.Flag;

            MsgTransferFlag transfer = new MsgTransferFlag();

            transfer.FromID = from.PlayerID;
            transfer.ToID   = to.PlayerID;
            transfer.FlagID = to.Info.CariedFlag.FlagID;

            Players.SendToAll(transfer, false);

            FlagTransfered?.Invoke(this, args);

            Logger.Log2("Flag transfered from  " + from.Callsign + " to " + to.Callsign);
        }