[fix] Fixed an issue that nearness_coe was ignored.

This commit is contained in:
falsycat 2019-10-16 00:00:00 +00:00
parent 2ad131534f
commit d3026b1fb7
3 changed files with 7 additions and 3 deletions

View File

@ -27,7 +27,8 @@ class CircleElement : AbstractShapeElement {
if (d <= 1) { if (d <= 1) {
return DamageCalculationResult(damage, 0); return DamageCalculationResult(damage, 0);
} }
return DamageCalculationResult(0, 1 - (d-1).clamp(0, 1)); const nearness = 1 - (d-1).clamp(0, 1);
return DamageCalculationResult(0, nearness * nearness_coe);
} }
} }

View File

@ -43,7 +43,8 @@ class SquareElement : AbstractShapeElement {
if (min_distance == 0) { if (min_distance == 0) {
return DamageCalculationResult(damage, 0); return DamageCalculationResult(damage, 0);
} }
return DamageCalculationResult(0, 1-(min_distance-1).clamp(0f, 1f)); const nearness = 1 - (min_distance-1).clamp(0f, 1f);
return DamageCalculationResult(0, nearness * nearness_coe);
} }
} }

View File

@ -50,7 +50,9 @@ class TriangleElement : AbstractShapeElement {
if (min_distance == 0) { if (min_distance == 0) {
return DamageCalculationResult(damage, 0); return DamageCalculationResult(damage, 0);
} }
return DamageCalculationResult(0, 1-(min_distance-1).clamp(0f, 1f));
const nearness = 1 - (min_distance-1).clamp(0f, 1f);
return DamageCalculationResult(0, nearness * nearness_coe);
} }
} }