fCraft.Player.JoinWorld C# (CSharp) Method

JoinWorld() public method

public JoinWorld ( [ newWorld, WorldChangeReason reason ) : void
newWorld [
reason WorldChangeReason
return void
        public void JoinWorld( [NotNull] World newWorld, WorldChangeReason reason )
        {
            if ( newWorld == null )
                throw new ArgumentNullException( "newWorld" );
            lock ( joinWorldLock ) {
                useWorldSpawn = true;
                postJoinPosition = Position.Zero;
                forcedWorldToJoin = newWorld;
                worldChangeReason = reason;
            }
        }

Same methods

Player::JoinWorld ( [ newWorld, WorldChangeReason reason, Position position ) : void

Usage Example

Ejemplo n.º 1
0
        public static void RevertGun()    //Reverts names for online players. Offline players get reverted upon leaving the game
        {
            List <PlayerInfo> FFAPlayers = new List <PlayerInfo>(PlayerDB.PlayerInfoList.Where(r => (r.isPlayingFFA) && r.IsOnline).ToArray());

            foreach (PlayerInfo pI in FFAPlayers)
            {
                Player p = pI.PlayerObject;
                p.JoinWorld(p.World, WorldChangeReason.Rejoin);

                //reset all special messages
                if (p.SupportsMessageTypes)
                {
                    p.Send(PacketWriter.MakeSpecialMessage((byte)100, "&f"));
                    p.Send(PacketWriter.MakeSpecialMessage((byte)1, "&f"));
                    p.Send(PacketWriter.MakeSpecialMessage((byte)2, "&f"));
                }

                pI.isPlayingFFA = false;
                if (pI != null)
                {
                    //undo gunmode (taken from GunHandler.cs)
                    p.GunMode = false;
                    try
                    {
                        foreach (Vector3I block in p.GunCache.Values)
                        {
                            p.Send(PacketWriter.MakeSetBlock(block.X, block.Y, block.Z, p.WorldMap.GetBlock(block)));
                            Vector3I removed;
                            p.GunCache.TryRemove(block.ToString(), out removed);
                        }
                        if (p.bluePortal.Count > 0)
                        {
                            int j = 0;
                            foreach (Vector3I block in p.bluePortal)
                            {
                                if (p.WorldMap != null && p.World.IsLoaded)
                                {
                                    p.WorldMap.QueueUpdate(new BlockUpdate(null, block, p.blueOld[j]));
                                    j++;
                                }
                            }
                            p.blueOld.Clear();
                            p.bluePortal.Clear();
                        }
                        if (p.orangePortal.Count > 0)
                        {
                            int j = 0;
                            foreach (Vector3I block in p.orangePortal)
                            {
                                if (p.WorldMap != null && p.World.IsLoaded)
                                {
                                    p.WorldMap.QueueUpdate(new BlockUpdate(null, block, p.orangeOld[j]));
                                    j++;
                                }
                            }
                            p.orangeOld.Clear();
                            p.orangePortal.Clear();
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(LogType.SeriousError, "" + ex);
                    }
                    if (p.IsOnline)
                    {
                        p.Message("Your status has been reverted.");
                    }
                }
            }
        }
All Usage Examples Of fCraft.Player::JoinWorld