[Fix] Refactor project

This commit is contained in:
2026-03-02 12:49:12 +07:00
parent f65976796d
commit f52131f755
44 changed files with 449 additions and 404 deletions
+17 -23
View File
@@ -23,22 +23,15 @@ namespace YachtDice.Dice
private void Awake() => RebuildSet();
private void OnValidate() => RebuildSet();
public void Test()
{
if (!TryGetTopValue(out var top) || !TryGetBottomValue(out var bottom))
return;
Debug.Log($"Top Value: {top}, Bottom Value: {bottom}");
AlignToTopByLocalAngles();
}
private void RebuildSet()
{
_entrySet = new HashSet<Entry>();
if (entries == null) return;
for (int i = 0; i < entries.Count; i++) _entrySet.Add(entries[i]);
foreach (var t in entries)
_entrySet.Add(t);
}
public bool TryGetTopValue(out int value) => TryGetExtremeValue(isTop: true, out value);
@@ -65,8 +58,8 @@ namespace YachtDice.Dice
if (_entrySet == null || _entrySet.Count == 0)
return false;
bool found = false;
float bestY = isTop ? float.NegativeInfinity : float.PositiveInfinity;
var found = false;
var bestY = isTop ? float.NegativeInfinity : float.PositiveInfinity;
int best = default;
foreach (var e in _entrySet)
@@ -94,22 +87,23 @@ namespace YachtDice.Dice
if (_entrySet == null || _entrySet.Count == 0)
throw new InvalidOperationException("Dice: коллекция пуста.");
bool found = false;
float bestY = isTop ? float.NegativeInfinity : float.PositiveInfinity;
var found = false;
var bestY = isTop ? float.NegativeInfinity : float.PositiveInfinity;
Entry best = default;
foreach (var e in _entrySet)
{
var p = e.Point;
if (!p) continue;
float y = p.position.y;
if (!found || (isTop ? y > bestY : y < bestY))
{
found = true;
bestY = y;
best = e;
}
var y = p.position.y;
if (found && (isTop ? !(y > bestY) : !(y < bestY))) continue;
found = true;
bestY = y;
best = e;
}
if (!found)