Damage falloff: effective range and damage at max range replace DamageCurve
WeaponData.RangeFactor is the one function of damage over range: 0 outside [MinRange, Range], 1 up to EffectiveRange, one lerp to DamageAtMaxRange. DamageCurve (key 7, retired) and its formula parameters, CurveField's BezierCurve path, and every fixture curve line are deleted. Fire freezes damage times the factor at BurstReach; the AI's DPS reads, Combat's optimum sampling and the properties panel chart read the same function. AetherDb gains range-falloff (command only; the catalog is re-saved in a later commit). Cut and wiring land in one commit rather than two; this commit has not been built yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b836af4850
commit
5e0ec92509
33 changed files with 282 additions and 127 deletions
|
|
@ -20,8 +20,7 @@ public class CurveField : MonoBehaviour
|
|||
public Image CurrentX;
|
||||
public Image CurrentY;
|
||||
|
||||
private BezierCurve _curve;
|
||||
//private Func<float, string> _xFunc;
|
||||
private Func<float, float> _y;
|
||||
|
||||
public void SetCurrent(float x)
|
||||
{
|
||||
|
|
@ -29,46 +28,33 @@ public class CurveField : MonoBehaviour
|
|||
CurrentY.gameObject.SetActive(true);
|
||||
var xrect = CurrentX.GetComponent<RectTransform>();
|
||||
var yrect = CurrentY.GetComponent<RectTransform>();
|
||||
var y = _curve.Evaluate(x);
|
||||
var y = _y(x);
|
||||
xrect.anchorMin = new Vector2(x, 0);
|
||||
xrect.anchorMax = new Vector2(x, y);
|
||||
yrect.anchorMin = new Vector2(x, y);
|
||||
yrect.anchorMax = new Vector2(x, y);
|
||||
}
|
||||
|
||||
public void Show(string label, BezierCurve curve, Func<float, string> xFunc, bool showMax = false)
|
||||
// Segments + 1 uniform samples of y over [0, 1], labelled by xFunc; the middle label sits at midX.
|
||||
public void Show(string label, Func<float, float> y, Func<float, string> xFunc, float midX = .5f)
|
||||
{
|
||||
_curve = curve;
|
||||
//_xFunc = xFunc;
|
||||
_y = y;
|
||||
CurrentX.gameObject.SetActive(false);
|
||||
CurrentY.gameObject.SetActive(false);
|
||||
Title.text = label;
|
||||
var points = new List<Vector2>();
|
||||
var keys = curve.Keys.Select(v => new Vector2(v.x, v.y));
|
||||
if (curve.Keys[0].x > .01f) keys = keys.Prepend(new Vector2(0, curve.Keys[0].y));
|
||||
if (curve.Keys[curve.Keys.Length-1].x < .99f) keys = keys.Append(new Vector2(1, curve.Keys[curve.Keys.Length-1].y));
|
||||
var keysArray = keys.ToArray();
|
||||
for (int i = 0; i < keysArray.Length - 1; i++)
|
||||
for (int j = 0; j <= Segments; j++)
|
||||
{
|
||||
for (int j = 0; j < Segments; j++)
|
||||
{
|
||||
var x = lerp(keysArray[i].x, keysArray[i + 1].x, (float) j / Segments);
|
||||
points.Add(new Vector2(x, curve.Evaluate(x)));
|
||||
}
|
||||
var x = (float) j / Segments;
|
||||
points.Add(new Vector2(x, y(x)));
|
||||
}
|
||||
points.Add(new Vector2(1, curve.Evaluate(1)));
|
||||
|
||||
Line.Points = points.ToArray();
|
||||
MinLabel.text = xFunc(0);
|
||||
MaxLabel.text = xFunc(1);
|
||||
if (showMax)
|
||||
{
|
||||
var midX = curve.Maximum;
|
||||
MidLabel.text = xFunc(midX);
|
||||
var rect = MidLabel.GetComponent<RectTransform>();
|
||||
rect.anchorMin = new Vector2(midX, rect.anchorMin.y);
|
||||
rect.anchorMax = new Vector2(midX, rect.anchorMax.y);
|
||||
}
|
||||
else MidLabel.text = xFunc(.5f);
|
||||
MidLabel.text = xFunc(midX);
|
||||
var rect = MidLabel.GetComponent<RectTransform>();
|
||||
rect.anchorMin = new Vector2(midX, rect.anchorMin.y);
|
||||
rect.anchorMax = new Vector2(midX, rect.anchorMax.y);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -423,7 +423,13 @@ public class PropertiesPanel : MonoBehaviour
|
|||
if (gearData.Behaviors.FirstOrDefault(b => b is WeaponData) is WeaponData weapon)
|
||||
{
|
||||
var range = AddCurveField();
|
||||
range.Show("Damage Range", weapon.DamageCurve, t => ActionGameManager.PlayerSettings.Format(lerp(statValueFunction(weapon.MinRange), statValueFunction(weapon.Range), t)));
|
||||
var min = statValueFunction(weapon.MinRange);
|
||||
var effective = statValueFunction(weapon.EffectiveRange);
|
||||
var max = statValueFunction(weapon.Range);
|
||||
range.Show("Damage Range",
|
||||
t => WeaponData.RangeFactor(min, effective, max, weapon.DamageAtMaxRange, lerp(min, max, t)),
|
||||
t => ActionGameManager.PlayerSettings.Format(lerp(min, max, t)),
|
||||
effective < max ? saturate(unlerp(min, max, effective)) : .5f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue