Ejemplo n.º 1
0
        private void HandleGrabFlag(NetworkMessage msg)
        {
            MsgGrabFlag gf = msg as MsgGrabFlag;

            var          owner = PlayerList.GetPlayerByID(gf.PlayerID);
            FlagInstance flag  = SetFlagUpdateData(gf.FlagData);

            if (FlagGrabbed != null)
            {
                FlagGrabbed.Invoke(this, flag);
            }
        }
Ejemplo n.º 2
0
        public bool GrantFlag(ServerPlayer player, FlagInstance flag)
        {
            if (flag.Owner != null || player.Info.CariedFlag != null)
            {
                return(false);
            }

            OnGrantFlag?.Invoke(player, flag);

            FlagEventArgs args = new FlagEventArgs();

            args.Player = player;
            args.Flag   = flag;

            FlagPreGrab?.Invoke(this, args);

            if (flag.Status == FlagStatuses.FlagNoExist)
            {
                return(false);
            }

            lock (ActiveFlags)
            {
                if (!args.Allow || flag.Owner != null)
                {
                    return(false);
                }

                lock (WorldFlags)
                    WorldFlags.Remove(flag.FlagID);

                lock (CarriedFlags)
                    CarriedFlags.Add(flag.FlagID, flag);

                flag.Owner   = player;
                flag.Status  = FlagStatuses.FlagOnTank;
                flag.OwnerID = player.PlayerID;
            }

            FlagGrabbed?.Invoke(this, flag);

            player.Info.CariedFlag = flag;

            MsgGrabFlag grabMessage = new MsgGrabFlag();

            grabMessage.PlayerID = player.PlayerID;
            grabMessage.FlagData = flag;

            Logger.Log2("Player " + player.Callsign + " granted flag " + flag.FlagID.ToString() + " " + flag.ToString());

            Players.SendToAll(grabMessage, false);
            return(true);
        }