fix(huoshan): 收紧辉光管绘制区域避免轻微溢出

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-25 23:28:32 +08:00
co-authored by Cursor
parent c16e9d06ee
commit d5c0842fd9
@@ -15,6 +15,10 @@ namespace AibisDream.MiniGame.HuoShan
[Tooltip("效果区域参考(取其 SpriteRenderer bounds),不填则用自身")] [Tooltip("效果区域参考(取其 SpriteRenderer bounds),不填则用自身")]
[SerializeField] private SpriteRenderer areaReference; [SerializeField] private SpriteRenderer areaReference;
[Tooltip("相对参考区域向内收缩比例,避免辉光贴满边框轻微溢出")]
[Range(0f, 0.2f)]
[SerializeField] private float areaInset = 0.04f;
[Header("像素网格")] [Header("像素网格")]
[Tooltip("横向像素格数(纵向按区域纵横比自动推算)")] [Tooltip("横向像素格数(纵向按区域纵横比自动推算)")]
[SerializeField] private int pixelColumns = 72; [SerializeField] private int pixelColumns = 72;
@@ -201,7 +205,10 @@ namespace AibisDream.MiniGame.HuoShan
if (reference != null) if (reference != null)
{ {
var b = reference.bounds; var b = reference.bounds;
_areaHalfSize = new Vector2(Mathf.Max(0.01f, b.extents.x), Mathf.Max(0.01f, b.extents.y)); float inset = 1f - Mathf.Clamp01(areaInset);
_areaHalfSize = new Vector2(
Mathf.Max(0.01f, b.extents.x * inset),
Mathf.Max(0.01f, b.extents.y * inset));
} }
} }
@@ -340,7 +347,8 @@ namespace AibisDream.MiniGame.HuoShan
float x = Random.value < sparkEdgeBias float x = Random.value < sparkEdgeBias
? Mathf.Max(0f, _fill - Random.value * edgeHotWidth * 0.8f) // 前沿迸溅 ? Mathf.Max(0f, _fill - Random.value * edgeHotWidth * 0.8f) // 前沿迸溅
: Random.value * _fill; : Random.value * _fill;
float y = 0.5f + (Random.value - 0.5f) * 0.75f; // 略收纵向散布,避免火花贴边后冲出管体外框
float y = 0.5f + (Random.value - 0.5f) * 0.62f;
float outward = y >= 0.5f ? 1f : -1f; float outward = y >= 0.5f ? 1f : -1f;
float life = Mathf.Max(0.05f, sparkLife * (0.55f + Random.value * 0.9f)); float life = Mathf.Max(0.05f, sparkLife * (0.55f + Random.value * 0.9f));
@@ -351,7 +359,7 @@ namespace AibisDream.MiniGame.HuoShan
Y = y, Y = y,
// 略偏左:被抑制的方向 // 略偏左:被抑制的方向
VX = (Random.value - 0.5f) * 0.55f - 0.12f, VX = (Random.value - 0.5f) * 0.55f - 0.12f,
VY = outward * (0.3f + Random.value * 1.1f), VY = outward * (0.22f + Random.value * 0.85f),
Life = life, Life = life,
MaxLife = life MaxLife = life
}; };
@@ -432,7 +440,7 @@ namespace AibisDream.MiniGame.HuoShan
// 每行前沿单独抖动:右端像火焰一样翻腾,而不是一条硬边 // 每行前沿单独抖动:右端像火焰一样翻腾,而不是一条硬边
float boilN = Mathf.PerlinNoise(py * 0.35f + _seedY, _time * 6f) - 0.5f; float boilN = Mathf.PerlinNoise(py * 0.35f + _seedY, _time * 6f) - 0.5f;
float fillEdge = _fill + boilN * edgeBoil * 2f; float fillEdge = Mathf.Min(1f, _fill + boilN * edgeBoil * 2f);
for (int px = 0; px < w; px++) for (int px = 0; px < w; px++)
{ {