示例#1
0
        public override void Update()
        {
            bool state = TELogicSensor.GetState((int)this.Position.X, (int)this.Position.Y, this.logicCheck, this);

            TELogicSensor.LogicCheckType logicCheck = this.logicCheck;
            if ((uint)(logicCheck - 1) > 1U)
            {
                if ((uint)(logicCheck - 3) > 4U || this.On == state)
                {
                    return;
                }
                this.ChangeState(state, true);
            }
            else
            {
                if (!this.On & state)
                {
                    this.ChangeState(true, true);
                }
                if (!this.On || state)
                {
                    return;
                }
                this.ChangeState(false, false);
            }
        }
示例#2
0
        // Token: 0x06000F7A RID: 3962 RVA: 0x003F4848 File Offset: 0x003F2A48
        public override void Update()
        {
            bool state = TELogicSensor.GetState((int)this.Position.X, (int)this.Position.Y, this.logicCheck, this);

            TELogicSensor.LogicCheckType logicCheckType = this.logicCheck;
            if (logicCheckType - TELogicSensor.LogicCheckType.Day > 1)
            {
                if (logicCheckType - TELogicSensor.LogicCheckType.PlayerAbove > 4)
                {
                    return;
                }
                if (this.On != state)
                {
                    this.ChangeState(state, true);
                }
            }
            else
            {
                if (!this.On & state)
                {
                    this.ChangeState(true, true);
                }
                if (this.On && !state)
                {
                    this.ChangeState(false, false);
                    return;
                }
            }
        }
示例#3
0
 public override void ReadExtraData(BinaryReader reader, bool networkSend)
 {
     if (networkSend)
     {
         return;
     }
     this.logicCheck = (TELogicSensor.LogicCheckType)reader.ReadByte();
     this.On         = reader.ReadBoolean();
 }
示例#4
0
        public static TELogicSensor.LogicCheckType FigureCheckType(
            int x,
            int y,
            out bool on)
        {
            on = false;
            if (!WorldGen.InWorld(x, y, 0))
            {
                return(TELogicSensor.LogicCheckType.None);
            }
            Tile tile = Main.tile[x, y];

            if (tile == null)
            {
                return(TELogicSensor.LogicCheckType.None);
            }
            TELogicSensor.LogicCheckType type = TELogicSensor.LogicCheckType.None;
            switch ((int)tile.frameY / 18)
            {
            case 0:
                type = TELogicSensor.LogicCheckType.Day;
                break;

            case 1:
                type = TELogicSensor.LogicCheckType.Night;
                break;

            case 2:
                type = TELogicSensor.LogicCheckType.PlayerAbove;
                break;

            case 3:
                type = TELogicSensor.LogicCheckType.Water;
                break;

            case 4:
                type = TELogicSensor.LogicCheckType.Lava;
                break;

            case 5:
                type = TELogicSensor.LogicCheckType.Honey;
                break;

            case 6:
                type = TELogicSensor.LogicCheckType.Liquid;
                break;
            }
            on = TELogicSensor.GetState(x, y, type, (TELogicSensor)null);
            return(type);
        }
示例#5
0
        public static int Hook_AfterPlacement(int x, int y, int type = 423, int style = 0, int direction = 1)
        {
            bool on;

            TELogicSensor.LogicCheckType type1 = TELogicSensor.FigureCheckType(x, y, out on);
            TELogicSensor.GetFrame(x, y, type1, on);
            if (Main.netMode == 1)
            {
                NetMessage.SendTileSquare(Main.myPlayer, x, y, 1, TileChangeType.None);
                NetMessage.SendData(87, -1, -1, (NetworkText)null, x, (float)y, 2f, 0.0f, 0, 0, 0);
                return(-1);
            }
            int index = TELogicSensor.Place(x, y);

            ((TELogicSensor)TileEntity.ByID[index]).FigureCheckState();
            return(index);
        }
        // Token: 0x06001283 RID: 4739 RVA: 0x00422E54 File Offset: 0x00421054
        public static int Hook_AfterPlacement(int x, int y, int type = 423, int style = 0, int direction = 1)
        {
            bool on;

            TELogicSensor.LogicCheckType type2 = TELogicSensor.FigureCheckType(x, y, out on);
            TELogicSensor.GetFrame(x, y, type2, on);
            if (Main.netMode == 1)
            {
                NetMessage.SendTileSquare(Main.myPlayer, x, y, 1);
                NetMessage.SendData(87, -1, -1, "", x, (float)y, 2f, 0f, 0, 0, 0);
                return(-1);
            }
            int num = TELogicSensor.Place(x, y);

            ((TELogicSensor)TileEntity.ByID[num]).FigureCheckState();
            return(num);
        }
示例#7
0
        public static void GetFrame(int x, int y, TELogicSensor.LogicCheckType type, bool on)
        {
            Main.tile[x, y].frameX = on ? (short)18 : (short)0;
            switch (type)
            {
            case TELogicSensor.LogicCheckType.Day:
                Main.tile[x, y].frameY = (short)0;
                break;

            case TELogicSensor.LogicCheckType.Night:
                Main.tile[x, y].frameY = (short)18;
                break;

            case TELogicSensor.LogicCheckType.PlayerAbove:
                Main.tile[x, y].frameY = (short)36;
                break;

            case TELogicSensor.LogicCheckType.Water:
                Main.tile[x, y].frameY = (short)54;
                break;

            case TELogicSensor.LogicCheckType.Lava:
                Main.tile[x, y].frameY = (short)72;
                break;

            case TELogicSensor.LogicCheckType.Honey:
                Main.tile[x, y].frameY = (short)90;
                break;

            case TELogicSensor.LogicCheckType.Liquid:
                Main.tile[x, y].frameY = (short)108;
                break;

            default:
                Main.tile[x, y].frameY = (short)0;
                break;
            }
        }
示例#8
0
        // Token: 0x06000F81 RID: 3969 RVA: 0x003F4C44 File Offset: 0x003F2E44
        public static void GetFrame(int x, int y, TELogicSensor.LogicCheckType type, bool on)
        {
            Main.tile[x, y].frameX = ((short)(on ? 18 : 0));
            switch (type)
            {
            case TELogicSensor.LogicCheckType.Day:
                Main.tile[x, y].frameY = 0;
                return;

            case TELogicSensor.LogicCheckType.Night:
                Main.tile[x, y].frameY = 18;
                return;

            case TELogicSensor.LogicCheckType.PlayerAbove:
                Main.tile[x, y].frameY = 36;
                return;

            case TELogicSensor.LogicCheckType.Water:
                Main.tile[x, y].frameY = 54;
                return;

            case TELogicSensor.LogicCheckType.Lava:
                Main.tile[x, y].frameY = 72;
                return;

            case TELogicSensor.LogicCheckType.Honey:
                Main.tile[x, y].frameY = 90;
                return;

            case TELogicSensor.LogicCheckType.Liquid:
                Main.tile[x, y].frameY = 108;
                return;

            default:
                Main.tile[x, y].frameY = 0;
                return;
            }
        }
示例#9
0
 public void FigureCheckState()
 {
     this.logicCheck = TELogicSensor.FigureCheckType((int)this.Position.X, (int)this.Position.Y, out this.On);
     TELogicSensor.GetFrame((int)this.Position.X, (int)this.Position.Y, this.logicCheck, this.On);
 }
示例#10
0
        public static bool GetState(int x, int y, TELogicSensor.LogicCheckType type, TELogicSensor instance = null)
        {
            switch (type)
            {
            case TELogicSensor.LogicCheckType.Day:
                return(Main.dayTime);

            case TELogicSensor.LogicCheckType.Night:
                return(!Main.dayTime);

            case TELogicSensor.LogicCheckType.PlayerAbove:
                var flag1     = false;
                var rectangle = new Rectangle(x * 16 - 32 - 1, y * 16 - 160 - 1, 82, 162);
                foreach (var keyValuePair in TELogicSensor.playerBox)
                {
                    if (keyValuePair.Value.Intersects(rectangle))
                    {
                        flag1 = true;
                        break;
                    }
                }

                return(flag1);

            case TELogicSensor.LogicCheckType.Water:
            case TELogicSensor.LogicCheckType.Lava:
            case TELogicSensor.LogicCheckType.Honey:
            case TELogicSensor.LogicCheckType.Liquid:
                if (instance == null)
                {
                    return(false);
                }
                var tile  = Main.tile[x, y];
                var flag2 = true;
                if (tile == null || tile.liquid == (byte)0)
                {
                    flag2 = false;
                }
                if (!tile.lava() && type == TELogicSensor.LogicCheckType.Lava)
                {
                    flag2 = false;
                }
                if (!tile.honey() && type == TELogicSensor.LogicCheckType.Honey)
                {
                    flag2 = false;
                }
                if ((tile.honey() || tile.lava()) && type == TELogicSensor.LogicCheckType.Water)
                {
                    flag2 = false;
                }
                if (!flag2 && instance.On)
                {
                    if (instance.CountedData == 0)
                    {
                        instance.CountedData = 15;
                    }
                    else if (instance.CountedData > 0)
                    {
                        --instance.CountedData;
                    }
                    flag2 = instance.CountedData > 0;
                }

                return(flag2);

            default:
                return(false);
            }
        }
示例#11
0
 public TELogicSensor()
 {
     this.logicCheck = TELogicSensor.LogicCheckType.None;
     this.On         = false;
 }
示例#12
0
        public static bool GetState(int x, int y, TELogicSensor.LogicCheckType type, TELogicSensor instance = null)
        {
            switch (type)
            {
            case TELogicSensor.LogicCheckType.Day:
                return(Main.dayTime);

            case TELogicSensor.LogicCheckType.Night:
                return(!Main.dayTime);

            case TELogicSensor.LogicCheckType.PlayerAbove:
                bool      flag1 = false;
                Rectangle rectangle1;
                // ISSUE: explicit reference operation
                ((Rectangle)@rectangle1).\u002Ector(x * 16 - 32 - 1, y * 16 - 160 - 1, 82, 162);
                using (Dictionary <int, Rectangle> .Enumerator enumerator = TELogicSensor.playerBox.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        Rectangle rectangle2 = enumerator.Current.Value;
                        // ISSUE: explicit reference operation
                        if (((Rectangle)@rectangle2).Intersects(rectangle1))
                        {
                            flag1 = true;
                            break;
                        }
                    }
                }
                return(flag1);

            case TELogicSensor.LogicCheckType.Water:
            case TELogicSensor.LogicCheckType.Lava:
            case TELogicSensor.LogicCheckType.Honey:
            case TELogicSensor.LogicCheckType.Liquid:
                if (instance == null)
                {
                    return(false);
                }
                Tile tile  = Main.tile[x, y];
                bool flag2 = true;
                if (tile == null || (int)tile.liquid == 0)
                {
                    flag2 = false;
                }
                if (!tile.lava() && type == TELogicSensor.LogicCheckType.Lava)
                {
                    flag2 = false;
                }
                if (!tile.honey() && type == TELogicSensor.LogicCheckType.Honey)
                {
                    flag2 = false;
                }
                if ((tile.honey() || tile.lava()) && type == TELogicSensor.LogicCheckType.Water)
                {
                    flag2 = false;
                }
                if (!flag2 && instance.On)
                {
                    if (instance.CountedData == 0)
                    {
                        instance.CountedData = 15;
                    }
                    else if (instance.CountedData > 0)
                    {
                        --instance.CountedData;
                    }
                    flag2 = instance.CountedData > 0;
                }
                return(flag2);

            default:
                return(false);
            }
        }
示例#13
0
        // Token: 0x06000F7F RID: 3967 RVA: 0x003F4A84 File Offset: 0x003F2C84
        public static bool GetState(int x, int y, TELogicSensor.LogicCheckType type, TELogicSensor instance = null)
        {
            switch (type)
            {
            case TELogicSensor.LogicCheckType.Day:
                return(Main.dayTime);

            case TELogicSensor.LogicCheckType.Night:
                return(!Main.dayTime);

            case TELogicSensor.LogicCheckType.PlayerAbove:
            {
                bool      result = false;
                Rectangle value  = new Rectangle(x * 16 - 32 - 1, y * 16 - 160 - 1, 82, 162);
                foreach (KeyValuePair <int, Rectangle> current in TELogicSensor.playerBox)
                {
                    if (current.Value.Intersects(value))
                    {
                        result = true;
                        break;
                    }
                }
                return(result);
            }

            case TELogicSensor.LogicCheckType.Water:
            case TELogicSensor.LogicCheckType.Lava:
            case TELogicSensor.LogicCheckType.Honey:
            case TELogicSensor.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 == TELogicSensor.LogicCheckType.Lava)
                {
                    flag = false;
                }
                if (!tile.honey() && type == TELogicSensor.LogicCheckType.Honey)
                {
                    flag = false;
                }
                if ((tile.honey() || tile.lava()) && type == TELogicSensor.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);
            }
        }