feat(battle-engine): full Unity/VFX/god-object shims + expanded copy closure (2570 files)
Authored Unity primitive/object-model shim, VFX layer (control-flow-preserving, InstantVfx never invokes its action -- headless suppression), god-object stubs (GameMgr/EffectMgr/UIManager with faithfully-extracted nested enums), View/UI/Touch tree, LitJson+BetterList+Tuple copied, third-party stubs. Discovered Roslyn header-error masking: fixing class-header type errors unmasks body references, so the true copy closure is ~2570 files (was 782 under masking). Errors: masked-25720 -> 268; our shim files compile clean. Remaining: ~50 residual shim/external types, 24 NGUI UI-base overrides, static-type fixes, plus likely 1-2 more unmask waves.
This commit is contained in:
140
SVSim.BattleEngine/Engine/FadeUtility.cs
Normal file
140
SVSim.BattleEngine/Engine/FadeUtility.cs
Normal file
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using Cute;
|
||||
using UnityEngine;
|
||||
|
||||
public class FadeUtility
|
||||
{
|
||||
private static readonly AnimationCurve FADE_ALPHA_ANIM_CURVE = AnimationCurve.Linear(0f, 0f, 1f, 1f);
|
||||
|
||||
private const float FADE_FROM_ALPHA = 1f;
|
||||
|
||||
private const float FADE_TO_ALPHA = 0f;
|
||||
|
||||
private const float FADE_DURATION = 0.3f;
|
||||
|
||||
private const float FADE_DELAY = 0f;
|
||||
|
||||
public static void FadeInGameObject(GameObject obj, Action onFinish = null)
|
||||
{
|
||||
FadeFinish(obj);
|
||||
FadeInObject(obj.AddMissingComponent<UITweenAlpha>(), delegate
|
||||
{
|
||||
onFinish.Call();
|
||||
});
|
||||
}
|
||||
|
||||
public static void FadeOutGameObject(GameObject obj, Action onFinish = null)
|
||||
{
|
||||
FadeFinish(obj);
|
||||
FadeOut(obj, delegate
|
||||
{
|
||||
onFinish.Call();
|
||||
});
|
||||
}
|
||||
|
||||
public static void FadeOutObjectAndNonActive(GameObject obj)
|
||||
{
|
||||
FadeFinish(obj);
|
||||
FadeOut(obj, delegate
|
||||
{
|
||||
obj.SetActive(value: false);
|
||||
});
|
||||
}
|
||||
|
||||
private static void FadeOut(GameObject obj, Action onFinish)
|
||||
{
|
||||
UIButtonColor button = obj.GetComponent<UIButtonColor>();
|
||||
float originalDuration = 0f;
|
||||
if (button != null)
|
||||
{
|
||||
originalDuration = button.duration;
|
||||
button.duration = 0f;
|
||||
}
|
||||
TweenColor component = obj.GetComponent<TweenColor>();
|
||||
if (component != null)
|
||||
{
|
||||
component.enabled = false;
|
||||
}
|
||||
FadeOutObject(obj.AddMissingComponent<UITweenAlpha>(), delegate
|
||||
{
|
||||
if (button != null)
|
||||
{
|
||||
button.duration = originalDuration;
|
||||
}
|
||||
onFinish();
|
||||
});
|
||||
}
|
||||
|
||||
public static void ShowSoon(GameObject obj)
|
||||
{
|
||||
FadeFinish(obj);
|
||||
UISprite component = obj.GetComponent<UISprite>();
|
||||
if (component != null)
|
||||
{
|
||||
component.alpha = 1f;
|
||||
}
|
||||
obj.gameObject.SetActive(value: true);
|
||||
}
|
||||
|
||||
public static void RemoveFadeObject(GameObject obj)
|
||||
{
|
||||
UITweenAlpha component = obj.GetComponent<UITweenAlpha>();
|
||||
if (component != null)
|
||||
{
|
||||
UnityEngine.Object.Destroy(component);
|
||||
}
|
||||
}
|
||||
|
||||
public static void FadeFinish(GameObject obj)
|
||||
{
|
||||
UITweenAlpha component = obj.GetComponent<UITweenAlpha>();
|
||||
if (!(component == null))
|
||||
{
|
||||
component.End();
|
||||
}
|
||||
}
|
||||
|
||||
public static void FadeOutObject(UITweenAlpha tweenAlpha, Action onFinish = null)
|
||||
{
|
||||
if (!(tweenAlpha == null))
|
||||
{
|
||||
if (tweenAlpha._curve == null)
|
||||
{
|
||||
tweenAlpha._curve = FADE_ALPHA_ANIM_CURVE;
|
||||
tweenAlpha._curve.postWrapMode = WrapMode.Once;
|
||||
tweenAlpha._curve.preWrapMode = WrapMode.Once;
|
||||
}
|
||||
tweenAlpha._from = 1f;
|
||||
tweenAlpha._to = 0f;
|
||||
tweenAlpha._endTime = 0.3f;
|
||||
tweenAlpha._delayTime = 0f;
|
||||
tweenAlpha._finishCallBack = delegate
|
||||
{
|
||||
onFinish.Call();
|
||||
};
|
||||
tweenAlpha.PlayForward(isReset: true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void FadeInObject(UITweenAlpha tweenAlpha, Action onFinish = null)
|
||||
{
|
||||
if (!(tweenAlpha == null))
|
||||
{
|
||||
if (tweenAlpha._curve == null)
|
||||
{
|
||||
tweenAlpha._curve = FADE_ALPHA_ANIM_CURVE;
|
||||
tweenAlpha._curve.postWrapMode = WrapMode.Once;
|
||||
tweenAlpha._curve.preWrapMode = WrapMode.Once;
|
||||
}
|
||||
tweenAlpha._from = 0f;
|
||||
tweenAlpha._to = 1f;
|
||||
tweenAlpha._endTime = 0.3f;
|
||||
tweenAlpha._delayTime = 0f;
|
||||
tweenAlpha._finishCallBack = delegate
|
||||
{
|
||||
onFinish.Call();
|
||||
};
|
||||
tweenAlpha.PlayForward(isReset: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user