yyl
2025-11-20 9e89e605d5429babb4b33df2e47ea86dff9d2ba7
Main/System/Redpoint/RedpointCenter.cs
@@ -22,6 +22,7 @@
        {
            redpoint.state = RedPointState.None;
        }
        RemoverOtherParent();
    }
    public void Register(Redpoint _redpoint)
@@ -50,18 +51,66 @@
        }
    }
    //额外添加父红点用,会屏蔽重复添加,外层可直接重复调用
    public void AddParent(int _parentId, int _childId)
    {
        Redpoint child = null;
        if (!redpoints.TryGetValue(_childId, out child))
        {
            Debug.LogErrorFormat("添加父子关系失败,子节点不存在:id->{0}", _childId);
            return;
        }
        if (child.otherParent > 0)
        {
            //不重复添加
            return;
        }
        child.otherParent = _parentId;
        List<int> children = null;
        if (!parentChildren.TryGetValue(_parentId, out children))
        {
            parentChildren[_parentId] = children = new List<int>();
        }
        if (!children.Contains(_childId))
        {
            children.Add(_childId);
        }
    }
    public void RemoverOtherParent()
    {
        List<int> otherParents = new List<int>();
        foreach (var redpoint in redpoints.Values)
        {
            if (redpoint.otherParent > 0)
            {
                otherParents.Add(redpoint.otherParent);
            }
            redpoint.otherParent = 0;
        }
        foreach (var parentId in otherParents)
        {
            parentChildren.Remove(parentId);
        }
    }
    public void Report(Redpoint _redpoint)
    {
        var parentId = _redpoint.parent;
        if (redpointValueChangeEvent != null)
        {
            redpointValueChangeEvent(_redpoint.id);
        }
        if (parentId > 0)
        if (_redpoint.parent > 0)
        {
            TestParentValue(_redpoint.parent);
        }
        if (_redpoint.otherParent > 0)
        {
            TestParentValue(_redpoint.otherParent);
        }
    }
@@ -127,4 +176,14 @@
        }
    }
    public Redpoint GetRedpoint(int _id)
    {
        Redpoint redpoint = null;
        if (this.redpoints.TryGetValue(_id, out redpoint))
        {
            return redpoint;
        }
        return null;
    }
}