Ejemplo n.º 1
0
        public static BitsByte[] ComposeBitsBytesChain(bool optimizeLength, params bool[] flags)
        {
            int length1 = flags.Length;
            int length2 = 0;

            while (length1 > 0)
            {
                ++length2;
                length1 -= 7;
            }
            BitsByte[] array  = new BitsByte[length2];
            int        index1 = 0;
            int        index2 = 0;

            for (int index3 = 0; index3 < flags.Length; ++index3)
            {
                array[index2][index1] = flags[index3];
                ++index1;
                if (index1 == 7 && index2 < length2 - 1)
                {
                    array[index2][index1] = true;
                    index1 = 0;
                    ++index2;
                }
            }
            if (optimizeLength)
            {
                int index3;
                for (index3 = array.Length - 1; (int)(byte)array[index3] == 0 && index3 > 0; --index3)
                {
                    array[index3 - 1][7] = false;
                }
                Array.Resize <BitsByte>(ref array, index3 + 1);
            }
            return(array);
        }
Ejemplo n.º 2
0
 public static BitsByte TrackCollision(ref Vector2 Position, ref Vector2 Velocity, ref Vector2 lastBoost, int Width, int Height, bool followDown, bool followUp, int fallStart, bool trackOnly)
 {
     int num;
     int num1;
     Matrix matrix;
     Minecart.TrackState trackState;
     if (followDown && followUp)
     {
         followDown = false;
         followUp = false;
     }
     Vector2 vector2 = new Vector2((float)(Width / 2) - 25f, (float)(Height / 2));
     Vector2 position = Position + new Vector2((float)(Width / 2) - 25f, (float)(Height / 2));
     Vector2 vector21 = position + Minecart._trackMagnetOffset;
     Vector2 velocity = Velocity;
     float x = velocity.Length();
     velocity.Normalize();
     Vector2 y = vector21;
     Tile tile = null;
     bool flag = false;
     bool flag1 = true;
     int num2 = -1;
     int num3 = -1;
     int num4 = -1;
     Minecart.TrackState trackState1 = Minecart.TrackState.NoTrack;
     bool flag2 = false;
     bool flag3 = false;
     bool flag4 = false;
     bool flag5 = false;
     Vector2 zero = Vector2.Zero;
     Vector2 zero1 = Vector2.Zero;
     BitsByte bitsByte = new BitsByte();
     while (true)
     {
         int x1 = (int)(y.X / 16f);
         int y1 = (int)(y.Y / 16f);
         int x2 = (int)y.X % 16 / 2;
         if (flag1)
         {
             num4 = x2;
         }
         bool flag6 = x2 != num4;
         if ((trackState1 == Minecart.TrackState.OnBack || trackState1 == Minecart.TrackState.OnTrack || trackState1 == Minecart.TrackState.OnFront) && x1 != num2)
         {
             num = (trackState1 != Minecart.TrackState.OnBack ? tile.FrontTrack() : tile.BackTrack());
             num1 = (velocity.X >= 0f ? Minecart._rightSideConnection[num] : Minecart._leftSideConnection[num]);
             switch (num1)
             {
                 case 0:
                 {
                     y1--;
                     y.Y = y.Y - 2f;
                     break;
                 }
                 case 2:
                 {
                     y1++;
                     y.Y = y.Y + 2f;
                     break;
                 }
             }
         }
         Minecart.TrackState trackState2 = Minecart.TrackState.NoTrack;
         bool flag7 = false;
         if (x1 != num2 || y1 != num3)
         {
             if (!flag1)
             {
                 flag7 = true;
             }
             else
             {
                 flag1 = false;
             }
             tile = Main.tile[x1, y1];
             if (tile == null)
             {
                 tile = new Tile();
                 Main.tile[x1, y1] = tile;
             }
             flag = (!tile.nactive() || tile.type != 314 ? false : true);
         }
         if (flag)
         {
             Minecart.TrackState trackState3 = Minecart.TrackState.NoTrack;
             int num5 = tile.FrontTrack();
             int num6 = tile.BackTrack();
             int num7 = Minecart._tileHeight[num5][x2];
             switch (num7)
             {
                 case -4:
                 {
                     if (trackState1 != Minecart.TrackState.OnFront)
                     {
                         break;
                     }
                     if (!trackOnly)
                     {
                         trackState2 = Minecart.TrackState.NoTrack;
                         flag4 = true;
                         break;
                     }
                     else
                     {
                         y = y - zero1;
                         x = 0f;
                         trackState2 = Minecart.TrackState.OnFront;
                         flag5 = true;
                         break;
                     }
                 }
                 case -3:
                 {
                     if (trackState1 != Minecart.TrackState.OnFront)
                     {
                         break;
                     }
                     trackState1 = Minecart.TrackState.NoTrack;
                     if (Velocity.X <= 0f)
                     {
                         matrix = (Minecart._rightSideConnection[num5] != 2 ? Matrix.CreateRotationZ(-0.7853982f) : Matrix.CreateRotationZ(0.7853982f));
                     }
                     else
                     {
                         matrix = (Minecart._leftSideConnection[num5] != 2 ? Matrix.CreateRotationZ(0.7853982f) : Matrix.CreateRotationZ(-0.7853982f));
                     }
                     zero = Vector2.Transform(new Vector2(Velocity.X, 0f), matrix);
                     zero.X = Velocity.X;
                     flag3 = true;
                     x = 0f;
                     break;
                 }
                 case -2:
                 {
                     if (trackState1 != Minecart.TrackState.OnFront)
                     {
                         break;
                     }
                     if (!trackOnly)
                     {
                         if (velocity.X < 0f)
                         {
                             float single = (float)(x1 * 16 + (x2 + 1) * 2) - y.X;
                             y.X = y.X + single;
                             x = x + single / velocity.X;
                         }
                         velocity.X = -velocity.X;
                         bitsByte[1] = true;
                         trackState2 = Minecart.TrackState.OnFront;
                         break;
                     }
                     else
                     {
                         y = y - zero1;
                         x = 0f;
                         trackState2 = Minecart.TrackState.OnFront;
                         flag5 = true;
                         break;
                     }
                 }
                 case -1:
                 {
                     if (trackState1 != Minecart.TrackState.OnFront)
                     {
                         break;
                     }
                     y = y - zero1;
                     x = 0f;
                     trackState2 = Minecart.TrackState.OnFront;
                     flag5 = true;
                     break;
                 }
                 default:
                 {
                     float single1 = (float)(y1 * 16 + num7);
                     if (x1 != num2 && trackState1 == Minecart.TrackState.NoTrack && y.Y > single1 && y.Y - single1 < 2f)
                     {
                         flag7 = false;
                         trackState1 = Minecart.TrackState.AboveFront;
                     }
                     if (y.Y >= single1)
                     {
                         trackState = (y.Y <= single1 ? Minecart.TrackState.OnTrack : Minecart.TrackState.BelowTrack);
                     }
                     else
                     {
                         trackState = Minecart.TrackState.AboveTrack;
                     }
                     if (num6 != -1)
                     {
                         float single2 = (float)(y1 * 16 + Minecart._tileHeight[num6][x2]);
                         if (y.Y >= single2)
                         {
                             trackState3 = (y.Y <= single2 ? Minecart.TrackState.OnTrack : Minecart.TrackState.BelowTrack);
                         }
                         else
                         {
                             trackState3 = Minecart.TrackState.AboveTrack;
                         }
                     }
                     switch (trackState)
                     {
                         case Minecart.TrackState.AboveTrack:
                         {
                             switch (trackState3)
                             {
                                 case Minecart.TrackState.AboveTrack:
                                 {
                                     trackState2 = Minecart.TrackState.AboveTrack;
                                     break;
                                 }
                                 case Minecart.TrackState.OnTrack:
                                 {
                                     trackState2 = Minecart.TrackState.OnBack;
                                     break;
                                 }
                                 case Minecart.TrackState.BelowTrack:
                                 {
                                     trackState2 = Minecart.TrackState.AboveFront;
                                     break;
                                 }
                                 default:
                                 {
                                     trackState2 = Minecart.TrackState.AboveFront;
                                     break;
                                 }
                             }
                             break;
                         }
                         case Minecart.TrackState.OnTrack:
                         {
                             trackState2 = (trackState3 != Minecart.TrackState.OnTrack ? Minecart.TrackState.OnFront : Minecart.TrackState.OnTrack);
                             break;
                         }
                         case Minecart.TrackState.BelowTrack:
                         {
                             switch (trackState3)
                             {
                                 case Minecart.TrackState.AboveTrack:
                                 {
                                     trackState2 = Minecart.TrackState.AboveBack;
                                     break;
                                 }
                                 case Minecart.TrackState.OnTrack:
                                 {
                                     trackState2 = Minecart.TrackState.OnBack;
                                     break;
                                 }
                                 case Minecart.TrackState.BelowTrack:
                                 {
                                     trackState2 = Minecart.TrackState.BelowTrack;
                                     break;
                                 }
                                 default:
                                 {
                                     trackState2 = Minecart.TrackState.BelowTrack;
                                     break;
                                 }
                             }
                             break;
                         }
                     }
                     break;
                 }
             }
         }
         if (!flag7)
         {
             if (trackState1 != trackState2)
             {
                 bool flag8 = false;
                 if (flag6 || velocity.Y > 0f)
                 {
                     switch (trackState1)
                     {
                         case Minecart.TrackState.AboveTrack:
                         {
                             switch (trackState2)
                             {
                                 case Minecart.TrackState.AboveTrack:
                                 {
                                     trackState2 = Minecart.TrackState.OnTrack;
                                     break;
                                 }
                                 case Minecart.TrackState.AboveFront:
                                 {
                                     trackState2 = Minecart.TrackState.OnBack;
                                     break;
                                 }
                                 case Minecart.TrackState.AboveBack:
                                 {
                                     trackState2 = Minecart.TrackState.OnFront;
                                     break;
                                 }
                                 default:
                                 {
                                     break;
                                 }
                             }
                             goto case Minecart.TrackState.BelowTrack;
                         }
                         case Minecart.TrackState.OnTrack:
                         {
                             int num8 = Minecart._tileHeight[tile.FrontTrack()][x2];
                             int num9 = Minecart._tileHeight[tile.BackTrack()][x2];
                             if (followDown)
                             {
                                 trackState2 = (num8 >= num9 ? Minecart.TrackState.OnFront : Minecart.TrackState.OnBack);
                             }
                             else if (!followUp)
                             {
                                 trackState2 = Minecart.TrackState.OnFront;
                             }
                             else
                             {
                                 trackState2 = (num8 >= num9 ? Minecart.TrackState.OnBack : Minecart.TrackState.OnFront);
                             }
                             flag8 = true;
                             goto case Minecart.TrackState.BelowTrack;
                         }
                         case Minecart.TrackState.BelowTrack:
                         {
                             int num10 = -1;
                             Minecart.TrackState trackState4 = trackState2;
                             if (trackState4 != Minecart.TrackState.OnTrack)
                             {
                                 switch (trackState4)
                                 {
                                     case Minecart.TrackState.OnFront:
                                     {
                                         break;
                                     }
                                     case Minecart.TrackState.OnBack:
                                     {
                                         num10 = tile.BackTrack();
                                         goto Label1;
                                     }
                                     default:
                                     {
                                         goto Label1;
                                     }
                                 }
                             }
                             num10 = tile.FrontTrack();
                         Label1:
                             if (num10 == -1)
                             {
                                 break;
                             }
                             if (trackState1 == Minecart.TrackState.AboveFront && Minecart._trackType[num10] == 1)
                             {
                                 flag2 = true;
                             }
                             velocity.Y = 0f;
                             y.Y = (float)(y1 * 16 + Minecart._tileHeight[num10][x2]);
                             break;
                         }
                         case Minecart.TrackState.AboveFront:
                         {
                             if (trackState2 != Minecart.TrackState.BelowTrack)
                             {
                                 goto case Minecart.TrackState.BelowTrack;
                             }
                             trackState2 = Minecart.TrackState.OnFront;
                             goto case Minecart.TrackState.BelowTrack;
                         }
                         case Minecart.TrackState.AboveBack:
                         {
                             if (trackState2 != Minecart.TrackState.BelowTrack)
                             {
                                 goto case Minecart.TrackState.BelowTrack;
                             }
                             trackState2 = Minecart.TrackState.OnBack;
                             goto case Minecart.TrackState.BelowTrack;
                         }
                         case Minecart.TrackState.OnFront:
                         {
                             trackState2 = Minecart.TrackState.OnFront;
                             flag8 = true;
                             goto case Minecart.TrackState.BelowTrack;
                         }
                         case Minecart.TrackState.OnBack:
                         {
                             trackState2 = Minecart.TrackState.OnBack;
                             flag8 = true;
                             goto case Minecart.TrackState.BelowTrack;
                         }
                         default:
                         {
                             goto case Minecart.TrackState.BelowTrack;
                         }
                     }
                 }
             }
         }
         else if (trackState2 == Minecart.TrackState.OnFront || trackState2 == Minecart.TrackState.OnBack || trackState2 == Minecart.TrackState.OnTrack)
         {
             if (flag && Minecart._trackType[tile.FrontTrack()] == 1)
             {
                 flag2 = true;
             }
             velocity.Y = 0f;
         }
         if (trackState2 == Minecart.TrackState.OnFront)
         {
             int num11 = tile.FrontTrack();
             if (Minecart._trackType[num11] == 2 && lastBoost.X == 0f && lastBoost.Y == 0f)
             {
                 lastBoost = new Vector2((float)x1, (float)y1);
                 if (!Minecart._boostLeft[num11])
                 {
                     bitsByte[5] = true;
                 }
                 else
                 {
                     bitsByte[4] = true;
                 }
             }
         }
         num4 = x2;
         trackState1 = trackState2;
         num2 = x1;
         num3 = y1;
         if (x <= 0f)
         {
             if (lastBoost.X == (float)num2 && lastBoost.Y == (float)num3)
             {
                 break;
             }
             lastBoost = Vector2.Zero;
             break;
         }
         else
         {
             float x3 = y.X % 2f;
             float y2 = y.Y % 2f;
             float single3 = 3f;
             float single4 = 3f;
             if (velocity.X < 0f)
             {
                 single3 = x3 + 0.125f;
             }
             else if (velocity.X > 0f)
             {
                 single3 = 2f - x3;
             }
             if (velocity.Y < 0f)
             {
                 single4 = y2 + 0.125f;
             }
             else if (velocity.Y > 0f)
             {
                 single4 = 2f - y2;
             }
             if (single3 == 3f && single4 == 3f)
             {
                 break;
             }
             float single5 = Math.Abs(single3 / velocity.X);
             float single6 = Math.Abs(single4 / velocity.Y);
             float single7 = (single5 < single6 ? single5 : single6);
             if (single7 <= x)
             {
                 zero1 = velocity * single7;
                 x = x - single7;
             }
             else
             {
                 zero1 = velocity * x;
                 x = 0f;
             }
             y = y + zero1;
         }
     }
     if (flag2)
     {
         bitsByte[3] = true;
     }
     if (flag4)
     {
         Velocity.X = y.X - vector21.X;
         Velocity.Y = Player.defaultGravity;
     }
     else if (flag3)
     {
         bitsByte[2] = true;
         Velocity = zero;
     }
     else if (!bitsByte[1])
     {
         if (flag5)
         {
             Velocity.X = y.X - vector21.X;
         }
         if (velocity.Y == 0f)
         {
             Velocity.Y = 0f;
         }
     }
     else
     {
         Velocity.X = -Velocity.X;
         Position.X = y.X - Minecart._trackMagnetOffset.X - vector2.X - Velocity.X;
         if (velocity.Y == 0f)
         {
             Velocity.Y = 0f;
         }
     }
     Position.Y = Position.Y + (y.Y - vector21.Y - Velocity.Y);
     Position.Y = (float)Math.Round((double)Position.Y, 2);
     Minecart.TrackState trackState5 = trackState1;
     if (trackState5 != Minecart.TrackState.OnTrack)
     {
         switch (trackState5)
         {
             case Minecart.TrackState.OnFront:
             case Minecart.TrackState.OnBack:
             {
                 break;
             }
             default:
             {
                 return bitsByte;
             }
         }
     }
     bitsByte[0] = true;
     return bitsByte;
 }
Ejemplo n.º 3
0
 //in Terraria.NetMessage.SendData at end of case 27 call
 //  ProjectileLoader.SendExtraAI(projectile, writer, ref bb14);
 internal static void SendExtraAI(Projectile projectile, BinaryWriter writer, ref BitsByte flags)
 {
     if (IsModProjectile(projectile))
     {
         byte[] data;
         using (MemoryStream stream = new MemoryStream())
         {
             using (BinaryWriter modWriter = new BinaryWriter(stream))
             {
                 projectile.modProjectile.SendExtraAI(modWriter);
                 modWriter.Flush();
                 data = stream.ToArray();
             }
         }
         if (data.Length > 0)
         {
             flags[Projectile.maxAI + 1] = true;
             writer.Write((byte)data.Length);
             writer.Write(data);
         }
     }
 }
Ejemplo n.º 4
0
 //in Terraria.MessageBuffer.GetData for case 27 after reading all data add
 //  byte[] extraAI = ProjectileLoader.ReadExtraAI(reader, bitsByte14);
 internal static byte[] ReadExtraAI(BinaryReader reader, BitsByte flags)
 {
     if (flags[Projectile.maxAI + 1])
     {
         return reader.ReadBytes(reader.ReadByte());
     }
     return new byte[0];
 }
Ejemplo n.º 5
0
		public override void Pack(Stream stream)
		{
			BinaryWriter writer = new BinaryWriter(stream);
			writer.Write(Time);
			BitsByte worldinfo = new BitsByte(DayTime, BloodMoon, Eclipse);
			writer.Write(worldinfo);
			writer.Write(MoonPhase);
			writer.Write(MaxTilesX);
			writer.Write(MaxTilesY);
			writer.Write(SpawnX);
			writer.Write(SpawnY);
			writer.Write(WorldSurface);
			writer.Write(RockLayer);
			writer.Write(WorldID);
			writer.Write(WorldName);
			writer.Write(MoonType);

			writer.Write(SetBG0);
			writer.Write(SetBG1);
			writer.Write(SetBG2);
			writer.Write(SetBG3);
			writer.Write(SetBG4);
			writer.Write(SetBG5);
			writer.Write(SetBG6);
			writer.Write(SetBG7);
			writer.Write(IceBackStyle);
			writer.Write(JungleBackStyle);
			writer.Write(HellBackStyle);
			writer.Write(WindSpeed);
			writer.Write(NumberOfClouds);

			writer.Write(TreeX0);
			writer.Write(TreeX1);
			writer.Write(TreeX2);
			writer.Write(TreeStyle0);
			writer.Write(TreeStyle1);
			writer.Write(TreeStyle2);
			writer.Write(TreeStyle3);
			writer.Write(CaveBackX0);
			writer.Write(CaveBackX1);
			writer.Write(CaveBackX2);
			writer.Write(CaveBackStyle0);
			writer.Write(CaveBackStyle1);
			writer.Write(CaveBackStyle2);
			writer.Write(CaveBackStyle3);

			writer.Write(Rain);

			BitsByte bosses1 = new BitsByte((BossFlags & BossFlags.OrbSmashed) == BossFlags.OrbSmashed,
				(BossFlags & BossFlags.DownedBoss1) == BossFlags.DownedBoss1,
				(BossFlags & BossFlags.DownedBoss2) == BossFlags.DownedBoss2,
				(BossFlags & BossFlags.DownedBoss3) == BossFlags.DownedBoss3,
				(BossFlags & BossFlags.HardMode) == BossFlags.HardMode,
				(BossFlags & BossFlags.DownedClown) == BossFlags.DownedClown,
				(BossFlags & BossFlags.ServerSideCharacter) == BossFlags.ServerSideCharacter,
				(BossFlags & BossFlags.DownedPlantBoss) == BossFlags.DownedPlantBoss);
			writer.Write(bosses1);

			BitsByte bosses2 = new BitsByte((BossFlags2 & BossFlags2.DownedMechBoss1) == BossFlags2.DownedMechBoss1,
				(BossFlags2 & BossFlags2.DownedMechBoss2) == BossFlags2.DownedMechBoss2,
				(BossFlags2 & BossFlags2.DownedMechBoss3) == BossFlags2.DownedMechBoss3,
				(BossFlags2 & BossFlags2.DownedMechBossAny) == BossFlags2.DownedMechBossAny,
				(BossFlags2 & BossFlags2.CloudBg) == BossFlags2.CloudBg,
				(BossFlags2 & BossFlags2.Crimson) == BossFlags2.Crimson,
				(BossFlags2 & BossFlags2.PumpkinMoon) == BossFlags2.PumpkinMoon,
				(BossFlags2 & BossFlags2.SnowMoon) == BossFlags2.SnowMoon);
			writer.Write(bosses2);

			BitsByte bosses3 = new BitsByte((BossFlags3 & BossFlags3.ExpertMode) == BossFlags3.ExpertMode,
				(BossFlags3 & BossFlags3.FastForwardTime) == BossFlags3.FastForwardTime,
				(BossFlags3 & BossFlags3.SlimeRain) == BossFlags3.SlimeRain,
				(BossFlags3 & BossFlags3.DownedKingSlime) == BossFlags3.DownedKingSlime,
				(BossFlags3 & BossFlags3.DownedQueenBee) == BossFlags3.DownedQueenBee,
				(BossFlags3 & BossFlags3.DownedFishron) == BossFlags3.DownedFishron,
				(BossFlags3 & BossFlags3.DownedMartians) == BossFlags3.DownedMartians,
				(BossFlags3 & BossFlags3.DownedAncientCultist) == BossFlags3.DownedAncientCultist);
			writer.Write(bosses3);

			BitsByte bosses4 = new BitsByte((BossFlags4 & BossFlags4.DownedMoonLord) == BossFlags4.DownedMoonLord,
				(BossFlags4 & BossFlags4.DownedHalloweenKing) == BossFlags4.DownedHalloweenKing,
				(BossFlags4 & BossFlags4.DownedHalloweenTree) == BossFlags4.DownedHalloweenTree,
				(BossFlags4 & BossFlags4.DownedChristmasIceQueen) == BossFlags4.DownedChristmasIceQueen,
				(BossFlags4 & BossFlags4.DownedChristmasSantank) == BossFlags4.DownedChristmasSantank,
				(BossFlags4 & BossFlags4.DownedChristmasTree) == BossFlags4.DownedChristmasTree);
			writer.Write(bosses4);

			writer.Write((sbyte)Main.invasionType);
			writer.Write(Main.LobbyId);
		}
Ejemplo n.º 6
0
		public void Pack(Stream stream)
		{
			var bits = new BitsByte();

			if ((Active) && (!Inactive))
				bits[0] = true;

			if (HasWall)
				bits[2] = true;

			if (HasLiquid)
				bits[3] = true;

			if (Wire)
				bits[4] = true;
			
			if (IsHalf)
				bits[5] = true;

			if (IsActuator)
				bits[6] = true;

			if (Inactive)
			{
				bits[7] = true;
			}

			stream.WriteInt8((byte) bits);

			bits = new BitsByte();

			if ((Wire2))
				bits[0] = true;

			if (Wire3)
				bits[1] = true;

			if (HasColor)
				bits[2] = true;

			if (HasWallColor)
				bits[3] = true;

			if (Slope)
				bits[4] = true;

			if (Slope2)
				bits[5] = true;

			if (Slope3)
				bits[6] = true;


			stream.WriteInt8((byte)bits);

			if (HasColor)
			{
				stream.WriteByte(TileColor);
			}

			if (HasWallColor)
			{
				stream.WriteByte(WallColor);
			}

			if (Active)
			{
				stream.WriteInt16((short)Type);
				if (FrameImportant)
				{
					stream.WriteInt16(FrameX);
					stream.WriteInt16(FrameY);
				}
			}

			if (HasWall)
				stream.WriteInt8(Wall);

			if (HasLiquid)
			{
				stream.WriteInt8(Liquid);
				stream.WriteInt8(LiquidType);
			}
		}
Ejemplo n.º 7
0
        public override void Pack(Stream stream)
        {
            BinaryWriter writer = new BinaryWriter(stream);
            writer.Write(Time);
            BitsByte worldinfo = new BitsByte(DayTime, BloodMoon, Eclipse);
            writer.Write(worldinfo);
            writer.Write(MoonPhase);
            writer.Write(MaxTilesX);
            writer.Write(MaxTilesY);
            writer.Write(SpawnX);
            writer.Write(SpawnY);
            writer.Write(WorldSurface);
            writer.Write(RockLayer);
            writer.Write(WorldID);
            writer.Write(WorldName);
            writer.Write(MoonType);

            writer.Write(SetBG0);
            writer.Write(SetBG1);
            writer.Write(SetBG2);
            writer.Write(SetBG3);
            writer.Write(SetBG4);
            writer.Write(SetBG5);
            writer.Write(SetBG6);
            writer.Write(SetBG7);
            writer.Write(IceBackStyle);
            writer.Write(JungleBackStyle);
            writer.Write(HellBackStyle);
            writer.Write(WindSpeed);
            writer.Write(NumberOfClouds);

            writer.Write(TreeX0);
            writer.Write(TreeX1);
            writer.Write(TreeX2);
            writer.Write(TreeStyle0);
            writer.Write(TreeStyle1);
            writer.Write(TreeStyle2);
            writer.Write(TreeStyle3);
            writer.Write(CaveBackX0);
            writer.Write(CaveBackX1);
            writer.Write(CaveBackX2);
            writer.Write(CaveBackStyle0);
            writer.Write(CaveBackStyle1);
            writer.Write(CaveBackStyle2);
            writer.Write(CaveBackStyle3);

            writer.Write(Rain);

            BitsByte bosses1 = new BitsByte((BossFlags & BossFlags.OrbSmashed) == BossFlags.OrbSmashed,
                (BossFlags & BossFlags.DownedBoss1) == BossFlags.DownedBoss1,
                (BossFlags & BossFlags.DownedBoss2) == BossFlags.DownedBoss2,
                (BossFlags & BossFlags.DownedBoss3) == BossFlags.DownedBoss3,
                (BossFlags & BossFlags.HardMode) == BossFlags.HardMode,
                (BossFlags & BossFlags.DownedClown) == BossFlags.DownedClown,
                (BossFlags & BossFlags.ServerSideCharacter) == BossFlags.ServerSideCharacter,
                (BossFlags & BossFlags.DownedPlantBoss) == BossFlags.DownedPlantBoss);
            writer.Write(bosses1);

            BitsByte bosses2 = new BitsByte((BossFlags2 & BossFlags2.DownedMechBoss1) == BossFlags2.DownedMechBoss1,
                (BossFlags2 & BossFlags2.DownedMechBoss2) == BossFlags2.DownedMechBoss2,
                (BossFlags2 & BossFlags2.DownedMechBoss3) == BossFlags2.DownedMechBoss3,
                (BossFlags2 & BossFlags2.DownedMechBossAny) == BossFlags2.DownedMechBossAny,
                (BossFlags2 & BossFlags2.CloudBg) == BossFlags2.CloudBg,
                (BossFlags2 & BossFlags2.Crimson) == BossFlags2.Crimson,
                (BossFlags2 & BossFlags2.PumpkinMoon) == BossFlags2.PumpkinMoon,
                (BossFlags2 & BossFlags2.SnowMoon) == BossFlags2.SnowMoon);
            writer.Write(bosses2);
        }
Ejemplo n.º 8
0
        public override void NetSend(BinaryWriter writer)
        {
            BitsByte flags = new BitsByte();
            flags[0] = downedAbomination;
            flags[1] = downedPuritySpirit;
            writer.Write(flags);

            //If you prefer, you can use the BitsByte constructor approach as well.
            //writer.Write(saveVersion);
            //BitsByte flags = new BitsByte(downedAbomination, downedPuritySpirit);
            //writer.Write(flags);

            // This is another way to do the same thing, but with bitmasks and the bitwise OR assignment operator (the |=)
            // Note that 1 and 2 here are bit masks. The next values in the pattern are 4,8,16,32,64,128. If you require more than 8 flags, make another byte.
            //writer.Write(saveVersion);
            //byte flags = 0;
            //if (downedAbomination)
            //{
            //	flags |= 1;
            //}
            //if (downedPuritySpirit)
            //{
            //	flags |= 2;
            //}
            //writer.Write(flags);
        }