Files
Cielonos/Assets/Scripts/MainGame/Base/SubmoduleBase.cs
SoulliesOfficial 39b43680a9 爆更
2026-07-18 03:16:20 -04:00

44 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Sirenix.OdinInspector;
using UnityEngine;
namespace Cielonos.MainGame
{
/// <remarks>
/// Submodule 是普通 C# 逻辑对象,不是 Unity Component。
/// Submodule 可以作为 owner class 的 nested class用类型层级表达归属关系。
/// Submodule 不允许继承 MonoBehaviour / SerializedMonoBehaviour也不应直接挂载到 GameObject。
/// 需要 Unity 生命周期、Inspector 组件绑定或 prefab/scene script 引用的逻辑,应使用顶层 Subcontroller。
/// </remarks>
/// <summary>
/// 子模块通用接口。允许子模块通过继承其他类(如动作播放器)来避免单继承限制。
/// </summary>
public interface ISubmodule<T>
{
T Owner { get; set; }
}
public class SubmoduleBase<T> : ISubmodule<T>
{
[HideInInspector]
protected T owner;
public T Owner => owner;
T ISubmodule<T>.Owner
{
get => Owner;
set => owner = value;
}
public SubmoduleBase(T owner)
{
this.owner = owner;
}
public void SetOwner(T newOwner)
{
this.owner = newOwner;
}
}
}