Files
SVSimServer/SVSim.BattleEngine/Engine/AspectCamera.cs
gamer147 957af3d1ec 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.
2026-06-05 17:22:20 -04:00

77 lines
1.6 KiB
C#

using UnityEngine;
[ExecuteInEditMode]
public class AspectCamera : MonoBehaviour
{
public Vector2 aspect = new Vector2(4f, 3f);
public Color32 backgroundColor = Color.black;
private float aspectRate;
private Camera _camera;
private static Camera _backgroundCamera;
private int sizeVal = 1;
public const float LOWER_LIMIT_ASPECT_RATIO = 0.5625f;
public const float UPPER_LIMIT_ASPECT_RATIO = 0.4618f;
public const float LOWER_LIMIT_ASPECT_RATIO_RECIPROCAL = 1.7777778f;
private const float SAFE_AREA_RATE = 0.892f;
private const float SAFE_AREA_NONE_RATE = 1f;
public static float SafeAreaRate;
private void Start()
{
aspectRate = aspect.x / aspect.y;
_camera = GetComponent<Camera>();
SafeAreaRate = 1f;
float num = (float)Screen.height / (float)Screen.width;
if (num < 0.5625f)
{
num = Mathf.Max(num, 0.4618f);
float t = (0.5625f - num) / 0.10069999f;
SafeAreaRate = Mathf.Lerp(1f, 0.892f, t);
}
}
private void UpdateScreenRate()
{
float num = aspect.y / aspect.x;
float num2 = (float)Screen.height / (float)Screen.width;
if (num2 < 0.5625f)
{
num2 = 0.5625f;
}
if (num > num2)
{
float num3 = num2 / num;
_camera.rect = new Rect(0f, 0f, 1f, 1f);
_camera.orthographicSize = (float)sizeVal * num3;
}
else
{
float num4 = num / num2;
_camera.rect = new Rect(0f, 0f, 1f, 1f);
_camera.orthographicSize = (float)sizeVal / num4;
}
}
private bool IsChangeAspect()
{
return _camera.aspect == aspectRate;
}
private void Update()
{
UpdateScreenRate();
_camera.ResetAspect();
}
}