function AISMN_GoToWork::OnEnter(%this,%obj)
{
   %workplace = GetWorkplace(%obj);
   if(0 != %workplace)
   {
      SetPathToSpot(%obj,GetBuildingDoorX(%workplace),GetBuildingDoorY(%workplace));
      GetThisObject(%obj).playThread( 0, "run");
   }
   return;
}

function AISMN_GoToWork::OnExit(%this,%obj)
{
   GetThisObject(%obj).playThread( 0, "root");
   return;
}

//EXIT 0: ARRIVED AT WORK
//EXIT 1: WORK PLACE DOESN'T EXIST
function AISMN_GoToWork::Update(%this,%obj)
{
   if(GetWorkplace(%obj) == 0)
   {
      ReturnValue(%obj,1);
      return;
   }
   
   if(!IsFollowingPath(%obj))
   {
      ReturnValue(%obj,0);
      return;
   }
   
   ReturnValue(%obj,-1);
   return;
}