class BankTakeOut extends Decoration;

var(Events) name BankName;
var DeusExPlayer SafeOwner;
var MMRPGCreditCard CredCard;
var int MoneyInBank;


Function CheckBalance()
{
	local MMRPGCreditsProjectileTen Cred;
	local MMRPGCreditsProjectileFive Cred2;
	local MMRPGCreditsProjectile Cred3;
	local MMRPGCreditCard Card;

	MoneyInBank = 0;

	foreach VisibleActors(class'MMRPGCreditsProjectileTen', Cred, CollisionRadius)
	{
		MoneyInBank += 10;
	}

	foreach VisibleActors(class'MMRPGCreditsProjectileFive', Cred2, CollisionRadius)
	{
		MoneyInBank += 5;
	}

	foreach VisibleActors(class'MMRPGCreditsProjectile', Cred3, CollisionRadius)
	{
		MoneyInBank += 1;
	}


}

Function bool CanTakeOut10()
{
	local MMRPGCreditsProjectileTen Cred;
	local MMRPGCreditCard Card;

	Cred = None;

	foreach VisibleActors(class'MMRPGCreditsProjectileTen', Cred, CollisionRadius)
	{
		If(Cred != None)
		{
			foreach AllActors(class'MMRPGCreditCard', Card)
			{
				if (Card.Owner == SafeOwner)
				{
					CredCard = Card;
					return true;
				}
			}
		}
	}
	return false;
}

Function bool CanTakeOut5()
{
	local MMRPGCreditsProjectileFive Cred;
	local MMRPGCreditCard Card;

	Cred = None;

	foreach VisibleActors(class'MMRPGCreditsProjectileFive', Cred, CollisionRadius)
	{
		If(Cred != None)
		{
			foreach AllActors(class'MMRPGCreditCard', Card)
			{
				if (Card.Owner == SafeOwner)
				{
					CredCard = Card;
					return true;
				}
			}
		}
	}
	return false;
}

Function bool CanTakeOut1()
{
	local MMRPGCreditsProjectile Cred;
	local MMRPGCreditCard Card;

	Cred = None;

	foreach VisibleActors(class'MMRPGCreditsProjectile', Cred, CollisionRadius)
	{
		If(Cred != None)
		{
			foreach AllActors(class'MMRPGCreditCard', Card)
			{
				if (Card.Owner == SafeOwner)
				{
					CredCard = Card;
					return true;
				}
			}
		}
	}
	return false;
}

Function TakeOut10()
{
	local MMRPGCreditsProjectileTen Cred;
	local int CheckInt;

	//Thanks to [A]lex for checkint part!

	CheckInt = 0;
	if (CanTakeOut10())
	{
		foreach VisibleActors(class'MMRPGCreditsProjectileTen', Cred, CollisionRadius)
		{
			if(CheckInt == 0)
			{
				Cred.Destroy();
				CredCard.CreditAmount += 10;
				CheckInt = 1;
			}
		}
	}
}

Function TakeOut5()
{
	local MMRPGCreditsProjectileFive Cred;
	local int CheckInt;

	//Thanks to [A]lex for checkint part!

	CheckInt = 0;
	if (CanTakeOut5())
	{
		foreach VisibleActors(class'MMRPGCreditsProjectileFive', Cred, CollisionRadius)
		{
			if(CheckInt == 0)
			{
				Cred.Destroy();
				CredCard.CreditAmount += 5;
				CheckInt = 1;
			}
		}
	}
}


Function TakeOut1()
{
	local MMRPGCreditsProjectile Cred;
	local int CheckInt;

	//Thanks to [A]lex for checkint part!

	CheckInt = 0;
	if (CanTakeOut1())
	{
		foreach VisibleActors(class'MMRPGCreditsProjectile', Cred, CollisionRadius)
		{
			if(CheckInt == 0)
			{
				Cred.Destroy();
				CredCard.CreditAmount += 1;
				CheckInt = 1;
			}
		}
	}
}


defaultproperties
{
     bHidden=True
     Physics=PHYS_None
     DrawType=DT_Sprite
     Texture=Texture'Engine.S_Inventory'
     DrawScale=1.000000
     CollisionRadius=43.000000
     CollisionHeight=40.000000
     Mass=0.000000
     Buoyancy=0.000000
     bBlockActors=False
     bBlockPlayers=False
     bCollideActors=False
     bCollideWorld=False
     bProjTarget=False
}
