// Copyright (c) coherence ApS.
// For all coherence generated code, the coherence SDK license terms apply. See the license file in the coherence Package root folder for more information.

// <auto-generated>
// Generated file. DO NOT EDIT!
// </auto-generated>
namespace Coherence.Generated
{
	using Coherence.ProtocolDef;
	using Coherence.Serializer;
	using Coherence.Brook;
	using UnityEngine;
	using Coherence.Entity;

	public struct AuthorityTransfer : IEntityCommand
	{
		public uint newAuthority;
		public bool accepted;
		public int authorityType;

		public MessageTarget Routing => MessageTarget.All;
		public uint GetComponentType() => Definition.InternalAuthorityTransfer;

		public AuthorityTransfer
		(
			uint datanewAuthority,
			bool dataaccepted,
			int dataauthorityType
		)
		{
			newAuthority = datanewAuthority;
			accepted = dataaccepted;
			authorityType = dataauthorityType;
		}

		public static void Serialize(AuthorityTransfer commandData, IOutProtocolBitStream bitStream)
		{
			bitStream.WriteUIntegerRange(commandData.newAuthority, 32, 0);
			bitStream.WriteBool(commandData.accepted);
			bitStream.WriteIntegerRange(commandData.authorityType, 2, 0);
		}

		public static AuthorityTransfer Deserialize(IInProtocolBitStream bitStream)
		{
			var datanewAuthority = bitStream.ReadUIntegerRange(32, 0);
			var dataaccepted = bitStream.ReadBool();
			var dataauthorityType = bitStream.ReadIntegerRange(2, 0);

			return new AuthorityTransfer
			(
				datanewAuthority,
				dataaccepted,
				dataauthorityType
			){};
		}
	}
}
