Beispiel #1
0
 /**
  * Computes and adds the material requirements for a process to a ProcessData object.
  *
  * @param IndustryModifier $iMod the object that holds all the information about skills, implants, system industry
  * indices, tax and assemblyLines
  * @param ProcessData $pdata to which materials shall be added
  * @param int $activityId of the activity
  * @param float $materialFactor the IndustryModifier and Blueprint ME level dependant ME bonus factor
  * @param float $numPortions the number of portions being built or researched. Note that passing a fraction will
  * make the method not use the rounding for the resulting required amounts.
  * @param int $manuRecursionDepth defines if and how deep used materials should be manufactured recursively
  * @param int $reactionRecursionDepth defines if and how deep used materials should be gained through reaction
  * recursively
  *
  * @return void
  */
 protected function addActivityMaterials(IndustryModifier $iMod, ProcessData $pdata, $activityId, $materialFactor, $numPortions, $manuRecursionDepth, $reactionRecursionDepth)
 {
     foreach ($this->getMaterialsForActivity($activityId) as $matId => $rawAmount) {
         $mat = Type::getById($matId);
         $amount = $rawAmount * $materialFactor * $numPortions;
         //calculate total quantity needed, applying all modifiers
         //if number of portions is a fraction, don't ceil() amounts
         if (fmod($numPortions, 1.0) > 1.0E-9) {
             $totalNeeded = $amount;
         } else {
             //fix float precision problems
             if (fmod($amount, 1.0) < 1.0E-9) {
                 $totalNeeded = round($amount);
             } else {
                 $totalNeeded = ceil($amount);
             }
         }
         //at least one unit of material is required per portion
         if ($totalNeeded < $numPortions) {
             $totalNeeded = $numPortions;
         }
         //if using recursive building and material is manufacturable, recurse!
         if ($manuRecursionDepth > 0 and $mat instanceof Manufacturable) {
             $pdata->addSubProcessData($mat->getBlueprint()->manufacture($iMod, $totalNeeded, null, null, $manuRecursionDepth - 1, $reactionRecursionDepth));
         } elseif ($reactionRecursionDepth > 0 and $mat instanceof ReactionProduct) {
             $pdata->addSubProcessData($mat->doBestReaction($iMod, $totalNeeded, $reactionRecursionDepth - 1));
         } else {
             $pdata->addMaterial($matId, $totalNeeded);
         }
     }
 }
Beispiel #2
0
 /**
  * Computes and adds the material requirements for a process to a ProcessData object.
  * 
  * 
  * @param IndustryModifier $iMod the object that holds all the information about skills, implants, system industry
  * indices, teams, tax and assemblyLines
  * @param ProcessData $pdata to which materials shall be added
  * @param int $activityId of the activity
  * @param float $materialFactor the IndustryModifier and Blueprint ME level dependant ME bonus factor
  * @param float $numPortions the number of portions being built or researched. Note that passing a fraction will
  * make the method not use the rounding for the resulting required amounts.
  * @param bool $recursive defines if used materials should be manufactured recursively
  * 
  * @return void
  */
 protected function addActivityMaterials(IndustryModifier $iMod, ProcessData $pdata, $activityId, $materialFactor, $numPortions, $recursive)
 {
     foreach ($this->getMaterialsForActivity($activityId) as $matID => $matData) {
         //if consume flag is set to 0, add to needed mats with quantity 0
         if (isset($matData['c']) and $matData['c'] == 0) {
             $pdata->addMaterial($matID, 0);
             continue;
         }
         $mat = Type::getById($matID);
         //calculate total quantity needed, applying all modifiers
         //if number of portions is a fraction, don't ceil() amounts
         if (fmod($numPortions, 1.0) > 0.0) {
             $totalNeeded = $matData['q'] * $materialFactor * $numPortions;
         } else {
             $totalNeeded = ceil($matData['q'] * $materialFactor * $numPortions);
         }
         //at least one unit of material is required per portion
         if ($totalNeeded < $numPortions) {
             $totalNeeded = $numPortions;
         }
         //if using recursive building and material is manufacturable, recurse!
         if ($recursive and $mat instanceof Manufacturable) {
             $pdata->addSubProcessData($mat->getBlueprint()->manufacture($iMod, $totalNeeded));
         } else {
             $pdata->addMaterial($matID, $totalNeeded);
         }
     }
 }