Provides data for Player.JoinedWorld event. Immutable.
Inheritance: System.EventArgs, IPlayerEvent
Beispiel #1
0
 public static void PlayerJoiningWorld ( object sender, PlayerJoinedWorldEventArgs e ) {
     foreach ( FeedData data in e.NewWorld.Feeds.Values.Where( f => !f.started ) ) {
         if ( data.world.Name == e.NewWorld.Name ) {
             data.Start();
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// Event which occurs when a player is joining a world
 /// </summary>
 /// <param name="e">event params</param>
 public static void Player_JoiningWorld( object sender, PlayerJoinedWorldEventArgs e )
 {
     World world = e.NewWorld;
     Player player = e.Player;
     if ( world != null ) { //run anti null checks
         if ( world.IsLoaded ) {
             if ( world.Map != null ) {
                 //Change the spawn position to block coords (X / 32, Y / 32, Z / 32)
                 Vector3I Pos = player.Position.ToBlockCoords();
                 bool foundPos = false;
                 //iterate from the maps height, to Zero. If a block is not equal to air, change the spawn point
                 for ( int z = Pos.Z; z > 0; z-- ) {
                     if ( world.Map.GetBlock( Pos.X, Pos.Y, z ) != Block.Air &&
                         world.Map.GetBlock( Pos.X, Pos.Y, z ) != Block.Undefined ) {
                         //Z + 3 so the player's feet are above the block pos
                         Position toSend = new Vector3I( Pos.X, Pos.Y, z + 3 ).ToPlayerCoords();
                         player.TeleportTo( toSend ); //teleport the player
                         foundPos = true;
                         break;
                     }
                 }
                 if ( !foundPos ) { //presume the map is empty and set the zPos to 0
                     Position toSend = new Vector3I( Pos.X, Pos.Y, 3 ).ToPlayerCoords();
                     player.TeleportTo( toSend ); //teleport the player
                 }
             }
         }
     }
 }
Beispiel #3
0
 //check if player left world where infection is being played
 public static void PlayerLeftWorld(object poo, fCraft.Events.PlayerJoinedWorldEventArgs e)
 {
     e.Player.Info.isPlayingInfection = false;
     if (e.Player.Info.isInfected)
     {
         e.Player.Info.isInfected = false;
         e.Player.entityChanged   = false;
         e.Player.iName           = null;
     }
 }
Beispiel #4
0
 public static void WorldChanging(object sender, PlayerJoinedWorldEventArgs e)
 {
     if (e.OldWorld != null)
     {
         if (e.OldWorld != e.NewWorld && e.NewWorld.GameOn)
         {
             if (!e.NewWorld.blueTeam.Contains(e.Player) && !e.NewWorld.redTeam.Contains(e.Player))
             {
                 TeamChooser(e.Player, e.NewWorld);
             }
         }
         else if (e.OldWorld.GameOn && e.OldWorld != e.NewWorld)
         {
             teamRemover(e.Player, e.OldWorld);
             e.Player.GunMode = false;
             foreach (Vector3I block in e.Player.GunCache.Values)
             {
                 e.Player.Send(PacketWriter.MakeSetBlock(block, world.Map.GetBlock(block)));
             }
         }
     }
 }
Beispiel #5
0
        public static void changedWorld(object sender, PlayerJoinedWorldEventArgs e)
        {
            try
            {
                if (e.OldWorld != null)
                {
                    if (e.OldWorld.Name == e.NewWorld.Name)
                    {
                        e.Player.orangeOld.Clear();
                        e.Player.orangePortal.Clear();
                        e.Player.blueOld.Clear();
                        e.Player.bluePortal.Clear();
                    }
                    if (e.OldWorld.IsLoaded)
                    {
                        Map map = e.OldWorld.Map;
                        if (e.Player.orangePortal.Count > 0)
                        {
                            int i = 0;
                            foreach (Vector3I block in e.Player.orangePortal)
                            {
                                map.QueueUpdate(new BlockUpdate(null, block, e.Player.orangeOld[i]));
                                i++;
                            }
                            e.Player.orangeOld.Clear();
                            e.Player.orangePortal.Clear();
                        }

                        if (e.Player.bluePortal.Count > 0)
                        {
                            int i = 0;
                            foreach (Vector3I block in e.Player.bluePortal)
                            {
                                map.QueueUpdate(new BlockUpdate(null, block, e.Player.blueOld[i]));
                                i++;
                            }
                            e.Player.blueOld.Clear();
                            e.Player.bluePortal.Clear();
                        }
                    }
                    else
                    {
                        if (e.Player.bluePortal.Count > 0)
                        {
                            e.OldWorld.Map.Blocks[e.OldWorld.Map.Index(e.Player.bluePortal[0])] = (byte)e.Player.blueOld[0];
                            e.OldWorld.Map.Blocks[e.OldWorld.Map.Index(e.Player.bluePortal[1])] = (byte)e.Player.blueOld[1];
                            e.Player.blueOld.Clear();
                            e.Player.bluePortal.Clear();
                        }
                        if (e.Player.orangePortal.Count > 0)
                        {
                            e.OldWorld.Map.Blocks[e.OldWorld.Map.Index(e.Player.orangePortal[0])] = (byte)e.Player.orangeOld[0];
                            e.OldWorld.Map.Blocks[e.OldWorld.Map.Index(e.Player.orangePortal[1])] = (byte)e.Player.orangeOld[1];
                            e.Player.orangeOld.Clear();
                            e.Player.orangePortal.Clear();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log(LogType.SeriousError, "GunPortalChangeWorld: " + ex);
            }
        }
 public void OnPlayerJoined(object sender, PlayerJoinedWorldEventArgs args)
 {
     lock (_lock)
     {
         if (args.NewWorld != args.OldWorld)
         {
             if (_world == args.NewWorld)
                 _tracker.AddPlayer(args.Player, args.Player.Position.ToBlockCoords());
         }
     }
 }
Beispiel #7
0
 void OnChangedWorld( object sender, PlayerJoinedWorldEventArgs e )
 {
     if ( e.OldWorld != null ) {
         if ( e.OldWorld.gameMode == GameMode.ZombieSurvival && e.NewWorld != e.OldWorld ) {
             if ( e.Player.iName != null )
                 RevertPlayerName( e.Player );
         } else if ( e.OldWorld.gameMode != GameMode.ZombieSurvival && e.NewWorld.gameMode == GameMode.ZombieSurvival ) {
             if ( e.NewWorld.Players.Where( p => p.iName == _zomb ).Count() > 0 ) {
                 e.Player.iName = _zomb;
                 e.Player.entityChanged = true;
                 e.Player.Message( "&WYou arrived late, so you are " + _zomb );
             }
             if ( e.Player.IsUsingWoM ) e.Player.Message( "&HUsing WoM? Be sure to turn off hacks" );
         }
     }
 }
Beispiel #8
0
		static void PlayerChangedWorld(object sender, PlayerJoinedWorldEventArgs e) {
			if (e.OldWorld == null) return;
			
			if (e.NewWorld == world) {
				if (!BlueTeam.Has(e.Player) && !RedTeam.Has(e.Player)) {
					ChooseTeamFor(e.Player, e.NewWorld);
				}
			} else if (e.OldWorld == world) {
				RemovePlayer(e.Player, e.OldWorld);
				
				if (BlueTeam.Count + RedTeam.Count == 0) {
					e.Player.Message("&sYou were the last player in the game, and thus, the game has ended.");
					Stop();
				}
			}
		}