Files
ichni_Official/Assets/Scripts/Game/Components/SubmoduleBase.cs

61 lines
1.6 KiB
C#
Raw Normal View History

2025-06-03 02:42:28 -04:00
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
{
2026-03-14 03:13:10 -04:00
#region [] Essential Properties
2025-06-03 02:42:28 -04:00
public GameElement attachedGameElement;
public BaseElement_BM matchedBM { get; set; }
/// <summary>
/// 在生成时检测是否已经有重复的submodule
/// </summary>
public bool HaveSameSubmodule { get; set; }
2026-03-14 03:13:10 -04:00
#endregion
2025-06-03 02:42:28 -04:00
2026-03-14 03:13:10 -04:00
#region [] Lifecycle & Initialization
2025-06-03 02:42:28 -04:00
public SubmoduleBase(GameElement attachedGameElement)
{
this.attachedGameElement = attachedGameElement;
HaveSameSubmodule = attachedGameElement.submoduleList.Any(x => x.GetType() == this.GetType());
if (HaveSameSubmodule)
{
2026-03-31 07:51:40 -04:00
Debug.LogAssertion($"物体 '{attachedGameElement.name}' 已经有一个类型为 '{this.GetType().Name}' 的 Submodule 了,新的 Submodule 将不会被添加。");
2025-06-03 02:42:28 -04:00
return;
}
this.attachedGameElement.submoduleList.Add(this);
}
public virtual void OnDelete()
{
}
public virtual void Delete()
{
OnDelete();
attachedGameElement.submoduleList.Remove(this);
}
public virtual void Refresh()
{
}
2025-07-21 05:42:20 -04:00
public virtual void CheckAndRemoveObservers()
{
}
2026-03-14 03:13:10 -04:00
#endregion
2025-06-03 02:42:28 -04:00
}
}