public static Sign DbGetSign(int x, int y) { try { Sign sign = null; string query = "SELECT Text FROM Signs WHERE X=@0 AND Y=@1 AND WorldID=@2;"; using (var reader = db.QueryReader(query, x, y, Main.worldID)) { while (reader.Read()) { sign = new Sign() { x = x, y = y, text = reader.Get<string>("Text") }; } } return sign; } catch (Exception ex) { TShock.Log.ConsoleError(ex.ToString()); return null; } }
public static Sign ReadSign(this BinaryReader reader) { Sign sign = new Sign(); sign.text = reader.ReadString(); sign.x = reader.ReadInt32(); sign.y = reader.ReadInt32(); return sign; }
public static void WriteSign(this BinaryWriter writer, Sign sign) { writer.Write(sign.text); writer.Write(sign.x); writer.Write(sign.y); }
private static void LoadSigns(BinaryReader reader) { Sign sign; int i; short num = reader.ReadInt16(); for (i = 0; i < num; i++) { string str = reader.ReadString(); int num1 = reader.ReadInt32(); int num2 = reader.ReadInt32(); Tile tile = Main.tile[num1, num2]; if (!tile.active() || tile.type != 55 && tile.type != 85) { sign = null; } else { sign = new Sign() { text = str, x = num1, y = num2 }; } Main.sign[i] = sign; } while (i < 1000) { Main.sign[i] = null; i++; } }
private static void LoadSigns(BinaryReader reader) { short num = reader.ReadInt16(); int i; for (i = 0; i < (int)num; i++) { string text = reader.ReadString(); int num2 = reader.ReadInt32(); int num3 = reader.ReadInt32(); Tile tile = Main.tile[num2, num3]; Sign sign; if (tile.active() && (tile.type == 55 || tile.type == 85)) { sign = new Sign(); sign.text = text; sign.x = num2; sign.y = num3; } else { sign = null; } Main.sign[i] = sign; } while (i < 1000) { Main.sign[i] = null; i++; } }
private static void LoadSigns(BinaryReader reader) { short num4 = reader.ReadInt16(); int index = 0; while (index < num4) { Sign sign; string str = reader.ReadString(); int num2 = reader.ReadInt32(); int num3 = reader.ReadInt32(); Tile tile = Main.tile[num2, num3]; if (tile.active() && ((tile.type == 0x37) || (tile.type == 0x55))) { sign = new Sign { text = str, x = num2, y = num3 }; } else { sign = null; } Main.sign[index] = sign; index++; } while (index < 0x3e8) { Main.sign[index] = null; index++; } }
private static Sign Adapt(TerrariaSign terrariaSign) => new Sign(new Vector(terrariaSign.x, terrariaSign.y), terrariaSign.text);
public World(string path) { if (genRand == null) { genRand = new Random((int) DateTime.Now.Ticks); } using (FileStream stream = new FileStream(path, FileMode.Open)) { using (BinaryReader reader = new BinaryReader(stream)) { worldVersion = reader.ReadInt32(); Name = reader.ReadString(); ID = reader.ReadInt32(); leftWorld = reader.ReadInt32(); rightWorld = reader.ReadInt32(); topWorld = reader.ReadInt32(); bottomWorld = reader.ReadInt32(); int tilesY = reader.ReadInt32(); int tilesX = reader.ReadInt32(); Size = new Size(tilesX, tilesY); Spawn = new Point(reader.ReadInt32(), reader.ReadInt32()); worldSurface = reader.ReadDouble(); rockLayer = reader.ReadDouble(); double tempTime = reader.ReadDouble(); bool tempDayTime= reader.ReadBoolean(); int tempMoonPhase = reader.ReadInt32(); bool tempBloodMoon= reader.ReadBoolean(); Dungeon = new Point(reader.ReadInt32(), reader.ReadInt32()); downedBoss1 = reader.ReadBoolean(); downedBoss2 = reader.ReadBoolean(); downedBoss3 = reader.ReadBoolean(); shadowOrbSmashed = reader.ReadBoolean(); spawnMeteor = reader.ReadBoolean(); shadowOrbCount = reader.ReadByte(); invasionDelay = reader.ReadInt32(); invasionSize = reader.ReadInt32(); invasionType = reader.ReadInt32(); invasionX = reader.ReadDouble(); for (int num4 = 0; num4 < MaxTilesX; num4++) { for (int num6 = 0; num6 < MaxTilesY; num6++) { tile[num4, num6] = new Tile(); } } for (int i = 0; i < tilesX; i++) { float num3 = ((float) i) / ((float) tilesX); for (int n = 0; n < tilesY; n++) { tile[i, n].Active = reader.ReadBoolean(); if (tile[i, n].Active) { tile[i, n].Type = reader.ReadByte(); if (tileFrameImportant[tile[i, n].Type]) { tile[i, n].FrameX = reader.ReadInt16(); tile[i, n].FrameY = reader.ReadInt16(); } else { tile[i, n].FrameX = -1; tile[i, n].FrameY = -1; } } tile[i, n].Lighted = reader.ReadBoolean(); if (reader.ReadBoolean()) { tile[i, n].Wall = reader.ReadByte(); } if (reader.ReadBoolean()) { tile[i, n].Liquid = reader.ReadByte(); tile[i, n].Lava = reader.ReadBoolean(); } } } for (int j = 0; j < 0x3e8; j++) { if (reader.ReadBoolean()) { chest[j] = new Chest(); chest[j].Position = new Microsoft.Xna.Framework.Vector2(reader.ReadInt32(), reader.ReadInt32()); for (int num6 = 0; num6 < Chest.MaxItems; num6++) { byte num7 = reader.ReadByte(); if (num7 > 0) { chest[j].Items[num6] = new Item(); string itemName = reader.ReadString(); chest[j].Items[num6].Name = itemName; chest[j].Items[num6].Count = num7; } } } } for (int k = 0; k < 0x3e8; k++) { if (reader.ReadBoolean()) { string str2 = reader.ReadString(); int num9 = reader.ReadInt32(); int num10 = reader.ReadInt32(); if (tile[num9, num10].Active && (tile[num9, num10].Type == 0x37)) { sign[k] = new Sign(); sign[k].Position = new Microsoft.Xna.Framework.Vector2(num9, num10); sign[k].Text = str2; } } } bool flag = reader.ReadBoolean(); for (int m = 0; flag; m++) { npc[m] = new Npc(); npc[m].Name = reader.ReadString(); npc[m].Position.X = reader.ReadSingle(); npc[m].Position.Y = reader.ReadSingle(); npc[m].IsHomeless = reader.ReadBoolean(); npc[m].HomePosition = new Microsoft.Xna.Framework.Vector2(reader.ReadInt32(), reader.ReadInt32()); flag = reader.ReadBoolean(); } reader.Close(); waterLine = tilesY; } } FrameTiles(); }