/// <summary>
/// Spawns "other" to "target"
/// <para>This is soley used for the first spawn of a player</para>
/// </summary>
public static void SpawnEntity(Entity target, Entity other, bool mutual = true)
{
if (mutual)
{
SpawnEntity(other, target, false);
}
if (target.VisibleIDs.Contains(other.EntityID))
{
return;
}
if (target is Player)
{
ByteBuffer buffer = new ByteBuffer(Opcodes.SpawnPlayer.length);
buffer.WriteByte(Opcodes.SpawnPlayer.id);
buffer.WriteByte(other.EntityID);
buffer.WriteString(other.HoverName, Encoding.ASCII);
buffer.WriteShort(other.Position.X);
buffer.WriteShort(other.Position.Y);
buffer.WriteShort(other.Position.Z);
buffer.WriteByte(other.Rotation.X);
buffer.WriteByte(other.Rotation.Y);
((Player)target).SendRaw(buffer.Data);
}
target.VisibleIDs.Add(other.EntityID);
if (mutual)
{
SpawnEntity(other, target, false);
}
}