fix: Fix ongoing event cycling logic
This commit is contained in:
@@ -22,6 +22,8 @@ namespace Cryville.EEW.Unity.Map {
|
||||
readonly List<ReportViewModel> _displayingReports = new();
|
||||
readonly List<int> _displayingOrder = new();
|
||||
|
||||
public int Count => _displayingReports.Count;
|
||||
|
||||
[SerializeField] MapElementManager m_subManager;
|
||||
|
||||
public RectangleF? AABB {
|
||||
@@ -37,8 +39,6 @@ namespace Cryville.EEW.Unity.Map {
|
||||
return _displayingElements[index].AABB;
|
||||
}
|
||||
|
||||
public void AddOngoing(ReportViewModel e) => Add(e);
|
||||
public void RemoveOngoing(ReportViewModel e) => Remove(e);
|
||||
public void SetSelected(ReportViewModel e) {
|
||||
if (_selected is not null)
|
||||
Remove(_selected);
|
||||
@@ -46,16 +46,17 @@ namespace Cryville.EEW.Unity.Map {
|
||||
_selected = null;
|
||||
return;
|
||||
}
|
||||
Add(e);
|
||||
if (!Add(e))
|
||||
return;
|
||||
_selected = e;
|
||||
}
|
||||
public void SetCurrent(ReportViewModel e) {
|
||||
_current = e;
|
||||
}
|
||||
|
||||
void Add(ReportViewModel e) {
|
||||
public bool Add(ReportViewModel e) {
|
||||
var element = Build(e.Model, out _, out int order);
|
||||
if (element == null) return;
|
||||
if (element == null) return false;
|
||||
var pos = element.transform.localPosition;
|
||||
pos.z = OrderToZ(_displayingOrder.Sum());
|
||||
element.transform.localPosition = pos;
|
||||
@@ -64,8 +65,9 @@ namespace Cryville.EEW.Unity.Map {
|
||||
_displayingOrder.Add(order);
|
||||
element.transform.SetParent(transform, false);
|
||||
if (m_subManager != null) m_subManager.Add(e);
|
||||
return true;
|
||||
}
|
||||
void Remove(ReportViewModel e) {
|
||||
public void Remove(ReportViewModel e) {
|
||||
int index = _displayingReports.IndexOf(e);
|
||||
if (index == -1) return;
|
||||
_displayingElements.RemoveAt(index);
|
||||
|
Reference in New Issue
Block a user