void HandlePlayerSpawning(Player p, ref Position pos, ref byte yaw, ref byte pitch, bool respawning)
 {
     if (!respawning || !Remaining.Contains(p))
     {
         return;
     }
     Map.Message(p.ColoredName + " &Sis out of countdown!");
     OnPlayerDied(p);
 }
        void HandlePlayerMove(Player p, Position next, byte yaw, byte pitch)
        {
            if (!RoundInProgress || !FreezeMode)
            {
                return;
            }
            if (!Remaining.Contains(p))
            {
                return;
            }

            int freezeX = p.Extras.GetInt("MCG_CD_X");
            int freezeZ = p.Extras.GetInt("MCG_CD_Z");

            if (next.X != freezeX || next.Z != freezeZ)
            {
                next.X = freezeX; next.Z = freezeZ;
                p.SendPos(Entities.SelfID, next, new Orientation(yaw, pitch));
            }

            p.Pos = next;
            p.SetYawPitch(yaw, pitch);
            p.cancelmove = true;
        }
Example #3
0
        protected override bool Receive(object message)
        {
            switch (message)
            {
            case WriteAck _:
                Remaining = Remaining.Remove(SenderAddress);
                if (IsDone)
                {
                    Reply(isTimeout: false);
                }
                return(true);

            case WriteNack _:
                _gotNackFrom = _gotNackFrom.Add(SenderAddress);
                if (IsDone)
                {
                    Reply(isTimeout: false);
                }
                return(true);

            case DeltaNack _:
                Sender.Tell(_write);
                return(true);

            case UpdateSuccess _:
                _gotLocalStoreReply = true;
                if (IsDone)
                {
                    Reply(isTimeout: false);
                }
                return(true);

            case StoreFailure _:
                _gotLocalStoreReply = true;
                _gotNackFrom        = _gotNackFrom.Add(_selfUniqueAddress.Address);
                if (IsDone)
                {
                    Reply(isTimeout: false);
                }
                return(true);

            case SendToSecondary _:
                if (_delta != null)
                {
                    // Deltas must be applied in order and we can't keep track of ordering of
                    // simultaneous updates so there is a chance that the delta could not be applied.
                    // Try again with the full state to the primary nodes that have not acked.
                    foreach (var address in PrimaryNodes)
                    {
                        if (Remaining.Contains(address))
                        {
                            Replica(address).Tell(_write);
                        }
                    }
                }

                foreach (var n in SecondaryNodes)
                {
                    Replica(n).Tell(_write);
                }
                return(true);

            case ReceiveTimeout _:
                Reply(isTimeout: true);
                return(true);
            }

            return(false);
        }