Files
TheVVaS-Assets/RPGCore/Runtime/Core/ObjectModule.cs
T
2026-04-25 23:37:10 +02:00

39 lines
1.1 KiB
C#

using System;
using RPGCore.Core.Objects;
using UnityEngine;
namespace RPGCore.Core
{
/// <summary>
/// Extend this abstract class to create new module for &lt;<typeparamref name="T"/>&gt; object type.<br/>
/// </summary>
/// <typeparam name="T">Type of object that this module will be attached to. Can be <see cref="BaseObject"/> or any of its children.</typeparam>
[Serializable]
public abstract class ObjectModule<T> : ObjectModule where T : BaseObject
{
public new T parent => (T)base.parent;
}
/// <summary>
/// <b>DO NOT EXTEND THIS</b>, use <see cref="ObjectModule{T}"/> instead!
/// </summary>
[Serializable]
public abstract class ObjectModule : MonoBehaviour
{
private BaseObject _parent;
internal BaseObject parent
{
get
{
if (!_parent) _parent = GetComponent<BaseObject>();
return _parent;
}
set => _parent = value;
}
private protected ObjectModule()
{
}
}
}