考虑PSVita,修改C#编写中的高版本out特性,为定义外置

This commit is contained in:
sin365 2025-11-05 09:48:51 +08:00
parent 5ebc5ee4fb
commit a62ce0e171
34 changed files with 231 additions and 82 deletions

View File

@ -438,7 +438,8 @@ public class AxiProjectToolsStatistics : EditorWindow
int DirtyCount = 0; int DirtyCount = 0;
foreach (var node in cache.nodes) foreach (var node in cache.nodes)
{ {
GameObject targetNodePathObj = GetNodeByLink(cache.FullPath, node.link, out string errStr); string errStr;
GameObject targetNodePathObj = GetNodeByLink(cache.FullPath, node.link, out errStr);
if (targetNodePathObj == null) if (targetNodePathObj == null)
{ {
errLog.Add(errStr); errLog.Add(errStr);

View File

@ -0,0 +1,69 @@
#if UNITY_EDITOR
using AxibugEmuOnline.Client.Network;
using Google.Protobuf;
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using UnityEditor;
public static class GenCode
{
const string TEMPLATE = @"
namespace [NAMESPACE]
{
public sealed partial class [CLASSNAME] : IResetable
{
public void Reset()
{[RESETCODE]
}
}
}
";
[MenuItem("项目工具/生成Protobuff Reset代码文件")]
public static void GenResetCode()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("using AxibugEmuOnline.Client.Network;");
var msgInterfaceType = typeof(IMessage);
var protoMsgTypes = typeof(NetMsg).Assembly.GetExportedTypes().Where(t => msgInterfaceType.IsAssignableFrom(t)).ToArray();
var flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.GetProperty;
foreach (var msgType in protoMsgTypes)
{
if (msgType.IsAbstract) continue;
var props = msgType.GetProperties(flag);
StringBuilder resetCodeSB = new StringBuilder();
foreach (var prop in props)
{
resetCodeSB.AppendLine();
if (prop.PropertyType.IsValueType)
resetCodeSB.Append($"\t\t\t{prop.Name} = default;");
else if (typeof(IBufferMessage).IsAssignableFrom(prop.PropertyType))
resetCodeSB.Append($"\t\t\t{prop.Name}?.Reset();");
else if (typeof(IList).IsAssignableFrom(prop.PropertyType))
resetCodeSB.Append($"\t\t\t{prop.Name}?.Clear();");
else if (typeof(string) == prop.PropertyType)
resetCodeSB.Append($"\t\t\t{prop.Name} = string.Empty;");
else if (typeof(ByteString) == prop.PropertyType)
resetCodeSB.Append($"\t\t\t{prop.Name} = Google.Protobuf.ByteString.Empty;");
else throw new Exception($"Not Impl Reset Op {msgType}.{prop.Name} : {prop.PropertyType}");
}
var code = TEMPLATE
.Replace("[NAMESPACE]", msgType.Namespace)
.Replace("[CLASSNAME]", msgType.Name)
.Replace("[RESETCODE]", resetCodeSB.ToString());
sb.AppendLine(code);
}
File.WriteAllText("Assets/Script/AppMain/Network/ProtobufferMsgPool.g.cs", sb.ToString());
AssetDatabase.Refresh();
}
}
#endif

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 896973cf744f927409f700f4e9151a82

View File

@ -53,7 +53,8 @@ namespace AxiReplay
void CalcCacheCount() void CalcCacheCount()
{ {
double deltaMax = 0; double deltaMax = 0;
while (m_timePoints.TryRead(out double delta)) double delta;
while (m_timePoints.TryRead(out delta))
{ {
deltaMax = Math.Max(deltaMax, delta); deltaMax = Math.Max(deltaMax, delta);
} }

View File

@ -16,28 +16,33 @@ namespace Essgee.Utilities
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref uint* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref uint* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (uint*)intptr; ptr = (uint*)intptr;
} }
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref short* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref short* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (short*)intptr; ptr = (short*)intptr;
} }
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref ushort* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref ushort* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (ushort*)intptr; ptr = (ushort*)intptr;
} }
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref int* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref int* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (int*)intptr; ptr = (int*)intptr;
} }
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref byte* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref byte* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (byte*)intptr; ptr = (byte*)intptr;
} }

View File

@ -186,7 +186,8 @@ namespace Essgee.Emulation.Machines
//var (type, bootstrapRomData) = CartridgeLoader.Load(configuration.BiosRom, "ColecoVision BIOS"); //var (type, bootstrapRomData) = CartridgeLoader.Load(configuration.BiosRom, "ColecoVision BIOS");
//直接加载BootStrap //直接加载BootStrap
GameMetadataHandler.instance.gameMetaReources.GetDatBytes("Bootstrap/[BIOS] ColecoVision (USA, Europe).col", out byte[] bootstrapRomData); byte[] bootstrapRomData;
GameMetadataHandler.instance.gameMetaReources.GetDatBytes("Bootstrap/[BIOS] ColecoVision (USA, Europe).col", out bootstrapRomData);
bios = new ColecoCartridge(bootstrapRomData.Length, 0); bios = new ColecoCartridge(bootstrapRomData.Length, 0);
bios.LoadRom(bootstrapRomData); bios.LoadRom(bootstrapRomData);
} }

View File

@ -159,7 +159,8 @@ internal static class ObjectPoolAuto
public static T GetCachedResult<T>(Func<T> function) public static T GetCachedResult<T>(Func<T> function)
{ {
var method = function.Method; var method = function.Method;
if (!Cache<T>.Results.TryGetValue(method, out var result)) KeyValuePair<Func<T>, T> result;
if (!Cache<T>.Results.TryGetValue(method, out result))
{ {
result = new KeyValuePair<Func<T>, T>(function, function()); result = new KeyValuePair<Func<T>, T>(function, function());

View File

@ -18,7 +18,9 @@ namespace IngameDebugConsole
protected void OnValidate() protected void OnValidate()
{ {
if( preventFontCallback != null && TryGetComponent( out InputField inputField ) ) InputField inputField;
if ( preventFontCallback != null && TryGetComponent( out inputField ) )
{ {
preventFontCallback.SetValue( inputField, true ); preventFontCallback.SetValue( inputField, true );
UnityEditor.EditorApplication.delayCall += () => preventFontCallback.SetValue( inputField, false ); UnityEditor.EditorApplication.delayCall += () => preventFontCallback.SetValue( inputField, false );

View File

@ -151,7 +151,8 @@ namespace MAME.Core
public static T GetCachedResult<T>(Func<T> function) public static T GetCachedResult<T>(Func<T> function)
{ {
var method = function.Method; var method = function.Method;
if (!Cache<T>.Results.TryGetValue(method, out var result)) KeyValuePair<Func<T>, T> result;
if (!Cache<T>.Results.TryGetValue(method, out result))
{ {
result = new KeyValuePair<Func<T>, T>(function, function()); result = new KeyValuePair<Func<T>, T>(function, function());

View File

@ -420,28 +420,33 @@ namespace MAME.Core
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref uint* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref uint* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (uint*)intptr; ptr = (uint*)intptr;
} }
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref short* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref short* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (short*)intptr; ptr = (short*)intptr;
} }
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref ushort* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref ushort* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (ushort*)intptr; ptr = (ushort*)intptr;
} }
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref int* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref int* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (int*)intptr; ptr = (int*)intptr;
} }
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref byte* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref byte* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (byte*)intptr; ptr = (byte*)intptr;
} }

View File

@ -15,7 +15,8 @@ namespace MAME.Core
public static void Update() public static void Update()
{ {
int X, Y; int X, Y;
iMouse.MouseXY(out X, out Y, out byte[] MouseButtons); byte[] MouseButtons;
iMouse.MouseXY(out X, out Y, out MouseButtons);
deltaX = X - oldX; deltaX = X - oldX;
deltaY = Y - oldY; deltaY = Y - oldY;
oldX = X; oldX = X;

View File

@ -21,7 +21,8 @@ namespace MAME.Core
} }
public static RomInfo GetRomByName(string s1) public static RomInfo GetRomByName(string s1)
{ {
if (!dictName2Rom.TryGetValue(s1, out RomInfo info)) RomInfo info;
if (!dictName2Rom.TryGetValue(s1, out info))
return null; return null;
return info; return info;
} }

View File

@ -21,28 +21,33 @@ namespace StoicGooseUnity
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref uint* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref uint* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (uint*)intptr; ptr = (uint*)intptr;
} }
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref short* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref short* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (short*)intptr; ptr = (short*)intptr;
} }
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref ushort* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref ushort* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (ushort*)intptr; ptr = (ushort*)intptr;
} }
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref int* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref int* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (int*)intptr; ptr = (int*)intptr;
} }
public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref byte* ptr) public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref byte* ptr)
{ {
GetObjectPtr(srcObj, ref handle, out IntPtr intptr); IntPtr intptr;
GetObjectPtr(srcObj, ref handle, out intptr);
ptr = (byte*)intptr; ptr = (byte*)intptr;
} }

View File

@ -83,23 +83,26 @@ public abstract class AxiPlayerPrefsFileBase : IAxiPlayerPrefs
public float GetFloat(string key, float defaultValue) public float GetFloat(string key, float defaultValue)
{ {
AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out bool IsNew); bool IsNew;
AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out IsNew);
if (IsNew) if (IsNew)
kv.floatval = defaultValue; kv.floatval = defaultValue;
return kv.floatval; return kv.floatval;
} }
public int GetInt(string key, int defaultValue) public int GetInt(string key, int defaultValue)
{ {
AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out bool IsNew); bool IsNew;
AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out IsNew);
if (IsNew) if (IsNew)
kv.intval = defaultValue; kv.intval = defaultValue;
return kv.intval; return kv.intval;
} }
public string GetString(string key, string defaultValue) public string GetString(string key, string defaultValue)
{ {
AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out bool IsNew); bool IsNew;
AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out IsNew);
if (IsNew) if (IsNew)
kv.strval = defaultValue; kv.strval = defaultValue;
return kv.strval; return kv.strval;
@ -107,29 +110,33 @@ public abstract class AxiPlayerPrefsFileBase : IAxiPlayerPrefs
public float GetFloat(string key) public float GetFloat(string key)
{ {
AxiPlayerPrefsKeyValye kv = GetByKey(key, false, out bool _); bool val;
AxiPlayerPrefsKeyValye kv = GetByKey(key, false, out val);
if (kv != null) return kv.floatval; if (kv != null) return kv.floatval;
return default(float); return default(float);
} }
public int GetInt(string key) public int GetInt(string key)
{ {
AxiPlayerPrefsKeyValye kv = GetByKey(key, false, out bool _); bool val;
AxiPlayerPrefsKeyValye kv = GetByKey(key, false, out val);
if (kv != null) return kv.intval; if (kv != null) return kv.intval;
return default(int); return default(int);
} }
public string GetString(string key) public string GetString(string key)
{ {
AxiPlayerPrefsKeyValye kv = GetByKey(key, false, out bool _); bool val;
AxiPlayerPrefsKeyValye kv = GetByKey(key, false, out val);
if (kv != null) return kv.strval; if (kv != null) return kv.strval;
return string.Empty; return string.Empty;
} }
public void SetInt(string key, int value) public void SetInt(string key, int value)
{ {
AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out bool _); bool val;
AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out val);
if (kv.intval == value) if (kv.intval == value)
return; return;
kv.intval = value; kv.intval = value;
@ -137,8 +144,9 @@ public abstract class AxiPlayerPrefsFileBase : IAxiPlayerPrefs
} }
public void SetString(string key, string value) public void SetString(string key, string value)
{ {
AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out bool _); bool val;
AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out val);
if (string.Equals(kv.strval, value)) if (string.Equals(kv.strval, value))
return; return;
kv.strval = value; kv.strval = value;
@ -146,8 +154,9 @@ public abstract class AxiPlayerPrefsFileBase : IAxiPlayerPrefs
} }
public void SetFloat(string key, float value) public void SetFloat(string key, float value)
{ {
AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out bool _); bool val;
AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out val);
if (kv.floatval == value) if (kv.floatval == value)
return; return;
kv.floatval = value; kv.floatval = value;

View File

@ -162,7 +162,8 @@ namespace AxibugEmuOnline.Client.Common
public static T GetCachedResult<T>(Func<T> function) public static T GetCachedResult<T>(Func<T> function)
{ {
var method = function.Method; var method = function.Method;
if (!Cache<T>.Results.TryGetValue(method, out var result)) KeyValuePair<Func<T>, T> result;
if (!Cache<T>.Results.TryGetValue(method, out result))
{ {
result = new KeyValuePair<Func<T>, T>(function, function()); result = new KeyValuePair<Func<T>, T>(function, function());

View File

@ -88,7 +88,8 @@ namespace AxibugEmuOnline.Client
bool TryPushEmulatorFrame() bool TryPushEmulatorFrame()
{ {
if (SampleInputData(out var inputData)) INPUTDATA inputData;
if (SampleInputData(out inputData))
{ {
if (IsNetPlay) SendLocalInput(); if (IsNetPlay) SendLocalInput();

View File

@ -14,7 +14,8 @@ public sealed class DatabaseHandler
{ {
{ {
string wsc = "Bandai - WonderSwan Color.dat"; string wsc = "Bandai - WonderSwan Color.dat";
GetDatBytes(wsc, out byte[] loadedData); byte[] loadedData;
GetDatBytes(wsc, out loadedData);
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(loadedData)) using (System.IO.MemoryStream stream = new System.IO.MemoryStream(loadedData))
{ {
var root = new XmlRootAttribute("datafile") { IsNullable = true }; var root = new XmlRootAttribute("datafile") { IsNullable = true };
@ -26,7 +27,8 @@ public sealed class DatabaseHandler
{ {
string ws = "Bandai - WonderSwan.dat"; string ws = "Bandai - WonderSwan.dat";
GetDatBytes(ws, out byte[] loadedData); byte[] loadedData;
GetDatBytes(ws, out loadedData);
using (System.IO.MemoryStream stream = new System.IO.MemoryStream(loadedData)) using (System.IO.MemoryStream stream = new System.IO.MemoryStream(loadedData))
{ {
var root = new XmlRootAttribute("datafile") { IsNullable = true }; var root = new XmlRootAttribute("datafile") { IsNullable = true };

View File

@ -68,7 +68,7 @@ namespace AxibugEmuOnline.Client.Manager
} }
public void RecvLoginMsg(Protobuf_Login_RESP msg) public void RecvLoginMsg(Protobuf_Login_RESP msg)
{ {
if (msg.Status == LoginResultStatus.Ok) if (msg.Status == LoginResultStatus.Ok)
{ {
App.log.Info("登录成功"); App.log.Info("登录成功");

View File

@ -78,7 +78,8 @@ public abstract class FilterChainEffect : FilterEffect
{ {
var existoutput = m_passOutputTexNames[index]; var existoutput = m_passOutputTexNames[index];
var existoutputSize = m_passOutputTexSizes[index]; var existoutputSize = m_passOutputTexSizes[index];
if (m_outputCaches.TryGetValue(existoutput, out var passOutput)) RenderTexture passOutput;
if (m_outputCaches.TryGetValue(existoutput, out passOutput))
{ {
if (pass.Mat.HasTexture(existoutput)) if (pass.Mat.HasTexture(existoutput))
pass.Mat.SetTexture(existoutput, passOutput); pass.Mat.SetTexture(existoutput, passOutput);

View File

@ -28,13 +28,15 @@ namespace AxibugEmuOnline.Client.Settings
public T GetBinder<T>() where T : InternalEmuCoreBinder public T GetBinder<T>() where T : InternalEmuCoreBinder
{ {
m_bindersByType.TryGetValue(typeof(T), out var binder); InternalEmuCoreBinder binder;
m_bindersByType.TryGetValue(typeof(T), out binder);
return binder as T; return binder as T;
} }
public T GetBinder<T>(RomPlatformType romType) where T : InternalEmuCoreBinder public T GetBinder<T>(RomPlatformType romType) where T : InternalEmuCoreBinder
{ {
m_binders.TryGetValue(romType, out var binder); InternalEmuCoreBinder binder;
m_binders.TryGetValue(romType, out binder);
return binder as T; return binder as T;
} }
} }

View File

@ -258,12 +258,14 @@ public abstract class EmuCoreBinder<T> : InternalEmuCoreBinder,
public void SetBinding(T emuBtn, InputControl_C key, int settingSlot) public void SetBinding(T emuBtn, InputControl_C key, int settingSlot)
{ {
var device = key.Device; var device = key.Device;
m_registedDevices.TryGetValue(device.GetType(), out var inputDevice); InputDevice_D inputDevice;
m_registedDevices.TryGetValue(device.GetType(), out inputDevice);
Debug.Assert(inputDevice == device); Debug.Assert(inputDevice == device);
var setting = m_mapSetting[inputDevice]; var setting = m_mapSetting[inputDevice];
if (!setting.TryGetValue(emuBtn, out var settingList)) List<InputControl_C> settingList;
if (!setting.TryGetValue(emuBtn, out settingList))
{ {
settingList = new List<InputControl_C>(); settingList = new List<InputControl_C>();
setting[emuBtn] = settingList; setting[emuBtn] = settingList;
@ -277,10 +279,12 @@ public abstract class EmuCoreBinder<T> : InternalEmuCoreBinder,
public InputControl_C GetBinding(T emuBtn, InputDevice_D device, int settingSlot) public InputControl_C GetBinding(T emuBtn, InputDevice_D device, int settingSlot)
{ {
m_mapSetting.TryGetValue(device, out var mapSetting); MapSetting mapSetting;
m_mapSetting.TryGetValue(device, out mapSetting);
if (mapSetting == null) return null; if (mapSetting == null) return null;
mapSetting.TryGetValue(emuBtn, out var settingList); List<InputControl_C> settingList;
mapSetting.TryGetValue(emuBtn, out settingList);
if (settingList == null || settingSlot >= settingList.Count) return null; if (settingList == null || settingSlot >= settingList.Count) return null;
return settingList[settingSlot]; return settingList[settingSlot];
@ -293,7 +297,8 @@ public abstract class EmuCoreBinder<T> : InternalEmuCoreBinder,
foreach (var mapSettings in m_mapSetting.Values) foreach (var mapSettings in m_mapSetting.Values)
{ {
mapSettings.TryGetValue(emuBtn, out var bindControls); List<InputControl_C> bindControls;
mapSettings.TryGetValue(emuBtn, out bindControls);
if (bindControls != null) if (bindControls != null)
{ {
m_caches.AddRange(bindControls); m_caches.AddRange(bindControls);

View File

@ -28,7 +28,8 @@ namespace AxibugEmuOnline.Client.InputDevices
get => _forward[key]; get => _forward[key];
set set
{ {
if (_forward.TryGetValue(key, out var oldValue)) TValue oldValue;
if (_forward.TryGetValue(key, out oldValue))
_reverse.Remove(oldValue); _reverse.Remove(oldValue);
_forward[key] = value; _forward[key] = value;
_reverse[value] = key; _reverse[value] = key;
@ -78,7 +79,11 @@ namespace AxibugEmuOnline.Client.InputDevices
} }
public bool Contains(object key) => key is TKey k && _forward.ContainsKey(k); public bool Contains(object key) => key is TKey k && _forward.ContainsKey(k);
public bool Contains(KeyValuePair<TKey, TValue> item) => _forward.TryGetValue(item.Key, out var v) && v.Equals(item.Value); public bool Contains(KeyValuePair<TKey, TValue> item)
{
TValue v;
return _forward.TryGetValue(item.Key, out v) && v.Equals(item.Value);
}
public bool ContainsKey(TKey key) => _forward.ContainsKey(key); public bool ContainsKey(TKey key) => _forward.ContainsKey(key);
public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex) public void CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
@ -93,7 +98,8 @@ namespace AxibugEmuOnline.Client.InputDevices
public bool Remove(TKey key) public bool Remove(TKey key)
{ {
if (!_forward.Remove(key, out var value)) return false; TValue value;
if (!_forward.Remove(key, out value)) return false;
_reverse.Remove(value); _reverse.Remove(value);
return true; return true;
} }

View File

@ -40,7 +40,8 @@ namespace AxibugEmuOnline.Client.InputDevices
private void AxiScreenGamepad_OnGamepadDisactive(AxiScreenGamepad sender) private void AxiScreenGamepad_OnGamepadDisactive(AxiScreenGamepad sender)
{ {
if (m_devices.TryGetValue(sender, out var device)) ScreenGamepad_D device;
if (m_devices.TryGetValue(sender, out device))
{ {
m_devices.Remove(sender); m_devices.Remove(sender);
RaiseDeviceLost(device); RaiseDeviceLost(device);
@ -76,7 +77,8 @@ namespace AxibugEmuOnline.Client.InputDevices
{ {
if (device is ScreenGamepad_D) if (device is ScreenGamepad_D)
{ {
return m_devices.TryGetKey(device as ScreenGamepad_D, out var _); AxiScreenGamepad val;
return m_devices.TryGetKey(device as ScreenGamepad_D, out val);
} }
else else
{ {
@ -168,7 +170,8 @@ namespace AxibugEmuOnline.Client.InputDevices
{ {
if (inputDevice is ScreenGamepad_D) if (inputDevice is ScreenGamepad_D)
{ {
m_devices.TryGetKey(inputDevice as ScreenGamepad_D, out var realDeviceScript); AxiScreenGamepad realDeviceScript;
m_devices.TryGetKey(inputDevice as ScreenGamepad_D, out realDeviceScript);
return $"{realDeviceScript.GetType().Name}_{realDeviceScript.GetHashCode()}"; return $"{realDeviceScript.GetType().Name}_{realDeviceScript.GetHashCode()}";
} }
else return OnGetDeviceName(inputDevice); else return OnGetDeviceName(inputDevice);

View File

@ -108,7 +108,8 @@ On-Screen Keyboard这个是真正的屏幕软键盘。
private void RemoveDevice(InputDevice ipdev) private void RemoveDevice(InputDevice ipdev)
{ {
if (m_devices.TryGetValue(ipdev, out var device)) InputDevice_D device;
if (m_devices.TryGetValue(ipdev, out device))
{ {
RemoveDeviceMapper(device); RemoveDeviceMapper(device);
RaiseDeviceLost(device); RaiseDeviceLost(device);
@ -118,7 +119,8 @@ On-Screen Keyboard这个是真正的屏幕软键盘。
private T GetInputSystemDevice<T>(InputDevice_D device) where T : InputDevice private T GetInputSystemDevice<T>(InputDevice_D device) where T : InputDevice
{ {
m_devices.TryGetKey(device, out var ipDev); InputDevice ipDev;
m_devices.TryGetKey(device, out ipDev);
return ipDev as T; return ipDev as T;
} }
@ -132,7 +134,8 @@ On-Screen Keyboard这个是真正的屏幕软键盘。
protected override bool OnCheckOnline(InputDevice_D device) protected override bool OnCheckOnline(InputDevice_D device)
{ {
return m_devices.TryGetKey(device, out var _); InputDevice val;
return m_devices.TryGetKey(device, out val);
} }
private void IP_onDeviceChange(InputDevice device, InputDeviceChange changeType) private void IP_onDeviceChange(InputDevice device, InputDeviceChange changeType)
@ -171,7 +174,8 @@ On-Screen Keyboard这个是真正的屏幕软键盘。
{ {
var device_d = key.Device; var device_d = key.Device;
var mapper = m_deviceMapper[device_d]; var mapper = m_deviceMapper[device_d];
mapper.TryGetValue(key, out InputControl inputBtn); InputControl inputBtn;
mapper.TryGetValue(key, out inputBtn);
if (inputBtn != null) if (inputBtn != null)
return inputBtn; return inputBtn;
else else

View File

@ -11,7 +11,8 @@ namespace AxibugEmuOnline.Client
Dictionary<string, Action<byte[]>> m_completeCallback = new Dictionary<string, Action<byte[]>>(); Dictionary<string, Action<byte[]>> m_completeCallback = new Dictionary<string, Action<byte[]>>();
public void BeginDownload(string url, Action<byte[]> callback) public void BeginDownload(string url, Action<byte[]> callback)
{ {
if (m_downloadingTasks.TryGetValue(url, out var downloadProxy)) return; AxiHttpProxy.SendDownLoadProxy downloadProxy;
if (m_downloadingTasks.TryGetValue(url, out downloadProxy)) return;
m_completeCallback[url] = callback; m_completeCallback[url] = callback;
var downloadRequest = AxiHttpProxy.GetDownLoad($"{App.httpAPI.WebHost}/{url}"); var downloadRequest = AxiHttpProxy.GetDownLoad($"{App.httpAPI.WebHost}/{url}");
@ -20,7 +21,8 @@ namespace AxibugEmuOnline.Client
public float? GetDownloadProgress(string url) public float? GetDownloadProgress(string url)
{ {
m_downloadingTasks.TryGetValue(url, out var proxy); AxiHttpProxy.SendDownLoadProxy proxy;
m_downloadingTasks.TryGetValue(url, out proxy);
if (proxy == null) return null; if (proxy == null) return null;
return Mathf.Clamp01(proxy.downloadHandler.downLoadPr); return Mathf.Clamp01(proxy.downloadHandler.downLoadPr);

View File

@ -275,13 +275,14 @@ namespace AxibugEmuOnline.Client
private static void Add(SyncingFiles file) private static void Add(SyncingFiles file)
{ {
if (!m_syncFiles.TryGetValue(file.platform, out var mapper)) Dictionary<int, HashSet<SyncingFiles>> mapper;
if (!m_syncFiles.TryGetValue(file.platform, out mapper))
{ {
mapper = new Dictionary<int, HashSet<SyncingFiles>>(); mapper = new Dictionary<int, HashSet<SyncingFiles>>();
m_syncFiles.Add(file.platform, mapper); m_syncFiles.Add(file.platform, mapper);
} }
HashSet<SyncingFiles> syncingTables;
if (!mapper.TryGetValue(file.romID, out var syncingTables)) if (!mapper.TryGetValue(file.romID, out syncingTables))
{ {
syncingTables = new HashSet<SyncingFiles>(); syncingTables = new HashSet<SyncingFiles>();
mapper[file.romID] = syncingTables; mapper[file.romID] = syncingTables;
@ -296,12 +297,15 @@ namespace AxibugEmuOnline.Client
public static void Remove(SaveFile savFile) public static void Remove(SaveFile savFile)
{ {
SyncingFiles file = new SyncingFiles { romID = savFile.RomID, platform = savFile.EmuPlatform, slotIndex = savFile.SlotIndex }; SyncingFiles file = new SyncingFiles { romID = savFile.RomID, platform = savFile.EmuPlatform, slotIndex = savFile.SlotIndex };
if (!m_syncFiles.TryGetValue(file.platform, out var mapper))
Dictionary<int, HashSet<SyncingFiles>> mapper;
if (!m_syncFiles.TryGetValue(file.platform, out mapper))
{ {
return; return;
} }
if (!mapper.TryGetValue(savFile.RomID, out var syncingTables)) HashSet<SyncingFiles> syncingTables;
if (!mapper.TryGetValue(savFile.RomID, out syncingTables))
{ {
return; return;
} }

View File

@ -15,7 +15,8 @@ namespace AxibugEmuOnline.Client
FSM.ChangeState<SyncedState>(); FSM.ChangeState<SyncedState>();
return; return;
} }
Host.GetSavData(out byte[] savData, out byte[] screenData); byte[] savData, screenData;
Host.GetSavData(out savData, out screenData);
Host.CloudAPI.SendUpLoadGameSav(Host.RomID, Host.SlotIndex, Host.Sequecen, savData, screenData); Host.CloudAPI.SendUpLoadGameSav(Host.RomID, Host.SlotIndex, Host.Sequecen, savData, screenData);
Host.SetSavingFlag(); Host.SetSavingFlag();

View File

@ -100,7 +100,8 @@ namespace AxibugEmuOnline.Client.Tools
public T GetState<T>() where T : State, new() public T GetState<T>() where T : State, new()
{ {
m_states.TryGetValue(typeof(T), out var value); State value;
m_states.TryGetValue(typeof(T), out value);
return value as T; return value as T;
} }

View File

@ -201,7 +201,8 @@ namespace AxibugEmuOnline.Client
public void BeginRecordGameAudio() public void BeginRecordGameAudio()
{ {
App.emu.Core.GetAudioParams(out int frequency, out int channels); int frequency, channels;
App.emu.Core.GetAudioParams(out frequency, out channels);
BeginRecording(frequency, channels); BeginRecording(frequency, channels);
} }
@ -275,7 +276,8 @@ namespace AxibugEmuOnline.Client
this.SourceSampleRate = SourceSampleRate; this.SourceSampleRate = SourceSampleRate;
this.AxiAudioPullHandle = audiohandle; this.AxiAudioPullHandle = audiohandle;
NeedsResampling = SourceSampleRate != AudioSettings.outputSampleRate; NeedsResampling = SourceSampleRate != AudioSettings.outputSampleRate;
AudioSettings.GetDSPBufferSize(out int bufferLength, out int numBuffers); int bufferLength, numBuffers;
AudioSettings.GetDSPBufferSize(out bufferLength, out numBuffers);
} }
} }
class WaveHeader class WaveHeader

View File

@ -62,8 +62,10 @@ namespace AxibugEmuOnline.Client.Network
public void UnregisterCMD<T>(int cmd, Action<T> callback) where T : IMessage public void UnregisterCMD<T>(int cmd, Action<T> callback) where T : IMessage
{ {
if (delegateWrappers.TryGetValue(typeof(T), out var wrapperDict) && Dictionary<Delegate, Action<IMessage>> wrapperDict;
wrapperDict.TryGetValue(callback, out var wrappedCallback)) Action<IMessage> wrappedCallback;
if (delegateWrappers.TryGetValue(typeof(T), out wrapperDict) &&
wrapperDict.TryGetValue(callback, out wrappedCallback))
{ {
InterUnregisterCMD(cmd, wrappedCallback); InterUnregisterCMD(cmd, wrappedCallback);
wrapperDict.Remove(callback); wrapperDict.Remove(callback);
@ -242,7 +244,8 @@ namespace AxibugEmuOnline.Client.Network
} }
private static Type GetTypeByCmd(int cmd) private static Type GetTypeByCmd(int cmd)
{ {
if (cmd2MsgTypeDict.TryGetValue(cmd, out var type)) return type; Type type;
if (cmd2MsgTypeDict.TryGetValue(cmd, out type)) return type;
return null; return null;
} }
@ -251,7 +254,8 @@ namespace AxibugEmuOnline.Client.Network
/// </summary> /// </summary>
private HashSet<Action<IMessage>> GetNetEventDicList(int cmd) private HashSet<Action<IMessage>> GetNetEventDicList(int cmd)
{ {
if (netEventDic.TryGetValue(cmd, out var tempList) && tempList != null) HashSet<Action<IMessage>> tempList;
if (netEventDic.TryGetValue(cmd, out tempList) && tempList != null)
return tempList; return tempList;
return null; return null;
} }

View File

@ -2,6 +2,7 @@
using Google.Protobuf; using Google.Protobuf;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEditor.Search;
namespace AxibugEmuOnline.Client.Network namespace AxibugEmuOnline.Client.Network
{ {
@ -11,7 +12,8 @@ namespace AxibugEmuOnline.Client.Network
public IMessage Get(Type msgType) public IMessage Get(Type msgType)
{ {
if (!_pool.TryGetValue(msgType, out var queue)) Queue<IResetable> queue;
if (!_pool.TryGetValue(msgType, out queue))
{ {
queue = new Queue<IResetable>(); queue = new Queue<IResetable>();
_pool[msgType] = queue; _pool[msgType] = queue;
@ -36,7 +38,8 @@ namespace AxibugEmuOnline.Client.Network
if (msg is IResetable resetableMsg) if (msg is IResetable resetableMsg)
{ {
var msgType = msg.GetType(); var msgType = msg.GetType();
if (!_pool.TryGetValue(msgType, out var queue)) Queue<IResetable> queue;
if (!_pool.TryGetValue(msgType, out queue))
{ {
queue = new Queue<IResetable>(); queue = new Queue<IResetable>();
_pool[msgType] = queue; _pool[msgType] = queue;

View File

@ -120,7 +120,8 @@ namespace AxibugEmuOnline.Client
public override void OnExcute(OptionUI optionUI, ref bool cancelHide) public override void OnExcute(OptionUI optionUI, ref bool cancelHide)
{ {
cancelHide = true; cancelHide = true;
m_savFile.GetSavData(out byte[] savData, out var _); byte[] data, savData;
m_savFile.GetSavData(out savData, out data);
if (savData != null) if (savData != null)
{ {
m_ingameUI.Core.LoadStateFromBytes(savData); m_ingameUI.Core.LoadStateFromBytes(savData);

View File

@ -330,7 +330,8 @@ namespace AxibugEmuOnline.Client
private void CreateRuntimeMenuItem(InternalOptionMenu menuData) private void CreateRuntimeMenuItem(InternalOptionMenu menuData)
{ {
m_menuUI_templates.TryGetValue(menuData.MenuUITemplateType, out var template); OptionUI_MenuItem template;
m_menuUI_templates.TryGetValue(menuData.MenuUITemplateType, out template);
if (template == null) if (template == null)
{ {
throw new NotImplementedException($"{menuData.GetType().Name}指定的MenuUI类型实例未在OptionUI中找到"); throw new NotImplementedException($"{menuData.GetType().Name}指定的MenuUI类型实例未在OptionUI中找到");

View File

@ -79,7 +79,8 @@ namespace AxibugEmuOnline.Client
{ {
var savTime = MenuData.SavFile.GetSavTimeUTC().ToLocalTime(); var savTime = MenuData.SavFile.GetSavTimeUTC().ToLocalTime();
UI_SavTime.text = $"{savTime.Year}/{savTime.Month:00}/{savTime.Day:00}\n{savTime.Hour}:{savTime.Minute}:{savTime.Second}"; UI_SavTime.text = $"{savTime.Year}/{savTime.Month:00}/{savTime.Day:00}\n{savTime.Hour}:{savTime.Minute}:{savTime.Second}";
MenuData.SavFile.GetSavData(out byte[] _, out byte[] screenShotData); byte[] _tempdata, screenShotData;
MenuData.SavFile.GetSavData(out _tempdata, out screenShotData);
if (!m_screenTex) m_screenTex = new Texture2D(1, 1); if (!m_screenTex) m_screenTex = new Texture2D(1, 1);