Skip to content

Commit

Permalink
Fix two minor issues in shield component
Browse files Browse the repository at this point in the history
- Calculate percent operational from shield damage and not shield strength. By shield damage I mean that the actual generator sustained damage and is not operating at a 100%. By shield strength I mean the value of the shields after they absorb damage.
- Calculate damaged from operational and not call percent. Operational is an internal variable that reports the percent the component is undamaged. Percent is a function that returns an average of the shield strength at the moment.
  • Loading branch information
royfalk committed Feb 23, 2025
1 parent 9d5a3f7 commit c23ccbd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions engine/src/components/shield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,11 @@ void Shield::CalculatePercentOperational() {
double percent = regeneration.Percent();

for (Resource<double> &facet : facets) {
percent += facet.Percent();
if(facet.MaxValue() == 0.0) {
continue;
}

percent += facet.AdjustedValue() / facet.MaxValue();
}

// A simple average of regeneration and facets
Expand Down Expand Up @@ -289,7 +293,7 @@ void Shield::Repair() {
}

bool Shield::Damaged() const {
return Percent() < 1;
return operational.Value() < 1;
}


Expand Down

0 comments on commit c23ccbd

Please sign in to comment.