Files
LuaCsForBarotraumaEP/Barotrauma/BarotraumaServer/ServerSource/Items/Components/Projectile.cs
T
2020-03-27 15:22:59 -03:00

39 lines
1.3 KiB
C#

using Barotrauma.Networking;
using System;
namespace Barotrauma.Items.Components
{
partial class Projectile : ItemComponent
{
public void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
{
msg.Write(StickTarget != null);
if (StickTarget != null)
{
msg.Write(item.body.SimPosition.X);
msg.Write(item.body.SimPosition.Y);
msg.Write(stickJoint.Axis.X);
msg.Write(stickJoint.Axis.Y);
if (StickTarget.UserData is Structure structure)
{
msg.Write(structure.ID);
msg.Write((byte)structure.Bodies.IndexOf(StickTarget));
}
else if (StickTarget.UserData is Entity entity)
{
msg.Write(entity.ID);
}
else if (StickTarget.UserData is Limb limb)
{
msg.Write(limb.character.ID);
msg.Write((byte)Array.IndexOf(limb.character.AnimController.Limbs, limb));
}
else
{
throw new NotImplementedException(StickTarget.UserData?.ToString() ?? "null" + " is not a valid projectile stick target.");
}
}
}
}
}