class UR_Actor_LinkMine extends UTDeployedActor
	placeable;

/** range for detecting enemies */
var float DetectionRange;
/** class of spider mine to spawn */
var class<UR_Proj_LinkPowerPlasma> MineClass;

var() int MyTeam;

/** played when we spawn a mine */
var SoundCue ActivateSound;

simulated event PostBeginPlay()
{
	SetTimer(0.5, false, 'CheckForEnemies');
	bDeployed = true;
	Super.PostBeginPlay();
}

event Landed(vector HitNormal, Actor HitActor)
{
	PerformDeploy();
}

simulated function PerformDeploy()
{
	SkeletalMeshComponent(Mesh).PlayAnim('Deploy');
}

/** spawn a mine to attack the given target */
function UR_Proj_LinkPowerPlasma SpawnMine(Pawn Target, vector TargetDir)
{
	local UR_Proj_LinkPowerPlasma Mine;
	local vector X,Y,Z;
	PlaySound(ActivateSound);
	GetAxes(Rotation, X,Y,Z);
	Mine = Spawn(MineClass,,, Location + 25*Z);
	if (Mine != None)
	{
		Mine.Init(TargetDir);
		Mine.TossZ = 1000.0;
	}

	return Mine;
}

/** called on a timer to check for enemies to target with mines */
function CheckForEnemies()
{
	local Controller C;
	local float NextInterval;

	if (!bDeleteMe)
	{
		NextInterval = 0.25;
		foreach WorldInfo.AllControllers(class'Controller', C)
		{
			if (UR_SurferRocket(C.Pawn) != None && VSize(C.Pawn.Location - Location) < DetectionRange && FastTrace(C.Pawn.Location, Location))
			{
				SpawnMine(C.Pawn, Normal(C.Pawn.Location - Location));
				NextInterval = 0.5;
			}
		}
		SetTimer(NextInterval, false, 'CheckForEnemies');
	}
}

defaultproperties
{
   DetectionRange=4000.000000
   MineClass=Class'UnrealRider.UR_Proj_LinkPowerPlasma'

   ActivateSound=SoundCue'A_Pickups_Deployables.SpiderMine.SpiderMine_ActivateCue'

   Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment ObjName=MyLightEnvironment Archetype=DynamicLightEnvironmentComponent'Engine.Default__DynamicLightEnvironmentComponent'
      ModShadowFadeoutTime=1.000000
      Name="MyLightEnvironment"
      ObjectArchetype=DynamicLightEnvironmentComponent'Engine.Default__DynamicLightEnvironmentComponent'
   End Object


      Begin Object Name=DeployedLightEnvironment ObjName=DeployedLightEnvironment Archetype=DynamicLightEnvironmentComponent'UTGame.Default__UTSpiderMineTrap:DeployedLightEnvironment'
      ObjectArchetype=DynamicLightEnvironmentComponent'UTGame.Default__UTSpiderMineTrap:DeployedLightEnvironment'
   End Object
   LightEnvironment=DeployedLightEnvironment

   Begin Object Class=SkeletalMeshComponent Name=ThirdPersonMesh ObjName=ThirdPersonMesh Archetype=SkeletalMeshComponent'Engine.Default__SkeletalMeshComponent'
      SkeletalMesh=SkeletalMesh'PICKUPS.Deployables.Mesh.SK_Deployables_SpiderMine'
      Begin Object Class=AnimNodeSequence Name=MeshSequenceA ObjName=MeshSequenceA Archetype=AnimNodeSequence'Engine.Default__AnimNodeSequence'
         Name="MeshSequenceA"
         ObjectArchetype=AnimNodeSequence'Engine.Default__AnimNodeSequence'
      End Object
      Animations=AnimNodeSequence'UTGameContent.Default__UTSpiderMineTrapBlue:MeshSequenceA'
      AnimSets(0)=AnimSet'PICKUPS.Deployables.Anims.K_Deployables_SpiderMine'
      Materials(0)=Material'PICKUPS.Deployables.Materials.M_Deployables_Spidermine_VRed'
      LightEnvironment=MyLightEnvironment
      bUseAsOccluder=False
      Name="ThirdPersonMesh"
      ObjectArchetype=SkeletalMeshComponent'Engine.Default__SkeletalMeshComponent'
   End Object
   Mesh=ThirdPersonMesh


   Components(0)=DeployedLightEnvironment
   Begin Object class=CylinderComponent Name=CollisionCylinder ObjName=CollisionCylinder Archetype=CylinderComponent'UTGame.Default__UTSpiderMineTrap:CollisionCylinder'
      ObjectArchetype=CylinderComponent'UTGame.Default__UTSpiderMineTrap:CollisionCylinder'
   End Object
   Components(1)=CollisionCylinder

   Components(2)=MyLightEnvironment
   Components(3)=ThirdPersonMesh
   CollisionComponent=CollisionCylinder
   Name="Default__UTSpiderMineTrapBlue"
   ObjectArchetype=UTSpiderMineTrap'UTGame.Default__UTSpiderMineTrap'
}
