Beispiel #1
0
 public WorldEdit(Main game)
     : base(game)
 {
     for (int i = 0; i < 256; i++)
     {
         Players[i] = new PlayerInfo();
     }
 }
Beispiel #2
0
 void OnLeave(int plr)
 {
     File.Delete(Path.Combine("worldedit", String.Format("clipboard-{0}.dat", plr)));
     foreach (string fileName in Directory.EnumerateFiles("worldedit", String.Format("??do-{0}-*.dat", plr)))
     {
         File.Delete(fileName);
     }
     Players[plr] = new PlayerInfo();
 }
Beispiel #3
0
        public void Initialize()
        {
            #region Colors
            Colors.Add("blank", 0);

            Main.player[Main.myPlayer] = new Player();
            var item = new Item();
            for (var i = 1; i < Main.maxItemTypes; i++)
            {
                item.netDefaults(i);

                if (item.paint <= 0)
                {
                    continue;
                }

                var name = TShockAPI.Localization.EnglishLanguage.GetItemNameById(i);
                Colors.Add(name.Substring(0, name.Length - 6).ToLowerInvariant(), item.paint);
            }
            #endregion
            #region Selections
            Selections.Add("altcheckers", (i, j, plr) => ((i + j) & 1) == 0);
            Selections.Add("checkers", (i, j, plr) => ((i + j) & 1) == 1);
            Selections.Add("normal", (i, j, plr) => true);
            Selections.Add("border", (i, j, plr) =>
            {
                PlayerInfo info = plr.GetPlayerInfo();
                return(i == info.X || i == info.X2 || j == info.Y || j == info.Y2);
            });
            Selections.Add("outline", (i, j, plr) =>
            {
                return((i > 0) && (j > 0) && (i < Main.maxTilesX - 1) && (j < Main.maxTilesY - 1) &&
                       (Main.tile[i, j].active()) &&
                       ((!Main.tile[i - 1, j].active()) || (!Main.tile[i, j - 1].active()) ||
                        (!Main.tile[i + 1, j].active()) || (!Main.tile[i, j + 1].active()) ||
                        (!Main.tile[i + 1, j + 1].active()) || (!Main.tile[i - 1, j - 1].active()) ||
                        (!Main.tile[i - 1, j + 1].active()) || (!Main.tile[i + 1, j - 1].active())));
            });
            Selections.Add("45", (i, j, plr) =>
            {
                PlayerInfo info = plr.GetPlayerInfo();

                int X = Math.Min(info.X, info.X2);
                int Y = Math.Min(info.Y, info.Y2);

                return((i - X) == (j - Y));
            });
            Selections.Add("225", (i, j, plr) =>
            {
                PlayerInfo info = plr.GetPlayerInfo();

                int Y  = Math.Min(info.Y, info.Y2);
                int X2 = Math.Max(info.X, info.X2);

                return((X2 - i) == (j - Y));
            });
            #endregion
            #region Tiles
            Tiles.Add("air", -1);
            Tiles.Add("lava", -2);
            Tiles.Add("honey", -3);
            Tiles.Add("water", -4);

            foreach (var fi in typeof(TileID).GetFields())
            {
                string name = fi.Name;
                var    sb   = new StringBuilder();
                for (int i = 0; i < name.Length; i++)
                {
                    if (char.IsUpper(name[i]))
                    {
                        sb.Append(" ").Append(char.ToLower(name[i]));
                    }
                    else
                    {
                        sb.Append(name[i]);
                    }
                }
                Tiles.Add(sb.ToString(1, sb.Length - 1), (ushort)fi.GetValue(null));
            }
            #endregion
            #region Walls
            Walls.Add("air", 0);

            foreach (var fi in typeof(WallID).GetFields())
            {
                string name = fi.Name;
                var    sb   = new StringBuilder();
                for (int i = 0; i < name.Length; i++)
                {
                    if (char.IsUpper(name[i]))
                    {
                        sb.Append(" ").Append(char.ToLower(name[i]));
                    }
                    else
                    {
                        sb.Append(name[i]);
                    }
                }
                Walls.Add(sb.ToString(1, sb.Length - 1), (byte)fi.GetValue(null));
            }
            #endregion
        }
Beispiel #4
0
 public WorldEdit(Main game)
     : base(game)
 {
     for (int i = 0; i < Players.Length; i++)
         Players[i] = new PlayerInfo();
 }