diff --git a/EXILED/Exiled.CustomItems/API/Features/CustomItem{T}.cs b/EXILED/Exiled.CustomItems/API/Features/CustomItem{T}.cs new file mode 100644 index 000000000..7d157b9a8 --- /dev/null +++ b/EXILED/Exiled.CustomItems/API/Features/CustomItem{T}.cs @@ -0,0 +1,180 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- +#pragma warning disable SA1402 // File may only contain a single type +namespace Exiled.CustomItems.API.Features +{ + using YamlDotNet.Serialization; + + /// + /// A generic base class for that provides a typed singleton . + /// + /// The concrete type. + public abstract class CustomItem : CustomItem + where T : CustomItem + { + /// + /// Gets the singleton instance of this . + /// + [YamlIgnore] + public static T? Instance { get; private set; } + + /// + public override void Init() + { + base.Init(); + Instance = this as T; + } + + /// + public override void Destroy() + { + Instance = null; + base.Destroy(); + } + } + + /// + /// A generic base class for that provides a typed singleton . + /// + /// The concrete type. + public abstract class CustomWeapon : CustomWeapon + where T : CustomWeapon + { + /// + /// Gets the singleton instance of this . + /// + [YamlIgnore] + public static T? Instance { get; private set; } + + /// + public override void Init() + { + base.Init(); + Instance = this as T; + } + + /// + public override void Destroy() + { + Instance = null; + base.Destroy(); + } + } + + /// + /// A generic base class for that provides a typed singleton . + /// + /// The concrete type. + public abstract class CustomKeycard : CustomKeycard + where T : CustomKeycard + { + /// + /// Gets the singleton instance of this . + /// + [YamlIgnore] + public static T? Instance { get; private set; } + + /// + public override void Init() + { + base.Init(); + Instance = this as T; + } + + /// + public override void Destroy() + { + Instance = null; + base.Destroy(); + } + } + + /// + /// A generic base class for that provides a typed singleton . + /// + /// The concrete type. + public abstract class CustomGrenade : CustomGrenade + where T : CustomGrenade + { + /// + /// Gets the singleton instance of this . + /// + [YamlIgnore] + public static T? Instance { get; private set; } + + /// + public override void Init() + { + base.Init(); + Instance = this as T; + } + + /// + public override void Destroy() + { + Instance = null; + base.Destroy(); + } + } + + /// + /// A generic base class for that provides a typed singleton . + /// + /// The concrete type. + public abstract class CustomArmor : CustomArmor + where T : CustomArmor + { + /// + /// Gets the singleton instance of this . + /// + [YamlIgnore] + public static T? Instance { get; private set; } + + /// + public override void Init() + { + base.Init(); + Instance = this as T; + } + + /// + public override void Destroy() + { + Instance = null; + base.Destroy(); + } + } + + /// + /// A generic base class for that provides a typed singleton . + /// + /// The concrete type. + public abstract class CustomGoggles : CustomGoggles + where T : CustomGoggles + { + /// + /// Gets the singleton instance of this . + /// + [YamlIgnore] + public static T? Instance { get; private set; } + + /// + public override void Init() + { + base.Init(); + Instance = this as T; + } + + /// + public override void Destroy() + { + Instance = null; + base.Destroy(); + } + } +} +#pragma warning restore SA1402 // File may only contain a single type \ No newline at end of file diff --git a/EXILED/Exiled.CustomRoles/API/Features/CustomRole{T}.cs b/EXILED/Exiled.CustomRoles/API/Features/CustomRole{T}.cs new file mode 100644 index 000000000..c91ffad08 --- /dev/null +++ b/EXILED/Exiled.CustomRoles/API/Features/CustomRole{T}.cs @@ -0,0 +1,39 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) ExMod Team. All rights reserved. +// Licensed under the CC BY-SA 3.0 license. +// +// ----------------------------------------------------------------------- + +namespace Exiled.CustomRoles.API.Features +{ + using YamlDotNet.Serialization; + + /// + /// A generic base class for that provides a typed singleton . + /// + /// The concrete type. + public abstract class CustomRole : CustomRole + where T : CustomRole + { + /// + /// Gets the singleton instance of this . + /// + [YamlIgnore] + public static T? Instance { get; private set; } + + /// + public override void Init() + { + base.Init(); + Instance = this as T; + } + + /// + public override void Destroy() + { + Instance = null; + base.Destroy(); + } + } +} \ No newline at end of file