mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-08 22:33:24 +00:00
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
angular.module('shipyard').service('Components', ['lodash', 'ComponentSet', function (_, ComponentSet) {
|
|
var C = DB.components;
|
|
|
|
this.cargoScoop = function() {
|
|
return { name: 'Cargo Scoop', class: 1, rating: 'H', power: 0.6};
|
|
}
|
|
|
|
this.common = function (typeIndex, componentId) {
|
|
return C.common[typeIndex][componentId];
|
|
};
|
|
|
|
this.hardpoints = function(id) {
|
|
for (var n in C.hardpoints) {
|
|
var group = C.hardpoints[n];
|
|
for (var i = 0; i < group.length; i++) {
|
|
if (group[i].id == id) {
|
|
return group[i];
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
|
|
this.internal = function(id) {
|
|
for (var n in C.internal) {
|
|
var group = C.internal[n];
|
|
for (var i = 0; i < group.length; i++) {
|
|
if (group[i].id == id) {
|
|
return group[i];
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
|
|
this.bulkheads = function(shipId, bulkheadsId) {
|
|
return C.bulkheads[shipId][bulkheadsId];
|
|
};
|
|
|
|
this.forShip = function (shipId) {
|
|
var ship = DB.ships[shipId];
|
|
return new ComponentSet(C, ship.properties.mass, ship.slots.common, ship.slots.internal[0], ship.slots.hardpoints[0]);
|
|
};
|
|
|
|
}]); |