Firstborn/Assets/ModTool/ModTool.Shared/CodeSettings.cs
Schaken-Mods 7502018d20 Adding Mod Support
There is an asset in the store I grabbed. the coding is WAY above my head, I got about half of it and integrated and adapted what I can to it. im going as far as I can with it and ill come back in a few month when I understand t better.
2023-05-13 22:01:48 -05:00

82 lines
2.5 KiB
C#

using System.Collections.Generic;
using UnityEngine;
using ModTool.Shared.Verification;
namespace ModTool.Shared
{
/// <summary>
/// Stores settings related to code verification for Mods.
/// </summary>
public class CodeSettings : Singleton<CodeSettings>
{
/// <summary>
/// Restrictions related to inheritance of Types inside Mod Assemblies.
/// </summary>
public static List<InheritanceRestriction> inheritanceRestrictions
{
get
{
return instance._inheritanceRestrictions;
}
}
/// <summary>
/// Restrictions related to the use of fields, properties and methods from other types.
/// </summary>
public static List<MemberRestriction> memberRestrictions
{
get
{
return instance._memberRestrictions;
}
}
/// <summary>
/// Restrictions related to the use of Types for fields and properties.
/// </summary>
public static List<TypeRestriction> typeRestrictions
{
get
{
return instance._typeRestrictions;
}
}
/// <summary>
/// Restrictions related to the use of entire namespaces.
/// </summary>
public static List<NamespaceRestriction> namespaceRestrictions
{
get
{
return instance._namespaceRestrictions;
}
}
[SerializeField]
private List<InheritanceRestriction> _inheritanceRestrictions = new List<InheritanceRestriction>();
[SerializeField]
private List<MemberRestriction> _memberRestrictions = new List<MemberRestriction>();
[SerializeField]
private List<TypeRestriction> _typeRestrictions = new List<TypeRestriction>();
[SerializeField]
private List<NamespaceRestriction> _namespaceRestrictions = new List<NamespaceRestriction>();
protected CodeSettings()
{
namespaceRestrictions.Add(new NamespaceRestriction("System.Reflection", true, null, "Reflection is not allowed.", RestrictionMode.Prohibited));
namespaceRestrictions.Add(new NamespaceRestriction("System.IO", true, null, "IO is not allowed.", RestrictionMode.Prohibited));
}
[RuntimeInitializeOnLoadMethod]
private static void Initialize()
{
GetInstance();
}
}
}