Files
SVSimServer/SVSim.BattleEngine/Engine/Wizard/ParameterOverwriterBase.cs
gamer147 0d9d8acae0 feat(battle-engine): M1 auto-copy closure (782 battle-logic files)
Compile-driven bulk-copy loop (tools/engine-port/m1_copy_loop.py) pulled the precise reference closure of the battle-core roots, stopping at the classify god-object/View-VFX-UI boundary. 782 files; no re-explosion (M0 had estimated ~order 1000). Residual frontier = 52 shim-classified + 80 external (Unity/BCL) types to author next.
2026-06-05 16:57:20 -04:00

77 lines
1.3 KiB
C#

using System;
using UnityEngine;
namespace Wizard;
public abstract class ParameterOverwriterBase : MonoBehaviour
{
private enum State
{
None,
RequestOverwrite,
Overwrote
}
private State _state;
protected abstract GameObject TargetObject { get; }
private void Awake()
{
SaveOriginalParameters();
_state = State.None;
}
private void OnEnable()
{
_state = State.RequestOverwrite;
}
private void OnDisable()
{
if (_state == State.Overwrote)
{
UndoParameters();
}
_state = State.None;
}
private void Update()
{
if (_state == State.RequestOverwrite && NGUITools.GetActive(TargetObject))
{
OverwriteParameters();
_state = State.Overwrote;
}
}
protected void RequestOverwrite()
{
if (base.enabled)
{
_state = State.RequestOverwrite;
}
}
protected bool ColorTryParse(string strColorCodeId, out Color color)
{
color = Color.red;
if (string.IsNullOrEmpty(strColorCodeId))
{
return false;
}
if (Enum.TryParse<eColorCodeId>(strColorCodeId, out var result))
{
color = ColorCode.Get(result);
return true;
}
return false;
}
protected abstract void SaveOriginalParameters();
protected abstract void UndoParameters();
protected abstract void OverwriteParameters();
}