2025-06-03 02:42:28 -04:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Ichni.RhythmGame.Beatmap;
|
|
|
|
|
|
using Sirenix.OdinInspector;
|
2025-07-21 05:42:20 -04:00
|
|
|
|
using UnityEngine;
|
2025-06-03 02:42:28 -04:00
|
|
|
|
|
|
|
|
|
|
namespace Ichni.RhythmGame
|
|
|
|
|
|
{
|
2025-07-26 04:20:25 -04:00
|
|
|
|
public abstract partial class GameElement : SerializedMonoBehaviour, IBaseElement, IComparable<GameElement>
|
2025-06-03 02:42:28 -04:00
|
|
|
|
{
|
2026-03-14 03:13:10 -04:00
|
|
|
|
#region [属性和标记] Essential & Tracking Info
|
2025-06-03 02:42:28 -04:00
|
|
|
|
//物体名
|
|
|
|
|
|
public string elementName;
|
|
|
|
|
|
|
|
|
|
|
|
//标识 GUID
|
|
|
|
|
|
public Guid elementGuid;
|
|
|
|
|
|
|
|
|
|
|
|
//标签
|
|
|
|
|
|
public List<string> tags;
|
|
|
|
|
|
|
2026-03-14 03:13:10 -04:00
|
|
|
|
//物理层级优先级
|
|
|
|
|
|
public virtual int HierarchyPriority => 0;
|
|
|
|
|
|
|
|
|
|
|
|
//存档类
|
|
|
|
|
|
public BaseElement_BM matchedBM { get; set; }
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region [层级从属结构] Hierarchy & Children
|
2025-06-03 02:42:28 -04:00
|
|
|
|
//父游戏物体
|
|
|
|
|
|
public GameElement parentElement;
|
|
|
|
|
|
|
|
|
|
|
|
//子物体列表
|
|
|
|
|
|
public List<GameElement> childElementList = new List<GameElement>();
|
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 [附着子模块集] Components List
|
2025-06-03 02:42:28 -04:00
|
|
|
|
//次级模块
|
|
|
|
|
|
public List<SubmoduleBase> submoduleList = new List<SubmoduleBase>();
|
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 [生命周期与构造] Initialization
|
2025-06-03 02:42:28 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 首次初始化
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="name">物体名</param>
|
|
|
|
|
|
public virtual void Initialize(string name, Guid elementGuid, List<string> tags,
|
|
|
|
|
|
bool isFirstGenerated, GameElement parentElement)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.elementName = name;
|
|
|
|
|
|
this.elementGuid = elementGuid;
|
|
|
|
|
|
this.tags = tags;
|
2026-03-14 03:13:10 -04:00
|
|
|
|
GameManager.Instance.beatmapContainer.gameElementList.Add(this);
|
2025-06-03 02:42:28 -04:00
|
|
|
|
submoduleList = new List<SubmoduleBase>();
|
|
|
|
|
|
|
|
|
|
|
|
if (isFirstGenerated)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetDefaultSubmodules();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SetParent(parentElement);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置次级模块
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void SetDefaultSubmodules()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2026-03-14 03:13:10 -04:00
|
|
|
|
#endregion
|
2025-07-21 05:42:20 -04:00
|
|
|
|
|
2026-03-14 03:13:10 -04:00
|
|
|
|
#region [生命周期:激活阶段] Lifecycle Events Extensions
|
2025-06-03 02:42:28 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 在所有物体生成完毕后,执行的初始化方法
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void AfterInitialize()
|
|
|
|
|
|
{
|
2025-07-21 05:42:20 -04:00
|
|
|
|
matchedBM?.AfterExecute();
|
|
|
|
|
|
|
|
|
|
|
|
if (this is IHaveTransformSubmodule transformSource)
|
|
|
|
|
|
{
|
|
|
|
|
|
transformSource.transformSubmodule.CheckAndRemoveObservers();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(this is IHaveColorSubmodule colorSource)
|
|
|
|
|
|
{
|
|
|
|
|
|
colorSource.colorSubmodule.CheckAndRemoveObservers();
|
|
|
|
|
|
}
|
2025-06-03 02:42:28 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-11 14:04:06 -04:00
|
|
|
|
public virtual void BeforeStart()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this is IHaveTransformSubmodule transformSource)
|
|
|
|
|
|
{
|
|
|
|
|
|
transformSource.UpdateTransform(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this is IHaveColorSubmodule colorSource)
|
|
|
|
|
|
{
|
2025-08-22 14:54:40 -04:00
|
|
|
|
colorSource.UpdateColor(false);
|
2025-08-11 14:04:06 -04:00
|
|
|
|
}
|
2025-10-02 23:49:18 -04:00
|
|
|
|
|
|
|
|
|
|
Refresh();
|
2025-08-11 14:04:06 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void WhenStart()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2026-03-14 03:13:10 -04:00
|
|
|
|
#endregion
|
2025-08-11 14:04:06 -04:00
|
|
|
|
|
2026-03-14 03:13:10 -04:00
|
|
|
|
#region [工具方法] Global Methods
|
2025-06-03 02:42:28 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 设置父物体
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="parentElement">父物体</param>
|
|
|
|
|
|
public void SetParent(GameElement parentElement)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (parentElement != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
parentElement.childElementList.Add(this);
|
|
|
|
|
|
this.parentElement = parentElement;
|
|
|
|
|
|
transform.SetParent(parentElement.transform);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int CompareTo(GameElement other)
|
|
|
|
|
|
{
|
|
|
|
|
|
return HierarchyPriority.CompareTo(other.HierarchyPriority);
|
|
|
|
|
|
}
|
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 [额外交互及存档重写预留] Editor Interaction & Interfaces Overrides
|
2025-06-03 02:42:28 -04:00
|
|
|
|
public abstract partial class GameElement //存档,删除,复制,粘贴
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void Refresh()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 当物体被删除时执行的方法
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void OnDelete()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-03-14 03:13:10 -04:00
|
|
|
|
#endregion
|
2025-06-03 02:42:28 -04:00
|
|
|
|
|
|
|
|
|
|
}
|