using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.VisualScripting;
using UnityEngine;

[CreateAssetMenu(fileName = "InfraredSpotSettings", menuName = "ScriptableObjects/InfraredSpotSettings", order = 1)]
public class InfraredSpotSettings : ScriptableObject
{
    public float RadiusThreshold = 100f;      // 初始阈值参考价值不大，每个环境都不一样？

    List<float> data;

    public InfraredSpotSettings()
    {
        data = new List<float>(50);
        data.AddRange(Enumerable.Repeat(RadiusThreshold, 3));
    }
    public void UpdateThreshold(float data)
    {
        var sum = RadiusThreshold * this.data.Count() + data;
        if (this.data.Count >= 100)
        {
            sum -= this.data[0];
            this.data.RemoveAt(0);
        }
        this.data.Add(data);

        RadiusThreshold = sum / this.data.Count();
    }
}