84 lines
2.2 KiB
C#
84 lines
2.2 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
|
|
{
|
|
public GameElement attachedGameElement;
|
|
|
|
public BaseElement_BM matchedBM { get; set; }
|
|
|
|
/// <summary>
|
|
/// 在生成时检测是否已经有重复的submodule
|
|
/// </summary>
|
|
public bool HaveSameSubmodule { get; set; }
|
|
|
|
public SubmoduleBase(GameElement attachedGameElement)
|
|
{
|
|
this.attachedGameElement = attachedGameElement;
|
|
|
|
HaveSameSubmodule = attachedGameElement.submoduleList.Any(x => x.GetType() == this.GetType());
|
|
|
|
if (HaveSameSubmodule)
|
|
{
|
|
Debug.LogAssertion($"存在重复的Submodule: {GetType()},此操作无效");
|
|
return;
|
|
}
|
|
|
|
this.attachedGameElement.submoduleList.Add(this);
|
|
}
|
|
|
|
public abstract void SaveBM();
|
|
|
|
public virtual void OnDelete()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void Delete()
|
|
{
|
|
OnDelete();
|
|
attachedGameElement.submoduleList.Remove(this);
|
|
}
|
|
|
|
public virtual void Refresh()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void CheckAndRemoveObservers()
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
namespace Beatmap
|
|
{
|
|
public abstract class Submodule_BM : BaseElement_BM
|
|
{
|
|
[System.NonSerialized] protected GameElement attachedElement; //存档类对应的游戏物体
|
|
|
|
public Submodule_BM()
|
|
{
|
|
|
|
}
|
|
|
|
public Submodule_BM(GameElement attachedElement)
|
|
{
|
|
this.attachedElement = attachedElement;
|
|
attachedElementGuid = attachedElement.elementGuid;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 复制物体
|
|
/// </summary>
|
|
/// <param name="attached">(对于物体)父物体,(对于次级模块)或挂载物体</param>
|
|
public abstract void DuplicateBM(GameElement attached);
|
|
}
|
|
}
|
|
} |