61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Ichni.RhythmGame.Beatmap;
|
|
using UnityEngine;
|
|
|
|
namespace Ichni.RhythmGame
|
|
{
|
|
public abstract class SubmoduleBase : IBaseElement
|
|
{
|
|
#region [基础属性] Essential Properties
|
|
public GameElement attachedGameElement;
|
|
public BaseElement_BM matchedBM { get; set; }
|
|
|
|
/// <summary>
|
|
/// 在生成时检测是否已经有重复的submodule
|
|
/// </summary>
|
|
public bool HaveSameSubmodule { get; set; }
|
|
#endregion
|
|
|
|
#region [生命周期与初始化] Lifecycle & Initialization
|
|
public SubmoduleBase(GameElement attachedGameElement)
|
|
{
|
|
this.attachedGameElement = attachedGameElement;
|
|
|
|
HaveSameSubmodule = attachedGameElement.submoduleList.Any(x => x.GetType() == this.GetType());
|
|
|
|
if (HaveSameSubmodule)
|
|
{
|
|
//Debug.LogAssertion($"物体 '{attachedGameElement.name}' 已经有一个类型为 '{this.GetType().Name}' 的 Submodule 了,新的 Submodule 将不会被添加。");
|
|
return;
|
|
}
|
|
|
|
this.attachedGameElement.submoduleList.Add(this);
|
|
}
|
|
|
|
public virtual void OnDelete()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void Delete()
|
|
{
|
|
OnDelete();
|
|
attachedGameElement.submoduleList.Remove(this);
|
|
}
|
|
|
|
public virtual void Refresh()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void CheckAndRemoveObservers()
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
} |