mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 14:45:35 +00:00
Toggling shield and boosters updates shield strength
This commit is contained in:
@@ -238,11 +238,22 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
||||
};
|
||||
|
||||
Ship.prototype.setSlotEnabled = function(slot, enabled) {
|
||||
if (slot.enabled != enabled && slot.c) { // Enabled state is changing
|
||||
this.priorityBands[slot.priority][powerUsageType(slot, slot.c)] += enabled ? slot.c.power : -slot.c.power;
|
||||
this.updatePower();
|
||||
if (slot.enabled != enabled) { // Enabled state is changing
|
||||
slot.enabled = enabled;
|
||||
if (slot.c) {
|
||||
this.priorityBands[slot.priority][powerUsageType(slot, slot.c)] += enabled ? slot.c.power : -slot.c.power;
|
||||
|
||||
if (slot.c.grp == 'sg') {
|
||||
this.updateShieldStrength();
|
||||
}
|
||||
else if (slot.c.grp == 'sb') {
|
||||
this.shieldMultiplier += slot.c.shieldmul * (enabled ? 1 : -1);
|
||||
this.updateShieldStrength();
|
||||
}
|
||||
|
||||
this.updatePower();
|
||||
}
|
||||
}
|
||||
slot.enabled = enabled;
|
||||
};
|
||||
|
||||
Ship.prototype.getSlotStatus = function(slot, deployed) {
|
||||
@@ -277,7 +288,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
||||
this.armourAdded -= old.armouradd;
|
||||
break;
|
||||
case 'sb':
|
||||
this.shieldMultiplier -= old.shieldmul;
|
||||
this.shieldMultiplier -= slot.enabled ? old.shieldmul : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -307,7 +318,7 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
||||
this.armourAdded += n.armouradd;
|
||||
break;
|
||||
case 'sb':
|
||||
this.shieldMultiplier += n.shieldmul;
|
||||
this.shieldMultiplier += slot.enabled ? n.shieldmul : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -351,7 +362,8 @@ angular.module('shipyard').factory('Ship', ['Components', 'calcShieldStrength',
|
||||
|
||||
Ship.prototype.updateShieldStrength = function() {
|
||||
var sgSlot = this.findInternalByGroup('sg'); // Find Shield Generator slot Index if any
|
||||
this.shieldStrength = sgSlot ? calcShieldStrength(this.mass, this.shields, sgSlot.c, this.shieldMultiplier) : 0;
|
||||
this.shieldStrength = sgSlot && sgSlot.enabled ? calcShieldStrength(this.mass, this.shields, sgSlot.c, this.shieldMultiplier) : 0;
|
||||
console.log(this.shieldStrength);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user