home *** CD-ROM | disk | FTP | other *** search
/ ring.yamanashi.ac.jp/pub/pc/freem/action/ / action.zip / baku100.zip / baku100 / Kernel / ProcessGroup.tonyu < prev    next >
Text File  |  2003-04-06  |  2KB  |  81 lines

  1. extends Object;
  2.  
  3. constructor ProcessGroup(chr) {
  4.   frameCount=2; 
  5.   waitProcs=new WaitProc();
  6.   procs=new ProcessList();
  7.   if (!chr) chars=new Array(); else chars=chr;
  8.   resumed=0;
  9. }
  10.  
  11. function killAll() {
  12.   procs.killAll();
  13. }
  14.  
  15. function setCurrent() {
  16.   $chars=chars;
  17.   $procs=procs; 
  18.   $waitProcs=waitProcs;
  19.   $curProcGroup=this;
  20. }
  21. function interrupt() {
  22.    intr=1;
  23. }
  24. function resumeInterrupt() {
  25.    resumed=1;
  26. }
  27.  
  28. function exec() {
  29.     var p,c,i;
  30.     intr=0;
  31.     if ($frameManager) $frameManager.onBeforeMove();
  32.     if (!resumed) pIdx=0; else resumed=0;
  33.     for (1; pIdx<procs.size() ; pIdx++) {
  34.       p=procs.get(pIdx);
  35.       if ( p.aobj) {
  36.         if ( p.aobj.died ){
  37.           p.kill(); 
  38.           procs.set(pIdx,0);
  39.         } else if (p.nextWake) {
  40.           p.deletedFromProcs=1;
  41.           procs.set(pIdx,0);
  42.         } else if (p.halted() ){
  43.           if (p.autoKill) p.aobj.die();
  44.           p.kill();
  45.           procs.set(pIdx,0);
  46.         } else {
  47.           p.exec();
  48.         }
  49.       }
  50.       if (intr) break;
  51.     }
  52.     for (i=chars.size()-1 ; i>=0 ; i--) {
  53.       p=chars.get(i);
  54.       if ( p.died ){
  55.         p.clearAllValues();
  56.         p.died=1;    // clearAllé┼diedé¬0é╔é╚é┴é┐éßéñé⌐éτ
  57.         chars.delete(i);
  58.       }
  59.     }
  60.     if (!intr) {
  61.       procs.pack();
  62.       if ($frameManager) $frameManager.onAfterMove();
  63.       frameCount++;
  64.       waitProcs.autoWake(frameCount);
  65.     }
  66. }
  67.     
  68.  
  69. function draw() {
  70.     var i,p,c;
  71.     setAdjust(0,0);
  72.     $map.draw();
  73.     if($panel) $panel.draw();
  74.     setAdjust($viewX,$viewY);
  75.     c=chars.size();
  76.     for (i=0 ; i<c ; i++){
  77.       p=chars.get(i);
  78.       if (p._visible) p.draw();
  79.     }
  80.     p=0;
  81. }