mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-08 22:33:24 +00:00
[744] add support of experimental weapon stabilizer (#745)
This commit is contained in:
@@ -4,7 +4,7 @@ import * as ModuleUtils from '../shipyard/ModuleUtils';
|
|||||||
import TranslatedComponent from './TranslatedComponent';
|
import TranslatedComponent from './TranslatedComponent';
|
||||||
import { stopCtxPropagation } from '../utils/UtilityFunctions';
|
import { stopCtxPropagation } from '../utils/UtilityFunctions';
|
||||||
import cn from 'classnames';
|
import cn from 'classnames';
|
||||||
import { MountFixed, MountGimballed, MountTurret } from './SvgIcons';
|
import { CoriolisLogo, MountFixed, MountGimballed, MountTurret } from './SvgIcons';
|
||||||
import FuzzySearch from 'react-fuzzy';
|
import FuzzySearch from 'react-fuzzy';
|
||||||
|
|
||||||
const PRESS_THRESHOLD = 500; // mouse/touch down threshold
|
const PRESS_THRESHOLD = 500; // mouse/touch down threshold
|
||||||
@@ -84,6 +84,8 @@ const GRPCAT = {
|
|||||||
// Assists
|
// Assists
|
||||||
'dc': 'flight assists',
|
'dc': 'flight assists',
|
||||||
'sua': 'flight assists',
|
'sua': 'flight assists',
|
||||||
|
// Stabilizers
|
||||||
|
'ews': 'weapon stabilizers',
|
||||||
};
|
};
|
||||||
// Order here is the order in which items will be shown in the modules menu
|
// Order here is the order in which items will be shown in the modules menu
|
||||||
const CATEGORIES = {
|
const CATEGORIES = {
|
||||||
@@ -107,11 +109,12 @@ const CATEGORIES = {
|
|||||||
// Utilities
|
// Utilities
|
||||||
'sb': ['sb'],
|
'sb': ['sb'],
|
||||||
'hs': ['hs'],
|
'hs': ['hs'],
|
||||||
|
'csl': ['csl'],
|
||||||
'defence': ['ch', 'po', 'ec'],
|
'defence': ['ch', 'po', 'ec'],
|
||||||
'scanners': ['sc', 'ss', 'cs', 'kw', 'ws'], // Overloaded with internal scanners
|
'scanners': ['sc', 'ss', 'cs', 'kw', 'ws'], // Overloaded with internal scanners
|
||||||
// Experimental
|
// Experimental
|
||||||
'experimental': ['axmc', 'axmr', 'rfl', 'tbrfl', 'tbsc', 'tbem', 'xs', 'sfn', 'rcpl', 'dtl', 'rsl', 'mahr',],
|
'experimental': ['axmc', 'axmr', 'rfl', 'tbrfl', 'tbsc', 'tbem', 'xs', 'sfn', 'rcpl', 'dtl', 'rsl', 'mahr',],
|
||||||
|
'weapon stabilizers': ['ews'],
|
||||||
// Guardian
|
// Guardian
|
||||||
'guardian': ['gpp', 'gpd', 'gpc', 'ggc', 'gsrp', 'gfsb', 'ghrp', 'gmrp', 'gsc'],
|
'guardian': ['gpp', 'gpd', 'gpc', 'ggc', 'gsrp', 'gfsb', 'ghrp', 'gmrp', 'gsc'],
|
||||||
|
|
||||||
@@ -250,6 +253,24 @@ export default class AvailableModulesMenu extends TranslatedComponent {
|
|||||||
return { list, currentGroup, fuzzy, trackingFocus };
|
return { list, currentGroup, fuzzy, trackingFocus };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return Is expiremental capacity reached
|
||||||
|
* @return {boolean} Is experimental capacity reached
|
||||||
|
*/
|
||||||
|
_experimentalCapacityReached() {
|
||||||
|
const ship = this.props.ship;
|
||||||
|
const ews = ship.internal.filter(o => o.m && o.m.grp === 'ews');
|
||||||
|
let expCap;
|
||||||
|
|
||||||
|
if(ews.length < 1){
|
||||||
|
expCap = 4;
|
||||||
|
} else{
|
||||||
|
expCap = ews[0].m.class == 3 ? 5 : 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
return expCap <= this.props.ship.hardpoints.filter(o => o.m && o.m.experimental).length;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate React Components for Module Group
|
* Generate React Components for Module Group
|
||||||
* @param {Ship} ship Ship the selection is for
|
* @param {Ship} ship Ship the selection is for
|
||||||
@@ -286,7 +307,7 @@ export default class AvailableModulesMenu extends TranslatedComponent {
|
|||||||
// If the mounted module is experimental as well, we can replace it so
|
// If the mounted module is experimental as well, we can replace it so
|
||||||
// the maximum does not apply
|
// the maximum does not apply
|
||||||
} else if (m.experimental && (!mountedModule || !mountedModule.experimental)) {
|
} else if (m.experimental && (!mountedModule || !mountedModule.experimental)) {
|
||||||
disabled = 4 <= ship.hardpoints.filter(o => o.m && o.m.experimental).length;
|
disabled = this._experimentalCapacityReached();
|
||||||
} else if (m.grp === 'mlc' && (!mountedModule || mountedModule.grp !== 'mlc')) {
|
} else if (m.grp === 'mlc' && (!mountedModule || mountedModule.grp !== 'mlc')) {
|
||||||
disabled = 1 <= ship.internal.filter(o => o.m && o.m.grp === 'mlc').length;
|
disabled = 1 <= ship.internal.filter(o => o.m && o.m.grp === 'mlc').length;
|
||||||
}
|
}
|
||||||
@@ -385,6 +406,7 @@ export default class AvailableModulesMenu extends TranslatedComponent {
|
|||||||
if (this.props.modules instanceof Array) {
|
if (this.props.modules instanceof Array) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const mountedModule = this.props.m;
|
||||||
return (
|
return (
|
||||||
<FuzzySearch
|
<FuzzySearch
|
||||||
list={this.state.fuzzy}
|
list={this.state.fuzzy}
|
||||||
@@ -396,11 +418,20 @@ export default class AvailableModulesMenu extends TranslatedComponent {
|
|||||||
onSelect={e => this.props.onSelect.bind(null, e.m)()}
|
onSelect={e => this.props.onSelect.bind(null, e.m)()}
|
||||||
resultsTemplate={(props, state, styles, clickHandler) => {
|
resultsTemplate={(props, state, styles, clickHandler) => {
|
||||||
return state.results.map((val, i) => {
|
return state.results.map((val, i) => {
|
||||||
|
let disabled;
|
||||||
|
|
||||||
|
if(val.m.experimental && (!mountedModule || !mountedModule.experimental)) {
|
||||||
|
disabled = this._experimentalCapacityReached();
|
||||||
|
} else{
|
||||||
|
disabled = false;
|
||||||
|
}
|
||||||
|
const handler = disabled ? null : () => clickHandler(i);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={i}
|
key={i}
|
||||||
className={'lc'}
|
className={cn('lc', {disabled})}
|
||||||
onClick={() => clickHandler(i)}
|
onClick={handler}
|
||||||
>
|
>
|
||||||
{val.name}
|
{val.name}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -93,6 +93,7 @@
|
|||||||
"ch": "Chaff Launcher",
|
"ch": "Chaff Launcher",
|
||||||
"cr": "Cargo Rack",
|
"cr": "Cargo Rack",
|
||||||
"cs": "Manifest Scanner",
|
"cs": "Manifest Scanner",
|
||||||
|
"csl": "Caustic Sink Launcher",
|
||||||
"dc": "Docking Computer",
|
"dc": "Docking Computer",
|
||||||
"ec": "Electronic Countermeasure",
|
"ec": "Electronic Countermeasure",
|
||||||
"fc": "Fragment Cannon",
|
"fc": "Fragment Cannon",
|
||||||
@@ -113,6 +114,7 @@
|
|||||||
"mlc": "Multi Limpet Controller",
|
"mlc": "Multi Limpet Controller",
|
||||||
"mr": "Missile Rack",
|
"mr": "Missile Rack",
|
||||||
"axmr": "AX Missile Rack",
|
"axmr": "AX Missile Rack",
|
||||||
|
"ews": "Experimental Weapon Stabilizer",
|
||||||
"mrp": "Module Reinforcement Package",
|
"mrp": "Module Reinforcement Package",
|
||||||
"nl": "Mine Launcher",
|
"nl": "Mine Launcher",
|
||||||
"pa": "Plasma Accelerator",
|
"pa": "Plasma Accelerator",
|
||||||
|
|||||||
@@ -94,6 +94,7 @@
|
|||||||
"ch": "Разбрасыватель дипольных отражателей",
|
"ch": "Разбрасыватель дипольных отражателей",
|
||||||
"cr": "Грузовой стеллаж",
|
"cr": "Грузовой стеллаж",
|
||||||
"cs": "Сканер содержимого",
|
"cs": "Сканер содержимого",
|
||||||
|
"csl": "Антикор катапульта",
|
||||||
"dc": "Стыковочный компьютер",
|
"dc": "Стыковочный компьютер",
|
||||||
"ec": "Радиоэлектронное подавление",
|
"ec": "Радиоэлектронное подавление",
|
||||||
"fc": "Залповое орудие",
|
"fc": "Залповое орудие",
|
||||||
@@ -113,6 +114,7 @@
|
|||||||
"ml": "Проходочный лазер",
|
"ml": "Проходочный лазер",
|
||||||
"mr": "Блок ракет",
|
"mr": "Блок ракет",
|
||||||
"axmr": "Блок ракет АИ",
|
"axmr": "Блок ракет АИ",
|
||||||
|
"ews": "Стабилизатор экспериментального вооружения",
|
||||||
"mrp": "Набор для усиления модуля",
|
"mrp": "Набор для усиления модуля",
|
||||||
"nl": "Мины",
|
"nl": "Мины",
|
||||||
"pa": "Ускоритель плазмы",
|
"pa": "Ускоритель плазмы",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { Ships, Modifications } from 'coriolis-data/dist';
|
|||||||
import { chain } from 'lodash';
|
import { chain } from 'lodash';
|
||||||
const zlib = require('zlib');
|
const zlib = require('zlib');
|
||||||
|
|
||||||
const UNIQUE_MODULES = ['psg', 'sg', 'bsg', 'rf', 'fs', 'fh', 'gfsb', 'dc'];
|
const UNIQUE_MODULES = ['psg', 'sg', 'bsg', 'rf', 'fs', 'fh', 'gfsb', 'dc', 'ews'];
|
||||||
|
|
||||||
// Constants for modifications struct
|
// Constants for modifications struct
|
||||||
const SLOT_ID_DONE = -1;
|
const SLOT_ID_DONE = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user