struct GateSignalInstance
{
	var gateSignal : GateSignal;
	var timeStamp : Float;
	var consumeTags : array< CName >;
}

class GateSignal extends TaggedSignalUserData
{
	var data : AISignalSenderTask;
	var priority : Float;
	var lifeTime : Float;
}

class ConsumeGateSignal extends GateSignal
{
	var consumeCallName : CName;
	var signalToConsume : GateSignal;
}

import enum AISignalFlags
{
	Undefined,
	OverridesSelf,
	InterruptsSamePriorityTask,
	InterruptsForcedBehavior,
	AcceptsAdditives,
}

implicit cast ( flag : EAIGateSignalFlags ) : AISignalFlags
{
	switch( flag )
	{
		case EAIGateSignalFlags.AIGSF_Undefined:
			return AISignalFlags.Undefined;
		case EAIGateSignalFlags.AIGSF_OverridesSelf:
			return AISignalFlags.OverridesSelf;
		case EAIGateSignalFlags.AIGSF_InterruptsSamePriorityTask:
			return AISignalFlags.InterruptsSamePriorityTask;
		case EAIGateSignalFlags.AIGSF_InterruptsForcedBehavior:
			return AISignalFlags.InterruptsForcedBehavior;
		case EAIGateSignalFlags.AIGSF_AcceptsAdditives:
			return AISignalFlags.AcceptsAdditives;
		default:
			return AISignalFlags.Undefined;
	}
}

importonly struct AIGateSignal
{
	import var flags : AISignalFlags;
	import var priority : Float;
	import var lifeTime : Float;

	public import static function IsEmpty( self : ref< AIGateSignal > ) : Bool;
	public import static function GetTagCount( self : ref< AIGateSignal > ) : Uint32;
	public import static function GetTag( self : ref< AIGateSignal >, index : Uint32 ) : CName;
	public import static function HasTag( self : ref< AIGateSignal >, tag : CName ) : Bool;
	public import static function AddTag( self : ref< AIGateSignal >, tag : CName );
	public import static function HasAllTagsOf( self : ref< AIGateSignal >, other : ref< AIGateSignal > ) : Bool;
	public import static function HasFlag( self : ref< AIGateSignal >, flag : AISignalFlags ) : Bool;
	public import static function AddFlag( self : ref< AIGateSignal >, flag : AISignalFlags );
}

importonly class AISignalHandlerComponent extends IComponent
{
	public import function AddSignal( signal : ref< AIGateSignal >, optional keepActive : Bool ) : Uint32;
	public import function RemoveSignal( id : Uint32 ) : Bool;
	public import function ConsumeSignal( tag : CName );
	public import function IsHighestPriority( tag : CName, out signalId : Uint32 ) : Bool;
	public import function GetSignal( signalId : Uint32, out signal : AIGateSignal ) : Bool;
	public import function HasSignalWithTag( tag : CName ) : Bool;
	public import function GetHighestPrioritySignal( out signal : AIGateSignal, out signalId : Uint32 ) : Bool;
	public import static function Get( entity : Entity ) : AISignalHandlerComponent;
}

