importonly abstract class IRestrictMovementAreaManager extends IGameSystem
{
}

importonly final class RestrictMovementAreaManager extends IRestrictMovementAreaManager
{
	public import function HasAssignedRestrictMovementArea( npcEntityID : EntityID ) : Bool;
	public import function AssignRestrictMovementArea( npcEntityID : EntityID, restrictMovementArea : NodeRef ) : Bool;
	public import function IsPointInRestrictMovementArea( npcEntityID : EntityID, point : Vector4, optional onlyActualArea : Bool ) : Bool;
	public import function IsPointInPursuitZone( npcEntityID : EntityID, point : Vector4 ) : Bool;
	public import function FindPointInRestrictMovementArea( npcEntityID : EntityID, referencePoint : Vector4, out restrictMovementAreaPoint : Vector4 ) : Bool;
	public import function GetAllPuppetsInRestrictMovementArea( area : RestrictMovementArea ) : array< EntityID >;
}

importonly struct RestrictMovementArea
{
}

importonly abstract class ICombatRestrictMovementAreaCondition extends IScriptable
{
}

import class CombatRestrictMovementAreaScriptCondition extends ICombatRestrictMovementAreaCondition
{

	public virtual function IsFulfilled( game : GameInstance, entityId : EntityID, area : RestrictMovementArea, entityEntered : Bool ) : Bool
	{
		return true;
	}

}

class CombatRestrictMovementAreaPlayerEnterMainRMACondition extends CombatRestrictMovementAreaScriptCondition
{

	public override function IsFulfilled( game : GameInstance, entityId : EntityID, area : RestrictMovementArea, entityEntered : Bool ) : Bool
	{
		var localPlayer : GameObject;
		if( entityEntered )
		{
			return true;
		}
		if( GameInstance.GetRestrictMovementAreaManager( game ).HasAssignedRestrictMovementArea( entityId ) )
		{
			localPlayer = GameInstance.GetPlayerSystem( game ).GetLocalPlayerMainGameObject();
			if( localPlayer )
			{
				if( GameInstance.GetRestrictMovementAreaManager( game ).IsPointInRestrictMovementArea( entityId, localPlayer.GetWorldPosition(), true ) )
				{
					return true;
				}
			}
		}
		return false;
	}

}

class CombatRestrictMovementAreaAllDeadCondition extends CombatRestrictMovementAreaScriptCondition
{

	public override function IsFulfilled( game : GameInstance, entityId : EntityID, area : RestrictMovementArea, entityEntered : Bool ) : Bool
	{
		var puppetsInRestrictedArea : array< EntityID >;
		var someoneAlive : Bool;
		var puppetEntityId : EntityID;
		var i : Int32;
		var isDead : Bool;
		var isDefeated : Bool;
		someoneAlive = false;
		if( entityEntered )
		{
			return true;
		}
		puppetsInRestrictedArea = GameInstance.GetRestrictMovementAreaManager( game ).GetAllPuppetsInRestrictMovementArea( area );
		for( i = 0; i < puppetsInRestrictedArea.Size(); i = i + 1 )
		{
			puppetEntityId = puppetsInRestrictedArea[ i ];
			isDefeated = GameInstance.GetStatusEffectSystem( game ).HasStatusEffect( puppetEntityId, T"BaseStatusEffect.Defeated" );
			isDead = GameInstance.GetStatPoolsSystem( game ).HasStatPoolValueReachedMin( puppetEntityId, gamedataStatPoolType.Health );
			if( !( isDefeated ) && !( isDead ) )
			{
				someoneAlive = true;
			}
		}
		if( someoneAlive )
		{
			return false;
		}
		return true;
	}

}

