init
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using RPGCore.Core.Objects;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RPGCore.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Extend this abstract class to create new module for <<typeparamref name="T"/>> 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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user