Add modeling to new projectile handling
This commit is contained in:
parent
ea6425a2e2
commit
c2e3f65a2a
4 changed files with 97 additions and 7 deletions
|
|
@ -38,6 +38,7 @@ using OTAPI.Tile;
|
|||
using TShockAPI.Localization;
|
||||
using TShockAPI.Models;
|
||||
using TShockAPI.Models.PlayerUpdate;
|
||||
using TShockAPI.Models.Projectiles;
|
||||
|
||||
namespace TShockAPI
|
||||
{
|
||||
|
|
@ -2364,18 +2365,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))
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
86
TShockAPI/Models/Projectiles/NewProjectileData.cs
Normal file
86
TShockAPI/Models/Projectiles/NewProjectileData.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue