public override void ReadExtraData(BinaryReader reader, bool networkSend) { if (!networkSend) { logicCheck = (LogicCheckType)reader.ReadByte(); On = reader.ReadBoolean(); } }
public static LogicCheckType FigureCheckType(int x, int y, out bool on) { on = false; if (!WorldGen.InWorld(x, y)) { return(LogicCheckType.None); } Tile tile = Main.tile[x, y]; if (tile == null) { return(LogicCheckType.None); } LogicCheckType logicCheckType = LogicCheckType.None; switch (tile.frameY / 18) { case 0: logicCheckType = LogicCheckType.Day; break; case 1: logicCheckType = LogicCheckType.Night; break; case 2: logicCheckType = LogicCheckType.PlayerAbove; break; case 3: logicCheckType = LogicCheckType.Water; break; case 4: logicCheckType = LogicCheckType.Lava; break; case 5: logicCheckType = LogicCheckType.Honey; break; case 6: logicCheckType = LogicCheckType.Liquid; break; } on = GetState(x, y, logicCheckType); return(logicCheckType); }
public static int Hook_AfterPlacement(int x, int y, int type = 423, int style = 0, int direction = 1, int alternate = 0) { bool on; LogicCheckType type2 = FigureCheckType(x, y, out on); GetFrame(x, y, type2, on); if (Main.netMode == 1) { NetMessage.SendTileSquare(Main.myPlayer, x, y, 1); NetMessage.SendData(87, -1, -1, null, x, y, (int)_myEntityID); return(-1); } int num = Place(x, y); ((TELogicSensor)TileEntity.ByID[num]).FigureCheckState(); return(num); }
public static void GetFrame(int x, int y, LogicCheckType type, bool on) { Main.tile[x, y].frameX = (short)(on ? 18 : 0); switch (type) { case LogicCheckType.Day: Main.tile[x, y].frameY = 0; break; case LogicCheckType.Night: Main.tile[x, y].frameY = 18; break; case LogicCheckType.PlayerAbove: Main.tile[x, y].frameY = 36; break; case LogicCheckType.Water: Main.tile[x, y].frameY = 54; break; case LogicCheckType.Lava: Main.tile[x, y].frameY = 72; break; case LogicCheckType.Honey: Main.tile[x, y].frameY = 90; break; case LogicCheckType.Liquid: Main.tile[x, y].frameY = 108; break; default: Main.tile[x, y].frameY = 0; break; } }
public void FigureCheckState() { logicCheck = FigureCheckType(Position.X, Position.Y, out On); GetFrame(Position.X, Position.Y, logicCheck, On); }
public static bool GetState(int x, int y, LogicCheckType type, TELogicSensor instance = null) { switch (type) { case LogicCheckType.Day: return(Main.dayTime); case LogicCheckType.Night: return(!Main.dayTime); case LogicCheckType.PlayerAbove: { bool result = false; Rectangle value = new Rectangle(x * 16 - 32 - 1, y * 16 - 160 - 1, 82, 162); { foreach (KeyValuePair <int, Rectangle> item in playerBox) { if (item.Value.Intersects(value)) { return(true); } } return(result); } } case LogicCheckType.Water: case LogicCheckType.Lava: case LogicCheckType.Honey: case LogicCheckType.Liquid: { if (instance == null) { return(false); } Tile tile = Main.tile[x, y]; bool flag = true; if (tile == null || tile.liquid == 0) { flag = false; } if (!tile.lava() && type == LogicCheckType.Lava) { flag = false; } if (!tile.honey() && type == LogicCheckType.Honey) { flag = false; } if ((tile.honey() || tile.lava()) && type == LogicCheckType.Water) { flag = false; } if (!flag && instance.On) { if (instance.CountedData == 0) { instance.CountedData = 15; } else if (instance.CountedData > 0) { instance.CountedData--; } flag = instance.CountedData > 0; } return(flag); } default: return(false); } }
public TELogicSensor() { logicCheck = LogicCheckType.None; On = false; }