home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / alex_trax.swf / scripts / __Packages / com / neodelight / std / Blueprint.as < prev    next >
Encoding:
Text File  |  2007-10-01  |  2.9 KB  |  111 lines

  1. class com.neodelight.std.Blueprint
  2. {
  3.    static var lib = new Array();
  4.    static var cfgLoader = new LoadVars();
  5.    function Blueprint()
  6.    {
  7.    }
  8.    static function addBlueprint(id, o)
  9.    {
  10.       com.neodelight.std.Blueprint.lib[id] = o;
  11.    }
  12.    static function readConfigFile(path)
  13.    {
  14.       com.neodelight.std.Blueprint.cfgLoader.onData = function(src)
  15.       {
  16.          var _loc4_ = src.split("\n");
  17.          var _loc3_ = 0;
  18.          while(_loc3_ < _loc4_.length)
  19.          {
  20.             var _loc2_ = _loc4_[_loc3_];
  21.             if(_loc2_.charAt(0) != "#")
  22.             {
  23.                if(com.neodelight.std.XString.trim(_loc2_) != "")
  24.                {
  25.                   if(_loc2_.indexOf("=") != -1)
  26.                   {
  27.                      var _loc1_ = _loc2_.split("=");
  28.                      _loc1_[0] = com.neodelight.std.XString.trim(_loc1_[0]);
  29.                      _loc1_[1] = com.neodelight.std.XString.trim(_loc1_[1]);
  30.                      com.neodelight.std.Blueprint.addBlueprint(_loc1_[0],_loc1_[1]);
  31.                   }
  32.                }
  33.             }
  34.             _loc3_ = _loc3_ + 1;
  35.          }
  36.          com.neodelight.std.Blueprint.onReadConfigFile(src != undefined);
  37.       };
  38.       com.neodelight.std.Blueprint.cfgLoader.load(path);
  39.    }
  40.    static function onReadConfigFile(success)
  41.    {
  42.    }
  43.    static function isBlueprint(id)
  44.    {
  45.       return com.neodelight.std.Blueprint.lib[id] != undefined;
  46.    }
  47.    static function getBlueprint(id)
  48.    {
  49.       if(typeof id == "object")
  50.       {
  51.          return id;
  52.       }
  53.       var _loc1_ = com.neodelight.std.Blueprint.lib[id];
  54.       if(_loc1_.blueprint)
  55.       {
  56.          com.neodelight.std.Blueprint.apply(_loc1_,_loc1_.blueprint);
  57.       }
  58.       return _loc1_;
  59.    }
  60.    static function getBlueprints(filter)
  61.    {
  62.       if(!filter)
  63.       {
  64.          return undefined;
  65.       }
  66.       var _loc1_ = new Array();
  67.       for(var _loc3_ in com.neodelight.std.Blueprint.lib)
  68.       {
  69.          if(filter.test(_loc3_))
  70.          {
  71.             _loc1_.push(com.neodelight.std.Blueprint.getBlueprint(_loc3_));
  72.          }
  73.       }
  74.       return _loc1_;
  75.    }
  76.    static function apply(target, id)
  77.    {
  78.       if(!id)
  79.       {
  80.          id = String(target.blueprint);
  81.       }
  82.       var _loc3_ = com.neodelight.std.Blueprint.lib[id];
  83.       if(!_loc3_)
  84.       {
  85.          trace("!!!blueprint not found:" + id);
  86.       }
  87.       var _loc6_ = 0;
  88.       for(var _loc1_ in _loc3_)
  89.       {
  90.          if(_loc1_ != "blueprint")
  91.          {
  92.             if(target[_loc1_] == undefined)
  93.             {
  94.                target[_loc1_] = _loc3_[_loc1_];
  95.             }
  96.          }
  97.       }
  98.       if(_loc3_.blueprint)
  99.       {
  100.          var _loc4_ = _loc3_.blueprint.split(",");
  101.          _loc1_ = 0;
  102.          while(_loc1_ < _loc4_.length)
  103.          {
  104.             com.neodelight.std.Blueprint.apply(target,_loc4_[_loc1_]);
  105.             _loc1_ = _loc1_ + 1;
  106.          }
  107.       }
  108.       return target;
  109.    }
  110. }
  111.