Merge branch 'general-devel' of github.com:Pryaxis/TShock into general-devel

This commit is contained in:
Lucas Nicodemus 2020-05-17 23:48:55 -07:00
commit 0a95457a7e
No known key found for this signature in database
GPG key ID: A07BD9023D1664DB
4 changed files with 97 additions and 7 deletions

View file

@ -38,6 +38,7 @@ using OTAPI.Tile;
using TShockAPI.Localization;
using TShockAPI.Models;
using TShockAPI.Models.PlayerUpdate;
using TShockAPI.Models.Projectiles;
namespace TShockAPI
{
@ -2374,18 +2375,17 @@ namespace TShockAPI
Vector2 vel = args.Data.ReadVector2();
byte owner = args.Data.ReadInt8();
short type = args.Data.ReadInt16();
BitsByte bits = (BitsByte)args.Data.ReadByte();
NewProjectileData bits = new NewProjectileData((BitsByte)args.Data.ReadByte());
float[] ai = new float[Projectile.maxAI];
for (int i = 0; i < Projectile.maxAI; ++i)
ai[i] = !bits[i] ? 0.0f : args.Data.ReadSingle();
short dmg = bits[4] ? args.Data.ReadInt16() : (short)0;
float knockback = bits[5] ? args.Data.ReadSingle() : 0.0f;
short origDmg = bits[6] ? args.Data.ReadInt16() : (short)0;
short projUUID = bits[7] ? args.Data.ReadInt16() : (short)-1;
ai[i] = !bits.AI[i] ? 0.0f : args.Data.ReadSingle();
short dmg = bits.HasDamage ? args.Data.ReadInt16() : (short)0;
float knockback = bits.HasKnockback ? args.Data.ReadSingle() : 0.0f;
short origDmg = bits.HasOriginalDamage ? args.Data.ReadInt16() : (short)0;
short projUUID = bits.HasUUUID ? args.Data.ReadInt16() : (short)-1;
if (projUUID >= 1000)
projUUID = -1;
var index = TShock.Utils.SearchProjectile(ident, owner);
if (OnNewProjectile(args.Data, ident, pos, vel, knockback, dmg, owner, type, index, args.Player))

View file

@ -14,6 +14,9 @@ namespace TShockAPI.Models.PlayerUpdate
{
public BitsByte bitsbyte;
/// <summary>
/// Gets or Sets the Sleeping flag on the backing field
/// </summary>
public bool IsSleeping
{
get => bitsbyte[0];

View file

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria;
namespace TShockAPI.Models.Projectiles
{
/// <summary>
/// Model for the data sent with a new projectile packet
/// </summary>
public struct NewProjectileData
{
public BitsByte bitsbyte;
/// <summary>
/// Gets or Sets the keepTryingHoverDown flag on the backing field
/// </summary>
public bool[] AI
{
get
{
bool[] arr = new bool[Projectile.maxAI];
for (int i = 0; i < Projectile.maxAI; i++)
{
arr[i] = bitsbyte[i];
}
return arr;
}
set
{
for (int i = 0; i < Projectile.maxAI; i++)
{
bitsbyte[i] = value[i];
}
}
}
/// <summary>
/// Gets or Sets the Damage flag on the backing field
/// </summary>
public bool HasDamage
{
get => bitsbyte[4];
set => bitsbyte[4] = value;
}
/// <summary>
/// Gets or Sets the Knockback flag on the backing field
/// </summary>
public bool HasKnockback
{
get => bitsbyte[5];
set => bitsbyte[5] = value;
}
/// <summary>
/// Gets or Sets the Original Damage flag on the backing field
/// </summary>
public bool HasOriginalDamage
{
get => bitsbyte[6];
set => bitsbyte[6] = value;
}
/// <summary>
/// Gets or Sets the UUID flag on the backing field
/// </summary>
public bool HasUUUID
{
get => bitsbyte[7];
set => bitsbyte[7] = value;
}
/// <summary>
/// Constructs a new instance of NewProjectileData with the given backing BitsByte
/// </summary>
/// <param name="bitsbyte"></param>
public NewProjectileData(BitsByte bitsbyte)
{
this.bitsbyte = bitsbyte;
}
}
}

View file

@ -97,6 +97,7 @@
<Compile Include="Models\PlayerUpdate\MiscDataSet1.cs" />
<Compile Include="Models\PlayerUpdate\MiscDataSet2.cs" />
<Compile Include="Models\PlayerUpdate\MiscDataSet3.cs" />
<Compile Include="Models\Projectiles\NewProjectileData.cs" />
<Compile Include="NetItem.cs" />
<Compile Include="PlayerData.cs" />
<Compile Include="RegionHandler.cs" />