r2mods/ilspy_dump/ror2_csproj/RoR2/DisableIfNoExpansion.cs

35 lines
662 B
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using RoR2.EntitlementManagement;
using RoR2.ExpansionManagement;
using UnityEngine;
namespace RoR2;
public class DisableIfNoExpansion : MonoBehaviour
{
[SerializeField]
private ExpansionDef expansionDef;
private void Awake()
{
EntitlementManager.onEntitlementsUpdated += Reset;
Reset();
}
private void OnDestroy()
{
EntitlementManager.onEntitlementsUpdated -= Reset;
}
private void Reset()
{
if ((bool)expansionDef && !EntitlementManager.localUserEntitlementTracker.AnyUserHasEntitlement(expansionDef.requiredEntitlement))
{
base.gameObject.SetActive(value: false);
}
else
{
base.gameObject.SetActive(value: true);
}
}
}