/**
  * @param TypeMapper $typeMapper
  * @param string $dataFile
  */
 public function __construct(TypeMapper $typeMapper, $dataFile = "Oblivion.esm")
 {
     $this->typeMapper = $typeMapper;
     if ($this->esm === null) {
         $this->esm = file_get_contents($dataFile);
     }
     if ($this->scriptTypes === null) {
         preg_match_all("#SCPT................EDID..([a-zA-Z0-9_-]+)\\x{00}SCHR..................(..)#si", $this->esm, $scripts);
         foreach ($scripts[2] as $i => $type) {
             $is_q = (bool) ord($type[0]);
             $is_m = (bool) ord($type[1]);
             if ($is_q) {
                 $scriptType = TES5BasicType::T_QUEST();
             } else {
                 if ($is_m) {
                     $scriptType = TES5BasicType::T_ACTIVEMAGICEFFECT();
                 } else {
                     $scriptType = TES5BasicType::T_OBJECTREFERENCE();
                 }
             }
             $this->scriptTypes[strtolower($scripts[1][$i])] = $scriptType;
         }
     }
     if ($this->globals === null) {
         preg_match_all("#GLOB................EDID..([a-zA-Z0-9_-]+)\\x{00}#si", $this->esm, $globals);
         $globalArray = [];
         foreach ($globals[1] as $global) {
             $globalArray[] = new TES5GlobalVariable($global);
         }
         $this->globals = $globalArray;
     }
     if (self::$instance === null) {
         self::$instance = $this;
     }
 }
 public function __construct(TES5ObjectPropertyFactory $objectPropertyFactory)
 {
     $this->objectPropertyFactory = $objectPropertyFactory;
     //Those are used to hook in the internal Skyblivion systems.
     $special_conversions = ['TES4AttrStrength' => TES5BasicType::T_GLOBALVARIABLE(), 'TES4AttrIntelligence' => TES5BasicType::T_GLOBALVARIABLE(), 'TES4AttrWillpower' => TES5BasicType::T_GLOBALVARIABLE(), 'TES4AttrAgility' => TES5BasicType::T_GLOBALVARIABLE(), 'TES4AttrSpeed' => TES5BasicType::T_GLOBALVARIABLE(), 'TES4AttrEndurance' => TES5BasicType::T_GLOBALVARIABLE(), 'TES4AttrPersonality' => TES5BasicType::T_GLOBALVARIABLE(), 'TES4AttrLuck' => TES5BasicType::T_GLOBALVARIABLE(), 'tContainer' => TES5TypeFactory::memberByValue("TES4Container", TES5BasicType::T_QUEST()), 'tTimer' => TES5TypeFactory::memberByValue("TES4TimerHelper", TES5BasicType::T_QUEST()), 'tGSPLocalTimer' => TES5BasicType::T_FLOAT(), 'TES4CyrodiilCrimeFaction' => TES5BasicType::T_FACTION(), self::MESSAGEBOX_VARIABLE_CONST => TES5BasicType::T_INT()];
     $this->special_conversions = $special_conversions;
 }
 public function createGlobalScopes()
 {
     $globalScopes = [];
     $globalScope = new TES5GlobalScope(new TES5ScriptHeader("TES4TimerHelper", "TES4TimerHelper", TES5BasicType::T_QUEST(), ""));
     $globalScopes[] = $globalScope;
     $globalScope = new TES5GlobalScope(new TES5ScriptHeader("TES4Container", "TES4Container", TES5BasicType::T_QUEST(), ""));
     $globalScope->add(new TES5Property("isInJail", TES5BasicType::T_BOOL(), "isInJail"));
     $globalScope->add(new TES5Property("isMurderer", TES5BasicType::T_BOOL(), "isMurderer"));
     $globalScopes[] = $globalScope;
     return $globalScopes;
 }
 /**
  * Extracts implicit reference from calls.
  * Returns a reference from calls like:
  * Enable
  * Disable
  * Activate
  * GetInFaction whatsoever
  * @param TES5GlobalScope $globalScope
  * @param TES5MultipleScriptsScope $multipleScriptsScope
  * @param TES5LocalScope $localScope
  * @return TES5Referencer
  * @throws \Ormin\OBSLexicalParser\TES5\Exception\ConversionException
  */
 private function extractImplicitReference(TES5GlobalScope $globalScope, TES5MultipleScriptsScope $multipleScriptsScope, TES5LocalScope $localScope)
 {
     switch ($globalScope->getScriptHeader()->getBasicScriptType()) {
         case TES5BasicType::T_OBJECTREFERENCE():
             return $this->referenceFactory->createReferenceToSelf($globalScope);
         case TES5BasicType::T_ACTIVEMAGICEFFECT():
             $self = $this->referenceFactory->createReferenceToSelf($globalScope);
             return $this->createObjectCall($self, "GetTargetActor", $multipleScriptsScope);
         case TES5BasicType::T_QUEST():
             //todo - this should not be done like this
             //we should actually not try to extract the implicit reference on the non-reference oblivion functions like "stopQuest"
             //think of this line as a hacky way to just get code forward.
             return $this->referenceFactory->createReferenceToSelf($globalScope);
             /**
              * TIF Fragments
              */
         /**
          * TIF Fragments
          */
         case TES5BasicType::T_TOPICINFO():
             return $this->createReadReference('akSpeakerRef', $globalScope, $multipleScriptsScope, $localScope);
         default:
             throw new ConversionException("Cannot extract implicit reference - unknown basic script type.");
     }
 }