diff --git a/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiPrefabCache.cs b/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiPrefabCache.cs index 898c6500..2e941e84 100644 --- a/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiPrefabCache.cs +++ b/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiPrefabCache.cs @@ -5,8 +5,6 @@ using UnityEditor; using UnityEngine; - -[CreateAssetMenu(fileName = "CrossMapCfg", menuName = "Tools/AxiPrefabCachec", order = 0)] public class AxiPrefabCache : ScriptableObject { public List caches = new List(); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs index 56f3a4d3..d900c388 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/App.cs @@ -47,6 +47,8 @@ namespace AxibugEmuOnline.Client.ClientCore #endif public static void Init( bool isTest = false, string testSrvIP = "") { + log = new LogManager(OnLogOut); + //其他平台必要的初始化 if (UnityEngine.Application.platform == RuntimePlatform.PSP2) { @@ -54,9 +56,6 @@ namespace AxibugEmuOnline.Client.ClientCore } settings = new AppSettings(); - - log = new LogManager(); - LogManager.OnLog += OnNoSugarNetLog; network = new NetworkHelper(); login = new AppLogin(); chat = new AppChat(); @@ -187,20 +186,20 @@ namespace AxibugEmuOnline.Client.ClientCore { App.log.Info("停止"); } - static void OnNoSugarNetLog(int LogLevel, string msg) + static void OnLogOut(int LogLevel, string msg) { E_LogType logType = (E_LogType)LogLevel; switch (logType) { case E_LogType.Debug: case E_LogType.Info: - Debug.Log("[AxiEmu]:" + msg); + Debug.Log("[AxiNet]:" + msg); break; case E_LogType.Warning: - Debug.LogWarning("[AxiEmu]:" + msg); + Debug.LogWarning("[AxiNet]:" + msg); break; case E_LogType.Error: - Debug.LogError("[AxiEmu]:" + msg); + Debug.LogError("[AxiNet]:" + msg); break; } } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiHttp/AxiHttp.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiHttp/AxiHttp.cs index d4bd6df4..76fb09c5 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiHttp/AxiHttp.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiHttp/AxiHttp.cs @@ -14,9 +14,12 @@ using System.Threading; public static class PSVThread { + +#if UNITY_PSP2 static AutoResetEvent autoEvent = new AutoResetEvent(false); static Queue qActs = new Queue(); static Queue qWork = new Queue(); +#endif public static void DoTask(Action act) { @@ -85,7 +88,7 @@ public static class AxiHttp public static long index = 0; static int singlePkgMaxRead = 1024; - public class WaitAxiRequest : UnityEngine.CustomYieldInstruction + public class WaitAxiRequest : UnityEngine.CustomYieldInstruction { public AxiRespInfo mReqAsync; public WaitAxiRequest(AxiRespInfo reqAsync) diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Common/ObjectPoolAuto.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Common/ObjectPoolAuto.cs new file mode 100644 index 00000000..515c1cd0 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Common/ObjectPoolAuto.cs @@ -0,0 +1,404 @@ +using AxibugEmuOnline.Client.ClientCore; +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; + +namespace AxibugEmuOnline.Client.Common +{ + public static class ObjectPoolAuto + { + /************************************************************************************************************************/ + + /// + /// 获取或者创建一个新的 + /// + /// Remember to 需要回收参见这个 + public static T Acquire() + where T : class, new() + => ObjectPool.Acquire(); + + /// + /// 获取或者创建一个新的 + /// + /// Remember to 需要回收参见这个 + public static void Acquire(out T item) + where T : class, new() + => item = ObjectPool.Acquire(); + /************************************************************************************************************************/ + + /// + /// 回收对象 + /// + public static void Release(T item) + where T : class, new() + => ObjectPool.Release(item); + + /// + /// 回收对象 + /// + public static void Release(ref T item) where T : class, new() + { + if (item != null) + { + ObjectPool.Release(item); + item = null; + } + } + + /************************************************************************************************************************/ + public const string + NotClearError = " They must be cleared before being released to the pool and not modified after that."; + + /************************************************************************************************************************/ + + /// + /// 获取或创建List + /// + /// Remember to 回收参见此方法 + public static List AcquireList() + { + var list = ObjectPool>.Acquire(); + App.log.Assert(list.Count == 0, "A pooled list is not empty." + NotClearError); + return list; + } + + /// + /// 回收List + /// + public static void Release(List list) + { + list.Clear(); + ObjectPool>.Release(list); + } + + /************************************************************************************************************************/ + + /// + /// 获取或创建Queue + /// + /// Remember to 回收参见此方法 + public static Queue AcquireQueue() + { + var queue = ObjectPool>.Acquire(); + App.log.Assert(queue.Count == 0, "A pooled list is not empty." + NotClearError); + return queue; + } + + /// + /// 回收Queue + /// + public static void Release(Queue list) + { + list.Clear(); + ObjectPool>.Release(list); + } + + + /************************************************************************************************************************/ + + /// + /// 获取或创建HashSet + /// + public static HashSet AcquireSet() + { + var set = ObjectPool>.Acquire(); + App.log.Assert(set.Count == 0, "A pooled set is not empty." + NotClearError); + return set; + } + + /// + /// 释放HashSet + /// + public static void Release(HashSet set) + { + set.Clear(); + ObjectPool>.Release(set); + } + + /************************************************************************************************************************/ + + /// + /// 获取一个字符串StringBuilder + /// + /// Remember to 回收参见这个 + public static StringBuilder AcquireStringBuilder() + { + var builder = ObjectPool.Acquire(); + App.log.Assert(builder.Length == 0, $"A pooled {nameof(StringBuilder)} is not empty." + NotClearError); + return builder; + } + + /// + /// 回收 StringBuilder + /// + public static void Release(StringBuilder builder) + { + builder.Length = 0; + ObjectPool.Release(builder); + } + + /// + /// 回收 StringBuilder + /// + public static string ReleaseToString(this StringBuilder builder) + { + var result = builder.ToString(); + Release(builder); + return result; + } + + /************************************************************************************************************************/ + + private static class Cache + { + public static readonly Dictionary, T>> + Results = new Dictionary, T>>(); + } + + /// + /// 此方法主要用于频繁绘制缓存,比如说GUI绘制 + /// + public static T GetCachedResult(Func function) + { + var method = function.Method; + if (!Cache.Results.TryGetValue(method, out var result)) + { + + result = new KeyValuePair, T>(function, function()); + Cache.Results.Add(method, result); + } + else if (result.Key != function) + { + App.log.Warning( + $"{nameof(GetCachedResult)}<{typeof(T).Name}>" + + $" was previously called on {method.Name} with a different target." + + " This likely means that a new delegate is being passed into every call" + + " so it can't actually return the same cached object."); + } + + return result.Value; + } + + /************************************************************************************************************************/ + + public static class Disposable + { + /************************************************************************************************************************/ + + /// + /// Calls to get a spare if + /// + public static IDisposable Acquire(out T item) + where T : class, new() + => ObjectPool.Disposable.Acquire(out item); + + /************************************************************************************************************************/ + + /// + /// Calls to get a spare if + /// + public static IDisposable AcquireList(out List list) + { + var disposable = ObjectPool>.Disposable.Acquire(out list, onRelease: (l) => l.Clear()); + App.log.Assert(list.Count == 0, "A pooled list is not empty." + NotClearError); + return disposable; + } + + /************************************************************************************************************************/ + + /// + /// Calls to get a spare if + /// + public static IDisposable AcquireSet(out HashSet set) + { + var disposable = ObjectPool>.Disposable.Acquire(out set, onRelease: (s) => s.Clear()); + App.log.Assert(set.Count == 0, "A pooled set is not empty." + NotClearError); + return disposable; + } + + /************************************************************************************************************************/ + } + /************************************************************************************************************************/ + } + + public static class ObjectPool where T : class, new() + { + /************************************************************************************************************************/ + + private static readonly List + Items = new List(); + + /************************************************************************************************************************/ + + /// The number of spare items currently in the pool. + public static int Count + { + get => Items.Count; + set + { + var count = Items.Count; + if (count < value) + { + if (Items.Capacity < value) + Items.Capacity = NextPowerOfTwo(value); + + do + { + Items.Add(new T()); + count++; + } + while (count < value); + + } + else if (count > value) + { + Items.RemoveRange(value, count - value); + } + } + } + + public static int NextPowerOfTwo(int value) + { + if (value <= 0) + { + throw new ArgumentException("Value must be greater than zero."); + } + + int powerOfTwo = 1; + while (powerOfTwo < value) + { + powerOfTwo <<= 1; // equivalent to multiplying by 2 + } + + return powerOfTwo; + } + + /************************************************************************************************************************/ + + /// + /// If the is less than the specified value, this method increases it to that value by + /// creating new objects. + /// + public static void SetMinCount(int count) + { + if (Count < count) + Count = count; + } + + /************************************************************************************************************************/ + + /// The of the internal list of spare items. + public static int Capacity + { + get => Items.Capacity; + set + { + if (Items.Count > value) + Items.RemoveRange(value, Items.Count - value); + Items.Capacity = value; + } + } + + /************************************************************************************************************************/ + + /// Returns a spare item if there are any, or creates a new one. + /// Remember to it when you are done. + public static T Acquire() + { + var count = Items.Count; + if (count == 0) + { + return new T(); + } + else + { + count--; + var item = Items[count]; + Items.RemoveAt(count); + + return item; + } + } + + /************************************************************************************************************************/ + + /// Adds the `item` to the list of spares so it can be reused. + public static void Release(T item) + { + Items.Add(item); + + } + + /************************************************************************************************************************/ + + /// Returns a description of the state of this pool. + public static string GetDetails() + { + return + $"{typeof(T).Name}" + + $" ({nameof(Count)} = {Items.Count}" + + $", {nameof(Capacity)} = {Items.Capacity}" + + ")"; + } + + /************************************************************************************************************************/ + + /// + /// An system to allow pooled objects to be acquired and released within using + /// statements instead of needing to manually release everything. + /// + public sealed class Disposable : IDisposable + { + /************************************************************************************************************************/ + + private static readonly List LazyStack = new List(); + + private static int _ActiveDisposables; + + private T _Item; + private Action _OnRelease; + + /************************************************************************************************************************/ + + private Disposable() { } + + /// + /// Calls to set the `item` and returns an + /// that will call on the `item` when disposed. + /// + public static IDisposable Acquire(out T item, Action onRelease = null) + { + Disposable disposable; + + if (LazyStack.Count <= _ActiveDisposables) + { + LazyStack.Add(disposable = new Disposable()); + } + else + { + disposable = LazyStack[_ActiveDisposables]; + } + + _ActiveDisposables++; + + disposable._Item = item = ObjectPool.Acquire(); + disposable._OnRelease = onRelease; + return disposable; + } + + /************************************************************************************************************************/ + + void IDisposable.Dispose() + { + _OnRelease?.Invoke(_Item); + Release(_Item); + _ActiveDisposables--; + } + + /************************************************************************************************************************/ + } + } +} + + diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Common/ObjectPoolAuto.cs.meta b/AxibugEmuOnline.Client/Assets/Script/AppMain/Common/ObjectPoolAuto.cs.meta new file mode 100644 index 00000000..c70f62d8 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Common/ObjectPoolAuto.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: ca23a07857cb5674d9e563ca515e70d0 \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Initer.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Initer.cs index 1a03268c..077f2634 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Initer.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Initer.cs @@ -18,16 +18,22 @@ namespace AxibugEmuOnline.Client #if UNITY_EDITOR public bool bTest = false; public string mTestSrvIP = "192.168.0.47"; + public bool bEditorUUID = false; #endif private void Awake() { #if UNITY_EDITOR App.Init(bTest, mTestSrvIP); + dev_UUID = SystemInfo.deviceUniqueIdentifier; + if (bEditorUUID) + { + dev_UUID += "_Editor"; + } #else App.Init(this); -#endif dev_UUID = SystemInfo.deviceUniqueIdentifier; +#endif m_refs = Instantiate(IMPORTENT, transform).GetComponent(); } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/Filter/FilterManager.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/Filter/FilterManager.cs index 79b038d3..d02cca7a 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/Filter/FilterManager.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/Filter/FilterManager.cs @@ -1,5 +1,4 @@ using AxibugEmuOnline.Client.ClientCore; -using Sony.Vita.Dialog; using System; using System.Collections.Generic; using System.Linq; diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/LogManager.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/LogManager.cs index 26024cc5..d128377c 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/LogManager.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/LogManager.cs @@ -2,6 +2,11 @@ { public class LogManager { + public LogManager(OnLogHandler logOut) + { + OnLog += logOut; + } + public enum E_LogType : byte { Info = 0, @@ -18,7 +23,7 @@ /// /// 内部输出 /// - public static event OnLogHandler OnLog; + static event OnLogHandler OnLog; public void Info(string str) { @@ -40,6 +45,14 @@ Log(E_LogType.Error, str); } + public void Assert(bool conditional, string message) + { + if (!conditional) + { + Debug(message); + } + } + public void Log(E_LogType logtype, string str) { OnLog?.Invoke((int)logtype, str); diff --git a/AxibugEmuOnline.Server/Properties/PublishProfiles/FolderProfile.pubxml.user b/AxibugEmuOnline.Server/Properties/PublishProfiles/FolderProfile.pubxml.user index 3ac9d7b5..880c1b01 100644 --- a/AxibugEmuOnline.Server/Properties/PublishProfiles/FolderProfile.pubxml.user +++ b/AxibugEmuOnline.Server/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - True|2024-12-11T02:52:05.7940446Z||;True|2024-12-04T22:26:53.2238425+08:00||;True|2024-12-04T22:26:10.9572308+08:00||;True|2024-12-04T21:24:20.1913809+08:00||;True|2024-12-04T21:24:02.9590471+08:00||;True|2024-12-04T01:43:54.7646411+08:00||;True|2024-12-04T01:22:11.8117030+08:00||;True|2024-12-04T01:20:06.5770785+08:00||;True|2024-12-04T01:16:31.6391421+08:00||;True|2024-12-04T01:12:43.4697251+08:00||;True|2024-12-04T01:07:04.8333668+08:00||;True|2024-12-04T00:59:23.6611648+08:00||;True|2024-12-04T00:27:05.0229247+08:00||;True|2024-12-03T23:50:48.5712706+08:00||;True|2024-12-03T23:47:47.1095592+08:00||;True|2024-12-03T20:24:57.4098592+08:00||;True|2024-12-03T20:16:36.9886489+08:00||;True|2024-12-03T20:15:52.5482738+08:00||;True|2024-12-02T20:10:07.8192795+08:00||;True|2024-11-28T19:58:55.3995125+08:00||;True|2024-09-14T16:39:29.4677979+08:00||;True|2024-09-14T16:38:22.2398996+08:00||;True|2024-09-13T13:39:28.9591993+08:00||;True|2024-09-12T17:48:43.1521740+08:00||;True|2024-09-12T17:43:57.0504432+08:00||;True|2024-09-12T17:19:48.6392091+08:00||;True|2024-09-12T13:38:45.0141937+08:00||;False|2024-09-12T13:37:57.6131232+08:00||;True|2024-06-28T16:25:59.3159172+08:00||;True|2024-06-28T15:30:49.8257235+08:00||; + True|2025-01-02T07:36:28.7979053Z||;True|2025-01-02T15:31:33.8583976+08:00||;True|2024-12-11T10:52:05.7940446+08:00||;True|2024-12-04T22:26:53.2238425+08:00||;True|2024-12-04T22:26:10.9572308+08:00||;True|2024-12-04T21:24:20.1913809+08:00||;True|2024-12-04T21:24:02.9590471+08:00||;True|2024-12-04T01:43:54.7646411+08:00||;True|2024-12-04T01:22:11.8117030+08:00||;True|2024-12-04T01:20:06.5770785+08:00||;True|2024-12-04T01:16:31.6391421+08:00||;True|2024-12-04T01:12:43.4697251+08:00||;True|2024-12-04T01:07:04.8333668+08:00||;True|2024-12-04T00:59:23.6611648+08:00||;True|2024-12-04T00:27:05.0229247+08:00||;True|2024-12-03T23:50:48.5712706+08:00||;True|2024-12-03T23:47:47.1095592+08:00||;True|2024-12-03T20:24:57.4098592+08:00||;True|2024-12-03T20:16:36.9886489+08:00||;True|2024-12-03T20:15:52.5482738+08:00||;True|2024-12-02T20:10:07.8192795+08:00||;True|2024-11-28T19:58:55.3995125+08:00||;True|2024-09-14T16:39:29.4677979+08:00||;True|2024-09-14T16:38:22.2398996+08:00||;True|2024-09-13T13:39:28.9591993+08:00||;True|2024-09-12T17:48:43.1521740+08:00||;True|2024-09-12T17:43:57.0504432+08:00||;True|2024-09-12T17:19:48.6392091+08:00||;True|2024-09-12T13:38:45.0141937+08:00||;False|2024-09-12T13:37:57.6131232+08:00||;True|2024-06-28T16:25:59.3159172+08:00||;True|2024-06-28T15:30:49.8257235+08:00||; \ No newline at end of file diff --git a/AxibugEmuOnline.Server/Properties/PublishProfiles/FolderProfile1.pubxml b/AxibugEmuOnline.Server/Properties/PublishProfiles/FolderProfile1.pubxml new file mode 100644 index 00000000..2e6e038f --- /dev/null +++ b/AxibugEmuOnline.Server/Properties/PublishProfiles/FolderProfile1.pubxml @@ -0,0 +1,18 @@ + + + + + Release + Any CPU + bin\Release\net9.0\publish\win-x64\ + FileSystem + <_TargetId>Folder + net9.0 + win-x64 + false + false + true + + \ No newline at end of file diff --git a/AxibugEmuOnline.Server/Properties/PublishProfiles/FolderProfile1.pubxml.user b/AxibugEmuOnline.Server/Properties/PublishProfiles/FolderProfile1.pubxml.user new file mode 100644 index 00000000..7d6c2dc2 --- /dev/null +++ b/AxibugEmuOnline.Server/Properties/PublishProfiles/FolderProfile1.pubxml.user @@ -0,0 +1,10 @@ + + + + + False|2025-01-02T07:36:18.1906464Z||;False|2025-01-02T15:36:06.5622643+08:00||;True|2024-12-27T18:24:49.7554320+08:00||; + + + \ No newline at end of file