class Pawn2D expands Pawn
	abstract;

var bool bFacingRight;
var bool bRunning;
var bool bWalking;
var float Position;

function PreBeginPlay()
{
	bIsPlayer = true;
	Super.PreBeginPlay();
}

function PostBeginPlay()
{
	local Weapon newWeapon;
	Super.PostBeginPlay();

	newWeapon = Spawn(class'Eightball');
	if( newWeapon != None )
	{
		newWeapon.BecomeItem();
		AddInventory(newWeapon);
		newWeapon.BringUp();
		newWeapon.Instigator = self;
		newWeapon.GiveAmmo(self);
		newWeapon.WeaponSet(self);
		newWeapon.ThirdPersonScale = 0.03;
	}
	bRunning = true;
	PlayRunning();
}

function Destroyed()
{
	if ( Weapon != None )
		Weapon.Destroy();

	Super.Destroyed();
}

function PlayRunning()
{
	if (Weapon == None)
		AnimSequence = 'RunSM';
	else if ( Weapon.bPointing ) 
	{
		if (Weapon.Mass < 20)
			AnimSequence = 'RunSMFR';
		else
			AnimSequence = 'RunLGFR';
	}
	else
	{
		if (Weapon.Mass < 20)
			AnimSequence = 'RunSM';
		else
			AnimSequence = 'RunLG';
	}
	LoopAnim(AnimSequence);
}

function Update(float DeltaTime)
{
	local float RemainingTime;
	local Rotator NewRot;

	// Update position
	if ( bFacingRight )
	{
		Position += DeltaTime * 0.4;
		if ( Position > 1 )
		{
			NewRot = Rotation;
			NewRot.Yaw = 49152;
			SetRotation(NewRot);
			bFacingRight = false;
		}
	}
	else
	{
		Position -= DeltaTime * 0.4;
		if ( Position < 0 )
		{
			NewRot = Rotation;
			NewRot.Yaw = 16384;
			SetRotation(NewRot);
			bFacingRight = true;
		}
	}

	// Update Animation
	RemainingTime = DeltaTime;
	while ( RemainingTime > 0 )
	{
		if ( AnimFrame < 0 )
		{
			AnimFrame += TweenRate * RemainingTime;
			if ( AnimFrame > 0 )
				RemainingTime = AnimFrame/TweenRate;
			else
				RemainingTime = 0;
		}
		else
		{
			AnimFrame += AnimRate * RemainingTime;
			if ( AnimFrame > 1 )
			{
				RemainingTime = (AnimFrame - 1)/AnimRate;
				AnimFrame = 0;
			}
			else
				RemainingTime = 0;
		}
	}
}

DefaultProperties
{
	Physics=PHYS_None
	CollisionRadius=0
	CollisionHeight=0
	bProjTarget=false
     bCollideActors=false
     bCollideWorld=false
     bBlockActors=false
     bBlockPlayers=false
     bOnlyOwnerSee=True
	 bAlwaysTick=True
     RemoteRole=ROLE_None
     DrawType=DT_Mesh
     DrawScale=0.030000
     bUnlit=True
	 bIsPlayer=true
}