r2mods/ilspy_dump/ror2_csproj/RoR2.UI/CurrentRunArtifactDisplayDa...

50 lines
1.2 KiB
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using UnityEngine;
namespace RoR2.UI;
public class CurrentRunArtifactDisplayDataDriver : MonoBehaviour
{
public ArtifactDisplayPanelController artifactDisplayPanelController;
private bool dirty;
private void OnEnable()
{
RunArtifactManager.onArtifactEnabledGlobal += OnArtifactEnabledGlobal;
RunArtifactManager.onArtifactEnabledGlobal += OnArtifactDisabledGlobal;
MarkDirty();
}
private void OnDisable()
{
RunArtifactManager.onArtifactEnabledGlobal -= OnArtifactDisabledGlobal;
RunArtifactManager.onArtifactEnabledGlobal -= OnArtifactEnabledGlobal;
}
private void OnArtifactEnabledGlobal(RunArtifactManager runArtifactManager, ArtifactDef artifactDef)
{
MarkDirty();
}
private void OnArtifactDisabledGlobal(RunArtifactManager runArtifactManager, ArtifactDef artifactDef)
{
MarkDirty();
}
private void MarkDirty()
{
if (!dirty)
{
dirty = true;
RoR2Application.onLateUpdate += Refresh;
}
}
private void Refresh()
{
RunArtifactManager.RunEnabledArtifacts enabledArtifacts = RunArtifactManager.enabledArtifactsEnumerable.GetEnumerator();
artifactDisplayPanelController.SetDisplayData(ref enabledArtifacts);
dirty = false;
}
}