Пример #1
0
 /**
  * Get a lang file for an NPC.
  * @param SR_NPC $npc
  * @return GWF_LangTrans
  */
 public static function getLangNPC(SR_NPC $npc)
 {
     # Full classname
     $cl = $npc->getNPCClassName();
     # Cache hit?
     if (true === isset(self::$LANG_NPC[$cl])) {
         return self::$LANG_NPC[$cl];
     }
     # Get classname without city
     if (false === ($cls = Common::substrFrom($cl, '_', false))) {
         die(sprintf('NPC %s does not follow naming conventions 1!', $npc->getClassName()));
     }
     $cls = strtolower($cls);
     # Get cityname
     if (false === ($city = $npc->getNPCCityClass())) {
         die(sprintf('NPC %s does not follow naming conventions 2!', $npc->getClassName()));
     }
     $cityname = $city->getName();
     # Cache npcs here
     $path = sprintf('%scity/%s/lang/npc/%s/%s', Shadowrun4::getShadowDir(), $cityname, $cls, $cls);
     self::$LANG_NPC[$cl] = new GWF_LangTrans($path);
     # And return the langfile!
     return self::$LANG_NPC[$cl];
 }