import React from 'react'; import cn from 'classnames'; import SlotSection from './SlotSection'; import StandardSlot from './StandardSlot'; import Module from '../shipyard/Module'; import { diffDetails } from '../utils/SlotFunctions'; import * as ShipRoles from '../shipyard/ShipRoles'; import { stopCtxPropagation } from '../utils/UtilityFunctions'; /** * Standard Slot section */ export default class StandardSlotSection extends SlotSection { /** * Constructor * @param {Object} props React Component properties * @param {Object} context React Component context */ constructor(props, context) { super(props, context, 'standard', 'core internal'); this._optimizeStandard = this._optimizeStandard.bind(this); this._selectBulkhead = this._selectBulkhead.bind(this); } /** * Use the lightest/optimal available standard modules */ _optimizeStandard() { this.props.ship.useLightestStandard(); this.props.onChange(); this._close(); } /** * Fill all standard slots with the specificed rating (using max class) * @param {Boolean} shielded True if shield generator should be included * @param {integer} bulkheadIndex Bulkhead to use see Constants.BulkheadNames */ _multiPurpose(shielded, bulkheadIndex) { ShipRoles.multiPurpose(this.props.ship, shielded, bulkheadIndex); this.props.onChange(); this._close(); } /** * Trader Build * @param {Boolean} shielded True if shield generator should be included */ _optimizeCargo(shielded) { ShipRoles.trader(this.props.ship, shielded); this.props.onChange(); this._close(); } /** * Explorer role * @param {Boolean} planetary True if Planetary Vehicle Hangar (PVH) should be included */ _optimizeExplorer(planetary) { ShipRoles.explorer(this.props.ship, planetary); this.props.onChange(); this._close(); } /** * Use the specified bulkhead * @param {Object} bulkhead Bulkhead module details */ _selectBulkhead(bulkhead) { this.props.ship.useBulkhead(bulkhead.index); this.context.tooltip(); this.props.onChange(); this._close(); } /** * On right click optimize the standard modules */ _contextMenu() { this._optimizeStandard(); } /** * Generate the slot React Components * @return {Array} Array of Slots */ _getSlots() { let { ship, currentMenu } = this.props; let slots = new Array(8); let open = this._openMenu; let select = this._selectModule; let st = ship.standard; let avail = ship.getAvailableModules().standard; let bh = ship.bulkheads; slots[0] = ; slots[1] = m instanceof Module ? m.getPowerGeneration() < ship.powerRetracted : m.pgen < ship.powerRetracted} />; slots[2] = m instanceof Module ? m.getMaxMass() < (ship.ladenMass - st[1].mass + m.mass) : m.maxmass < (ship.ladenMass - st[1].mass + m.mass)} />; slots[3] = ; slots[4] = ; slots[5] = m instanceof Module ? m.getEnginesCapacity() < ship.boostEnergy : m.engcap < ship.boostEnergy} />; slots[6] = ; slots[7] = m.fuel < st[2].m.maxfuel} // Show warning when fuel tank is smaller than FSD Max Fuel />; return slots; } /** * Generate the section drop-down menu * @param {Function} translate Translate function * @return {React.Component} Section menu */ _getSectionMenu(translate) { let planetaryDisabled = this.props.ship.internal.length < 4; return
e.stopPropagation()} onContextMenu={stopCtxPropagation}>
  • {translate('Maximize Jump Range')}
{translate('roles')}
  • {translate('Multi-purpose')}
  • {translate('Combat')}
  • {translate('Trader')}
  • {translate('Shielded Trader')}
  • {translate('Explorer')}
  • {translate('Planetary Explorer')}
; } }