Aetheria/Assets/Scripts/UI/Properties Panel/CurveField.cs
Meta Vens 5e0ec92509 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>
2026-10-14 02:16:04 +02:00

60 lines
1.9 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UI.Extensions;
using static CultMath.math;
public class CurveField : MonoBehaviour
{
public int Segments = 16;
public int SigDigs = 3;
public TextMeshProUGUI Title;
public TextMeshProUGUI MinLabel;
public TextMeshProUGUI MidLabel;
public TextMeshProUGUI MaxLabel;
public UILineRenderer Line;
public Image CurrentX;
public Image CurrentY;
private Func<float, float> _y;
public void SetCurrent(float x)
{
CurrentX.gameObject.SetActive(true);
CurrentY.gameObject.SetActive(true);
var xrect = CurrentX.GetComponent<RectTransform>();
var yrect = CurrentY.GetComponent<RectTransform>();
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);
}
// 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)
{
_y = y;
CurrentX.gameObject.SetActive(false);
CurrentY.gameObject.SetActive(false);
Title.text = label;
var points = new List<Vector2>();
for (int j = 0; j <= Segments; j++)
{
var x = (float) j / Segments;
points.Add(new Vector2(x, y(x)));
}
Line.Points = points.ToArray();
MinLabel.text = xFunc(0);
MaxLabel.text = xFunc(1);
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);
}
}