From 4491c6c7f3f0d3d9bea87c3486f8db23a40807b6 Mon Sep 17 00:00:00 2001 From: gamer147 Date: Fri, 5 Jun 2026 20:22:43 -0400 Subject: [PATCH] feat(battle-engine): full Unity primitive/runtime surface + game extension copies Grows Vector2/3, Mathf, Color, Quaternion, GameObject, Transform, Camera, Material, ParticleSystem, Rect, Bounds, Time to the surface the engine references; adds Input/ Random/Resources statics + full KeyCode enum. Copies the verbatim extension files that collapse thousands of CS1061s at once (ContentKeywordExt, JsonData/LitJson extensions, EventExtension.Call, GameObjectExtension(s)). 26.5k -> 15.9k errors; residual now dominated by god-object member surface (GameMgr/UIManager/EffectMgr/Vfx*). --- SVSim.BattleEngine/COPIED.manifest.tsv | 6 + .../Engine/ContentKeywordExt.cs | 14 + .../Engine/Cute/EventExtension.cs | 159 +++++++++++ .../Engine/GameObjectExtension.cs | 21 ++ .../Engine/GameObjectExtensions.cs | 22 ++ .../Engine/JsonDataExtension.cs | 64 +++++ .../Wizard.AutoTest/LitJsonExtention.cs | 125 +++++++++ .../Shim/UnityEngine/Primitives.cs | 165 ++++++++++- .../Shim/UnityEngine/UnityRuntime.cs | 94 +++++++ .../Shim/UnityEngine/UnityShim.cs | 264 ++++++++++++++++-- 10 files changed, 895 insertions(+), 39 deletions(-) create mode 100644 SVSim.BattleEngine/Engine/ContentKeywordExt.cs create mode 100644 SVSim.BattleEngine/Engine/Cute/EventExtension.cs create mode 100644 SVSim.BattleEngine/Engine/GameObjectExtension.cs create mode 100644 SVSim.BattleEngine/Engine/GameObjectExtensions.cs create mode 100644 SVSim.BattleEngine/Engine/JsonDataExtension.cs create mode 100644 SVSim.BattleEngine/Engine/Wizard.AutoTest/LitJsonExtention.cs create mode 100644 SVSim.BattleEngine/Shim/UnityEngine/UnityRuntime.cs diff --git a/SVSim.BattleEngine/COPIED.manifest.tsv b/SVSim.BattleEngine/COPIED.manifest.tsv index 1850f17..916aabb 100644 --- a/SVSim.BattleEngine/COPIED.manifest.tsv +++ b/SVSim.BattleEngine/COPIED.manifest.tsv @@ -107,6 +107,7 @@ ColosseumResultReporter.cs ColosseumResultReporter.cs 6e9ca923733f01c6c20aeb544c ConditionSkillFilterCollection.cs ConditionSkillFilterCollection.cs b8fc3d9621a1f8ae7aaffbaac618bdaba36b63b036a37b611d9a798e2e68a8aa 0 ConnectionReportTrigger.cs ConnectionReportTrigger.cs c78d2c39db8a484c95b7e47c7bbdd16d050942c012531f286a188d5df33d3ca6 0 ConnectionReporter.cs ConnectionReporter.cs 64f1c1133af6cd674763ed612d837a14bbc5ce1908afc9f3a93ff6b6cc18577f 0 +ContentKeywordExt.cs ContentKeywordExt.cs 3e93b52de66c252f5225c0d8924e19c53852b3d9c9c46b5620702dc7b13e0986 0 ConventionInfo.cs ConventionInfo.cs f4199507123b62b5da1633608e877cf0d9ed4ecf26a1671d520dfa2c8ee3026a 0 ConventionList.cs ConventionList.cs d0271cd5a5029c3ccf3fff460d093070d97fc13c1871573bd980733c6a21ad9c 0 ConventionListPlate.cs ConventionListPlate.cs 367921469919006a00056b6899bad8ff06c7ffcebe0142abe71b40a206b61ac2 0 @@ -116,6 +117,7 @@ CostCurveUI.cs CostCurveUI.cs 75c41420986c2e5acbce33837dd0d475a50fb5a1bb3e3abcf0 CostHalfModifier.cs CostHalfModifier.cs 21e90484e832afa41ec4f9e6244762a32b0a162f1ab940329d7a994ecce73347 0 CostHalfRoundUpModifier.cs CostHalfRoundUpModifier.cs 92e2a80e70e590d861036e69c77beb5a48c52012885e62876240bed3a059fa70 0 CostSetModifier.cs CostSetModifier.cs f6821df3735ce643be552bb7b919ccb8c75a1c22135daf01ef28a6eed9bf7c02 0 +Cute/EventExtension.cs Cute/EventExtension.cs abe1b8be9d01d8ad88901cdccf387563ae14282dd4e02b3fc1e1e7a872526f0c 0 Cute\AssetBundleObject.cs Cute\AssetBundleObject.cs 8bb313efedc9c4ceea5ecc22768952299393dfa30e532c9d411e48f622929d2e 0 Cute\AssetErrorState.cs Cute\AssetErrorState.cs b33ad3fb7e2ef3fe360dd4bfb4fa165c6545fea387978a19954be38534aafc5f 0 Cute\AssetHandle.cs Cute\AssetHandle.cs 1d8a2e86416732f74946f33dcc83668475124040ac512495fb78581a21c6e504 0 @@ -216,6 +218,8 @@ FriendInfoDetail.cs FriendInfoDetail.cs 969b8b156330d258e54dd88747d22e24f8e691ef FusionIngredientInfo.cs FusionIngredientInfo.cs f27ea653c65be64dbf872e64dfca4ac1da361eb347a96b2d05836b79452c8510 0 GachaObj.cs GachaObj.cs ed8ef737f4254948f1e99fa49487dda56893096d472cfceaf4d68593ee81c7f2 0 GachaUI.cs GachaUI.cs 9a2717c4c7488d1ac985e3f297efc5a0d2b1f11154257f120db4716b9562a280 0 +GameObjectExtension.cs GameObjectExtension.cs c52b9f14cc4237846cad401e99a269de16bbaae57ceafd3aff88b4de48763032 0 +GameObjectExtensions.cs GameObjectExtensions.cs e2cfe625254133493242c2f67a77a16149115ce2148f56423c9e854c8074ff56 0 GateField.cs GateField.cs 7e46608dfc593222fb0364424b87944064f061d736b93d69d2c531f1645b7d18 0 Global.cs Global.cs 176c8351aa9f1c5529fa0ed3ae8514fef117d4274034ec358ac1b7ee4fafb782 0 GuardInfo.cs GuardInfo.cs f90debeff49492f32e54241fe88120353c9e640c63e40e5368e37aca46cbe4d7 0 @@ -270,6 +274,7 @@ InputDialog.cs InputDialog.cs cdca35d6b09423bd6995c573d775d05a5548b5fa5e9d29329f InputMgr.cs InputMgr.cs 581fa15080fb3a88827b415e1da7b27624df5b6990bc3901ab73fab64a2c22ba 0 InviteFriendBattle.cs InviteFriendBattle.cs f1c14f9d25baffa1414175af2bdb9cee3188a3d914bd29d4c5925a08f9b3160b 0 IronField.cs IronField.cs 689150823ae55cf49abda584ecbc7a41893e25f04f9fb5a390342f8be2de1ead 0 +JsonDataExtension.cs JsonDataExtension.cs aa81fbf84fb4479dc9e2ad2ea5970b62553454bb7de88101617a80db02c53c6c 0 JudgeResultFailedToRetryChecker.cs JudgeResultFailedToRetryChecker.cs de1009153f15895bec6f0540db81859a4f57812ca5c44f5db9c2b3bd6d907f2d 0 LaboratoryField.cs LaboratoryField.cs 294c70c4ba7ca09b01025a3494dbf1af61095babbc5dfb166489689cf5f7a2b8 0 LaboratoryNightField.cs LaboratoryNightField.cs a4026bf07382df824e1745660551947413d56180a25b58af64428ee0850bd5c2 0 @@ -1305,6 +1310,7 @@ WatchTouchControl.cs WatchTouchControl.cs 7a8426ee3f178f05650eb4ccd5952eb5dcc171 WatchTurnEndTimeController.cs WatchTurnEndTimeController.cs 50cd44122fe694f1003214c31a552ec9e899388166b4a495e5a03d5601fbfb1d 0 WatcherDisconnectChecker.cs WatcherDisconnectChecker.cs b2ec9803c3ed9e473233cfd4e2f805195df1f607936f7dde9ae1b7a7028dd847 0 WatcherLeaveChecker.cs WatcherLeaveChecker.cs 7b969aacc9670f319bd45d344528524a3001b0152cc96e99631e89fa69354466 0 +Wizard.AutoTest/LitJsonExtention.cs Wizard.AutoTest/LitJsonExtention.cs 2c7f0f5931516292033479e8ef92631fdd72a27907c048ba77d3e287187fc504 0 Wizard.AutoTest\AutoTestBattleMgr.cs Wizard.AutoTest\AutoTestBattleMgr.cs 42841daf11cb9b42e8d97f44f7ae24aebee089b7d9c7c6d8d39f21b32b49860d 0 Wizard.Battle.Card.InnerOptions\CardInnerOptionsBase.cs Wizard.Battle.Card.InnerOptions\CardInnerOptionsBase.cs e0c9e0e503c55e536924b17f7b2948423a79b85bafaf0ffa0d02b053667d69f2 0 Wizard.Battle.Card\IVirtualBattleCard.cs Wizard.Battle.Card\IVirtualBattleCard.cs 9446d58a4ab2ddd2097d3132b133c36780d7e9d36b83309a4dc12d7c8d441f40 0 diff --git a/SVSim.BattleEngine/Engine/ContentKeywordExt.cs b/SVSim.BattleEngine/Engine/ContentKeywordExt.cs new file mode 100644 index 0000000..0ef284d --- /dev/null +++ b/SVSim.BattleEngine/Engine/ContentKeywordExt.cs @@ -0,0 +1,14 @@ +internal static class ContentKeywordExt +{ + public static string ToStringCustom(this SkillFilterCreator.ContentKeyword type) + { + return type switch + { + SkillFilterCreator.ContentKeyword._class => "class", + SkillFilterCreator.ContentKeyword._true => "true", + SkillFilterCreator.ContentKeyword._false => "false", + SkillFilterCreator.ContentKeyword._ref_prev => "<-", + _ => type.ToString(), + }; + } +} diff --git a/SVSim.BattleEngine/Engine/Cute/EventExtension.cs b/SVSim.BattleEngine/Engine/Cute/EventExtension.cs new file mode 100644 index 0000000..61ad990 --- /dev/null +++ b/SVSim.BattleEngine/Engine/Cute/EventExtension.cs @@ -0,0 +1,159 @@ +using System; + +namespace Cute; + +public static class EventExtension +{ + public static void Call(this Action action) + { + action?.Invoke(); + } + + public static void Call(this Action action, T1 arg1) + { + action?.Invoke(arg1); + } + + public static void Call(this Action action, T1 arg1, T2 arg2) + { + action?.Invoke(arg1, arg2); + } + + public static void Call(this Action action, T1 arg1, T2 arg2, T3 arg3) + { + action?.Invoke(arg1, arg2, arg3); + } + + public static void Call(this Action action, T1 arg1, T2 arg2, T3 arg3, T4 arg4) + { + action?.Invoke(arg1, arg2, arg3, arg4); + } + + public static void Call(this Action action, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) + { + action?.Invoke(arg1, arg2, arg3, arg4, arg5); + } + + public static void Call(this Action action, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6) + { + action?.Invoke(arg1, arg2, arg3, arg4, arg5, arg6); + } + + public static void Call(this Action action, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) + { + action?.Invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7); + } + + public static void Call(this Action action, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8) + { + action?.Invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8); + } + + public static void Call(this Action action, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9) + { + action?.Invoke(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); + } + + public static TR Call(this Func func) + { + if (func == null) + { + return default(TR); + } + return func(); + } + + public static TR Call(this Func func, T1 arg1) + { + if (func == null) + { + return default(TR); + } + return func(arg1); + } + + public static TR Call(this Func func, T1 arg1, T2 arg2) + { + if (func == null) + { + return default(TR); + } + return func(arg1, arg2); + } + + public static TR Call(this Func func, T1 arg1, T2 arg2, T3 arg3) + { + if (func == null) + { + return default(TR); + } + return func(arg1, arg2, arg3); + } + + public static TR Call(this Func func, T1 arg1, T2 arg2, T3 arg3, T4 arg4) + { + if (func == null) + { + return default(TR); + } + return func(arg1, arg2, arg3, arg4); + } + + public static TR Call(this Func func, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) + { + if (func == null) + { + return default(TR); + } + return func(arg1, arg2, arg3, arg4, arg5); + } + + public static TR[] GetAllFuncCallResults(this Func func) + { + if (func == null) + { + return new TR[0]; + } + return CallAllFunc(func, (Delegate f) => ((Func)f)()); + } + + public static TR[] GetAllFuncCallResults(this Func func, T1 arg1) + { + if (func == null) + { + return new TR[0]; + } + return CallAllFunc(func, (Delegate f) => ((Func)f)(arg1)); + } + + public static TR[] GetAllFuncCallResults(this Func func, T1 arg1, T2 arg2) + { + if (func == null) + { + return new TR[0]; + } + return CallAllFunc(func, (Delegate f) => ((Func)f)(arg1, arg2)); + } + + public static TR[] GetAllFuncCallResults(this Func func, T1 arg1, T2 arg2, T3 arg3) + { + if (func == null) + { + return new TR[0]; + } + return CallAllFunc(func, (Delegate f) => ((Func)f)(arg1, arg2, arg3)); + } + + private static TR[] CallAllFunc(Delegate func, Func call) + { + Delegate[] invocationList = func.GetInvocationList(); + int num = invocationList.Length; + TR[] array = new TR[num]; + for (int i = 0; i < num; i++) + { + TR val = call(invocationList[i]); + array[i] = val; + } + return array; + } +} diff --git a/SVSim.BattleEngine/Engine/GameObjectExtension.cs b/SVSim.BattleEngine/Engine/GameObjectExtension.cs new file mode 100644 index 0000000..68fef4f --- /dev/null +++ b/SVSim.BattleEngine/Engine/GameObjectExtension.cs @@ -0,0 +1,21 @@ +using UnityEngine; + +public static class GameObjectExtension +{ + public static void SetLayer(this GameObject gameObject, int layer, bool isSetChildren) + { + if (gameObject == null) + { + return; + } + gameObject.layer = layer; + if (!isSetChildren) + { + return; + } + foreach (Transform item in gameObject.transform) + { + item.gameObject.SetLayer(layer, isSetChildren); + } + } +} diff --git a/SVSim.BattleEngine/Engine/GameObjectExtensions.cs b/SVSim.BattleEngine/Engine/GameObjectExtensions.cs new file mode 100644 index 0000000..bae925c --- /dev/null +++ b/SVSim.BattleEngine/Engine/GameObjectExtensions.cs @@ -0,0 +1,22 @@ +using System.Linq; +using UnityEngine; + +public static class GameObjectExtensions +{ + public static BattleCardBase GetBattleCard(this GameObject go) + { + if (go == null) + { + return null; + } + BattleCardBase battleCardBase = null; + BattleCardBase battleCardBase2 = null; + battleCardBase = BattleManagerBase.GetIns().BattlePlayer.AllCards.FirstOrDefault((BattleCardBase s) => s.BattleCardView.GameObject == go); + battleCardBase2 = BattleManagerBase.GetIns().BattleEnemy.AllCards.FirstOrDefault((BattleCardBase s) => s.BattleCardView.GameObject == go); + if (battleCardBase != null) + { + return battleCardBase; + } + return battleCardBase2; + } +} diff --git a/SVSim.BattleEngine/Engine/JsonDataExtension.cs b/SVSim.BattleEngine/Engine/JsonDataExtension.cs new file mode 100644 index 0000000..8071cf8 --- /dev/null +++ b/SVSim.BattleEngine/Engine/JsonDataExtension.cs @@ -0,0 +1,64 @@ +using LitJson; + +public static class JsonDataExtension +{ + public static bool TryGetValue(this JsonData data, string key, out JsonData value) + { + value = null; + if (!data.IsObject) + { + return false; + } + if (!data.Keys.Contains(key)) + { + return false; + } + value = data[key]; + return true; + } + + public static string GetValueOrDefault(this JsonData data, string key, string defaultValue) + { + if (!data.TryGetValue(key, out var value)) + { + return defaultValue; + } + return value.ToString(); + } + + public static int GetValueOrDefault(this JsonData data, string key, int defaultValue) + { + if (!data.TryGetValue(key, out var value)) + { + return defaultValue; + } + return value.ToInt(); + } + + public static long GetValueOrDefault(this JsonData data, string key, long defaultValue) + { + if (!data.TryGetValue(key, out var value)) + { + return defaultValue; + } + return value.ToLong(); + } + + public static double GetValueOrDefault(this JsonData data, string key, double defaultValue) + { + if (!data.TryGetValue(key, out var value)) + { + return defaultValue; + } + return value.ToDouble(); + } + + public static bool GetValueOrDefault(this JsonData data, string key, bool defaultValue) + { + if (!data.TryGetValue(key, out var value)) + { + return defaultValue; + } + return value.ToBoolean(); + } +} diff --git a/SVSim.BattleEngine/Engine/Wizard.AutoTest/LitJsonExtention.cs b/SVSim.BattleEngine/Engine/Wizard.AutoTest/LitJsonExtention.cs new file mode 100644 index 0000000..75fdc72 --- /dev/null +++ b/SVSim.BattleEngine/Engine/Wizard.AutoTest/LitJsonExtention.cs @@ -0,0 +1,125 @@ +using System.Collections.Generic; +using System.Linq; +using LitJson; + +namespace Wizard.AutoTest; + +public static class LitJsonExtention +{ + public static bool? ToBooleanOrNull(this JsonData jsonData, string key) + { + if (!jsonData.HasKey(key)) + { + return null; + } + if (!jsonData[key].IsBoolean) + { + return null; + } + return jsonData[key].ToBoolean(); + } + + public static bool ToBooleanOrDefault(this JsonData jsonData, string key, bool defaultBoolean) + { + bool? flag = jsonData.ToBooleanOrNull(key); + if (!flag.HasValue) + { + return defaultBoolean; + } + return flag.Value; + } + + public static int? ToIntOrNull(this JsonData jsonData, string key) + { + if (!jsonData.HasKey(key)) + { + return null; + } + if (!jsonData[key].IsInt) + { + return null; + } + return jsonData[key].ToInt(); + } + + public static int ToIntOrDefault(this JsonData jsonData, string key, int defaultInt) + { + int? num = jsonData.ToIntOrNull(key); + if (!num.HasValue) + { + return defaultInt; + } + return num.Value; + } + + public static long? ToLongOrNull(this JsonData jsonData, string key) + { + if (!jsonData.HasKey(key)) + { + return null; + } + if (!jsonData[key].IsLong && !jsonData[key].IsInt) + { + return null; + } + return jsonData[key].ToLong(); + } + + public static long ToLongOrDefault(this JsonData jsonData, string key, int defaultLong) + { + long? num = jsonData.ToLongOrNull(key); + if (!num.HasValue) + { + return defaultLong; + } + return num.Value; + } + + public static string ToStringOrNull(this JsonData jsonData, string key) + { + if (!jsonData.HasKey(key)) + { + return null; + } + if (!jsonData[key].IsString) + { + return null; + } + return jsonData[key].ToString(); + } + + public static string ToStringOrDefault(this JsonData jsonData, string key, string defaultString) + { + return jsonData.ToStringOrNull(key) ?? defaultString; + } + + public static JsonData ToObjectOrNull(this JsonData jsonData, string key) + { + if (!jsonData.HasKey(key)) + { + return null; + } + if (!jsonData[key].IsObject) + { + return null; + } + return jsonData[key]; + } + + public static IEnumerable ToJsonDataCollection(this JsonData jsonData, string key) + { + if (jsonData.HasKey(key) && jsonData[key].IsArray) + { + JsonData arrayJsonData = jsonData[key]; + for (int i = 0; i < arrayJsonData.Count; i++) + { + yield return arrayJsonData[i]; + } + } + } + + public static bool HasKey(this JsonData jsonData, string key) + { + return jsonData.Keys.Any((string k) => k == key); + } +} diff --git a/SVSim.BattleEngine/Shim/UnityEngine/Primitives.cs b/SVSim.BattleEngine/Shim/UnityEngine/Primitives.cs index 127aa1d..2c1101b 100644 --- a/SVSim.BattleEngine/Shim/UnityEngine/Primitives.cs +++ b/SVSim.BattleEngine/Shim/UnityEngine/Primitives.cs @@ -1,35 +1,172 @@ -// AUTHORED SHIM (not copied). Minimal no-op UnityEngine surface. Grows via the -// Task 4 compile loop -- add only members the compiler actually demands. +// AUTHORED SHIM (not copied). Minimal no-op UnityEngine value-type surface. Grows via +// the M1 compile loop -- members added are exactly those the copied engine references +// (geometry/math used inside never-run VFX/layout code; IsForecast suppresses playback, +// so numeric results here never feed authoritative game state). +using System; + namespace UnityEngine { - public struct Vector2 { public float x, y; public Vector2(float x, float y){ this.x=x; this.y=y; } } + public struct Vector2 + { + public float x, y; + public Vector2(float x, float y) { this.x = x; this.y = y; } + public static Vector2 zero => new Vector2(0, 0); + public static Vector2 one => new Vector2(1, 1); + public static Vector2 up => new Vector2(0, 1); + public static Vector2 down => new Vector2(0, -1); + public static Vector2 left => new Vector2(-1, 0); + public static Vector2 right => new Vector2(1, 0); + public float magnitude => (float)Math.Sqrt(x * x + y * y); + public float sqrMagnitude => x * x + y * y; + public Vector2 normalized { get { float m = magnitude; return m > 1e-6f ? new Vector2(x / m, y / m) : zero; } } + public static float Distance(Vector2 a, Vector2 b) => (a - b).magnitude; + public static Vector2 Lerp(Vector2 a, Vector2 b, float t) => new Vector2(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t); + public static Vector2 operator +(Vector2 a, Vector2 b) => new Vector2(a.x + b.x, a.y + b.y); + public static Vector2 operator -(Vector2 a, Vector2 b) => new Vector2(a.x - b.x, a.y - b.y); + public static Vector2 operator -(Vector2 a) => new Vector2(-a.x, -a.y); + public static Vector2 operator *(Vector2 a, float s) => new Vector2(a.x * s, a.y * s); + public static Vector2 operator *(float s, Vector2 a) => new Vector2(a.x * s, a.y * s); + public static Vector2 operator /(Vector2 a, float s) => new Vector2(a.x / s, a.y / s); + public static implicit operator Vector2(Vector3 v) => new Vector2(v.x, v.y); + public static implicit operator Vector3(Vector2 v) => new Vector3(v.x, v.y, 0); + } + public struct Vector3 { public float x, y, z; - public Vector3(float x, float y, float z){ this.x=x; this.y=y; this.z=z; } - public static Vector3 zero => new Vector3(0,0,0); - public static Vector3 operator +(Vector3 a, Vector3 b) => new Vector3(a.x+b.x, a.y+b.y, a.z+b.z); + public Vector3(float x, float y, float z) { this.x = x; this.y = y; this.z = z; } + public Vector3(float x, float y) { this.x = x; this.y = y; this.z = 0; } + public static Vector3 zero => new Vector3(0, 0, 0); + public static Vector3 one => new Vector3(1, 1, 1); + public static Vector3 up => new Vector3(0, 1, 0); + public static Vector3 down => new Vector3(0, -1, 0); + public static Vector3 left => new Vector3(-1, 0, 0); + public static Vector3 right => new Vector3(1, 0, 0); + public static Vector3 forward => new Vector3(0, 0, 1); + public static Vector3 back => new Vector3(0, 0, -1); + public float magnitude => (float)Math.Sqrt(x * x + y * y + z * z); + public float sqrMagnitude => x * x + y * y + z * z; + public Vector3 normalized { get { float m = magnitude; return m > 1e-6f ? new Vector3(x / m, y / m, z / m) : zero; } } + public static float Distance(Vector3 a, Vector3 b) => (a - b).magnitude; + public static float SqrMagnitude(Vector3 a) => a.sqrMagnitude; + public static float Dot(Vector3 a, Vector3 b) => a.x * b.x + a.y * b.y + a.z * b.z; + public static Vector3 Cross(Vector3 a, Vector3 b) => new Vector3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); + public static Vector3 Scale(Vector3 a, Vector3 b) => new Vector3(a.x * b.x, a.y * b.y, a.z * b.z); + public static Vector3 Lerp(Vector3 a, Vector3 b, float t) => new Vector3(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t); + public static Vector3 LerpUnclamped(Vector3 a, Vector3 b, float t) => Lerp(a, b, t); + public static Vector3 MoveTowards(Vector3 a, Vector3 b, float d) => b; + public static Vector3 operator +(Vector3 a, Vector3 b) => new Vector3(a.x + b.x, a.y + b.y, a.z + b.z); + public static Vector3 operator -(Vector3 a, Vector3 b) => new Vector3(a.x - b.x, a.y - b.y, a.z - b.z); + public static Vector3 operator -(Vector3 a) => new Vector3(-a.x, -a.y, -a.z); + public static Vector3 operator *(Vector3 a, float s) => new Vector3(a.x * s, a.y * s, a.z * s); + public static Vector3 operator *(float s, Vector3 a) => new Vector3(a.x * s, a.y * s, a.z * s); + public static Vector3 operator /(Vector3 a, float s) => new Vector3(a.x / s, a.y / s, a.z / s); + public static bool operator ==(Vector3 a, Vector3 b) => a.x == b.x && a.y == b.y && a.z == b.z; + public static bool operator !=(Vector3 a, Vector3 b) => !(a == b); + public override bool Equals(object o) => o is Vector3 v && this == v; + public override int GetHashCode() => x.GetHashCode() ^ y.GetHashCode() ^ z.GetHashCode(); } + public struct Quaternion { public float x, y, z, w; - public static Quaternion identity => new Quaternion { x=0, y=0, z=0, w=1 }; - public static Quaternion Euler(float x, float y, float z) => new Quaternion(); + public Quaternion(float x, float y, float z, float w) { this.x = x; this.y = y; this.z = z; this.w = w; } + public static Quaternion identity => new Quaternion(0, 0, 0, 1); + public static Quaternion Euler(float x, float y, float z) => identity; + public static Quaternion Euler(Vector3 e) => identity; + public static Quaternion AngleAxis(float angle, Vector3 axis) => identity; + public static Quaternion LookRotation(Vector3 fwd) => identity; + public static Quaternion Slerp(Quaternion a, Quaternion b, float t) => identity; + public Vector3 eulerAngles { get => Vector3.zero; set { } } + public static Vector3 operator *(Quaternion q, Vector3 v) => v; + public static Quaternion operator *(Quaternion a, Quaternion b) => identity; } - public struct Color { public float r, g, b, a; public Color(float r,float g,float b,float a){ this.r=r; this.g=g; this.b=b; this.a=a; } } + + public struct Color + { + public float r, g, b, a; + public Color(float r, float g, float b, float a) { this.r = r; this.g = g; this.b = b; this.a = a; } + public Color(float r, float g, float b) { this.r = r; this.g = g; this.b = b; this.a = 1f; } + public static Color white => new Color(1, 1, 1, 1); + public static Color black => new Color(0, 0, 0, 1); + public static Color clear => new Color(0, 0, 0, 0); + public static Color red => new Color(1, 0, 0, 1); + public static Color green => new Color(0, 1, 0, 1); + public static Color blue => new Color(0, 0, 1, 1); + public static Color yellow => new Color(1, 0.92f, 0.016f, 1); + public static Color cyan => new Color(0, 1, 1, 1); + public static Color magenta => new Color(1, 0, 1, 1); + public static Color gray => new Color(0.5f, 0.5f, 0.5f, 1); + public static Color grey => gray; + public static Color Lerp(Color a, Color b, float t) => new Color(a.r + (b.r - a.r) * t, a.g + (b.g - a.g) * t, a.b + (b.b - a.b) * t, a.a + (b.a - a.a) * t); + public static Color operator *(Color c, float s) => new Color(c.r * s, c.g * s, c.b * s, c.a * s); + public static Color operator *(Color a, Color b) => new Color(a.r * b.r, a.g * b.g, a.b * b.b, a.a * b.a); + public static Color operator +(Color a, Color b) => new Color(a.r + b.r, a.g + b.g, a.b + b.b, a.a + b.a); + public static implicit operator Color(Color32 c) => new Color(c.r / 255f, c.g / 255f, c.b / 255f, c.a / 255f); + } + public static class Mathf { public const float PI = 3.14159265f; - public static float Floor(float f) => (float)System.Math.Floor(f); - public static int FloorToInt(float f) => (int)System.Math.Floor(f); - public static float Max(float a, float b) => System.Math.Max(a, b); - public static float Min(float a, float b) => System.Math.Min(a, b); - public static float Clamp(float v, float lo, float hi) => System.Math.Max(lo, System.Math.Min(hi, v)); + public const float Infinity = float.PositiveInfinity; + public const float NegativeInfinity = float.NegativeInfinity; + public const float Epsilon = 1.401298E-45f; + public const float Deg2Rad = PI / 180f; + public const float Rad2Deg = 180f / PI; + public static float Floor(float f) => (float)Math.Floor(f); + public static int FloorToInt(float f) => (int)Math.Floor(f); + public static float Ceil(float f) => (float)Math.Ceiling(f); + public static int CeilToInt(float f) => (int)Math.Ceiling(f); + public static float Round(float f) => (float)Math.Round(f); + public static int RoundToInt(float f) => (int)Math.Round(f); + public static float Abs(float f) => Math.Abs(f); + public static int Abs(int f) => Math.Abs(f); + public static float Max(float a, float b) => Math.Max(a, b); + public static int Max(int a, int b) => Math.Max(a, b); + public static float Min(float a, float b) => Math.Min(a, b); + public static int Min(int a, int b) => Math.Min(a, b); + public static float Clamp(float v, float lo, float hi) => Math.Max(lo, Math.Min(hi, v)); + public static int Clamp(int v, int lo, int hi) => Math.Max(lo, Math.Min(hi, v)); + public static float Clamp01(float v) => Math.Max(0f, Math.Min(1f, v)); + public static float Lerp(float a, float b, float t) => a + (b - a) * Clamp01(t); + public static float LerpUnclamped(float a, float b, float t) => a + (b - a) * t; + public static float LerpAngle(float a, float b, float t) => a + (b - a) * Clamp01(t); + public static float MoveTowards(float a, float b, float d) => b; + public static float SmoothDamp(float cur, float target, ref float vel, float time) { vel = 0; return target; } + public static float SmoothDamp(float cur, float target, ref float vel, float time, float maxSpeed) { vel = 0; return target; } + public static float SmoothDampAngle(float cur, float target, ref float vel, float time) { vel = 0; return target; } + public static float SmoothStep(float a, float b, float t) => Lerp(a, b, t); + public static float Sin(float f) => (float)Math.Sin(f); + public static float Cos(float f) => (float)Math.Cos(f); + public static float Tan(float f) => (float)Math.Tan(f); + public static float Asin(float f) => (float)Math.Asin(f); + public static float Acos(float f) => (float)Math.Acos(f); + public static float Atan(float f) => (float)Math.Atan(f); + public static float Atan2(float y, float x) => (float)Math.Atan2(y, x); + public static float Sqrt(float f) => (float)Math.Sqrt(f); + public static float Pow(float f, float p) => (float)Math.Pow(f, p); + public static float Exp(float f) => (float)Math.Exp(f); + public static float Log(float f) => (float)Math.Log(f); + public static float Log(float f, float b) => (float)Math.Log(f, b); + public static float Log10(float f) => (float)Math.Log10(f); + public static float Sign(float f) => Math.Sign(f); + public static bool Approximately(float a, float b) => Math.Abs(a - b) < 1e-6f; + public static float Repeat(float t, float length) => t - Floor(t / length) * length; + public static float PingPong(float t, float length) => length - Math.Abs(Repeat(t, length * 2) - length); + public static float DeltaAngle(float a, float b) => Repeat(b - a + 180f, 360f) - 180f; + public static float GammaToLinearSpace(float v) => v; + public static float LinearToGammaSpace(float v) => v; } + public static class Debug { public static void Log(object m) { } + public static void LogFormat(string m, params object[] a) { } public static void LogWarning(object m) { } public static void LogError(object m) { } + public static void LogException(Exception e) { } + public static void Assert(bool c) { } + public static void DrawLine(Vector3 a, Vector3 b) { } + public static void DrawRay(Vector3 a, Vector3 b) { } } } diff --git a/SVSim.BattleEngine/Shim/UnityEngine/UnityRuntime.cs b/SVSim.BattleEngine/Shim/UnityEngine/UnityRuntime.cs new file mode 100644 index 0000000..d25ab8e --- /dev/null +++ b/SVSim.BattleEngine/Shim/UnityEngine/UnityRuntime.cs @@ -0,0 +1,94 @@ +// AUTHORED SHIM (not copied). Input / Random / Resources statics + the full KeyCode +// enum. Referenced almost entirely by non-battle UI/input files swept into the closure; +// headless we never pump input and never load resources, so all of this is inert. +using System; + +namespace UnityEngine +{ + public static class Input + { + public static Vector3 mousePosition => Vector3.zero; + public static Vector2 mouseScrollDelta => Vector2.zero; + public static int touchCount => 0; + public static Touch[] touches => new Touch[0]; + public static Touch GetTouch(int i) => default; + public static bool anyKey => false; + public static bool anyKeyDown => false; + public static bool mousePresent => false; + public static bool GetMouseButton(int b) => false; + public static bool GetMouseButtonDown(int b) => false; + public static bool GetMouseButtonUp(int b) => false; + public static bool GetKey(KeyCode k) => false; + public static bool GetKey(string n) => false; + public static bool GetKeyDown(KeyCode k) => false; + public static bool GetKeyDown(string n) => false; + public static bool GetKeyUp(KeyCode k) => false; + public static bool GetButton(string n) => false; + public static bool GetButtonDown(string n) => false; + public static float GetAxis(string n) => 0f; + public static float GetAxisRaw(string n) => 0f; + public static string inputString => ""; + public static bool multiTouchEnabled { get; set; } + } + + public static class Random + { + public static float value => 0f; + public static int Range(int minInclusive, int maxExclusive) => minInclusive; + public static float Range(float min, float max) => min; + public static Vector2 insideUnitCircle => Vector2.zero; + public static Vector3 insideUnitSphere => Vector3.zero; + public static Vector3 onUnitSphere => Vector3.up; + public static Quaternion rotation => Quaternion.identity; + public static Quaternion rotationUniform => Quaternion.identity; + public static int seed { get; set; } + public static void InitState(int s) { } + public static Color ColorHSV() => Color.white; + } + + public static class Resources + { + public static T Load(string path) where T : Object => null; + public static T Load(string path, Type t) where T : Object => null; + public static Object Load(string path) => null; + public static Object Load(string path, Type t) => null; + public static T[] LoadAll(string path) where T : Object => new T[0]; + public static Object[] LoadAll(string path) => new Object[0]; + public static ResourceRequest LoadAsync(string path) where T : Object => null; + public static void UnloadAsset(Object o) { } + public static AsyncOperation UnloadUnusedAssets() => null; + } + + public class ResourceRequest : AsyncOperation { public Object asset => null; } + + public enum KeyCode + { + None = 0, + Backspace = 8, Tab = 9, Clear = 12, Return = 13, Pause = 19, Escape = 27, Space = 32, + Exclaim = 33, DoubleQuote = 34, Hash = 35, Dollar = 36, Ampersand = 38, Quote = 39, + LeftParen = 40, RightParen = 41, Asterisk = 42, Plus = 43, Comma = 44, Minus = 45, + Period = 46, Slash = 47, + Alpha0 = 48, Alpha1, Alpha2, Alpha3, Alpha4, Alpha5, Alpha6, Alpha7, Alpha8, Alpha9, + Colon = 58, Semicolon = 59, Less = 60, Equals = 61, Greater = 62, Question = 63, At = 64, + LeftBracket = 91, Backslash = 92, RightBracket = 93, Caret = 94, Underscore = 95, BackQuote = 96, + A = 97, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, + LeftCurlyBracket = 123, Pipe = 124, RightCurlyBracket = 125, Tilde = 126, Delete = 127, + Keypad0 = 256, Keypad1, Keypad2, Keypad3, Keypad4, Keypad5, Keypad6, Keypad7, Keypad8, Keypad9, + KeypadPeriod = 266, KeypadDivide = 267, KeypadMultiply = 268, KeypadMinus = 269, + KeypadPlus = 270, KeypadEnter = 271, KeypadEquals = 272, + UpArrow = 273, DownArrow = 274, RightArrow = 275, LeftArrow = 276, + Insert = 277, Home = 278, End = 279, PageUp = 280, PageDown = 281, + F1 = 282, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, + Numlock = 300, CapsLock = 301, ScrollLock = 302, + RightShift = 303, LeftShift = 304, RightControl = 305, LeftControl = 306, + RightAlt = 307, LeftAlt = 308, RightCommand = 309, LeftCommand = 310, + LeftWindows = 311, RightWindows = 312, AltGr = 313, + Help = 315, Print = 316, SysReq = 317, Break = 318, Menu = 319, + Mouse0 = 323, Mouse1, Mouse2, Mouse3, Mouse4, Mouse5, Mouse6, + JoystickButton0 = 330, JoystickButton1, JoystickButton2, JoystickButton3, + JoystickButton4, JoystickButton5, JoystickButton6, JoystickButton7, + JoystickButton8, JoystickButton9, JoystickButton10, JoystickButton11, + JoystickButton12, JoystickButton13, JoystickButton14, JoystickButton15, + JoystickButton16, JoystickButton17, JoystickButton18, JoystickButton19 + } +} diff --git a/SVSim.BattleEngine/Shim/UnityEngine/UnityShim.cs b/SVSim.BattleEngine/Shim/UnityEngine/UnityShim.cs index 2b64fad..b8f4e83 100644 --- a/SVSim.BattleEngine/Shim/UnityEngine/UnityShim.cs +++ b/SVSim.BattleEngine/Shim/UnityEngine/UnityShim.cs @@ -10,18 +10,50 @@ namespace UnityEngine // ---- value types (Vector2/3, Quaternion, Color, Mathf, Debug live in Primitives.cs) ---- public struct Vector4 { public float x, y, z, w; public Vector4(float x, float y, float z, float w){ this.x=x; this.y=y; this.z=z; this.w=w; } } public struct Color32 { public byte r, g, b, a; public Color32(byte r, byte g, byte b, byte a){ this.r=r; this.g=g; this.b=b; this.a=a; } } - public struct Bounds { public Vector3 center, size; public Bounds(Vector3 c, Vector3 s){ center=c; size=s; } } - public struct Rect { public float x, y, width, height; public Rect(float x, float y, float w, float h){ this.x=x; this.y=y; width=w; height=h; } } - public struct Matrix4x4 { public static Matrix4x4 identity => new Matrix4x4(); } - public struct Plane { } - public struct Ray { } - public struct RaycastHit { } + public struct Bounds + { + public Vector3 center, size; + public Bounds(Vector3 c, Vector3 s) { center = c; size = s; } + public Vector3 extents { get => size * 0.5f; set => size = value * 2f; } + public Vector3 min { get => center - extents; set { } } + public Vector3 max { get => center + extents; set { } } + public bool Contains(Vector3 p) => false; + public void Encapsulate(Vector3 p) { } + public void Encapsulate(Bounds b) { } + public void Expand(float amount) { } + public bool Intersects(Bounds b) => false; + public float SqrDistance(Vector3 p) => 0f; + } + public struct Rect + { + public float x, y, width, height; + public Rect(float x, float y, float w, float h) { this.x = x; this.y = y; width = w; height = h; } + public float xMin { get => x; set { width += x - value; x = value; } } + public float yMin { get => y; set { height += y - value; y = value; } } + public float xMax { get => x + width; set => width = value - x; } + public float yMax { get => y + height; set => height = value - y; } + public Vector2 center { get => new Vector2(x + width / 2, y + height / 2); set { } } + public Vector2 size { get => new Vector2(width, height); set { width = value.x; height = value.y; } } + public Vector2 position { get => new Vector2(x, y); set { x = value.x; y = value.y; } } + public Vector2 min { get => new Vector2(xMin, yMin); set { } } + public Vector2 max { get => new Vector2(xMax, yMax); set { } } + public bool Contains(Vector2 p) => false; + public bool Contains(Vector3 p) => false; + public bool Overlaps(Rect other) => false; + public static Rect MinMaxRect(float xmin, float ymin, float xmax, float ymax) => new Rect(xmin, ymin, xmax - xmin, ymax - ymin); + } + public struct Matrix4x4 { public static Matrix4x4 identity => new Matrix4x4(); public Vector3 MultiplyPoint(Vector3 p) => p; public Vector3 MultiplyPoint3x4(Vector3 p) => p; public Vector3 MultiplyVector(Vector3 v) => v; public static Matrix4x4 TRS(Vector3 t, Quaternion r, Vector3 s) => identity; public Matrix4x4 inverse => identity; } + public struct Plane { public Plane(Vector3 normal, Vector3 point) { } public bool Raycast(Ray r, out float enter) { enter = 0; return false; } } + public struct Ray { public Ray(Vector3 origin, Vector3 dir) { this.origin = origin; this.direction = dir; } public Vector3 origin; public Vector3 direction; public Vector3 GetPoint(float d) => origin; } + public struct RaycastHit { public Vector3 point; public Vector3 normal; public float distance; public Collider collider; public Transform transform; public GameObject gameObject; } + public struct RaycastHit2D { public Vector3 point; public Vector3 normal; public float distance; public Collider2D collider; public Transform transform; } public struct LayerMask { public int value; public static int NameToLayer(string n) => 0; public static implicit operator int(LayerMask m) => m.value; } // ---- core object model ---- public class Object { public string name { get; set; } + public HideFlags hideFlags { get; set; } public int GetInstanceID() => 0; public override string ToString() => name ?? base.ToString(); public static void Destroy(Object o) { } @@ -29,7 +61,12 @@ namespace UnityEngine public static void DestroyImmediate(Object o) { } public static void DontDestroyOnLoad(Object o) { } public static T Instantiate(T original) where T : Object => original; + public static T Instantiate(T original, Transform parent) where T : Object => original; + public static T Instantiate(T original, Vector3 pos, Quaternion rot) where T : Object => original; + public static Object Instantiate(Object original) => original; public static T FindObjectOfType() where T : Object => null; + public static T[] FindObjectsOfType() where T : Object => new T[0]; + public static Object FindObjectOfType(System.Type t) => null; public static bool operator ==(Object a, Object b) => ReferenceEquals(a, b); public static bool operator !=(Object a, Object b) => !ReferenceEquals(a, b); public static implicit operator bool(Object o) => !ReferenceEquals(o, null); @@ -41,10 +78,25 @@ namespace UnityEngine { public Transform transform => null; public GameObject gameObject => null; + public string tag { get; set; } public T GetComponent() => default; + public T GetComponent(string type) => default; + public Component GetComponent(System.Type t) => null; + public Component GetComponent(string t) => null; public T GetComponentInChildren() => default; + public T GetComponentInChildren(bool includeInactive) => default; public T[] GetComponentsInChildren() => new T[0]; + public T[] GetComponentsInChildren(bool includeInactive) => new T[0]; public T GetComponentInParent() => default; + public T[] GetComponentsInParent() => new T[0]; + public T[] GetComponents() => new T[0]; + public Component[] GetComponents(System.Type t) => new Component[0]; + public void SendMessage(string method) { } + public void SendMessage(string method, object value) { } + public void SendMessage(string method, object value, SendMessageOptions options) { } + public void SendMessage(string method, SendMessageOptions options) { } + public void BroadcastMessage(string method) { } + public bool CompareTag(string t) => false; } public class Behaviour : Component { public bool enabled { get; set; } } @@ -80,6 +132,26 @@ namespace UnityEngine public int GetSiblingIndex() => 0; public void SetAsLastSibling() { } public void SetAsFirstSibling() { } + public Vector3 lossyScale => Vector3.one; + public Vector3 forward { get => Vector3.forward; set { } } + public Vector3 up { get => Vector3.up; set { } } + public Vector3 right { get => Vector3.right; set { } } + public Transform root => this; + public Vector3 TransformPoint(Vector3 p) => p; + public Vector3 InverseTransformPoint(Vector3 p) => p; + public Vector3 TransformDirection(Vector3 d) => d; + public Vector3 InverseTransformDirection(Vector3 d) => d; + public Vector3 TransformVector(Vector3 v) => v; + public Vector3 InverseTransformVector(Vector3 v) => v; + public void Translate(Vector3 t) { } + public void Translate(float x, float y, float z) { } + public void Rotate(Vector3 e) { } + public void Rotate(float x, float y, float z) { } + public void RotateAround(Vector3 point, Vector3 axis, float angle) { } + public void LookAt(Transform t) { } + public void LookAt(Vector3 p) { } + public void DetachChildren() { } + public Transform Find(string n, bool includeInactive) => null; public IEnumerator GetEnumerator() { yield break; } } @@ -87,17 +159,35 @@ namespace UnityEngine { public GameObject() { } public GameObject(string name) { this.name = name; } + public GameObject(string name, params Type[] components) { this.name = name; } public Transform transform => null; + public GameObject gameObject => this; public bool activeSelf => false; public bool activeInHierarchy => false; public int layer { get; set; } public string tag { get; set; } public void SetActive(bool value) { } public T GetComponent() => default; + public Component GetComponent(Type t) => null; + public Component GetComponent(string t) => null; public T GetComponentInChildren() => default; + public T GetComponentInChildren(bool includeInactive) => default; + public T[] GetComponentsInChildren() => new T[0]; + public T[] GetComponentsInChildren(bool includeInactive) => new T[0]; + public T GetComponentInParent() => default; + public T[] GetComponents() => new T[0]; + public Component[] GetComponents(Type t) => new Component[0]; public T AddComponent() where T : Component => default; public Component AddComponent(Type t) => null; + public void SendMessage(string method) { } + public void SendMessage(string method, object value) { } + public void SendMessage(string method, object value, SendMessageOptions options) { } + public void SendMessage(string method, SendMessageOptions options) { } + public void BroadcastMessage(string method) { } + public bool CompareTag(string t) => false; public static GameObject Find(string n) => null; + public static GameObject FindGameObjectWithTag(string t) => null; + public static GameObject[] FindGameObjectsWithTag(string t) => new GameObject[0]; } public class ScriptableObject : Object { } @@ -108,27 +198,111 @@ namespace UnityEngine public class SkinnedMeshRenderer : Renderer { } public class SpriteRenderer : Renderer { public Sprite sprite { get; set; } } public class MeshFilter : Component { public Mesh mesh { get; set; } } - public class ParticleSystem : Component { } + public class ParticleSystem : Component + { + public void Play() { } public void Play(bool withChildren) { } + public void Stop() { } public void Stop(bool withChildren) { } + public void Pause() { } public void Clear() { } public void Clear(bool withChildren) { } + public void Simulate(float t) { } + public bool isPlaying => false; public bool isPaused => false; public bool isStopped => true; + public bool IsAlive() => false; public bool IsAlive(bool withChildren) => false; + public int particleCount => 0; + public MainModule main => default; + public EmissionModule emission => default; + public int GetParticles(Particle[] p) => 0; + public void SetParticles(Particle[] p, int n) { } + public struct MainModule { public float duration; public float startLifetime; public bool loop; public float startSpeed; } + public struct EmissionModule { public bool enabled; public float rateOverTime; } + public struct Particle { public Vector3 position; public Vector3 velocity; public Color32 startColor; public float remainingLifetime; } + } public class ParticleSystemRenderer : Renderer { } public class LODGroup : Component { } public class Collider : Component { public bool enabled { get; set; } } public class BoxCollider : Collider { } public class Rigidbody : Component { } public class Rigidbody2D : Component { } - public class Material : Object { public Material() { } public Material(Material src) { } public Color color { get; set; } public void SetFloat(string n, float v) { } public void SetColor(string n, Color c) { } public void SetTexture(string n, Texture t) { } } - public class Mesh : Object { } - public class Texture : Object { } - public class Texture2D : Texture { public Texture2D(int w, int h) { } } - public class RenderTexture : Texture { } - public class Sprite : Object { } - public class Shader : Object { public static Shader Find(string n) => null; } - public class AnimationClip : Object { } - public class Animation : Component { } - public class Animator : Component { } - public class AnimationCurve { } - public class AudioClip : Object { } - public class AudioSource : Component { } - public class Camera : Component { public static Camera main => null; } + public class Material : Object + { + public Material() { } + public Material(Material src) { } + public Material(Shader shader) { } + public Color color { get; set; } + public Shader shader { get; set; } + public Texture mainTexture { get; set; } + public Vector2 mainTextureOffset { get; set; } + public Vector2 mainTextureScale { get; set; } + public int renderQueue { get; set; } + public string[] shaderKeywords { get; set; } + public float GetFloat(string n) => 0f; + public int GetInt(string n) => 0; + public Color GetColor(string n) => Color.white; + public Texture GetTexture(string n) => null; + public Vector4 GetVector(string n) => default; + public void SetFloat(string n, float v) { } + public void SetInt(string n, int v) { } + public void SetColor(string n, Color c) { } + public void SetTexture(string n, Texture t) { } + public void SetVector(string n, Vector4 v) { } + public void SetMatrix(string n, Matrix4x4 m) { } + public void SetTextureOffset(string n, Vector2 o) { } + public void EnableKeyword(string k) { } + public void DisableKeyword(string k) { } + public bool IsKeywordEnabled(string k) => false; + public bool HasProperty(string n) => false; + } + public class Mesh : Object { public Vector3[] vertices { get; set; } public int[] triangles { get; set; } public void Clear() { } public void RecalculateBounds() { } } + public class Texture : Object { public int width => 0; public int height => 0; } + public class Texture2D : Texture { public Texture2D(int w, int h) { } public void Apply() { } public Color GetPixel(int x, int y) => Color.white; public void SetPixel(int x, int y, Color c) { } } + public class RenderTexture : Texture { public RenderTexture(int w, int h, int depth) { } public RenderTexture(int w, int h, int depth, RenderTextureFormat fmt) { } public void Create() { } public void Release() { } public bool IsCreated() => false; public static RenderTexture active { get; set; } } + public class Sprite : Object { public Rect rect => default; public Texture2D texture => null; public static Sprite Create(Texture2D t, Rect r, Vector2 pivot) => null; } + public class Shader : Object { public static Shader Find(string n) => null; public bool isSupported => true; } + public class AnimationClip : Object { public float length => 0f; public string name { get; set; } } + public class Animation : Component, IEnumerable { public AnimationClip clip { get; set; } public bool isPlaying => false; public void Play() { } public void Play(string n) { } public void Stop() { } public IEnumerator GetEnumerator() { yield break; } } + public class Animator : Component + { + public void SetTrigger(string n) { } public void SetTrigger(int id) { } + public void SetBool(string n, bool v) { } public void SetInteger(string n, int v) { } + public void SetFloat(string n, float v) { } + public bool GetBool(string n) => false; public int GetInteger(string n) => 0; public float GetFloat(string n) => 0f; + public void Play(string n) { } public void Play(int hash) { } + public void SetLayerWeight(int layer, float w) { } + public float speed { get; set; } public bool enabled { get; set; } + } + public class AnimationCurve { public float Evaluate(float t) => 0f; } + public class AudioClip : Object { public float length => 0f; } + public class AudioSource : Component { public AudioClip clip { get; set; } public float volume { get; set; } public bool isPlaying => false; public bool loop { get; set; } public void Play() { } public void Stop() { } public void Pause() { } } + public class Camera : Component + { + public static Camera main => null; + public static Camera current => null; + public static int allCamerasCount => 0; + public static Camera[] allCameras => new Camera[0]; + public float nearClipPlane { get; set; } + public float farClipPlane { get; set; } + public float fieldOfView { get; set; } + public float orthographicSize { get; set; } + public bool orthographic { get; set; } + public float aspect { get; set; } + public float depth { get; set; } + public int cullingMask { get; set; } + public int pixelWidth => 1920; + public int pixelHeight => 1080; + public Rect rect { get; set; } + public Rect pixelRect { get; set; } + public Color backgroundColor { get; set; } + public CameraClearFlags clearFlags { get; set; } + public RenderTexture targetTexture { get; set; } + public Vector3 ViewportToWorldPoint(Vector3 p) => p; + public Vector3 WorldToViewportPoint(Vector3 p) => p; + public Vector3 ScreenToWorldPoint(Vector3 p) => p; + public Vector3 WorldToScreenPoint(Vector3 p) => p; + public Vector3 ViewportToScreenPoint(Vector3 p) => p; + public Vector3 ScreenToViewportPoint(Vector3 p) => p; + public Ray ScreenPointToRay(Vector3 p) => default; + public Ray ViewportPointToRay(Vector3 p) => default; + public void Render() { } + } + public enum CameraClearFlags { Skybox = 1, Color = 2, SolidColor = 2, Depth = 3, Nothing = 4 } public struct CharacterInfo { } // ---- coroutine machinery (never pumped headless; types must exist) ---- @@ -144,7 +318,9 @@ namespace UnityEngine // ---- enums (grow members as the compiler demands) ---- public enum FontStyle { Normal, Bold, Italic, BoldAndItalic } public enum TouchPhase { Began, Moved, Stationary, Ended, Canceled } - public enum KeyCode { None } + // KeyCode lives in UnityRuntime.cs (full enum). + [Flags] public enum HideFlags { None = 0, HideInHierarchy = 1, HideInInspector = 2, DontSaveInEditor = 4, NotEditable = 8, DontSaveInBuild = 16, DontUnloadUnusedAsset = 32, DontSave = 52, HideAndDontSave = 61 } + public enum SendMessageOptions { RequireReceiver, DontRequireReceiver } // ---- attributes: permissive ctors accept any compile-time attribute args ---- public class SerializeField : Attribute { } @@ -160,7 +336,45 @@ namespace UnityEngine public class MultilineAttribute : Attribute { public MultilineAttribute() { } public MultilineAttribute(int lines) { } } // ---- subsystem singletons / statics ---- - public static class Application { public static bool isEditor => false; public static bool isPlaying => true; public static string persistentDataPath => ""; } - public static class Time { public static float deltaTime => 0f; public static float time => 0f; public static float unscaledDeltaTime => 0f; public static int frameCount => 0; } - public static class Screen { public static int width => 1920; public static int height => 1080; } + public static class Application + { + public static bool isEditor => false; + public static bool isPlaying => true; + public static bool isMobilePlatform => false; + public static string persistentDataPath => ""; + public static string dataPath => ""; + public static string temporaryCachePath => ""; + public static string version => "1.0"; + public static string identifier => ""; + public static int targetFrameRate { get; set; } + public static RuntimePlatform platform => RuntimePlatform.WindowsPlayer; + public static SystemLanguage systemLanguage => SystemLanguage.English; + public static void Quit() { } + public static event System.Action focusChanged { add { } remove { } } + } + public enum RuntimePlatform { WindowsPlayer, OSXPlayer, IPhonePlayer, Android, WindowsEditor, OSXEditor, LinuxPlayer } + public enum SystemLanguage { English, Japanese, ChineseSimplified, ChineseTraditional, Korean, French, German, Unknown } + public static class Time + { + public static float deltaTime => 0f; + public static float time => 0f; + public static float unscaledTime => 0f; + public static float unscaledDeltaTime => 0f; + public static float fixedDeltaTime => 0.02f; + public static float realtimeSinceStartup => 0f; + public static float timeScale { get; set; } + public static int frameCount => 0; + public static float timeSinceLevelLoad => 0f; + } + public static class Screen + { + public static int width => 1920; + public static int height => 1080; + public static float dpi => 96f; + public static ScreenOrientation orientation { get; set; } + public static bool fullScreen { get; set; } + public static Resolution currentResolution => default; + } + public enum ScreenOrientation { Portrait, PortraitUpsideDown, LandscapeLeft, LandscapeRight, AutoRotation } + public struct Resolution { public int width; public int height; public int refreshRate; } }