/* Galli Flocking Behaviour
//
*/

machine GalliFlock
{
	default state Start
	{
		;// temp here for dilopho
		action StopAnim("fan", "up_lp")
		action PlayAnimLooping("fan", "dn_lp", false, -1.0, 1.0)
		;// temp here for dilopho

		action SetAutoMovementBlend(true)
		action SetSpeedModifier(1.0)
		action SetRunMode(true)

		action StartLook("LookProximity", 0.5)
		action InitFlockAway()

		transition IsAwayFromFlock(1.0)
		{
			action SetRandomTimerBetween(1, 2.0, 3.0)
			goto FlockCloser
		}
		transition
		{
			goto Wander
		}
	}

	state FlockCloser
	{
		action UpdateFlockAway()
		transition SeekTowardsFlock()
		{
			action SetRandomTimerBetween(2, 5.0, 5.0)
			goto FlockCloserWait
		}
		transition IsTimerUp(1)
		{
			goto Wander
		}
	}

	state FlockCloserWait
	{
		action UpdateFlockAway()
		transition HasArrived()
		{
			goto Start
		}
		transition IsTimerUp(2)
		{
			action SetRandomTimerBetween(1, 2.0, 3.0)
			goto FlockCloser
		}
	}

	state Wander
	{
		transition SetWander()
		{
			action SetRandomTimerBetween(2, 5.0, 5.0)
			goto WanderWait
		}
	}

	state WanderWait
	{
		transition IsTimerUp(2) == false
		{
			goto WanderWait
		}
		transition IsAwayFromFlock(1.0)
		{
			action SetRandomTimerBetween(1, 2.0, 3.0)
			goto FlockCloser
		}
		transition HasArrived()
		{
			goto Start
		}
	}


;////////////////////////////////////////////////////////
	exitstart state FlockEndBegin
	{
		transition
		{
			goto FlockEnd
		}
	}

	exitend state FlockEnd
	{
		action UpdateFlockAway()
		action StopLook()
	}
}
