public static void SetSelection(Player player, Vector2[] selection)
        {
            if (isInSelectionlist(player))
                selectionPlayers.Remove(player.Name);

            selectionPlayers.Add(player.Name, selection);
        }
Пример #2
0
        public static List<String> SerializePlayer(Player player)
        {
            List<String> data = new List<String>();

            foreach (PropertyInfo info in player.GetType().GetProperties())
            {
                try
                {
                    if (!IgnoreFields.Contains(info.Name))
                    {
                        string pInfo = info.Name + ":";
                        //Type mType = info.GetValue(player, null).GetType();

                        object variable = info.GetValue(player, null);
                        if (variable is Vector2)
                        {
                            Vector2 vVar = (Vector2)variable;
                            data.Add(pInfo + variable.ToString() + " {" + vVar.X.ToString() + ", " + vVar.Y.ToString() + "}");
                        }
                        else
                            data.Add(pInfo + variable.ToString());
                    }
                }
                catch { }
            }

            return data;
        }
        public void removeGlobalWarp(Player player, string warpName)
        {
            Passport passport = passportManager.getPassport(player);
            // must be logged in to remove a global warp
            if (passport == null) {
                player.sendMessage("Error: Must be logged in to Passport to remove a global warp.", 255, 255f, 0f, 0f);
                return;
            }

            if (!globalWarpExists(warpName)) {
                player.sendMessage("Error: Global warp <" + warpName + "> does not exist.", 255, 255f, 0f, 0f);
                return;
            }

            User user = passport.getUser();
            Warp warp = null;
            globalWarpList.TryGetValue(warpName, out warp);

            // only allow if they own the warp
            if (globalOwnershipEnforced && !warp.owner.Equals(user.username)) {
                player.sendMessage("Error: Cannot delete global warp you do not own.", 255, 255f, 0f, 0f);
                warpDrivePlugin.Log(player.Name + " attempted to remove warp <" + warpName + "> unsuccessfully.");
                return;
            }

            globalWarpList.Remove(warpName);
            vault.store(globalWarpList);
            player.sendMessage("Global warp <" + warpName + "> removed.", 255, 0f, 255f, 255f);
            warpDrivePlugin.Log("<" + user.username + ">[" + player.Name + "] removed warp " + warpName);
        }
Пример #4
0
 public static void DeleteHouse(string PlayerName, string HouseName, Player Deleter)
 {
     int playerIndex = House.plugin.GetPlayerHouseIndex(PlayerName);
     if (playerIndex < 0)
     {
         Deleter.sendMessage("Invalid player", House.plugin.chatColor);
     }
     else
     {
         int playerHouseIndex = House.plugin.GetPlayerHouseIndex(PlayerName);
         if (playerHouseIndex < 0)
         {
             if (PlayerName == Deleter.Name)
             {
                 Deleter.sendMessage("You have no houses to delete", House.plugin.chatColor);
             }
             else
             {
                 Deleter.sendMessage("There are no houses to delete for " + PlayerName, House.plugin.chatColor);
             }
         }
         else
         {
             int coordsIndex = House.plugin.GetHouseCoordsIndexByName(PlayerName, HouseName);
             if (coordsIndex < 0)
                 Deleter.sendMessage("There is no house called " + HouseName, House.plugin.chatColor);
             else
             {
                 House.plugin.playerHouses[playerHouseIndex].Houses.RemoveAt(coordsIndex);
                 Deleter.sendMessage("You've deleted the house called " + HouseName, House.plugin.chatColor);
             }
         }
     }
 }
 public static Vector2[] GetSelection(Player player)
 {
     Vector2[] selections = null;
     if (isInSelectionlist(player) && selectionPlayers.TryGetValue(player.Name, out selections))
         return selections;
     else
         return null;
 }
        //This is what TDSM will check.
        public bool IsPermitted(string node, Player player)
        {
            User user;
            if (Permissions.users.TryGetValue(player.Name, out user))
                return ((player.AuthenticatedAs != null && IsUserAllowed(node, user)) || player.Op);

            return false;
        }
 public bool isPermitted(string node, Player player)
 {
     User user;
     if (users.TryGetValue(player.Name, out user))
     {
         if (user.hasPerm.Contains(node))
             return true;
     }
     return false;
 }
 public bool personalWarpExists(Player player, string warpName)
 {
     bool warpAlreadyExists = false;
     Passport passport = passportManager.getPassport(player);
     if (passport != null) {
         WarpList personalWarpList = getPersonalWarpList(player);
         if (personalWarpList != null) {
             warpAlreadyExists = personalWarpList.ContainsKey(warpName);
         }
     }
     return warpAlreadyExists;
 }
Пример #9
0
        //the following is taken and modified from Commands.cs from TDSM source. Thanks guys!!! ;)
        public bool highlightsearch(Player player, string nameOrID)
        {
            List<ItemInfo> itemlist;

            if (Server.TryFindItemByName(nameOrID, out itemlist) && itemlist.Count > 0)
            {
                if (itemlist.Count > 1)
                {
                    player.sendMessage("There were " + itemlist.Count + " Items found regarding the specified name");
                    return false;
                }

                foreach (ItemInfo id in itemlist)
                    highlightID = id.Type;
            }
            else
            {
                player.sendMessage("There were no Items found regarding the specified Item Id/Name");
                return false;
            }

            return true;
        }
 public void RemovePlayer(Player player)
 {
     if (isInSelectionlist(player))
         selectionPlayers.Remove(player.Name);
 }
Пример #11
0
 public void logIP(Player player)
 {
     string playername = player.Name.Replace ("'", @"\'");
     DateTime value = DateTime.Now;
     string time = value.ToString ("yyyyMMddHHmmssffff");
     // logs player IP to mysql table 'terraria_iplog'
     IDbConnection dbcon;
     dbcon = new MySqlConnection (connectionString);
     dbcon.Open();
     IDbCommand dbcmd = dbcon.CreateCommand ();
     string sql =
         "INSERT INTO terraria_iplog ( timestamp, player, ip ) " +
       				"VALUES ( '" + time + "', '" + playername + "', '" + player.IPAddress + "' )";
     dbcmd.CommandText = sql;
     IDataReader reader = dbcmd.ExecuteReader ();
     // clean up
     reader.Close();
     reader = null;
     dbcmd.Dispose ();
     dbcmd = null;
     dbcon.Close();
     dbcon = null;
     //end mysql
 }
Пример #12
0
        /// <summary>
        /// Spawns specified NPC type on specified player
        /// </summary>
        /// <param name="player">Instance of player to spawn on</param>
        /// <param name="playerIndex">Index of player to spawn on</param>
        /// <param name="Type">Type of NPC to spawn</param>
        public static void SpawnOnPlayer(Player player, int playerIndex, int Type)
        {
            if (Main.stopSpawns)
                return;

            bool flag = false;
            int x = 0;
            int y = 0;
            int minX = (int)(player.Position.X / 16f) - NPC.spawnRangeX * 3;
            int maxX = (int)(player.Position.X / 16f) + NPC.spawnRangeX * 3;
            int minY = (int)(player.Position.Y / 16f) - NPC.spawnRangeY * 3;
            int maxY = (int)(player.Position.Y / 16f) + NPC.spawnRangeY * 3;
            int xLeft = (int)(player.Position.X / 16f) - NPC.safeRangeX;
            int xRight = (int)(player.Position.X / 16f) + NPC.safeRangeX;
            int yLeft = (int)(player.Position.Y / 16f) - NPC.safeRangeY;
            int yRight = (int)(player.Position.Y / 16f) + NPC.safeRangeY;
            if (minX < 0)
            {
                minX = 0;
            }
            if (maxX >= Main.maxTilesX)
            {
                maxX = Main.maxTilesX - 1;
            }
            if (minY < 0)
            {
                minY = 0;
            }
            if (maxY >= Main.maxTilesY)
            {
                maxY = Main.maxTilesY - 1;
            }
            for (int i = 0; i < MAX_NPCS; i++)
            {
                int j = 0;
                while (j < 100)
                {
                    int tileX = Main.rand.Next(minX, maxX);
                    int tileY = Main.rand.Next(minY, maxY);
                    if (Main.tile.At(tileX, tileY).Active && Main.tileSolid[(int)Main.tile.At(tileX, tileY).Type])
                    {
                        if (!flag && !flag)
                        {
                            j++;
                            continue;
                        }
                        break;
                    }
                    if (Main.tile.At(tileX, tileY).Wall != 1)
                    {
                        int yTile = tileY;
                        while (yTile < Main.maxTilesY)
                        {
                            if (Main.tile.At(tileX, yTile).Active && Main.tileSolid[(int)Main.tile.At(tileX, yTile).Type])
                            {
                                if (tileX < xLeft || tileX > xRight || yTile < yLeft || yTile > yRight)
                                {
                                    //byte arg_220_0 = Main.tile.At(tileX, y).Type;
                                    x = tileX;
                                    y = yTile;
                                    flag = true;
                                    break;
                                }
                                break;
                            }
                            else
                            {
                                yTile++;
                            }
                        }
                        if (!flag)
                        {
                            if (!flag && !flag)
                            {
                                j++;
                                continue;
                            }
                            break;
                        }
                        int spawnMinX = x - NPC.spawnSpaceX / 2;
                        int spawnMaxX = x + NPC.spawnSpaceX / 2;
                        int spawnMinY = y - NPC.spawnSpaceY;
                        int spawnMaxY = y;
                        if (spawnMinX < 0)
                        {
                            flag = false;
                        }
                        if (spawnMaxX >= Main.maxTilesX)
                        {
                            flag = false;
                        }
                        if (spawnMinY < 0)
                        {
                            flag = false;
                        }
                        if (spawnMaxY >= Main.maxTilesY)
                        {
                            flag = false;
                        }
                        if (flag)
                        {
                            for (int l = spawnMinX; l < spawnMaxX; l++)
                            {
                                for (int m = spawnMinY; m < spawnMaxY; m++)
                                {
                                    if (Main.tile.At(l, m).Active && Main.tileSolid[(int)Main.tile.At(l, m).Type])
                                    {
                                        flag = false;
                                        break;
                                    }
                                }
                            }
                        }
                        if (!flag && !flag)
                        {
                            j++;
                            continue;
                        }
                        break;
                    }
                }
                if (flag)
                {
                    Rectangle rectangle = new Rectangle(x * 16, y * 16, 16, 16);
                    for (int n = 0; n < 255; n++)
                    {
                        if (Main.players[n].Active)
                        {
                            Rectangle rectangle2 = new Rectangle((int)(Main.players[n].Position.X + (float)(Main.players[n].Width / 2) - (float)(NPC.sWidth / 2) - (float)NPC.safeRangeX), (int)(Main.players[n].Position.Y + (float)(Main.players[n].Height / 2) - (float)(NPC.sHeight / 2) - (float)NPC.safeRangeY), NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
                            if (rectangle.Intersects(rectangle2))
                            {
                                flag = false;
                            }
                        }
                    }
                }
                if (flag)
                {
                    break;
                }
            }
            if (flag)
            {
                int npcIndex = NPC.NewNPC(x * 16 + 8, y * 16, Type, 1);
                Main.npcs[npcIndex].target = playerIndex;
                string str = Main.npcs[npcIndex].Name;
                if (Main.npcs[npcIndex].type == NPCType.N13_EATER_OF_WORLDS_HEAD)
                {
                    str = "Eater of Worlds";
                }
                if (Main.npcs[npcIndex].type == NPCType.N35_SKELETRON_HEAD)
                {
                    str = "Skeletron";
                }
                if (npcIndex < MAX_NPCS)
                {
                    NetMessage.SendData(23, -1, -1, "", npcIndex);
                }

                NetMessage.SendData(25, -1, -1, str + " has awoken!", 255, 175f, 75f, 255f);
            }
        }
 public bool isInSelectionlist(Player player)
 {
     return selectionPlayers.ContainsKey(player.Name);
 }
        public static bool IsRestrictedForUser(Player player, Region region, Node node)
        {
            if (UsingPermissions)
            {
                var Allowed = Program.permissionManager.IsPermittedImpl(node.Path, player);

                if (!Allowed)
                    return region.IsRestrictedForUser(player);

                return !Allowed;
            }

            return region.IsRestrictedForUser(player);
        }
 public static void SavePlayer(Player newPlayer)
 {
     string playerPath = Statics.PlayerPath + "\\" + newPlayer.Name;
     try
     {
         Directory.CreateDirectory(Statics.PlayerPath);
     }
     catch
     {
     }
     if (playerPath == null)
     {
         return;
     }
     string destFileName = playerPath + ".bak";
     if (File.Exists(playerPath))
     {
         File.Copy(playerPath, destFileName, true);
     }
     string text = playerPath + ".dat";
     using (FileStream fileStream = new FileStream(text, FileMode.Create))
     {
         using (BinaryWriter binaryWriter = new BinaryWriter(fileStream))
         {
             binaryWriter.Write(Statics.CURRENT_RELEASE);
             binaryWriter.Write(newPlayer.Name);
             binaryWriter.Write(newPlayer.hair);
             binaryWriter.Write(newPlayer.statLife);
             binaryWriter.Write(newPlayer.statLifeMax);
             binaryWriter.Write(newPlayer.statMana);
             binaryWriter.Write(newPlayer.statManaMax);
             binaryWriter.Write(newPlayer.hairColor.R);
             binaryWriter.Write(newPlayer.hairColor.G);
             binaryWriter.Write(newPlayer.hairColor.B);
             binaryWriter.Write(newPlayer.skinColor.R);
             binaryWriter.Write(newPlayer.skinColor.G);
             binaryWriter.Write(newPlayer.skinColor.B);
             binaryWriter.Write(newPlayer.eyeColor.R);
             binaryWriter.Write(newPlayer.eyeColor.G);
             binaryWriter.Write(newPlayer.eyeColor.B);
             binaryWriter.Write(newPlayer.shirtColor.R);
             binaryWriter.Write(newPlayer.shirtColor.G);
             binaryWriter.Write(newPlayer.shirtColor.B);
             binaryWriter.Write(newPlayer.underShirtColor.R);
             binaryWriter.Write(newPlayer.underShirtColor.G);
             binaryWriter.Write(newPlayer.underShirtColor.B);
             binaryWriter.Write(newPlayer.pantsColor.R);
             binaryWriter.Write(newPlayer.pantsColor.G);
             binaryWriter.Write(newPlayer.pantsColor.B);
             binaryWriter.Write(newPlayer.shoeColor.R);
             binaryWriter.Write(newPlayer.shoeColor.G);
             binaryWriter.Write(newPlayer.shoeColor.B);
             for (int i = 0; i < 8; i++)
             {
                 if (newPlayer.armor[i].Name == null)
                 {
                     newPlayer.armor[i].Name = "";
                 }
                 binaryWriter.Write(newPlayer.armor[i].Name);
             }
             for (int j = 0; j < 44; j++)
             {
                 if (newPlayer.inventory[j].Name == null)
                 {
                     newPlayer.inventory[j].Name = "";
                 }
                 binaryWriter.Write(newPlayer.inventory[j].Name);
                 binaryWriter.Write(newPlayer.inventory[j].Stack);
             }
             for (int k = 0; k < Chest.MAX_ITEMS; k++)
             {
                 if (newPlayer.bank[k].Name == null)
                 {
                     newPlayer.bank[k].Name = "";
                 }
                 binaryWriter.Write(newPlayer.bank[k].Name);
                 binaryWriter.Write(newPlayer.bank[k].Stack);
             }
             for (int l = 0; l < 200; l++)
             {
                 if (newPlayer.spN[l] == null)
                 {
                     binaryWriter.Write(-1);
                     break;
                 }
                 binaryWriter.Write(newPlayer.spX[l]);
                 binaryWriter.Write(newPlayer.spY[l]);
                 binaryWriter.Write(newPlayer.spI[l]);
                 binaryWriter.Write(newPlayer.spN[l]);
             }
             binaryWriter.Close();
         }
     }
     Player.EncryptFile(text, playerPath);
     File.Delete(text);
 }
        public static void OnPlayerLeft(Player player, ServerSlot slot, bool announced)
        {
            player.Active = false;

            if (announced)
            {
                ProgramLog.Users.Log ("{0} @ {1}: LEAVE {2}", slot.remoteAddress, slot.whoAmI, player.Name);

                var msg = NetMessage.PrepareThreadInstance();

                msg.SynchBegin (player.whoAmi, 0 /*inactive*/);

                if (player.DisconnectReason != null)
                    msg.PlayerChat (255, string.Concat (player.Name, " disconnected (", player.DisconnectReason, ")."), 255, 165, 0);
                else
                    msg.PlayerChat (255, string.Concat (player.Name, " has left."), 255, 240, 20);

                msg.BroadcastExcept (player.whoAmi);
            }

            PlayerLogoutEvent Event = new PlayerLogoutEvent();
            Event.Slot = null;
            Event.Sender = player;
            Program.server.PluginManager.processHook(Plugin.Hooks.PLAYER_LOGOUT, Event);
        }
 public static void SpawnOnPlayer(Player player, int playerIndex, int Type)
 {
     if (Main.netMode == 1)
     {
         return;
     }
     bool flag = false;
     int num = 0;
     int num2 = 0;
     int num3 = (int)(player.Position.X / 16f) - NPC.spawnRangeX * 3;
     int num4 = (int)(player.Position.X / 16f) + NPC.spawnRangeX * 3;
     int num5 = (int)(player.Position.Y / 16f) - NPC.spawnRangeY * 3;
     int num6 = (int)(player.Position.Y / 16f) + NPC.spawnRangeY * 3;
     int num7 = (int)(player.Position.X / 16f) - NPC.safeRangeX;
     int num8 = (int)(player.Position.X / 16f) + NPC.safeRangeX;
     int num9 = (int)(player.Position.Y / 16f) - NPC.safeRangeY;
     int num10 = (int)(player.Position.Y / 16f) + NPC.safeRangeY;
     if (num3 < 0)
     {
         num3 = 0;
     }
     if (num4 > Main.maxTilesX)
     {
         num4 = Main.maxTilesX;
     }
     if (num5 < 0)
     {
         num5 = 0;
     }
     if (num6 > Main.maxTilesY)
     {
         num6 = Main.maxTilesY;
     }
     for (int i = 0; i < 1000; i++)
     {
         int j = 0;
         while (j < 100)
         {
             int num11 = Main.rand.Next(num3, num4);
             int num12 = Main.rand.Next(num5, num6);
             if (Main.tile[num11, num12].Active && Main.tileSolid[(int)Main.tile[num11, num12].type])
             {
                 goto IL_2E1;
             }
             if (Main.tile[num11, num12].wall != 1)
             {
                 int k = num12;
                 while (k < Main.maxTilesY)
                 {
                     if (Main.tile[num11, k].Active && Main.tileSolid[(int)Main.tile[num11, k].type])
                     {
                         if (num11 < num7 || num11 > num8 || k < num9 || k > num10)
                         {
                             byte arg_220_0 = Main.tile[num11, k].type;
                             num = num11;
                             num2 = k;
                             flag = true;
                             break;
                         }
                         break;
                     }
                     else
                     {
                         k++;
                     }
                 }
                 if (!flag)
                 {
                     goto IL_2E1;
                 }
                 int num13 = num - NPC.spawnSpaceX / 2;
                 int num14 = num + NPC.spawnSpaceX / 2;
                 int num15 = num2 - NPC.spawnSpaceY;
                 int num16 = num2;
                 if (num13 < 0)
                 {
                     flag = false;
                 }
                 if (num14 > Main.maxTilesX)
                 {
                     flag = false;
                 }
                 if (num15 < 0)
                 {
                     flag = false;
                 }
                 if (num16 > Main.maxTilesY)
                 {
                     flag = false;
                 }
                 if (flag)
                 {
                     for (int l = num13; l < num14; l++)
                     {
                         for (int m = num15; m < num16; m++)
                         {
                             if (Main.tile[l, m].Active && Main.tileSolid[(int)Main.tile[l, m].type])
                             {
                                 flag = false;
                                 break;
                             }
                         }
                     }
                     goto IL_2E1;
                 }
                 goto IL_2E1;
             }
         IL_2E7:
             j++;
             continue;
         IL_2E1:
             if (!flag && !flag)
             {
                 goto IL_2E7;
             }
             break;
         }
         if (flag)
         {
             Rectangle rectangle = new Rectangle(num * 16, num2 * 16, 16, 16);
             for (int n = 0; n < 255; n++)
             {
                 if (Main.players[n].Active)
                 {
                     Rectangle rectangle2 = new Rectangle((int)(Main.players[n].Position.X + (float)(Main.players[n].width / 2) - (float)(NPC.sWidth / 2) - (float)NPC.safeRangeX), (int)(Main.players[n].Position.Y + (float)(Main.players[n].height / 2) - (float)(NPC.sHeight / 2) - (float)NPC.safeRangeY), NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
                     if (rectangle.Intersects(rectangle2))
                     {
                         flag = false;
                     }
                 }
             }
         }
         if (flag)
         {
             break;
         }
     }
     if (flag)
     {
         int num17 = NPC.NewNPC(num * 16 + 8, num2 * 16, Type, 1);
         Main.npc[num17].target = playerIndex;
         string str = Main.npc[num17].Name;
         if (Main.npc[num17].type == 13)
         {
             str = "Eater of Worlds";
         }
         if (Main.npc[num17].type == 35)
         {
             str = "Skeletron";
         }
         if (Main.netMode == 2 && num17 < 1000)
         {
             NetMessage.SendData(23, -1, -1, "", num17);
         }
         if (Main.netMode == 0)
         {
             return;
         }
         if (Main.netMode == 2)
         {
             NetMessage.SendData(25, -1, -1, str + " has awoken!", 255, 175f, 75f, 255f);
         }
     }
 }
        public void StatusPlayer(Player player)
        {
            switch (this.type)
            {
                case ProjectileType.N55_STINGER:
                    if (Main.rand.Next(3) == 0)
                        player.AddBuff(20, 600, true);
                    break;

                case ProjectileType.N44_DEMON_SICKLE:
                    if (Main.rand.Next(3) == 0)
                        player.AddBuff(22, 900, true);
                    break;
                case ProjectileType.N82_FLAMING_ARROW:
                    if (Main.rand.Next(3) == 0)
                        player.AddBuff(24, 420, true);
                    break;
                case ProjectileType.N96_CURSED_FLAME:
                    if (Main.rand.Next(3) == 0)
                        player.AddBuff(39, 480, true);
                    break;
                case ProjectileType.N101_EYE_FIRE:
                    if (Main.rand.Next(3) == 0)
                        player.AddBuff(39, 480, true);
                    break;
                case ProjectileType.N98_POISON_DART:
                    player.AddBuff(20, 600, true);
                    break;
            }
        }
 public object clientClone()
 {
     Player player = new Player();
     player.zoneEvil = this.zoneEvil;
     player.zoneMeteor = this.zoneMeteor;
     player.zoneDungeon = this.zoneDungeon;
     player.zoneJungle = this.zoneJungle;
     player.direction = this.direction;
     player.selectedItemIndex = this.selectedItemIndex;
     player.controlUp = this.controlUp;
     player.controlDown = this.controlDown;
     player.controlLeft = this.controlLeft;
     player.controlRight = this.controlRight;
     player.controlJump = this.controlJump;
     player.controlUseItem = this.controlUseItem;
     player.statLife = this.statLife;
     player.statLifeMax = this.statLifeMax;
     player.statMana = this.statMana;
     player.statManaMax = this.statManaMax;
     player.Position.X = this.Position.X;
     player.chest = this.chest;
     player.talkNPC = this.talkNPC;
     for (int i = 0; i < 44; i++)
     {
         player.inventory[i] = (Item)this.inventory[i].Clone();
         if (i < 8)
         {
             player.armor[i] = (Item)this.armor[i].Clone();
         }
     }
     return player;
 }
Пример #20
0
        /// <summary>
        /// Spawns specified NPC type on specified player
        /// </summary>
        /// <param name="player">Instance of player to spawn on</param>
        /// <param name="playerIndex">Index of player to spawn on</param>
        /// <param name="Type">Type of NPC to spawn</param>
        public static void SpawnOnPlayer(Player player, int playerIndex, int Type)
        {
            bool flag = false;
            int num = 0;
            int num2 = 0;
            int num3 = (int)(player.Position.X / 16f) - NPC.spawnRangeX * 3;
            int num4 = (int)(player.Position.X / 16f) + NPC.spawnRangeX * 3;
            int num5 = (int)(player.Position.Y / 16f) - NPC.spawnRangeY * 3;
            int num6 = (int)(player.Position.Y / 16f) + NPC.spawnRangeY * 3;
            int num7 = (int)(player.Position.X / 16f) - NPC.safeRangeX;
            int num8 = (int)(player.Position.X / 16f) + NPC.safeRangeX;
            int num9 = (int)(player.Position.Y / 16f) - NPC.safeRangeY;
            int num10 = (int)(player.Position.Y / 16f) + NPC.safeRangeY;
            if (num3 < 0)
            {
                num3 = 0;
            }
            if (num4 >= Main.maxTilesX)
            {
                num4 = Main.maxTilesX - 1;
            }
            if (num5 < 0)
            {
                num5 = 0;
            }
            if (num6 >= Main.maxTilesY)
            {
                num6 = Main.maxTilesY - 1;
            }
            for (int i = 0; i < 1000; i++)
            {
                int j = 0;
                while (j < 100)
                {
                    int num11 = Main.rand.Next(num3, num4);
                    int num12 = Main.rand.Next(num5, num6);
                    if (Main.tile.At(num11, num12).Active && Main.tileSolid[(int)Main.tile.At(num11, num12).Type])
                    {
                        goto IL_2E1;
                    }
                    if (Main.tile.At(num11, num12).Wall != 1)
                    {
                        int k = num12;
                        while (k < Main.maxTilesY)
                        {
                            if (Main.tile.At(num11, k).Active && Main.tileSolid[(int)Main.tile.At(num11, k).Type])
                            {
                                if (num11 < num7 || num11 > num8 || k < num9 || k > num10)
                                {
                                    byte arg_220_0 = Main.tile.At(num11, k).Type;
                                    num = num11;
                                    num2 = k;
                                    flag = true;
                                    break;
                                }
                                break;
                            }
                            else
                            {
                                k++;
                            }
                        }
                        if (!flag)
                        {
                            goto IL_2E1;
                        }
                        int num13 = num - NPC.spawnSpaceX / 2;
                        int num14 = num + NPC.spawnSpaceX / 2;
                        int num15 = num2 - NPC.spawnSpaceY;
                        int num16 = num2;
                        if (num13 < 0)
                        {
                            flag = false;
                        }
                        if (num14 >= Main.maxTilesX)
                        {
                            flag = false;
                        }
                        if (num15 < 0)
                        {
                            flag = false;
                        }
                        if (num16 >= Main.maxTilesY)
                        {
                            flag = false;
                        }
                        if (flag)
                        {
                            for (int l = num13; l < num14; l++)
                            {
                                for (int m = num15; m < num16; m++)
                                {
                                    if (Main.tile.At(l, m).Active && Main.tileSolid[(int)Main.tile.At(l, m).Type])
                                    {
                                        flag = false;
                                        break;
                                    }
                                }
                            }
                            goto IL_2E1;
                        }
                        goto IL_2E1;
                    }
                IL_2E7:
                    j++;
                    continue;
                IL_2E1:
                    if (!flag && !flag)
                    {
                        goto IL_2E7;
                    }
                    break;
                }
                if (flag)
                {
                    Rectangle rectangle = new Rectangle(num * 16, num2 * 16, 16, 16);
                    for (int n = 0; n < 255; n++)
                    {
                        if (Main.players[n].Active)
                        {
                            Rectangle rectangle2 = new Rectangle((int)(Main.players[n].Position.X + (float)(Main.players[n].Width / 2) - (float)(NPC.sWidth / 2) - (float)NPC.safeRangeX), (int)(Main.players[n].Position.Y + (float)(Main.players[n].Height / 2) - (float)(NPC.sHeight / 2) - (float)NPC.safeRangeY), NPC.sWidth + NPC.safeRangeX * 2, NPC.sHeight + NPC.safeRangeY * 2);
                            if (rectangle.Intersects(rectangle2))
                            {
                                flag = false;
                            }
                        }
                    }
                }
                if (flag)
                {
                    break;
                }
            }
            if (flag)
            {
                //Boss summon?
                NPCBossSummonEvent npcEvent = new NPCBossSummonEvent();
                npcEvent.BossType = Type;
                npcEvent.Sender = Main.players[playerIndex];
                Program.server.PluginManager.processHook(Hooks.NPC_BOSSSUMMON, npcEvent);
                if (npcEvent.Cancelled)
                {
                    return;
                }

                int npcIndex = NPC.NewNPC(num * 16 + 8, num2 * 16, Type, 1);
                Main.npcs[npcIndex].target = playerIndex;
                String str = Main.npcs[npcIndex].Name;
                if (Main.npcs[npcIndex].type == NPCType.N13_EATER_OF_WORLDS_HEAD)
                {
                    str = "Eater of Worlds";
                }
                if (Main.npcs[npcIndex].type == NPCType.N35_SKELETRON_HEAD)
                {
                    str = "Skeletron";
                }
                if (npcIndex < MAX_NPCS)
                {
                    NetMessage.SendData(23, -1, -1, "", npcIndex);
                }

                NetMessage.SendData(25, -1, -1, str + " has awoken!", 255, 175f, 75f, 255f);
            }
        }
Пример #21
0
 public static void TeleportToHouse(string PlayerName, string HouseName, Player Teleporter)
 {
     int playerIndex = House.plugin.GetPlayerHouseIndex(PlayerName);
     if (playerIndex < 0)
     {
         Teleporter.sendMessage("Invalid player", House.plugin.chatColor);
     }
     else
     {
         if (House.plugin.properties.PlayersCanTeleport || Teleporter.Op)
         {
             int houseIndex = House.plugin.GetHouseCoordsIndexByName(PlayerName, HouseName);
             if (houseIndex < 0)
             {
                 if (PlayerName == Teleporter.Name)
                     Teleporter.sendMessage("You don't have a house called " + HouseName, House.plugin.chatColor);
                 else
                     Teleporter.sendMessage(PlayerName + " doesn't have a house called " + HouseName, House.plugin.chatColor);
             }
             else
             {
                 Teleporter.sendMessage("Teleporting to " + HouseName, House.plugin.chatColor);
                 PlayerHouseCoords pHC = House.plugin.playerHouses[House.plugin.GetPlayerHouseIndex(PlayerName)].Houses[houseIndex];
                 if (pHC.TeleportPoint.X > 0 && pHC.TeleportPoint.Y > 0)
                     Teleporter.Teleport(pHC.TeleportPoint.X * 16, pHC.TeleportPoint.Y * 16);
                 else
                     Teleporter.Teleport(((pHC.TopLeft.X * 16) + (pHC.BottomRight.X * 16)) / 2,
                                           ((pHC.TopLeft.Y * 16) + (pHC.BottomRight.Y * 16)) / 2);
             }
         }
         else
             Teleporter.sendMessage("Only OPs can teleport to houses", House.plugin.chatColor);
     }
 }
 public void teleportTo(Player player)
 {
     this.teleportTo(player.Position.X, player.Position.Y);
 }
 public Boolean IsRestrictedForUser(Player player)
 {
     return (Restricted && player.Op || !player.Op && !ContainsUser(player.Name) && !ContainsUser(player.IPAddress));
 }
 public bool isPermitted(Node node, Player player)
 {
     return false;
 }
 public static Boolean isInSelectionlist(Player player)
 {
     return selectionPlayers.ContainsKey(player.Name);
 }
 public static void KillTile(int i, int j, bool fail = false, bool effectOnly = false, bool noItem = false, Player player = null)
 {
     if (i >= 0 && j >= 0 && i < Main.maxTilesX && j < Main.maxTilesY)
     {
         if (Main.tile.At(i, j).Active)
         {
             if (j >= 1 && Main.tile.At(i, j - 1).Active && ((Main.tile.At(i, j - 1).Type == 5 && Main.tile.At(i, j).Type != 5) || (Main.tile.At(i, j - 1).Type == 21 && Main.tile.At(i, j).Type != 21) || (Main.tile.At(i, j - 1).Type == 26 && Main.tile.At(i, j).Type != 26) || (Main.tile.At(i, j - 1).Type == 72 && Main.tile.At(i, j).Type != 72) || (Main.tile.At(i, j - 1).Type == 12 && Main.tile.At(i, j).Type != 12)) && (Main.tile.At(i, j - 1).Type != 5 || ((Main.tile.At(i, j - 1).FrameX != 66 || Main.tile.At(i, j - 1).FrameY < 0 || Main.tile.At(i, j - 1).FrameY > 44) && (Main.tile.At(i, j - 1).FrameX != 88 || Main.tile.At(i, j - 1).FrameY < 66 || Main.tile.At(i, j - 1).FrameY > 110) && Main.tile.At(i, j - 1).FrameY < 198)))
             {
                 return;
             }
             if (!effectOnly && !WorldGen.stopDrops)
             {
                 if (Main.tile.At(i, j).Type == 3)
                 {
                     if (Main.tile.At(i, j).FrameX == 144)
                     {
                         Item.NewItem(i * 16, j * 16, 16, 16, 5, 1, false);
                     }
                 }
                 else
                 {
                     if (Main.tile.At(i, j).Type == 24)
                     {
                         if (Main.tile.At(i, j).FrameX == 144)
                         {
                             Item.NewItem(i * 16, j * 16, 16, 16, 60, 1, false);
                         }
                     }
                 }
             }
             if (effectOnly)
             {
                 return;
             }
             if (fail)
             {
                 if (Main.tile.At(i, j).Type == 2 || Main.tile.At(i, j).Type == 23)
                 {
                     Main.tile.At(i, j).SetType (0);
                 }
                 if (Main.tile.At(i, j).Type == 60 || Main.tile.At(i, j).Type == 70)
                 {
                     Main.tile.At(i, j).SetType (59);
                 }
                 WorldGen.SquareTileFrame(i, j, true);
                 return;
             }
             if (Main.tile.At(i, j).Type == 21)
             {
                 int l = (int)(Main.tile.At(i, j).FrameX / 18);
                 int y = j - (int)(Main.tile.At(i, j).FrameY / 18);
                 while (l > 1)
                 {
                     l -= 2;
                 }
                 l = i - l;
                 if (!Chest.DestroyChest(l, y))
                 {
                     return;
                 }
             }
             if (!noItem && !WorldGen.stopDrops)
             {
                 int num4 = 0;
                 if (Main.tile.At(i, j).Type == 0 || Main.tile.At(i, j).Type == 2)
                 {
                     num4 = 2;
                 }
                 else
                 {
                     if (Main.tile.At(i, j).Type == 1)
                     {
                         num4 = 3;
                     }
                     else
                     {
                         if (Main.tile.At(i, j).Type == 3 || Main.tile.At(i, j).Type == 73)
                         {
                             if (Main.rand.Next(2) == 0 && Main.players[(int)Player.FindClosest(new Vector2((float)(i * 16), (float)(j * 16)), 16, 16)].HasItem(281))
                             {
                                 num4 = 283;
                             }
                         }
                         else
                         {
                             if (Main.tile.At(i, j).Type == 4)
                             {
                                 num4 = 8;
                             }
                             else
                             {
                                 if (Main.tile.At(i, j).Type == 5)
                                 {
                                     if (Main.tile.At(i, j).FrameX >= 22 && Main.tile.At(i, j).FrameY >= 198)
                                     {
                                         if (WorldGen.genRand.Next(2) == 0)
                                         {
                                             int num5 = j;
                                             while ((!Main.tile.At(i, num5).Active || !Main.tileSolid[(int)Main.tile.At(i, num5).Type] || Main.tileSolidTop[(int)Main.tile.At(i, num5).Type]))
                                             {
                                                 num5++;
                                             }
                                             if (Main.tile.At(i, num5).Type == 2)
                                             {
                                                 num4 = 27;
                                             }
                                             else
                                             {
                                                 num4 = 9;
                                             }
                                         }
                                         else
                                         {
                                             num4 = 9;
                                         }
                                     }
                                     else
                                     {
                                         num4 = 9;
                                     }
                                 }
                                 else
                                 {
                                     if (Main.tile.At(i, j).Type == 6)
                                     {
                                         num4 = 11;
                                     }
                                     else
                                     {
                                         if (Main.tile.At(i, j).Type == 7)
                                         {
                                             num4 = 12;
                                         }
                                         else
                                         {
                                             if (Main.tile.At(i, j).Type == 8)
                                             {
                                                 num4 = 13;
                                             }
                                             else
                                             {
                                                 if (Main.tile.At(i, j).Type == 9)
                                                 {
                                                     num4 = 14;
                                                 }
                                                 else
                                                 {
                                                     if (Main.tile.At(i, j).Type == 13)
                                                     {
                                                         if (Main.tile.At(i, j).FrameX == 18)
                                                         {
                                                             num4 = 28;
                                                         }
                                                         else
                                                         {
                                                             if (Main.tile.At(i, j).FrameX == 36)
                                                             {
                                                                 num4 = 110;
                                                             }
                                                             else
                                                             {
                                                                 num4 = 31;
                                                             }
                                                         }
                                                     }
                                                     else
                                                     {
                                                         if (Main.tile.At(i, j).Type == 19)
                                                         {
                                                             num4 = 94;
                                                         }
                                                         else
                                                         {
                                                             if (Main.tile.At(i, j).Type == 22)
                                                             {
                                                                 num4 = 56;
                                                             }
                                                             else
                                                             {
                                                                 if (Main.tile.At(i, j).Type == 23)
                                                                 {
                                                                     num4 = 2;
                                                                 }
                                                                 else
                                                                 {
                                                                     if (Main.tile.At(i, j).Type == 25)
                                                                     {
                                                                         num4 = 61;
                                                                     }
                                                                     else
                                                                     {
                                                                         if (Main.tile.At(i, j).Type == 30)
                                                                         {
                                                                             num4 = 9;
                                                                         }
                                                                         else
                                                                         {
                                                                             if (Main.tile.At(i, j).Type == 33)
                                                                             {
                                                                                 num4 = 105;
                                                                             }
                                                                             else
                                                                             {
                                                                                 if (Main.tile.At(i, j).Type == 37)
                                                                                 {
                                                                                     num4 = 116;
                                                                                 }
                                                                                 else
                                                                                 {
                                                                                     if (Main.tile.At(i, j).Type == 38)
                                                                                     {
                                                                                         num4 = 129;
                                                                                     }
                                                                                     else
                                                                                     {
                                                                                         if (Main.tile.At(i, j).Type == 39)
                                                                                         {
                                                                                             num4 = 131;
                                                                                         }
                                                                                         else
                                                                                         {
                                                                                             if (Main.tile.At(i, j).Type == 40)
                                                                                             {
                                                                                                 num4 = 133;
                                                                                             }
                                                                                             else
                                                                                             {
                                                                                                 if (Main.tile.At(i, j).Type == 41)
                                                                                                 {
                                                                                                     num4 = 134;
                                                                                                 }
                                                                                                 else
                                                                                                 {
                                                                                                     if (Main.tile.At(i, j).Type == 43)
                                                                                                     {
                                                                                                         num4 = 137;
                                                                                                     }
                                                                                                     else
                                                                                                     {
                                                                                                         if (Main.tile.At(i, j).Type == 44)
                                                                                                         {
                                                                                                             num4 = 139;
                                                                                                         }
                                                                                                         else
                                                                                                         {
                                                                                                             if (Main.tile.At(i, j).Type == 45)
                                                                                                             {
                                                                                                                 num4 = 141;
                                                                                                             }
                                                                                                             else
                                                                                                             {
                                                                                                                 if (Main.tile.At(i, j).Type == 46)
                                                                                                                 {
                                                                                                                     num4 = 143;
                                                                                                                 }
                                                                                                                 else
                                                                                                                 {
                                                                                                                     if (Main.tile.At(i, j).Type == 47)
                                                                                                                     {
                                                                                                                         num4 = 145;
                                                                                                                     }
                                                                                                                     else
                                                                                                                     {
                                                                                                                         if (Main.tile.At(i, j).Type == 48)
                                                                                                                         {
                                                                                                                             num4 = 147;
                                                                                                                         }
                                                                                                                         else
                                                                                                                         {
                                                                                                                             if (Main.tile.At(i, j).Type == 49)
                                                                                                                             {
                                                                                                                                 num4 = 148;
                                                                                                                             }
                                                                                                                             else
                                                                                                                             {
                                                                                                                                 if (Main.tile.At(i, j).Type == 51)
                                                                                                                                 {
                                                                                                                                     num4 = 150;
                                                                                                                                 }
                                                                                                                                 else
                                                                                                                                 {
                                                                                                                                     if (Main.tile.At(i, j).Type == 53)
                                                                                                                                     {
                                                                                                                                         num4 = 169;
                                                                                                                                     }
                                                                                                                                     else
                                                                                                                                     {
                                                                                                                                         if (Main.tile.At(i, j).Type != 54)
                                                                                                                                         {
                                                                                                                                             if (Main.tile.At(i, j).Type == 56)
                                                                                                                                             {
                                                                                                                                                 num4 = 173;
                                                                                                                                             }
                                                                                                                                             else
                                                                                                                                             {
                                                                                                                                                 if (Main.tile.At(i, j).Type == 57)
                                                                                                                                                 {
                                                                                                                                                     num4 = 172;
                                                                                                                                                 }
                                                                                                                                                 else
                                                                                                                                                 {
                                                                                                                                                     if (Main.tile.At(i, j).Type == 58)
                                                                                                                                                     {
                                                                                                                                                         num4 = 174;
                                                                                                                                                     }
                                                                                                                                                     else
                                                                                                                                                     {
                                                                                                                                                         if (Main.tile.At(i, j).Type == 60)
                                                                                                                                                         {
                                                                                                                                                             num4 = 176;
                                                                                                                                                         }
                                                                                                                                                         else
                                                                                                                                                         {
                                                                                                                                                             if (Main.tile.At(i, j).Type == 70)
                                                                                                                                                             {
                                                                                                                                                                 num4 = 176;
                                                                                                                                                             }
                                                                                                                                                             else
                                                                                                                                                             {
                                                                                                                                                                 if (Main.tile.At(i, j).Type == 75)
                                                                                                                                                                 {
                                                                                                                                                                     num4 = 192;
                                                                                                                                                                 }
                                                                                                                                                                 else
                                                                                                                                                                 {
                                                                                                                                                                     if (Main.tile.At(i, j).Type == 76)
                                                                                                                                                                     {
                                                                                                                                                                         num4 = 214;
                                                                                                                                                                     }
                                                                                                                                                                     else
                                                                                                                                                                     {
                                                                                                                                                                         if (Main.tile.At(i, j).Type == 78)
                                                                                                                                                                         {
                                                                                                                                                                             num4 = 222;
                                                                                                                                                                         }
                                                                                                                                                                         else
                                                                                                                                                                         {
                                                                                                                                                                             if (Main.tile.At(i, j).Type == 81)
                                                                                                                                                                             {
                                                                                                                                                                                 num4 = 275;
                                                                                                                                                                             }
                                                                                                                                                                             else
                                                                                                                                                                             {
                                                                                                                                                                                 if (Main.tile.At(i, j).Type == 80)
                                                                                                                                                                                 {
                                                                                                                                                                                     num4 = 276;
                                                                                                                                                                                 }
                                                                                                                                                                                 else
                                                                                                                                                                                 {
                                                                                                                                                                                     if (Main.tile.At(i, j).Type == 61 || Main.tile.At(i, j).Type == 74)
                                                                                                                                                                                     {
                                                                                                                                                                                         if (Main.tile.At(i, j).FrameX == 162)
                                                                                                                                                                                         {
                                                                                                                                                                                             num4 = 223;
                                                                                                                                                                                         }
                                                                                                                                                                                         else
                                                                                                                                                                                         {
                                                                                                                                                                                             if (Main.tile.At(i, j).FrameX >= 108 && Main.tile.At(i, j).FrameX <= 126 && (double)j > Main.rockLayer)
                                                                                                                                                                                             {
                                                                                                                                                                                                 if (WorldGen.genRand.Next(2) == 0)
                                                                                                                                                                                                 {
                                                                                                                                                                                                     num4 = 208;
                                                                                                                                                                                                 }
                                                                                                                                                                                             }
                                                                                                                                                                                             else
                                                                                                                                                                                             {
                                                                                                                                                                                                 if (WorldGen.genRand.Next(100) == 0)
                                                                                                                                                                                                 {
                                                                                                                                                                                                     num4 = 195;
                                                                                                                                                                                                 }
                                                                                                                                                                                             }
                                                                                                                                                                                         }
                                                                                                                                                                                     }
                                                                                                                                                                                     else
                                                                                                                                                                                     {
                                                                                                                                                                                         if (Main.tile.At(i, j).Type == 59 || Main.tile.At(i, j).Type == 60)
                                                                                                                                                                                         {
                                                                                                                                                                                             num4 = 176;
                                                                                                                                                                                         }
                                                                                                                                                                                         else
                                                                                                                                                                                         {
                                                                                                                                                                                             if (Main.tile.At(i, j).Type == 71 || Main.tile.At(i, j).Type == 72)
                                                                                                                                                                                             {
                                                                                                                                                                                                 if (WorldGen.genRand.Next(50) == 0)
                                                                                                                                                                                                 {
                                                                                                                                                                                                     num4 = 194;
                                                                                                                                                                                                 }
                                                                                                                                                                                                 else
                                                                                                                                                                                                 {
                                                                                                                                                                                                     if (WorldGen.genRand.Next(2) == 0)
                                                                                                                                                                                                     {
                                                                                                                                                                                                         num4 = 183;
                                                                                                                                                                                                     }
                                                                                                                                                                                                 }
                                                                                                                                                                                             }
                                                                                                                                                                                             else
                                                                                                                                                                                             {
                                                                                                                                                                                                 if (Main.tile.At(i, j).Type >= 63 && Main.tile.At(i, j).Type <= 68)
                                                                                                                                                                                                 {
                                                                                                                                                                                                     num4 = (int)(Main.tile.At(i, j).Type - 63 + 177);
                                                                                                                                                                                                 }
                                                                                                                                                                                                 else
                                                                                                                                                                                                 {
                                                                                                                                                                                                     if (Main.tile.At(i, j).Type == 50)
                                                                                                                                                                                                     {
                                                                                                                                                                                                         if (Main.tile.At(i, j).FrameX == 90)
                                                                                                                                                                                                         {
                                                                                                                                                                                                             num4 = 165;
                                                                                                                                                                                                         }
                                                                                                                                                                                                         else
                                                                                                                                                                                                         {
                                                                                                                                                                                                             num4 = 149;
                                                                                                                                                                                                         }
                                                                                                                                                                                                     }
                                                                                                                                                                                                     else
                                                                                                                                                                                                     {
                                                                                                                                                                                                         if (Main.tileAlch[(int)Main.tile.At(i, j).Type] && Main.tile.At(i, j).Type > 82)
                                                                                                                                                                                                         {
                                                                                                                                                                                                             int num6 = (int)(Main.tile.At(i, j).FrameX / 18);
                                                                                                                                                                                                             bool flag = false;
                                                                                                                                                                                                             if (Main.tile.At(i, j).Type == 84)
                                                                                                                                                                                                             {
                                                                                                                                                                                                                 flag = true;
                                                                                                                                                                                                             }
                                                                                                                                                                                                             if (num6 == 0 && Main.dayTime)
                                                                                                                                                                                                             {
                                                                                                                                                                                                                 flag = true;
                                                                                                                                                                                                             }
                                                                                                                                                                                                             if (num6 == 1 && !Main.dayTime)
                                                                                                                                                                                                             {
                                                                                                                                                                                                                 flag = true;
                                                                                                                                                                                                             }
                                                                                                                                                                                                             if (num6 == 3 && Main.bloodMoon)
                                                                                                                                                                                                             {
                                                                                                                                                                                                                 flag = true;
                                                                                                                                                                                                             }
                                                                                                                                                                                                             num4 = 313 + num6;
                                                                                                                                                                                                             if (flag)
                                                                                                                                                                                                             {
                                                                                                                                                                                                                 Item.NewItem(i * 16, j * 16, 16, 16, 307 + num6, WorldGen.genRand.Next(1, 4), false);
                                                                                                                                                                                                             }
                                                                                                                                                                                                         }
                                                                                                                                                                                                     }
                                                                                                                                                                                                 }
                                                                                                                                                                                             }
                                                                                                                                                                                         }
                                                                                                                                                                                     }
                                                                                                                                                                                 }
                                                                                                                                                                             }
                                                                                                                                                                         }
                                                                                                                                                                     }
                                                                                                                                                                 }
                                                                                                                                                             }
                                                                                                                                                         }
                                                                                                                                                     }
                                                                                                                                                 }
                                                                                                                                             }
                                                                                                                                         }
                                                                                                                                     }
                                                                                                                                 }
                                                                                                                             }
                                                                                                                         }
                                                                                                                     }
                                                                                                                 }
                                                                                                             }
                                                                                                         }
                                                                                                     }
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if (num4 > 0)
                 {
                     Item.NewItem(i * 16, j * 16, 16, 16, num4, 1, false);
                 }
             }
             Main.tile.At(i, j).SetActive (false);
             if (Main.tileSolid[(int)Main.tile.At(i, j).Type])
             {
                 Main.tile.At(i, j).SetLighted (false);
             }
             Main.tile.At(i, j).SetFrameX (-1);
             Main.tile.At(i, j).SetFrameY (-1);
             Main.tile.At(i, j).SetFrameNumber (0);
             Main.tile.At(i, j).SetType (0);
             WorldGen.SquareTileFrame(i, j, true);
         }
     }
 }
        public static bool IsRestricted(Node node, Player player)
        {
            if (IsRunningPermissions())
            {
                var isPermitted = Program.permissionManager.IsPermittedImpl(node.Path, player);
                var isOp = player.Op;

                return !isPermitted && !isOp;
            }

            return !player.Op;
        }
        public static void OnPlayerLeft(Player player, ServerSlot slot, bool announced)
        {
            player.Active = false;

            if (announced)
            {
                ProgramLog.Users.Log ("{0} @ {1}: LEAVE {2}", slot.remoteAddress, slot.whoAmI, player.Name);

                var msg = NetMessage.PrepareThreadInstance();

                msg.SynchBegin (player.whoAmi, 0 /*inactive*/);

                if (player.DisconnectReason != null)
                    msg.PlayerChat (255, string.Concat (player.Name, " disconnected (", player.DisconnectReason, ")."), 255, 165, 0);
                else
                    msg.PlayerChat (255, string.Concat (player.Name, " has left."), 255, 240, 20);

                msg.BroadcastExcept (player.whoAmi);
            }

            var ctx = new HookContext
            {
                Player = player,
                Sender = player,
            };

            var args = new HookArgs.PlayerLeftGame
            {
                Slot = slot.whoAmI,
            };

            HookPoints.PlayerLeftGame.Invoke (ref ctx, ref args);
        }
        public void StatusPvP(Player player)
        {
            switch (this.type)
            {
                case ProjectileType.N2_FIRE_ARROW:
                    if (Main.rand.Next(3) == 0)
                        player.AddBuff(24, 180, false);
                    break;

                case ProjectileType.N15_BALL_OF_FIRE:
                    if (Main.rand.Next(2) == 0)
                        player.AddBuff(24, 300, false);
                    break;

                case ProjectileType.N19_FLAMARANG:
                    if (Main.rand.Next(5) == 0)
                        player.AddBuff(24, 180, false);
                    break;

                case ProjectileType.N34_FLAMELASH:
                    if (Main.rand.Next(2) == 0)
                        player.AddBuff(24, 240, false);
                    break;

                case ProjectileType.N35_SUNFURY:
                    if (Main.rand.Next(4) == 0)
                        player.AddBuff(24, 180, false);
                    break;

                case ProjectileType.N33_THORN_CHAKRUM:
                    if (Main.rand.Next(5) == 0)
                        player.AddBuff(20, 420, false);
                    break;

                case ProjectileType.N54_POISONED_KNIFE:
                    if (Main.rand.Next(2) == 0)
                        player.AddBuff(20, 600, false);
                    break;
                case ProjectileType.N63_THE_DAO_OF_POW:
                    if (Main.rand.Next(3) != 0)
                        player.AddBuff(31, 120, true);
                    break;
                case ProjectileType.N85_FLAMES:
                    player.AddBuff(24, 1200, false);
                    break;
                case (ProjectileType.N95_CURSED_FLAME):
                    player.AddBuff(39, 420, true);
                    break;
                case (ProjectileType.N103_CURSED_ARROW):
                    player.AddBuff(39, 420, true);
                    break;
                case (ProjectileType.N104_CURSED_BULLET):
                    player.AddBuff(39, 420, true);
                    break;
            }
        }
 public static Player LoadPlayer(string playerPath)
 {
     bool flag = false;
     if (Main.rand == null)
     {
         Main.rand = new Random((int)DateTime.Now.Ticks);
     }
     Player player = new Player();
     try
     {
         string text = playerPath + ".dat";
         flag = Player.DecryptFile(playerPath, text);
         if (!flag)
         {
             using (FileStream fileStream = new FileStream(text, FileMode.Open))
             {
                 using (BinaryReader binaryReader = new BinaryReader(fileStream))
                 {
                     int release = binaryReader.ReadInt32();
                     player.Name = binaryReader.ReadString();
                     player.hair = binaryReader.ReadInt32();
                     player.statLife = binaryReader.ReadInt32();
                     player.statLifeMax = binaryReader.ReadInt32();
                     if (player.statLife > player.statLifeMax)
                     {
                         player.statLife = player.statLifeMax;
                     }
                     player.statMana = binaryReader.ReadInt32();
                     player.statManaMax = binaryReader.ReadInt32();
                     if (player.statMana > player.statManaMax)
                     {
                         player.statMana = player.statManaMax;
                     }
                     player.hairColor.R = binaryReader.ReadByte();
                     player.hairColor.G = binaryReader.ReadByte();
                     player.hairColor.B = binaryReader.ReadByte();
                     player.skinColor.R = binaryReader.ReadByte();
                     player.skinColor.G = binaryReader.ReadByte();
                     player.skinColor.B = binaryReader.ReadByte();
                     player.eyeColor.R = binaryReader.ReadByte();
                     player.eyeColor.G = binaryReader.ReadByte();
                     player.eyeColor.B = binaryReader.ReadByte();
                     player.shirtColor.R = binaryReader.ReadByte();
                     player.shirtColor.G = binaryReader.ReadByte();
                     player.shirtColor.B = binaryReader.ReadByte();
                     player.underShirtColor.R = binaryReader.ReadByte();
                     player.underShirtColor.G = binaryReader.ReadByte();
                     player.underShirtColor.B = binaryReader.ReadByte();
                     player.pantsColor.R = binaryReader.ReadByte();
                     player.pantsColor.G = binaryReader.ReadByte();
                     player.pantsColor.B = binaryReader.ReadByte();
                     player.shoeColor.R = binaryReader.ReadByte();
                     player.shoeColor.G = binaryReader.ReadByte();
                     player.shoeColor.B = binaryReader.ReadByte();
                     for (int i = 0; i < 8; i++)
                     {
                         player.armor[i].SetDefaults(Item.VersionName(binaryReader.ReadString(), release));
                     }
                     for (int j = 0; j < 44; j++)
                     {
                         player.inventory[j].SetDefaults(Item.VersionName(binaryReader.ReadString(), release));
                         player.inventory[j].Stack = binaryReader.ReadInt32();
                     }
                     for (int k = 0; k < Chest.MAX_ITEMS; k++)
                     {
                         player.bank[k].SetDefaults(Item.VersionName(binaryReader.ReadString(), release));
                         player.bank[k].Stack = binaryReader.ReadInt32();
                     }
                     for (int l = 0; l < 200; l++)
                     {
                         int num = binaryReader.ReadInt32();
                         if (num == -1)
                         {
                             break;
                         }
                         player.spX[l] = num;
                         player.spY[l] = binaryReader.ReadInt32();
                         player.spI[l] = binaryReader.ReadInt32();
                         player.spN[l] = binaryReader.ReadString();
                     }
                     binaryReader.Close();
                 }
             }
             player.PlayerFrame();
             File.Delete(text);
             return player;
         }
     }
     catch
     {
         flag = true;
     }
     if (!flag)
     {
         return new Player();
     }
     string text2 = playerPath + ".bak";
     if (File.Exists(text2))
     {
         File.Delete(playerPath);
         File.Move(text2, playerPath);
         return Player.LoadPlayer(playerPath);
     }
     return new Player();
 }