diff --git a/.gitignore b/.gitignore index df089d85..3c7ff2ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,133 +1,15 @@ -# This .gitignore file should be placed at the root of your Unity project directory -# -# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore -# -/[Ll]ibrary/ -/[Tt]emp/ -/[Oo]bj/ -/[Bb]uild/ -/[Bb]uilds/ -/[Ll]ogs/ -/[Mm]emoryCaptures/ -/EditorBuild/ -# /[Aa]ssets/TResources/DLL/ -/[Aa]ssets/StreamingAssets -/BuildBundleInfo/ -[Aa]ssets/AATest/ -[Aa]ssets/AATest.meta -# Asset meta data should only be ignored when the corresponding asset is also ignored -!/[Aa]ssets/**/*.meta - -# Uncomment this line if you wish to ignore the asset store tools plugin -# /[Aa]ssets/AssetStoreTools* - -# Autogenerated Jetbrains Rider plugin -[Aa]ssets/Plugins/Editor/JetBrains* - -# Visual Studio cache directory -.vs/ - -# Gradle cache directory -.gradle/ - -# Autogenerated VS/MD/Consulo solution and project files -ExportedObj/ -.consulo/ -*.csproj -*.unityproj -*.sln -*.suo -*.tmp -*.user -*.userprefs -*.pidb -*.booproj -*.svd -*.pdb -*.mdb -*.opendb -*.VC.db - -# Unity3D generated meta files -*.pidb.meta -*.pdb.meta -*.mdb.meta - -# Unity3D generated file on crash reports -sysinfo.txt - -# Builds -*.apk - -# Crashlytics generated file -crashlytics-build.properties - -# TEnginePersistentDataPath -TEnginePersistentDataPath/ - -# Hotfix -TEngineHotUpdate/bin -TEngineHotUpdate/obj - -#HybirdCLR(HuaTuo) -/HybirdCLRData/ -[Hh]ybridCLRData/ - - -#AATemp -[Aa]ssets/AATemp/ -[Aa]ssets/AATemp.meta - -#Rider -/.idea/ - -# ABConfig -[Aa]ssets/BuildConfig/ -[Aa]ssets/BuildConfig.meta - -[Aa]ssets/StreamingAssets/ -[Aa]ssets/StreamingAssets.meta -Assets/HybridCLRBuildCache/AssetBundleOutput.meta -Assets/HybridCLRBuildCache/AssetBundleOutput/StandaloneWindows.meta -Assets/HybridCLRBuildCache.meta -Assets/HybridCLRBuildCache/AssetBundleSourceData.meta -Assets/HybridCLRBuildCache/AssetBundleSourceData/StandaloneWindows.meta - -#Bundles -Bundles/ - -#Sandbox -Sandbox/ +UnityProject/UserSettings/Layouts/default-2021.dwlt +UnityProject/UserSettings/Search.settings #Luban -Luban/.cache.meta +Tools/Luban/ +Tools/Luban.ClientServer/ +Configs/.cache.meta GenerateDatas/ -#HybridCLR -Assets/HybridCLRData.meta -UserSettings/Search.settings +#FileServer +Tools/FileServer/AssetRoot -#Unity UserSettings -UserSettings/Search.index -UserSettings/Layouts/default-2021.dwlt - -#UnityOnlineServiceData -Assets/UnityOnlineServiceData.meta -Assets/UnityOnlineServiceData - -#MAC -.DS_Store - -#Server_sln -DotNet/.idea/ -DotNet/App/obj/ -DotNet/Core/obj/ -DotNet/Logic/obj/ -DotNet/ThirdParty/obj/ - -Bin/ - -#Server_Config -DotNet/Config/GameConfig -DotNet/Config/ProtoBuf/OpCode.Cache +UnityProject/ProjectSettings/CommonBurstAotSettings.json +UnityProject/ProjectSettings/BurstAotSettings_StandaloneWindows.json diff --git a/Assets/AssetRaw/UI/GMPanel.prefab b/Assets/AssetRaw/UI/GMPanel.prefab deleted file mode 100644 index 4e19cd2b..00000000 --- a/Assets/AssetRaw/UI/GMPanel.prefab +++ /dev/null @@ -1,3000 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1 &109996 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 457598} - m_Layer: 0 - m_Name: Line - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!4 &457598 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 109996} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 5370576790709736058} - - {fileID: 5370576790709736328} - - {fileID: 5370576790709736054} - - {fileID: 5370576790709736052} - - {fileID: 5370576790709736050} - - {fileID: 5370576790709736048} - - {fileID: 5370576790709736062} - - {fileID: 5370576790709736060} - - {fileID: 5370576790709736330} - m_Father: {fileID: 22427082} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!1 &113614 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 22413614} - - component: {fileID: 22213614} - - component: {fileID: 11413616} - m_Layer: 5 - m_Name: Image - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &22413614 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 113614} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 22427080} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: -0.000030517578} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &22213614 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 113614} - m_CullTransparentMesh: 0 ---- !u!114 &11413616 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 113614} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.18965517, g: 0.18965517, b: 0.18965517, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &124070 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 22424070} - - component: {fileID: 11424070} - m_Layer: 5 - m_Name: InputText Input Caret - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &22424070 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 124070} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 22458672} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -0.5} - m_SizeDelta: {x: -20, y: -13} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &11424070 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 124070} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IgnoreLayout: 1 - m_MinWidth: -1 - m_MinHeight: -1 - m_PreferredWidth: -1 - m_PreferredHeight: -1 - m_FlexibleWidth: -1 - m_FlexibleHeight: -1 - m_LayoutPriority: 1 ---- !u!1 &127076 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 22427076} - - component: {fileID: 22227078} - - component: {fileID: 11427088} - m_Layer: 5 - m_Name: TextDisplay - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!224 &22427076 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 127076} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 9183884789717483776} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 170, y: -12.5} - m_SizeDelta: {x: 340, y: 25} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &22227078 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 127076} - m_CullTransparentMesh: 0 ---- !u!114 &11427088 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 127076} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 12800000, guid: aedb1ecac0b0c134f9ef343cfdbf49ac, type: 3} - m_FontSize: 20 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 0 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: ---- !u!1 &127078 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 22427080} - m_Layer: 5 - m_Name: Panel - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &22427080 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 127078} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 22413614} - - {fileID: 3586912872020723759} - m_Father: {fileID: 22433872} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 67} - m_SizeDelta: {x: 0, y: -135} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!1 &127082 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 22427082} - - component: {fileID: 22327044} - - component: {fileID: 11427092} - m_Layer: 5 - m_Name: GMPanel - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &22427082 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 127082} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 1558318686151050005} - - {fileID: 22433872} - - {fileID: 457598} - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!223 &22327044 -Canvas: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 127082} - m_Enabled: 1 - serializedVersion: 3 - m_RenderMode: 2 - m_Camera: {fileID: 0} - m_PlaneDistance: 100 - m_PixelPerfect: 0 - m_ReceivesEvents: 1 - m_OverrideSorting: 1 - m_OverridePixelPerfect: 0 - m_SortingBucketNormalizedSize: 0 - m_AdditionalShaderChannelsFlag: 25 - m_SortingLayerID: 0 - m_SortingOrder: 0 - m_TargetDisplay: 0 ---- !u!114 &11427092 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 127082} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IgnoreReversedGraphics: 1 - m_BlockingObjects: 0 - m_BlockingMask: - serializedVersion: 2 - m_Bits: 55 ---- !u!1 &133872 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 22433872} - - component: {fileID: 22268914} - - component: {fileID: 11468914} - m_Layer: 5 - m_Name: center - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &22433872 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 133872} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 22427080} - - {fileID: 22458672} - - {fileID: 22499142} - - {fileID: 224597927930311180} - - {fileID: 224627476836101448} - m_Father: {fileID: 22427082} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 450, y: 900} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &22268914 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 133872} - m_CullTransparentMesh: 0 ---- !u!114 &11468914 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 133872} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.1882353, g: 0.1882353, b: 0.1882353, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &158670 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 22458670} - - component: {fileID: 22258670} - - component: {fileID: 11458668} - m_Layer: 5 - m_Name: Placeholder - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &22458670 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 158670} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 22458672} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -0.5} - m_SizeDelta: {x: -20, y: -13} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &22258670 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 158670} - m_CullTransparentMesh: 0 ---- !u!114 &11458668 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 158670} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 30 - m_FontStyle: 2 - m_BestFit: 0 - m_MinSize: 2 - m_MaxSize: 40 - m_Alignment: 0 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: Enter text... ---- !u!1 &158672 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 22458672} - - component: {fileID: 22258672} - - component: {fileID: 11458670} - - component: {fileID: 11458672} - m_Layer: 5 - m_Name: InputText - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &22458672 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 158672} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 22424070} - - {fileID: 22458670} - - {fileID: 22458674} - m_Father: {fileID: 22433872} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 0} - m_AnchoredPosition: {x: 0, y: 68} - m_SizeDelta: {x: 0, y: 51} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &22258672 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 158672} - m_CullTransparentMesh: 0 ---- !u!114 &11458670 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 158672} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!114 &11458672 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 158672} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 0 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Highlighted - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 11458670} - m_TextComponent: {fileID: 11458674} - m_Placeholder: {fileID: 11458668} - m_ContentType: 0 - m_InputType: 0 - m_AsteriskChar: 42 - m_KeyboardType: 0 - m_LineType: 0 - m_HideMobileInput: 0 - m_CharacterValidation: 0 - m_CharacterLimit: 0 - m_OnSubmit: - m_PersistentCalls: - m_Calls: [] - m_OnDidEndEdit: - m_PersistentCalls: - m_Calls: [] - m_OnValueChanged: - m_PersistentCalls: - m_Calls: [] - m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_CustomCaretColor: 0 - m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} - m_Text: - m_CaretBlinkRate: 1.7 - m_CaretWidth: 1 - m_ReadOnly: 0 - m_ShouldActivateOnSelect: 1 ---- !u!1 &158674 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 22458674} - - component: {fileID: 22258674} - - component: {fileID: 11458674} - m_Layer: 5 - m_Name: Text - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &22458674 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 158674} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 22458672} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -0.5} - m_SizeDelta: {x: -20, y: -13} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &22258674 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 158674} - m_CullTransparentMesh: 0 ---- !u!114 &11458674 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 158674} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 30 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 2 - m_MaxSize: 40 - m_Alignment: 0 - m_AlignByGeometry: 0 - m_RichText: 0 - m_HorizontalOverflow: 1 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: ---- !u!1 &199142 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 22499142} - - component: {fileID: 22299142} - - component: {fileID: 11499144} - - component: {fileID: 11499142} - m_Layer: 5 - m_Name: BtnClose - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &22499142 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 199142} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 5370576790709644850} - m_Father: {fileID: 22433872} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 1, y: 1} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 50, y: 50} - m_Pivot: {x: 1, y: 1} ---- !u!222 &22299142 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 199142} - m_CullTransparentMesh: 0 ---- !u!114 &11499144 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 199142} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!114 &11499142 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 199142} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 0 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Highlighted - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 11499144} - m_OnClick: - m_PersistentCalls: - m_Calls: [] ---- !u!1 &1377928252335766 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 224862973598623584} - - component: {fileID: 222423012872392302} - - component: {fileID: 114462841935913398} - - component: {fileID: 114151767960586756} - - component: {fileID: 8926493224171522001} - m_Layer: 5 - m_Name: ButtonTemp - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!224 &224862973598623584 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1377928252335766} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 5302269272582789912} - m_Father: {fileID: 224597927930311180} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 100, y: -25} - m_SizeDelta: {x: 200, y: 50} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &222423012872392302 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1377928252335766} - m_CullTransparentMesh: 0 ---- !u!114 &114462841935913398 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1377928252335766} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!114 &114151767960586756 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1377928252335766} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 0 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Highlighted - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 114462841935913398} - m_OnClick: - m_PersistentCalls: - m_Calls: [] ---- !u!114 &8926493224171522001 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1377928252335766} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 95e66cfdf24a4c9d949625a7b449f54a, type: 3} - m_Name: - m_EditorClassIdentifier: - tweenTarget: {fileID: 0} - pressedScale: {x: 0.95, y: 0.95, z: 0.95} - duration: 0.1 - needRemoveAllTween: 1 ---- !u!1 &1473040200867122 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 224627476836101448} - - component: {fileID: 114281126043090278} - m_Layer: 5 - m_Name: RightQuickList - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &224627476836101448 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1473040200867122} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1.0001518, y: 1.0001518, z: 1.0001518} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 5302637319207519766} - m_Father: {fileID: 22433872} - m_RootOrder: 4 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 1, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 200, y: 0} - m_Pivot: {x: 0, y: 0.5} ---- !u!114 &114281126043090278 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1473040200867122} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8a8695521f0d02e499659fee002a26c2, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Padding: - m_Left: 0 - m_Right: 0 - m_Top: 0 - m_Bottom: 0 - m_ChildAlignment: 0 - m_StartCorner: 0 - m_StartAxis: 0 - m_CellSize: {x: 200, y: 50} - m_Spacing: {x: 0, y: 2} - m_Constraint: 1 - m_ConstraintCount: 1 ---- !u!1 &1514089831618850 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 224597927930311180} - - component: {fileID: 114408687673664964} - m_Layer: 5 - m_Name: LeftQuickList - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &224597927930311180 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1514089831618850} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 224862973598623584} - m_Father: {fileID: 22433872} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 200, y: 0} - m_Pivot: {x: 1, y: 0.5} ---- !u!114 &114408687673664964 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1514089831618850} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 8a8695521f0d02e499659fee002a26c2, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Padding: - m_Left: 0 - m_Right: 0 - m_Top: 0 - m_Bottom: 0 - m_ChildAlignment: 0 - m_StartCorner: 0 - m_StartAxis: 0 - m_CellSize: {x: 200, y: 50} - m_Spacing: {x: 0, y: 0} - m_Constraint: 0 - m_ConstraintCount: 2 ---- !u!1 &18618802382548027 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1880006169666239299} - - component: {fileID: 2234199390376188205} - - component: {fileID: 8212693084694154228} - m_Layer: 5 - m_Name: Text - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1880006169666239299 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 18618802382548027} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 3333904470847530211} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 170, y: -244.57494} - m_SizeDelta: {x: 340, y: 489.1496} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &2234199390376188205 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 18618802382548027} - m_CullTransparentMesh: 1 ---- !u!114 &8212693084694154228 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 18618802382548027} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 30 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 3 - m_MaxSize: 40 - m_Alignment: 0 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: ---- !u!1 &46330484961142090 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 3999121812702472049} - - component: {fileID: 1688821722835163898} - - component: {fileID: 8383563158968125843} - m_Layer: 5 - m_Name: Handle - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &3999121812702472049 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 46330484961142090} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 9042399952659313492} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 20, y: 20} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &1688821722835163898 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 46330484961142090} - m_CullTransparentMesh: 0 ---- !u!114 &8383563158968125843 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 46330484961142090} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &4385976318821334888 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 3586912872020723759} - - component: {fileID: 8498757465146356363} - - component: {fileID: 6143431380190213117} - - component: {fileID: 434540664626699535} - m_Layer: 5 - m_Name: Scroll View - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &3586912872020723759 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4385976318821334888} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 8325013484836239859} - - {fileID: 2130905818841278456} - m_Father: {fileID: 22427080} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -31.5} - m_SizeDelta: {x: 0, y: 43} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &8498757465146356363 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4385976318821334888} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 1aa08ab6e0800fa44ae55d278d1423e3, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Content: {fileID: 9183884789717483776} - m_Horizontal: 0 - m_Vertical: 1 - m_MovementType: 1 - m_Elasticity: 0.1 - m_Inertia: 1 - m_DecelerationRate: 0.135 - m_ScrollSensitivity: 1 - m_Viewport: {fileID: 8325013484836239859} - m_HorizontalScrollbar: {fileID: 0} - m_VerticalScrollbar: {fileID: 5132998792277039523} - m_HorizontalScrollbarVisibility: 2 - m_VerticalScrollbarVisibility: 2 - m_HorizontalScrollbarSpacing: -3 - m_VerticalScrollbarSpacing: -3 - m_OnValueChanged: - m_PersistentCalls: - m_Calls: [] ---- !u!222 &6143431380190213117 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4385976318821334888} - m_CullTransparentMesh: 0 ---- !u!114 &434540664626699535 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4385976318821334888} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 0} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &5354112836232479489 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 9042399952659313492} - m_Layer: 5 - m_Name: Sliding Area - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &9042399952659313492 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5354112836232479489} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 3999121812702472049} - m_Father: {fileID: 2130905818841278456} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: -20, y: -20} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!1 &5370576790695766162 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5370576790709644850} - - component: {fileID: 5370576790709838706} - - component: {fileID: 5370576790702823410} - m_Layer: 5 - m_Name: Text - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5370576790709644850 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695766162} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 22499142} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5370576790709838706 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695766162} - m_CullTransparentMesh: 0 ---- !u!114 &5370576790702823410 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695766162} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 20 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 2 - m_MaxSize: 40 - m_Alignment: 4 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: X ---- !u!1 &5370576790695857360 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5370576790709736062} - - component: {fileID: 5370576790709404862} - - component: {fileID: 5370576790702914366} - m_Layer: 5 - m_Name: Line - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5370576790709736062 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857360} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 457598} - m_RootOrder: 6 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -300, y: 0} - m_SizeDelta: {x: 2, y: 2000} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5370576790709404862 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857360} - m_CullTransparentMesh: 0 ---- !u!114 &5370576790702914366 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857360} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.5647059, g: 0.5647059, b: 0.5647059, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &5370576790695857362 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5370576790709736048} - - component: {fileID: 5370576790709404848} - - component: {fileID: 5370576790702914352} - m_Layer: 5 - m_Name: Line - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5370576790709736048 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857362} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 457598} - m_RootOrder: 5 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 150, y: 0} - m_SizeDelta: {x: 2, y: 2000} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5370576790709404848 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857362} - m_CullTransparentMesh: 0 ---- !u!114 &5370576790702914352 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857362} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.5647059, g: 0.5647059, b: 0.5647059, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &5370576790695857364 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5370576790709736050} - - component: {fileID: 5370576790709404850} - - component: {fileID: 5370576790702914354} - m_Layer: 5 - m_Name: Line - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5370576790709736050 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857364} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 457598} - m_RootOrder: 4 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 300, y: 0} - m_SizeDelta: {x: 2, y: 2000} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5370576790709404850 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857364} - m_CullTransparentMesh: 0 ---- !u!114 &5370576790702914354 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857364} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.5647059, g: 0.5647059, b: 0.5647059, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &5370576790695857366 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5370576790709736052} - - component: {fileID: 5370576790709404852} - - component: {fileID: 5370576790702914356} - m_Layer: 5 - m_Name: Line - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5370576790709736052 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857366} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 457598} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 2, y: 2000} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5370576790709404852 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857366} - m_CullTransparentMesh: 0 ---- !u!114 &5370576790702914356 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857366} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.5647059, g: 0.5647059, b: 0.5647059, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &5370576790695857372 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5370576790709736058} - - component: {fileID: 5370576790709404858} - - component: {fileID: 5370576790702914362} - m_Layer: 5 - m_Name: Line - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5370576790709736058 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857372} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 457598} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 100} - m_SizeDelta: {x: 2000, y: 2} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5370576790709404858 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857372} - m_CullTransparentMesh: 0 ---- !u!114 &5370576790702914362 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857372} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.5647059, g: 0.5647059, b: 0.5647059, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &5370576790695857374 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5370576790709736060} - - component: {fileID: 5370576790709404860} - - component: {fileID: 5370576790702914364} - m_Layer: 5 - m_Name: Line - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5370576790709736060 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857374} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 457598} - m_RootOrder: 7 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -150, y: 0} - m_SizeDelta: {x: 2, y: 2000} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5370576790709404860 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857374} - m_CullTransparentMesh: 0 ---- !u!114 &5370576790702914364 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857374} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.5647059, g: 0.5647059, b: 0.5647059, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &5370576790695857384 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5370576790709736054} - - component: {fileID: 5370576790709404854} - - component: {fileID: 5370576790702914358} - m_Layer: 5 - m_Name: Line - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5370576790709736054 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857384} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 457598} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: -200} - m_SizeDelta: {x: 2000, y: 2} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5370576790709404854 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857384} - m_CullTransparentMesh: 0 ---- !u!114 &5370576790702914358 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857384} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.5647059, g: 0.5647059, b: 0.5647059, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &5370576790695857386 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5370576790709736328} - - component: {fileID: 5370576790709404872} - - component: {fileID: 5370576790702914376} - m_Layer: 5 - m_Name: Line - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5370576790709736328 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857386} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 457598} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: -100} - m_SizeDelta: {x: 2000, y: 2} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5370576790709404872 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857386} - m_CullTransparentMesh: 0 ---- !u!114 &5370576790702914376 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857386} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.5647059, g: 0.5647059, b: 0.5647059, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &5370576790695857388 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5370576790709736330} - - component: {fileID: 5370576790709404874} - - component: {fileID: 5370576790702914378} - m_Layer: 5 - m_Name: Line - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5370576790709736330 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857388} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 457598} - m_RootOrder: 8 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 2000, y: 2} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5370576790709404874 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857388} - m_CullTransparentMesh: 0 ---- !u!114 &5370576790702914378 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5370576790695857388} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.5647059, g: 0.5647059, b: 0.5647059, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &5371606567585024880 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5302459429950045614} - - component: {fileID: 5304494792491252128} - - component: {fileID: 5412499365680950152} - m_Layer: 5 - m_Name: Text - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5302459429950045614 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5371606567585024880} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 5302637319207519766} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5304494792491252128 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5371606567585024880} - m_CullTransparentMesh: 0 ---- !u!114 &5412499365680950152 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5371606567585024880} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 25 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 2 - m_MaxSize: 40 - m_Alignment: 4 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: Button ---- !u!1 &5371880304303996158 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5302269272582789912} - - component: {fileID: 5305002484682660262} - - component: {fileID: 5408984482005445168} - m_Layer: 5 - m_Name: Text - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5302269272582789912 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5371880304303996158} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 224862973598623584} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5305002484682660262 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5371880304303996158} - m_CullTransparentMesh: 0 ---- !u!114 &5408984482005445168 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5371880304303996158} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 25 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 0 - m_MaxSize: 299 - m_Alignment: 4 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: Button ---- !u!1 &5371943423989401568 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5302637319207519766} - - component: {fileID: 5304725444799655704} - - component: {fileID: 5412966644088668352} - - component: {fileID: 5412644296352721778} - - component: {fileID: 5739967526536321831} - m_Layer: 5 - m_Name: ButtonTemp - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 0 ---- !u!224 &5302637319207519766 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5371943423989401568} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 0.9997236, y: 0.9997236, z: 0.9997236} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 5302459429950045614} - m_Father: {fileID: 224627476836101448} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 100, y: -25} - m_SizeDelta: {x: 200, y: 50} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5304725444799655704 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5371943423989401568} - m_CullTransparentMesh: 0 ---- !u!114 &5412966644088668352 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5371943423989401568} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!114 &5412644296352721778 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5371943423989401568} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 0 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Highlighted - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 5412966644088668352} - m_OnClick: - m_PersistentCalls: - m_Calls: [] ---- !u!114 &5739967526536321831 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5371943423989401568} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 95e66cfdf24a4c9d949625a7b449f54a, type: 3} - m_Name: - m_EditorClassIdentifier: - tweenTarget: {fileID: 0} - pressedScale: {x: 0.95, y: 0.95, z: 0.95} - duration: 0.1 - needRemoveAllTween: 1 ---- !u!1 &6335309373571002301 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2130905818841278456} - - component: {fileID: 6263002944673096089} - - component: {fileID: 6779960388779415824} - - component: {fileID: 5132998792277039523} - m_Layer: 5 - m_Name: Scrollbar Vertical - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &2130905818841278456 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6335309373571002301} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 9042399952659313492} - m_Father: {fileID: 3586912872020723759} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 1, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -55} - m_SizeDelta: {x: 20, y: -105} - m_Pivot: {x: 1, y: 1} ---- !u!222 &6263002944673096089 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6335309373571002301} - m_CullTransparentMesh: 0 ---- !u!114 &6779960388779415824 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6335309373571002301} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!114 &5132998792277039523 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6335309373571002301} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 2a4db7a114972834c8e4117be1d82ba3, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Highlighted - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 8383563158968125843} - m_HandleRect: {fileID: 3999121812702472049} - m_Direction: 2 - m_Value: 0 - m_Size: 1 - m_NumberOfSteps: 0 - m_OnValueChanged: - m_PersistentCalls: - m_Calls: [] ---- !u!1 &7673824418619918182 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 9183884789717483776} - - component: {fileID: 5255637919511563419} - - component: {fileID: 9091182439136768454} - m_Layer: 5 - m_Name: Content - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &9183884789717483776 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7673824418619918182} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 22427076} - - {fileID: 3333904470847530211} - m_Father: {fileID: 8325013484836239859} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0.0000038146973} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0, y: 1} ---- !u!114 &5255637919511563419 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7673824418619918182} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 59f8146938fff824cb5fd77236b75775, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Padding: - m_Left: 0 - m_Right: 0 - m_Top: 0 - m_Bottom: 0 - m_ChildAlignment: 0 - m_Spacing: 0 - m_ChildForceExpandWidth: 0 - m_ChildForceExpandHeight: 0 - m_ChildControlWidth: 0 - m_ChildControlHeight: 1 - m_ChildScaleWidth: 0 - m_ChildScaleHeight: 0 - m_ReverseArrangement: 0 ---- !u!114 &9091182439136768454 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7673824418619918182} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3} - m_Name: - m_EditorClassIdentifier: - m_HorizontalFit: 0 - m_VerticalFit: 2 ---- !u!1 &8079478090513115854 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1558318686151050005} - - component: {fileID: 5091200081109500671} - - component: {fileID: 5574224629625444049} - m_Layer: 5 - m_Name: Bg - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1558318686151050005 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8079478090513115854} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 22427082} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5091200081109500671 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8079478090513115854} - m_CullTransparentMesh: 1 ---- !u!114 &5574224629625444049 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8079478090513115854} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0, g: 0, b: 0, a: 0.46666667} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &8468027351246481588 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 3333904470847530211} - - component: {fileID: 429531869344369655} - - component: {fileID: 5842391223623699131} - m_Layer: 5 - m_Name: InputField - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &3333904470847530211 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8468027351246481588} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 1880006169666239299} - m_Father: {fileID: 9183884789717483776} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &429531869344369655 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8468027351246481588} - m_CullTransparentMesh: 1 ---- !u!114 &5842391223623699131 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8468027351246481588} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 0 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Selected - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 0} - m_TextComponent: {fileID: 0} - m_Placeholder: {fileID: 0} - m_ContentType: 0 - m_InputType: 0 - m_AsteriskChar: 42 - m_KeyboardType: 0 - m_LineType: 2 - m_HideMobileInput: 0 - m_CharacterValidation: 0 - m_CharacterLimit: 0 - m_OnSubmit: - m_PersistentCalls: - m_Calls: [] - m_OnDidEndEdit: - m_PersistentCalls: - m_Calls: [] - m_OnValueChanged: - m_PersistentCalls: - m_Calls: [] - m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_CustomCaretColor: 0 - m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} - m_Text: - m_CaretBlinkRate: 0.85 - m_CaretWidth: 1 - m_ReadOnly: 0 - m_ShouldActivateOnSelect: 0 ---- !u!1 &8665295936275395088 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 8325013484836239859} - - component: {fileID: 7509293525911778697} - - component: {fileID: 3907158282102209364} - - component: {fileID: 8607675702078589160} - m_Layer: 5 - m_Name: Viewport - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &8325013484836239859 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8665295936275395088} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 9183884789717483776} - m_Father: {fileID: 3586912872020723759} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0, y: 1} ---- !u!114 &7509293525911778697 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8665295936275395088} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 31a19414c41e5ae4aae2af33fee712f6, type: 3} - m_Name: - m_EditorClassIdentifier: - m_ShowMaskGraphic: 0 ---- !u!222 &3907158282102209364 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8665295936275395088} - m_CullTransparentMesh: 0 ---- !u!114 &8607675702078589160 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8665295936275395088} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10917, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 diff --git a/Assets/AssetRaw/UI/GMPanel.prefab.meta b/Assets/AssetRaw/UI/GMPanel.prefab.meta deleted file mode 100644 index eb512f3a..00000000 --- a/Assets/AssetRaw/UI/GMPanel.prefab.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 930f8bca659c7504b8fe431ee8c40e7b -PrefabImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AssetRaw/UI/LogUI.prefab.meta b/Assets/AssetRaw/UI/LogUI.prefab.meta deleted file mode 100644 index 9cea434d..00000000 --- a/Assets/AssetRaw/UI/LogUI.prefab.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: ad23fce0bd282924fa4aedb4da24684f -PrefabImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/AssetRaw/UI/NetWorkDemoUI.prefab b/Assets/AssetRaw/UI/NetWorkDemoUI.prefab deleted file mode 100644 index 27f49938..00000000 --- a/Assets/AssetRaw/UI/NetWorkDemoUI.prefab +++ /dev/null @@ -1,1888 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1 &200028900962926734 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5516143048718199109} - - component: {fileID: 3624900391551237124} - - component: {fileID: 9081802975426763189} - m_Layer: 5 - m_Name: Placeholder - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5516143048718199109 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 200028900962926734} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 2569723302594454181} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -0.5} - m_SizeDelta: {x: -20, y: -13} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &3624900391551237124 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 200028900962926734} - m_CullTransparentMesh: 1 ---- !u!114 &9081802975426763189 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 200028900962926734} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 30 - m_FontStyle: 2 - m_BestFit: 0 - m_MinSize: 3 - m_MaxSize: 40 - m_Alignment: 3 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: "\u8F93\u5165\u7528\u6237\u540D" ---- !u!1 &228610304149681099 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2661482540827288745} - - component: {fileID: 8059956825526392220} - - component: {fileID: 6750364511045006514} - - component: {fileID: 4295640278102793288} - m_Layer: 5 - m_Name: Viewport - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &2661482540827288745 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 228610304149681099} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 5225285352838474515} - m_Father: {fileID: 2913277243696531993} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: -17} - m_Pivot: {x: 0, y: 1} ---- !u!222 &8059956825526392220 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 228610304149681099} - m_CullTransparentMesh: 1 ---- !u!114 &6750364511045006514 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 228610304149681099} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10917, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!114 &4295640278102793288 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 228610304149681099} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 31a19414c41e5ae4aae2af33fee712f6, type: 3} - m_Name: - m_EditorClassIdentifier: - m_ShowMaskGraphic: 0 ---- !u!1 &987942439051806727 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5500452580366305332} - - component: {fileID: 1047442495027168704} - - component: {fileID: 3370946749493556016} - m_Layer: 5 - m_Name: Text (Legacy) - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5500452580366305332 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 987942439051806727} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 2569723302594454181} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -0.5} - m_SizeDelta: {x: -20, y: -13} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &1047442495027168704 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 987942439051806727} - m_CullTransparentMesh: 1 ---- !u!114 &3370946749493556016 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 987942439051806727} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 14 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 3 - m_AlignByGeometry: 0 - m_RichText: 0 - m_HorizontalOverflow: 1 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: ---- !u!1 &1354977820134472711 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5910359893906513543} - - component: {fileID: 5407814213624276446} - m_Layer: 5 - m_Name: m_itemTemp - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5910359893906513543 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1354977820134472711} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 1620476634722495211} - m_Father: {fileID: 5225285352838474515} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 163, y: 300} - m_Pivot: {x: 0, y: 1} ---- !u!114 &5407814213624276446 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1354977820134472711} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 29af6e9bda3402e4eba67bb72531e618, type: 3} - m_Name: - m_EditorClassIdentifier: - Padding: 0 ---- !u!1 &1517610079850641450 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 8498826217500179750} - - component: {fileID: 7902351646531252867} - - component: {fileID: 5122733431999654371} - m_Layer: 5 - m_Name: Text (Legacy) - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &8498826217500179750 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1517610079850641450} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1106430378647148480} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &7902351646531252867 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1517610079850641450} - m_CullTransparentMesh: 1 ---- !u!114 &5122733431999654371 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1517610079850641450} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 30 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 1 - m_MaxSize: 40 - m_Alignment: 4 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: "\u767B\u5F55" ---- !u!1 &1813490318935253646 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2362168986400613964} - - component: {fileID: 5350660492919270410} - - component: {fileID: 7665724797767963408} - m_Layer: 5 - m_Name: Text (Legacy) - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &2362168986400613964 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1813490318935253646} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 8401360966016205532} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5350660492919270410 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1813490318935253646} - m_CullTransparentMesh: 1 ---- !u!114 &7665724797767963408 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1813490318935253646} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 30 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 1 - m_MaxSize: 40 - m_Alignment: 4 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: "\u6CE8\u518C" ---- !u!1 &2294538527106005025 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2913277243696531993} - - component: {fileID: 7710575040041964180} - - component: {fileID: 6581535211515335702} - - component: {fileID: 7476014482463418513} - - component: {fileID: 2372447356726108403} - m_Layer: 5 - m_Name: m_scrollRect - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &2913277243696531993 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2294538527106005025} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 2661482540827288745} - m_Father: {fileID: 2683445927021212027} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -185.26123} - m_SizeDelta: {x: 0, y: 370.5225} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &7710575040041964180 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2294538527106005025} - m_CullTransparentMesh: 1 ---- !u!114 &6581535211515335702 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2294538527106005025} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 0.392} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!114 &7476014482463418513 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2294538527106005025} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 1aa08ab6e0800fa44ae55d278d1423e3, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Content: {fileID: 5225285352838474515} - m_Horizontal: 1 - m_Vertical: 0 - m_MovementType: 1 - m_Elasticity: 0.1 - m_Inertia: 1 - m_DecelerationRate: 0.135 - m_ScrollSensitivity: 1 - m_Viewport: {fileID: 2661482540827288745} - m_HorizontalScrollbar: {fileID: 0} - m_VerticalScrollbar: {fileID: 0} - m_HorizontalScrollbarVisibility: 2 - m_VerticalScrollbarVisibility: 2 - m_HorizontalScrollbarSpacing: -3 - m_VerticalScrollbarSpacing: -3 - m_OnValueChanged: - m_PersistentCalls: - m_Calls: [] ---- !u!114 &2372447356726108403 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2294538527106005025} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: dd536d252034dd74b87b436507ec44f7, type: 3} - m_Name: - m_EditorClassIdentifier: - itemPrefabDataList: [] - arrangeType: 2 - supportScrollBar: 1 - itemSnapEnable: 0 - viewPortSnapPivot: {x: 0, y: 0} - itemSnapPivot: {x: 0, y: 0} ---- !u!1 &2683445925571829816 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2683445925571829817} - - component: {fileID: 2683445925571829820} - - component: {fileID: 2683445925571829822} - m_Layer: 5 - m_Name: NetWorkDemoUI - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &2683445925571829817 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2683445925571829816} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 2683445927021212027} - m_Father: {fileID: 0} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!223 &2683445925571829820 -Canvas: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2683445925571829816} - m_Enabled: 1 - serializedVersion: 3 - m_RenderMode: 0 - m_Camera: {fileID: 0} - m_PlaneDistance: 100 - m_PixelPerfect: 0 - m_ReceivesEvents: 1 - m_OverrideSorting: 0 - m_OverridePixelPerfect: 0 - m_SortingBucketNormalizedSize: 0 - m_AdditionalShaderChannelsFlag: 0 - m_SortingLayerID: 0 - m_SortingOrder: 0 - m_TargetDisplay: 0 ---- !u!114 &2683445925571829822 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2683445925571829816} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IgnoreReversedGraphics: 1 - m_BlockingObjects: 0 - m_BlockingMask: - serializedVersion: 2 - m_Bits: 55 ---- !u!1 &2683445927021212026 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2683445927021212027} - - component: {fileID: 2683445927021212025} - - component: {fileID: 2683445927021212024} - m_Layer: 5 - m_Name: Panel - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &2683445927021212027 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2683445927021212026} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 2734507746760885577} - - {fileID: 3818961499522768759} - - {fileID: 2913277243696531993} - m_Father: {fileID: 2683445925571829817} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &2683445927021212025 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2683445927021212026} - m_CullTransparentMesh: 1 ---- !u!114 &2683445927021212024 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2683445927021212026} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0, g: 0, b: 0, a: 0.34901962} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &2709473284806726369 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1106430378647148480} - - component: {fileID: 6762629404423469341} - - component: {fileID: 6909114571960324083} - - component: {fileID: 5629067341950657379} - - component: {fileID: 3084207183330216106} - m_Layer: 5 - m_Name: m_btnLogin - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1106430378647148480 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2709473284806726369} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 8498826217500179750} - m_Father: {fileID: 3818961499522768759} - m_RootOrder: 2 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 151, y: -400} - m_SizeDelta: {x: 140, y: 91.3583} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &6762629404423469341 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2709473284806726369} - m_CullTransparentMesh: 1 ---- !u!114 &6909114571960324083 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2709473284806726369} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 2761fc23b4aa7e34187ac5ffbc3fad9b, type: 3} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!114 &5629067341950657379 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2709473284806726369} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Selected - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 6909114571960324083} - m_OnClick: - m_PersistentCalls: - m_Calls: [] ---- !u!114 &3084207183330216106 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2709473284806726369} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 95e66cfdf24a4c9d949625a7b449f54a, type: 3} - m_Name: - m_EditorClassIdentifier: - tweenTarget: {fileID: 0} - pressedScale: {x: 0.95, y: 0.95, z: 0.95} - duration: 0.1 - needRemoveAllTween: 1 ---- !u!1 &2768576353239435451 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 8637260190448754603} - - component: {fileID: 8461151415791777188} - - component: {fileID: 3169165635314310857} - m_Layer: 5 - m_Name: Text (Legacy) - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &8637260190448754603 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2768576353239435451} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 1376866687255549051} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &8461151415791777188 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2768576353239435451} - m_CullTransparentMesh: 1 ---- !u!114 &3169165635314310857 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2768576353239435451} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 30 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 1 - m_MaxSize: 40 - m_Alignment: 4 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: "\u8FDE\u63A5\u670D\u52A1\u5668" ---- !u!1 &2870296819149627294 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5188623661349924932} - - component: {fileID: 3609389541239336281} - - component: {fileID: 5826886270982682815} - - component: {fileID: 8294651354544214058} - m_Layer: 5 - m_Name: m_inputPassWord - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5188623661349924932 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2870296819149627294} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 4148737368739005183} - - {fileID: 3484400567530334976} - m_Father: {fileID: 3818961499522768759} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: -250} - m_SizeDelta: {x: 300, y: 60} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &3609389541239336281 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2870296819149627294} - m_CullTransparentMesh: 1 ---- !u!114 &5826886270982682815 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2870296819149627294} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!114 &8294651354544214058 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2870296819149627294} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Selected - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 5826886270982682815} - m_TextComponent: {fileID: 1008938815901879018} - m_Placeholder: {fileID: 2634743641081403190} - m_ContentType: 0 - m_InputType: 0 - m_AsteriskChar: 42 - m_KeyboardType: 0 - m_LineType: 0 - m_HideMobileInput: 0 - m_CharacterValidation: 0 - m_CharacterLimit: 0 - m_OnSubmit: - m_PersistentCalls: - m_Calls: [] - m_OnDidEndEdit: - m_PersistentCalls: - m_Calls: [] - m_OnValueChanged: - m_PersistentCalls: - m_Calls: [] - m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_CustomCaretColor: 0 - m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} - m_Text: - m_CaretBlinkRate: 0.85 - m_CaretWidth: 1 - m_ReadOnly: 0 - m_ShouldActivateOnSelect: 1 ---- !u!1 &3767654980372289091 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2734507746760885577} - m_Layer: 5 - m_Name: m_goConnect - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &2734507746760885577 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 3767654980372289091} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 1376866687255549051} - m_Father: {fileID: 2683445927021212027} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!1 &4245195200902289313 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 8401360966016205532} - - component: {fileID: 4364683885784822962} - - component: {fileID: 3514794735929018262} - - component: {fileID: 147930967487138937} - - component: {fileID: 7561528164157637041} - m_Layer: 5 - m_Name: m_btnRegister - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &8401360966016205532 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4245195200902289313} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 2362168986400613964} - m_Father: {fileID: 3818961499522768759} - m_RootOrder: 3 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -135, y: -402} - m_SizeDelta: {x: 140, y: 91.3583} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &4364683885784822962 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4245195200902289313} - m_CullTransparentMesh: 1 ---- !u!114 &3514794735929018262 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4245195200902289313} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 2761fc23b4aa7e34187ac5ffbc3fad9b, type: 3} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!114 &147930967487138937 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4245195200902289313} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Selected - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 3514794735929018262} - m_OnClick: - m_PersistentCalls: - m_Calls: [] ---- !u!114 &7561528164157637041 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4245195200902289313} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 95e66cfdf24a4c9d949625a7b449f54a, type: 3} - m_Name: - m_EditorClassIdentifier: - tweenTarget: {fileID: 0} - pressedScale: {x: 0.95, y: 0.95, z: 0.95} - duration: 0.1 - needRemoveAllTween: 1 ---- !u!1 &4436822588635160366 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 3484400567530334976} - - component: {fileID: 5331393496658834013} - - component: {fileID: 1008938815901879018} - m_Layer: 5 - m_Name: Text (Legacy) - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &3484400567530334976 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4436822588635160366} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 5188623661349924932} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -0.5} - m_SizeDelta: {x: -20, y: -13} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &5331393496658834013 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4436822588635160366} - m_CullTransparentMesh: 1 ---- !u!114 &1008938815901879018 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4436822588635160366} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 14 - m_FontStyle: 0 - m_BestFit: 0 - m_MinSize: 10 - m_MaxSize: 40 - m_Alignment: 3 - m_AlignByGeometry: 0 - m_RichText: 0 - m_HorizontalOverflow: 1 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: ---- !u!1 &4617476580249816438 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1376866687255549051} - - component: {fileID: 6921014378886857442} - - component: {fileID: 6728334406767592418} - - component: {fileID: 2720110197764131227} - - component: {fileID: 8059309401354459790} - m_Layer: 5 - m_Name: m_btnConnect - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1376866687255549051 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4617476580249816438} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 8637260190448754603} - m_Father: {fileID: 2734507746760885577} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 9, y: -501} - m_SizeDelta: {x: 264.1912, y: 91.3583} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &6921014378886857442 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4617476580249816438} - m_CullTransparentMesh: 1 ---- !u!114 &6728334406767592418 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4617476580249816438} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 2761fc23b4aa7e34187ac5ffbc3fad9b, type: 3} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!114 &2720110197764131227 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4617476580249816438} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Selected - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 6728334406767592418} - m_OnClick: - m_PersistentCalls: - m_Calls: [] ---- !u!114 &8059309401354459790 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 4617476580249816438} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 95e66cfdf24a4c9d949625a7b449f54a, type: 3} - m_Name: - m_EditorClassIdentifier: - tweenTarget: {fileID: 0} - pressedScale: {x: 0.95, y: 0.95, z: 0.95} - duration: 0.1 - needRemoveAllTween: 1 ---- !u!1 &5314664002961178086 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 3818961499522768759} - m_Layer: 5 - m_Name: m_goLogin - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &3818961499522768759 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5314664002961178086} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 5188623661349924932} - - {fileID: 2569723302594454181} - - {fileID: 1106430378647148480} - - {fileID: 8401360966016205532} - m_Father: {fileID: 2683445927021212027} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!1 &7135572807202764412 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 2569723302594454181} - - component: {fileID: 6364278022469945924} - - component: {fileID: 3857729967064403561} - - component: {fileID: 1004417961562649728} - m_Layer: 5 - m_Name: m_inputName - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &2569723302594454181 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7135572807202764412} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 5516143048718199109} - - {fileID: 5500452580366305332} - m_Father: {fileID: 3818961499522768759} - m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: -138} - m_SizeDelta: {x: 300, y: 60} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &6364278022469945924 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7135572807202764412} - m_CullTransparentMesh: 1 ---- !u!114 &3857729967064403561 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7135572807202764412} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0} - m_Type: 1 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!114 &1004417961562649728 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 7135572807202764412} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d199490a83bb2b844b9695cbf13b01ef, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Navigation: - m_Mode: 3 - m_WrapAround: 0 - m_SelectOnUp: {fileID: 0} - m_SelectOnDown: {fileID: 0} - m_SelectOnLeft: {fileID: 0} - m_SelectOnRight: {fileID: 0} - m_Transition: 1 - m_Colors: - m_NormalColor: {r: 1, g: 1, b: 1, a: 1} - m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} - m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} - m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} - m_ColorMultiplier: 1 - m_FadeDuration: 0.1 - m_SpriteState: - m_HighlightedSprite: {fileID: 0} - m_PressedSprite: {fileID: 0} - m_SelectedSprite: {fileID: 0} - m_DisabledSprite: {fileID: 0} - m_AnimationTriggers: - m_NormalTrigger: Normal - m_HighlightedTrigger: Highlighted - m_PressedTrigger: Pressed - m_SelectedTrigger: Selected - m_DisabledTrigger: Disabled - m_Interactable: 1 - m_TargetGraphic: {fileID: 3857729967064403561} - m_TextComponent: {fileID: 3370946749493556016} - m_Placeholder: {fileID: 9081802975426763189} - m_ContentType: 0 - m_InputType: 0 - m_AsteriskChar: 42 - m_KeyboardType: 0 - m_LineType: 0 - m_HideMobileInput: 0 - m_CharacterValidation: 0 - m_CharacterLimit: 0 - m_OnSubmit: - m_PersistentCalls: - m_Calls: [] - m_OnDidEndEdit: - m_PersistentCalls: - m_Calls: [] - m_OnValueChanged: - m_PersistentCalls: - m_Calls: [] - m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} - m_CustomCaretColor: 0 - m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412} - m_Text: - m_CaretBlinkRate: 0.85 - m_CaretWidth: 1 - m_ReadOnly: 0 - m_ShouldActivateOnSelect: 1 ---- !u!1 &8297792320047316563 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1620476634722495211} - - component: {fileID: 3309228999550946613} - - component: {fileID: 581887214916487053} - m_Layer: 5 - m_Name: Sp - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &1620476634722495211 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8297792320047316563} - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 5910359893906513543} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 100, y: 100} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &3309228999550946613 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8297792320047316563} - m_CullTransparentMesh: 1 ---- !u!114 &581887214916487053 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8297792320047316563} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!1 &8523066568731304380 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 5225285352838474515} - m_Layer: 5 - m_Name: m_tfContent - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &5225285352838474515 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8523066568731304380} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 5910359893906513543} - m_Father: {fileID: 2661482540827288745} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 300} - m_Pivot: {x: 0, y: 1} ---- !u!1 &8765138137118890297 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 4148737368739005183} - - component: {fileID: 3700789672722937178} - - component: {fileID: 2634743641081403190} - m_Layer: 5 - m_Name: Placeholder - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!224 &4148737368739005183 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8765138137118890297} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 5188623661349924932} - m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -0.5} - m_SizeDelta: {x: -20, y: -13} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!222 &3700789672722937178 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8765138137118890297} - m_CullTransparentMesh: 1 ---- !u!114 &2634743641081403190 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8765138137118890297} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 0.5} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_FontData: - m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} - m_FontSize: 30 - m_FontStyle: 2 - m_BestFit: 0 - m_MinSize: 3 - m_MaxSize: 40 - m_Alignment: 3 - m_AlignByGeometry: 0 - m_RichText: 1 - m_HorizontalOverflow: 0 - m_VerticalOverflow: 0 - m_LineSpacing: 1 - m_Text: "\u8F93\u5165\u5BC6\u7801" diff --git a/Assets/AssetRaw/UI/NetWorkDemoUI.prefab.meta b/Assets/AssetRaw/UI/NetWorkDemoUI.prefab.meta deleted file mode 100644 index 5402f651..00000000 --- a/Assets/AssetRaw/UI/NetWorkDemoUI.prefab.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: ed92f6b6b24543747bc10eba9141feb1 -PrefabImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Atlas/UIRaw_Atlas_Common.spriteatlas b/Assets/Atlas/UIRaw_Atlas_Common.spriteatlas deleted file mode 100644 index 8428f93a..00000000 --- a/Assets/Atlas/UIRaw_Atlas_Common.spriteatlas +++ /dev/null @@ -1,69 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!687078895 &4343727234628468602 -SpriteAtlas: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_Name: UIRaw_Atlas_Common - serializedVersion: 2 - m_EditorData: - serializedVersion: 2 - textureSettings: - serializedVersion: 2 - anisoLevel: 0 - compressionQuality: 0 - maxTextureSize: 0 - textureCompression: 0 - filterMode: 1 - generateMipMaps: 0 - readable: 0 - crunchedCompression: 0 - sRGB: 1 - platformSettings: - - serializedVersion: 3 - m_BuildTarget: iPhone - m_MaxTextureSize: 2048 - m_ResizeAlgorithm: 0 - m_TextureFormat: 49 - m_TextureCompression: 1 - m_CompressionQuality: 100 - m_CrunchedCompression: 0 - m_AllowsAlphaSplitting: 0 - m_Overridden: 1 - m_AndroidETC2FallbackOverride: 0 - m_ForceMaximumCompressionQuality_BC6H_BC7: 0 - packingSettings: - serializedVersion: 2 - padding: 2 - blockOffset: 1 - allowAlphaSplitting: 0 - enableRotation: 1 - enableTightPacking: 0 - enableAlphaDilation: 0 - secondaryTextureSettings: {} - variantMultiplier: 1 - packables: - - {fileID: 21300000, guid: f9a06e163014f4f46b14f4499d3e7240, type: 3} - - {fileID: 21300000, guid: 2761fc23b4aa7e34187ac5ffbc3fad9b, type: 3} - - {fileID: 21300000, guid: d623a2b7e069a4c4592d3da48f476189, type: 3} - - {fileID: 21300000, guid: 57e4117f4cd6ae54284898652e70d553, type: 3} - bindAsDefault: 1 - isAtlasV2: 0 - cachedData: {fileID: 0} - m_MasterAtlas: {fileID: 0} - m_PackedSprites: - - {fileID: 21300000, guid: 2761fc23b4aa7e34187ac5ffbc3fad9b, type: 3} - - {fileID: 21300000, guid: f9a06e163014f4f46b14f4499d3e7240, type: 3} - - {fileID: 21300000, guid: d623a2b7e069a4c4592d3da48f476189, type: 3} - - {fileID: 21300000, guid: 57e4117f4cd6ae54284898652e70d553, type: 3} - m_PackedSpriteNamesToIndex: - - red_button - - blue_button - - white_background - - white_button - m_RenderDataMap: {} - m_Tag: UIRaw_Atlas_Common - m_IsVariant: 0 - m_IsPlaceholder: 0 diff --git a/Assets/Atlas/UIRaw_Atlas_Common.spriteatlas.meta b/Assets/Atlas/UIRaw_Atlas_Common.spriteatlas.meta deleted file mode 100644 index 22151491..00000000 --- a/Assets/Atlas/UIRaw_Atlas_Common.spriteatlas.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 1a8431d2a64361c4d821790ed88aeb3d -NativeFormatImporter: - externalObjects: {} - mainObjectFileID: 4343727234628468602 - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet.meta b/Assets/GameScripts/DotNet.meta deleted file mode 100644 index a4a088d3..00000000 --- a/Assets/GameScripts/DotNet.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: dbb608c870018e94d9603500e9cb4d5e -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core.meta b/Assets/GameScripts/DotNet/Core.meta deleted file mode 100644 index 1bda6d1c..00000000 --- a/Assets/GameScripts/DotNet/Core.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: fdae3569c5cbfe54e97778a1f7e7af21 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/App.cs b/Assets/GameScripts/DotNet/Core/App.cs deleted file mode 100644 index bbae9a5b..00000000 --- a/Assets/GameScripts/DotNet/Core/App.cs +++ /dev/null @@ -1,117 +0,0 @@ -#if TENGINE_NET -using CommandLine; -using TEngine.Core; -using NLog; - -namespace TEngine -{ - public static class App - { - public static void Init() - { - try - { - // 设置默认的线程的同步上下文 - SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Main); - // 解析命令行参数 - Parser.Default.ParseArguments(Environment.GetCommandLineArgs()) - .WithNotParsed(error => throw new Exception("Command line format error!")) - .WithParsed(option => AppDefine.Options = option); - // 加载框架配置 - TEngineSettingsHelper.Initialize(); - // 检查启动参数 - switch (AppDefine.Options.AppType) - { - case AppType.Game: - { - break; - } - case AppType.Export: - { - new Exporter().Start(); - return; - } - default: - { - throw new NotSupportedException($"AppType is {AppDefine.Options.AppType} Unrecognized!"); - } - } - - // 根据不同的运行模式来选择日志的方式 - switch (AppDefine.Options.Mode) - { - case Mode.Develop: - { - LogManager.Configuration.RemoveRuleByName("ConsoleTrace"); - LogManager.Configuration.RemoveRuleByName("ConsoleDebug"); - LogManager.Configuration.RemoveRuleByName("ConsoleInfo"); - LogManager.Configuration.RemoveRuleByName("ConsoleWarn"); - LogManager.Configuration.RemoveRuleByName("ConsoleError"); - - LogManager.Configuration.RemoveRuleByName("ServerDebug"); - LogManager.Configuration.RemoveRuleByName("ServerTrace"); - LogManager.Configuration.RemoveRuleByName("ServerInfo"); - LogManager.Configuration.RemoveRuleByName("ServerWarn"); - LogManager.Configuration.RemoveRuleByName("ServerError"); - break; - } - case Mode.Release: - { - LogManager.Configuration.RemoveRuleByName("ConsoleTrace"); - LogManager.Configuration.RemoveRuleByName("ConsoleDebug"); - LogManager.Configuration.RemoveRuleByName("ConsoleInfo"); - LogManager.Configuration.RemoveRuleByName("ConsoleWarn"); - LogManager.Configuration.RemoveRuleByName("ConsoleError"); - break; - } - } - - // 初始化SingletonSystemCenter这个一定要放到最前面 - // 因为SingletonSystem会注册AssemblyManager的OnLoadAssemblyEvent和OnUnLoadAssemblyEvent的事件 - // 如果不这样、会无法把程序集的单例注册到SingletonManager中 - SingletonSystem.Initialize(); - // 加载核心程序集 - AssemblyManager.Initialize(); - - Log.Info($"Start Server Param => {Parser.Default.FormatCommandLine(AppDefine.Options)}"); - } - catch (Exception exception) - { - Log.Error(exception); - } - } - - public static async FTask Start() - { - switch (AppDefine.Options.Mode) - { - case Mode.Develop: - { - // 开发模式默认所有Server都在一个进程中、方便调试、但网络还都是独立的 - var serverConfigInfos = ConfigTableManage.AllServerConfig(); - - foreach (var serverConfig in serverConfigInfos) - { - await Server.Create(serverConfig.Id); - } - - return; - } - case Mode.Release: - { - // 发布模式只会启动启动参数传递的Server、也就是只会启动一个Server - // 您可以做一个Server专门用于管理启动所有Server的工作 - await Server.Create(AppDefine.Options.AppId); - return; - } - } - } - - public static void Close() - { - SingletonSystem.Dispose(); - AssemblyManager.Dispose(); - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/App.cs.meta b/Assets/GameScripts/DotNet/Core/App.cs.meta deleted file mode 100644 index 2f2fa4d9..00000000 --- a/Assets/GameScripts/DotNet/Core/App.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f6b4f60ee2b59b649835c9b25028d9e4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/AppDefine.cs b/Assets/GameScripts/DotNet/Core/AppDefine.cs deleted file mode 100644 index a3bcadd0..00000000 --- a/Assets/GameScripts/DotNet/Core/AppDefine.cs +++ /dev/null @@ -1,11 +0,0 @@ -#if TENGINE_NET -#pragma warning disable CS8618 -namespace TEngine -{ - public static class AppDefine - { - public static CommandLineOptions Options; - public static uint AppId => Options.AppId; - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/AppDefine.cs.meta b/Assets/GameScripts/DotNet/Core/AppDefine.cs.meta deleted file mode 100644 index 1334d185..00000000 --- a/Assets/GameScripts/DotNet/Core/AppDefine.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e08a4791989b16843a924bf798cdaa34 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Assembly.meta b/Assets/GameScripts/DotNet/Core/Assembly.meta deleted file mode 100644 index 1554674a..00000000 --- a/Assets/GameScripts/DotNet/Core/Assembly.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9d838cbc15b0f034bb83f3aa5ea5b72d -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Assembly/AssemblyInfo.cs b/Assets/GameScripts/DotNet/Core/Assembly/AssemblyInfo.cs deleted file mode 100644 index cf8e6939..00000000 --- a/Assets/GameScripts/DotNet/Core/Assembly/AssemblyInfo.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using TEngine.DataStructure; - -namespace TEngine.Core -{ - public sealed class AssemblyInfo - { - public Assembly Assembly { get; private set; } - public readonly List AssemblyTypeList = new List(); - public readonly OneToManyList AssemblyTypeGroupList = new OneToManyList(); - - public void Load(Assembly assembly) - { - Assembly = assembly; - var assemblyTypes = assembly.GetTypes().ToList(); - - foreach (var type in assemblyTypes) - { - if (type.IsAbstract || type.IsInterface) - { - continue; - } - - var interfaces = type.GetInterfaces(); - - foreach (var interfaceType in interfaces) - { - AssemblyTypeGroupList.Add(interfaceType, type); - } - } - - AssemblyTypeList.AddRange(assemblyTypes); - } - - public void Unload() - { - AssemblyTypeList.Clear(); - AssemblyTypeGroupList.Clear(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Assembly/AssemblyInfo.cs.meta b/Assets/GameScripts/DotNet/Core/Assembly/AssemblyInfo.cs.meta deleted file mode 100644 index 2d1bf2bf..00000000 --- a/Assets/GameScripts/DotNet/Core/Assembly/AssemblyInfo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: aee73bf0d744afd439ef9b6a5d531951 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Assembly/AssemblyManager.cs b/Assets/GameScripts/DotNet/Core/Assembly/AssemblyManager.cs deleted file mode 100644 index cf91f258..00000000 --- a/Assets/GameScripts/DotNet/Core/Assembly/AssemblyManager.cs +++ /dev/null @@ -1,172 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -#if TENGINE_NET -using System.Runtime.Loader; -// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract -#endif -#pragma warning disable CS8603 -#pragma warning disable CS8618 -namespace TEngine.Core -{ - public static class AssemblyManager - { - public static event Action OnLoadAssemblyEvent; - public static event Action OnUnLoadAssemblyEvent; - public static event Action OnReLoadAssemblyEvent; - private static readonly Dictionary AssemblyList = new Dictionary(); - - public static void Initialize() - { - LoadAssembly(int.MaxValue, typeof(AssemblyManager).Assembly); - } - - public static void LoadAssembly(int assemblyName, Assembly assembly) - { - var isReLoad = false; - - if (!AssemblyList.TryGetValue(assemblyName, out var assemblyInfo)) - { - assemblyInfo = new AssemblyInfo(); - AssemblyList.Add(assemblyName, assemblyInfo); - } - else - { - isReLoad = true; - assemblyInfo.Unload(); - - if (OnUnLoadAssemblyEvent != null) - { - OnUnLoadAssemblyEvent(assemblyName); - } - } - - assemblyInfo.Load(assembly); - - if (OnLoadAssemblyEvent != null) - { - OnLoadAssemblyEvent(assemblyName); - } - - if (isReLoad && OnReLoadAssemblyEvent != null) - { - OnReLoadAssemblyEvent(assemblyName); - } - } - - public static void Load(int assemblyName, Assembly assembly) - { - if (int.MaxValue == assemblyName) - { - throw new NotSupportedException("AssemblyName cannot be 2147483647"); - } - - LoadAssembly(assemblyName, assembly); - } - - public static IEnumerable ForEachAssemblyName() - { - foreach (var (key, _) in AssemblyList) - { - yield return key; - } - } - - public static IEnumerable ForEach() - { - foreach (var (_, assemblyInfo) in AssemblyList) - { - foreach (var type in assemblyInfo.AssemblyTypeList) - { - yield return type; - } - } - } - - public static IEnumerable ForEach(int assemblyName) - { - if (!AssemblyList.TryGetValue(assemblyName, out var assemblyInfo)) - { - yield break; - } - - foreach (var type in assemblyInfo.AssemblyTypeList) - { - yield return type; - } - } - - public static IEnumerable ForEach(Type findType) - { - foreach (var (_, assemblyInfo) in AssemblyList) - { - if (!assemblyInfo.AssemblyTypeGroupList.TryGetValue(findType, out var assemblyLoad)) - { - yield break; - } - - foreach (var type in assemblyLoad) - { - yield return type; - } - } - } - - public static IEnumerable ForEach(int assemblyName, Type findType) - { - if (!AssemblyList.TryGetValue(assemblyName, out var assemblyInfo)) - { - yield break; - } - - if (!assemblyInfo.AssemblyTypeGroupList.TryGetValue(findType, out var assemblyLoad)) - { - yield break; - } - - foreach (var type in assemblyLoad) - { - yield return type; - } - } - - public static Assembly GetAssembly(int assemblyName) - { - return !AssemblyList.TryGetValue(assemblyName, out var assemblyInfo) ? null : assemblyInfo.Assembly; - } - - public static void Dispose() - { - foreach (var (_, assemblyInfo) in AssemblyList) - { - assemblyInfo.Unload(); - } - - AssemblyList.Clear(); - - if (OnLoadAssemblyEvent != null) - { - foreach (var @delegate in OnLoadAssemblyEvent.GetInvocationList()) - { - OnLoadAssemblyEvent -= @delegate as Action; - } - } - - if (OnUnLoadAssemblyEvent != null) - { - foreach (var @delegate in OnUnLoadAssemblyEvent.GetInvocationList()) - { - OnUnLoadAssemblyEvent -= @delegate as Action; - } - } - - if (OnReLoadAssemblyEvent != null) - { - foreach (var @delegate in OnReLoadAssemblyEvent.GetInvocationList()) - { - OnReLoadAssemblyEvent -= @delegate as Action; - } - } - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Assembly/AssemblyManager.cs.meta b/Assets/GameScripts/DotNet/Core/Assembly/AssemblyManager.cs.meta deleted file mode 100644 index 91e2a27d..00000000 --- a/Assets/GameScripts/DotNet/Core/Assembly/AssemblyManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8d7a578f700ea034a9b98a5f63491eb3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/CommandLineOptions.cs b/Assets/GameScripts/DotNet/Core/CommandLineOptions.cs deleted file mode 100644 index 6b077e52..00000000 --- a/Assets/GameScripts/DotNet/Core/CommandLineOptions.cs +++ /dev/null @@ -1,67 +0,0 @@ -#if TENGINE_NET -using CommandLine; -using TEngine.Core; - -#pragma warning disable CS8618 - -namespace TEngine; - -public enum AppType -{ - Game, - - Export, - - /// - /// 每台物理机一个守护进程,用来启动该物理机上的所有进程。 - /// - Watcher, -} - - -public enum Mode -{ - /// - /// Develop:所有Server都在一个进程中,Release:每个Server都在独立的进程中。 - /// - Release, - - Develop, -} - -public class CommandLineOptions -{ - /// - /// 进程Id - /// - [Option("AppId", Required = false, Default = (uint)0, HelpText = "Enter an AppId such as 1")] - public uint AppId { get; set; } - - /// - /// App类型 - /// Game - 游戏服务器App - /// Export - 导表App - /// - [Option("AppType", Required = false, Default = AppType.Game, HelpText = "AppType enum")] - public AppType AppType { get; set; } - - /// - /// 服务器运行模式 - /// Develop - 开发模式(所有Server都在一个进程中) - /// Release - 发布模式(每个Server都在独立的进程中) - /// - [Option("Mode", Required = false, Default = Mode.Develop, HelpText = "Mode enum")] - public Mode Mode { get; set; } - - [Option("LogLevel", Required = false, Default = 2)] - public int LogLevel { get; set; } - -#if TENGINE_NET - /// - /// 导表的类型 - /// - [Option("ExcelExportType", Required = false, Default = ExportType.None, HelpText = "Increment,All")] - public ExportType ExportType { get; set; } -#endif -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/CommandLineOptions.cs.meta b/Assets/GameScripts/DotNet/Core/CommandLineOptions.cs.meta deleted file mode 100644 index a1467fa8..00000000 --- a/Assets/GameScripts/DotNet/Core/CommandLineOptions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c644dc25b4098d24683e949b5a14f754 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/CoreErrorCode.cs b/Assets/GameScripts/DotNet/Core/CoreErrorCode.cs deleted file mode 100644 index 18edc3f1..00000000 --- a/Assets/GameScripts/DotNet/Core/CoreErrorCode.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace TEngine.Core -{ - public class CoreErrorCode - { - public const uint ErrRpcFail = 100000002; // Rpc消息发送失败 - public const uint ErrNotFoundRoute = 100000003; // 没有找到Route消息 - public const uint ErrRouteTimeout = 100000004; // 发送Route消息超时 - public const uint Error_NotFindEntity = 100000008; // 没有找到Entity - public const uint Error_CopyTimeout = 100000009; // CopyTimeout不能小于或等于0 - public const uint Error_Transfer = 100000010;// 传送发生了错误 - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/CoreErrorCode.cs.meta b/Assets/GameScripts/DotNet/Core/CoreErrorCode.cs.meta deleted file mode 100644 index 250051d3..00000000 --- a/Assets/GameScripts/DotNet/Core/CoreErrorCode.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d0b2fb99ac2580c418659e6a1328206b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/CoroutineLock.meta b/Assets/GameScripts/DotNet/Core/CoroutineLock.meta deleted file mode 100644 index ef9cb45c..00000000 --- a/Assets/GameScripts/DotNet/Core/CoroutineLock.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 21519f62191bd1447bfafd815de9046d -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/CoroutineLock/CoroutineLockQueue.cs b/Assets/GameScripts/DotNet/Core/CoroutineLock/CoroutineLockQueue.cs deleted file mode 100644 index 13a68e35..00000000 --- a/Assets/GameScripts/DotNet/Core/CoroutineLock/CoroutineLockQueue.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TEngine.Core -{ - public sealed class CoroutineLockQueue : IDisposable - { - public long Key { get; private set; } - public CoroutineLockQueueType CoroutineLockQueueType { get; private set; } - private readonly Queue _waitCoroutineLocks = new Queue(); - - public static CoroutineLockQueue Create(long key, int time, CoroutineLockQueueType coroutineLockQueueType) - { - var coroutineLockQueue = Pool.Rent(); - coroutineLockQueue.Key = key; - coroutineLockQueue.CoroutineLockQueueType = coroutineLockQueueType; - return coroutineLockQueue; - } - - public void Dispose() - { - Key = 0; - CoroutineLockQueueType = null; - Pool.Return(this); - } - - public async FTask Lock(string tag, int time) - { -#if TENGINE_DEVELOP - if (_waitCoroutineLocks.Count >= 100) - { - // 当等待队列超过100个、表示这个协程锁可能有问题、打印一个警告方便排查错误 - Log.Warning($"too much waitCoroutineLock CoroutineLockQueueType:{CoroutineLockQueueType.Name} Key:{Key} Count: {_waitCoroutineLocks.Count} "); - } -#endif - var waitCoroutineLock = WaitCoroutineLock.Create(this, tag, time); - _waitCoroutineLocks.Enqueue(waitCoroutineLock); - return await waitCoroutineLock.Tcs; - } - - public void Release() - { - if (_waitCoroutineLocks.Count == 0) - { - CoroutineLockQueueType.Remove(Key); - return; - } - - while (_waitCoroutineLocks.TryDequeue(out var waitCoroutineLock)) - { - if (waitCoroutineLock.IsDisposed) - { - continue; - } - - waitCoroutineLock.SetResult(); - break; - } - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/CoroutineLock/CoroutineLockQueue.cs.meta b/Assets/GameScripts/DotNet/Core/CoroutineLock/CoroutineLockQueue.cs.meta deleted file mode 100644 index 77d1b02d..00000000 --- a/Assets/GameScripts/DotNet/Core/CoroutineLock/CoroutineLockQueue.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8f07b80619d455d4499aefbc3eab9f65 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/CoroutineLock/CoroutineLockQueueType.cs b/Assets/GameScripts/DotNet/Core/CoroutineLock/CoroutineLockQueueType.cs deleted file mode 100644 index fabaac49..00000000 --- a/Assets/GameScripts/DotNet/Core/CoroutineLock/CoroutineLockQueueType.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TEngine.Core -{ - public sealed class CoroutineLockQueueType - { - public readonly string Name; - private readonly Dictionary _coroutineLockQueues = new Dictionary(); - - private CoroutineLockQueueType() { } - public CoroutineLockQueueType(string name) - { - Name = name; - } - - public async FTask Lock(long key, string tag = null, int time = 10000) - { - if (_coroutineLockQueues.TryGetValue(key, out var coroutineLockQueue)) - { - return await coroutineLockQueue.Lock(tag,time); - } - - coroutineLockQueue = CoroutineLockQueue.Create(key, time, this); - _coroutineLockQueues.Add(key, coroutineLockQueue); - return WaitCoroutineLock.Create(coroutineLockQueue, tag, time); - } - - public void Remove(long key) - { - if (_coroutineLockQueues.Remove(key, out var coroutineLockQueue)) - { - coroutineLockQueue.Dispose(); - } - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/CoroutineLock/CoroutineLockQueueType.cs.meta b/Assets/GameScripts/DotNet/Core/CoroutineLock/CoroutineLockQueueType.cs.meta deleted file mode 100644 index f582eb35..00000000 --- a/Assets/GameScripts/DotNet/Core/CoroutineLock/CoroutineLockQueueType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2067a4304a800324bbe9c547eefac9fa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/CoroutineLock/WaitCoroutineLock.cs b/Assets/GameScripts/DotNet/Core/CoroutineLock/WaitCoroutineLock.cs deleted file mode 100644 index 97bc7bf6..00000000 --- a/Assets/GameScripts/DotNet/Core/CoroutineLock/WaitCoroutineLock.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using TEngine.Core; - -namespace TEngine.Core -{ - public struct CoroutineLockTimeout - { - public long LockId; - public WaitCoroutineLock WaitCoroutineLock; - } - - public sealed class OnCoroutineLockTimeout : EventSystem - { - public override void Handler(CoroutineLockTimeout self) - { - if (self.LockId != self.WaitCoroutineLock.LockId) - { - return; - } - - var coroutineLockQueue = self.WaitCoroutineLock.CoroutineLockQueue; - var coroutineLockQueueType = coroutineLockQueue.CoroutineLockQueueType; - var key = coroutineLockQueue.Key; - Log.Error($"coroutine lock timeout CoroutineLockQueueType:{coroutineLockQueueType.Name} Key:{key} Tag:{self.WaitCoroutineLock.Tag}"); - } - } - - public sealed class WaitCoroutineLock : IDisposable - { - private long _timerId; - public bool IsDisposed => LockId == 0; - public string Tag { get; private set; } - public long LockId { get; private set; } - public FTask Tcs { get; private set; } - public CoroutineLockQueue CoroutineLockQueue{ get; private set; } - - public static WaitCoroutineLock Create(CoroutineLockQueue coroutineLockQueue, string tag, int timeOut) - { - var lockId = IdFactory.NextRunTimeId(); - var waitCoroutineLock = Pool.Rent(); - - waitCoroutineLock.Tag = tag; - waitCoroutineLock.LockId = lockId; - waitCoroutineLock.CoroutineLockQueue = coroutineLockQueue; - waitCoroutineLock.Tcs = FTask.Create(); - waitCoroutineLock._timerId = TimerScheduler.Instance.Core.OnceTimer(timeOut, new CoroutineLockTimeout() - { - LockId = lockId, WaitCoroutineLock = waitCoroutineLock - }); - - return waitCoroutineLock; - } - - public void Dispose() - { - if (IsDisposed) - { - Log.Error("WaitCoroutineLock is Dispose"); - return; - } - - Release(CoroutineLockQueue); - - LockId = 0; - Tcs = null; - Tag = null; - CoroutineLockQueue = null; - - if (_timerId != 0) - { - TimerScheduler.Instance.Core.RemoveByRef(ref _timerId); - } - - Pool.Return(this); - } - - private static void Release(CoroutineLockQueue coroutineLockQueue) - { - // 放到下一帧执行释放锁、如果不这样、会导致逻辑的顺序不正常 - ThreadSynchronizationContext.Main.Post(coroutineLockQueue.Release); - } - - public void SetResult() - { - if (Tcs == null) - { - throw new NullReferenceException("SetResult tcs is null"); - } - - Tcs.SetResult(this); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/CoroutineLock/WaitCoroutineLock.cs.meta b/Assets/GameScripts/DotNet/Core/CoroutineLock/WaitCoroutineLock.cs.meta deleted file mode 100644 index 86602f5a..00000000 --- a/Assets/GameScripts/DotNet/Core/CoroutineLock/WaitCoroutineLock.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1ee0d61ec53909c4695fe2ecc97f42bd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataBase.meta b/Assets/GameScripts/DotNet/Core/DataBase.meta deleted file mode 100644 index 862bcd66..00000000 --- a/Assets/GameScripts/DotNet/Core/DataBase.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9f6012de0e164ce4da102c93fa2df9ea -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataBase/Base.meta b/Assets/GameScripts/DotNet/Core/DataBase/Base.meta deleted file mode 100644 index 83280e41..00000000 --- a/Assets/GameScripts/DotNet/Core/DataBase/Base.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: bd10fb6ee217e1e4a82db518e161aaec -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataBase/Base/IDateBase.cs b/Assets/GameScripts/DotNet/Core/DataBase/Base/IDateBase.cs deleted file mode 100644 index c370f2ce..00000000 --- a/Assets/GameScripts/DotNet/Core/DataBase/Base/IDateBase.cs +++ /dev/null @@ -1,48 +0,0 @@ -#if TENGINE_NET -using System.Linq.Expressions; -#pragma warning disable CS8625 - -namespace TEngine.Core.DataBase; - -public interface IDateBase -{ - public static readonly CoroutineLockQueueType DataBaseLock = new CoroutineLockQueueType("DataBaseLock"); - IDateBase Initialize(string connectionString, string dbName); - FTask Count(string collection = null) where T : Entity; - FTask Count(Expression> filter, string collection = null) where T : Entity; - FTask Exist(string collection = null) where T : Entity; - FTask Exist(Expression> filter, string collection = null) where T : Entity; - FTask QueryNotLock(long id, string collection = null) where T : Entity; - FTask Query(long id, string collection = null) where T : Entity; - FTask<(int count, List dates)> QueryCountAndDatesByPage(Expression> filter, int pageIndex, int pageSize, string collection = null) where T : Entity; - FTask<(int count, List dates)> QueryCountAndDatesByPage(Expression> filter, int pageIndex, int pageSize, string[] cols, string collection = null) where T : Entity; - FTask> QueryByPage(Expression> filter, int pageIndex, int pageSize, string collection = null) where T : Entity; - FTask> QueryByPage(Expression> filter, int pageIndex, int pageSize, string[] cols, string collection = null) where T : Entity; - FTask> QueryByPageOrderBy(Expression> filter, int pageIndex, int pageSize, Expression> orderByExpression, bool isAsc = true, string collection = null) where T : Entity; - FTask First(Expression> filter, string collection = null) where T : Entity; - FTask First(string json, string[] cols, string collection = null) where T : Entity; - FTask Last(Expression> filter, string collection = null) where T : Entity; - FTask> QueryOrderBy(Expression> filter, Expression> orderByExpression, bool isAsc = true, string collection = null) where T : Entity; - FTask> Query(Expression> filter, string collection = null) where T : Entity; - FTask Query(long id, List collectionNames, List result); - FTask> QueryJson(string json, string collection = null) where T : Entity; - FTask> QueryJson(string json, string[] cols, string collection = null) where T : Entity; - FTask> QueryJson(long taskId, string json, string collection = null) where T : Entity; - FTask> Query(Expression> filter, string[] cols, string collection = null) where T : class; - FTask Save(T entity, string collection = null) where T : Entity, new(); - FTask Save(long id, List entities); - FTask Save(object transactionSession, T entity, string collection = null) where T : Entity; - FTask Insert(T entity, string collection = null) where T : Entity, new(); - FTask InsertBatch(IEnumerable list, string collection = null) where T : Entity, new(); - FTask InsertBatch(object transactionSession, IEnumerable list, string collection = null) where T : Entity, new(); - FTask Remove(object transactionSession, long id, string collection = null) where T : Entity, new(); - FTask Remove(long id, string collection = null) where T : Entity, new(); - FTask Remove(long id,object transactionSession, Expression> filter, string collection = null) where T : Entity, new(); - FTask Remove(long id, Expression> filter, string collection = null) where T : Entity, new(); - FTask Sum(Expression> filter, Expression> sumExpression, string collection = null) where T : Entity; - FTask CreateIndex(string collection, params object[] keys) where T : Entity; - FTask CreateIndex(params object[] keys) where T : Entity; - FTask CreateDB() where T : Entity; - FTask CreateDB(Type type); -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataBase/Base/IDateBase.cs.meta b/Assets/GameScripts/DotNet/Core/DataBase/Base/IDateBase.cs.meta deleted file mode 100644 index 7b7158f2..00000000 --- a/Assets/GameScripts/DotNet/Core/DataBase/Base/IDateBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 801a4f2fbf5d7944480423ade9d8a998 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataBase/Base/World.cs b/Assets/GameScripts/DotNet/Core/DataBase/Base/World.cs deleted file mode 100644 index 123893b6..00000000 --- a/Assets/GameScripts/DotNet/Core/DataBase/Base/World.cs +++ /dev/null @@ -1,42 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core.DataBase; - -public sealed class World -{ - public uint Id { get; private init; } - public IDateBase DateBase { get; private init; } - public WorldConfigInfo Config => ConfigTableManage.WorldConfigInfo(Id); - private static readonly Dictionary Worlds = new(); - - public World(WorldConfigInfo worldConfigInfo) - { - Id = worldConfigInfo.Id; - var dbType = worldConfigInfo.DbType.ToLower(); - - switch (dbType) - { - case "mongodb": - { - DateBase = new MongoDataBase(); - DateBase.Initialize(worldConfigInfo.DbConnection, worldConfigInfo.DbName); - break; - } - default: - throw new Exception("No supported database"); - } - } - - public static World Create(uint id) - { - if (Worlds.TryGetValue(id, out var world)) - { - return world; - } - - var worldConfigInfo = ConfigTableManage.WorldConfigInfo(id); - world = new World(worldConfigInfo); - Worlds.Add(id, world); - return world; - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataBase/Base/World.cs.meta b/Assets/GameScripts/DotNet/Core/DataBase/Base/World.cs.meta deleted file mode 100644 index eb2803da..00000000 --- a/Assets/GameScripts/DotNet/Core/DataBase/Base/World.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e207b62400a4d2742945b50eb84f8233 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataBase/Base/WorldConfigInfo.cs b/Assets/GameScripts/DotNet/Core/DataBase/Base/WorldConfigInfo.cs deleted file mode 100644 index f54b36bb..00000000 --- a/Assets/GameScripts/DotNet/Core/DataBase/Base/WorldConfigInfo.cs +++ /dev/null @@ -1,12 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core.DataBase; - -public class WorldConfigInfo -{ - public uint Id; - public string WorldName; - public string DbConnection; - public string DbName; - public string DbType; -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataBase/Base/WorldConfigInfo.cs.meta b/Assets/GameScripts/DotNet/Core/DataBase/Base/WorldConfigInfo.cs.meta deleted file mode 100644 index 25691db1..00000000 --- a/Assets/GameScripts/DotNet/Core/DataBase/Base/WorldConfigInfo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1c1d63a41ee591348a2aeab0a1ff5b2f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataBase/MongoDataBase.cs b/Assets/GameScripts/DotNet/Core/DataBase/MongoDataBase.cs deleted file mode 100644 index badb41f0..00000000 --- a/Assets/GameScripts/DotNet/Core/DataBase/MongoDataBase.cs +++ /dev/null @@ -1,556 +0,0 @@ -#if TENGINE_NET -using System.Linq.Expressions; -using TEngine.Core; -using MongoDB.Bson; -using MongoDB.Driver; - -namespace TEngine.Core.DataBase; - -public sealed class MongoDataBase : IDateBase -{ - private string _dbName; - private string _connectionString; - private MongoClient _mongoClient; - private IMongoDatabase _mongoDatabase; - private readonly HashSet _collections = new HashSet(); - - public IDateBase Initialize(string connectionString, string dbName) - { - _dbName = dbName; - _connectionString = connectionString; - _mongoClient = new MongoClient(connectionString); - _mongoDatabase = _mongoClient.GetDatabase(dbName); - // 记录所有集合名 - _collections.UnionWith(_mongoDatabase.ListCollectionNames().ToList()); - return this; - } - - #region Other - - public async FTask Sum(Expression> filter, Expression> sumExpression, string collection = null) where T : Entity - { - var member = (MemberExpression) ((UnaryExpression) sumExpression.Body).Operand; - - var projection = - new BsonDocument("_id", "null").Add("Result", new BsonDocument("$sum", $"${member.Member.Name}")); - - var data = await GetCollection(collection).Aggregate().Match(filter).Group(projection) - .FirstOrDefaultAsync(); - - return data == null ? 0 : Convert.ToInt64(data["Result"]); - } - - #endregion - - #region GetCollection - - private IMongoCollection GetCollection(string collection = null) - { - return _mongoDatabase.GetCollection(collection ?? typeof(T).Name); - } - - private IMongoCollection GetCollection(string name) - { - return _mongoDatabase.GetCollection(name); - } - - #endregion - - #region Count - - public async FTask Count(string collection = null) where T : Entity - { - return await GetCollection(collection).CountDocumentsAsync(d => true); - } - - public async FTask Count(Expression> filter, string collection = null) where T : Entity - { - return await GetCollection(collection).CountDocumentsAsync(filter); - } - - #endregion - - #region Exist - - public async FTask Exist(string collection = null) where T : Entity - { - return await Count(collection) > 0; - } - - public async FTask Exist(Expression> filter, string collection = null) where T : Entity - { - return await Count(filter, collection) > 0; - } - - #endregion - - #region Query - public async FTask QueryNotLock(long id, string collection = null) where T : Entity - { - var cursor = await GetCollection(collection).FindAsync(d => d.Id == id); - var v = await cursor.FirstOrDefaultAsync(); - return v; - } - - public async FTask Query(long id, string collection = null) where T : Entity - { - using (await IDateBase.DataBaseLock.Lock(id)) - { - var cursor = await GetCollection(collection).FindAsync(d => d.Id == id); - var v = await cursor.FirstOrDefaultAsync(); - return v; - } - } - - public async FTask<(int count, List dates)> QueryCountAndDatesByPage(Expression> filter, int pageIndex, int pageSize, string collection = null) where T : Entity - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - var count = await Count(filter); - var dates = await QueryByPage(filter, pageIndex, pageSize, collection); - return ((int)count, dates); - } - } - - public async FTask<(int count, List dates)> QueryCountAndDatesByPage(Expression> filter, int pageIndex, int pageSize, string[] cols, string collection = null) where T : Entity - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - var count = await Count(filter); - - var dates = await QueryByPage(filter, pageIndex, pageSize, cols, collection); - - return ((int) count, dates); - } - } - - public async FTask> QueryByPage(Expression> filter, int pageIndex, int pageSize, string collection = null) where T : Entity - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - return await GetCollection(collection).Find(filter).Skip((pageIndex - 1) * pageSize) - .Limit(pageSize) - .ToListAsync(); - } - } - - public async FTask> QueryByPage(Expression> filter, int pageIndex, int pageSize, string[] cols, string collection = null) where T : Entity - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - var projection = Builders.Projection.Include(""); - - foreach (var col in cols) - { - projection = projection.Include(col); - } - - return await GetCollection(collection).Find(filter).Project(projection) - .Skip((pageIndex - 1) * pageSize).Limit(pageSize).ToListAsync(); - } - } - - public async FTask> QueryByPageOrderBy(Expression> filter, int pageIndex, int pageSize, Expression> orderByExpression, bool isAsc = true, string collection = null) where T : Entity - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - if (isAsc) - { - return await GetCollection(collection).Find(filter).SortBy(orderByExpression) - .Skip((pageIndex - 1) * pageSize).Limit(pageSize).ToListAsync(); - } - - return await GetCollection(collection).Find(filter).SortByDescending(orderByExpression) - .Skip((pageIndex - 1) * pageSize).Limit(pageSize).ToListAsync(); - } - } - - public async FTask First(Expression> filter, string collection = null) where T : Entity - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - var cursor = await GetCollection(collection).FindAsync(filter); - - return await cursor.FirstOrDefaultAsync(); - } - } - - public async FTask First(string json, string[] cols, string collection = null) where T : Entity - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - var projection = Builders.Projection.Include(""); - - foreach (var col in cols) - { - projection = projection.Include(col); - } - - var options = new FindOptions {Projection = projection}; - - FilterDefinition filterDefinition = new JsonFilterDefinition(json); - - var cursor = await GetCollection(collection).FindAsync(filterDefinition, options); - - return await cursor.FirstOrDefaultAsync(); - } - } - - public async FTask Last(Expression> filter, string collection = null) where T : Entity - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - var cursor = await GetCollection(collection).FindAsync(filter); - - var list = await cursor.ToListAsync(); - - return list.LastOrDefault(); - } - } - - public async FTask> QueryOrderBy(Expression> filter, Expression> orderByExpression, bool isAsc = true, string collection = null) where T : Entity - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - if (isAsc) - { - return await GetCollection(collection).Find(filter).SortBy(orderByExpression).ToListAsync(); - } - - return await GetCollection(collection).Find(filter).SortByDescending(orderByExpression) - .ToListAsync(); - } - } - - public async FTask> Query(Expression> filter, string collection = null) where T : Entity - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - var cursor = await GetCollection(collection).FindAsync(filter); - var v = await cursor.ToListAsync(); - return v; - } - } - - public async FTask Query(long id, List collectionNames, List result) - { - using (await IDateBase.DataBaseLock.Lock(id)) - { - if (collectionNames == null || collectionNames.Count == 0) - { - return; - } - - foreach (var collectionName in collectionNames) - { - var cursor = await GetCollection(collectionName).FindAsync(d => d.Id == id); - - var e = await cursor.FirstOrDefaultAsync(); - - if (e == null) - { - continue; - } - - result.Add(e); - } - } - } - - public async FTask> QueryJson(string json, string collection = null) where T : Entity - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - FilterDefinition filterDefinition = new JsonFilterDefinition(json); - var cursor = await GetCollection(collection).FindAsync(filterDefinition); - var v = await cursor.ToListAsync(); - return v; - } - } - - public async FTask> QueryJson(string json, string[] cols, string collection = null) where T : Entity - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - var projection = Builders.Projection.Include(""); - - foreach (var col in cols) - { - projection = projection.Include(col); - } - - var options = new FindOptions {Projection = projection}; - - FilterDefinition filterDefinition = new JsonFilterDefinition(json); - - var cursor = await GetCollection(collection).FindAsync(filterDefinition, options); - var v = await cursor.ToListAsync(); - return v; - } - } - - public async FTask> QueryJson(long taskId, string json, string collection = null) where T : Entity - { - using (await IDateBase.DataBaseLock.Lock(taskId)) - { - FilterDefinition filterDefinition = new JsonFilterDefinition(json); - var cursor = await GetCollection(collection).FindAsync(filterDefinition); - var v = await cursor.ToListAsync(); - return v; - } - } - - public async FTask> Query(Expression> filter, string[] cols, string collection = null) where T : class - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - var projection = Builders.Projection.Include(cols[0]); - - for (var i = 1; i < cols.Length; i++) - { - projection = projection.Include(cols[i]); - } - - return await GetCollection(collection).Find(filter).Project(projection).ToListAsync(); - } - } - - #endregion - - #region Save - - public async FTask Save(object transactionSession, T entity, string collection = null) where T : Entity - { - if (entity == null) - { - Log.Error($"save entity is null: {typeof(T).Name}"); - return; - } - - var clone = MongoHelper.Instance.Clone(entity); - - using (await IDateBase.DataBaseLock.Lock(clone.Id)) - { - await GetCollection(collection ?? clone.GetType().Name).ReplaceOneAsync( - (IClientSessionHandle) transactionSession, d => d.Id == clone.Id, clone, - new ReplaceOptions {IsUpsert = true}); - } - } - - public async FTask Save(T entity, string collection = null) where T : Entity, new() - { - if (entity == null) - { - Log.Error($"save entity is null: {typeof(T).Name}"); - - return; - } - - var clone = MongoHelper.Instance.Clone(entity); - - using (await IDateBase.DataBaseLock.Lock(clone.Id)) - { - await GetCollection(collection ?? clone.GetType().Name).ReplaceOneAsync(d => d.Id == clone.Id, clone, - new ReplaceOptions {IsUpsert = true}); - } - } - - private async FTask SaveBase(T entity, string collection = null) where T : Entity - { - if (entity == null) - { - Log.Error($"save entity is null: {typeof(T).Name}"); - - return; - } - - var clone = MongoHelper.Instance.Clone(entity); - - using (await IDateBase.DataBaseLock.Lock(clone.Id)) - { - await GetCollection(collection ?? clone.GetType().Name).ReplaceOneAsync(d => d.Id == clone.Id, clone, new ReplaceOptions {IsUpsert = true}); - } - } - - public async FTask Save(long id, List entities) - { - if (entities == null) - { - Log.Error("save entity is null"); - return; - } - - var clones = MongoHelper.Instance.Clone(entities); - - using (await IDateBase.DataBaseLock.Lock(id)) - { - foreach (Entity clone in clones) - { - try - { - await GetCollection(clone.GetType().Name).ReplaceOneAsync(d => d.Id == clone.Id, clone, - new ReplaceOptions {IsUpsert = true}); - } - catch (Exception e) - { - Log.Error($"Save List Entity Error: {clone.GetType().Name} {clone}\n{e}"); - } - } - } - } - - #endregion - - #region Insert - - public FTask Insert(T entity, string collection = null) where T : Entity, new() - { - return Save(entity); - } - - public async FTask InsertBatch(IEnumerable list, string collection = null) where T : Entity, new() - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - await GetCollection(collection ?? typeof(T).Name).InsertManyAsync(list); - } - } - - public async FTask InsertBatch(object transactionSession, IEnumerable list, string collection = null) where T : Entity, new() - { - using (await IDateBase.DataBaseLock.Lock(RandomHelper.RandInt64())) - { - await GetCollection(collection ?? typeof(T).Name).InsertManyAsync((IClientSessionHandle) transactionSession, list); - } - } - - #endregion - - #region Remove - - public async FTask Remove(object transactionSession, long id, string collection = null) where T : Entity, new() - { - using (await IDateBase.DataBaseLock.Lock(id)) - { - var result = await GetCollection(collection).DeleteOneAsync((IClientSessionHandle) transactionSession, d => d.Id == id); - return result.DeletedCount; - } - } - - public async FTask Remove(long id, string collection = null) where T : Entity, new() - { - using (await IDateBase.DataBaseLock.Lock(id)) - { - var result = await GetCollection(collection).DeleteOneAsync(d => d.Id == id); - return result.DeletedCount; - } - } - - public async FTask Remove(long id, object transactionSession, Expression> filter, string collection = null) where T : Entity, new() - { - using (await IDateBase.DataBaseLock.Lock(id)) - { - var result = await GetCollection(collection).DeleteManyAsync((IClientSessionHandle) transactionSession, filter); - return result.DeletedCount; - } - } - - public async FTask Remove(long id, Expression> filter, string collection = null) where T : Entity, new() - { - using (await IDateBase.DataBaseLock.Lock(id)) - { - var result = await GetCollection(collection).DeleteManyAsync(filter); - return result.DeletedCount; - } - } - - #endregion - - #region Index - - /// - /// 创建数据库索引 - /// - /// - /// - /// - /// - /// 使用例子(可多个): - /// 1 : Builders.IndexKeys.Ascending(d=>d.Id) - /// 2 : Builders.IndexKeys.Descending(d=>d.Id).Ascending(d=>d.Name) - /// 3 : Builders.IndexKeys.Descending(d=>d.Id),Builders.IndexKeys.Descending(d=>d.Name) - /// - public async FTask CreateIndex(string collection, params object[] keys) where T : Entity - { - if (keys == null || keys.Length <= 0) - { - return; - } - - var indexModels = new List>(); - - foreach (object key in keys) - { - IndexKeysDefinition indexKeysDefinition = (IndexKeysDefinition) key; - - indexModels.Add(new CreateIndexModel(indexKeysDefinition)); - } - - await GetCollection(collection).Indexes.CreateManyAsync(indexModels); - } - - public async FTask CreateIndex(params object[] keys) where T : Entity - { - if (keys == null) - { - return; - } - - List> indexModels = new List>(); - - foreach (object key in keys) - { - IndexKeysDefinition indexKeysDefinition = (IndexKeysDefinition) key; - - indexModels.Add(new CreateIndexModel(indexKeysDefinition)); - } - - await GetCollection().Indexes.CreateManyAsync(indexModels); - } - - #endregion - - #region CreateDB - - public async FTask CreateDB() where T : Entity - { - // 已经存在数据库表 - string name = typeof(T).Name; - - if (_collections.Contains(name)) - { - return; - } - - await _mongoDatabase.CreateCollectionAsync(name); - - _collections.Add(name); - } - - public async FTask CreateDB(Type type) - { - string name = type.Name; - - if (_collections.Contains(name)) - { - return; - } - - await _mongoDatabase.CreateCollectionAsync(name); - - _collections.Add(name); - } - - #endregion -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataBase/MongoDataBase.cs.meta b/Assets/GameScripts/DotNet/Core/DataBase/MongoDataBase.cs.meta deleted file mode 100644 index 7a37758a..00000000 --- a/Assets/GameScripts/DotNet/Core/DataBase/MongoDataBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0aaa971dc58538e46b0e43df7cc72a2f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure.meta b/Assets/GameScripts/DotNet/Core/DataStructure.meta deleted file mode 100644 index 36e901a7..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ddb0edd718602754083d07d649e65d8f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection.meta deleted file mode 100644 index 6887d895..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e9c6ac6ade3864b42887435f6eac263f -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/CircularBuffer.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/CircularBuffer.cs deleted file mode 100644 index d194f49e..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/CircularBuffer.cs +++ /dev/null @@ -1,261 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -#pragma warning disable CS8625 -#pragma warning disable CS8618 - -namespace TEngine.DataStructure -{ - /// - /// 环形缓存(自动扩充、不会收缩缓存、所以不要用这个操作过大的IO流) - /// 1、环大小8192,溢出的会自动增加环的大小。 - /// 2、每个块都是一个环形缓存,当溢出的时候会自动添加到下一个环中。 - /// 3、当读取完成后用过的环会放在缓存中,不会销毁掉。 - /// - public sealed class CircularBuffer : Stream, IDisposable - { - private byte[] _lastBuffer; - public const int ChunkSize = 8192; // 环形缓存块大小 - private readonly Queue _bufferCache = new Queue(); - private readonly Queue _bufferQueue = new Queue(); - public int FirstIndex { get; set; } - public int LastIndex { get; set; } - public override long Length - { - get - { - if (_bufferQueue.Count == 0) - { - return 0; - } - - return (_bufferQueue.Count - 1) * ChunkSize + LastIndex - FirstIndex; - } - } - public byte[] First - { - get - { - if (_bufferQueue.Count == 0) - { - AddLast(); - } - - return _bufferQueue.Peek(); - } - } - public byte[] Last - { - get - { - if (_bufferQueue.Count == 0) - { - AddLast(); - } - - return _lastBuffer; - } - } - - public void AddLast() - { - var buffer = _bufferCache.Count > 0 ? _bufferCache.Dequeue() : new byte[ChunkSize]; - _bufferQueue.Enqueue(buffer); - _lastBuffer = buffer; - } - - public void RemoveFirst() - { - _bufferCache.Enqueue(_bufferQueue.Dequeue()); - } - - public void Read(Stream stream, int count) - { - if (count > Length) - { - throw new Exception($"bufferList length < count, {Length} {count}"); - } - - var copyCount = 0; - while (copyCount < count) - { - var n = count - copyCount; - if (ChunkSize - FirstIndex > n) - { - stream.Write(First, FirstIndex, n); - FirstIndex += n; - copyCount += n; - } - else - { - stream.Write(First, FirstIndex, ChunkSize - FirstIndex); - copyCount += ChunkSize - FirstIndex; - FirstIndex = 0; - RemoveFirst(); - } - } - } - - public void Read(Memory memory, int count) - { - if (count > Length) - { - throw new Exception($"bufferList length < count, {Length} {count}"); - } - - var copyCount = 0; - while (copyCount < count) - { - var n = count - copyCount; - var asMemory = First.AsMemory(); - - if (ChunkSize - FirstIndex > n) - { - var slice = asMemory.Slice(FirstIndex, n); - slice.CopyTo(memory.Slice(copyCount, n)); - FirstIndex += n; - copyCount += n; - } - else - { - var length = ChunkSize - FirstIndex; - var slice = asMemory.Slice(FirstIndex, length); - slice.CopyTo(memory.Slice(copyCount, length)); - copyCount += ChunkSize - FirstIndex; - FirstIndex = 0; - RemoveFirst(); - } - } - } - - public override int Read(byte[] buffer, int offset, int count) - { - if (buffer.Length < offset + count) - { - throw new Exception($"buffer length < count, buffer length: {buffer.Length} {offset} {count}"); - } - - var length = Length; - if (length < count) - { - count = (int) length; - } - - var copyCount = 0; - while (copyCount < count) - { - var copyLength = count - copyCount; - - if (ChunkSize - FirstIndex > copyLength) - { - Array.Copy(First, FirstIndex, buffer, copyCount + offset, copyLength); - - FirstIndex += copyLength; - copyCount += copyLength; - continue; - } - - Array.Copy(First, FirstIndex, buffer, copyCount + offset, ChunkSize - FirstIndex); - copyCount += ChunkSize - FirstIndex; - FirstIndex = 0; - - RemoveFirst(); - } - - return count; - } - - public void Write(byte[] buffer) - { - Write(buffer, 0, buffer.Length); - } - - public void Write(Stream stream) - { - var copyCount = 0; - var count = (int) (stream.Length - stream.Position); - - while (copyCount < count) - { - if (LastIndex == ChunkSize) - { - AddLast(); - LastIndex = 0; - } - - var n = count - copyCount; - - if (ChunkSize - LastIndex > n) - { - _ = stream.Read(Last, LastIndex, n); - LastIndex += count - copyCount; - copyCount += n; - } - else - { - _ = stream.Read(Last, LastIndex, ChunkSize - LastIndex); - copyCount += ChunkSize - LastIndex; - LastIndex = ChunkSize; - } - } - } - - public override void Write(byte[] buffer, int offset, int count) - { - var copyCount = 0; - - while (copyCount < count) - { - if (ChunkSize == LastIndex) - { - AddLast(); - LastIndex = 0; - } - - var byteLength = count - copyCount; - - if (ChunkSize - LastIndex > byteLength) - { - Array.Copy(buffer, copyCount + offset, Last, LastIndex, byteLength); - LastIndex += byteLength; - copyCount += byteLength; - } - else - { - Array.Copy(buffer, copyCount + offset, _lastBuffer, LastIndex, ChunkSize - LastIndex); - copyCount += ChunkSize - LastIndex; - LastIndex = ChunkSize; - } - } - } - - public override bool CanRead { get; } = true; - public override bool CanSeek { get; } = false; - public override bool CanWrite { get; } = true; - public override long Position { get; set; } - - public override void Flush() - { - throw new NotImplementedException(); - } - - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotImplementedException(); - } - - public override void SetLength(long value) - { - throw new NotImplementedException(); - } - - public new void Dispose() - { - _bufferQueue.Clear(); - _lastBuffer = null; - FirstIndex = 0; - LastIndex = 0; - base.Dispose(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/CircularBuffer.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/CircularBuffer.cs.meta deleted file mode 100644 index ae54acd9..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/CircularBuffer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 28188b5e2acefe14a996fb93df6b2fc6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ConcurrentOneToManyList.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ConcurrentOneToManyList.cs deleted file mode 100644 index a91d8297..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ConcurrentOneToManyList.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -#pragma warning disable CS8603 - -namespace TEngine.DataStructure -{ - public class ConcurrentOneToManyListPool : ConcurrentOneToManyList, IDisposable where TKey : notnull - { - private bool _isDispose; - - public static ConcurrentOneToManyListPool Create() - { - var a = Pool>.Rent(); - a._isDispose = false; - return a; - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } - - public class ConcurrentOneToManyList : ConcurrentDictionary> where TKey : notnull - { - private readonly Queue> _queue = new Queue>(); - private readonly int _recyclingLimit = 120; - - public ConcurrentOneToManyList() - { - } - - /// - /// 设置最大缓存数量 - /// - /// - /// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC. - /// 2:设置成0不控制数量,全部缓存 - /// - public ConcurrentOneToManyList(int recyclingLimit) - { - _recyclingLimit = recyclingLimit; - } - - public bool Contains(TKey key, TValue value) - { - TryGetValue(key, out var list); - - return list != null && list.Contains(value); - } - - public void Add(TKey key, TValue value) - { - if (!TryGetValue(key, out var list)) - { - list = Fetch(); - list.Add(value); - base[key] = list; - return; - } - - list.Add(value); - } - - public TValue First(TKey key) - { - return !TryGetValue(key, out var list) ? default : list.FirstOrDefault(); - } - - public void RemoveValue(TKey key, TValue value) - { - if (!TryGetValue(key, out var list)) return; - - list.Remove(value); - - if (list.Count == 0) RemoveKey(key); - } - - public void RemoveKey(TKey key) - { - if (!TryRemove(key, out var list)) return; - - Recycle(list); - } - - private List Fetch() - { - return _queue.Count <= 0 ? new List() : _queue.Dequeue(); - } - - private void Recycle(List list) - { - list.Clear(); - - if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return; - - _queue.Enqueue(list); - } - - protected new void Clear() - { - base.Clear(); - _queue.Clear(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ConcurrentOneToManyList.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ConcurrentOneToManyList.cs.meta deleted file mode 100644 index 1c3e2821..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ConcurrentOneToManyList.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f35e267f0b797464e856a9b9244b4215 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ConcurrentOneToManyQueue.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ConcurrentOneToManyQueue.cs deleted file mode 100644 index 177aac11..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ConcurrentOneToManyQueue.cs +++ /dev/null @@ -1,116 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -#pragma warning disable CS8603 - -namespace TEngine.DataStructure -{ - public class ConcurrentOneToManyQueuePool : ConcurrentOneToManyQueue, IDisposable - where TKey : notnull - { - private bool _isDispose; - - public static ConcurrentOneToManyQueuePool Create() - { - var a = Pool>.Rent(); - a._isDispose = false; - return a; - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } - - public class ConcurrentOneToManyQueue : ConcurrentDictionary> where TKey : notnull - { - private readonly Queue> _queue = new Queue>(); - private readonly int _recyclingLimit; - - /// - /// 设置最大缓存数量 - /// - /// - /// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC. - /// 2:设置成0不控制数量,全部缓存 - /// - public ConcurrentOneToManyQueue(int recyclingLimit = 0) - { - _recyclingLimit = recyclingLimit; - } - - public bool Contains(TKey key, TValue value) - { - TryGetValue(key, out var list); - - return list != null && list.Contains(value); - } - - public void Enqueue(TKey key, TValue value) - { - if (!TryGetValue(key, out var list)) - { - list = Fetch(); - list.Enqueue(value); - TryAdd(key, list); - return; - } - - list.Enqueue(value); - } - - public TValue Dequeue(TKey key) - { - if (!TryGetValue(key, out var list) || list.Count == 0) return default; - - var value = list.Dequeue(); - - if (list.Count == 0) RemoveKey(key); - - return value; - } - - public bool TryDequeue(TKey key, out TValue value) - { - value = Dequeue(key); - - return value != null; - } - - public void RemoveKey(TKey key) - { - if (!TryGetValue(key, out var list)) return; - - TryRemove(key, out _); - Recycle(list); - } - - private Queue Fetch() - { - return _queue.Count <= 0 ? new Queue() : _queue.Dequeue(); - } - - private void Recycle(Queue list) - { - list.Clear(); - - if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return; - - _queue.Enqueue(list); - } - - protected new void Clear() - { - base.Clear(); - _queue.Clear(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ConcurrentOneToManyQueue.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ConcurrentOneToManyQueue.cs.meta deleted file mode 100644 index 70c46829..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ConcurrentOneToManyQueue.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 162f7b8459ead1940bfaef049f6d8e2c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/EntityList.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/EntityList.cs deleted file mode 100644 index 4dc36284..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/EntityList.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TEngine.DataStructure -{ - public sealed class EntityList : List, IDisposable where T : IDisposable - { - private bool _isDispose; - - public static EntityList Create() - { - var list = Pool>.Rent(); - list._isDispose = false; - return list; - } - - public new void Clear() - { - for (var i = 0; i < this.Count; i++) - { - this[i].Dispose(); - } - - base.Clear(); - } - - public void ClearNotDispose() - { - base.Clear(); - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/EntityList.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/EntityList.cs.meta deleted file mode 100644 index 5dcf0472..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/EntityList.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 763e9615aee0ac1428f141df39057bf7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/HashSetPool.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/HashSetPool.cs deleted file mode 100644 index 971b9fc2..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/HashSetPool.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TEngine.DataStructure -{ - public sealed class HashSetPool : HashSet, IDisposable - { - private bool _isDispose; - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - - public static HashSetPool Create() - { - var list = Pool>.Rent(); - list._isDispose = false; - return list; - } - } - - public sealed class HashSetBasePool : IDisposable - { - public HashSet Set = new HashSet(); - - public static HashSetBasePool Create() - { - return Pool>.Rent(); - } - - public void Dispose() - { - Set.Clear(); - Pool>.Return(this); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/HashSetPool.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/HashSetPool.cs.meta deleted file mode 100644 index 0c7c2d3d..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/HashSetPool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0f2f1a1f1a3f5f246a40be1e7bff871a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ListPool.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ListPool.cs deleted file mode 100644 index e7960911..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ListPool.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TEngine.DataStructure -{ - public sealed class ListPool : List, IDisposable - { - private bool _isDispose; - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - - public static ListPool Create(params T[] args) - { - var list = Pool>.Rent(); - list._isDispose = false; - if (args != null) list.AddRange(args); - return list; - } - - public static ListPool Create(List args) - { - var list = Pool>.Rent(); - list._isDispose = false; - if (args != null) list.AddRange(args); - return list; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ListPool.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ListPool.cs.meta deleted file mode 100644 index 8d0fa06c..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ListPool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3014ce89f46d33742acca54a28995242 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyHashSet.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyHashSet.cs deleted file mode 100644 index 3cd6317d..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyHashSet.cs +++ /dev/null @@ -1,121 +0,0 @@ -using System; -using System.Collections.Generic; -#pragma warning disable CS8600 - -namespace TEngine.DataStructure -{ - public class OneToManyHashSetPool : OneToManyHashSet, IDisposable where TKey : notnull - { - private bool _isDispose; - - public static OneToManyHashSetPool Create() - { - var a = Pool>.Rent(); - a._isDispose = false; - return a; - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } - - public class OneToManyHashSet : Dictionary> where TKey : notnull - { - private readonly Queue> _queue = new Queue>(); - private readonly int _recyclingLimit = 120; - private static HashSet _empty = new HashSet(); - - public OneToManyHashSet() - { - } - - /// - /// 设置最大缓存数量 - /// - /// - /// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC. - /// 2:设置成0不控制数量,全部缓存 - /// - public OneToManyHashSet(int recyclingLimit) - { - _recyclingLimit = recyclingLimit; - } - - public bool Contains(TKey key, TValue value) - { - TryGetValue(key, out var list); - - return list != null && list.Contains(value); - } - - public void Add(TKey key, TValue value) - { - if (!TryGetValue(key, out var list)) - { - list = Fetch(); - list.Add(value); - Add(key, list); - - return; - } - - list.Add(value); - } - - public void RemoveValue(TKey key, TValue value) - { - if (!TryGetValue(key, out var list)) return; - - list.Remove(value); - - if (list.Count == 0) RemoveKey(key); - } - - public void RemoveKey(TKey key) - { - if (!TryGetValue(key, out var list)) return; - - Remove(key); - Recycle(list); - } - - public HashSet GetValue(TKey key) - { - if (TryGetValue(key, out HashSet value)) - { - return value; - } - - return _empty; - } - - private HashSet Fetch() - { - return _queue.Count <= 0 ? new HashSet() : _queue.Dequeue(); - } - - private void Recycle(HashSet list) - { - list.Clear(); - - if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return; - - _queue.Enqueue(list); - } - - protected new void Clear() - { - base.Clear(); - _queue.Clear(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyHashSet.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyHashSet.cs.meta deleted file mode 100644 index a8ee7fc7..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyHashSet.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 393302e735c4b2f4885c21dd4235b64a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyList.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyList.cs deleted file mode 100644 index 35d29353..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyList.cs +++ /dev/null @@ -1,141 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -#pragma warning disable CS8600 -#pragma warning disable CS8603 - -namespace TEngine.DataStructure -{ - public class OneToManyListPool : OneToManyList, IDisposable where TKey : notnull - { - private bool _isDispose; - - public static OneToManyListPool Create() - { - var list = Pool>.Rent(); - list._isDispose = false; - return list; - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } - - public class OneToManyList : Dictionary> where TKey : notnull - { - private readonly Queue> _queue = new Queue>(); - private readonly int _recyclingLimit = 120; - private static List _empty = new List(); - - public OneToManyList() - { - } - - /// - /// 设置最大缓存数量 - /// - /// - /// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC. - /// 2:设置成0不控制数量,全部缓存 - /// - public OneToManyList(int recyclingLimit) - { - _recyclingLimit = recyclingLimit; - } - - public bool Contains(TKey key, TValue value) - { - TryGetValue(key, out var list); - - return list != null && list.Contains(value); - } - - public void Add(TKey key, TValue value) - { - if (!TryGetValue(key, out var list)) - { - list = Fetch(); - list.Add(value); - Add(key, list); - - return; - } - - list.Add(value); - } - - public TValue First(TKey key) - { - return !TryGetValue(key, out var list) ? default : list.FirstOrDefault(); - } - - public bool RemoveValue(TKey key, TValue value) - { - if (!TryGetValue(key, out var list)) - { - return true; - } - - var isRemove = list.Remove(value); - - if (list.Count == 0) - { - isRemove = RemoveByKey(key); - } - - return isRemove; - } - - public bool RemoveByKey(TKey key) - { - if (!TryGetValue(key, out var list)) - { - return false; - } - - Remove(key); - Recycle(list); - return true; - } - - public List GetValues(TKey key) - { - if (TryGetValue(key, out List list)) - { - return list; - } - - return _empty; - } - - public new void Clear() - { - foreach (var keyValuePair in this) Recycle(keyValuePair.Value); - - base.Clear(); - } - - private List Fetch() - { - return _queue.Count <= 0 ? new List() : _queue.Dequeue(); - } - - private void Recycle(List list) - { - list.Clear(); - - if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return; - - _queue.Enqueue(list); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyList.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyList.cs.meta deleted file mode 100644 index c548cb74..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyList.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7a6fdf7c8423c0e41804022df95a399d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyQueue.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyQueue.cs deleted file mode 100644 index 6fb4580e..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyQueue.cs +++ /dev/null @@ -1,120 +0,0 @@ -using System; -using System.Collections.Generic; -#pragma warning disable CS8603 - -namespace TEngine.DataStructure -{ - public class OneToManyQueuePool : OneToManyQueue, IDisposable where TKey : notnull - { - private bool _isDispose; - - public static OneToManyQueuePool Create() - { - var a = Pool>.Rent(); - a._isDispose = false; - return a; - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } - - public class OneToManyQueue : Dictionary> where TKey : notnull - { - private readonly Queue> _queue = new Queue>(); - private readonly int _recyclingLimit; - - /// - /// 设置最大缓存数量 - /// - /// - /// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC. - /// 2:设置成0不控制数量,全部缓存 - /// - public OneToManyQueue(int recyclingLimit = 0) - { - _recyclingLimit = recyclingLimit; - } - - public bool Contains(TKey key, TValue value) - { - TryGetValue(key, out var list); - - return list != null && list.Contains(value); - } - - public void Enqueue(TKey key, TValue value) - { - if (!TryGetValue(key, out var list)) - { - list = Fetch(); - list.Enqueue(value); - Add(key, list); - return; - } - - list.Enqueue(value); - } - - public TValue Dequeue(TKey key) - { - if (!TryGetValue(key, out var list) || list.Count == 0) - { - return default; - } - - var value = list.Dequeue(); - - if (list.Count == 0) - { - RemoveKey(key); - } - - return value; - } - - public bool TryDequeue(TKey key, out TValue value) - { - value = Dequeue(key); - - return value != null; - } - - public void RemoveKey(TKey key) - { - if (!TryGetValue(key, out var list)) return; - - Remove(key); - Recycle(list); - } - - private Queue Fetch() - { - return _queue.Count <= 0 ? new Queue() : _queue.Dequeue(); - } - - private void Recycle(Queue list) - { - list.Clear(); - - if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return; - - _queue.Enqueue(list); - } - - protected new void Clear() - { - base.Clear(); - _queue.Clear(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyQueue.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyQueue.cs.meta deleted file mode 100644 index 135cbb39..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/OneToManyQueue.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 35d6a9fde65a99143b0abf6d9569c462 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/PriorityQueue.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/PriorityQueue.cs deleted file mode 100644 index 8c191ca3..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/PriorityQueue.cs +++ /dev/null @@ -1,537 +0,0 @@ -// #if UNITY_5_3_OR_NEWER -// using System; -// using System.Collections; -// using System.Collections.Generic; -// using System.Diagnostics; -// using System.Diagnostics.CodeAnalysis; -// using System.Linq; -// using System.Runtime.CompilerServices; -// #pragma warning disable CS8600 -// -// namespace System.Collections.Generic -// { -// public class PriorityQueue -// { -// private const int DefaultCapacity = 4; -// -// private readonly IComparer _priorityComparer; -// -// private HeapEntry[] _heap; -// private int _count; -// private int _version; -// -// private UnorderedItemsCollection? _unorderedItemsCollection; -// -// #region Constructors -// public PriorityQueue() : this(0, null) -// { -// -// } -// -// // public PriorityQueue(int initialCapacity) : this(initialCapacity, null) -// // { -// // -// // } -// -// // public PriorityQueue(IComparer? comparer) : this(0, comparer) -// // { -// // -// // } -// -// // public PriorityQueue(int initialCapacity, IComparer? comparer) -// // { -// // if (initialCapacity < 0) -// // { -// // throw new ArgumentOutOfRangeException(nameof(initialCapacity)); -// // } -// // -// // if (initialCapacity == 0) -// // { -// // _heap = Array.Empty(); -// // } -// // else -// // { -// // _heap = new HeapEntry[initialCapacity]; -// // } -// // -// // _priorityComparer = comparer ?? Comparer.Default; -// // } -// -// public PriorityQueue(IEnumerable<(TElement Element, TPriority Priority)> values) : this(values, null) -// { -// -// } -// -// public PriorityQueue(IEnumerable<(TElement Element, TPriority Priority)> values, IComparer? comparer) -// { -// _priorityComparer = comparer ?? Comparer.Default; -// _heap = Array.Empty(); -// _count = 0; -// -// AppendRaw(values); -// Heapify(); -// } -// #endregion -// -// public int Count => _count; -// public IComparer Comparer => _priorityComparer; -// -// public void Enqueue(TElement element, TPriority priority) -// { -// _version++; -// if (_count == _heap.Length) -// { -// Resize(ref _heap); -// } -// -// SiftUp(index: _count++, in element, in priority); -// } -// -// public void EnqueueRange(IEnumerable<(TElement Element, TPriority Priority)> values) -// { -// _version++; -// if (_count == 0) -// { -// AppendRaw(values); -// Heapify(); -// } -// else -// { -// foreach ((TElement element, TPriority priority) in values) -// { -// if (_count == _heap.Length) -// { -// Resize(ref _heap); -// } -// -// SiftUp(index: _count++, in element, in priority); -// } -// } -// } -// -// // TODO optimize -// public void EnqueueRange(IEnumerable elements, TPriority priority) => EnqueueRange(elements.Select(e => (e, priority))); -// -// public TElement Peek() -// { -// if (_count == 0) -// { -// throw new InvalidOperationException(); -// } -// -// return _heap[0].Element; -// } -// -// public bool TryPeek([MaybeNullWhen(false)] out TElement element, [MaybeNullWhen(false)] out TPriority priority) -// { -// if (_count == 0) -// { -// element = default; -// priority = default; -// return false; -// } -// -// (element, priority) = _heap[0]; -// return true; -// } -// -// public TElement Dequeue() -// { -// if (_count == 0) -// { -// throw new InvalidOperationException(); -// } -// -// _version++; -// RemoveIndex(index: 0, out TElement result, out _); -// return result; -// } -// -// public bool TryDequeue([MaybeNullWhen(false)] out TElement element, [MaybeNullWhen(false)] out TPriority priority) -// { -// if (_count == 0) -// { -// element = default; -// priority = default; -// return false; -// } -// -// _version++; -// RemoveIndex(index: 0, out element, out priority); -// return true; -// } -// -// public TElement EnqueueDequeue(TElement element, TPriority priority) -// { -// if (_count == 0) -// { -// return element; -// } -// -// ref HeapEntry minEntry = ref _heap[0]; -// if (_priorityComparer.Compare(priority, minEntry.Priority) <= 0) -// { -// return element; -// } -// -// _version++; -// TElement minElement = minEntry.Element; -// #if SIFTDOWN_EMPTY_NODES -// SiftDownHeapPropertyRequired(index: 0, in element, in priority); -// #else -// SiftDown(index: 0, in element, in priority); -// #endif -// return minElement; -// } -// -// public void Clear() -// { -// _version++; -// if (_count > 0) -// { -// //if (RuntimeHelpers.IsReferenceOrContainsReferences()) -// { -// Array.Clear(_heap, 0, _count); -// } -// -// _count = 0; -// } -// } -// -// public void TrimExcess() -// { -// int count = _count; -// int threshold = (int)(((double)_heap.Length) * 0.9); -// if (count < threshold) -// { -// Array.Resize(ref _heap, count); -// } -// } -// -// public void EnsureCapacity(int capacity) -// { -// if (capacity < 0) -// { -// throw new ArgumentOutOfRangeException(); -// } -// -// if (capacity > _heap.Length) -// { -// Array.Resize(ref _heap, capacity); -// } -// } -// -// public UnorderedItemsCollection UnorderedItems => _unorderedItemsCollection ??= new UnorderedItemsCollection(this); -// -// public class UnorderedItemsCollection : IReadOnlyCollection<(TElement Element, TPriority Priority)>, ICollection -// { -// private readonly PriorityQueue _priorityQueue; -// -// internal UnorderedItemsCollection(PriorityQueue priorityQueue) -// { -// _priorityQueue = priorityQueue; -// } -// -// public int Count => _priorityQueue.Count; -// public bool IsSynchronized => false; -// public object SyncRoot => _priorityQueue; -// -// public Enumerator GetEnumerator() => new Enumerator(_priorityQueue); -// IEnumerator<(TElement Element, TPriority Priority)> IEnumerable<(TElement Element, TPriority Priority)>.GetEnumerator() => new Enumerator(_priorityQueue); -// IEnumerator IEnumerable.GetEnumerator() => new Enumerator(_priorityQueue); -// -// bool ICollection.IsSynchronized => false; -// object ICollection.SyncRoot => this; -// void ICollection.CopyTo(Array array, int index) -// { -// if (array == null) -// throw new ArgumentNullException(nameof(array)); -// if (array.Rank != 1) -// throw new ArgumentException("SR.Arg_RankMultiDimNotSupported", nameof(array)); -// if (index < 0) -// throw new ArgumentOutOfRangeException(nameof(index), "SR.ArgumentOutOfRange_Index"); -// -// int arrayLen = array.Length; -// if (arrayLen - index < _priorityQueue._count) -// throw new ArgumentException("SR.Argument_InvalidOffLen"); -// -// int numToCopy = _priorityQueue._count; -// HeapEntry[] heap = _priorityQueue._heap; -// -// for (int i = 0; i < numToCopy; i++) -// { -// ref HeapEntry entry = ref heap[i]; -// array.SetValue((entry.Element, entry.Priority), index + i); -// } -// } -// -// public struct Enumerator : IEnumerator<(TElement Element, TPriority Priority)>, IEnumerator -// { -// private readonly PriorityQueue _queue; -// private readonly int _version; -// private int _index; -// private (TElement Element, TPriority Priority) _current; -// -// internal Enumerator(PriorityQueue queue) -// { -// _version = queue._version; -// _queue = queue; -// _index = 0; -// _current = default; -// } -// -// public bool MoveNext() -// { -// PriorityQueue queue = _queue; -// -// if (queue._version == _version && _index < queue._count) -// { -// ref HeapEntry entry = ref queue._heap[_index]; -// _current = (entry.Element, entry.Priority); -// _index++; -// return true; -// } -// -// if (queue._version != _version) -// { -// throw new InvalidOperationException("collection was modified"); -// } -// -// return false; -// } -// -// public (TElement Element, TPriority Priority) Current => _current; -// object IEnumerator.Current => _current; -// -// public void Reset() -// { -// if (_queue._version != _version) -// { -// throw new InvalidOperationException("collection was modified"); -// } -// -// _index = 0; -// _current = default; -// } -// -// public void Dispose() -// { -// } -// } -// } -// -// #region Private Methods -// private void Heapify() -// { -// HeapEntry[] heap = _heap; -// -// for (int i = (_count - 1) >> 2; i >= 0; i--) -// { -// HeapEntry entry = heap[i]; // ensure struct is copied before sifting -// SiftDown(i, in entry.Element, in entry.Priority); -// } -// } -// -// private void AppendRaw(IEnumerable<(TElement Element, TPriority Priority)> values) -// { -// // TODO: specialize on ICollection types -// var heap = _heap; -// int count = _count; -// -// foreach ((TElement element, TPriority priority) in values) -// { -// if (count == heap.Length) -// { -// Resize(ref heap); -// } -// -// ref HeapEntry entry = ref heap[count]; -// entry.Element = element; -// entry.Priority = priority; -// count++; -// } -// -// _heap = heap; -// _count = count; -// } -// -// private void RemoveIndex(int index, out TElement element, out TPriority priority) -// { -// Debug.Assert(index < _count); -// -// (element, priority) = _heap[index]; -// -// int lastElementPos = --_count; -// ref HeapEntry lastElement = ref _heap[lastElementPos]; -// -// if (lastElementPos > 0) -// { -// #if SIFTDOWN_EMPTY_NODES -// SiftDownHeapPropertyRequired(index, in lastElement.Element, in lastElement.Priority); -// #else -// SiftDown(index, in lastElement.Element, in lastElement.Priority); -// #endif -// } -// -// //if (RuntimeHelpers.IsReferenceOrContainsReferences()) -// { -// lastElement = default; -// } -// } -// -// private void SiftUp(int index, in TElement element, in TPriority priority) -// { -// while (index > 0) -// { -// int parentIndex = (index - 1) >> 2; -// ref HeapEntry parent = ref _heap[parentIndex]; -// -// if (_priorityComparer.Compare(parent.Priority, priority) <= 0) -// { -// // parentPriority <= priority, heap property is satisfed -// break; -// } -// -// _heap[index] = parent; -// index = parentIndex; -// } -// -// ref HeapEntry entry = ref _heap[index]; -// entry.Element = element; -// entry.Priority = priority; -// } -// -// private void SiftDown(int index, in TElement element, in TPriority priority) -// { -// int minChildIndex; -// int count = _count; -// HeapEntry[] heap = _heap; -// -// while ((minChildIndex = (index << 2) + 1) < count) -// { -// // find the child with the minimal priority -// ref HeapEntry minChild = ref heap[minChildIndex]; -// int childUpperBound = Math.Min(count, minChildIndex + 4); -// -// for (int nextChildIndex = minChildIndex + 1; nextChildIndex < childUpperBound; nextChildIndex++) -// { -// ref HeapEntry nextChild = ref heap[nextChildIndex]; -// if (_priorityComparer.Compare(nextChild.Priority, minChild.Priority) < 0) -// { -// minChildIndex = nextChildIndex; -// minChild = ref nextChild; -// } -// } -// -// // compare with inserted priority -// if (_priorityComparer.Compare(priority, minChild.Priority) <= 0) -// { -// // priority <= minChild, heap property is satisfied -// break; -// } -// -// heap[index] = minChild; -// index = minChildIndex; -// } -// -// ref HeapEntry entry = ref heap[index]; -// entry.Element = element; -// entry.Priority = priority; -// } -// -// #if SIFTDOWN_EMPTY_NODES -// private void SiftDownHeapPropertyRequired(int index, in TElement element, in TPriority priority) -// { -// int emptyNodeIndex = SiftDownEmptyNode(index); -// SiftUp(emptyNodeIndex, in element, in priority); -// } -// -// private int SiftDownEmptyNode(int emptyNodeIndex) -// { -// int count = _count; -// int minChildIndex; -// HeapEntry[] heap = _heap; -// -// while ((minChildIndex = (emptyNodeIndex << 2) + 1) < count) -// { -// // find the child with the minimal priority -// ref HeapEntry minChild = ref heap[minChildIndex]; -// int childUpperBound = Math.Min(count, minChildIndex + 4); -// -// for (int nextChildIndex = minChildIndex + 1; nextChildIndex < childUpperBound; nextChildIndex++) -// { -// ref HeapEntry nextChild = ref heap[nextChildIndex]; -// if (_priorityComparer.Compare(nextChild.Priority, minChild.Priority) < 0) -// { -// minChildIndex = nextChildIndex; -// minChild = ref nextChild; -// } -// } -// -// heap[emptyNodeIndex] = minChild; -// emptyNodeIndex = minChildIndex; -// } -// -// return emptyNodeIndex; -// } -// #endif -// -// private void Resize(ref HeapEntry[] heap) -// { -// int newSize = heap.Length == 0 ? DefaultCapacity : 2 * heap.Length; -// Array.Resize(ref heap, newSize); -// } -// -// private struct HeapEntry -// { -// public TElement Element; -// public TPriority Priority; -// -// public void Deconstruct(out TElement element, out TPriority priority) -// { -// element = Element; -// priority = Priority; -// } -// } -// -// #if DEBUG -// public void ValidateInternalState() -// { -// if (_heap.Length < _count) -// { -// throw new Exception("invalid elements array length"); -// } -// -// foreach ((var element, var idx) in _heap.Select((x, i) => (x.Element, i)).Skip(_count)) -// { -// if (!IsDefault(element)) -// { -// throw new Exception($"Non-zero element '{element}' at index {idx}."); -// } -// } -// -// foreach ((var priority, var idx) in _heap.Select((x, i) => (x.Priority, i)).Skip(_count)) -// { -// if (!IsDefault(priority)) -// { -// throw new Exception($"Non-zero priority '{priority}' at index {idx}."); -// } -// } -// -// static bool IsDefault(T value) -// { -// T defaultVal = default; -// -// if (defaultVal is null) -// { -// return value is null; -// } -// -// return value!.Equals(defaultVal); -// } -// } -// #endif -// #endregion -// } -// } -// #endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/PriorityQueue.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/PriorityQueue.cs.meta deleted file mode 100644 index 48c9a39f..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/PriorityQueue.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1e7e9292b9c27384d9aed58ea3d5098d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ReuseList.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ReuseList.cs deleted file mode 100644 index 8905104b..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ReuseList.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TEngine.DataStructure -{ - public sealed class ReuseList : List, IDisposable - { - private bool _isDispose; - - public static ReuseList Create() - { - var list = Pool>.Rent(); - list._isDispose = false; - return list; - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ReuseList.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ReuseList.cs.meta deleted file mode 100644 index 17e47eac..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/ReuseList.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fe34244ec94ec0240a92d11c66f9d94e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedConcurrentOneToManyList.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedConcurrentOneToManyList.cs deleted file mode 100644 index 9a638732..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedConcurrentOneToManyList.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -#pragma warning disable CS8603 - -namespace TEngine.DataStructure -{ - public class SortedConcurrentOneToManyListPool : SortedConcurrentOneToManyList, - IDisposable where TKey : notnull - { - private bool _isDispose; - - public static SortedConcurrentOneToManyListPool Create() - { - var a = Pool>.Rent(); - a._isDispose = false; - return a; - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } - - public class SortedConcurrentOneToManyList : SortedDictionary> where TKey : notnull - { - private readonly object _lockObject = new object(); - private readonly Queue> _queue = new Queue>(); - private readonly int _recyclingLimit; - - public SortedConcurrentOneToManyList() - { - } - - /// - /// 设置最大缓存数量 - /// - /// - /// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC. - /// 2:设置成0不控制数量,全部缓存 - /// - public SortedConcurrentOneToManyList(int recyclingLimit = 0) - { - _recyclingLimit = recyclingLimit; - } - - public bool Contains(TKey key, TValue value) - { - lock (_lockObject) - { - TryGetValue(key, out var list); - - return list != null && list.Contains(value); - } - } - - public void Add(TKey key, TValue value) - { - lock (_lockObject) - { - if (!TryGetValue(key, out var list)) - { - list = Fetch(); - list.Add(value); - base[key] = list; - return; - } - - list.Add(value); - } - } - - public TValue First(TKey key) - { - lock (_lockObject) - { - return !TryGetValue(key, out var list) ? default : list.FirstOrDefault(); - } - } - - public void RemoveValue(TKey key, TValue value) - { - lock (_lockObject) - { - if (!TryGetValue(key, out var list)) return; - - list.Remove(value); - - if (list.Count == 0) RemoveKey(key); - } - } - - public void RemoveKey(TKey key) - { - lock (_lockObject) - { - if (!TryGetValue(key, out var list)) return; - - Remove(key); - - Recycle(list); - } - } - - private List Fetch() - { - lock (_lockObject) - { - return _queue.Count <= 0 ? new List() : _queue.Dequeue(); - } - } - - private void Recycle(List list) - { - lock (_lockObject) - { - list.Clear(); - - if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return; - - _queue.Enqueue(list); - } - } - - protected new void Clear() - { - base.Clear(); - _queue.Clear(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedConcurrentOneToManyList.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedConcurrentOneToManyList.cs.meta deleted file mode 100644 index 50fdb007..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedConcurrentOneToManyList.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 24aa8bc8ac4d8584cb9ceb23a51c78fa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedOneToManyHashSet.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedOneToManyHashSet.cs deleted file mode 100644 index 93027527..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedOneToManyHashSet.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TEngine.DataStructure -{ - public class SortedOneToManyHashSetPool : SortedOneToManyHashSet, IDisposable - where TKey : notnull - { - private bool _isDispose; - - public static SortedOneToManyHashSetPool Create() - { - var a = Pool>.Rent(); - a._isDispose = false; - return a; - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } - - public class SortedOneToManyHashSet : SortedDictionary> where TKey : notnull - { - private readonly Queue> _queue = new Queue>(); - private readonly int _recyclingLimit = 120; - - public SortedOneToManyHashSet() - { - } - - /// - /// 设置最大缓存数量 - /// - /// - /// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC. - /// 2:设置成0不控制数量,全部缓存 - /// - public SortedOneToManyHashSet(int recyclingLimit) - { - _recyclingLimit = recyclingLimit; - } - - public bool Contains(TKey key, TValue value) - { - TryGetValue(key, out var list); - - return list != null && list.Contains(value); - } - - public void Add(TKey key, TValue value) - { - if (!TryGetValue(key, out var list)) - { - list = Fetch(); - list.Add(value); - Add(key, list); - - return; - } - - list.Add(value); - } - - public void RemoveValue(TKey key, TValue value) - { - if (!TryGetValue(key, out var list)) return; - - list.Remove(value); - - if (list.Count == 0) RemoveKey(key); - } - - public void RemoveKey(TKey key) - { - if (!TryGetValue(key, out var list)) return; - - Remove(key); - - Recycle(list); - } - - private HashSet Fetch() - { - return _queue.Count <= 0 ? new HashSet() : _queue.Dequeue(); - } - - private void Recycle(HashSet list) - { - list.Clear(); - - if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return; - - _queue.Enqueue(list); - } - - protected new void Clear() - { - base.Clear(); - _queue.Clear(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedOneToManyHashSet.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedOneToManyHashSet.cs.meta deleted file mode 100644 index 6f6c11d0..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedOneToManyHashSet.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ddf73601eadf11349b77b78a4d91f35a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedOneToManyList.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedOneToManyList.cs deleted file mode 100644 index 432feca6..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedOneToManyList.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -#pragma warning disable CS8603 - -namespace TEngine.DataStructure -{ - public class SortedOneToManyListPool : SortedOneToManyList, IDisposable - where TKey : notnull - { - private bool _isDispose; - - public static SortedOneToManyListPool Create() - { - var a = Pool>.Rent(); - a._isDispose = false; - return a; - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } - - public class SortedOneToManyList : SortedDictionary> where TKey : notnull - { - private readonly Queue> _queue = new Queue>(); - private readonly int _recyclingLimit; - - public SortedOneToManyList() - { - } - - /// - /// 设置最大缓存数量 - /// - /// - /// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC. - /// 2:设置成0不控制数量,全部缓存 - /// - public SortedOneToManyList(int recyclingLimit = 0) - { - _recyclingLimit = recyclingLimit; - } - - public bool Contains(TKey key, TValue value) - { - TryGetValue(key, out var list); - - return list != null && list.Contains(value); - } - - public void Add(TKey key, TValue value) - { - if (!TryGetValue(key, out var list)) - { - list = Fetch(); - list.Add(value); - base[key] = list; - return; - } - - list.Add(value); - } - - public TValue First(TKey key) - { - return !TryGetValue(key, out var list) ? default : list.FirstOrDefault(); - } - - public void RemoveValue(TKey key, TValue value) - { - if (!TryGetValue(key, out var list)) - { - return; - } - - list.Remove(value); - - if (list.Count == 0) - { - RemoveKey(key); - } - } - - public void RemoveKey(TKey key) - { - if (!TryGetValue(key, out var list)) - { - return; - } - - Remove(key); - Recycle(list); - } - - private List Fetch() - { - return _queue.Count <= 0 ? new List() : _queue.Dequeue(); - } - - private void Recycle(List list) - { - list.Clear(); - - if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) - { - return; - } - - _queue.Enqueue(list); - } - - protected new void Clear() - { - base.Clear(); - _queue.Clear(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedOneToManyList.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedOneToManyList.cs.meta deleted file mode 100644 index e2e1459c..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Collection/SortedOneToManyList.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: db62c1998de4d5048bde5d5e09d6f284 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary.meta deleted file mode 100644 index 9a527253..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3217a5df0b4fae04cad4694ae07948b8 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DictionaryExtensions.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DictionaryExtensions.cs deleted file mode 100644 index 0f7d031f..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DictionaryExtensions.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Collections.Generic; -#pragma warning disable CS8601 - -namespace TEngine.DataStructure -{ - public static class DictionaryExtensions - { - public static bool TryRemove(this IDictionary self, T key, out TV value) - { - if (!self.TryGetValue(key, out value)) - { - return false; - } - - self.Remove(key); - return true; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DictionaryExtensions.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DictionaryExtensions.cs.meta deleted file mode 100644 index 477a6f3d..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DictionaryExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2906692879c7825458790e8cb128e7f2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DictionaryPool.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DictionaryPool.cs deleted file mode 100644 index e48f8764..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DictionaryPool.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TEngine.DataStructure -{ - public sealed class DictionaryPool : Dictionary, IDisposable where TM : notnull - { - private bool _isDispose; - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - - public static DictionaryPool Create() - { - var dictionary = Pool>.Rent(); - dictionary._isDispose = false; - return dictionary; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DictionaryPool.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DictionaryPool.cs.meta deleted file mode 100644 index 112d7f84..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DictionaryPool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 45285f160861f9c4bb96634e744e2c74 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DoubleMapDictionary.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DoubleMapDictionary.cs deleted file mode 100644 index b4259f45..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DoubleMapDictionary.cs +++ /dev/null @@ -1,174 +0,0 @@ -using System; -using System.Collections.Generic; -#pragma warning disable CS8601 -#pragma warning disable CS8604 -#pragma warning disable CS8603 - -namespace TEngine.DataStructure -{ - public class DoubleMapDictionaryPool : DoubleMapDictionary, IDisposable - where TKey : notnull where TValue : notnull - { - private bool _isDispose; - - public static DoubleMapDictionaryPool Create() - { - var a = Pool>.Rent(); - a._isDispose = false; - return a; - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } - - public class DoubleMapDictionary where TK : notnull where TV : notnull - { - private readonly Dictionary _kv = new Dictionary(); - private readonly Dictionary _vk = new Dictionary(); - - public DoubleMapDictionary() - { - } - - public DoubleMapDictionary(int capacity) - { - _kv = new Dictionary(capacity); - _vk = new Dictionary(capacity); - } - - public List Keys => new List(_kv.Keys); - - public List Values => new List(_vk.Keys); - - public void ForEach(Action action) - { - if (action == null) - { - return; - } - - var keys = _kv.Keys; - foreach (var key in keys) - { - action(key, _kv[key]); - } - } - - public void Add(TK key, TV value) - { - if (key == null || value == null || _kv.ContainsKey(key) || _vk.ContainsKey(value)) - { - return; - } - - _kv.Add(key, value); - _vk.Add(value, key); - } - - public TV GetValueByKey(TK key) - { - if (key != null && _kv.ContainsKey(key)) - { - return _kv[key]; - } - - return default; - } - - public bool TryGetValueByKey(TK key, out TV value) - { - var result = key != null && _kv.ContainsKey(key); - - value = result ? _kv[key] : default; - - return result; - } - - public TK GetKeyByValue(TV value) - { - if (value != null && _vk.ContainsKey(value)) - { - return _vk[value]; - } - - return default; - } - - public bool TryGetKeyByValue(TV value, out TK key) - { - var result = value != null && _vk.ContainsKey(value); - - key = result ? _vk[value] : default; - - return result; - } - - public void RemoveByKey(TK key) - { - if (key == null) - { - return; - } - - if (!_kv.TryGetValue(key, out var value)) - { - return; - } - - _kv.Remove(key); - _vk.Remove(value); - } - - public void RemoveByValue(TV value) - { - if (value == null) - { - return; - } - - if (!_vk.TryGetValue(value, out var key)) - { - return; - } - - _kv.Remove(key); - _vk.Remove(value); - } - - public void Clear() - { - _kv.Clear(); - _vk.Clear(); - } - - public bool ContainsKey(TK key) - { - return key != null && _kv.ContainsKey(key); - } - - public bool ContainsValue(TV value) - { - return value != null && _vk.ContainsKey(value); - } - - public bool Contains(TK key, TV value) - { - if (key == null || value == null) - { - return false; - } - - return _kv.ContainsKey(key) && _vk.ContainsKey(value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DoubleMapDictionary.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DoubleMapDictionary.cs.meta deleted file mode 100644 index a258a377..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/DoubleMapDictionary.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e9b1abd0ffc450842bea6ec96e84425f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/EntityDictionary.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/EntityDictionary.cs deleted file mode 100644 index ec103299..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/EntityDictionary.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TEngine.DataStructure -{ - public sealed class EntityDictionary : Dictionary, IDisposable where TN : IDisposable where TM : notnull - { - private bool _isDispose; - - public static EntityDictionary Create() - { - var entityDictionary = Pool>.Rent(); - entityDictionary._isDispose = false; - return entityDictionary; - } - - public new void Clear() - { - foreach (var keyValuePair in this) - { - keyValuePair.Value.Dispose(); - } - - base.Clear(); - } - - public void ClearNotDispose() - { - base.Clear(); - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/EntityDictionary.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/EntityDictionary.cs.meta deleted file mode 100644 index 97e564f5..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/EntityDictionary.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3e08b2b0077e40143a1f772a0f7b1ad5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/OneToManyDictionary.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/OneToManyDictionary.cs deleted file mode 100644 index e6cc73bf..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/OneToManyDictionary.cs +++ /dev/null @@ -1,147 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -#pragma warning disable CS8603 -#pragma warning disable CS8601 - -namespace TEngine.DataStructure -{ - public class OneToManyDictionaryPool : OneToManyDictionary, - IDisposable where TKey : notnull where TValueKey : notnull - { - private bool _isDispose; - - public static OneToManyDictionaryPool Create() - { - var a = Pool>.Rent(); - a._isDispose = false; - return a; - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } - - public class OneToManyDictionary : Dictionary> - where TKey : notnull where TValueKey : notnull - { - private readonly Queue> _queue = new Queue>(); - private readonly int _recyclingLimit = 120; - - public OneToManyDictionary() - { - } - - /// - /// 设置最大缓存数量 - /// - /// - /// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC. - /// 2:设置成0不控制数量,全部缓存 - /// - public OneToManyDictionary(int recyclingLimit = 0) - { - _recyclingLimit = recyclingLimit; - } - - public bool Contains(TKey key, TValueKey valueKey) - { - TryGetValue(key, out var dic); - - return dic != null && dic.ContainsKey(valueKey); - } - - public bool TryGetValue(TKey key, TValueKey valueKey, out TValue value) - { - value = default; - return TryGetValue(key, out var dic) && dic.TryGetValue(valueKey, out value); - } - - public TValue First(TKey key) - { - return !TryGetValue(key, out var dic) ? default : dic.First().Value; - } - - public void Add(TKey key, TValueKey valueKey, TValue value) - { - if (!TryGetValue(key, out var dic)) - { - dic = Fetch(); - dic[valueKey] = value; - // dic.Add(valueKey, value); - Add(key, dic); - - return; - } - - dic[valueKey] = value; - // dic.Add(valueKey, value); - } - - public bool Remove(TKey key, TValueKey valueKey) - { - if (!TryGetValue(key, out var dic)) return false; - - var result = dic.Remove(valueKey); - - if (dic.Count == 0) RemoveKey(key); - - return result; - } - - public bool Remove(TKey key, TValueKey valueKey, out TValue value) - { - if (!TryGetValue(key, out var dic)) - { - value = default; - return false; - } - - var result = dic.TryGetValue(valueKey, out value); - - if (result) dic.Remove(valueKey); - - if (dic.Count == 0) RemoveKey(key); - - return result; - } - - public void RemoveKey(TKey key) - { - if (!TryGetValue(key, out var dic)) return; - - Remove(key); - Recycle(dic); - } - - private Dictionary Fetch() - { - return _queue.Count <= 0 ? new Dictionary() : _queue.Dequeue(); - } - - private void Recycle(Dictionary dic) - { - dic.Clear(); - - if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) return; - - _queue.Enqueue(dic); - } - - public new void Clear() - { - foreach (var keyValuePair in this) Recycle(keyValuePair.Value); - - base.Clear(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/OneToManyDictionary.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/OneToManyDictionary.cs.meta deleted file mode 100644 index 3c465392..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/OneToManyDictionary.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5db437bfa1f9b8b438b7260196e01934 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/OneToManySortedDictionary.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/OneToManySortedDictionary.cs deleted file mode 100644 index 4dc4afab..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/OneToManySortedDictionary.cs +++ /dev/null @@ -1,150 +0,0 @@ -using System; -using System.Collections.Generic; -#pragma warning disable CS8601 - -namespace TEngine.DataStructure -{ - public class - OneToManySortedDictionaryPool : OneToManySortedDictionary, - IDisposable where TKey : notnull where TSortedKey : notnull - { - private bool _isDispose; - - public static OneToManySortedDictionaryPool Create() - { - var a = Pool>.Rent(); - a._isDispose = false; - return a; - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } - - public class - OneToManySortedDictionary : Dictionary> - where TSortedKey : notnull where TKey : notnull - { - private readonly int _recyclingLimit = 120; - - private readonly Queue> _queue = - new Queue>(); - - protected OneToManySortedDictionary() - { - } - - /// - /// 设置最大缓存数量 - /// - /// - /// 1:防止数据量过大、所以超过recyclingLimit的数据还是走GC. - /// 2:设置成0不控制数量,全部缓存 - /// - public OneToManySortedDictionary(int recyclingLimit) - { - _recyclingLimit = recyclingLimit; - } - - public bool Contains(TKey key) - { - return this.ContainsKey(key); - } - - public bool Contains(TKey key, TSortedKey sortedKey) - { - return TryGetValue(key, out var dic) && dic.ContainsKey(sortedKey); - } - - public new bool TryGetValue(TKey key, out SortedDictionary dic) - { - return base.TryGetValue(key, out dic); - } - - public bool TryGetValueBySortedKey(TKey key, TSortedKey sortedKey, out TValue value) - { - if (base.TryGetValue(key, out var dic)) - { - return dic.TryGetValue(sortedKey, out value); - } - - value = default; - return false; - } - - public void Add(TKey key, TSortedKey sortedKey, TValue value) - { - if (!TryGetValue(key, out var dic)) - { - dic = Fetch(); - dic.Add(sortedKey, value); - Add(key, dic); - - return; - } - - dic.Add(sortedKey, value); - } - - public bool RemoveSortedKey(TKey key, TSortedKey sortedKey) - { - if (!TryGetValue(key, out var dic)) - { - return false; - } - - var isRemove = dic.Remove(sortedKey); - - if (dic.Count == 0) - { - isRemove = RemoveKey(key); - } - - return isRemove; - } - - public bool RemoveKey(TKey key) - { - if (!TryGetValue(key, out var list)) - { - return false; - } - - Remove(key); - Recycle(list); - return true; - } - - private SortedDictionary Fetch() - { - return _queue.Count <= 0 ? new SortedDictionary() : _queue.Dequeue(); - } - - private void Recycle(SortedDictionary dic) - { - dic.Clear(); - - if (_recyclingLimit != 0 && _queue.Count > _recyclingLimit) - { - return; - } - - _queue.Enqueue(dic); - } - - protected new void Clear() - { - base.Clear(); - _queue.Clear(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/OneToManySortedDictionary.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/OneToManySortedDictionary.cs.meta deleted file mode 100644 index 354acedf..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/OneToManySortedDictionary.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c0ac9ed7abbf4e4408901274ee344642 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/ReuseDictionary.cs b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/ReuseDictionary.cs deleted file mode 100644 index 4df0b125..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/ReuseDictionary.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TEngine.DataStructure -{ - public sealed class ReuseDictionary : Dictionary, IDisposable where TM : notnull - { - private bool _isDispose; - - public static ReuseDictionary Create() - { - var entityDictionary = Pool>.Rent(); - entityDictionary._isDispose = false; - return entityDictionary; - } - - public void Dispose() - { - if (_isDispose) - { - return; - } - - _isDispose = true; - Clear(); - Pool>.Return(this); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/ReuseDictionary.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/ReuseDictionary.cs.meta deleted file mode 100644 index 1e76d601..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/Dictionary/ReuseDictionary.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bf01018dd07bd2243b8636a1321f50c5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable.meta b/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable.meta deleted file mode 100644 index d4889032..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a7e0baed1cdd57b4e916270c39382710 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTable.cs b/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTable.cs deleted file mode 100644 index 47af78b2..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTable.cs +++ /dev/null @@ -1,166 +0,0 @@ -#pragma warning disable CS8602 -#pragma warning disable CS8601 -#pragma warning disable CS8625 -#pragma warning disable CS8604 -#pragma warning disable CS8600 -namespace TEngine.DataStructure -{ - /// - /// 跳表升序版 - /// - /// - public class SkipTable : SkipTableBase - { - public SkipTable(int maxLayer = 8) : base(maxLayer) { } - public override void Add(long sortKey, long viceKey, long key, TValue value) - { - var rLevel = 1; - - while (rLevel <= MaxLayer && Random.Next(3) == 0) - { - ++rLevel; - } - - SkipTableNode cur = TopHeader, last = null; - - for (var layer = MaxLayer; layer >= 1; --layer) - { - // 节点有next节点,且 (next主键 < 插入主键) 或 (next主键 == 插入主键 且 next副键 < 插入副键) - while (cur.Right != null && ((cur.Right.SortKey < sortKey) || - (cur.Right.SortKey == sortKey && cur.Right.ViceKey < viceKey))) - { - cur = cur.Right; - } - - if (layer <= rLevel) - { - var currentRight = cur.Right; - - cur.Right = new SkipTableNode(sortKey, viceKey, key, value, layer == 1 ? cur.Index + 1 : 0, cur, cur.Right, null); - - if (currentRight != null) - { - currentRight.Left = cur.Right; - } - - if (last != null) - { - last.Down = cur.Right; - } - - if (layer == 1) - { - cur.Right.Index = cur.Index + 1; - Node.Add(key, cur.Right); - - SkipTableNode v = cur.Right.Right; - - while (v != null) - { - v.Index++; - v = v.Right; - } - } - - last = cur.Right; - } - - cur = cur.Down; - } - } - public override bool Remove(long sortKey, long viceKey, long key, out TValue value) - { - value = default; - var seen = false; - var cur = TopHeader; - - for (var layer = MaxLayer; layer >= 1; --layer) - { - // 先按照主键查找 再 按副键查找 - while (cur.Right != null && cur.Right.SortKey < sortKey && cur.Right.Key != key) cur = cur.Right; - while (cur.Right != null && (cur.Right.SortKey == sortKey && cur.Right.ViceKey <= viceKey) && - cur.Right.Key != key) cur = cur.Right; - - var isFind = false; - var currentCur = cur; - SkipTableNode removeCur = null; - // 如果当前不是要删除的节点、但主键和副键都一样、需要特殊处理下。 - if (cur.Right != null && cur.Right.Key == key) - { - isFind = true; - removeCur = cur.Right; - currentCur = cur; - } - else - { - // 先向左查找下 - var currentNode = cur.Left; - while (currentNode != null && currentNode.SortKey == sortKey && currentNode.ViceKey == viceKey) - { - if (currentNode.Key == key) - { - isFind = true; - removeCur = currentNode; - currentCur = currentNode.Left; - break; - } - - currentNode = currentNode.Left; - } - - // 再向右查找下 - if (!isFind) - { - currentNode = cur.Right; - while (currentNode != null && currentNode.SortKey == sortKey && currentNode.ViceKey == viceKey) - { - if (currentNode.Key == key) - { - isFind = true; - removeCur = currentNode; - currentCur = currentNode.Left; - break; - } - - currentNode = currentNode.Right; - } - } - } - - if (isFind && currentCur != null) - { - value = removeCur.Value; - currentCur.Right = removeCur.Right; - - if (removeCur.Right != null) - { - removeCur.Right.Left = currentCur; - removeCur.Right = null; - } - - removeCur.Left = null; - removeCur.Down = null; - removeCur.Value = default; - - if (layer == 1) - { - var tempCur = currentCur.Right; - while (tempCur != null) - { - tempCur.Index--; - tempCur = tempCur.Right; - } - - Node.Remove(removeCur.Key); - } - - seen = true; - } - - cur = cur.Down; - } - - return seen; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTable.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTable.cs.meta deleted file mode 100644 index 13f9f83d..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTable.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 94af5a03823f82246a24b4e5dfdc2be5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableBase.cs b/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableBase.cs deleted file mode 100644 index 9e9a635a..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableBase.cs +++ /dev/null @@ -1,181 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -#pragma warning disable CS8601 -#pragma warning disable CS8603 -#pragma warning disable CS8625 -#pragma warning disable CS8604 - -namespace TEngine.DataStructure -{ - public abstract class SkipTableBase : IEnumerable> - { - public readonly int MaxLayer; - public readonly SkipTableNode TopHeader; - public SkipTableNode BottomHeader; - - public int Count => Node.Count; - protected readonly Random Random = new Random(); - protected readonly Dictionary> Node = new(); - protected readonly Stack> AntiFindStack = new Stack>(); - - protected SkipTableBase(int maxLayer = 8) - { - MaxLayer = maxLayer; - var cur = TopHeader = new SkipTableNode(long.MinValue, 0, 0, default, 0, null, null, null); - - for (var layer = MaxLayer - 1; layer >= 1; --layer) - { - cur.Down = new SkipTableNode(long.MinValue, 0, 0, default, 0, null, null, null); - cur = cur.Down; - } - - BottomHeader = cur; - } - - public TValue this[long key] => !TryGetValueByKey(key, out TValue value) ? default : value; - - public int GetRanking(long key) - { - if (!Node.TryGetValue(key, out var node)) - { - return 0; - } - - return node.Index; - } - - public int GetAntiRanking(long key) - { - var ranking = GetRanking(key); - - if (ranking == 0) - { - return 0; - } - - return Count + 1 - ranking; - } - - public bool TryGetValueByKey(long key, out TValue value) - { - if (!Node.TryGetValue(key, out var node)) - { - value = default; - return false; - } - - value = node.Value; - return true; - } - - public bool TryGetNodeByKey(long key, out SkipTableNode node) - { - if (Node.TryGetValue(key, out node)) - { - return true; - } - - return false; - } - - public void Find(int start, int end, ListPool> list) - { - var cur = BottomHeader; - var count = end - start; - - for (var i = 0; i < start; i++) - { - cur = cur.Right; - } - - for (var i = 0; i <= count; i++) - { - if (cur == null) - { - break; - } - - list.Add(cur); - cur = cur.Right; - } - } - - public void AntiFind(int start, int end, ListPool> list) - { - var cur = BottomHeader; - start = Count + 1 - start; - end = start - end; - - for (var i = 0; i < start; i++) - { - cur = cur.Right; - - if (cur == null) - { - break; - } - - if (i < end) - { - continue; - } - - AntiFindStack.Push(cur); - } - - while (AntiFindStack.TryPop(out var node)) - { - list.Add(node); - } - } - - public TValue GetLastValue() - { - var cur = TopHeader; - - while (cur.Right != null || cur.Down != null) - { - while (cur.Right != null) - { - cur = cur.Right; - } - - if (cur.Down != null) - { - cur = cur.Down; - } - } - - return cur.Value; - } - - public bool Remove(long key) - { - if (!Node.TryGetValue(key, out var node)) - { - return false; - } - - return Remove(node.SortKey, node.ViceKey, key, out _); - } - - public abstract void Add(long sortKey, long viceKey, long key, TValue value); - public abstract bool Remove(long sortKey, long viceKey, long key, out TValue value); - - public IEnumerator> GetEnumerator() - { - var cur = BottomHeader.Right; - while (cur != null) - { - yield return cur; - cur = cur.Right; - } - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableBase.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableBase.cs.meta deleted file mode 100644 index 1b8d4294..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c3dacacc147f7c8499e328284a0542ef -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableDesc.cs b/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableDesc.cs deleted file mode 100644 index 73162e9a..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableDesc.cs +++ /dev/null @@ -1,166 +0,0 @@ -#pragma warning disable CS8602 -#pragma warning disable CS8601 -#pragma warning disable CS8625 -#pragma warning disable CS8604 -#pragma warning disable CS8600 -namespace TEngine.DataStructure -{ - /// - /// 跳表降序版 - /// - /// - public class SkipTableDesc : SkipTableBase - { - public SkipTableDesc(int maxLayer = 8) : base(maxLayer) { } - public override void Add(long sortKey, long viceKey, long key, TValue value) - { - var rLevel = 1; - - while (rLevel <= MaxLayer && Random.Next(3) == 0) - { - ++rLevel; - } - - SkipTableNode cur = TopHeader, last = null; - - for (var layer = MaxLayer; layer >= 1; --layer) - { - // 节点有next节点,且 (next主键 > 插入主键) 或 (next主键 == 插入主键 且 next副键 > 插入副键) - while (cur.Right != null && ((cur.Right.SortKey > sortKey) || - (cur.Right.SortKey == sortKey && cur.Right.ViceKey > viceKey))) - { - cur = cur.Right; - } - - if (layer <= rLevel) - { - var currentRight = cur.Right; - cur.Right = new SkipTableNode(sortKey, viceKey, key, value, - layer == 1 ? cur.Index + 1 : 0, cur, cur.Right, null); - - if (currentRight != null) - { - currentRight.Left = cur.Right; - } - - if (last != null) - { - last.Down = cur.Right; - } - - if (layer == 1) - { - cur.Right.Index = cur.Index + 1; - Node.Add(key, cur.Right); - - SkipTableNode v = cur.Right.Right; - - while (v != null) - { - v.Index++; - v = v.Right; - } - } - - last = cur.Right; - } - - cur = cur.Down; - } - } - public override bool Remove(long sortKey, long viceKey, long key, out TValue value) - { - value = default; - var seen = false; - var cur = TopHeader; - - for (var layer = MaxLayer; layer >= 1; --layer) - { - // 先按照主键查找 再 按副键查找 - while (cur.Right != null && cur.Right.SortKey > sortKey && cur.Right.Key != key) cur = cur.Right; - while (cur.Right != null && (cur.Right.SortKey == sortKey && cur.Right.ViceKey >= viceKey) && - cur.Right.Key != key) cur = cur.Right; - - var isFind = false; - var currentCur = cur; - SkipTableNode removeCur = null; - // 如果当前不是要删除的节点、但主键和副键都一样、需要特殊处理下。 - if (cur.Right != null && cur.Right.Key == key) - { - isFind = true; - removeCur = cur.Right; - currentCur = cur; - } - else - { - // 先向左查找下 - var currentNode = cur.Left; - while (currentNode != null && currentNode.SortKey == sortKey && currentNode.ViceKey == viceKey) - { - if (currentNode.Key == key) - { - isFind = true; - removeCur = currentNode; - currentCur = currentNode.Left; - break; - } - - currentNode = currentNode.Left; - } - - // 再向右查找下 - if (!isFind) - { - currentNode = cur.Right; - while (currentNode != null && currentNode.SortKey == sortKey && currentNode.ViceKey == viceKey) - { - if (currentNode.Key == key) - { - isFind = true; - removeCur = currentNode; - currentCur = currentNode.Left; - break; - } - - currentNode = currentNode.Right; - } - } - } - - if (isFind && currentCur != null) - { - value = removeCur.Value; - currentCur.Right = removeCur.Right; - - if (removeCur.Right != null) - { - removeCur.Right.Left = currentCur; - removeCur.Right = null; - } - - removeCur.Left = null; - removeCur.Down = null; - removeCur.Value = default; - - if (layer == 1) - { - var tempCur = currentCur.Right; - while (tempCur != null) - { - tempCur.Index--; - tempCur = tempCur.Right; - } - - Node.Remove(removeCur.Key); - } - - seen = true; - } - - cur = cur.Down; - } - - return seen; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableDesc.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableDesc.cs.meta deleted file mode 100644 index 1acbed79..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableDesc.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5dd291e3d391b8842a15ea93f72e4771 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableNode.cs b/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableNode.cs deleted file mode 100644 index e318bbc6..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableNode.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace TEngine.DataStructure -{ - public class SkipTableNode - { - public int Index; - public long Key; - public long SortKey; - public long ViceKey; - public TValue Value; - public SkipTableNode Left; - public SkipTableNode Right; - public SkipTableNode Down; - - public SkipTableNode(long sortKey, long viceKey, long key, TValue value, int index, - SkipTableNode l, - SkipTableNode r, - SkipTableNode d) - { - Left = l; - Right = r; - Down = d; - Value = value; - Key = key; - Index = index; - SortKey = sortKey; - ViceKey = viceKey; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableNode.cs.meta b/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableNode.cs.meta deleted file mode 100644 index beed5522..00000000 --- a/Assets/GameScripts/DotNet/Core/DataStructure/SkipTable/SkipTableNode.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2dcae58948d93a74bb7234d2a88fee46 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Define.cs b/Assets/GameScripts/DotNet/Core/Define.cs deleted file mode 100644 index 89b54685..00000000 --- a/Assets/GameScripts/DotNet/Core/Define.cs +++ /dev/null @@ -1,116 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core; - -public static class Define -{ -#if TENGINE_NET - - #region ProtoBuf - - public static readonly char[] SplitChars = { ' ', '\t' }; - /// - /// ProtoBuf文件夹 - /// - public static string ProtoBufDirectory; - /// - /// 服务端生成文件夹 - /// - public static string ProtoBufServerDirectory; - /// - /// 客户端生成文件夹 - /// - public static string ProtoBufClientDirectory; - /// - /// 代码模板路径 - /// - public static string ProtoBufTemplatePath; - - #endregion - - #region Excel - - /// - /// 配置文件根目录 - /// - public static string ExcelProgramPath; - /// - /// 版本文件Excel - /// - public static string ExcelVersionFile; - /// - /// 服务器代码生成文件夹 - /// - public static string ExcelServerFileDirectory; - /// - /// 客户端代码生成文件夹 - /// - public static string ExcelClientFileDirectory; - /// - /// 服务器二进制数据文件夹 - /// - public static string ExcelServerBinaryDirectory; - /// - /// 客户端二进制数据文件夹 - /// - public static string ExcelClientBinaryDirectory; - /// - /// 服务器Json数据文件夹 - /// - public static string ExcelServerJsonDirectory; - /// - /// 客户端Json数据文件夹 - /// - public static string ExcelClientJsonDirectory; - /// - /// 服务器自定义导出代码 - /// - public static string ServerCustomExportDirectory; - /// - /// 客户端自定义导出代码 - /// - public static string ClientCustomExportDirectory; - /// - /// SceneConfig.xlsx的位置 - /// - public static string SceneConfigPath; - /// - /// 自定义导出代码存放的程序集 - /// - public static string CustomExportAssembly; - /// - /// 导表支持的类型 - /// - public static readonly HashSet ColTypeSet = new HashSet() - { - "", "0", "bool", "byte", "short", "ushort", "int", "uint", "long", "ulong", "float", "string", "AttrConfig", - "IntDictionaryConfig", "StringDictionaryConfig", - "short[]", "int[]", "long[]", "float[]", "string[]","uint[]" - }; - /// - /// Excel生成代码模板的位置 - /// - public static string ExcelTemplatePath; - /// - /// 代码模板 - /// - public static string ExcelTemplate - { - get - { - return _template ??= File.ReadAllText(ExcelTemplatePath); - } - } - private static string _template; - - #endregion - - #region Network - - public static int SessionIdleCheckerInterval; - public static int SessionIdleCheckerTimeout; - - #endregion - -#endif -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Define.cs.meta b/Assets/GameScripts/DotNet/Core/Define.cs.meta deleted file mode 100644 index f21f54ba..00000000 --- a/Assets/GameScripts/DotNet/Core/Define.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 607b7ddd55f4bc3488ce863ef43f9613 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas.meta b/Assets/GameScripts/DotNet/Core/Entitas.meta deleted file mode 100644 index 0740d37c..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: adeda901c300a6544bc4c134eb42a5e5 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/ComponentView.cs b/Assets/GameScripts/DotNet/Core/Entitas/ComponentView.cs deleted file mode 100644 index b8fe1a18..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/ComponentView.cs +++ /dev/null @@ -1,15 +0,0 @@ -#if UNITY_EDITOR -using UnityEngine; - -namespace TEngine -{ - public class ComponentView: MonoBehaviour - { - public Entity Component - { - get; - set; - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/ComponentView.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/ComponentView.cs.meta deleted file mode 100644 index c91ec131..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/ComponentView.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 24bef9ebd1ca4a1cb8db0fba17ec5b2b -timeCreated: 1689576818 \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/EntitiesSystem.cs b/Assets/GameScripts/DotNet/Core/Entitas/EntitiesSystem.cs deleted file mode 100644 index b206984d..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/EntitiesSystem.cs +++ /dev/null @@ -1,184 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using TEngine.DataStructure; -using TEngine.Core; - -namespace TEngine -{ - public sealed class EntitiesSystem : Singleton, IUpdateSingleton - { - private readonly OneToManyList _assemblyList = new(); - private readonly Dictionary _awakeSystems = new(); - private readonly Dictionary _updateSystems = new(); - private readonly Dictionary _destroySystems = new(); - private readonly Dictionary _deserializeSystems = new(); - - private readonly Queue _updateQueue = new Queue(); - - protected override void OnLoad(int assemblyName) - { - foreach (var entitiesSystemType in AssemblyManager.ForEach(assemblyName, typeof(IEntitiesSystem))) - { - var entity = Activator.CreateInstance(entitiesSystemType); - - switch (entity) - { - case IAwakeSystem iAwakeSystem: - { - _awakeSystems.Add(iAwakeSystem.EntitiesType(), iAwakeSystem); - break; - } - case IDestroySystem iDestroySystem: - { - _destroySystems.Add(iDestroySystem.EntitiesType(), iDestroySystem); - break; - } - case IDeserializeSystem iDeserializeSystem: - { - _deserializeSystems.Add(iDeserializeSystem.EntitiesType(), iDeserializeSystem); - break; - } - case IUpdateSystem iUpdateSystem: - { - _updateSystems.Add(iUpdateSystem.EntitiesType(), iUpdateSystem); - break; - } - } - - _assemblyList.Add(assemblyName, entitiesSystemType); - } - } - - protected override void OnUnLoad(int assemblyName) - { - if (!_assemblyList.TryGetValue(assemblyName, out var assembly)) - { - return; - } - - _assemblyList.RemoveByKey(assemblyName); - - foreach (var type in assembly) - { - _awakeSystems.Remove(type); - _updateSystems.Remove(type); - _destroySystems.Remove(type); - _deserializeSystems.Remove(type); - } - } - - public void Awake(T entity) where T : Entity - { - var type = entity.GetType(); - - if (!_awakeSystems.TryGetValue(type, out var awakeSystem)) - { - return; - } - - try - { - awakeSystem.Invoke(entity); - } - catch (Exception e) - { - Log.Error($"{type.Name} Error {e}"); - } - } - - public void Destroy(T entity) where T : Entity - { - var type = entity.GetType(); - - if (!_destroySystems.TryGetValue(type, out var system)) - { - return; - } - - try - { - system.Invoke(entity); - } - catch (Exception e) - { - Log.Error($"{type.Name} Error {e}"); - } - } - - public void Deserialize(T entity) where T : Entity - { - var type = entity.GetType(); - - if (!_deserializeSystems.TryGetValue(type, out var system)) - { - return; - } - - try - { - system.Invoke(entity); - } - catch (Exception e) - { - Log.Error($"{type.Name} Error {e}"); - } - } - - public void StartUpdate(Entity entity) - { - if (!_updateSystems.ContainsKey(entity.GetType())) - { - return; - } - - _updateQueue.Enqueue(entity.RuntimeId); - } - - public void Update() - { - var updateQueueCount = _updateQueue.Count; - - while (updateQueueCount-- > 0) - { - var runtimeId = _updateQueue.Dequeue(); - var entity = Entity.GetEntity(runtimeId); - - if (entity == null || entity.IsDisposed) - { - continue; - } - - var type = entity.GetType(); - - if (!_updateSystems.TryGetValue(type, out var updateSystem)) - { - continue; - } - - _updateQueue.Enqueue(runtimeId); - - try - { - updateSystem.Invoke(entity); - } - catch (Exception e) - { - Log.Error($"{type} Error {e}"); - } - } - } - - public override void Dispose() - { - _assemblyList.Clear(); - _awakeSystems.Clear(); - _updateSystems.Clear(); - _destroySystems.Clear(); - _deserializeSystems.Clear(); - AssemblyManager.OnLoadAssemblyEvent -= OnLoad; - AssemblyManager.OnUnLoadAssemblyEvent -= OnUnLoad; - base.Dispose(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/EntitiesSystem.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/EntitiesSystem.cs.meta deleted file mode 100644 index c3b67c66..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/EntitiesSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2ebd4150be3b67b4bafd633a97a738c8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Entity.cs b/Assets/GameScripts/DotNet/Core/Entitas/Entity.cs deleted file mode 100644 index b627633e..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Entity.cs +++ /dev/null @@ -1,731 +0,0 @@ -using System; -using System.Collections.Generic; -using TEngine.Core; -using System.Runtime.Serialization; -using TEngine.DataStructure; -using MongoDB.Bson.Serialization.Attributes; -using Newtonsoft.Json; -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8601 -#pragma warning disable CS8603 -#pragma warning disable CS0436 - -// ReSharper disable SuspiciousTypeConversion.Global -// ReSharper disable InconsistentNaming -// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract - -namespace TEngine -{ - [Flags] - public enum EntityStatus: byte - { - None = 0, - IsFromPool = 1, - IsComponent = 1 << 1, - IsCreated = 1 << 2, - IsNew = 1 << 3, - } - - public abstract class Entity : IDisposable - { -#if UNITY_EDITOR - [UnityEngine.HideInInspector] - public UnityEngine.GameObject ViewGO; -#endif - - #region Status - [BsonIgnore] - [IgnoreDataMember] - private EntityStatus status = EntityStatus.None; - - [BsonIgnore] - [IgnoreDataMember] - public bool IsFromPool - { - get => (this.status & EntityStatus.IsFromPool) == EntityStatus.IsFromPool; - set - { - if (value) - { - this.status |= EntityStatus.IsFromPool; - } - else - { - this.status &= ~EntityStatus.IsFromPool; - } - } - } - - [BsonIgnore] - [IgnoreDataMember] - protected bool IsComponent - { - get => (this.status & EntityStatus.IsComponent) == EntityStatus.IsComponent; - set - { - if (value) - { - this.status |= EntityStatus.IsComponent; - } - else - { - this.status &= ~EntityStatus.IsComponent; - } - } - } - - [BsonIgnore] - [IgnoreDataMember] - protected bool IsCreated - { - get => (this.status & EntityStatus.IsCreated) == EntityStatus.IsCreated; - set - { - if (value) - { - this.status |= EntityStatus.IsCreated; - } - else - { - this.status &= ~EntityStatus.IsCreated; - } - } - } - - [BsonIgnore] - [IgnoreDataMember] - protected bool IsNew - { - get => (this.status & EntityStatus.IsNew) == EntityStatus.IsNew; - set - { - if (value) - { - this.status |= EntityStatus.IsNew; - } - else - { - this.status &= ~EntityStatus.IsNew; - } - } - } - - [BsonIgnore] - [IgnoreDataMember] - protected virtual string ViewName => this.GetType().Name; - - #endregion - - #region Entities - - private static readonly Dictionary Entities = new Dictionary(); - private static readonly OneToManyQueue Pool = new OneToManyQueue(); - - public static Entity GetEntity(long runTimeId) - { - return Entities.TryGetValue(runTimeId, out var entity) ? entity : null; - } - - public static bool TryGetEntity(long runTimeId, out Entity entity) - { - return Entities.TryGetValue(runTimeId, out entity); - } - - public static T GetEntity(long runTimeId) where T : Entity, new() - { - if (!Entities.TryGetValue(runTimeId, out var entity)) - { - return default; - } - - return (T) entity; - } - - public static bool TryGetEntity(long runTimeId, out T outEntity) where T : Entity, new() - { - if (!Entities.TryGetValue(runTimeId, out var entity)) - { - outEntity = default; - return false; - } - - outEntity = (T) entity; - return true; - } - - private static T Rent(Type entityType) where T : Entity, new() - { - if (typeof(INotSupportedPool).IsAssignableFrom(entityType)) - { - return Activator.CreateInstance(); - } - - T entity; - - if (Pool.TryDequeue(entityType, out var poolEntity)) - { - entity = (T) poolEntity; - } - else - { - entity = Activator.CreateInstance(); - } - - entity.IsFromPool = true; - return entity; - } - - private static void Return(Entity entity) - { - entity.Id = 0; - - if (!entity.IsFromPool) - { - return; - } - - entity.IsFromPool = false; - Pool.Enqueue(entity.GetType(), entity); - } - - #endregion - - #region Create - - public static T Create(Scene scene, bool isRunEvent = true) where T : Entity, new() - { - var entity = Create(scene.LocationId, isRunEvent); - entity.Scene = scene; - return entity; - } - - public static T Create(Scene scene, long id, bool isRunEvent = true) where T : Entity, new() - { - var entity = Create(id, scene.LocationId, isRunEvent); - entity.Scene = scene; - return entity; - } - - private static T Create(uint routeId, bool isRunEvent = true) where T : Entity, new() - { - var entity = Rent(typeof(T)); -#if TENGINE_NET - entity.Id = entity.RuntimeId = IdFactory.NextEntityId(routeId); -#else - entity.Id = entity.RuntimeId = IdFactory.NextRunTimeId(); -#endif - Entities.Add(entity.RuntimeId, entity); - - if (isRunEvent) - { - EntitiesSystem.Instance.Awake(entity); - EntitiesSystem.Instance.StartUpdate(entity); - } - - - entity.IsCreated = true; - entity.IsNew = true; - entity.OnCreate(); -#if UNITY_EDITOR - entity.ViewGO = new UnityEngine.GameObject(entity.ViewName); - entity.ViewGO.AddComponent().Component = entity; - entity.ViewGO.transform.SetParent(entity.Parent == null? - UnityEngine.GameObject.Find("[EntitySystem]").transform : entity.Parent.ViewGO.transform); -#endif - return entity; - } - - protected static T Create(long id, uint locationId, bool isRunEvent = true) where T : Entity, new() - { - return Create(id, IdFactory.NextEntityId(locationId), isRunEvent); - } - - protected static T Create(long id, long runtimeId, bool isRunEvent = true) where T : Entity, new() - { - var entity = Rent(typeof(T)); - entity.Id = id; - entity.RuntimeId = runtimeId; - Entities.Add(entity.RuntimeId, entity); - - if (isRunEvent) - { - EntitiesSystem.Instance.Awake(entity); - EntitiesSystem.Instance.StartUpdate(entity); - } - entity.IsCreated = true; - entity.IsNew = true; - entity.OnCreate(); -#if UNITY_EDITOR - entity.ViewGO = new UnityEngine.GameObject(entity.ViewName); - entity.ViewGO.AddComponent().Component = entity; - entity.ViewGO.transform.SetParent(entity.Parent == null? - UnityEngine.GameObject.Find("[EntitySystem]").transform : entity.Parent.ViewGO.transform); -#endif - return entity; - } - - #endregion - - #region Members - - [BsonId] - [BsonElement] - [BsonIgnoreIfDefault] - [BsonDefaultValue(0L)] - public long Id { get; private set; } - - [BsonIgnore] - [IgnoreDataMember] - public long RuntimeId { get; private set; } - - [BsonIgnore] - [JsonIgnore] - [IgnoreDataMember] - public bool IsDisposed => RuntimeId == 0; - - [BsonIgnore] - [JsonIgnore] - [IgnoreDataMember] - public Scene Scene { get; protected set; } - - [BsonIgnore] - [JsonIgnore] - [IgnoreDataMember] - public Entity Parent { get; protected set; } - - [BsonElement("t")] - [BsonIgnoreIfNull] - private ListPool _treeDb; - - [BsonIgnore] - [IgnoreDataMember] - private DictionaryPool _tree; - - [BsonElement("m")] - [BsonIgnoreIfNull] - private ListPool _multiDb; - - [BsonIgnore] - [IgnoreDataMember] - private DictionaryPool _multi; - #endregion - - #region AddComponent - - public T AddComponent() where T : Entity, new() - { - var entity = Create(Id, Scene.LocationId, false); - AddComponent(entity); - EntitiesSystem.Instance.Awake(entity); - EntitiesSystem.Instance.StartUpdate(entity); - return entity; - } - - public T AddComponent(long id) where T : Entity, new() - { - var entity = Create(id, Scene.LocationId, false); - AddComponent(entity); - EntitiesSystem.Instance.Awake(entity); - EntitiesSystem.Instance.StartUpdate(entity); - return entity; - } - - public void AddComponent(Entity component) - { - if (this == component) - { - Log.Error("Cannot add oneself to one's own components"); - return; - } - - if (component.IsDisposed) - { - Log.Error($"component is Disposed {component.GetType().FullName}"); - return; - } - - var type = component.GetType(); - component.Parent?.RemoveComponent(component, false); - - if (component is ISupportedMultiEntity multiEntity) - { - _multi ??= DictionaryPool.Create(); - _multi.Add(component.Id, multiEntity); - - if (component is ISupportedDataBase) - { - _multiDb ??= ListPool.Create(); - _multiDb.Add(component); - } - } - else - { -#if TENGINE_NET - if (component is ISupportedSingleCollection && component.Id != Id) - { - Log.Error($"component type :{component.GetType().FullName} for implementing ISupportedSingleCollection, it is required that the Id must be the same as the parent"); - } -#endif - if (_tree == null) - { - _tree = DictionaryPool.Create(); - } - else if(_tree.ContainsKey(type)) - { - Log.Error($"type:{type.FullName} If you want to add multiple components of the same type, please implement IMultiEntity"); - return; - } - - _tree.Add(type, component); - - if (component is ISupportedDataBase) - { - _treeDb ??= ListPool.Create(); - _treeDb.Add(component); - } - } - - this.IsComponent = false; - component.Parent = this; - component.Scene = Scene; - component.IsComponent = true; -#if UNITY_EDITOR - if (component.ViewGO == null) - { - Log.Error($"{component} ‘s component.ViewGO is null"); - return; - } - component.ViewGO.transform.SetParent(component.Parent == null? - UnityEngine.GameObject.Find("[EntitySystem]").transform : component.Parent.ViewGO.transform); -#endif - } - - #endregion - -#if TENGINE_NET - #region ForEach - public IEnumerable ForEachSingleCollection - { - get - { - foreach (var (_, treeEntity) in _tree) - { - if (treeEntity is not ISupportedSingleCollection) - { - continue; - } - yield return treeEntity; - } - } - } - public IEnumerable ForEachTransfer - { - get - { - if (_tree != null) - { - foreach (var (_, treeEntity) in _tree) - { - if (treeEntity is ISupportedSingleCollection || treeEntity is ISupportedTransfer) - { - yield return treeEntity; - } - } - } - if (_multiDb != null) - { - foreach (var treeEntity in _multiDb) - { - if (treeEntity is not ISupportedTransfer) - { - continue; - } - yield return treeEntity; - } - } - } - } - #endregion -#endif - - #region GetComponent - public T GetParent() where T : Entity, new() - { - return (T)Parent; - } - - public T GetComponent() where T : Entity, new() - { - return GetComponent(typeof(T)) as T; - } - - public Entity GetComponent(Type componentType) - { - if (_tree == null) - { - return default; - } - - return _tree.TryGetValue(componentType, out var component) ? component : default; - } - - public T GetComponent(long id) where T : ISupportedMultiEntity, new() - { - if (_multi == null) - { - return default; - } - - return _multi.TryGetValue(id, out var entity) ? (T) entity : default; - } - - #endregion - - #region RemoveComponent - - public void RemoveComponent(bool isDispose = true) where T : Entity, new() - { - if (_tree == null || !_tree.TryGetValue(typeof(T), out var component)) - { - return; - } - - RemoveComponent(component, isDispose); - } - - public void RemoveComponent(long id, bool isDispose = true) where T : ISupportedMultiEntity, new() - { - if (_multi == null || !_multi.TryGetValue(id, out var component)) - { - return; - } - - RemoveComponent((Entity)component, isDispose); - } - - public void RemoveComponent(Entity component, bool isDispose = true) - { - if (this == component) - { - return; - } - - if (component is ISupportedMultiEntity) - { - if (_multi != null) - { -#if TENGINE_NET - if (component is ISupportedDataBase && _multiDb != null) - { - _multiDb.Remove(component); - - if (_multiDb.Count == 0) - { - _multiDb.Dispose(); - _multiDb = null; - } - } -#endif - _multi.Remove(component.Id); - - if (_multi.Count == 0) - { - _multi.Dispose(); - _multi = null; - } - } - } - else if (_tree != null) - { -#if TENGINE_NET - if (component is ISupportedDataBase && _treeDb != null) - { - _treeDb.Remove(component); - - if (_treeDb.Count == 0) - { - _treeDb.Dispose(); - _treeDb = null; - } - } -#endif - _tree.Remove(component.GetType()); - - if (_tree.Count == 0) - { - _tree.Dispose(); - _tree = null; - } - } - - if (isDispose) - { - component.Dispose(); - } - } - - #endregion - - #region Deserialize - - public void Deserialize(Scene scene, bool resetId = false) - { - if (RuntimeId != 0) - { - return; - } - - try - { - Scene = scene; -#if TENGINE_NET - RuntimeId = IdFactory.NextEntityId(scene.LocationId); -#else - RuntimeId = IdFactory.NextRunTimeId(); -#endif - if (resetId) - { - Id = RuntimeId; - } - - Entities.Add(RuntimeId, this); - - if (_treeDb != null && _treeDb.Count > 0) - { - _tree = DictionaryPool.Create(); - foreach (var entity in _treeDb) - { - entity.Parent = this; - entity.Deserialize(scene, resetId); - _tree.Add(entity.GetType(), entity); - } - } - - if (_multiDb != null && _multiDb.Count > 0) - { - _multi = DictionaryPool.Create(); - foreach (var entity in _multiDb) - { - entity.Parent = this; - entity.Deserialize(scene, resetId); - _multi.Add(entity.Id, (ISupportedMultiEntity)entity); - } - } - } - catch (Exception e) - { - if (RuntimeId != 0) - { - Entities.Remove(RuntimeId); - } - - Log.Error(e); - } - } - - #endregion - - #region Clone - - public Entity Clone() - { -#if TENGINE_NET - var entity = MongoHelper.Instance.Clone(this); - entity.Deserialize(Scene, true); - return entity; -#elif TENGINE_UNITY - var entity = ProtoBufHelper.Clone(this); - entity.Deserialize(Scene, true); - return entity; -#endif - } - - #endregion - - #region OnCreate - public virtual void OnCreate() { } - #endregion - - #region Dispose - - public virtual void Dispose() - { - if (IsDisposed) - { - return; - } - - var runtimeId = RuntimeId; - RuntimeId = 0; - - if (_tree != null) - { - foreach (var (_, entity) in _tree) - { - entity.Dispose(); - } - - _tree.Dispose(); - _tree = null; - } - - if (_multi != null) - { - foreach (var (_, entity) in _multi) - { - entity.Dispose(); - } - - _multi.Dispose(); - _multi = null; - } - -#if TENGINE_NET - if (_treeDb != null) - { - foreach (var entity in _treeDb) - { - entity.Dispose(); - } - - _treeDb.Dispose(); - _treeDb = null; - } - - if (_multiDb != null) - { - foreach (var entity in _multiDb) - { - entity.Dispose(); - } - - _multiDb.Dispose(); - _multiDb = null; - } -#endif - EntitiesSystem.Instance?.Destroy(this); - - if (Parent != null && Parent != this && !Parent.IsDisposed) - { - Parent.RemoveComponent(this, false); - Parent = null; - } - - Entities.Remove(runtimeId); - Scene = null; - Return(this); - -#if UNITY_EDITOR - if (this.ViewGO == null) - { - Log.Error($"{this} ‘s ViewGO is null"); - return; - } - UnityEngine.Object.Destroy(this.ViewGO);; -#endif - } - - #endregion - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Entity.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Entity.cs.meta deleted file mode 100644 index 878271b0..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Entity.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f4ac3a7a2c87dab48819ea8ad865ec76 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/EntityReference.cs b/Assets/GameScripts/DotNet/Core/Entitas/EntityReference.cs deleted file mode 100644 index 3a479a62..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/EntityReference.cs +++ /dev/null @@ -1,30 +0,0 @@ -// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract -namespace TEngine -{ - public readonly struct EntityReference where T : Entity - { - private readonly T _entity; - private readonly long _runTimeId; - - private EntityReference(T t) - { - _entity = t; - _runTimeId = t.RuntimeId; - } - - public static implicit operator EntityReference(T t) - { - return new EntityReference(t); - } - - public static implicit operator T(EntityReference v) - { - if (v._entity == null) - { - return null; - } - - return v._entity.RuntimeId != v._runTimeId ? null : v._entity; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/EntityReference.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/EntityReference.cs.meta deleted file mode 100644 index 1c2a8b9c..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/EntityReference.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: c827c6f914b64f5d9eb0a1f29cc2c018 -timeCreated: 1691083017 \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface.meta b/Assets/GameScripts/DotNet/Core/Entitas/Interface.meta deleted file mode 100644 index 5d29d816..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2c5e09a29bcfe7c4f9f84422354a6d2c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported.meta b/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported.meta deleted file mode 100644 index 635398fc..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 0c3ff31e66c8ca44b8e99c068cdcc04a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/INotSupportedPool.cs b/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/INotSupportedPool.cs deleted file mode 100644 index 43e65f2e..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/INotSupportedPool.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace TEngine -{ - /// - /// Entity不支持对象池创建和回收 - /// - public interface INotSupportedPool { } -} - diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/INotSupportedPool.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/INotSupportedPool.cs.meta deleted file mode 100644 index e8f6f11c..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/INotSupportedPool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b9eceeefe7ee19f47bac590bc44d57d6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISingleCollectionRoot.cs b/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISingleCollectionRoot.cs deleted file mode 100644 index 346d5bd5..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISingleCollectionRoot.cs +++ /dev/null @@ -1,8 +0,0 @@ -#if TENGINE_NET -namespace TEngine; - -/// -/// Entity保存到数据库的时候会根据子组件设置分离存储特性分表存储在不同的集合表中 -/// -public interface ISingleCollectionRoot { } -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISingleCollectionRoot.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISingleCollectionRoot.cs.meta deleted file mode 100644 index 9944c0a8..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISingleCollectionRoot.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3dfa22a9da7a76b41bf6511e45b22b53 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedDataBase.cs b/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedDataBase.cs deleted file mode 100644 index fb3782a4..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedDataBase.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace TEngine -{ - /// - /// Entity支持数据库 - /// - // ReSharper disable once InconsistentNaming - public interface ISupportedDataBase { } -} diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedDataBase.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedDataBase.cs.meta deleted file mode 100644 index 108aa26d..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedDataBase.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fa02a2282c8866746a60eaaa35afb0de -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedMultiEntity.cs b/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedMultiEntity.cs deleted file mode 100644 index 320cdf83..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedMultiEntity.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace TEngine -{ - /// - /// 支持再一个组件里添加多个同类型组件 - /// - public interface ISupportedMultiEntity : IDisposable { } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedMultiEntity.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedMultiEntity.cs.meta deleted file mode 100644 index 22ef8d96..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedMultiEntity.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 17d0f9fb53e07414991160d50cf133e1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedSingleCollection.cs b/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedSingleCollection.cs deleted file mode 100644 index 0a344965..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedSingleCollection.cs +++ /dev/null @@ -1,23 +0,0 @@ -#if TENGINE_NET -namespace TEngine; - -/// -/// Entity是单一集合、保存到数据库的时候不会跟随父组件保存在一个集合里、会单独保存在一个集合里 -/// 需要配合SingleCollectionAttribute一起使用、如在Entity类头部定义SingleCollectionAttribute(typeOf(Unit)) -/// SingleCollectionAttribute用来定义这个Entity是属于哪个Entity的子集 -/// -public interface ISupportedSingleCollection { } - -[AttributeUsage(AttributeTargets.Class, Inherited = true, AllowMultiple = false)] -public class SingleCollectionAttribute : Attribute -{ - public readonly Type RootType; - public readonly string CollectionName; - - public SingleCollectionAttribute(Type rootType, string collectionName) - { - RootType = rootType; - CollectionName = collectionName; - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedSingleCollection.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedSingleCollection.cs.meta deleted file mode 100644 index d15991f5..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedSingleCollection.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d9654cddb77221d4eaa991df735b12c2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedTransfer.cs b/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedTransfer.cs deleted file mode 100644 index 2de2175b..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedTransfer.cs +++ /dev/null @@ -1,8 +0,0 @@ -#if TENGINE_NET -namespace TEngine; - -/// -/// Entity支持传送。 -/// -public interface ISupportedTransfer { } -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedTransfer.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedTransfer.cs.meta deleted file mode 100644 index aef658b7..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/Supported/ISupportedTransfer.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 06770f37cdfc480fb0c270ea93a10d26 -timeCreated: 1691083054 \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System.meta b/Assets/GameScripts/DotNet/Core/Entitas/Interface/System.meta deleted file mode 100644 index 9090f9ea..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3473ee41e6d3cfa489bcf20bc8f6d546 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/AwakeSystem.cs b/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/AwakeSystem.cs deleted file mode 100644 index e7dc4d55..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/AwakeSystem.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; - -namespace TEngine -{ - public interface IAwakeSystem : IEntitiesSystem { } - - public abstract class AwakeSystem : IAwakeSystem where T : Entity - { - public Type EntitiesType() => typeof(T); - - protected abstract void Awake(T self); - - public void Invoke(Entity self) - { - Awake((T) self); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/AwakeSystem.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/AwakeSystem.cs.meta deleted file mode 100644 index 5d27f576..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/AwakeSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6e152a700f49f0748bfbdd03108a4a5e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IDeserializeSystem.cs b/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IDeserializeSystem.cs deleted file mode 100644 index 1ebc772e..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IDeserializeSystem.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace TEngine -{ - public interface IDeserializeSystem : IEntitiesSystem { } - - public abstract class DeserializeSystem : IDeserializeSystem where T : Entity - { - public Type EntitiesType() => typeof(T); - protected abstract void Deserialize(T self); - public void Invoke(Entity self) - { - Deserialize((T) self); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IDeserializeSystem.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IDeserializeSystem.cs.meta deleted file mode 100644 index aa496030..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IDeserializeSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: be8b21b9058e78343abfeea9277be75e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IDestroySystem.cs b/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IDestroySystem.cs deleted file mode 100644 index 852deb7d..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IDestroySystem.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace TEngine -{ - public interface IDestroySystem : IEntitiesSystem { } - - public abstract class DestroySystem : IDestroySystem where T : Entity - { - public Type EntitiesType() => typeof(T); - protected abstract void Destroy(T self); - public void Invoke(Entity self) - { - Destroy((T) self); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IDestroySystem.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IDestroySystem.cs.meta deleted file mode 100644 index c42232b3..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IDestroySystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7140fd5ab56bd3b4ba04cfe40470ad23 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IEntitiesSystem.cs b/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IEntitiesSystem.cs deleted file mode 100644 index 4b525a58..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IEntitiesSystem.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace TEngine -{ - public interface IEntitiesSystem - { - public Type EntitiesType(); - void Invoke(Entity entity); - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IEntitiesSystem.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IEntitiesSystem.cs.meta deleted file mode 100644 index 2708bbf3..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IEntitiesSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4e4fa4e598c849148a0dd63e785716f3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IUpdateSystem.cs b/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IUpdateSystem.cs deleted file mode 100644 index 106f51b9..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IUpdateSystem.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; - -namespace TEngine -{ - public interface IUpdateSystem : IEntitiesSystem { } - - public abstract class UpdateSystem : IUpdateSystem where T : Entity - { - public Type EntitiesType() => typeof(T); - protected abstract void Update(T self); - public void Invoke(Entity self) - { - Update((T) self); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IUpdateSystem.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IUpdateSystem.cs.meta deleted file mode 100644 index 5f932383..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Interface/System/IUpdateSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f39edd76db52bd84aa385cd02fa98db8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Scene.meta b/Assets/GameScripts/DotNet/Core/Entitas/Scene.meta deleted file mode 100644 index 1366ec8b..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Scene.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3d9f783d00ec372489401151473f8d7e -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Scene/Scene.cs b/Assets/GameScripts/DotNet/Core/Entitas/Scene/Scene.cs deleted file mode 100644 index b052e715..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Scene/Scene.cs +++ /dev/null @@ -1,195 +0,0 @@ -using System; -using System.Collections.Generic; -using TEngine.Core.Network; -using TEngine.Core; -#if TENGINE_NET -using TEngine.Core.DataBase; -#endif -#pragma warning disable CS8625 -#pragma warning disable CS8618 -namespace TEngine -{ - public class Scene : Entity, INotSupportedPool - { - public string Name { get; private set; } - public uint LocationId { get; private set; } -#if TENGINE_UNITY - public Session Session { get; private set; } - public SceneConfigInfo SceneInfo { get; private set; } -#endif -#if TENGINE_NET - public int SceneType { get; private set; } - public int SceneSubType { get; private set; } - public World World { get; private set; } - public Server Server { get; private set; } -#endif - public static readonly List Scenes = new List(); - - public override void Dispose() - { - if (IsDisposed) - { - return; - } - - Name = null; - this.LocationId = 0; -#if TENGINE_NET - World = null; - Server = null; - SceneType = 0; - SceneSubType = 0; -#endif -#if TENGINE_UNITY - SceneInfo = null; - if (Session is { IsDisposed: false }) - { - Session.Dispose(); - Session = null; - } -#endif - Scenes.Remove(this); - base.Dispose(); - } - - public static void DisposeAllScene() - { - foreach (var scene in Scenes.ToArray()) - { - scene.Dispose(); - } - } -#if TENGINE_UNITY - public static Scene Create() - { - var sceneId = IdFactory.NextRunTimeId(); - var scene = Create(sceneId, sceneId); - scene.Scene = scene; - scene.Parent = scene; - Scenes.Add(scene); - return scene; - } - - public static Scene Create(string name) - { - var sceneId = IdFactory.NextRunTimeId(); - var scene = Create(sceneId, sceneId); - scene.Scene = scene; - scene.Parent = scene; - scene.Name = name; - Scenes.Add(scene); - return scene; - } - - public void CreateSession(string remoteAddress, NetworkProtocolType networkProtocolType, Action onConnectComplete, Action onConnectFail,Action onConnectDisconnect, int connectTimeout = 5000) - { - var address = NetworkHelper.ToIPEndPoint(remoteAddress); - var clientNetworkComponent = GetComponent() ?? AddComponent(); - clientNetworkComponent.Initialize(networkProtocolType, NetworkTarget.Outer); - clientNetworkComponent.Connect(address, onConnectComplete, onConnectFail,onConnectDisconnect, connectTimeout); - Session = clientNetworkComponent.Session; - } -#else - /// - /// 创建一个Scene。 - /// - /// - /// - /// - /// - /// - public static async FTask Create(Scene scene, int sceneType, int sceneSubType) where T : Scene, new() - { - var newScene = Create(scene); - newScene.Scene = newScene; - newScene.Parent = scene; - newScene.SceneType = sceneType; - newScene.SceneSubType = sceneSubType; - newScene.Server = scene.Server; - newScene.LocationId = scene.Server.Id; - - if (scene.World != null) - { - newScene.World = scene.World; - } - - if (sceneType > 0) - { - await EventSystem.Instance.PublishAsync(new OnCreateScene(newScene)); - } - - Scenes.Add(newScene); - return newScene; - } - - /// - /// 创建一个Scene。 - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static async FTask Create(Server server, int sceneType = 0, int sceneSubType = 0, long sceneId = 0, uint worldId = 0, string networkProtocol = null, string outerBindIp = null, int outerPort = 0) - { - if (sceneId == 0) - { - sceneId = new EntityIdStruct(server.Id, 0, 0); - } - - var scene = Create(sceneId, sceneId); - scene.Scene = scene; - scene.Parent = scene; - scene.SceneType = sceneType; - scene.SceneSubType = sceneSubType; - scene.Server = server; - scene.LocationId = server.Id; - - if (worldId != 0) - { - // 有可能不需要数据库、所以这里默认0的情况下就不创建数据库了 - scene.World = World.Create(worldId); - } - - if (!string.IsNullOrEmpty(networkProtocol) && !string.IsNullOrEmpty(outerBindIp) && outerPort != 0) - { - // 设置Scene的网络、目前只支持KCP和TCP - var networkProtocolType = Enum.Parse(networkProtocol); - var serverNetworkComponent = scene.AddComponent(); - var address = NetworkHelper.ToIPEndPoint($"{outerBindIp}:{outerPort}"); - serverNetworkComponent.Initialize(networkProtocolType, NetworkTarget.Outer, address); - } - - if (sceneType > 0) - { - await EventSystem.Instance.PublishAsync(new OnCreateScene(scene)); - } - - Scenes.Add(scene); - return scene; - } - - public static List GetSceneInfoByServerConfigId(uint serverConfigId) - { - var list = new List(); - var allSceneConfig = ConfigTableManage.AllSceneConfig(); - - foreach (var sceneConfigInfo in allSceneConfig) - { - if (sceneConfigInfo.ServerConfigId != serverConfigId) - { - continue; - } - - list.Add(sceneConfigInfo); - } - - return list; - } -#endif - } -} diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Scene/Scene.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Scene/Scene.cs.meta deleted file mode 100644 index cddd73a4..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Scene/Scene.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 12c279f9aa38cab41b3bf04be0eea700 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Scene/SceneEvent.cs b/Assets/GameScripts/DotNet/Core/Entitas/Scene/SceneEvent.cs deleted file mode 100644 index 20e7566c..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Scene/SceneEvent.cs +++ /dev/null @@ -1,16 +0,0 @@ -#if TENGINE_NET -using System; -using TEngine.Core.Network; -namespace TEngine -{ - public struct OnCreateScene - { - public readonly Scene Scene; - - public OnCreateScene(Scene scene) - { - Scene = scene; - } - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Scene/SceneEvent.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Scene/SceneEvent.cs.meta deleted file mode 100644 index e2e144d0..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Scene/SceneEvent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e237f0cc7a65b51408d828a87535b4dc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Scene/SceneTypeConfigToEnum.cs b/Assets/GameScripts/DotNet/Core/Entitas/Scene/SceneTypeConfigToEnum.cs deleted file mode 100644 index 4a41616f..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Scene/SceneTypeConfigToEnum.cs +++ /dev/null @@ -1,89 +0,0 @@ -#if TENGINE_NET -using System.Text; -using TEngine.Core; -using TEngine.Helper; - -namespace TEngine.CustomExport; - -public sealed class SceneTypeConfigToEnum : ACustomExport -{ - public override void Run() - { - var fullPath = FileHelper.GetFullPath("../../../Config/Excel/Server/SceneConfig.xlsx"); - using var excelPackage = ExcelHelper.LoadExcel(fullPath); - var sceneType = new Dictionary(); - var sceneSubType = new Dictionary(); - var sceneTypeConfig = excelPackage.Workbook.Worksheets["SceneTypeConfig"]; - - for (var row = 3; row <= sceneTypeConfig.Dimension.Rows; row++) - { - var sceneTypeId = sceneTypeConfig.GetCellValue(row, 1); - var sceneTypeStr = sceneTypeConfig.GetCellValue(row, 2); - - if (string.IsNullOrEmpty(sceneTypeId) || string.IsNullOrEmpty(sceneTypeStr)) - { - continue; - } - - sceneType.Add(sceneTypeId, sceneTypeStr); - } - - var sceneSubTypeConfig = excelPackage.Workbook.Worksheets["SceneSubTypeConfig"]; - - for (var row = 3; row <= sceneSubTypeConfig.Dimension.Rows; row++) - { - var sceneSubTypeId = sceneSubTypeConfig.GetCellValue(row, 1); - var sceneSubTypeStr = sceneSubTypeConfig.GetCellValue(row, 2); - - if (string.IsNullOrEmpty(sceneSubTypeId) || string.IsNullOrEmpty(sceneSubTypeStr)) - { - continue; - } - - sceneSubType.Add(sceneSubTypeId, sceneSubTypeStr); - } - - if (sceneType.Count > 0 || sceneSubType.Count > 0) - { - Write(CustomExportType.Server, sceneType, sceneSubType); - } - } - - private void Write(CustomExportType customExportType, Dictionary sceneTypes, Dictionary sceneSubType) - { - var strBuilder = new StringBuilder(); - var dicBuilder = new StringBuilder(); - - strBuilder.AppendLine("namespace TEngine\n{"); - strBuilder.AppendLine("\t// 生成器自动生成,请不要手动编辑。"); - strBuilder.AppendLine("\tpublic static class SceneType\n\t{"); - dicBuilder.AppendLine("\n\t\tpublic static readonly Dictionary SceneTypeDic = new Dictionary()\n\t\t{"); - - foreach (var (sceneTypeId, sceneTypeStr) in sceneTypes) - { - dicBuilder.AppendLine($"\t\t\t{{ \"{sceneTypeStr}\", {sceneTypeId} }},"); - strBuilder.AppendLine($"\t\tpublic const int {sceneTypeStr} = {sceneTypeId};"); - } - - dicBuilder.AppendLine("\t\t};"); - strBuilder.Append(dicBuilder); - strBuilder.AppendLine("\t}\n"); - - strBuilder.AppendLine("\t// 生成器自动生成,请不要手动编辑。"); - strBuilder.AppendLine("\tpublic static class SceneSubType\n\t{"); - - dicBuilder.Clear(); - dicBuilder.AppendLine("\n\t\tpublic static readonly Dictionary SceneSubTypeDic = new Dictionary()\n\t\t{"); - foreach (var (sceneSubTypeId, sceneSubTypeStr) in sceneSubType) - { - dicBuilder.AppendLine($"\t\t\t{{ \"{sceneSubTypeStr}\", {sceneSubTypeId} }},"); - strBuilder.AppendLine($"\t\tpublic const int {sceneSubTypeStr} = {sceneSubTypeId};"); - } - dicBuilder.AppendLine("\t\t};"); - strBuilder.Append(dicBuilder); - strBuilder.AppendLine("\t}\n}"); - - Write("SceneType.cs", strBuilder.ToString(), customExportType); - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Scene/SceneTypeConfigToEnum.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Scene/SceneTypeConfigToEnum.cs.meta deleted file mode 100644 index 1b33f896..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Scene/SceneTypeConfigToEnum.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: d254c1aefb624046ab545bd8cebbe57c -timeCreated: 1690561569 \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Unity.meta b/Assets/GameScripts/DotNet/Core/Entitas/Unity.meta deleted file mode 100644 index 494449e2..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Unity.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7cdae026533d88e4684eca7b48850d12 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes.meta b/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes.meta deleted file mode 100644 index 6c81ea1c..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f3af894a35a86864fa02cf949eb89f03 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonDefaultValueAttribute.cs b/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonDefaultValueAttribute.cs deleted file mode 100644 index 2d152373..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonDefaultValueAttribute.cs +++ /dev/null @@ -1,11 +0,0 @@ -#if TENGINE_UNITY -using System; -namespace MongoDB.Bson.Serialization.Attributes -{ - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] - public class BsonDefaultValueAttribute : Attribute - { - public BsonDefaultValueAttribute(object defaultValue) { } - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonDefaultValueAttribute.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonDefaultValueAttribute.cs.meta deleted file mode 100644 index e23ead9e..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonDefaultValueAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 49dc7c79f6822c64e927ca4f5cad88f8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonElementAttribute.cs b/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonElementAttribute.cs deleted file mode 100644 index 738258b8..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonElementAttribute.cs +++ /dev/null @@ -1,13 +0,0 @@ -#if TENGINE_UNITY -using System; -namespace MongoDB.Bson.Serialization.Attributes -{ - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] - public class BsonElementAttribute : Attribute - { - public BsonElementAttribute() { } - - public BsonElementAttribute(string elementName) { } - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonElementAttribute.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonElementAttribute.cs.meta deleted file mode 100644 index 58401921..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonElementAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9218b708df975ba428c2342e978cd473 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIdAttribute.cs b/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIdAttribute.cs deleted file mode 100644 index a927a11e..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIdAttribute.cs +++ /dev/null @@ -1,13 +0,0 @@ -#if TENGINE_UNITY -using System; -namespace MongoDB.Bson.Serialization.Attributes -{ - [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] - public class BsonIdAttribute : Attribute - { - - } -} -#endif - - diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIdAttribute.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIdAttribute.cs.meta deleted file mode 100644 index ce9cd2fb..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIdAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3e07e248c36907847adb96b09269689f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreAttribute.cs b/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreAttribute.cs deleted file mode 100644 index cd496693..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreAttribute.cs +++ /dev/null @@ -1,11 +0,0 @@ -#if TENGINE_UNITY -using System; -namespace MongoDB.Bson.Serialization.Attributes -{ - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] - public class BsonIgnoreAttribute : Attribute - { - - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreAttribute.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreAttribute.cs.meta deleted file mode 100644 index b7834c64..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a11815e9c0d9fe24f97da6a976538bfc -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreIfDefaultAttribute.cs b/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreIfDefaultAttribute.cs deleted file mode 100644 index db5ed11d..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreIfDefaultAttribute.cs +++ /dev/null @@ -1,13 +0,0 @@ -#if TENGINE_UNITY -using System; -namespace MongoDB.Bson.Serialization.Attributes -{ - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] - public class BsonIgnoreIfDefaultAttribute : Attribute - { - public BsonIgnoreIfDefaultAttribute() { } - - public BsonIgnoreIfDefaultAttribute(bool value) { } - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreIfDefaultAttribute.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreIfDefaultAttribute.cs.meta deleted file mode 100644 index 002cf812..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreIfDefaultAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 24366fa27fe479a439c306cae6a2cf98 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreIfNullAttribute.cs b/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreIfNullAttribute.cs deleted file mode 100644 index 81bdf08f..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreIfNullAttribute.cs +++ /dev/null @@ -1,11 +0,0 @@ -#if TENGINE_UNITY -using System; -namespace MongoDB.Bson.Serialization.Attributes -{ - [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] - public class BsonIgnoreIfNullAttribute : Attribute - { - - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreIfNullAttribute.cs.meta b/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreIfNullAttribute.cs.meta deleted file mode 100644 index cbd63cd0..00000000 --- a/Assets/GameScripts/DotNet/Core/Entitas/Unity/Attributes/BsonIgnoreIfNullAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fb14d1148e275bf4f8220694eab51fc0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/EventSystem.meta b/Assets/GameScripts/DotNet/Core/EventSystem.meta deleted file mode 100644 index 05cced74..00000000 --- a/Assets/GameScripts/DotNet/Core/EventSystem.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 29e4ce5c84d840a4c93fab95c1bbfd05 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/EventSystem/EventSystem.cs b/Assets/GameScripts/DotNet/Core/EventSystem/EventSystem.cs deleted file mode 100644 index 8134e132..00000000 --- a/Assets/GameScripts/DotNet/Core/EventSystem/EventSystem.cs +++ /dev/null @@ -1,177 +0,0 @@ -using System; -using System.Threading.Tasks; -using TEngine.DataStructure; -using TEngine.Core; -using Type = System.Type; -#pragma warning disable CS8600 - -// ReSharper disable MethodOverloadWithOptionalParameter - -namespace TEngine -{ - internal sealed class EventInfo - { - public readonly Type Type; - public readonly object Obj; - - public EventInfo(Type type, object obj) - { - Type = type; - Obj = obj; - } - } - - public sealed class EventSystem : Singleton - { - private readonly OneToManyList _events = new(); - private readonly OneToManyList _asyncEvents = new(); - - private readonly OneToManyList _assemblyEvents = new(); - private readonly OneToManyList _assemblyAsyncEvents = new(); - - protected override void OnLoad(int assemblyName) - { - foreach (var type in AssemblyManager.ForEach(assemblyName, typeof(IEvent))) - { - var obj = (IEvent) Activator.CreateInstance(type); - - if (obj != null) - { - var eventType = obj.EventType(); - _events.Add(eventType, obj); - _assemblyEvents.Add(assemblyName, new EventInfo(eventType, obj)); - } - } - - foreach (var type in AssemblyManager.ForEach(assemblyName, typeof(IAsyncEvent))) - { - var obj = (IAsyncEvent) Activator.CreateInstance(type); - - if (obj != null) - { - var eventType = obj.EventType(); - _asyncEvents.Add(eventType, obj); - _assemblyAsyncEvents.Add(assemblyName, new EventInfo(eventType, obj)); - } - } - } - - protected override void OnUnLoad(int assemblyName) - { - if (_assemblyEvents.TryGetValue(assemblyName, out var events)) - { - foreach (var @event in events) - { - _events.RemoveValue(@event.Type, (IEvent)@event.Obj); - } - - _assemblyEvents.RemoveByKey(assemblyName); - } - - if (_assemblyAsyncEvents.TryGetValue(assemblyName, out var asyncEvents)) - { - foreach (var @event in asyncEvents) - { - _asyncEvents.RemoveValue(@event.Type, (IAsyncEvent)@event.Obj); - } - - _assemblyAsyncEvents.RemoveByKey(assemblyName); - } - } - - public void Publish(TEventData eventData) where TEventData : struct - { - if (!_events.TryGetValue(eventData.GetType(), out var list)) - { - return; - } - - foreach (var @event in list) - { - try - { - @event.Invoke(eventData); - } - catch (Exception e) - { - Log.Error(e); - } - } - } - - public void Publish(TEventData eventData, bool isDisposed = true) where TEventData : Entity - { - if (!_events.TryGetValue(typeof(TEventData), out var list)) - { - return; - } - - foreach (var @event in list) - { - try - { - @event.Invoke(eventData); - } - catch (Exception e) - { - Log.Error(e); - } - } - - if (isDisposed) - { - eventData.Dispose(); - } - } - - public async FTask PublishAsync(TEventData eventData) where TEventData : struct - { - if (!_asyncEvents.TryGetValue(eventData.GetType(), out var list)) - { - return; - } - - using var tasks = ListPool.Create(); - - foreach (var @event in list) - { - tasks.Add(@event.InvokeAsync(eventData)); - } - - await FTask.WhenAll(tasks); - } - - public async FTask PublishAsync(TEventData eventData, bool isDisposed = true) where TEventData : Entity - { - if (!_asyncEvents.TryGetValue(eventData.GetType(), out var list)) - { - return; - } - - using var tasks = ListPool.Create(); - - foreach (var @event in list) - { - tasks.Add(@event.InvokeAsync(eventData)); - } - - await FTask.WhenAll(tasks); - - if (isDisposed) - { - eventData.Dispose(); - } - } - - public override void Dispose() - { - _events.Clear(); - _asyncEvents.Clear(); - _assemblyEvents.Clear(); - _assemblyAsyncEvents.Clear(); - AssemblyManager.OnLoadAssemblyEvent -= OnLoad; - AssemblyManager.OnUnLoadAssemblyEvent -= OnUnLoad; - base.Dispose(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/EventSystem/EventSystem.cs.meta b/Assets/GameScripts/DotNet/Core/EventSystem/EventSystem.cs.meta deleted file mode 100644 index 224b204a..00000000 --- a/Assets/GameScripts/DotNet/Core/EventSystem/EventSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b56c6594aff226346866e463dbc20582 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/EventSystem/Interface.meta b/Assets/GameScripts/DotNet/Core/EventSystem/Interface.meta deleted file mode 100644 index 5422cf26..00000000 --- a/Assets/GameScripts/DotNet/Core/EventSystem/Interface.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 582e470763f128640a6c6a2ef0c34243 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/EventSystem/Interface/IEvent.cs b/Assets/GameScripts/DotNet/Core/EventSystem/Interface/IEvent.cs deleted file mode 100644 index 18b7e8fb..00000000 --- a/Assets/GameScripts/DotNet/Core/EventSystem/Interface/IEvent.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; - -namespace TEngine -{ - public interface IEvent - { - Type EventType(); - void Invoke(object self); - } - - public interface IAsyncEvent - { - Type EventType(); - FTask InvokeAsync(object self); - } - - public abstract class EventSystem : IEvent - { - private readonly Type _selfType = typeof(T); - - public Type EventType() - { - return _selfType; - } - - public abstract void Handler(T self); - - public void Invoke(object self) - { - try - { - Handler((T) self); - } - catch (Exception e) - { - Log.Error($"{_selfType.Name} Error {e}"); - } - } - } - - public abstract class AsyncEventSystem : IAsyncEvent - { - private readonly Type _selfType = typeof(T); - - public Type EventType() - { - return _selfType; - } - - public abstract FTask Handler(T self); - - public async FTask InvokeAsync(object self) - { - try - { - await Handler((T) self); - } - catch (Exception e) - { - Log.Error($"{_selfType.Name} Error {e}"); - } - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/EventSystem/Interface/IEvent.cs.meta b/Assets/GameScripts/DotNet/Core/EventSystem/Interface/IEvent.cs.meta deleted file mode 100644 index cc069ad2..00000000 --- a/Assets/GameScripts/DotNet/Core/EventSystem/Interface/IEvent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d36b90aef6077f941b9fe043ab4889b9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter.meta b/Assets/GameScripts/DotNet/Core/Exporter.meta deleted file mode 100644 index 8664db9a..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 0e276cb6ff6d7414bacb29a4cd3a610a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel.meta b/Assets/GameScripts/DotNet/Core/Exporter/Excel.meta deleted file mode 100644 index 7ecd1b1d..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: bd2dcfcb8e4f2cd458f5b287c26f8dc4 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base.meta b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base.meta deleted file mode 100644 index 2991af22..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 374826e14ee51d24b9386dcdba282238 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary.meta b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary.meta deleted file mode 100644 index 5a7c1f41..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 2da9efac32374cb1a88c500e7ed43344 -timeCreated: 1691084274 \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary/IntDictionaryConfig.cs b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary/IntDictionaryConfig.cs deleted file mode 100644 index 4a4d462b..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary/IntDictionaryConfig.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; -using ProtoBuf; - -namespace TEngine.Core -{ - [ProtoContract] - public class IntDictionaryConfig - { - [ProtoMember(1, IsRequired = true)] - public Dictionary Dic; - - public int this[int key] => GetValue(key); - - public bool TryGetValue(int key, out int value) - { - value = default; - - if (!Dic.ContainsKey(key)) - { - return false; - } - - value = Dic[key]; - return true; - } - - private int GetValue(int key) - { - return Dic.TryGetValue(key, out var value) ? value : default; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary/IntDictionaryConfig.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary/IntDictionaryConfig.cs.meta deleted file mode 100644 index 4cb0b234..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary/IntDictionaryConfig.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 34b41344fd6e462bae371207cdf8a5cd -timeCreated: 1691084286 \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary/StringDictionaryConfig.cs b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary/StringDictionaryConfig.cs deleted file mode 100644 index 5f72da38..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary/StringDictionaryConfig.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System.Collections.Generic; -using ProtoBuf; - -namespace TEngine.Core -{ - [ProtoContract] - public sealed class StringDictionaryConfig - { - [ProtoMember(1, IsRequired = true)] - public Dictionary Dic; - - public string this[int key] => GetValue(key); - - public bool TryGetValue(int key, out string value) - { - value = default; - - if (!Dic.ContainsKey(key)) - { - return false; - } - - value = Dic[key]; - return true; - } - - private string GetValue(int key) - { - return Dic.TryGetValue(key, out var value) ? value : default; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary/StringDictionaryConfig.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary/StringDictionaryConfig.cs.meta deleted file mode 100644 index 00d53c76..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/Dictionary/StringDictionaryConfig.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: a26ad73832de4b3e986ddb58426bcced -timeCreated: 1691084294 \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/DynamicAssembly.cs b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/DynamicAssembly.cs deleted file mode 100644 index 565eb698..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/DynamicAssembly.cs +++ /dev/null @@ -1,144 +0,0 @@ -#if TENGINE_NET -using System.Reflection; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using ProtoBuf; - -#pragma warning disable CS8600 -#pragma warning disable CS8601 - -namespace TEngine.Core; - -public static class DynamicAssembly -{ - public static Assembly Load(string path) - { - var fileList = new List(); - - // 找到所有需要加载的CS文件 - - foreach (string file in Directory.GetFiles(path)) - { - if (Path.GetExtension(file) != ".cs") - { - continue; - } - - fileList.Add(file); - } - - var syntaxTreeList = new List(); - - foreach (var file in fileList) - { - using var fileStream = new StreamReader(file); - var cSharp = CSharpSyntaxTree.ParseText(fileStream.ReadToEnd()); - syntaxTreeList.Add(cSharp); - } - - AssemblyMetadata assemblyMetadata; - MetadataReference metadataReference; - var currentDomain = AppDomain.CurrentDomain; - var assemblyName = Path.GetRandomFileName(); - var assemblyArray = currentDomain.GetAssemblies(); - var metadataReferenceList = new List(); - - // 注册引用 - - foreach (var domainAssembly in assemblyArray) - { - if (string.IsNullOrEmpty(domainAssembly.Location)) - { - continue; - } - - assemblyMetadata = AssemblyMetadata.CreateFromFile(domainAssembly.Location); - metadataReference = assemblyMetadata.GetReference(); - metadataReferenceList.Add(metadataReference); - } - - // 添加ProtoEntity支持 - - assemblyMetadata = AssemblyMetadata.CreateFromFile(typeof(AProto).Assembly.Location); - metadataReference = assemblyMetadata.GetReference(); - metadataReferenceList.Add(metadataReference); - - // 添加ProtoBuf.net支持 - - assemblyMetadata = AssemblyMetadata.CreateFromFile(typeof(ProtoMemberAttribute).Assembly.Location); - metadataReference = assemblyMetadata.GetReference(); - metadataReferenceList.Add(metadataReference); - - CSharpCompilation compilation = CSharpCompilation.Create(assemblyName, syntaxTreeList, metadataReferenceList, - new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); - - using var ms = new MemoryStream(); - - var result = compilation.Emit(ms); - if (!result.Success) - { - foreach (var resultDiagnostic in result.Diagnostics) - { - Exporter.LogError(resultDiagnostic.GetMessage()); - } - - throw new Exception("failures"); - } - - ms.Seek(0, SeekOrigin.Begin); - return Assembly.Load(ms.ToArray()); - } - - public static DynamicConfigDataType GetDynamicInfo(Assembly dynamicAssembly, string tableName) - { - var dynamicConfigDataType = new DynamicConfigDataType - { - ConfigDataType = GetConfigType(dynamicAssembly, $"{tableName}Data"), - ConfigType = GetConfigType(dynamicAssembly, $"{tableName}") - }; - - dynamicConfigDataType.ConfigData = CreateInstance(dynamicConfigDataType.ConfigDataType); - var listPropertyType = dynamicConfigDataType.ConfigDataType.GetProperty("List"); - - if (listPropertyType == null) - { - throw new Exception("No Property named Add was found"); - } - - dynamicConfigDataType.Obj = listPropertyType.GetValue(dynamicConfigDataType.ConfigData); - dynamicConfigDataType.Method = listPropertyType.PropertyType.GetMethod("Add"); - - if (dynamicConfigDataType.Method == null) - { - throw new Exception("No method named Add was found"); - } - - return dynamicConfigDataType; - } - - private static Type GetConfigType(Assembly dynamicAssembly, string typeName) - { - var configType = dynamicAssembly.GetType($"TEngine.{typeName}"); - - if (configType == null) - { - throw new FileNotFoundException($"TEngine.{typeName} not found"); - } - - return configType; - // return dynamicAssembly.GetType($"TEngine.{typeName}"); - } - - public static AProto CreateInstance(Type configType) - { - var config = (AProto) Activator.CreateInstance(configType); - - if (config == null) - { - throw new Exception($"{configType.Name} is Activator.CreateInstance error"); - } - - return config; - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/DynamicAssembly.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/DynamicAssembly.cs.meta deleted file mode 100644 index 9439d69d..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/DynamicAssembly.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5ba993a045ee2d94da4827d5eff902af -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/DynamicConfigDataType.cs b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/DynamicConfigDataType.cs deleted file mode 100644 index dd67c3ce..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/DynamicConfigDataType.cs +++ /dev/null @@ -1,16 +0,0 @@ -#if TENGINE_NET -using System.Reflection; -using System.Text; - -namespace TEngine.Core; - -public class DynamicConfigDataType -{ - public AProto ConfigData; - public Type ConfigDataType; - public Type ConfigType; - public MethodInfo Method; - public object Obj; - public StringBuilder Json = new StringBuilder(); -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/DynamicConfigDataType.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/DynamicConfigDataType.cs.meta deleted file mode 100644 index 11e0d3fb..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/DynamicConfigDataType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 85d5d45679512064fa1c6dbbbc5ff29c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExcelTable.cs b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExcelTable.cs deleted file mode 100644 index d649fc8e..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExcelTable.cs +++ /dev/null @@ -1,15 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core; - -public sealed class ExcelTable -{ - public readonly string Name; - public readonly SortedDictionary> ClientColInfos = new(); - public readonly SortedDictionary> ServerColInfos = new(); - - public ExcelTable(string name) - { - Name = name; - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExcelTable.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExcelTable.cs.meta deleted file mode 100644 index 311c2005..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExcelTable.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ae216cf2a8852c54d9b1de65bc64fafa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExportInfo.cs b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExportInfo.cs deleted file mode 100644 index 538e9a87..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExportInfo.cs +++ /dev/null @@ -1,9 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core; - -public class ExportInfo -{ - public string Name; - public FileInfo FileInfo; -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExportInfo.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExportInfo.cs.meta deleted file mode 100644 index 2bd72782..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExportInfo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3b19f3554768a6647b36f89e6a7c2116 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExportType.cs b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExportType.cs deleted file mode 100644 index 6f435890..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExportType.cs +++ /dev/null @@ -1,34 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core; - -/// -/// 导出类型枚举,用于标识不同类型的导出操作。 -/// -public enum ExportType -{ - /// - /// 无导出类型。 - /// - None = 0, - /// - /// 导出ProtoBuf类型。 - /// - ProtoBuf = 1, - /// - /// 导出网络协议并重新生成OpCode。 - /// - ProtoBufAndOpCodeCache = 2, - /// - /// 所有数据的增量导出Excel类型。 - /// - AllExcelIncrement = 3, - /// - /// 所有数据的全量导出Excel类型。 - /// - AllExcel = 4, - /// - /// 导出类型枚举的最大值,一定要放在最后。 - /// - Max, -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExportType.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExportType.cs.meta deleted file mode 100644 index fb983303..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/Base/ExportType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8c7d1a9efd4b9a94bb7c4d99a7160068 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/ClientConfigTableManage.cs b/Assets/GameScripts/DotNet/Core/Exporter/Excel/ClientConfigTableManage.cs deleted file mode 100644 index 59bd9162..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/ClientConfigTableManage.cs +++ /dev/null @@ -1,84 +0,0 @@ -#if TENGINE_UNITY -using System; -using System.Collections.Generic; -using TEngine.Core; -using UnityEngine; - -namespace TEngine.Core -{ - public static class ConfigTableManage - { - private static readonly string ConfigBundle = "Config".ToLower(); - private static readonly Dictionary ConfigDic = new (); - - static ConfigTableManage() - { - - } - - public static T Load() where T : AProto - { - var dataConfig = typeof(T).Name; - - if (ConfigDic.TryGetValue(dataConfig, out var aProto)) - { - return (T)aProto; - } - - try - { - var bytes = GameModule.Resource.LoadAsset($"{ConfigBundle}-{dataConfig}").bytes; - var data = (AProto) ProtoBufHelper.FromBytes(typeof(T), bytes, 0, bytes.Length); - data.AfterDeserialization(); - ConfigDic[dataConfig] = data; - return (T)data; - } - catch (Exception ex) - { - throw new Exception($"ConfigTableManage:{typeof(T).Name} 数据表加载之后反序列化时出错:{ex}"); - } - } - - private static AProto Load(string dataConfig, int assemblyName) - { - if (ConfigDic.TryGetValue(dataConfig, out var aProto)) - { - return aProto; - } - - var fullName = $"TEngine.{dataConfig}"; - var assembly = AssemblyManager.GetAssembly(assemblyName); - var type = assembly.GetType(fullName); - - if (type == null) - { - Log.Error($"not find {fullName} in assembly"); - return null; - } - - try - { - var bytes = GameModule.Resource.LoadAsset($"{ConfigBundle}-{dataConfig}").bytes; - var data = (AProto) ProtoBufHelper.FromBytes(type, bytes, 0, bytes.Length); - data.AfterDeserialization(); - ConfigDic[dataConfig] = data; - return data; - } - catch (Exception ex) - { - throw new Exception($"ConfigTableManage:{type.Name} 数据表加载之后反序列化时出错:{ex}"); - } - } - - private static void Reload() - { - foreach (var (_, aProto) in ConfigDic) - { - ((IDisposable) aProto).Dispose(); - } - - ConfigDic.Clear(); - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/ClientConfigTableManage.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/Excel/ClientConfigTableManage.cs.meta deleted file mode 100644 index 600aea99..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/ClientConfigTableManage.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 30f0a5e8602ad3d4f83d9e275d1edd15 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/ExcelExporter.cs b/Assets/GameScripts/DotNet/Core/Exporter/Excel/ExcelExporter.cs deleted file mode 100644 index a8afe812..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/ExcelExporter.cs +++ /dev/null @@ -1,784 +0,0 @@ -#if TENGINE_NET -using System.Collections.Concurrent; -using System.Reflection; -using System.Runtime.Loader; -using System.Text; -using System.Text.RegularExpressions; -using TEngine.CustomExport; -using TEngine.DataStructure; -using Newtonsoft.Json; -using OfficeOpenXml; -using TEngine.Helper; -using static System.String; - -namespace TEngine.Core; - -using TableDictionary = SortedDictionary>; - -public sealed class ExcelExporter -{ - private Dictionary _versionDic; - private readonly Regex _regexName = new Regex("^[a-zA-Z][a-zA-Z0-9_]*$"); - private readonly HashSet _loadFiles = new HashSet {".xlsx", ".xlsm", ".csv"}; - private readonly OneToManyList _tables = new OneToManyList(); - private readonly ConcurrentDictionary _excelTables = new ConcurrentDictionary(); - private readonly ConcurrentDictionary _worksheets = new ConcurrentDictionary(); - - static ExcelExporter() - { - ExcelPackage.LicenseContext = LicenseContext.NonCommercial; - } - - public ExcelExporter(ExportType exportType) - { - var versionFilePath = Define.ExcelVersionFile; - - switch (exportType) - { - case ExportType.AllExcelIncrement: - { - break; - } - case ExportType.AllExcel: - { - if (File.Exists(versionFilePath)) - { - File.Delete(versionFilePath); - } - - FileHelper.ClearDirectoryFile(Define.ExcelServerFileDirectory); - FileHelper.ClearDirectoryFile(Define.ExcelClientFileDirectory); - break; - } - } - - Find(); - Parsing(); - ExportToBinary(); - File.WriteAllText(versionFilePath, JsonConvert.SerializeObject(_versionDic)); - CustomExport(); - } - - private static void CustomExport() - { - // 清除文件夹 - FileHelper.ClearDirectoryFile(Define.ServerCustomExportDirectory); - FileHelper.ClearDirectoryFile(Define.ClientCustomExportDirectory); - // 找到程序集 - var assemblyLoadContext = new AssemblyLoadContext("ExporterDll", true); - var dllBytes = File.ReadAllBytes($"{Define.CustomExportAssembly}.dll"); - var pdbBytes = File.ReadAllBytes($"{Define.CustomExportAssembly}.pdb"); - var assembly = assemblyLoadContext.LoadFromStream(new MemoryStream(dllBytes), new MemoryStream(pdbBytes)); - // 加载程序集 - AssemblyManager.LoadAssembly(int.MaxValue, assembly); - - // 执行自定义导出 - - var task = new List(); - - foreach (var type in AssemblyManager.ForEach(typeof(ICustomExport))) - { - var customExport = (ICustomExport)Activator.CreateInstance(type); - - if (customExport != null) - { - task.Add(Task.Run(customExport.Run)); - } - } - - // 添加生成SceneType的自定义导出 - task.Add(Task.Run(new SceneTypeConfigToEnum().Run)); - - Task.WaitAll(task.ToArray()); - } - - /// - /// 查找配置文件 - /// - private void Find() - { - var versionFilePath = Define.ExcelVersionFile; - - if(File.Exists(versionFilePath)) - { - var versionJson = File.ReadAllText(versionFilePath); - _versionDic = JsonConvert.DeserializeObject>(versionJson); - } - else - { - _versionDic = new Dictionary(); - } - - var dir = new DirectoryInfo(Define.ExcelProgramPath); - var excelFiles = dir.GetFiles("*", SearchOption.AllDirectories); - - if (excelFiles.Length <= 0) - { - return; - } - - foreach (var excelFile in excelFiles) - { - // 过滤掉非指定后缀的文件 - - if (!_loadFiles.Contains(excelFile.Extension)) - { - continue; - } - - var lastIndexOf = excelFile.Name.LastIndexOf(".", StringComparison.Ordinal); - - if (lastIndexOf < 0) - { - continue; - } - - var fullName = excelFile.FullName; - var excelName = excelFile.Name.Substring(0, lastIndexOf); - var path = fullName.Substring(0, fullName.Length - excelFile.Name.Length); - - // 过滤#和~开头文件和文件夹带有#的所有文件 - - if (excelName.StartsWith("#", StringComparison.Ordinal) || - excelName.StartsWith("~", StringComparison.Ordinal) || - path.Contains("#", StringComparison.Ordinal)) - { - continue; - } - - if (!_regexName.IsMatch(excelName)) - { - Exporter.LogError($"{excelName} 配置文件名非法"); - continue; - } - - _tables.Add(excelName.Split('_')[0], new ExportInfo() - { - Name = excelName, FileInfo = excelFile - }); - } - - var removeTables = new List(); - - foreach (var (tableName, tableList) in _tables) - { - var isNeedExport = false; - - foreach (var exportInfo in tableList) - { - var timer = TimeHelper.Transition(exportInfo.FileInfo.LastWriteTime); - - if (!isNeedExport) - { - if (_versionDic.TryGetValue(exportInfo.Name, out var lastWriteTime)) - { - isNeedExport = lastWriteTime != timer; - } - else - { - isNeedExport = true; - } - } - - _versionDic[exportInfo.Name] = timer; - } - - if (!isNeedExport) - { - removeTables.Add(tableName); - } - } - - foreach (var removeTable in removeTables) - { - _tables.Remove(removeTable); - } - - foreach (var (_, exportInfo) in _tables) - { - exportInfo.Sort((x, y) => Compare(x.Name, y.Name, StringComparison.Ordinal)); - } - } - - /// - /// 生成配置文件 - /// - private void Parsing() - { - var generateTasks = new List(); - - foreach (var (tableName, tableList) in _tables) - { - var task = Task.Run(() => - { - var writeToClassTask = new List(); - var excelTable = new ExcelTable(tableName); - - // 筛选需要导出的列 - - foreach (var exportInfo in tableList) - { - try - { - var serverColInfoList = new List(); - var clientColInfoList = new List(); - var worksheet = LoadExcel(exportInfo.FileInfo.FullName, true); - - for (var col = 3; col <= worksheet.Columns.EndColumn; col++) - { - // 列名字第一个字符是#不参与导出 - - var colName = worksheet.GetCellValue(5, col); - if (colName.StartsWith("#", StringComparison.Ordinal)) - { - continue; - } - - // 数值列不参与导出 - - var numericalCol = worksheet.GetCellValue(3, col); - if (numericalCol != "" && numericalCol != "0") - { - continue; - } - - var serverType = worksheet.GetCellValue(1, col); - var clientType = worksheet.GetCellValue(2, col); - var isExportServer = !IsNullOrEmpty(serverType) && serverType != "0"; - var isExportClient = !IsNullOrEmpty(clientType) && clientType != "0"; - - if (!isExportServer && !isExportClient) - { - continue; - } - - if (isExportServer && isExportClient & serverType != clientType) - { - Exporter.LogError($"配置表 {exportInfo.Name} {col} 列 [{colName}] 客户端类型 {clientType} 和 服务端类型 {serverType} 不一致"); - continue; - } - - if (!Define.ColTypeSet.Contains(serverType) || - !Define.ColTypeSet.Contains(clientType)) - { - Exporter.LogError($"配置表 {exportInfo.Name} {col} 列 [{colName}] 客户端类型 {clientType}, 服务端类型 {serverType} 不合法"); - continue; - } - - if (!_regexName.IsMatch(colName)) - { - Exporter.LogError($"配置表 {exportInfo.Name} {col} 列 [{colName}] 列名非法"); - continue; - } - - serverColInfoList.Add(col); - - if (isExportClient) - { - clientColInfoList.Add(col); - } - } - - if (clientColInfoList.Count > 0) - { - excelTable.ClientColInfos.Add(exportInfo.FileInfo.FullName, clientColInfoList); - } - - if (serverColInfoList.Count > 0) - { - excelTable.ServerColInfos.Add(exportInfo.FileInfo.FullName, serverColInfoList); - } - } - catch (Exception e) - { - Exporter.LogError($"Config : {tableName}, Name : {exportInfo.Name}, Error : {e}"); - } - } - - // 生成cs文件 - - writeToClassTask.Add(Task.Run(() => - { - WriteToClass(excelTable.ServerColInfos, Define.ExcelServerFileDirectory, true); - })); - - writeToClassTask.Add(Task.Run(() => - { - WriteToClass(excelTable.ClientColInfos, Define.ExcelClientFileDirectory, false); - })); - - Task.WaitAll(writeToClassTask.ToArray()); - _excelTables.TryAdd(tableName, excelTable); - }); - - generateTasks.Add(task); - } - - Task.WaitAll(generateTasks.ToArray()); - } - - /// - /// 写入到cs - /// - /// - /// - /// - private void WriteToClass(TableDictionary colInfos, string exportPath, bool isServer) - { - if (colInfos.Count <= 0) - { - return; - } - - var index = 0; - var fileBuilder = new StringBuilder(); - var colNameSet = new HashSet(); - - if (colInfos.Count == 0) - { - return; - } - - var csName = Path.GetFileNameWithoutExtension(colInfos.First().Key)?.Split('_')[0]; - - foreach (var (tableName, cols) in colInfos) - { - if (cols == null || cols.Count == 0) - { - continue; - } - - var excelWorksheet = LoadExcel(tableName, false); - - foreach (var colIndex in cols) - { - var colName = excelWorksheet.GetCellValue(5, colIndex); - - if (colNameSet.Contains(colName)) - { - continue; - } - - colNameSet.Add(colName); - - string colType; - - if (isServer) - { - colType = excelWorksheet.GetCellValue(1, colIndex); - - if (IsNullOrEmpty(colType) || colType == "0") - { - colType = excelWorksheet.GetCellValue(2, colIndex); - } - } - else - { - colType = excelWorksheet.GetCellValue(2, colIndex); - } - - var remarks = excelWorksheet.GetCellValue(4, colIndex); - - fileBuilder.Append($"\n\t\t[ProtoMember({++index}, IsRequired = true)]\n"); - fileBuilder.Append( - IsArray(colType,out var t) - ? $"\t\tpublic {colType} {colName} {{ get; set; }} = Array.Empty<{t}>(); // {remarks}" - : $"\t\tpublic {colType} {colName} {{ get; set; }} // {remarks}"); - } - } - - var template = Define.ExcelTemplate; - - if (fileBuilder.Length > 0) - { - if (!Directory.Exists(exportPath)) - { - Directory.CreateDirectory(exportPath); - } - - var content = template.Replace("(namespace)", "TEngine") - .Replace("(ConfigName)", csName) - .Replace("(Fields)", fileBuilder.ToString()); - File.WriteAllText(Path.Combine(exportPath, $"{csName}.cs"), content); - } - } - - /// - /// 把数据和实体类转换二进制导出到文件中 - /// - private void ExportToBinary() - { - var exportToBinaryTasks = new List(); - var dynamicServerAssembly = DynamicAssembly.Load(Define.ExcelServerFileDirectory); - var dynamicClientAssembly = DynamicAssembly.Load(Define.ExcelClientFileDirectory); - - foreach (var (tableName, tableList) in _tables) - { - var task = Task.Run(() => - { - var idCheck = new HashSet(); - var excelTable = _excelTables[tableName]; - var csName = Path.GetFileNameWithoutExtension(tableName); - var serverColInfoCount = excelTable.ServerColInfos.Sum(d=>d.Value.Count); - var serverDynamicInfo = serverColInfoCount == 0 ? null : DynamicAssembly.GetDynamicInfo(dynamicServerAssembly, csName); - var clientColInfoCount = excelTable.ClientColInfos.Sum(d=>d.Value.Count); - var clientDynamicInfo = clientColInfoCount == 0 ? null : DynamicAssembly.GetDynamicInfo(dynamicClientAssembly, csName); - - for (var i = 0; i < tableList.Count; i++) - { - var tableListName = tableList[i]; - - try - { - var fileInfoFullName = tableListName.FileInfo.FullName; - var excelWorksheet = LoadExcel(fileInfoFullName, false); - var rows = excelWorksheet.Dimension.Rows; - excelTable.ServerColInfos.TryGetValue(fileInfoFullName, out var serverCols); - excelTable.ClientColInfos.TryGetValue(fileInfoFullName, out var clientCols); - - for (var row = 7; row <= rows; row++) - { - if (excelWorksheet.GetCellValue(row, 1).StartsWith("#", StringComparison.Ordinal)) - { - continue; - } - - var id = excelWorksheet.GetCellValue(row, 3); - - if (idCheck.Contains(id)) - { - Exporter.LogError($"{tableListName.Name} 存在重复Id {id} 行号 {row}"); - continue; - } - - idCheck.Add(id); - var isLast = row == rows && (i == tableList.Count - 1); - GenerateBinary(fileInfoFullName, excelWorksheet, serverDynamicInfo, serverCols, id, row, isLast, true); - GenerateBinary(fileInfoFullName, excelWorksheet, clientDynamicInfo, clientCols, id, row, isLast, false); - } - } - catch (Exception e) - { - Exporter.LogError($"Table:{tableListName} error! \n{e}"); - throw; - } - } - - if (serverDynamicInfo?.ConfigData != null) - { - var bytes = ProtoBufHelper.ToBytes(serverDynamicInfo.ConfigData); - var serverBinaryDirectory = Define.ExcelServerBinaryDirectory; - - if (!Directory.Exists(serverBinaryDirectory)) - { - Directory.CreateDirectory(serverBinaryDirectory); - } - - File.WriteAllBytes(Path.Combine(serverBinaryDirectory, $"{csName}Data.bytes"), bytes); - - if (serverDynamicInfo.Json.Length > 0) - { - var serverJsonDirectory = Define.ExcelServerJsonDirectory; - using var sw = new StreamWriter(Path.Combine(serverJsonDirectory, $"{csName}Data.Json")); - sw.WriteLine("{\"List\":["); - sw.Write(serverDynamicInfo.Json.ToString()); - sw.WriteLine("]}"); - } - } - - if (clientDynamicInfo?.ConfigData != null) - { - var bytes = ProtoBufHelper.ToBytes(clientDynamicInfo.ConfigData); - var clientBinaryDirectory = Define.ExcelClientBinaryDirectory; - - if (!Directory.Exists(clientBinaryDirectory)) - { - Directory.CreateDirectory(clientBinaryDirectory); - } - - File.WriteAllBytes(Path.Combine(clientBinaryDirectory, $"{csName}Data.bytes"), bytes); - - if (clientDynamicInfo.Json.Length > 0) - { - var clientJsonDirectory = Define.ExcelClientJsonDirectory; - using var sw = new StreamWriter(Path.Combine(clientJsonDirectory, $"{csName}Data.Json")); - sw.WriteLine("{\"List\":["); - sw.Write(clientDynamicInfo.Json.ToString()); - sw.WriteLine("]}"); - } - } - }); - exportToBinaryTasks.Add(task); - } - - Task.WaitAll(exportToBinaryTasks.ToArray()); - } - - private void GenerateBinary(string fileInfoFullName, ExcelWorksheet excelWorksheet, DynamicConfigDataType dynamicInfo, List cols, string id, int row, bool isLast, bool isServer) - { - if (cols == null || IsNullOrEmpty(id) || cols.Count <= 0 || dynamicInfo?.ConfigType == null) - { - return; - } - - var config = DynamicAssembly.CreateInstance(dynamicInfo.ConfigType); - - for (var i = 0; i < cols.Count; i++) - { - string colType; - var colIndex = cols[i]; - var colName = excelWorksheet.GetCellValue(5, colIndex); - var value = excelWorksheet.GetCellValue(row, colIndex); - - if (isServer) - { - colType = excelWorksheet.GetCellValue(1, colIndex); - - if (IsNullOrEmpty(colType) || colType == "0") - { - colType = excelWorksheet.GetCellValue(2, colIndex); - } - } - else - { - colType = excelWorksheet.GetCellValue(2, colIndex); - } - - try - { - SetNewValue(dynamicInfo.ConfigType.GetProperty(colName), config, colType, value); - } - catch (Exception e) - { - Exporter.LogError($"Error Table {fileInfoFullName} Col:{colName} colType:{colType} Row:{row} value:{value} {e}"); - throw; - } - } - - dynamicInfo.Method.Invoke(dynamicInfo.Obj, new object[] {config}); - - var json = JsonConvert.SerializeObject(config); - - if (isLast) - { - dynamicInfo.Json.AppendLine(json); - } - else - { - dynamicInfo.Json.AppendLine($"{json},"); - } - } - - public ExcelWorksheet LoadExcel(string name, bool isAddToDic) - { - if (_worksheets.TryGetValue(name, out var worksheet)) - { - return worksheet; - } - - worksheet = ExcelHelper.LoadExcel(name).Workbook.Worksheets[0]; - - if (isAddToDic) - { - _worksheets.TryAdd(name, worksheet); - } - - Exporter.LogInfo(name); - return worksheet; - } - - private void SetNewValue(PropertyInfo propertyInfo, AProto config, string type, string value) - { - if (IsNullOrWhiteSpace(value)) - { - return; - } - - switch (type) - { - case "short": - { - propertyInfo.SetValue(config, Convert.ToInt16(value)); - return; - } - case "ushort": - { - propertyInfo.SetValue(config, Convert.ToUInt16(value)); - return; - } - case "uint": - { - propertyInfo.SetValue(config, Convert.ToUInt32(value)); - return; - } - case "int": - { - propertyInfo.SetValue(config, Convert.ToInt32(value)); - return; - } - case "decimal": - { - propertyInfo.SetValue(config, Convert.ToDecimal(value)); - return; - } - case "string": - { - try - { - propertyInfo.SetValue(config, value); - } - catch (Exception e) - { - Console.WriteLine(e); - throw; - } - - return; - } - case "bool": - { - // 空字符串 - - value = value.ToLower(); - - if (IsNullOrEmpty(value)) - { - propertyInfo.SetValue(config, false); - } - else if (bool.TryParse(value, out bool b)) - { - propertyInfo.SetValue(config, b); - } - else if (int.TryParse(value, out int v)) - { - propertyInfo.SetValue(config, v != 0); - } - else - { - propertyInfo.SetValue(config, false); - } - - return; - } - case "ulong": - { - propertyInfo.SetValue(config, Convert.ToUInt64(value)); - return; - } - case "long": - { - propertyInfo.SetValue(config, Convert.ToInt64(value)); - return; - } - case "double": - { - propertyInfo.SetValue(config, Convert.ToDouble(value)); - return; - } - case "float": - { - propertyInfo.SetValue(config, Convert.ToSingle(value)); - return; - } - case "int32[]": - case "int[]": - { - if (value != "0") - { - propertyInfo.SetValue(config, value.Split(",").Select(d => Convert.ToInt32(d)).ToArray()); - } - - return; - } - case "long[]": - { - if (value != "0") - { - propertyInfo.SetValue(config, value.Split(",").Select(d => Convert.ToInt64(d)).ToArray()); - } - - return; - } - case "double[]": - { - if (value != "0") - { - propertyInfo.SetValue(config, value.Split(",").Select(d => Convert.ToDouble(d)).ToArray()); - } - - return; - } - case "string[]": - { - if (value == "0") - { - return; - } - - var list = value.Split(",").ToArray(); - - for (var i = 0; i < list.Length; i++) - { - list[i] = list[i].Replace("\"", ""); - } - - propertyInfo.SetValue(config, value.Split(",").ToArray()); - - return; - } - case "float[]": - { - if (value != "0") - { - propertyInfo.SetValue(config, value.Split(",").Select(d => Convert.ToSingle(d)).ToArray()); - } - - return; - } - case "IntDictionaryConfig": - { - if (value.Trim() == "" || value.Trim() == "{}") - { - propertyInfo.SetValue(config, null); - return; - } - - var attr = new IntDictionaryConfig {Dic = JsonConvert.DeserializeObject>(value)}; - - propertyInfo.SetValue(config, attr); - - return; - } - case "StringDictionaryConfig": - { - if (value.Trim() == "" || value.Trim() == "{}") - { - propertyInfo.SetValue(config, null); - return; - } - - var attr = new StringDictionaryConfig {Dic = JsonConvert.DeserializeObject>(value)}; - - propertyInfo.SetValue(config, attr); - - return; - } - default: - throw new NotSupportedException($"不支持此类型: {type}"); - } - } - - private bool IsArray(string type, out string t) - { - t = null; - var index = type.IndexOf("[]", StringComparison.Ordinal); - - if (index >= 0) - { - t = type.Remove(index, 2); - } - - return index >= 0; - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/ExcelExporter.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/Excel/ExcelExporter.cs.meta deleted file mode 100644 index 9f9c09f4..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/ExcelExporter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 11f644344212d644dbfd6cae6ff1f133 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/ServerConfigTableManage.cs b/Assets/GameScripts/DotNet/Core/Exporter/Excel/ServerConfigTableManage.cs deleted file mode 100644 index 00d8b9d6..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/ServerConfigTableManage.cs +++ /dev/null @@ -1,102 +0,0 @@ -#if TENGINE_NET -using TEngine.Core.DataBase; -using TEngine.Core; -#pragma warning disable CS8603 -#pragma warning disable CS8618 - -namespace TEngine.Core -{ - public static class ConfigTableManage - { - public static Func ServerConfig; - public static Func MachineConfig; - public static Func SceneConfig; - public static Func WorldConfigInfo; - - public static Func> AllServerConfig; - public static Func> AllMachineConfig; - public static Func> AllSceneConfig; - - private const string BinaryDirectory = "../../../Config/Binary/"; - private static readonly Dictionary ConfigDic = new (); - - public static T Load() where T : AProto - { - var dataConfig = typeof(T).Name; - - if (ConfigDic.TryGetValue(dataConfig, out var aProto)) - { - return (T)aProto; - } - - try - { - var configFile = GetConfigPath(dataConfig); - var bytes = File.ReadAllBytes(configFile); - var data = (T)ProtoBufHelper.FromBytes(typeof(T), bytes, 0, bytes.Length); - data.AfterDeserialization(); - ConfigDic[dataConfig] = data; - return (T)data; - } - catch (Exception ex) - { - throw new Exception($"ConfigTableManage:{typeof(T).Name} 数据表加载之后反序列化时出错:{ex}"); - } - } - - private static AProto Load(string dataConfig, int assemblyName) - { - if (ConfigDic.TryGetValue(dataConfig, out var aProto)) - { - return aProto; - } - - var fullName = $"TEngine.{dataConfig}"; - var assembly = AssemblyManager.GetAssembly(assemblyName); - var type = assembly.GetType(fullName); - - if (type == null) - { - Log.Error($"not find {fullName} in assembly"); - return null; - } - - try - { - var configFile = GetConfigPath(type.Name); - var bytes = File.ReadAllBytes(configFile); - var data = (AProto)ProtoBufHelper.FromBytes(type, bytes, 0, bytes.Length); - data.AfterDeserialization(); - ConfigDic[dataConfig] = data; - return data; - } - catch (Exception ex) - { - throw new Exception($"ConfigTableManage:{type.Name} 数据表加载之后反序列化时出错:{ex}"); - } - } - - private static string GetConfigPath(string name) - { - var configFile = Path.Combine(BinaryDirectory, $"{name}.bytes"); - - if (File.Exists(configFile)) - { - return configFile; - } - - throw new FileNotFoundException($"{name}.byte not found: {configFile}"); - } - - private static void Reload() - { - foreach (var (_, aProto) in ConfigDic) - { - ((IDisposable) aProto).Dispose(); - } - - ConfigDic.Clear(); - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Excel/ServerConfigTableManage.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/Excel/ServerConfigTableManage.cs.meta deleted file mode 100644 index 7096eea2..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Excel/ServerConfigTableManage.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 04d66af120535af4a9dbbbf4e73931a1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Exporter.cs b/Assets/GameScripts/DotNet/Core/Exporter/Exporter.cs deleted file mode 100644 index e9bfd275..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Exporter.cs +++ /dev/null @@ -1,107 +0,0 @@ -#if TENGINE_NET -using System.Diagnostics; -using System.Reflection; -using System.Runtime.Loader; -using System.Text; -using TEngine.Helper; -using Microsoft.Extensions.Configuration; -#pragma warning disable CS8601 - - -namespace TEngine.Core; - -/// -/// 数据导出器,用于执行导出操作。 -/// -public sealed class Exporter -{ - /// - /// 开始执行数据导出操作。 - /// - public void Start() - { - Console.OutputEncoding = Encoding.UTF8; - var exportType = AppDefine.Options.ExportType; - - if (exportType != ExportType.None) - { - return; - } - - LogInfo("请输入你想要做的操作:"); - LogInfo("1:导出网络协议(ProtoBuf)"); - LogInfo("2:导出网络协议并重新生成OpCode(ProtoBuf)"); - LogInfo("3:增量导出Excel(包含常量枚举)"); - LogInfo("4:全量导出Excel(包含常量枚举)"); - - var keyChar = Console.ReadKey().KeyChar; - - if (!int.TryParse(keyChar.ToString(), out var key) || key is < 1 or >= (int) ExportType.Max) - { - Console.WriteLine(""); - LogInfo("无法识别的导出类型请,输入正确的操作类型。"); - return; - } - - LogInfo(""); - exportType = (ExportType) key; - - switch (exportType) - { - case ExportType.ProtoBuf: - { - _ = new ProtoBufExporter(false); - break; - } - case ExportType.ProtoBufAndOpCodeCache: - { - _ = new ProtoBufExporter(true); - break; - } - case ExportType.AllExcel: - case ExportType.AllExcelIncrement: - { - _ = new ExcelExporter(exportType); - break; - } - } - - LogInfo("操作完成,按任意键关闭程序"); - Console.ReadKey(); - Environment.Exit(0); - } - - /// - /// 输出信息到控制台。 - /// - /// 要输出的信息。 - public static void LogInfo(string msg) - { - Console.WriteLine(msg); - } - - /// - /// 输出错误信息到控制台。 - /// - /// 要输出的错误信息。 - public static void LogError(string msg) - { - ConsoleColor color = Console.ForegroundColor; - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine($"{msg}\n{new StackTrace(1, true)}"); - Console.ForegroundColor = color; - } - - /// - /// 输出异常信息到控制台。 - /// - /// 要输出的异常。 - public static void LogError(Exception e) - { - ConsoleColor color = Console.ForegroundColor; - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine(e.Data.Contains("StackTrace") ? $"{e.Data["StackTrace"]}\n{e}" : e.ToString()); - Console.ForegroundColor = color; - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Exporter.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/Exporter.cs.meta deleted file mode 100644 index 00a8a5d3..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Exporter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2b2afd6fb4280f446aff438db7861e64 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Interface.meta b/Assets/GameScripts/DotNet/Core/Exporter/Interface.meta deleted file mode 100644 index 719849d5..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Interface.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 3fa83b6f387771f48be26dc88c05e808 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Interface/IConfigTable.cs b/Assets/GameScripts/DotNet/Core/Exporter/Interface/IConfigTable.cs deleted file mode 100644 index bf807ea2..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Interface/IConfigTable.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace TEngine.Core -{ - /// - /// 表示是一个配置文件 - /// - public interface IConfigTable - { - - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Interface/IConfigTable.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/Interface/IConfigTable.cs.meta deleted file mode 100644 index bf9c3b1c..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Interface/IConfigTable.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f0c846012d7e36e4fa17c615f15da685 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Interface/ICustomExport.cs b/Assets/GameScripts/DotNet/Core/Exporter/Interface/ICustomExport.cs deleted file mode 100644 index 5801334f..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Interface/ICustomExport.cs +++ /dev/null @@ -1,44 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core; - -public interface ICustomExport -{ - void Run(); -} -public abstract class ACustomExport : ICustomExport -{ - protected enum CustomExportType - { - Client,Server - } - - public abstract void Run(); - - protected void Write(string fileName, string fileContent, CustomExportType customExportType) - { - switch (customExportType) - { - case CustomExportType.Client: - { - if (!Directory.Exists(Define.ClientCustomExportDirectory)) - { - Directory.CreateDirectory(Define.ClientCustomExportDirectory); - } - - File.WriteAllText($"{Define.ClientCustomExportDirectory}/{fileName}", fileContent); - return; - } - case CustomExportType.Server: - { - if (!Directory.Exists(Define.ServerCustomExportDirectory)) - { - Directory.CreateDirectory(Define.ServerCustomExportDirectory); - } - - File.WriteAllText($"{Define.ServerCustomExportDirectory}/{fileName}", fileContent); - return; - } - } - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Exporter/Interface/ICustomExport.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/Interface/ICustomExport.cs.meta deleted file mode 100644 index 0fec1e0a..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/Interface/ICustomExport.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d55723aa5c671d544a461eb8fb524769 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf.meta b/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf.meta deleted file mode 100644 index 854f2c6a..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5c6c545584f5eb24892e7de1da9daffd -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf/OpCodeCache.cs b/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf/OpCodeCache.cs deleted file mode 100644 index 0183c7b7..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf/OpCodeCache.cs +++ /dev/null @@ -1,60 +0,0 @@ -#if TENGINE_NET -using TEngine.Helper; - -namespace TEngine.Core; - -/// -/// 网络协议操作码缓存。 -/// -public class OpCodeCache -{ - private readonly List _opCodes = new List(); - private readonly SortedDictionary _opcodeCache; - private readonly SortedDictionary _saveOpCodeCache = new(); - private readonly string _opcodeCachePath = $"{Define.ProtoBufDirectory}OpCode.Cache"; - - /// - /// 构造函数,用于初始化网络协议操作码缓存。 - /// - public OpCodeCache(bool regenerate) - { - if (File.Exists(_opcodeCachePath) && !regenerate) - { - var readAllText = File.ReadAllText(_opcodeCachePath); - _opcodeCache = readAllText.Deserialize>(); - _opCodes.AddRange(_opcodeCache.Values); - } - else - { - _opcodeCache = new SortedDictionary(); - } - } - - /// - /// 保存网络协议操作码。 - /// - public void Save() - { - File.WriteAllText(_opcodeCachePath, _saveOpCodeCache.ToJson()); - } - - /// - /// 根据className获得OpCode、如果是新增的会产生一个新的OpCode。 - /// - /// 协议名。 - /// 操作码。 - /// - public uint GetOpcodeCache(string className, ref uint opcode) - { - if (!_opcodeCache.TryGetValue(className, out var opCode)) - { - while (_opCodes.Contains(++opcode)) { } - opCode = opcode; - _opCodes.Add(opCode); - } - - _saveOpCodeCache.Add(className, opCode); - return opCode; - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf/OpCodeCache.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf/OpCodeCache.cs.meta deleted file mode 100644 index f7e5402c..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf/OpCodeCache.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: e0f0d02da06c4ca981417bfe43162809 -timeCreated: 1693928511 \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf/ProtoBufExporter.cs b/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf/ProtoBufExporter.cs deleted file mode 100644 index 975cc8be..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf/ProtoBufExporter.cs +++ /dev/null @@ -1,581 +0,0 @@ -#if TENGINE_NET -using System.Text; -using TEngine.Core.Network; -using TEngine.Helper; - -namespace TEngine.Core; - -/// -/// ProtoBuf操作码类型枚举 -/// -public enum ProtoBufOpCodeType -{ - /// - /// 无 - /// - None = 0, - /// - /// 外部操作码类型 - /// - Outer = 1, - /// - /// 内部操作码类型 - /// - Inner = 2, - /// - /// 使用BSON的内部操作码类型 - /// - InnerBson = 3, -} - -/// -/// 操作码信息类 -/// -public sealed class OpcodeInfo -{ - /// - /// 操作码 - /// - public uint Code; - /// - /// 名称 - /// - public string Name; -} - - -/// -/// ProtoBuf导出器类 -/// -public sealed class ProtoBufExporter -{ - private uint _aMessage; - private uint _aRequest; - private uint _aResponse; - private uint _aRouteMessage; - private uint _aRouteRequest; - private uint _aRouteResponse; - private string _serverTemplate; - private string _clientTemplate; - private readonly OpCodeCache _opCodeCache; - private readonly List _opcodes = new(); - - /// - /// 构造函数,用于初始化导出器 - /// - public ProtoBufExporter(bool regenerateOpCodeCache) - { - Console.OutputEncoding = Encoding.UTF8; - - if (!Directory.Exists(Define.ProtoBufServerDirectory)) - { - Directory.CreateDirectory(Define.ProtoBufServerDirectory); - } - - if (!Directory.Exists(Define.ProtoBufClientDirectory)) - { - Directory.CreateDirectory(Define.ProtoBufClientDirectory); - } - - if (!Directory.Exists($"{Define.ProtoBufDirectory}Outer")) - { - Directory.CreateDirectory($"{Define.ProtoBufDirectory}Outer"); - } - - if (!Directory.Exists($"{Define.ProtoBufDirectory}Inner")) - { - Directory.CreateDirectory($"{Define.ProtoBufDirectory}Inner"); - } - - if (!Directory.Exists($"{Define.ProtoBufDirectory}InnerBosn")) - { - Directory.CreateDirectory($"{Define.ProtoBufDirectory}InnerBosn"); - } - - _opCodeCache = new OpCodeCache(regenerateOpCodeCache); - - var tasks = new Task[2]; - tasks[0] = Task.Run(RouteType); - tasks[1] = Task.Run(async () => - { - LoadTemplate(); - await Start(ProtoBufOpCodeType.Outer); - await Start(ProtoBufOpCodeType.Inner); - await Start(ProtoBufOpCodeType.InnerBson); - }); - Task.WaitAll(tasks); - _opCodeCache.Save(); - } - - private async Task Start(ProtoBufOpCodeType opCodeType) - { - List files = new List(); - var opCodeName = ""; - OpcodeInfo opcodeInfo = null; - _opcodes.Clear(); - var file = new StringBuilder(); - var saveDirectory = new Dictionary(); - - switch (opCodeType) - { - case ProtoBufOpCodeType.Outer: - { - _aMessage = Opcode.OuterMessage; - _aRequest = Opcode.OuterRequest; - _aResponse = Opcode.OuterResponse; - _aRouteMessage = Opcode.OuterRouteMessage; - _aRouteRequest = Opcode.OuterRouteRequest; - _aRouteResponse = Opcode.OuterRouteResponse; - opCodeName = "OuterOpcode"; - saveDirectory.Add(Define.ProtoBufServerDirectory, _serverTemplate); - saveDirectory.Add(Define.ProtoBufClientDirectory, _clientTemplate); - var protoBufFiles = FileHelper.GetDirectoryFile( - $"{Define.ProtoBufDirectory}Outer", "*.proto", SearchOption.AllDirectories); - files.AddRange(protoBufFiles); - break; - } - case ProtoBufOpCodeType.Inner: - { - // 预留1000个协议号给框架内部协议用 - _aMessage = Opcode.InnerMessage + 1000; - _aRequest = Opcode.InnerRequest + 1000; - _aResponse = Opcode.InnerResponse + 1000; - _aRouteMessage = Opcode.InnerRouteMessage + 1000; - _aRouteRequest = Opcode.InnerRouteRequest + 1000; - _aRouteResponse = Opcode.InnerRouteResponse + 1000; - opCodeName = "InnerOpcode"; - saveDirectory.Add(Define.ProtoBufServerDirectory, _serverTemplate); - var protoBufFiles = FileHelper.GetDirectoryFile($"{Define.ProtoBufDirectory}Inner", "*.proto", SearchOption.AllDirectories); - files.AddRange(protoBufFiles); - break; - } - case ProtoBufOpCodeType.InnerBson: - { - // 预留1000个协议号给框架内部协议用 - _aMessage = Opcode.InnerBsonMessage + 1000; - _aRequest = Opcode.InnerBsonRequest + 1000; - _aResponse = Opcode.InnerBsonResponse + 1000; - _aRouteMessage = Opcode.InnerBsonRouteMessage + 1000; - _aRouteRequest = Opcode.InnerBsonRouteRequest + 1000; - _aRouteResponse = Opcode.InnerBsonRouteResponse + 1000; - opCodeName = "InnerBsonOpcode"; - saveDirectory.Add(Define.ProtoBufServerDirectory, _serverTemplate); - var protoBufFiles = FileHelper.GetDirectoryFile($"{Define.ProtoBufDirectory}InnerBosn", "*.proto", SearchOption.AllDirectories); - files.AddRange(protoBufFiles); - break; - } - } - - #region GenerateProtoFiles - foreach (var filePath in files) - { - var parameter = ""; - var className = ""; - var isMsgHead = false; - string responseTypeStr = null; - string customRouteType = null; - - var protoFileText = await File.ReadAllTextAsync(filePath); - - foreach (var line in protoFileText.Split('\n')) - { - bool hadOpCode = true; - - var currentLine = line.Trim(); - - if (string.IsNullOrWhiteSpace(currentLine)) - { - continue; - } - - if (currentLine.StartsWith("///")) - { - file.AppendFormat(" /// \r\n" + " /// {0}\r\n" + " /// \r\n", currentLine.TrimStart(new[] { '/', '/', '/' })); - continue; - } - - if (currentLine.StartsWith("message")) - { - isMsgHead = true; - opcodeInfo = new OpcodeInfo(); - file.AppendLine("\t[ProtoContract]"); - className = currentLine.Split(Define.SplitChars, StringSplitOptions.RemoveEmptyEntries)[1]; - var splits = currentLine.Split(new[] { "//" }, StringSplitOptions.RemoveEmptyEntries); - - if (splits.Length > 1) - { - var parameterArray = currentLine.Split(new[] { "//" }, StringSplitOptions.RemoveEmptyEntries)[1].Trim().Split(','); - parameter = parameterArray[0].Trim(); - - switch (parameterArray.Length) - { - case 2: - { - if (parameter == "ICustomRouteMessage") - { - customRouteType = parameterArray[1].Trim(); - break; - } - - responseTypeStr = parameterArray[1].Trim(); - break; - } - case 3: - { - responseTypeStr = parameterArray[1].Trim(); - customRouteType = parameterArray[2].Trim(); - break; - } - } - } - else - { - parameter = ""; - } - - file.Append(string.IsNullOrWhiteSpace(parameter) - ? $"\tpublic partial class {className} : AProto" - : $"\tpublic partial class {className} : AProto, {parameter}"); - opcodeInfo.Name = className; - continue; - } - - if (!isMsgHead) - { - continue; - } - - switch (currentLine) - { - case "{": - { - file.AppendLine("\n\t{"); - - if (string.IsNullOrWhiteSpace(parameter)) - { - hadOpCode = false; - } - else if(parameter == "IMessage") - { - opcodeInfo.Code = _opCodeCache.GetOpcodeCache(className, ref _aMessage); - file.AppendLine($"\t\tpublic uint OpCode() {{ return {opCodeName}.{className}; }}"); - } - else - { - if (responseTypeStr != null) - { - file.AppendLine("\t\t[ProtoIgnore]"); - file.AppendLine($"\t\tpublic {responseTypeStr} ResponseType {{ get; set; }}"); - responseTypeStr = null; - } - else - { - if (parameter.Contains("RouteRequest")) - { - Exporter.LogError($"{opcodeInfo.Name} 没指定ResponseType"); - } - } - - file.AppendLine($"\t\tpublic uint OpCode() {{ return {opCodeName}.{className}; }}"); - - if (customRouteType != null) - { - file.AppendLine($"\t\tpublic long RouteTypeOpCode() {{ return (long)RouteType.{customRouteType}; }}"); - customRouteType = null; - } - else if (parameter is "IAddressableRouteRequest" or "IAddressableRouteMessage") - { - file.AppendLine($"\t\tpublic long RouteTypeOpCode() {{ return CoreRouteType.Addressable; }}"); - } - else if (parameter.EndsWith("BsonRouteMessage") || parameter.EndsWith("BsonRouteRequest")) - { - file.AppendLine($"\t\tpublic long RouteTypeOpCode() {{ return CoreRouteType.BsonRoute; }}"); - } - else if (parameter is "IRouteMessage" or "IRouteRequest") - { - file.AppendLine($"\t\tpublic long RouteTypeOpCode() {{ return CoreRouteType.Route; }}"); - } - - switch (parameter) - { - case "IRequest": - case "IBsonRequest": - { - opcodeInfo.Code = _opCodeCache.GetOpcodeCache(className, ref _aRequest); - break; - } - case "IResponse": - case "IBsonResponse": - { - opcodeInfo.Code = _opCodeCache.GetOpcodeCache(className, ref _aResponse); - file.AppendLine("\t\t[ProtoMember(91, IsRequired = true)]"); - file.AppendLine("\t\tpublic uint ErrorCode { get; set; }"); - break; - } - default: - { - if (parameter.EndsWith("RouteMessage") || parameter == "IRouteMessage") - { - opcodeInfo.Code = _opCodeCache.GetOpcodeCache(className, ref _aRouteMessage); - } - else if (parameter.EndsWith("RouteRequest") || parameter == "IRouteRequest") - { - opcodeInfo.Code = _opCodeCache.GetOpcodeCache(className, ref _aRouteRequest); - } - else if (parameter.EndsWith("RouteResponse") || parameter == "IRouteResponse") - { - opcodeInfo.Code = _opCodeCache.GetOpcodeCache(className, ref _aRouteResponse); - file.AppendLine("\t\t[ProtoMember(91, IsRequired = true)]"); - file.AppendLine("\t\tpublic uint ErrorCode { get; set; }"); - } - - break; - } - } - } - - if (hadOpCode) - { - _opcodes.Add(opcodeInfo); - } - continue; - } - case "}": - { - isMsgHead = false; - file.AppendLine("\t}"); - continue; - } - case "": - { - continue; - } - } - - if (currentLine.StartsWith("//")) - { - file.AppendFormat("\t\t///\r\n" + "\t\t/// {0}\r\n" + "\t\t///\r\n", currentLine.TrimStart('/', '/')); - continue; - } - - if (currentLine.StartsWith("repeated")) - { - Repeated(file, currentLine); - } - else - { - Members(file, currentLine); - } - } - - var csName = $"{Path.GetFileNameWithoutExtension(filePath)}.cs"; - - foreach (var (directory, template) in saveDirectory) - { - var csFile = Path.Combine(directory, csName); - var content = template.Replace("(Content)", file.ToString()); - await File.WriteAllTextAsync(csFile, content); - } - - file.Clear(); - } - #endregion - - #region GenerateOpCode - file.Clear(); - file.AppendLine("namespace TEngine"); - file.AppendLine("{"); - file.AppendLine($"\tpublic static partial class {opCodeName}"); - file.AppendLine("\t{"); - - foreach (var opcode in _opcodes) - { - file.AppendLine($"\t\t public const int {opcode.Name} = {opcode.Code};"); - } - - _opcodes.Clear(); - - file.AppendLine("\t}"); - file.AppendLine("}"); - - foreach (var (directory, _) in saveDirectory) - { - var csFile = Path.Combine(directory, $"{opCodeName}.cs"); - await File.WriteAllTextAsync(csFile, file.ToString()); - } - #endregion - } - - private async Task RouteType() - { - var routeTypeFile = $"{Define.ProtoBufDirectory}RouteType.Config"; - var protoFileText = await File.ReadAllTextAsync(routeTypeFile); - var routeTypeFileSb = new StringBuilder(); - routeTypeFileSb.AppendLine("namespace TEngine.Core.Network\n{"); - routeTypeFileSb.AppendLine("\t// Route协议定义(需要定义1000以上、因为1000以内的框架预留)\t"); - routeTypeFileSb.AppendLine("\tpublic enum RouteType : long\n\t{"); - - foreach (var line in protoFileText.Split('\n')) - { - var currentLine = line.Trim(); - - if (currentLine.StartsWith("//")) - { - continue; - } - - var splits = currentLine.Split(new[] {"//"}, StringSplitOptions.RemoveEmptyEntries); - var routeTypeStr = splits[0].Split("=", StringSplitOptions.RemoveEmptyEntries); - routeTypeFileSb.Append($"\t\t{routeTypeStr[0].Trim()} = {routeTypeStr[1].Trim()},"); - - if (splits.Length > 1) - { - routeTypeFileSb.Append($" // {splits[1].Trim()}\n"); - } - else - { - routeTypeFileSb.Append('\n'); - } - } - - routeTypeFileSb.AppendLine("\t}\n}"); - var file = routeTypeFileSb.ToString(); - await File.WriteAllTextAsync($"{Define.ProtoBufServerDirectory}RouteType.cs", file); - await File.WriteAllTextAsync($"{Define.ProtoBufClientDirectory}RouteType.cs", file); - } - - private void Repeated(StringBuilder file, string newline) - { - try - { - var index = newline.IndexOf(";", StringComparison.Ordinal); - newline = newline.Remove(index); - var property = newline.Split(Define.SplitChars, StringSplitOptions.RemoveEmptyEntries); - var type = property[1]; - var name = property[2]; - var memberIndex = int.Parse(property[4]); - type = ConvertType(type); - - file.AppendLine($"\t\t[ProtoMember({memberIndex})]"); - file.AppendLine($"\t\tpublic List<{type}> {name} = new List<{type}>();"); - } - catch (Exception e) - { - Exporter.LogError($"{newline}\n {e}"); - } - } - - private void Members(StringBuilder file, string currentLine) - { - try - { - var index = currentLine.IndexOf(";", StringComparison.Ordinal); - currentLine = currentLine.Remove(index); - var property = currentLine.Split(Define.SplitChars, StringSplitOptions.RemoveEmptyEntries); - var type = property[0]; - var name = property[1]; - var memberIndex = int.Parse(property[3]); - var typeCs = ConvertType(type); - string defaultValue = GetDefault(typeCs); - - file.AppendLine($"\t\t[ProtoMember({memberIndex})]"); - file.AppendLine($"\t\tpublic {typeCs} {name} {{ get; set; }}"); - } - catch (Exception e) - { - Exporter.LogError($"{currentLine}\n {e}"); - } - } - - private string ConvertType(string type) - { - return type switch - { - "int[]" => "int[] { }", - "int32[]" => "int[] { }", - "int64[]" => "long[] { }", - "int32" => "int", - "uint32" => "uint", - "int64" => "long", - "uint64" => "ulong", - _ => type - }; - } - - private string GetDefault(string type) - { - type = type.Trim(); - - switch (type) - { - case "byte": - case "short": - case "int": - case "long": - case "float": - case "double": - return "0"; - case "bool": - return "false"; - default: - return "null"; - } - } - - /// - /// 加载模板 - /// - private void LoadTemplate() - { - string[] lines = File.ReadAllLines(Define.ProtoBufTemplatePath, Encoding.UTF8); - - StringBuilder serverSb = new StringBuilder(); - StringBuilder clientSb = new StringBuilder(); - - int flag = 0; - foreach (string line in lines) - { - string trim = line.Trim(); - - if (trim.StartsWith("#if") && trim.Contains("SERVER")) - { - flag = 1; - continue; - } - else if(trim.StartsWith("#else")) - { - flag = 2; - continue; - } - else if(trim.StartsWith($"#endif")) - { - flag = 0; - continue; - } - - switch (flag) - { - case 1: // 服务端 - { - serverSb.AppendLine(line); - break; - } - case 2: // 客户端 - { - clientSb.AppendLine(line); - break; - } - default: // 双端 - { - serverSb.AppendLine(line); - clientSb.AppendLine(line); - break; - } - } - } - - _serverTemplate = serverSb.ToString(); - _clientTemplate = clientSb.ToString(); - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf/ProtoBufExporter.cs.meta b/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf/ProtoBufExporter.cs.meta deleted file mode 100644 index d36eb770..00000000 --- a/Assets/GameScripts/DotNet/Core/Exporter/ProtoBuf/ProtoBufExporter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2876caa2819095b4e94fa1ca697e3fba -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper.meta b/Assets/GameScripts/DotNet/Core/Helper.meta deleted file mode 100644 index c8cdf2d9..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: af4c2e7b63f02432a9d2658299efa111 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/AudioHelper.cs b/Assets/GameScripts/DotNet/Core/Helper/AudioHelper.cs deleted file mode 100644 index 31f002e2..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/AudioHelper.cs +++ /dev/null @@ -1,432 +0,0 @@ -#if TENGINE_UNITY -using System; -using System.IO; -using System.Text; -using UnityEngine; - -namespace TEngine.Core -{ - public static class AudioHelper - { - // Force save as 16-bit .wav - const int BlockSize_16Bit = 2; - - /// - /// Load PCM format *.wav audio file (using Unity's Application data path) and convert to AudioClip. - /// - /// The AudioClip. - /// Local file path to .wav file - public static AudioClip ToAudioClip(string filePath) - { - if (!filePath.StartsWith(UnityEngine.Application.persistentDataPath) && - !filePath.StartsWith(UnityEngine.Application.dataPath)) - { - Debug.LogWarning( - "This only supports files that are stored using Unity's Application data path. \nTo load bundled resources use 'Resources.Load(\"filename\") typeof(AudioClip)' method. \nhttps://docs.unity3d.com/ScriptReference/Resources.Load.html"); - return null; - } - - var fileBytes = File.ReadAllBytes(filePath); - return ToAudioClip(fileBytes, 0); - } - - public static AudioClip ToAudioClip(byte[] fileBytes, int offsetSamples = 0, string name = "wav") - { - //string riff = Encoding.ASCII.GetString (fileBytes, 0, 4); - //string wave = Encoding.ASCII.GetString (fileBytes, 8, 4); - int subchunk1 = BitConverter.ToInt32(fileBytes, 16); - UInt16 audioFormat = BitConverter.ToUInt16(fileBytes, 20); - - // NB: Only uncompressed PCM wav files are supported. - string formatCode = FormatCode(audioFormat); - Debug.AssertFormat(audioFormat == 1 || audioFormat == 65534, - "Detected format code '{0}' {1}, but only PCM and WaveFormatExtensable uncompressed formats are currently supported.", - audioFormat, formatCode); - - UInt16 channels = BitConverter.ToUInt16(fileBytes, 22); - int sampleRate = BitConverter.ToInt32(fileBytes, 24); - //int byteRate = BitConverter.ToInt32 (fileBytes, 28); - //UInt16 blockAlign = BitConverter.ToUInt16 (fileBytes, 32); - UInt16 bitDepth = BitConverter.ToUInt16(fileBytes, 34); - - int headerOffset = 16 + 4 + subchunk1 + 4; - int subchunk2 = BitConverter.ToInt32(fileBytes, headerOffset); - //Debug.LogFormat ("riff={0} wave={1} subchunk1={2} format={3} channels={4} sampleRate={5} byteRate={6} blockAlign={7} bitDepth={8} headerOffset={9} subchunk2={10} filesize={11}", riff, wave, subchunk1, formatCode, channels, sampleRate, byteRate, blockAlign, bitDepth, headerOffset, subchunk2, fileBytes.Length); - - float[] data; - switch (bitDepth) - { - case 8: - data = Convert8BitByteArrayToAudioClipData(fileBytes, headerOffset, subchunk2); - break; - case 16: - data = Convert16BitByteArrayToAudioClipData(fileBytes, headerOffset, subchunk2); - break; - case 24: - data = Convert24BitByteArrayToAudioClipData(fileBytes, headerOffset, subchunk2); - break; - case 32: - data = Convert32BitByteArrayToAudioClipData(fileBytes, headerOffset, subchunk2); - break; - default: - throw new Exception(bitDepth + " bit depth is not supported."); - } - - AudioClip audioClip = AudioClip.Create(name, data.Length, (int)channels, sampleRate, false); - audioClip.SetData(data, 0); - return audioClip; - } - - #region wav file bytes to Unity AudioClip conversion methods - - private static float[] Convert8BitByteArrayToAudioClipData(byte[] source, int headerOffset, int dataSize) - { - int wavSize = BitConverter.ToInt32(source, headerOffset); - headerOffset += sizeof(int); - Debug.AssertFormat(wavSize > 0 && wavSize == dataSize, - "Failed to get valid 8-bit wav size: {0} from data bytes: {1} at offset: {2}", wavSize, dataSize, - headerOffset); - - float[] data = new float[wavSize]; - - sbyte maxValue = sbyte.MaxValue; - - int i = 0; - while (i < wavSize) - { - data[i] = (float)source[i] / maxValue; - ++i; - } - - return data; - } - - private static float[] Convert16BitByteArrayToAudioClipData(byte[] source, int headerOffset, int dataSize) - { - int wavSize = BitConverter.ToInt32(source, headerOffset); - headerOffset += sizeof(int); - Debug.AssertFormat(wavSize > 0 && wavSize == dataSize, - "Failed to get valid 16-bit wav size: {0} from data bytes: {1} at offset: {2}", wavSize, dataSize, - headerOffset); - - int x = sizeof(Int16); // block size = 2 - int convertedSize = wavSize / x; - - float[] data = new float[convertedSize]; - - Int16 maxValue = Int16.MaxValue; - - int offset = 0; - int i = 0; - while (i < convertedSize) - { - offset = i * x + headerOffset; - data[i] = (float)BitConverter.ToInt16(source, offset) / maxValue; - ++i; - } - - Debug.AssertFormat(data.Length == convertedSize, "AudioClip .wav data is wrong size: {0} == {1}", - data.Length, convertedSize); - - return data; - } - - private static float[] Convert24BitByteArrayToAudioClipData(byte[] source, int headerOffset, int dataSize) - { - int wavSize = BitConverter.ToInt32(source, headerOffset); - headerOffset += sizeof(int); - Debug.AssertFormat(wavSize > 0 && wavSize == dataSize, - "Failed to get valid 24-bit wav size: {0} from data bytes: {1} at offset: {2}", wavSize, dataSize, - headerOffset); - - int x = 3; // block size = 3 - int convertedSize = wavSize / x; - - int maxValue = Int32.MaxValue; - - float[] data = new float[convertedSize]; - - byte[] - block = new byte[sizeof(int)]; // using a 4 byte block for copying 3 bytes, then copy bytes with 1 offset - - int offset = 0; - int i = 0; - while (i < convertedSize) - { - offset = i * x + headerOffset; - Buffer.BlockCopy(source, offset, block, 1, x); - data[i] = (float)BitConverter.ToInt32(block, 0) / maxValue; - ++i; - } - - Debug.AssertFormat(data.Length == convertedSize, "AudioClip .wav data is wrong size: {0} == {1}", - data.Length, convertedSize); - - return data; - } - - private static float[] Convert32BitByteArrayToAudioClipData(byte[] source, int headerOffset, int dataSize) - { - int wavSize = BitConverter.ToInt32(source, headerOffset); - headerOffset += sizeof(int); - Debug.AssertFormat(wavSize > 0 && wavSize == dataSize, - "Failed to get valid 32-bit wav size: {0} from data bytes: {1} at offset: {2}", wavSize, dataSize, - headerOffset); - - int x = sizeof(float); // block size = 4 - int convertedSize = wavSize / x; - - Int32 maxValue = Int32.MaxValue; - - float[] data = new float[convertedSize]; - - int offset = 0; - int i = 0; - while (i < convertedSize) - { - offset = i * x + headerOffset; - data[i] = (float)BitConverter.ToInt32(source, offset) / maxValue; - ++i; - } - - Debug.AssertFormat(data.Length == convertedSize, "AudioClip .wav data is wrong size: {0} == {1}", - data.Length, convertedSize); - - return data; - } - - #endregion - - public static byte[] FromAudioClip(AudioClip audioClip) - { - string file; - return FromAudioClip(audioClip, out file, false); - } - - public static byte[] FromAudioClip(AudioClip audioClip, out string filepath, bool saveAsFile = true, - string dirname = "recordings") - { - MemoryStream stream = new MemoryStream(); - - const int headerSize = 44; - - // get bit depth - UInt16 bitDepth = 16; //BitDepth (audioClip); - - // NB: Only supports 16 bit - //Debug.AssertFormat (bitDepth == 16, "Only converting 16 bit is currently supported. The audio clip data is {0} bit.", bitDepth); - - // total file size = 44 bytes for header format and audioClip.samples * factor due to float to Int16 / sbyte conversion - int fileSize = audioClip.samples * BlockSize_16Bit + headerSize; // BlockSize (bitDepth) - - // chunk descriptor (riff) - WriteFileHeader(ref stream, fileSize); - // file header (fmt) - WriteFileFormat(ref stream, audioClip.channels, audioClip.frequency, bitDepth); - // data chunks (data) - WriteFileData(ref stream, audioClip, bitDepth); - - byte[] bytes = stream.ToArray(); - - // Validate total bytes - Debug.AssertFormat(bytes.Length == fileSize, "Unexpected AudioClip to wav format byte count: {0} == {1}", - bytes.Length, fileSize); - - // Save file to persistant storage location - if (saveAsFile) - { - filepath = string.Format("{0}/{1}/{2}.{3}", UnityEngine.Application.persistentDataPath, dirname, - DateTime.UtcNow.ToString("yyMMdd-HHmmss-fff"), "wav"); - Directory.CreateDirectory(Path.GetDirectoryName(filepath)); - File.WriteAllBytes(filepath, bytes); - //Debug.Log ("Auto-saved .wav file: " + filepath); - } - else - { - filepath = null; - } - - stream.Dispose(); - - return bytes; - } - - #region write .wav file functions - - private static int WriteFileHeader(ref MemoryStream stream, int fileSize) - { - int count = 0; - int total = 12; - - // riff chunk id - byte[] riff = Encoding.ASCII.GetBytes("RIFF"); - count += WriteBytesToMemoryStream(ref stream, riff, "ID"); - - // riff chunk size - int chunkSize = fileSize - 8; // total size - 8 for the other two fields in the header - count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(chunkSize), "CHUNK_SIZE"); - - byte[] wave = Encoding.ASCII.GetBytes("WAVE"); - count += WriteBytesToMemoryStream(ref stream, wave, "FORMAT"); - - // Validate header - Debug.AssertFormat(count == total, "Unexpected wav descriptor byte count: {0} == {1}", count, total); - - return count; - } - - private static int WriteFileFormat(ref MemoryStream stream, int channels, int sampleRate, UInt16 bitDepth) - { - int count = 0; - int total = 24; - - byte[] id = Encoding.ASCII.GetBytes("fmt "); - count += WriteBytesToMemoryStream(ref stream, id, "FMT_ID"); - - int subchunk1Size = 16; // 24 - 8 - count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(subchunk1Size), "SUBCHUNK_SIZE"); - - UInt16 audioFormat = 1; - count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(audioFormat), "AUDIO_FORMAT"); - - UInt16 numChannels = Convert.ToUInt16(channels); - count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(numChannels), "CHANNELS"); - - count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(sampleRate), "SAMPLE_RATE"); - - int byteRate = sampleRate * channels * BytesPerSample(bitDepth); - count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(byteRate), "BYTE_RATE"); - - UInt16 blockAlign = Convert.ToUInt16(channels * BytesPerSample(bitDepth)); - count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(blockAlign), "BLOCK_ALIGN"); - - count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(bitDepth), "BITS_PER_SAMPLE"); - - // Validate format - Debug.AssertFormat(count == total, "Unexpected wav fmt byte count: {0} == {1}", count, total); - - return count; - } - - private static int WriteFileData(ref MemoryStream stream, AudioClip audioClip, UInt16 bitDepth) - { - int count = 0; - int total = 8; - - // Copy float[] data from AudioClip - float[] data = new float[audioClip.samples * audioClip.channels]; - audioClip.GetData(data, 0); - - byte[] bytes = ConvertAudioClipDataToInt16ByteArray(data); - - byte[] id = Encoding.ASCII.GetBytes("data"); - count += WriteBytesToMemoryStream(ref stream, id, "DATA_ID"); - - int subchunk2Size = Convert.ToInt32(audioClip.samples * BlockSize_16Bit); // BlockSize (bitDepth) - count += WriteBytesToMemoryStream(ref stream, BitConverter.GetBytes(subchunk2Size), "SAMPLES"); - - // Validate header - Debug.AssertFormat(count == total, "Unexpected wav data id byte count: {0} == {1}", count, total); - - // Write bytes to stream - count += WriteBytesToMemoryStream(ref stream, bytes, "DATA"); - - // Validate audio data - Debug.AssertFormat(bytes.Length == subchunk2Size, "Unexpected AudioClip to wav subchunk2 size: {0} == {1}", - bytes.Length, subchunk2Size); - - return count; - } - - private static byte[] ConvertAudioClipDataToInt16ByteArray(float[] data) - { - MemoryStream dataStream = new MemoryStream(); - - int x = sizeof(Int16); - - Int16 maxValue = Int16.MaxValue; - - int i = 0; - while (i < data.Length) - { - dataStream.Write(BitConverter.GetBytes(Convert.ToInt16(data[i] * maxValue)), 0, x); - ++i; - } - - byte[] bytes = dataStream.ToArray(); - - // Validate converted bytes - Debug.AssertFormat(data.Length * x == bytes.Length, - "Unexpected float[] to Int16 to byte[] size: {0} == {1}", data.Length * x, bytes.Length); - - dataStream.Dispose(); - - return bytes; - } - - private static int WriteBytesToMemoryStream(ref MemoryStream stream, byte[] bytes, string tag = "") - { - int count = bytes.Length; - stream.Write(bytes, 0, count); - //Debug.LogFormat ("WAV:{0} wrote {1} bytes.", tag, count); - return count; - } - - #endregion - - /// - /// Calculates the bit depth of an AudioClip - /// - /// The bit depth. Should be 8 or 16 or 32 bit. - /// Audio clip. - public static UInt16 BitDepth(AudioClip audioClip) - { - UInt16 bitDepth = - Convert.ToUInt16(audioClip.samples * audioClip.channels * audioClip.length / audioClip.frequency); - Debug.AssertFormat(bitDepth == 8 || bitDepth == 16 || bitDepth == 32, - "Unexpected AudioClip bit depth: {0}. Expected 8 or 16 or 32 bit.", bitDepth); - return bitDepth; - } - - private static int BytesPerSample(UInt16 bitDepth) - { - return bitDepth / 8; - } - - private static int BlockSize(UInt16 bitDepth) - { - switch (bitDepth) - { - case 32: - return sizeof(Int32); // 32-bit -> 4 bytes (Int32) - case 16: - return sizeof(Int16); // 16-bit -> 2 bytes (Int16) - case 8: - return sizeof(sbyte); // 8-bit -> 1 byte (sbyte) - default: - throw new Exception(bitDepth + " bit depth is not supported."); - } - } - - private static string FormatCode(UInt16 code) - { - switch (code) - { - case 1: - return "PCM"; - case 2: - return "ADPCM"; - case 3: - return "IEEE"; - case 7: - return "μ-law"; - case 65534: - return "WaveFormatExtensable"; - default: - Debug.LogWarning("Unknown wav code format:" + code); - return ""; - } - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/AudioHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/AudioHelper.cs.meta deleted file mode 100644 index 96c9c2ec..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/AudioHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 84a1c6c8542d1814da8b5fba76c64e74 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/ByteHelper.cs b/Assets/GameScripts/DotNet/Core/Helper/ByteHelper.cs deleted file mode 100644 index 86bf7231..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/ByteHelper.cs +++ /dev/null @@ -1,179 +0,0 @@ -using System; -using System.IO; -using System.Text; - -namespace TEngine.Core -{ - public static class ByteHelper - { - private static readonly string[] Suffix = { "Byte", "KB", "MB", "GB", "TB" }; - - public static long ReadInt64(FileStream stream) - { - var buffer = new byte[8]; - stream.Read(buffer, 0, 8); - return BitConverter.ToInt64(buffer, 0); - } - - public static int ReadInt32(FileStream stream) - { - var buffer = new byte[4]; - stream.Read(buffer, 0, 4); - return BitConverter.ToInt32(buffer, 0); - } - - public static long ReadInt64(MemoryStream stream) - { - var buffer = new byte[8]; - stream.Read(buffer, 0, 8); - return BitConverter.ToInt64(buffer, 0); - } - - public static int ReadInt32(MemoryStream stream) - { - var buffer = new byte[4]; - stream.Read(buffer, 0, 4); - return BitConverter.ToInt32(buffer, 0); - } - - public static string ToHex(this byte b) - { - return b.ToString("X2"); - } - - public static string ToHex(this byte[] bytes) - { - var stringBuilder = new StringBuilder(); - foreach (var b in bytes) - { - stringBuilder.Append(b.ToString("X2")); - } - - return stringBuilder.ToString(); - } - - public static string ToHex(this byte[] bytes, string format) - { - var stringBuilder = new StringBuilder(); - foreach (var b in bytes) - { - stringBuilder.Append(b.ToString(format)); - } - - return stringBuilder.ToString(); - } - - public static string ToHex(this byte[] bytes, int offset, int count) - { - var stringBuilder = new StringBuilder(); - for (var i = offset; i < offset + count; ++i) - { - stringBuilder.Append(bytes[i].ToString("X2")); - } - - return stringBuilder.ToString(); - } - - public static string ToStr(this byte[] bytes) - { - return Encoding.Default.GetString(bytes); - } - - public static string ToStr(this byte[] bytes, int index, int count) - { - return Encoding.Default.GetString(bytes, index, count); - } - - public static string Utf8ToStr(this byte[] bytes) - { - return Encoding.UTF8.GetString(bytes); - } - - public static string Utf8ToStr(this byte[] bytes, int index, int count) - { - return Encoding.UTF8.GetString(bytes, index, count); - } - - public static void WriteTo(this byte[] bytes, int offset, uint num) - { - bytes[offset] = (byte)(num & 0xff); - bytes[offset + 1] = (byte)((num & 0xff00) >> 8); - bytes[offset + 2] = (byte)((num & 0xff0000) >> 16); - bytes[offset + 3] = (byte)((num & 0xff000000) >> 24); - } - - public static void WriteTo(this byte[] bytes, int offset, int num) - { - bytes[offset] = (byte)(num & 0xff); - bytes[offset + 1] = (byte)((num & 0xff00) >> 8); - bytes[offset + 2] = (byte)((num & 0xff0000) >> 16); - bytes[offset + 3] = (byte)((num & 0xff000000) >> 24); - } - - public static void WriteTo(this byte[] bytes, int offset, byte num) - { - bytes[offset] = num; - } - - public static void WriteTo(this byte[] bytes, int offset, short num) - { - bytes[offset] = (byte)(num & 0xff); - bytes[offset + 1] = (byte)((num & 0xff00) >> 8); - } - - public static void WriteTo(this byte[] bytes, int offset, ushort num) - { - bytes[offset] = (byte)(num & 0xff); - bytes[offset + 1] = (byte)((num & 0xff00) >> 8); - } - - public static string ToReadableSpeed(this long byteCount) - { - var i = 0; - double dblSByte = byteCount; - if (byteCount <= 1024) - { - return $"{dblSByte:0.##}{Suffix[i]}"; - } - - for (i = 0; byteCount / 1024 > 0; i++, byteCount /= 1024) - { - dblSByte = byteCount / 1024.0; - } - - return $"{dblSByte:0.##}{Suffix[i]}"; - } - - public static string ToReadableSpeed(this ulong byteCount) - { - var i = 0; - double dblSByte = byteCount; - - if (byteCount <= 1024) - { - return $"{dblSByte:0.##}{Suffix[i]}"; - } - - for (i = 0; byteCount / 1024 > 0; i++, byteCount /= 1024) - { - dblSByte = byteCount / 1024.0; - } - - return $"{dblSByte:0.##}{Suffix[i]}"; - } - - /// - /// 合并一个数组 - /// - /// - /// - /// - public static byte[] MergeBytes(byte[] bytes, byte[] otherBytes) - { - var result = new byte[bytes.Length + otherBytes.Length]; - bytes.CopyTo(result, 0); - otherBytes.CopyTo(result, bytes.Length); - return result; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/ByteHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/ByteHelper.cs.meta deleted file mode 100644 index 3df7e77f..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/ByteHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 33f44962744fcd64d98b9bcd0fc41bf9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/CryptHelper.cs b/Assets/GameScripts/DotNet/Core/Helper/CryptHelper.cs deleted file mode 100644 index 9f634e90..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/CryptHelper.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.IO; -using System.Security.Cryptography; -using System.Text; - -namespace TEngine.Core -{ - public static class CryptHelper - { - // 对应的字符串SYUwQN360OPY1gaL - // 在这个网站随机生成的 http://tool.c7sky.com/password/ - private static readonly byte[] Key = - { - 0x53, 0x59, 0x55, 0x77, 0x51, 0x4e, 0x33, 0x36, - 0x30, 0x4f, 0x50, 0x59, 0x31, 0x67, 0x61, 0x4c - }; - - /// - /// 创建一个新的KEY - /// - /// 一个长度为16的字符串、如果超过只会截取前16位 - /// 返回的是一个十六进制的字符串、每个用,分割的、每个都是一个byte - public static string CreateKey(string keyStr) - { - if (keyStr.Length > 16) - { - keyStr = keyStr.Substring(0, 15); - } - - var bytes = Encoding.UTF8.GetBytes(keyStr); - return $"0x{BitConverter.ToString(bytes, 0).Replace("-", ", 0x").ToLower()}"; - } - - /// - /// AES 加密 - /// - /// - /// - public static byte[] AesEncrypt(byte[] toEncryptArray) - { - var rm = Aes.Create(); - rm.Key = Key; - rm.Mode = CipherMode.ECB; - rm.Padding = PaddingMode.PKCS7; - var cTransform = rm.CreateEncryptor(); - return cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); - } - - /// - /// AES 解密 - /// - /// - /// - public static MemoryStream AesDecryptReturnStream(byte[] toEncryptArray) - { - var bytes = AesDecrypt(toEncryptArray); - - return new MemoryStream(bytes); - } - - /// - /// AES 解密 - /// - /// - /// - public static byte[] AesDecrypt(byte[] toEncryptArray) - { - var rm = Aes.Create(); - rm.Key = Key; - rm.Mode = CipherMode.ECB; - rm.Padding = PaddingMode.PKCS7; - - var cTransform = rm.CreateDecryptor(); - return cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/CryptHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/CryptHelper.cs.meta deleted file mode 100644 index 33b3f96e..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/CryptHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 060c741ce3ae4d54498be5f7a286801b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/EnumHelper.cs b/Assets/GameScripts/DotNet/Core/Helper/EnumHelper.cs deleted file mode 100644 index c81bc51d..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/EnumHelper.cs +++ /dev/null @@ -1,39 +0,0 @@ -using System; - -namespace TEngine -{ - public static class EnumHelper - { - public static int EnumIndex(int value) - { - int i = 0; - foreach (object v in Enum.GetValues(typeof (T))) - { - if ((int) v == value) - { - return i; - } - ++i; - } - return -1; - } - - public static T FromString(string str) - { - if (!Enum.IsDefined(typeof(T), str)) - { - return default(T); - } - return (T)Enum.Parse(typeof(T), str); - } - - public static T Parse(this string str) - { - if (!Enum.IsDefined(typeof(T), str)) - { - return default(T); - } - return (T)Enum.Parse(typeof(T), str); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/EnumHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/EnumHelper.cs.meta deleted file mode 100644 index 1daa6980..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/EnumHelper.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 2638994be90d44a583fe978f8b92664d -timeCreated: 1689578753 \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/ExcelHelper.cs b/Assets/GameScripts/DotNet/Core/Helper/ExcelHelper.cs deleted file mode 100644 index 88e103db..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/ExcelHelper.cs +++ /dev/null @@ -1,34 +0,0 @@ -#if TENGINE_NET -using OfficeOpenXml; - -namespace TEngine.Helper; - -public static class ExcelHelper -{ - public static ExcelPackage LoadExcel(string name) - { - return new ExcelPackage(name); - } - - public static string GetCellValue(this ExcelWorksheet sheet, int row, int column) - { - ExcelRange cell = sheet.Cells[row, column]; - - try - { - if (cell.Value == null) - { - return ""; - } - - string s = cell.GetValue(); - - return s.Trim(); - } - catch (Exception e) - { - throw new Exception($"Rows {row} Columns {column} Content {cell.Text} {e}"); - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/ExcelHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/ExcelHelper.cs.meta deleted file mode 100644 index f5b66430..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/ExcelHelper.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 2ea3356f30cb40949949691a0e258a05 -timeCreated: 1690561972 \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/FileHelper.cs b/Assets/GameScripts/DotNet/Core/Helper/FileHelper.cs deleted file mode 100644 index fc34225b..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/FileHelper.cs +++ /dev/null @@ -1,137 +0,0 @@ -using System.Collections.Generic; -using System.IO; - -namespace TEngine -{ - /// - /// 文件操作助手类,提供了各种文件操作方法。 - /// - public static class FileHelper - { - /// - /// 获取相对路径的完整路径。 - /// - /// 相对路径。 - /// 完整路径。 - public static string GetFullPath(string relativePath) - { - return Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), relativePath)); - } - - /// - /// 将文件复制到目标路径,如果目标目录不存在会自动创建目录。 - /// - /// 源文件路径。 - /// 目标文件路径。 - /// 是否覆盖已存在的目标文件。 - public static void Copy(string sourceFile, string destinationFile, bool overwrite) - { - var directoriesByFilePath = GetDirectoriesByFilePath(destinationFile); - - foreach (var dir in directoriesByFilePath) - { - if (Directory.Exists(dir)) - { - continue; - } - - Directory.CreateDirectory(dir); - } - - File.Copy(sourceFile, destinationFile, overwrite); - } - - /// - /// 获取文件路径内的所有文件夹路径。 - /// - /// 文件路径。 - /// 文件夹路径列表。 - public static List GetDirectoriesByFilePath(string filePath) - { - var dir = ""; - var directories = new List(); - var fileDirectories = filePath.Split('/'); - - for (var i = 0; i < fileDirectories.Length - 1; i++) - { - dir = $"{dir}{fileDirectories[i]}/"; - directories.Add(dir); - } - - return directories; - } - - /// - /// 将文件夹内的所有内容复制到目标位置。 - /// - /// 源文件夹路径。 - /// 目标文件夹路径。 - /// 是否覆盖已存在的文件。 - public static void CopyDirectory(string sourceDirectory, string destinationDirectory, bool overwrite) - { - // 创建目标文件夹 - - if (!Directory.Exists(destinationDirectory)) - { - Directory.CreateDirectory(destinationDirectory); - } - - // 获取当前文件夹中的所有文件 - - var files = Directory.GetFiles(sourceDirectory); - - // 拷贝文件到目标文件夹 - - foreach (var file in files) - { - var fileName = Path.GetFileName(file); - var destinationPath = Path.Combine(destinationDirectory, fileName); - File.Copy(file, destinationPath, overwrite); - } - - // 获取源文件夹中的所有子文件夹 - - var directories = Directory.GetDirectories(sourceDirectory); - - // 递归方式拷贝文件夹 - - foreach (var directory in directories) - { - var directoryName = Path.GetFileName(directory); - var destinationPath = Path.Combine(destinationDirectory, directoryName); - CopyDirectory(directory, destinationPath, overwrite); - } - } - - /// - /// 获取目录下的所有文件 - /// - /// 文件夹路径。 - /// 需要查找的文件通配符 - /// 查找的类型 - /// - public static string[] GetDirectoryFile(string folderPath, string searchPattern, SearchOption searchOption) - { - return Directory.GetFiles(folderPath, searchPattern, searchOption); - } - - /// - /// 清空文件夹内的所有文件。 - /// - /// 文件夹路径。 - public static void ClearDirectoryFile(string folderPath) - { - if (!Directory.Exists(folderPath)) - { - return; - } - - var files = Directory.GetFiles(folderPath); - - foreach (var file in files) - { - File.Delete(file); - } - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/FileHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/FileHelper.cs.meta deleted file mode 100644 index 3733eb75..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/FileHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 74cc512af7309484fa066b16175c6331 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/JsonHelper.cs b/Assets/GameScripts/DotNet/Core/Helper/JsonHelper.cs deleted file mode 100644 index 5fce1f1b..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/JsonHelper.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using Newtonsoft.Json; -#pragma warning disable CS8603 - -namespace TEngine.Core -{ - public static class JsonHelper - { - public static string ToJson(this T t) - { - return JsonConvert.SerializeObject(t); - } - - public static object Deserialize(this string json, Type type, bool reflection = true) - { - return JsonConvert.DeserializeObject(json, type); - } - - public static T Deserialize(this string json) - { - return JsonConvert.DeserializeObject(json); - } - - public static T Clone(T t) - { - return t.ToJson().Deserialize(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/JsonHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/JsonHelper.cs.meta deleted file mode 100644 index 4a742e48..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/JsonHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 44fd4e119f9d29342a2e312d58f6a1fd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/MD5Helper.cs b/Assets/GameScripts/DotNet/Core/Helper/MD5Helper.cs deleted file mode 100644 index 29058f25..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/MD5Helper.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.IO; -using System.Security.Cryptography; - -namespace TEngine.Core -{ - public static class MD5Helper - { - public static string FileMD5(string filePath) - { - using var file = new FileStream(filePath, FileMode.Open); - return FileMD5(file); - } - - public static string FileMD5(FileStream fileStream) - { - var md5 = MD5.Create(); - return md5.ComputeHash(fileStream).ToHex("x2"); - } - - public static string BytesMD5(byte[] bytes) - { - var md5 = MD5.Create(); - bytes = md5.ComputeHash(bytes); - return bytes.ToHex("x2"); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/MD5Helper.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/MD5Helper.cs.meta deleted file mode 100644 index f6f0b9c2..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/MD5Helper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9c37f13dde60869459e624143ae45a3c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/MemoryStreamHelper.cs b/Assets/GameScripts/DotNet/Core/Helper/MemoryStreamHelper.cs deleted file mode 100644 index 015be7c7..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/MemoryStreamHelper.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.IO; -using TEngine.IO; - -namespace TEngine.Core -{ - public static class MemoryStreamHelper - { - private static readonly RecyclableMemoryStreamManager Manager = new RecyclableMemoryStreamManager(); - - public static MemoryStream GetRecyclableMemoryStream() - { - return Manager.GetStream(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/MemoryStreamHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/MemoryStreamHelper.cs.meta deleted file mode 100644 index 2f613e70..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/MemoryStreamHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 90f0f0ce0808b61458dbb17cdc1f3766 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/Mongo.meta b/Assets/GameScripts/DotNet/Core/Helper/Mongo.meta deleted file mode 100644 index ee3b3348..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/Mongo.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 90685e6f420bcae4f851975873f430c9 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/Mongo/MongoHelper.cs b/Assets/GameScripts/DotNet/Core/Helper/Mongo/MongoHelper.cs deleted file mode 100644 index 9925a21d..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/Mongo/MongoHelper.cs +++ /dev/null @@ -1,205 +0,0 @@ -#if TENGINE_NET -using System.ComponentModel; -using MongoDB.Bson; -using MongoDB.Bson.IO; -using MongoDB.Bson.Serialization; -using MongoDB.Bson.Serialization.Conventions; -using Unity.Mathematics; -using MongoHelper = TEngine.Core.MongoHelper; - -namespace TEngine.Core; - -public sealed class MongoHelper : Singleton -{ - private readonly HashSet _registerCount = new HashSet(3); - - static MongoHelper() - { - // 自动注册IgnoreExtraElements - var conventionPack = new ConventionPack {new IgnoreExtraElementsConvention(true)}; - ConventionRegistry.Register("IgnoreExtraElements", conventionPack, type => true); - RegisterStruct(); - RegisterStruct(); - RegisterStruct(); - RegisterStruct(); - } - - public static void RegisterStruct() where T : struct - { - BsonSerializer.RegisterSerializer(typeof (T), new StructBsonSerialize()); - } - - protected override void OnLoad(int assemblyName) - { - if (_registerCount.Count == 3) - { - return; - } - - _registerCount.Add(assemblyName); - - Task.Run(() => - { - foreach (var type in AssemblyManager.ForEach(assemblyName)) - { - if (type.IsInterface || type.IsAbstract || !typeof(Entity).IsAssignableFrom(type)) - { - continue; - } - - BsonClassMap.LookupClassMap(type); - } - }); - } - - private static readonly JsonWriterSettings defaultSettings = new() { OutputMode = JsonOutputMode.RelaxedExtendedJson }; - - public static string ToJson(object obj) - { - if (obj is ISupportInitialize supportInitialize) - { - supportInitialize.BeginInit(); - } - return obj.ToJson(defaultSettings); - } - - public static string ToJson(object obj, JsonWriterSettings settings) - { - if (obj is ISupportInitialize supportInitialize) - { - supportInitialize.BeginInit(); - } - return obj.ToJson(settings); - } - - public static T FromJson(string str) - { - try - { - return BsonSerializer.Deserialize(str); - } - catch (Exception e) - { - throw new Exception($"{str}\n{e}"); - } - } - - public static object FromJson(Type type, string str) - { - return BsonSerializer.Deserialize(str, type); - } - - public object Deserialize(Span span, Type type) - { - using var stream = MemoryStreamHelper.GetRecyclableMemoryStream(); - stream.Write(span); - stream.Seek(0, SeekOrigin.Begin); - return BsonSerializer.Deserialize(stream, type); - } - - public object Deserialize(Memory memory, Type type) - { - using var stream = MemoryStreamHelper.GetRecyclableMemoryStream(); - stream.Write(memory.Span); - stream.Seek(0, SeekOrigin.Begin); - return BsonSerializer.Deserialize(stream, type); - } - - public object Deserialize(Span span) - { - using var stream = MemoryStreamHelper.GetRecyclableMemoryStream(); - stream.Write(span); - stream.Seek(0, SeekOrigin.Begin); - return BsonSerializer.Deserialize(stream); - } - - public object Deserialize(Memory memory) - { - using var stream = MemoryStreamHelper.GetRecyclableMemoryStream(); - stream.Seek(0, SeekOrigin.Begin); - return BsonSerializer.Deserialize(stream); - } - - - public T Deserialize(byte[] bytes) - { - return BsonSerializer.Deserialize(bytes); - } - - public void SerializeTo(T t, Memory memory) - { - using var memoryStream = new MemoryStream(); - using (var writer = new BsonBinaryWriter(memoryStream, BsonBinaryWriterSettings.Defaults)) - { - BsonSerializer.Serialize(writer, typeof(T), t); - } - - memoryStream.GetBuffer().AsMemory().CopyTo(memory); - } - - public object Deserialize(byte[] bytes, Type type) - { - return BsonSerializer.Deserialize(bytes, type); - } - - public object Deserialize(byte[] bytes, string type) - { - return BsonSerializer.Deserialize(bytes, Type.GetType(type)); - } - - public T Deserialize(Stream stream) - { - return BsonSerializer.Deserialize(stream); - } - - public object Deserialize(Stream stream, Type type) - { - return BsonSerializer.Deserialize(stream, type); - } - - public object DeserializeFrom(Type type, MemoryStream stream) - { - return Deserialize(stream, type); - } - - public T DeserializeFrom(MemoryStream stream) - { - return Deserialize(stream); - } - - public T DeserializeFrom(byte[] bytes, int index, int count) - { - return BsonSerializer.Deserialize(bytes.AsMemory(index, count).ToArray()); - } - - public byte[] SerializeTo(T t) - { - return t.ToBson(); - } - - public void SerializeTo(T t, MemoryStream stream) - { - using var writer = new BsonBinaryWriter(stream, BsonBinaryWriterSettings.Defaults); - BsonSerializer.Serialize(writer, typeof(T), t); - } - - public T Clone(T t) - { - return Deserialize(t.ToBson()); - } -} -#endif -#if TENGINE_UNITY -using System; -using System.IO; -namespace TEngine.Core -{ - public sealed class MongoHelper : Singleton - { - public object DeserializeFrom(Type type, MemoryStream stream) - { - return null; - } - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Helper/Mongo/MongoHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/Mongo/MongoHelper.cs.meta deleted file mode 100644 index b6662b10..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/Mongo/MongoHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8305336cdf88b72498d9c3365424ed49 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/Mongo/StructBsonSerialize.cs b/Assets/GameScripts/DotNet/Core/Helper/Mongo/StructBsonSerialize.cs deleted file mode 100644 index f1db420f..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/Mongo/StructBsonSerialize.cs +++ /dev/null @@ -1,57 +0,0 @@ -#if TENGINE_NET -using System.Reflection; -using MongoDB.Bson; -using MongoDB.Bson.IO; -using MongoDB.Bson.Serialization; -using MongoDB.Bson.Serialization.Serializers; - -namespace TEngine.Core; - -public class StructBsonSerialize : StructSerializerBase where TValue : struct -{ - public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, TValue value) - { - var nominalType = args.NominalType; - - var bsonWriter = context.Writer; - - bsonWriter.WriteStartDocument(); - - var fields = nominalType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - foreach (var field in fields) - { - bsonWriter.WriteName(field.Name); - BsonSerializer.Serialize(bsonWriter, field.FieldType, field.GetValue(value)); - } - - bsonWriter.WriteEndDocument(); - } - - public override TValue Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args) - { - //boxing is required for SetValue to work - object obj = new TValue(); - var actualType = args.NominalType; - var bsonReader = context.Reader; - - bsonReader.ReadStartDocument(); - - while (bsonReader.ReadBsonType() != BsonType.EndOfDocument) - { - var name = bsonReader.ReadName(Utf8NameDecoder.Instance); - - var field = actualType.GetField(name, - BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - if (field != null) - { - var value = BsonSerializer.Deserialize(bsonReader, field.FieldType); - field.SetValue(obj, value); - } - } - - bsonReader.ReadEndDocument(); - - return (TValue) obj; - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Helper/Mongo/StructBsonSerialize.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/Mongo/StructBsonSerialize.cs.meta deleted file mode 100644 index 3939bf4e..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/Mongo/StructBsonSerialize.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8ac9e1e3f21a01f40a9bda7f7cc4e667 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/Proto.meta b/Assets/GameScripts/DotNet/Core/Helper/Proto.meta deleted file mode 100644 index 18ae8854..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/Proto.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9557f6157233b304fb1f1669311f5fc9 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/Proto/AProto.cs b/Assets/GameScripts/DotNet/Core/Helper/Proto/AProto.cs deleted file mode 100644 index 0940414d..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/Proto/AProto.cs +++ /dev/null @@ -1,11 +0,0 @@ -using ProtoBuf; - -namespace TEngine -{ - [ProtoContract] - public abstract class AProto - { - public virtual void AfterDeserialization() => EndInit(); - protected virtual void EndInit() { } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/Proto/AProto.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/Proto/AProto.cs.meta deleted file mode 100644 index 9e9fc670..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/Proto/AProto.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3172691aec101574282e3e66d998d4dd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/Proto/ProtoBufHelper.cs b/Assets/GameScripts/DotNet/Core/Helper/Proto/ProtoBufHelper.cs deleted file mode 100644 index 63c0f129..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/Proto/ProtoBufHelper.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Buffers; -using System.IO; -using System.Reflection; -using ProtoBuf; -using ProtoBuf.Meta; - -namespace TEngine.Core -{ - public static class ProtoBufHelper - { - public static object FromSpan(Type type, Span span) - { -#if TENGINE_UNITY - using var recyclableMemoryStream = MemoryStreamHelper.GetRecyclableMemoryStream(); - recyclableMemoryStream.Write(span); - recyclableMemoryStream.Seek(0, SeekOrigin.Begin); - return Serializer.Deserialize(type, recyclableMemoryStream); -#else - return RuntimeTypeModel.Default.Deserialize(type, span); -#endif - } - - public static object FromMemory(Type type, Memory memory) - { -#if TENGINE_UNITY - using var recyclableMemoryStream = MemoryStreamHelper.GetRecyclableMemoryStream(); - recyclableMemoryStream.Write(memory.Span); - recyclableMemoryStream.Seek(0, SeekOrigin.Begin); - return Serializer.Deserialize(type, recyclableMemoryStream); -#else - return RuntimeTypeModel.Default.Deserialize(type, memory); -#endif - } - - public static object FromBytes(Type type, byte[] bytes, int index, int count) - { -#if TENGINE_UNITY - using var stream = MemoryStreamHelper.GetRecyclableMemoryStream(); - stream.Write(bytes, index, count); - stream.Seek(0, SeekOrigin.Begin); - return Serializer.Deserialize(type, stream); -#else - var memory = new Memory(bytes, index, count); - return RuntimeTypeModel.Default.Deserialize(type, memory); -#endif - } - - public static T FromBytes(byte[] bytes) - { -#if TENGINE_UNITY - using var stream = MemoryStreamHelper.GetRecyclableMemoryStream(); - stream.Write(bytes, 0, bytes.Length); - stream.Seek(0, SeekOrigin.Begin); - return Serializer.Deserialize(stream); -#else - return Serializer.Deserialize(new Span(bytes)); -#endif - } - - public static T FromBytes(byte[] bytes, int index, int count) - { -#if TENGINE_UNITY - using var stream = MemoryStreamHelper.GetRecyclableMemoryStream(); - stream.Write(bytes, 0, bytes.Length); - stream.Seek(0, SeekOrigin.Begin); - return Serializer.Deserialize(stream); -#else - return Serializer.Deserialize(new Span(bytes, index, count)); -#endif - } - - public static byte[] ToBytes(object message) - { - using var stream = MemoryStreamHelper.GetRecyclableMemoryStream(); - Serializer.Serialize(stream, message); - return stream.ToArray(); - } - - public static void ToMemory(object message, Memory memory) - { - using var stream = MemoryStreamHelper.GetRecyclableMemoryStream(); - Serializer.Serialize(stream, message); - stream.GetBuffer().AsMemory().CopyTo(memory); - } - - public static void ToStream(object message, MemoryStream stream) - { - Serializer.Serialize(stream, message); - } - - public static object FromStream(Type type, MemoryStream stream) - { - return Serializer.Deserialize(type, stream); - } - - public static T FromStream(MemoryStream stream) - { - return (T) Serializer.Deserialize(typeof(T), stream); - } - - public static T Clone(T t) - { - using var stream = MemoryStreamHelper.GetRecyclableMemoryStream(); - Serializer.Serialize(stream, t); - return Serializer.Deserialize(stream); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/Proto/ProtoBufHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/Proto/ProtoBufHelper.cs.meta deleted file mode 100644 index 0287ecfc..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/Proto/ProtoBufHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 27e0977e977a7834695b073736221239 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/RandomHelper.cs b/Assets/GameScripts/DotNet/Core/Helper/RandomHelper.cs deleted file mode 100644 index 16f73e73..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/RandomHelper.cs +++ /dev/null @@ -1,251 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using TEngine.DataStructure; - -namespace TEngine.Core -{ - public static class RandomHelper - { - private static readonly Random Random = new Random(); - - private static readonly byte[] Byte8 = new byte[8]; - private static readonly byte[] Byte2 = new byte[2]; - - public static ulong RandUInt64() - { - Random.NextBytes(Byte8); - return BitConverter.ToUInt64(Byte8, 0); - } - - public static long RandInt64() - { - Random.NextBytes(Byte8); - return BitConverter.ToInt64(Byte8, 0); - } - - public static uint RandUInt32() - { - return (uint) Random.Next(); - } - - public static ushort RandUInt16() - { - Random.NextBytes(Byte2); - return BitConverter.ToUInt16(Byte2, 0); - } - - /// - /// 获取lower与Upper之间的随机数,包含下限,不包含上限 - /// - /// - /// - /// - public static int RandomNumber(int lower, int upper) - { - return Random.Next(lower, upper); - } - - public static bool RandomBool() - { - return Random.Next(2) == 0; - } - - public static T RandomArray(this T[] array) - { - return array[RandomNumber(0, array.Count() - 1)]; - } - - public static T RandomArray(this List array) - { - return array[RandomNumber(0, array.Count() - 1)]; - } - - /// - /// 打乱数组 - /// - /// - /// 要打乱的数组 - public static void BreakRank(List arr) - { - if (arr == null || arr.Count < 2) - { - return; - } - - for (var i = 0; i < arr.Count / 2; i++) - { - var index = Random.Next(0, arr.Count); - (arr[index], arr[arr.Count - index - 1]) = (arr[arr.Count - index - 1], arr[index]); - } - } - - public static float RandFloat01() - { - var value = Random.NextDouble(); - return (float) value; - } - - private static int Rand(int n) - { - var rd = new Random(); - // 注意,返回值是左闭右开,所以maxValue要加1 - return rd.Next(1, n + 1); - } - - /// - /// 通过权重随机 - /// - /// - /// - public static int RandomByWeight(int[] weights) - { - var sum = weights.Sum(); - var numberRand = Rand(sum); - var sumTemp = 0; - for (var i = 0; i < weights.Length; i++) - { - sumTemp += weights[i]; - if (numberRand <= sumTemp) - { - return i; - } - } - - return -1; - } - - /// - /// 固定概率的随机、就是某数值上限里比出多少次 - /// - /// - /// - public static int RandomByFixedProbability(int[] args) - { - var argCount = args.Length; - var sum = args.Sum(); - var random = Random.NextDouble() * sum; - while (sum > random) - { - sum -= args[argCount - 1]; - argCount--; - } - - return argCount; - } - - /// - /// 返回随机数。 - /// - /// 是否包含负数。 - /// 返回一个随机的单精度浮点数。 - public static float NextFloat(bool containNegative = false) - { - float f; - var buffer = new byte[4]; - if (containNegative) - { - do - { - Random.NextBytes(buffer); - f = BitConverter.ToSingle(buffer, 0); - } while ((f >= float.MinValue && f < float.MaxValue) == false); - - return f; - } - - do - { - Random.NextBytes(buffer); - f = BitConverter.ToSingle(buffer, 0); - } while ((f >= 0 && f < float.MaxValue) == false); - - return f; - } - - /// - /// 返回一个小于所指定最大值的非负随机数。 - /// - /// 要生成的随机数的上限(随机数不能取该上限值)。 maxValue 必须大于或等于零。 - /// 大于等于零且小于 maxValue 的单精度浮点数,即:返回值的范围通常包括零但不包括 maxValue。 不过,如果 maxValue 等于零,则返回 maxValue。 - public static float NextFloat(float maxValue) - { - if (maxValue.Equals(0)) - { - return maxValue; - } - - if (maxValue < 0) - { - throw new ArgumentOutOfRangeException("“maxValue”必须大于 0。", "maxValue"); - } - - float f; - var buffer = new byte[4]; - - do - { - Random.NextBytes(buffer); - f = BitConverter.ToSingle(buffer, 0); - } while ((f >= 0 && f < maxValue) == false); - - return f; - } - - /// - /// 返回一个指定范围内的随机数。 - /// - /// 返回的随机数的下界(随机数可取该下界值)。 - /// 返回的随机数的上界(随机数不能取该上界值)。 maxValue 必须大于或等于 minValue。 - /// 一个大于等于 minValue 且小于 maxValue 的单精度浮点数,即:返回的值范围包括 minValue 但不包括 maxValue。 如果 minValue 等于 maxValue,则返回 minValue。 - public static float NextFloat(float minValue, float maxValue) - { - if (minValue.Equals(maxValue)) - { - return minValue; - } - - if (minValue > maxValue) - { - throw new ArgumentOutOfRangeException("“minValue”不能大于 maxValue。", "minValue"); - } - - float f; - var buffer = new byte[4]; - - do - { - Random.NextBytes(buffer); - f = BitConverter.ToSingle(buffer, 0); - } while ((f >= minValue && f < maxValue) == false); - - return f; - } - - /// - /// 在4个Vector2点范围内随机出一个位置 - /// - /// X轴最小值 - /// X轴最大值 - /// Y轴最小值 - /// Y轴最大值 - /// - public static Vector2 NextVector2(float minX, float maxX, float minY, float maxY) - { - return new Vector2(NextFloat(minX, maxX), NextFloat(minY, maxY)); - } - - public static string RandomNumberCode(int len = 6) - { - int num = 0; - for (int i = 0; i < len; i++) - { - int number = RandomNumber(0, 10); - num = num * 10 + number; - } - - return num.ToString(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/RandomHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/RandomHelper.cs.meta deleted file mode 100644 index 831a7e9d..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/RandomHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9e66c86ada7ae8d4680728f4d6562245 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/StringHelper.cs b/Assets/GameScripts/DotNet/Core/Helper/StringHelper.cs deleted file mode 100644 index 0b7c1dae..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/StringHelper.cs +++ /dev/null @@ -1,191 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Globalization; -using System.Reflection; -using System.Text; - -namespace TEngine -{ - public static class StringHelper - { - public static IEnumerable ToBytes(this string str) - { - byte[] byteArray = Encoding.Default.GetBytes(str); - return byteArray; - } - - public static byte[] ToByteArray(this string str) - { - byte[] byteArray = Encoding.Default.GetBytes(str); - return byteArray; - } - - public static byte[] ToUtf8(this string str) - { - byte[] byteArray = Encoding.UTF8.GetBytes(str); - return byteArray; - } - - public static byte[] HexToBytes(this string hexString) - { - if (hexString.Length % 2 != 0) - { - throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "The binary key cannot have an odd number of digits: {0}", - hexString)); - } - - var hexAsBytes = new byte[hexString.Length / 2]; - for (int index = 0; index < hexAsBytes.Length; index++) - { - string byteValue = ""; - byteValue += hexString[index * 2]; - byteValue += hexString[index * 2 + 1]; - hexAsBytes[index] = byte.Parse(byteValue, NumberStyles.HexNumber, CultureInfo.InvariantCulture); - } - - return hexAsBytes; - } - - public static string Fmt(this string text, params object[] args) - { - return string.Format(text, args); - } - - public static string ListToString(this List list) - { - StringBuilder sb = new StringBuilder(); - foreach (T t in list) - { - sb.Append(t); - sb.Append(","); - } - - return sb.ToString(); - } - - public static string ArrayToString(this T[] args) - { - if (args == null) - { - return ""; - } - - string argStr = " ["; - for (int arrIndex = 0; arrIndex < args.Length; arrIndex++) - { - argStr += args[arrIndex]; - if (arrIndex != args.Length - 1) - { - argStr += ", "; - } - } - - argStr += "]"; - return argStr; - } - - public static string ArrayToString(this T[] args, int index, int count) - { - if (args == null) - { - return ""; - } - - string argStr = " ["; - for (int arrIndex = index; arrIndex < count + index; arrIndex++) - { - argStr += args[arrIndex]; - if (arrIndex != args.Length - 1) - { - argStr += ", "; - } - } - - argStr += "]"; - return argStr; - } - - public static string PrintProto(this AProto proto, int stackIndex = 0, string propertyInfoName = "", bool isList = false, int listIndex = 0) - { - if (proto == null) - { - return ""; - } - - StringBuilder _stringBuilder = new StringBuilder(); - _stringBuilder.Clear(); - - Type type = proto.GetType(); - _stringBuilder.Append($"\n"); - for (int i = 0; i < stackIndex; i++) - { - _stringBuilder.Append("\t"); - } - - propertyInfoName = isList ? $"[{propertyInfoName}][{listIndex}]" : $"[{propertyInfoName}]"; - _stringBuilder.Append(stackIndex == 0? $"[{type.Name}]" : propertyInfoName); - - var bindingFlags = BindingFlags.Public | BindingFlags.Instance; - var propertyInfos = type.GetProperties(bindingFlags); - for (var i = 0; i < propertyInfos.Length; ++i) - { - var propertyInfo = propertyInfos[i]; - - if (propertyInfo.PropertyType.BaseType == typeof (AProto)) - { - _stringBuilder.Append(PrintProto((AProto)propertyInfo.GetValue(proto), stackIndex + 1, propertyInfo.Name)); - } - else if (propertyInfo.PropertyType.IsList() && propertyInfo.PropertyType.IsGenericType) - { - object value = propertyInfo.GetValue(proto, null); - if (value != null) - { - Type objType = value.GetType(); - int count = Convert.ToInt32(objType.GetProperty("Count").GetValue(value, null)); - for (int j = 0; j < count; j++) - { - object item = objType.GetProperty("Item").GetValue(value, new object[] { j }); - _stringBuilder.Append(PrintProto((AProto)item, stackIndex + 1, propertyInfo.Name, isList: true, listIndex: j)); - } - } - } - else - { - _stringBuilder.Append($"\n"); - for (int j = 0; j < stackIndex + 1; j++) - { - _stringBuilder.Append("\t"); - } - - _stringBuilder.Append($"[{propertyInfo.Name}]"); - _stringBuilder.Append(": "); - _stringBuilder.Append(propertyInfo.GetValue(proto)); - } - } - - return _stringBuilder.ToString(); - } - - /// - /// 判断类型是否为可操作的列表类型 - /// - /// - /// - public static bool IsList(this Type type) - { - if (typeof (System.Collections.IList).IsAssignableFrom(type)) - { - return true; - } - - foreach (var it in type.GetInterfaces()) - { - if (it.IsGenericType && typeof (IList<>) == it.GetGenericTypeDefinition()) - return true; - } - - return false; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/StringHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/StringHelper.cs.meta deleted file mode 100644 index f0a88d8f..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/StringHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c253fa0108e29234f9198e6b720bdbf7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Helper/TimeHelper.cs b/Assets/GameScripts/DotNet/Core/Helper/TimeHelper.cs deleted file mode 100644 index 9937de21..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/TimeHelper.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; - -namespace TEngine.Core -{ - public static class TimeHelper - { - public const long Hour = 3600000; // 小时毫秒值 60 * 60 * 1000 - public const long Minute = 60000; // 分钟毫秒值 60 * 1000 - public const long OneDay = 86400000; // 天毫秒值 24 * 60 * 60 * 1000 - private const long Epoch = 621355968000000000L; // 1970年1月1日的Ticks - - private static readonly DateTime Dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - - public static long Now => (DateTime.UtcNow.Ticks - Epoch) / 10000; - -#if TENGINE_UNITY - public static long TimeDiff; - public static long ServerNow => Now + TimeDiff; -#endif - - public static long Transition(DateTime d) - { - return (d.Ticks - Epoch) / 10000; - } - - public static DateTime Transition(long timeStamp) - { - return Dt1970.AddTicks(timeStamp); - } - - public static DateTime TransitionLocal(long timeStamp) - { - return Dt1970.AddTicks(timeStamp).ToLocalTime(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Helper/TimeHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Helper/TimeHelper.cs.meta deleted file mode 100644 index 252995fb..00000000 --- a/Assets/GameScripts/DotNet/Core/Helper/TimeHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4061d25ace5fcdf4f866a85e45e1a8d6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/IdFactory.meta b/Assets/GameScripts/DotNet/Core/IdFactory.meta deleted file mode 100644 index ee21c89c..00000000 --- a/Assets/GameScripts/DotNet/Core/IdFactory.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 18509e45bb5163e4cb79fa240210f7cf -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/IdFactory/EntityIdStruct.cs b/Assets/GameScripts/DotNet/Core/IdFactory/EntityIdStruct.cs deleted file mode 100644 index a70153fb..00000000 --- a/Assets/GameScripts/DotNet/Core/IdFactory/EntityIdStruct.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System.Runtime.InteropServices; - -namespace TEngine.Core -{ - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct EntityIdStruct - { - // +-------------------+----------------------+-------------------------+----------------------------------+ - // | time(30) 最大34年 | AppId(8) 最多255个进程 | WordId(10) 最多1023个世界 | sequence(16) 每毫秒每个进程能生产65535个 - // +-------------------+----------------------+-------------------------+----------------------------------+ - // 这样算下来、每个世界都有255个进程、就算WOW的游戏一个区也用不到255个进程 - // 计算下每个世界255个进程也就是1023 * 255 = 260865个进程、完全够用了 - // 但有一个问题是游戏最大只能有1023个区了、但可以通过战区手段来解决这个问题 - - public uint Time{ get; private set; } - public uint Sequence{ get; private set; } - public uint LocationId { get; private set; } - - public ushort AppId => (ushort)(this.LocationId >> 10 & RouteIdStruct.MaskAppId); - public ushort WordId=> (ushort)(this.LocationId & RouteIdStruct.MaskWordId); - - public const int MaskRouteId = 0x3FFFF; - public const int MaskSequence = 0xFFFF; - - public EntityIdStruct(uint locationId, uint time, uint sequence) - { - Time = time; - Sequence = sequence; - LocationId = locationId; - } - - public static implicit operator long(EntityIdStruct entityIdStruct) - { - ulong result = 0; - result |= entityIdStruct.Sequence; - result |= (ulong)entityIdStruct.LocationId << 16; - result |= (ulong)entityIdStruct.Time << 34; - return (long)result; - } - - public static implicit operator EntityIdStruct(long id) - { - var result = (ulong) id; - var idStruct = new EntityIdStruct() - { - Sequence = (uint) (result & MaskSequence) - }; - result >>= 16; - idStruct.LocationId = (uint) (result & 0x3FFFF); - result >>= 18; - idStruct.Time = (uint) result; - return idStruct; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/IdFactory/EntityIdStruct.cs.meta b/Assets/GameScripts/DotNet/Core/IdFactory/EntityIdStruct.cs.meta deleted file mode 100644 index c3828128..00000000 --- a/Assets/GameScripts/DotNet/Core/IdFactory/EntityIdStruct.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ca0fd54b2e368d246a01a2e34420a11a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/IdFactory/IdFactory.cs b/Assets/GameScripts/DotNet/Core/IdFactory/IdFactory.cs deleted file mode 100644 index d0f75865..00000000 --- a/Assets/GameScripts/DotNet/Core/IdFactory/IdFactory.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; - -namespace TEngine.Core -{ - public static class IdFactory - { - private static readonly long Epoch1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).Ticks / 10000; - private static readonly long Epoch2023 = new DateTime(2023, 1, 1, 0, 0, 0, DateTimeKind.Utc).Ticks / 10000 - Epoch1970; - private static readonly long EpochThisYear = new DateTime(DateTime.Now.Year, 1, 1, 0, 0, 0, DateTimeKind.Utc).Ticks / 10000 - Epoch1970; - - private static uint _lastRunTimeIdTime; - private static uint _lastRunTimeIdSequence; - - private static uint _lastEntityIdTime; - private static uint _lastEntityIdSequence; - - public static long NextRunTimeId() - { - var time = (uint) ((TimeHelper.Now - EpochThisYear) / 1000); - - if (time > _lastRunTimeIdTime) - { - _lastRunTimeIdTime = time; - _lastRunTimeIdSequence = 0; - } - else if (++_lastRunTimeIdSequence > uint.MaxValue - 1) - { - ++_lastRunTimeIdTime; - _lastRunTimeIdSequence = 0; - } - - return new RuntimeIdStruct(_lastRunTimeIdTime, _lastRunTimeIdSequence); - } - - public static long NextEntityId(uint locationId) - { - var time = (uint)((TimeHelper.Now - Epoch2023) / 1000); - - if (time > _lastEntityIdTime) - { - _lastEntityIdTime = time; - _lastEntityIdSequence = 0; - } - else if (++_lastEntityIdSequence > EntityIdStruct.MaskSequence - 1) - { - ++_lastEntityIdTime; - _lastEntityIdSequence = 0; - } - - return new EntityIdStruct(locationId, _lastEntityIdTime, _lastEntityIdSequence); - } - - public static uint GetRouteId(long entityId) - { - return (ushort)(entityId >> 16 & EntityIdStruct.MaskRouteId); - } - - public static ushort GetAppId(long entityId) - { - return (ushort)(entityId >> 26 & RouteIdStruct.MaskAppId); - } - - public static int GetWordId(long entityId) - { - return (ushort)(entityId >> 16 & RouteIdStruct.MaskWordId); - } - } -} - diff --git a/Assets/GameScripts/DotNet/Core/IdFactory/IdFactory.cs.meta b/Assets/GameScripts/DotNet/Core/IdFactory/IdFactory.cs.meta deleted file mode 100644 index a1da3265..00000000 --- a/Assets/GameScripts/DotNet/Core/IdFactory/IdFactory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bcd505cdcef612546b9501632e9f56e8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/IdFactory/RouteIdStruct.cs b/Assets/GameScripts/DotNet/Core/IdFactory/RouteIdStruct.cs deleted file mode 100644 index 7e4e48a6..00000000 --- a/Assets/GameScripts/DotNet/Core/IdFactory/RouteIdStruct.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Runtime.InteropServices; - -namespace TEngine.Core -{ - // +----------------------+---------------------------+ - // | AppId(8) 最多255个进程 | WordId(10) 最多1023个世界 - // +----------------------+---------------------------+ - - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct RouteIdStruct - { - public ushort AppId; - public ushort WordId; - - public const int MaskAppId = 0xFF; - public const int MaskWordId = 0x3FF; - - public RouteIdStruct(ushort appId, ushort wordId) - { - AppId = appId; - WordId = wordId; - } - - public static implicit operator uint(RouteIdStruct routeId) - { - uint result = 0; - result |= routeId.WordId; - result |= (uint)routeId.AppId << 10; - return result; - } - - public static implicit operator RouteIdStruct(uint routeId) - { - var idStruct = new RouteIdStruct() - { - WordId = (ushort)(routeId & MaskWordId) - }; - - routeId >>= 10; - idStruct.AppId = (ushort)(routeId & MaskAppId); - return idStruct; - } - - public override string ToString() - { - return $"AppId:{this.AppId}|WordId:{this.WordId}"; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/IdFactory/RouteIdStruct.cs.meta b/Assets/GameScripts/DotNet/Core/IdFactory/RouteIdStruct.cs.meta deleted file mode 100644 index 70b944ae..00000000 --- a/Assets/GameScripts/DotNet/Core/IdFactory/RouteIdStruct.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e4db9bed6b0052e409bb43d36c146fd0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/IdFactory/RuntimeIdStruct.cs b/Assets/GameScripts/DotNet/Core/IdFactory/RuntimeIdStruct.cs deleted file mode 100644 index d581f4f7..00000000 --- a/Assets/GameScripts/DotNet/Core/IdFactory/RuntimeIdStruct.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System.Runtime.InteropServices; - -namespace TEngine.Core -{ - [StructLayout(LayoutKind.Sequential, Pack = 1)] - public struct RuntimeIdStruct - { - // +----------+------------+ - // | time(32) | sequence(32) - // +----------+------------+ - - private uint Time; - private uint Sequence; - - public RuntimeIdStruct(uint time, uint sequence) - { - Time = time; - Sequence = sequence; - } - - public static implicit operator long(RuntimeIdStruct runtimeId) - { - ulong result = 0; - result |= runtimeId.Sequence; - result |= (ulong) runtimeId.Time << 32; - return (long) result; - } - - public static implicit operator RuntimeIdStruct(long id) - { - var result = (ulong) id; - var idStruct = new RuntimeIdStruct() - { - Time = (uint) (result >> 32), - Sequence = (uint) (result & 0xFFFFFFFF) - }; - return idStruct; - } - - public override string ToString() - { - return $"Time: {this.Time}, Sequence: {this.Sequence}"; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/IdFactory/RuntimeIdStruct.cs.meta b/Assets/GameScripts/DotNet/Core/IdFactory/RuntimeIdStruct.cs.meta deleted file mode 100644 index df152fe4..00000000 --- a/Assets/GameScripts/DotNet/Core/IdFactory/RuntimeIdStruct.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e67b19c4b87042949acec08063708f54 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Log.meta b/Assets/GameScripts/DotNet/Core/Log.meta deleted file mode 100644 index f8bb2ac6..00000000 --- a/Assets/GameScripts/DotNet/Core/Log.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4cf6835f4f028434f8728b338abf2316 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Log/ILog.cs b/Assets/GameScripts/DotNet/Core/Log/ILog.cs deleted file mode 100644 index defd7022..00000000 --- a/Assets/GameScripts/DotNet/Core/Log/ILog.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace TEngine -{ - public interface ILog - { - void Trace(string message); - void Warning(string message); - void Info(string message); - void Debug(string message); - void Error(string message); - void Fatal(string message); - void Trace(string message, params object[] args); - void Warning(string message, params object[] args); - void Info(string message, params object[] args); - void Debug(string message, params object[] args); - void Error(string message, params object[] args); - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Log/ILog.cs.meta b/Assets/GameScripts/DotNet/Core/Log/ILog.cs.meta deleted file mode 100644 index 2b6f95d8..00000000 --- a/Assets/GameScripts/DotNet/Core/Log/ILog.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b90975fb800e1a745a323955fa71f3a2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Log/Log.cs b/Assets/GameScripts/DotNet/Core/Log/Log.cs deleted file mode 100644 index 3d4e6f37..00000000 --- a/Assets/GameScripts/DotNet/Core/Log/Log.cs +++ /dev/null @@ -1,145 +0,0 @@ -#if TENGINE_NET -namespace TEngine -{ - public static class Log - { - static Log() - { - if (LogCore.Instance == null) - { - LogCore.TempInstance = new LogCore(); - } - LogCore.Instance.ILog = new NLog("Server"); - } - - /// - /// 打印追朔级别日志,用于记录追朔类日志信息。 - /// - /// 日志内容。 - public static void Trace(string msg) - { - LogCore.Instance.Trace(msg); - } - - /// - /// 打印调试级别日志,用于记录调试类日志信息。 - /// - /// 日志内容。 - public static void Debug(string msg) - { - LogCore.Instance.Debug(msg); - } - - /// - /// 打印信息级别日志,用于记录信息类日志信息。 - /// - /// 日志内容。 - public static void Info(string msg) - { - LogCore.Instance.Info(msg); - } - - /// - /// 打印追朔级别日志,用于记录追朔类日志信息。 - /// - /// 日志内容。 - public static void TraceInfo(string msg) - { - LogCore.Instance.Trace(msg); - } - - /// - /// 打印追警告日志,用于记录警告类日志信息。 - /// - /// 日志内容。 - public static void Warning(string msg) - { - LogCore.Instance.Warning(msg); - } - - /// - /// 打印错误级别日志,建议在发生功能逻辑错误,但尚不会导致游戏崩溃或异常时使用。 - /// - /// 日志内容。 - public static void Error(string msg) - { - LogCore.Instance.Error(msg); - } - - /// - /// 打印错误级别日志,建议在发生功能逻辑错误,但尚不会导致游戏崩溃或异常时使用。 - /// - /// 异常内容。 - public static void Error(Exception exception) - { - LogCore.Instance.Error(exception); - } - - /// - /// 打印严重错误级别日志,建议在发生严重错误,可能导致游戏崩溃或异常时使用,此时应尝试重启进程或重建服务框架。 - /// - /// 日志内容。 - public static void Fatal(string msg) - { - LogCore.Instance.Fatal(msg); - } - - /// - /// 打印严重错误级别日志,建议在发生严重错误,可能导致游戏崩溃或异常时使用,此时应尝试重启进程或重建服务框架。 - /// - /// 常内容。 - public static void Fatal(Exception exception) - { - LogCore.Instance.Fatal(exception.Message); - } - - /// - /// 断言严重错误级别日志,建议在发生严重错误。 - /// - /// 断言条件 - /// - public static void Assert(bool condition, string msg = "") - { - if (!condition) - { - if (string.IsNullOrEmpty(msg)) - { - msg = AssertError; - } - - LogCore.Instance.Error(msg); - } - } - - /// - /// 断言默认日志。 - /// - public const string AssertError = "ASSERT FAILD"; - - public static void Trace(ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler message) - { - LogCore.Instance.Trace(message.ToStringAndClear()); - } - - public static void Warning(ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler message) - { - LogCore.Instance.Warning(message.ToStringAndClear()); - } - - public static void Info(ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler message) - { - LogCore.Instance.Info(message.ToStringAndClear()); - } - - public static void Debug(ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler message) - { - LogCore.Instance.Debug(message.ToStringAndClear()); - } - - public static void Error(ref System.Runtime.CompilerServices.DefaultInterpolatedStringHandler message) - { - LogCore.Instance.Error(message.ToStringAndClear()); - } - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Log/Log.cs.meta b/Assets/GameScripts/DotNet/Core/Log/Log.cs.meta deleted file mode 100644 index 0c497aea..00000000 --- a/Assets/GameScripts/DotNet/Core/Log/Log.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7794bf5b314b88d409d6113935a0d1f3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Log/LogCore.cs b/Assets/GameScripts/DotNet/Core/Log/LogCore.cs deleted file mode 100644 index 847e29da..00000000 --- a/Assets/GameScripts/DotNet/Core/Log/LogCore.cs +++ /dev/null @@ -1,267 +0,0 @@ -#if TENGINE_NET -using System.Diagnostics; -using System.Text; -using TEngine.Core; - -namespace TEngine -{ - public class LogCore : Singleton - { - private ILog iLog; - - public ILog ILog - { - set => iLog = value; - } - - public enum LogLevel - { - INFO, - DEBUG, - ASSERT, - WARNING, - ERROR, - EXCEPTION, - } - - private LogLevel _filterLevel = LogLevel.INFO; - private StringBuilder _stringBuilder = new StringBuilder(); - - private const int TraceLevel = 1; - private const int DebugLevel = 2; - private const int InfoLevel = 3; - private const int WarningLevel = 4; - - private bool CheckLogLevel(int level) - { - if (AppDefine.Options == null) - { - return true; - } - - return AppDefine.Options.LogLevel <= level; - } - - public void Trace(string msg) - { - if (!CheckLogLevel(DebugLevel)) - { - return; - } - - StackTrace st = new StackTrace(2, true); - string log = $"{msg}\n{st}"; - this.Log(LogLevel.INFO, log); - this.iLog.Trace(log); - } - - public void Debug(string msg) - { - if (!CheckLogLevel(DebugLevel)) - { - return; - } - this.Log(LogLevel.DEBUG, msg); - this.iLog.Debug(msg); - } - - public void Info(string msg) - { - if (!CheckLogLevel(InfoLevel)) - { - return; - } - this.Log(LogLevel.INFO, msg); - this.iLog.Info(msg); - } - - public void TraceInfo(string msg) - { - if (!CheckLogLevel(InfoLevel)) - { - return; - } - - StackTrace st = new StackTrace(2, true); - string log = $"{msg}\n{st}"; - this.Log(LogLevel.INFO, msg); - this.iLog.Trace(log); - } - - public void Warning(string msg) - { - if (!CheckLogLevel(WarningLevel)) - { - return; - } - this.Log(LogLevel.WARNING, msg); - this.iLog.Warning(msg); - } - - public void Error(string msg) - { - StackTrace st = new StackTrace(2, true); - string log = $"{msg}\n{st}"; - this.Log(LogLevel.ERROR, log); - this.iLog.Error(log); - } - - public void Error(Exception e) - { - if (e.Data.Contains("StackTrace")) - { - this.iLog.Error($"{e.Data["StackTrace"]}\n{e}"); - return; - } - - string str = e.ToString(); - this.Log(LogLevel.ERROR, str); - this.iLog.Error(str); - } - - public void Fatal(string msg) - { - StackTrace st = new StackTrace(2, true); - this.iLog.Fatal($"{msg}\n{st}"); - } - - public void Trace(string message, params object[] args) - { - if (!CheckLogLevel(TraceLevel)) - { - return; - } - - StackTrace st = new StackTrace(2, true); - this.iLog.Trace($"{string.Format(message, args)}\n{st}"); - } - - public void Warning(string message, params object[] args) - { - if (!CheckLogLevel(WarningLevel)) - { - return; - } - - this.iLog.Warning(string.Format(message, args)); - } - - public void Info(string message, params object[] args) - { - if (!CheckLogLevel(InfoLevel)) - { - return; - } - - this.iLog.Info(string.Format(message, args)); - } - - public void Debug(string message, params object[] args) - { - if (!CheckLogLevel(DebugLevel)) - { - return; - } - - this.iLog.Debug(string.Format(message, args)); - } - - public void Error(string message, params object[] args) - { - StackTrace st = new StackTrace(2, true); - string s = string.Format(message, args) + '\n' + st; - this.iLog.Error(s); - } - - private StringBuilder GetFormatString(LogLevel logLevel, string logString) - { - _stringBuilder.Clear(); - switch (logLevel) - { - case LogLevel.DEBUG: - _stringBuilder.AppendFormat( - "[TEngine][DEBUG][{0:yyyy-MM-dd HH:mm:ss fff}] - {1}", DateTime.Now, logString); - break; - case LogLevel.INFO: - _stringBuilder.AppendFormat( - "[TEngine][INFO][{0:yyyy-MM-dd HH:mm:ss fff}] - {1}", DateTime.Now, logString); - break; - case LogLevel.ASSERT: - _stringBuilder.AppendFormat( - "[TEngine][ASSERT][{0:yyyy-MM-dd HH:mm:ss fff}] - {1}", DateTime.Now, logString); - break; - case LogLevel.WARNING: - _stringBuilder.AppendFormat( - "[TEngine][WARNING][{0:yyyy-MM-dd HH:mm:ss fff}] - {1}", DateTime.Now, - logString); - break; - case LogLevel.ERROR: - _stringBuilder.AppendFormat( - "[TEngine][ERROR][{0:yyyy-MM-dd HH:mm:ss fff}] - {1}", DateTime.Now, logString); - break; - case LogLevel.EXCEPTION: - _stringBuilder.AppendFormat( - "[TEngine][EXCEPTION][{0:yyyy-MM-dd HH:mm:ss fff}] - {1}", DateTime.Now, logString); - break; - } - - return _stringBuilder; - } - - private void Log(LogLevel type, string logString) - { - if (type < _filterLevel) - { - return; - } - - StringBuilder infoBuilder = GetFormatString(type, logString); - - if (type == LogLevel.ERROR || type == LogLevel.EXCEPTION) - { - StackFrame[] sf = new StackTrace().GetFrames(); - for (int i = 0; i < sf.Length; i++) - { - StackFrame frame = sf[i]; - string declaringTypeName = frame.GetMethod()?.DeclaringType.FullName; - string methodName = frame.GetMethod()?.Name; - infoBuilder.AppendFormat("[{0}::{1}\n", declaringTypeName, methodName); - } - } - - string logStr = infoBuilder.ToString(); - - if (type == LogLevel.INFO) - { - Console.ForegroundColor = ConsoleColor.White; - Console.WriteLine(logStr); - } - else if (type == LogLevel.DEBUG) - { - Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine(logStr); - } - else if (type == LogLevel.WARNING) - { - Console.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine(logStr); - } - else if (type == LogLevel.ASSERT) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine(logStr); - } - else if (type == LogLevel.ERROR) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine(logStr); - } - else if (type == LogLevel.EXCEPTION) - { - Console.ForegroundColor = ConsoleColor.Magenta; - Console.WriteLine(logStr); - } - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Log/LogCore.cs.meta b/Assets/GameScripts/DotNet/Core/Log/LogCore.cs.meta deleted file mode 100644 index cb792b44..00000000 --- a/Assets/GameScripts/DotNet/Core/Log/LogCore.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1a0e8dec854eecb448be2f1bf80fc3d3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Log/NLog.cs b/Assets/GameScripts/DotNet/Core/Log/NLog.cs deleted file mode 100644 index 8ad3b94e..00000000 --- a/Assets/GameScripts/DotNet/Core/Log/NLog.cs +++ /dev/null @@ -1,75 +0,0 @@ -#if TENGINE_NET -using NLog; - -namespace TEngine; - -public class NLog : ILog -{ - private readonly Logger _logger; - - public NLog(string name) - { - _logger = LogManager.GetLogger(name); - } - - public void Trace(string message) - { - _logger.Trace(message); - } - - public void Warning(string message) - { - _logger.Warn(message); - } - - public void Info(string message) - { - _logger.Info(message); - } - - public void Debug(string message) - { - _logger.Debug(message); - } - - public void Error(string message) - { - _logger.Error(message); - } - - public void Fatal(string message) - { - _logger.Fatal(message); - } - - public void Trace(string message, params object[] args) - { - _logger.Trace(message, args); - } - - public void Warning(string message, params object[] args) - { - _logger.Warn(message, args); - } - - public void Info(string message, params object[] args) - { - _logger.Info(message, args); - } - - public void Debug(string message, params object[] args) - { - _logger.Debug(message, args); - } - - public void Error(string message, params object[] args) - { - _logger.Error(message, args); - } - - public void Fatal(string message, params object[] args) - { - _logger.Fatal(message, args); - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Log/NLog.cs.meta b/Assets/GameScripts/DotNet/Core/Log/NLog.cs.meta deleted file mode 100644 index 3961e58f..00000000 --- a/Assets/GameScripts/DotNet/Core/Log/NLog.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e9dee8b48fb3d80418d31ed532a904f0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Modules.meta b/Assets/GameScripts/DotNet/Core/Modules.meta deleted file mode 100644 index bcdfb1e4..00000000 --- a/Assets/GameScripts/DotNet/Core/Modules.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 37d561d4e0b69c2489c4f54813f740e1 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Modules/Session.meta b/Assets/GameScripts/DotNet/Core/Modules/Session.meta deleted file mode 100644 index 19e007fb..00000000 --- a/Assets/GameScripts/DotNet/Core/Modules/Session.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 62fb06b1efb2c3e4cb58e2bc0119688d -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Modules/Session/SessionHeartbeatComponent.cs b/Assets/GameScripts/DotNet/Core/Modules/Session/SessionHeartbeatComponent.cs deleted file mode 100644 index c0c8d466..00000000 --- a/Assets/GameScripts/DotNet/Core/Modules/Session/SessionHeartbeatComponent.cs +++ /dev/null @@ -1,65 +0,0 @@ -#if TENGINE_UNITY -using TEngine.Core; -using TEngine.Core.Network; - -namespace TEngine.Logic -{ - public class SessionHeartbeatComponent : Entity - { - private long _timerId; - private long _selfRunTimeId; - private Session _session; - private readonly PingRequest _pingRequest = new PingRequest(); - - public int Ping { get; private set; } - - public override void Dispose() - { - Stop(); - Ping = 0; - _session = null; - _selfRunTimeId = 0; - base.Dispose(); - } - - public void Start(int interval) - { - _session = (Session)Parent; - _selfRunTimeId = RuntimeId; - RepeatedSend().Coroutine(); - _timerId = TimerScheduler.Instance.Unity.RepeatedTimer(interval, () => RepeatedSend().Coroutine()); - } - - public void Stop() - { - if (_timerId == 0) - { - return; - } - - TimerScheduler.Instance?.Unity.RemoveByRef(ref _timerId); - } - - private async FTask RepeatedSend() - { - if (_selfRunTimeId != RuntimeId) - { - Stop(); - } - - var requestTime = TimeHelper.Now; - var pingResponse = (PingResponse)await _session.Call(_pingRequest); - - if (pingResponse.ErrorCode != 0) - { - return; - } - - var responseTime = TimeHelper.Now; - Ping = (int)(responseTime - requestTime) / 2; - TimeHelper.TimeDiff = pingResponse.Now + Ping - responseTime; - Log.Info("----------- HeartBeat -----------"); - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Modules/Session/SessionHeartbeatComponent.cs.meta b/Assets/GameScripts/DotNet/Core/Modules/Session/SessionHeartbeatComponent.cs.meta deleted file mode 100644 index cfb73c22..00000000 --- a/Assets/GameScripts/DotNet/Core/Modules/Session/SessionHeartbeatComponent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a99afa40336b6ab4b8f1935689ff27c1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Modules/Session/SessionIdleCheckerComponent.cs b/Assets/GameScripts/DotNet/Core/Modules/Session/SessionIdleCheckerComponent.cs deleted file mode 100644 index edf1d0b3..00000000 --- a/Assets/GameScripts/DotNet/Core/Modules/Session/SessionIdleCheckerComponent.cs +++ /dev/null @@ -1,58 +0,0 @@ -#if TENGINE_NET -using TEngine.Core.Network; - -namespace TEngine.Core; - -public class SessionIdleCheckerComponent: Entity -{ - private long _timeOut; - private long _timerId; - private long _selfRuntimeId; - private Session _session; - - public override void Dispose() - { - Stop(); - _timeOut = 0; - _selfRuntimeId = 0; - _session = null; - base.Dispose(); - } - - public void Start(int interval, int timeOut) - { - _timeOut = timeOut; - _session = (Session)Parent; - _selfRuntimeId = RuntimeId; - _timerId = TimerScheduler.Instance.Core.RepeatedTimer(interval, Check); - } - - public void Stop() - { - if (_timerId == 0) - { - return; - } - - TimerScheduler.Instance.Core.RemoveByRef(ref _timerId); - } - - private void Check() - { - if (_selfRuntimeId != RuntimeId) - { - Stop(); - } - - var timeNow = TimeHelper.Now; - - if (timeNow - _session.LastReceiveTime < _timeOut) - { - return; - } - - Log.Warning($"session timeout id:{Id} timeNow:{timeNow} _session.LastReceiveTime:{_session.LastReceiveTime} _timeOut:{_timeOut}"); - _session.Dispose(); - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Modules/Session/SessionIdleCheckerComponent.cs.meta b/Assets/GameScripts/DotNet/Core/Modules/Session/SessionIdleCheckerComponent.cs.meta deleted file mode 100644 index ec64559f..00000000 --- a/Assets/GameScripts/DotNet/Core/Modules/Session/SessionIdleCheckerComponent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d8ecddd8867e88f409286a99647a236c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network.meta b/Assets/GameScripts/DotNet/Core/Network.meta deleted file mode 100644 index 80423a65..00000000 --- a/Assets/GameScripts/DotNet/Core/Network.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 0c06c0635bd8bd84b90c02b96187e575 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base.meta b/Assets/GameScripts/DotNet/Core/Network/Base.meta deleted file mode 100644 index bcb31ffc..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 1d6d37d54409f584d95bcfea9b9345b3 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Enum.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Enum.meta deleted file mode 100644 index a3cbeba7..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Enum.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 457e84e8ec81f254da550c11a78d4353 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkProtocolType.cs b/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkProtocolType.cs deleted file mode 100644 index f6490555..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkProtocolType.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace TEngine.Core.Network -{ - public enum NetworkProtocolType - { - None = 0, - KCP = 1, - TCP = 2, - WebSocket = 3, - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkProtocolType.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkProtocolType.cs.meta deleted file mode 100644 index ef04b761..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkProtocolType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 74351b44f2b6d4a41969a8159e2808ab -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkTarget.cs b/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkTarget.cs deleted file mode 100644 index 32320ccb..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkTarget.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace TEngine.Core.Network -{ - public enum NetworkTarget - { - None = 0, - Outer = 1, - Inner = 2 - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkTarget.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkTarget.cs.meta deleted file mode 100644 index e7c5b332..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkTarget.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: cf647911052fccc40b1d4601ac423b5b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkType.cs b/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkType.cs deleted file mode 100644 index 7a995089..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkType.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace TEngine.Core.Network -{ - public enum NetworkType - { - None = 0, - Client = 1, - Server = 2 - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkType.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkType.cs.meta deleted file mode 100644 index efcdf6f5..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Enum/NetworkType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8841f1e5b0a30eb4cad8a4e0a099adc8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Helper.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Helper.meta deleted file mode 100644 index 5978eab1..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Helper.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a19a0ba64b936934ba63f099234b941a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Helper/NetworkHelper.cs b/Assets/GameScripts/DotNet/Core/Network/Base/Helper/NetworkHelper.cs deleted file mode 100644 index 6a7c0dc0..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Helper/NetworkHelper.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Net; -using System.Net.NetworkInformation; -#if !UNITY_WEBGL -using System.Net.Sockets; -#endif -using System.Runtime.InteropServices; - -// ReSharper disable InconsistentNaming - -namespace TEngine.Core -{ - public static class NetworkHelper - { - public static string[] GetAddressIPs() - { - var list = new List(); - foreach (var networkInterface in NetworkInterface.GetAllNetworkInterfaces()) - { - if (networkInterface.NetworkInterfaceType != NetworkInterfaceType.Ethernet) - { - continue; - } - - foreach (var add in networkInterface.GetIPProperties().UnicastAddresses) - { - list.Add(add.Address.ToString()); - } - } - - return list.ToArray(); - } - - public static IPEndPoint ToIPEndPoint(string host, int port) - { - return new IPEndPoint(IPAddress.Parse(host), port); - } - - public static IPEndPoint ToIPEndPoint(string address) - { - var index = address.LastIndexOf(':'); - var host = address.Substring(0, index); - var p = address.Substring(index + 1); - var port = int.Parse(p); - return ToIPEndPoint(host, port); - } - - public static string IPEndPointToStr(this IPEndPoint self) - { - return $"{self.Address}:{self.Port}"; - } - -#if !UNITY_WEBGL - public static void SetSioUdpConnReset(Socket socket) - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return; - } - - /* - 目前这个问题只有Windows下才会出现。 - 服务器端在发送数据时捕获到了一个异常, - 这个异常导致原因应该是远程客户端的UDP监听已停止导致数据发送出错。 - 按理说UDP是无连接的,报这个异常是不合理的 - 这个异常让整UDP的服务监听也停止了。 - 这样就因为一个客户端的数据发送无法到达而导致了服务挂了,所有客户端都无法与服务器通信了 - 想详细了解看下https://blog.csdn.net/sunzhen6251/article/details/124168805*/ - const uint IOC_IN = 0x80000000; - const uint IOC_VENDOR = 0x18000000; - const int SIO_UDP_CONNRESET = unchecked((int) (IOC_IN | IOC_VENDOR | 12)); - - socket.IOControl(SIO_UDP_CONNRESET, new[] {Convert.ToByte(false)}, null); - } -#endif - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Helper/NetworkHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Helper/NetworkHelper.cs.meta deleted file mode 100644 index 4157749d..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Helper/NetworkHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: adfef17cb18d2624c8b425b5004f9e75 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Interface.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Interface.meta deleted file mode 100644 index 0a615b64..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Interface.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 93c4a9920a37e1b4c9df005d5f1dfa54 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/AClientNetwork.cs b/Assets/GameScripts/DotNet/Core/Network/Base/Interface/AClientNetwork.cs deleted file mode 100644 index 1f6ac681..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/AClientNetwork.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.IO; -using System.Net; - -namespace TEngine.Core.Network -{ - public abstract class AClientNetwork: ANetwork - { - public uint ChannelId { get; protected set; } - public abstract event Action OnDispose; - public abstract event Action OnConnectFail; - public abstract event Action OnConnectComplete; - public abstract event Action OnConnectDisconnect; - public abstract event Action OnChangeChannelId; - public abstract event Action OnReceiveMemoryStream; - - protected AClientNetwork(Scene scene, NetworkType networkType, NetworkProtocolType networkProtocolType, NetworkTarget networkTarget): base( - scene, networkType, networkProtocolType, networkTarget) - { - } - - public abstract uint Connect(IPEndPoint remoteEndPoint, Action onConnectComplete, Action onConnectFail, Action onConnectDisconnect, - int connectTimeout = 5000); - - public override void Dispose() - { - ChannelId = 0; - base.Dispose(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/AClientNetwork.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Interface/AClientNetwork.cs.meta deleted file mode 100644 index fc9a51fe..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/AClientNetwork.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 513303d3661a378438e54a292c1c6d15 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/ANetwork.cs b/Assets/GameScripts/DotNet/Core/Network/Base/Interface/ANetwork.cs deleted file mode 100644 index 6dde100d..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/ANetwork.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System; -using System.IO; -using TEngine.Core; -using System.Buffers; -// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract -#pragma warning disable CS8625 -#pragma warning disable CS8618 - -namespace TEngine.Core.Network -{ - public struct MessageCacheInfo - { - public uint RpcId; - public long RouteId; - public long RouteTypeOpCode; - public object Message; - public MemoryStream MemoryStream; - } - - public abstract class ANetwork : IDisposable - { - public long Id { get; protected set; } - public Scene Scene { get; protected set; } - public bool IsDisposed { get; protected set; } - public NetworkType NetworkType { get; private set; } - public NetworkTarget NetworkTarget { get; private set; } - public NetworkProtocolType NetworkProtocolType { get; private set; } - public ANetworkMessageScheduler NetworkMessageScheduler { get; protected set; } - - protected readonly Func Pack; - - protected ANetwork(Scene scene, NetworkType networkType, NetworkProtocolType networkProtocolType, NetworkTarget networkTarget) - { - Scene = scene; - NetworkType = networkType; - NetworkTarget = networkTarget; - NetworkProtocolType = networkProtocolType; - Id = IdFactory.NextRunTimeId(); -#if TENGINE_NET - if (networkTarget == NetworkTarget.Inner) - { - Pack = InnerPack; - NetworkMessageScheduler = new InnerMessageScheduler(); - return; - } -#endif - Pack = OuterPack; - - switch (networkType) - { - case NetworkType.Client: - { - NetworkMessageScheduler = new ClientMessageScheduler(); - return; - } - case NetworkType.Server: - { - NetworkMessageScheduler = new OuterMessageScheduler(); - return; - } - } - } -#if TENGINE_NET - private MemoryStream InnerPack(uint rpcId, long routeTypeOpCode, long routeId, MemoryStream memoryStream, object message) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return null; - } -#endif - return memoryStream == null - ? InnerPacketParser.Pack(rpcId, routeId, message) - : InnerPacketParser.Pack(rpcId, routeId, memoryStream); - } -#endif - private MemoryStream OuterPack(uint rpcId, long routeTypeOpCode, long routeId, MemoryStream memoryStream, object message) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return null; - } -#endif - return memoryStream == null - ? OuterPacketParser.Pack(rpcId, routeTypeOpCode, message) - : OuterPacketParser.Pack(rpcId, routeTypeOpCode, memoryStream); - } - - public abstract void Send(uint channelId, uint rpcId, long routeTypeOpCode, long routeId, object message); - public abstract void Send(uint channelId, uint rpcId, long routeTypeOpCode, long routeId, MemoryStream memoryStream); - public abstract void RemoveChannel(uint channelId); - - public virtual void Dispose() - { - NetworkThread.Instance?.RemoveNetwork(Id); - - Id = 0; - Scene = null; - IsDisposed = true; - NetworkType = NetworkType.None; - NetworkTarget = NetworkTarget.None; - NetworkProtocolType = NetworkProtocolType.None; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/ANetwork.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Interface/ANetwork.cs.meta deleted file mode 100644 index 6a1e7411..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/ANetwork.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d8e1b157f4cd9134b84dd17cbb6cb498 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/ANetworkChannel.cs b/Assets/GameScripts/DotNet/Core/Network/Base/Interface/ANetworkChannel.cs deleted file mode 100644 index e4fc312b..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/ANetworkChannel.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.IO; -using System.Net; -#pragma warning disable CS8625 -#pragma warning disable CS8618 - -namespace TEngine.Core.Network -{ - public abstract class ANetworkChannel - { - public uint Id { get; private set; } - public Scene Scene { get; protected set; } - public long NetworkId { get; private set; } - public bool IsDisposed { get; protected set; } - public EndPoint RemoteEndPoint { get; protected set; } - public APacketParser PacketParser { get; protected set; } - - public uint LocalConn - { - get - { - return (uint)this.Id; - } - private set - { - this.Id = value; - } - } - - public abstract event Action OnDispose; - public abstract event Action OnReceiveMemoryStream; - - protected ANetworkChannel(Scene scene, uint id, long networkId) - { - Id = id; - Scene = scene; - NetworkId = networkId; - } - - public virtual void Dispose() - { - NetworkThread.Instance.RemoveChannel(NetworkId, Id); - - Id = 0; - Scene = null; - NetworkId = 0; - IsDisposed = true; - RemoteEndPoint = null; - - if (PacketParser != null) - { - PacketParser.Dispose(); - PacketParser = null; - } - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/ANetworkChannel.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Interface/ANetworkChannel.cs.meta deleted file mode 100644 index 97ed3761..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/ANetworkChannel.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: cef25b06be672c04993353b330cef248 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/INetworkUpdate.cs b/Assets/GameScripts/DotNet/Core/Network/Base/Interface/INetworkUpdate.cs deleted file mode 100644 index cfdd9daf..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/INetworkUpdate.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace TEngine.Core.Network -{ - public interface INetworkUpdate - { - void Update(); - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/INetworkUpdate.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Interface/INetworkUpdate.cs.meta deleted file mode 100644 index 57531212..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Interface/INetworkUpdate.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7eb7bbbac8bc38f429bad42158a0eb39 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Server.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Server.meta deleted file mode 100644 index 6182bd39..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Server.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b9629d3993af22245b83309fcfee436e -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Server/MachineConfigInfo.cs b/Assets/GameScripts/DotNet/Core/Network/Base/Server/MachineConfigInfo.cs deleted file mode 100644 index 8546e8cc..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Server/MachineConfigInfo.cs +++ /dev/null @@ -1,12 +0,0 @@ -#if TENGINE_NET -namespace TEngine; - -public class MachineConfigInfo -{ - public uint Id; - public string OuterIP; - public string OuterBindIP; - public string InnerBindIP; - public int ManagementPort; -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Server/MachineConfigInfo.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Server/MachineConfigInfo.cs.meta deleted file mode 100644 index aa83d518..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Server/MachineConfigInfo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c1e5851b16c4a4d49b253c124b953fb3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Server/SceneConfigInfo.cs b/Assets/GameScripts/DotNet/Core/Network/Base/Server/SceneConfigInfo.cs deleted file mode 100644 index ea3370e2..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Server/SceneConfigInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace TEngine -{ - public class SceneConfigInfo - { - public uint Id; - public long EntityId; - public int SceneType; - public int SceneSubType; - public string SceneTypeStr; - public string SceneSubTypeStr; - public uint ServerConfigId; - public uint WorldId; - public int OuterPort; - public string NetworkProtocol; - } -} - - - diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Server/SceneConfigInfo.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Server/SceneConfigInfo.cs.meta deleted file mode 100644 index 2f5ad2f0..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Server/SceneConfigInfo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4fb765098d2e8f34894ec2696a260f48 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Server/Server.cs b/Assets/GameScripts/DotNet/Core/Network/Base/Server/Server.cs deleted file mode 100644 index 92635894..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Server/Server.cs +++ /dev/null @@ -1,174 +0,0 @@ -#if TENGINE_NET -using TEngine.Core; -using TEngine.Core.Network; -#pragma warning disable CS8603 -#pragma warning disable CS8625 -#pragma warning disable CS8618 - -namespace TEngine -{ - public sealed class Server - { - public uint Id { get; private set; } - public Scene Scene { get; private set; } - private readonly Dictionary _sessions = new Dictionary(); - - private sealed class ConnectInfo : IDisposable - { - public Session Session; - public Entity NetworkComponent; - - public ConnectInfo(Session session, Entity networkComponent) - { - Session = session; - NetworkComponent = networkComponent; - } - - public void Dispose() - { - if (Session != null) - { - Session.Dispose(); - Session = null; - } - - if (NetworkComponent != null) - { - NetworkComponent.Dispose(); - NetworkComponent = null; - } - } - } - - public Session GetSession(uint targetServerId) - { - if (_sessions.TryGetValue(targetServerId, out var connectInfo)) - { - if (!connectInfo.Session.IsDisposed) - { - return connectInfo.Session; - } - - _sessions.Remove(targetServerId); - } - - // 同一个Server下、只需要内部走下消息派发就可以 - - if (Id == targetServerId) - { - var serverNetworkComponent = Scene.GetComponent(); - var session = Session.Create(serverNetworkComponent.Network); - _sessions.Add(targetServerId, new ConnectInfo(session, null)); - return session; - } - - // 不同的Server下需要建立网络连接 - - var serverConfigInfo = ConfigTableManage.ServerConfig(targetServerId); - - if (serverConfigInfo == null) - { - throw new Exception($"The server with ServerId {targetServerId} was not found in the configuration file"); - } - - var machineConfigInfo = ConfigTableManage.MachineConfig(serverConfigInfo.MachineId); - - if (machineConfigInfo == null) - { - throw new Exception($"Server.cs The specified MachineId was not found: {serverConfigInfo.MachineId}"); - } - - var ipEndPoint = NetworkHelper.ToIPEndPoint($"{machineConfigInfo.InnerBindIP}:{serverConfigInfo.InnerPort}"); - var clientNetworkComponent = Entity.Create(Scene); - clientNetworkComponent.Initialize(NetworkProtocolType.KCP, NetworkTarget.Inner); - clientNetworkComponent.Connect(ipEndPoint,null, () => - { - Log.Error($"Unable to connect to the target server sourceServerId:{Id} targetServerId:{targetServerId}"); - },null); - _sessions.Add(targetServerId, new ConnectInfo(clientNetworkComponent.Session, clientNetworkComponent)); - return clientNetworkComponent.Session; - } - - public void RemoveSession(uint targetServerId) - { - if (!_sessions.Remove(targetServerId, out var connectInfo)) - { - return; - } - - connectInfo.Dispose(); - } - - #region Static - - private static readonly Dictionary Servers = new Dictionary(); - - public static async FTask Create(uint serverConfigId) - { - var serverConfigInfo = ConfigTableManage.ServerConfig(serverConfigId); - - if (serverConfigInfo == null) - { - Log.Error($"not found server by Id:{serverConfigId}"); - return; - } - - var machineConfigInfo = ConfigTableManage.MachineConfig(serverConfigInfo.MachineId); - - if (machineConfigInfo == null) - { - Log.Error($"not found machine by Id:{serverConfigInfo.MachineId}"); - return; - } - - var sceneInfos = Scene.GetSceneInfoByServerConfigId(serverConfigId); - await Create(serverConfigId, machineConfigInfo.InnerBindIP, serverConfigInfo.InnerPort, machineConfigInfo.OuterBindIP, sceneInfos); - // Log.Info($"ServerId:{serverConfigId} is start complete"); - } - - public static async FTask Create(uint serverConfigId, string innerBindIp, int innerPort, string outerBindIp, List sceneInfos) - { - if (Servers.TryGetValue(serverConfigId, out var server)) - { - return server; - } - - // 创建一个新的Server、创建一个临时Scene给Server当做Scene使用 - - server = new Server - { - Id = serverConfigId - }; - - server.Scene = await Scene.Create(server); - - // 创建网络、Server下的网络只能是内部网络、外部网络是在Scene中定义 - - if (!string.IsNullOrEmpty(innerBindIp) && innerPort != 0) - { - var address = NetworkHelper.ToIPEndPoint(innerBindIp, innerPort); - var serverNetworkComponent = server.Scene.AddComponent(); - serverNetworkComponent.Initialize(NetworkProtocolType.KCP, NetworkTarget.Inner, address); - } - - // 创建Server拥有所有的Scene - - foreach (var sceneConfig in sceneInfos) - { - await Scene.Create(server, sceneConfig.SceneType, sceneConfig.SceneSubType, sceneConfig.EntityId, - sceneConfig.WorldId, sceneConfig.NetworkProtocol, outerBindIp, sceneConfig.OuterPort); - } - - Servers.Add(serverConfigId, server); - return server; - } - - public static Server Get(uint serverConfigId) - { - return Servers.TryGetValue(serverConfigId, out var server) ? server : null; - } - - #endregion - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Server/Server.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Server/Server.cs.meta deleted file mode 100644 index 40072da4..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Server/Server.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c108c5f2d1cfef844b1842be027fda0d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Server/ServerConfigInfo.cs b/Assets/GameScripts/DotNet/Core/Network/Base/Server/ServerConfigInfo.cs deleted file mode 100644 index 23f18cb2..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Server/ServerConfigInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -#if TENGINE_NET -namespace TEngine; - -public class ServerConfigInfo -{ - public uint Id; - public uint MachineId; - public int InnerPort; -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/Server/ServerConfigInfo.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Base/Server/ServerConfigInfo.cs.meta deleted file mode 100644 index 6fcfb6b0..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/Server/ServerConfigInfo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 9d2ecc96f78db214fa45582d7b146b93 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/SocketExtensions.cs b/Assets/GameScripts/DotNet/Core/Network/Base/SocketExtensions.cs deleted file mode 100644 index 5b571e8f..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/SocketExtensions.cs +++ /dev/null @@ -1,53 +0,0 @@ -#if !UNITY_WEBGL -using System.Net.Sockets; - -namespace TEngine.Core.Network -{ - public static class SocketExtensions - { - public static void SetSocketBufferToOsLimit(this Socket socket) - { - socket.SetReceiveBufferToOSLimit(); - socket.SetSendBufferToOSLimit(); - } - - // 100k attempts of 1 KB increases = default + 100 MB max - public static void SetReceiveBufferToOSLimit(this Socket socket, int stepSize = 1024, int attempts = 100_000) - { - // setting a too large size throws a socket exception. - // so let's keep increasing until we encounter it. - for (int i = 0; i < attempts; ++i) - { - // increase in 1 KB steps - try - { - socket.ReceiveBufferSize += stepSize; - } - catch (SocketException) - { - break; - } - } - } - - // 100k attempts of 1 KB increases = default + 100 MB max - public static void SetSendBufferToOSLimit(this Socket socket, int stepSize = 1024, int attempts = 100_000) - { - // setting a too large size throws a socket exception. - // so let's keep increasing until we encounter it. - for (var i = 0; i < attempts; ++i) - { - // increase in 1 KB steps - try - { - socket.SendBufferSize += stepSize; - } - catch (SocketException) - { - break; - } - } - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Base/SocketExtensions.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Base/SocketExtensions.cs.meta deleted file mode 100644 index 735f50a0..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Base/SocketExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4638b4ab890780c419b527a606f0b184 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Entity.meta b/Assets/GameScripts/DotNet/Core/Network/Entity.meta deleted file mode 100644 index 62572f80..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Entity.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f9ea43e4953ac874aa8ec1c44059c396 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Entity/ClientNetworkComponent.cs b/Assets/GameScripts/DotNet/Core/Network/Entity/ClientNetworkComponent.cs deleted file mode 100644 index 939b88ba..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Entity/ClientNetworkComponent.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Net; -#pragma warning disable CS8625 -#pragma warning disable CS8618 - -namespace TEngine.Core.Network -{ - public sealed class ClientNetworkComponent : Entity - { - private AClientNetwork Network { get; set; } - public Session Session { get; private set; } - - public void Initialize(NetworkProtocolType networkProtocolType, NetworkTarget networkTarget) - { - switch (networkProtocolType) - { -#if !UNITY_WEBGL - case NetworkProtocolType.KCP: - { - Network = new KCPClientNetwork(Scene, networkTarget); - return; - } - case NetworkProtocolType.TCP: - { - Network = new TCPClientNetwork(Scene, networkTarget); - return; - } -#endif - default: - { - throw new NotSupportedException($"Unsupported NetworkProtocolType:{networkProtocolType}"); - } - } - } - - public void Connect(IPEndPoint remoteEndPoint, Action onConnectComplete, Action onConnectFail,Action onConnectDisconnect, int connectTimeout = 5000) - { - if (Network == null || Network.IsDisposed) - { - throw new NotSupportedException("Network is null or isDisposed"); - } - - Network.Connect(remoteEndPoint, onConnectComplete, onConnectFail, onConnectDisconnect, connectTimeout); - Session = Session.Create(Network); - } - - public override void Dispose() - { - if (Network != null) - { - Network.Dispose(); - Network = null; - } - - Session = null; - base.Dispose(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Entity/ClientNetworkComponent.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Entity/ClientNetworkComponent.cs.meta deleted file mode 100644 index 66c4648f..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Entity/ClientNetworkComponent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8de6a8ca9e15721489a435305757da53 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Entity/ServerNetworkComponent.cs b/Assets/GameScripts/DotNet/Core/Network/Entity/ServerNetworkComponent.cs deleted file mode 100644 index ac7ae044..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Entity/ServerNetworkComponent.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Net; -#pragma warning disable CS8625 -#pragma warning disable CS8618 - -namespace TEngine.Core.Network -{ - public sealed class ServerNetworkComponent : Entity, INotSupportedPool - { - public ANetwork Network { get; private set; } - - public void Initialize(NetworkProtocolType networkProtocolType, NetworkTarget networkTarget, IPEndPoint address) - { - switch (networkProtocolType) - { -#if !UNITY_WEBGL - case NetworkProtocolType.KCP: - { - Network = new KCPServerNetwork(Scene, networkTarget, address); - // Log.Info($"NetworkProtocol:KCP IPEndPoint:{address}"); - return; - } - case NetworkProtocolType.TCP: - { - Network = new TCPServerNetwork(Scene, networkTarget, address); - // Log.Info($"NetworkProtocol:TCP IPEndPoint:{address}"); - return; - } -#endif - default: - { - throw new NotSupportedException($"Unsupported NetworkProtocolType:{networkProtocolType}"); - } - } - } - - public override void Dispose() - { - if (Network != null) - { - Network.Dispose(); - Network = null; - } - - base.Dispose(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Entity/ServerNetworkComponent.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Entity/ServerNetworkComponent.cs.meta deleted file mode 100644 index cc8c9782..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Entity/ServerNetworkComponent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 08a60481ef8b51540b31a673aa1837e3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Entity/Session.meta b/Assets/GameScripts/DotNet/Core/Network/Entity/Session.meta deleted file mode 100644 index f9034a86..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Entity/Session.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 313e3a0020362b4408b2b68e276004e6 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Entity/Session/ServerInnerSession.cs b/Assets/GameScripts/DotNet/Core/Network/Entity/Session/ServerInnerSession.cs deleted file mode 100644 index 781d9ad4..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Entity/Session/ServerInnerSession.cs +++ /dev/null @@ -1,36 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core.Network; - -public sealed class ServerInnerSession : Session -{ - public override void Send(object message, uint rpcId = 0, long routeId = 0) - { - if (IsDisposed) - { - return; - } - - NetworkMessageScheduler.InnerScheduler(this, rpcId, routeId, ((IMessage)message).OpCode(), 0, message).Coroutine(); - } - - public override void Send(IRouteMessage routeMessage, uint rpcId = 0, long routeId = 0) - { - if (IsDisposed) - { - return; - } - - NetworkMessageScheduler.InnerScheduler(this, rpcId, routeId, routeMessage.OpCode(), routeMessage.RouteTypeOpCode(), routeMessage).Coroutine(); - } - - public override void Send(MemoryStream memoryStream, uint rpcId = 0, long routeTypeOpCode = 0, long routeId = 0) - { - throw new Exception("The use of this method is not supported"); - } - - public override FTask Call(IRequest request, long routeId = 0) - { - throw new Exception("The use of this method is not supported"); - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Entity/Session/ServerInnerSession.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Entity/Session/ServerInnerSession.cs.meta deleted file mode 100644 index e3a12b20..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Entity/Session/ServerInnerSession.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 787fbc8b90a182644abe477d98ed8939 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Entity/Session/Session.cs b/Assets/GameScripts/DotNet/Core/Network/Entity/Session/Session.cs deleted file mode 100644 index cd3d6025..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Entity/Session/Session.cs +++ /dev/null @@ -1,222 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using TEngine.Core; -#pragma warning disable CS8603 -#pragma warning disable CS8601 -#pragma warning disable CS8618 - -namespace TEngine.Core.Network -{ - public class Session : Entity, INotSupportedPool, ISupportedMultiEntity - { - private uint _rpcId; - public long NetworkId { get; private set; } - public uint ChannelId { get; private set; } - public long LastReceiveTime { get; private set; } - public ANetworkMessageScheduler NetworkMessageScheduler { get; private set;} - public static readonly Dictionary Sessions = new (); - public readonly Dictionary> RequestCallback = new(); - - public static void Create(ANetworkMessageScheduler networkMessageScheduler, ANetworkChannel channel, NetworkTarget networkTarget) - { -#if TENGINE_DEVELOP - if (ThreadSynchronizationContext.Main.ThreadId != Thread.CurrentThread.ManagedThreadId) - { - throw new NotSupportedException("Session Create not in MainThread"); - } -#endif - var session = Entity.Create(channel.Scene); - session.ChannelId = channel.Id; - session.NetworkId = channel.NetworkId; - session.NetworkMessageScheduler = networkMessageScheduler; - channel.OnDispose += session.Dispose; - channel.OnReceiveMemoryStream += session.OnReceive; -#if TENGINE_NET - if (networkTarget == NetworkTarget.Outer) - { - var interval = Define.SessionIdleCheckerInterval; - var timeOut = Define.SessionIdleCheckerTimeout; - session.AddComponent().Start(interval, timeOut); - } -#endif - Sessions.Add(session.Id, session); - } - - public static Session Create(AClientNetwork network) - { -#if TENGINE_DEVELOP - if (ThreadSynchronizationContext.Main.ThreadId != Thread.CurrentThread.ManagedThreadId) - { - throw new NotSupportedException("Session Create not in MainThread"); - } -#endif - var session = Entity.Create(network.Scene); - session.ChannelId = network.ChannelId; - session.NetworkId = network.Id; - session.NetworkMessageScheduler = network.NetworkMessageScheduler; - network.OnDispose += session.Dispose; - network.OnChangeChannelId += session.OnChangeChannelId; - network.OnReceiveMemoryStream += session.OnReceive; - Sessions.Add(session.Id, session); - return session; - } -#if TENGINE_NET - public static ServerInnerSession Create(ANetwork network) - { -#if TENGINE_DEVELOP - if (ThreadSynchronizationContext.Main.ThreadId != Thread.CurrentThread.ManagedThreadId) - { - throw new NotSupportedException("Session Create not in MainThread"); - } -#endif - var session = Entity.Create(network.Scene); - session.NetworkMessageScheduler = network.NetworkMessageScheduler; - Sessions.Add(session.Id, session); - return session; - } - - public static ServerInnerSession CreateServerInner(Scene scene) - { -#if TENGINE_DEVELOP - if (ThreadSynchronizationContext.Main.ThreadId != Thread.CurrentThread.ManagedThreadId) - { - throw new NotSupportedException("Session Create not in MainThread"); - } -#endif - var session = Entity.Create(scene, false); - Sessions.Add(session.Id, session); - return session; - } -#endif - - public static bool TryGet(long id, out Session session) - { - return Sessions.TryGetValue(id, out session); - } - - public override void Dispose() - { -#if TENGINE_DEVELOP - if (ThreadSynchronizationContext.Main.ThreadId != Thread.CurrentThread.ManagedThreadId) - { - throw new NotSupportedException("Session Create not in MainThread"); - } -#endif - if (IsDisposed) - { - return; - } - - var id = Id; - var networkId = NetworkId; - var channelId = ChannelId; - - foreach (var requestCallback in RequestCallback.Values.ToArray()) - { - requestCallback.SetException(new Exception($"session is dispose: {Id}")); - } - - if (networkId != 0 && channelId != 0) - { - NetworkThread.Instance?.SynchronizationContext.Post(() => - { - NetworkThread.Instance?.RemoveChannel(networkId, channelId); - }); - } - - this.NetworkId = 0; - this.ChannelId = 0; - base.Dispose(); - Sessions.Remove(id); -#if NETDEBUG - Log.Debug($"Sessions Dispose Count:{Sessions.Count}"); -#endif - } - - public virtual void Send(object message, uint rpcId = 0, long routeId = 0) - { - if (IsDisposed) - { - return; - } - - NetworkThread.Instance.Send(NetworkId, ChannelId, rpcId, 0, routeId, message); - } - - public virtual void Send(IRouteMessage routeMessage, uint rpcId = 0, long routeId = 0) - { - if (IsDisposed) - { - return; - } - - NetworkThread.Instance.Send(NetworkId, ChannelId, rpcId, routeMessage.RouteTypeOpCode(), routeId, routeMessage); - } - - public virtual void Send(MemoryStream memoryStream, uint rpcId = 0, long routeTypeOpCode = 0, long routeId = 0) - { - if (IsDisposed) - { - return; - } - - NetworkThread.Instance.SendStream(NetworkId, ChannelId, rpcId, routeTypeOpCode, routeId, memoryStream); - } - - public virtual FTask Call(IRequest request, long routeId = 0) - { - if (IsDisposed) - { - return null; - } - - var requestCallback = FTask.Create(); - - unchecked - { - var rpcId = ++_rpcId; - RequestCallback.Add(rpcId, requestCallback); - - if (request is IRouteMessage iRouteMessage) - { - Send(iRouteMessage, rpcId, routeId); - } - else - { - Send(request, rpcId, routeId); - } - } - - return requestCallback; - } - - private void OnReceive(APackInfo packInfo) - { - if (IsDisposed) - { - return; - } - - LastReceiveTime = TimeHelper.Now; - - try - { - NetworkMessageScheduler.Scheduler(this, packInfo).Coroutine(); - } - catch (Exception e) - { - // 如果解析失败,只有一种可能,那就是有人恶意发包。 - // 所以这里强制关闭了当前连接。不让对方一直发包。 - Dispose(); - Log.Error(e); - } - } - - private void OnChangeChannelId(uint channelId) - { - ChannelId = channelId; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Entity/Session/Session.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Entity/Session/Session.cs.meta deleted file mode 100644 index a3109a5e..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Entity/Session/Session.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0a7d60d383d04c84888fd48783813ed3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Exception.meta b/Assets/GameScripts/DotNet/Core/Network/Exception.meta deleted file mode 100644 index 3f58f1e8..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Exception.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b62e9f6a86604cf469ab9d9f47bddc5a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Exception/ScanException.cs b/Assets/GameScripts/DotNet/Core/Network/Exception/ScanException.cs deleted file mode 100644 index 9a358126..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Exception/ScanException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace TEngine.Core.Network -{ - public class ScanException : Exception - { - public ScanException() { } - - public ScanException(string msg) : base(msg) { } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Exception/ScanException.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Exception/ScanException.cs.meta deleted file mode 100644 index 505355ca..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Exception/ScanException.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8258e475fd71ff040a40766c65bd34a4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message.meta b/Assets/GameScripts/DotNet/Core/Network/Message.meta deleted file mode 100644 index d449c5f3..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4192fecfffd49194086253fef2b074f7 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable.meta deleted file mode 100644 index 1ece76c2..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: ab17a7b38d59bc84aafe2d54a2a6c834 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableHelper.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableHelper.cs deleted file mode 100644 index d1f843b3..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableHelper.cs +++ /dev/null @@ -1,103 +0,0 @@ -#if TENGINE_NET - -namespace TEngine.Core.Network -{ - public static class AddressableHelper - { - private static readonly List AddressableScenes = new List(); - - static AddressableHelper() - { - var sceneConfigInfos = ConfigTableManage.AllSceneConfig(); - - foreach (var sceneConfigInfo in sceneConfigInfos) - { - if (sceneConfigInfo.SceneTypeStr == "Addressable") - { - AddressableScenes.Add(sceneConfigInfo); - } - } - } - - public static async FTask AddAddressable(Scene scene, long addressableId, long routeId, bool isLock = true) - { - var addressableScene = AddressableScenes[(int)addressableId % AddressableScenes.Count]; - var response = await MessageHelper.CallInnerRoute(scene, addressableScene.EntityId, - new I_AddressableAdd_Request - { - AddressableId = addressableId, RouteId = routeId, IsLock = isLock - }); - if (response.ErrorCode != 0) - { - Log.Error($"AddAddressable error is {response.ErrorCode}"); - } - } - - public static async FTask GetAddressableRouteId(Scene scene, long addressableId) - { - var addressableScene = AddressableScenes[(int)addressableId % AddressableScenes.Count]; - - var response = (I_AddressableGet_Response) await MessageHelper.CallInnerRoute(scene, addressableScene.EntityId, - new I_AddressableGet_Request - { - AddressableId = addressableId - }); - - if (response.ErrorCode == 0) - { - return response.RouteId; - } - - Log.Error($"GetAddressable error is {response.ErrorCode} addressableId:{addressableId}"); - return 0; - } - - public static async FTask RemoveAddressable(Scene scene, long addressableId) - { - var addressableScene = AddressableScenes[(int)addressableId % AddressableScenes.Count]; - var response = await MessageHelper.CallInnerRoute(scene, addressableScene.EntityId, - new I_AddressableRemove_Request - { - AddressableId = addressableId - }); - - if (response.ErrorCode != 0) - { - Log.Error($"RemoveAddressable error is {response.ErrorCode}"); - } - } - - public static async FTask LockAddressable(Scene scene, long addressableId) - { - var addressableScene = AddressableScenes[(int)addressableId % AddressableScenes.Count]; - var response = await MessageHelper.CallInnerRoute(scene, addressableScene.EntityId, - new I_AddressableLock_Request - { - AddressableId = addressableId - }); - - if (response.ErrorCode != 0) - { - Log.Error($"LockAddressable error is {response.ErrorCode}"); - } - } - - public static async FTask UnLockAddressable(Scene scene, long addressableId, long routeId, string source) - { - var addressableScene = AddressableScenes[(int)addressableId % AddressableScenes.Count]; - var response = await MessageHelper.CallInnerRoute(scene, addressableScene.EntityId, - new I_AddressableUnLock_Request - { - AddressableId = addressableId, - RouteId = routeId, - Source = source - }); - - if (response.ErrorCode != 0) - { - Log.Error($"UnLockAddressable error is {response.ErrorCode}"); - } - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableHelper.cs.meta deleted file mode 100644 index 9795ecb7..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e8589a3e288b52f4e92a04053ba0c6bf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableManageComponent.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableManageComponent.cs deleted file mode 100644 index dd965e19..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableManageComponent.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TEngine.Core.Network -{ - public sealed class AddressableManageComponent : Entity - { - private readonly Dictionary _addressable = new(); - private readonly Dictionary _locks = new(); - private readonly CoroutineLockQueueType _addressableLock = new CoroutineLockQueueType("AddressableLock"); - - public async FTask Add(long addressableId, long routeId, bool isLock) - { - WaitCoroutineLock waitCoroutineLock = null; - - try - { - if (isLock) - { - waitCoroutineLock = await _addressableLock.Lock(addressableId); - } - - _addressable[addressableId] = routeId; - Log.Debug($"AddressableManageComponent Add addressableId:{addressableId} routeId:{routeId}"); - } - catch (Exception e) - { - Log.Error(e); - } - finally - { - waitCoroutineLock?.Dispose(); - } - } - - public async FTask Get(long addressableId) - { - using (await _addressableLock.Lock(addressableId)) - { - _addressable.TryGetValue(addressableId, out var routeId); - return routeId; - } - } - - public async FTask Remove(long addressableId) - { - using (await _addressableLock.Lock(addressableId)) - { - _addressable.Remove(addressableId); - Log.Debug($"Addressable Remove addressableId: {addressableId} _addressable:{_addressable.Count}"); - } - } - - public async FTask Lock(long addressableId) - { - var waitCoroutineLock = await _addressableLock.Lock(addressableId); - _locks.Add(addressableId, waitCoroutineLock); - } - - public void UnLock(long addressableId, long routeId, string source) - { - if (!_locks.Remove(addressableId, out var coroutineLock)) - { - Log.Error($"Addressable unlock not found addressableId: {addressableId} Source:{source}"); - return; - } - - _addressable.TryGetValue(addressableId, out var oldAddressableId); - - if (routeId != 0) - { - _addressable[addressableId] = routeId; - } - - coroutineLock.Dispose(); - Log.Debug($"Addressable UnLock key: {addressableId} oldAddressableId : {oldAddressableId} routeId: {routeId} Source:{source}"); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableManageComponent.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableManageComponent.cs.meta deleted file mode 100644 index db9a6e28..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableManageComponent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e946a97e041db3b4f89af34ac9914098 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableMessageComponent.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableMessageComponent.cs deleted file mode 100644 index d18761e9..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableMessageComponent.cs +++ /dev/null @@ -1,59 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core.Network -{ - /// - /// 可寻址消息组件、挂载了这个组件可以接收Addressable消息 - /// - public sealed class AddressableMessageComponent : Entity - { - public long AddressableId; - - public override void Dispose() - { - if (AddressableId != 0) - { - AddressableHelper.RemoveAddressable(Scene, AddressableId).Coroutine(); - AddressableId = 0; - } - - base.Dispose(); - } - - public FTask Register(bool isLock = true) - { - if (Parent == null) - { - throw new Exception("AddressableRouteComponent must be mounted under a component"); - } - - AddressableId = Parent.Id; - - if (AddressableId == 0) - { - throw new Exception("AddressableRouteComponent.Parent.Id is null"); - } - -#if TENGINE_DEVELOP - Log.Debug($"AddressableMessageComponent Register addressableId:{AddressableId} RouteId:{Parent.RuntimeId}"); -#endif - return AddressableHelper.AddAddressable(Scene, AddressableId, Parent.RuntimeId, isLock); - } - - public FTask Lock() - { -#if TENGINE_DEVELOP - Log.Debug($"AddressableMessageComponent Lock {Parent.Id}"); -#endif - return AddressableHelper.LockAddressable(Scene, Parent.Id); - } - - public FTask UnLock(string source) - { -#if TENGINE_DEVELOP - Log.Debug($"AddressableMessageComponent UnLock {Parent.Id} {Parent.RuntimeId}"); -#endif - return AddressableHelper.UnLockAddressable(Scene, Parent.Id, Parent.RuntimeId, source); - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableMessageComponent.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableMessageComponent.cs.meta deleted file mode 100644 index 6d62194a..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableMessageComponent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: be31fb4b0e977f347837b7b6b6b840d5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableRouteComponent.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableRouteComponent.cs deleted file mode 100644 index 83b8ae47..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableRouteComponent.cs +++ /dev/null @@ -1,167 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core.Network; - -/// -/// 可寻址消息组件、挂载了这个组件可以接收和发送Addressable消息 -/// -public sealed class AddressableRouteComponent : Entity -{ - private long _routeId; - public long AddressableId { get; private set; } - - public static readonly CoroutineLockQueueType AddressableRouteMessageLock = new CoroutineLockQueueType("AddressableRouteMessageLock"); - - public override void Dispose() - { - _routeId = 0; - this.AddressableId = 0; - base.Dispose(); - } - - public void SetAddressableId(long addressableId) - { - this.AddressableId = addressableId; - } - - public void Send(IAddressableRouteMessage message) - { - Call(message).Coroutine(); - } - - public void Send(long routeTypeOpCode, Type requestType, MemoryStream message) - { - Call(routeTypeOpCode, requestType, message).Coroutine(); - } - - public async FTask Call(long routeTypeOpCode, Type requestType, MemoryStream request) - { - if (IsDisposed) - { - return MessageDispatcherSystem.Instance.CreateResponse(requestType, CoreErrorCode.ErrNotFoundRoute); - } - - var failCount = 0; - var runtimeId = RuntimeId; - IResponse iRouteResponse = null; - - using (await AddressableRouteMessageLock.Lock(this.AddressableId, "AddressableRouteComponent Call MemoryStream")) - { - while (!IsDisposed) - { - if (_routeId == 0) - { - _routeId = await AddressableHelper.GetAddressableRouteId(Scene, this.AddressableId); - } - - if (_routeId == 0) - { - return MessageDispatcherSystem.Instance.CreateResponse(requestType, CoreErrorCode.ErrNotFoundRoute); - } - - iRouteResponse = await MessageHelper.CallInnerRoute(Scene, _routeId, routeTypeOpCode, requestType, request); - - if (runtimeId != RuntimeId) - { - iRouteResponse.ErrorCode = CoreErrorCode.ErrRouteTimeout; - } - - switch (iRouteResponse.ErrorCode) - { - case CoreErrorCode.ErrRouteTimeout: - { - return iRouteResponse; - } - case CoreErrorCode.ErrNotFoundRoute: - { - if (++failCount > 20) - { - Log.Error($"AddressableComponent.Call failCount > 20 route send message fail, routeId: {_routeId} AddressableRouteComponent:{Id}"); - return iRouteResponse; - } - - await TimerScheduler.Instance.Core.WaitAsync(500); - - if (runtimeId != RuntimeId) - { - iRouteResponse.ErrorCode = CoreErrorCode.ErrRouteTimeout; - } - - _routeId = 0; - continue; - } - default: - { - return iRouteResponse; - } - } - } - } - - return iRouteResponse; - } - - public async FTask Call(IAddressableRouteMessage request) - { - if (IsDisposed) - { - return MessageDispatcherSystem.Instance.CreateResponse(request, CoreErrorCode.ErrNotFoundRoute); - } - - var failCount = 0; - var runtimeId = RuntimeId; - - using (await AddressableRouteMessageLock.Lock(this.AddressableId,"AddressableRouteComponent Call")) - { - while (true) - { - if (_routeId == 0) - { - _routeId = await AddressableHelper.GetAddressableRouteId(Scene, this.AddressableId); - } - - if (_routeId == 0) - { - return MessageDispatcherSystem.Instance.CreateResponse(request, CoreErrorCode.ErrNotFoundRoute); - } - - var iRouteResponse = await MessageHelper.CallInnerRoute(Scene, _routeId, request); - - if (runtimeId != RuntimeId) - { - iRouteResponse.ErrorCode = CoreErrorCode.ErrRouteTimeout; - } - - switch (iRouteResponse.ErrorCode) - { - case CoreErrorCode.ErrNotFoundRoute: - { - if (++failCount > 20) - { - Log.Error($"AddressableRouteComponent.Call failCount > 20 route send message fail, routeId: {_routeId} AddressableRouteComponent:{Id}"); - return iRouteResponse; - } - - await TimerScheduler.Instance.Core.WaitAsync(500); - - if (runtimeId != RuntimeId) - { - iRouteResponse.ErrorCode = CoreErrorCode.ErrRouteTimeout; - } - - _routeId = 0; - continue; - } - case CoreErrorCode.ErrRouteTimeout: - { - return iRouteResponse; - } - default: - { - return iRouteResponse; - } - } - } - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableRouteComponent.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableRouteComponent.cs.meta deleted file mode 100644 index 329d7751..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/AddressableRouteComponent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 897c9af3c45fd8e429f8a851eb1b8aab -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler.meta deleted file mode 100644 index b02da368..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 09bf59c6e0e10e644aa18a17e8a305e8 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableAddHandler.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableAddHandler.cs deleted file mode 100644 index 03bde8af..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableAddHandler.cs +++ /dev/null @@ -1,11 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core.Network; - -public sealed class I_AddressableAddHandler : RouteRPC -{ - protected override async FTask Run(Scene scene, I_AddressableAdd_Request request, I_AddressableAdd_Response response, Action reply) - { - await scene.GetComponent().Add(request.AddressableId, request.RouteId, request.IsLock); - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableAddHandler.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableAddHandler.cs.meta deleted file mode 100644 index 223efc26..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableAddHandler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 974e720fa811f47418b83d5b3ffdd41c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableGetHandler.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableGetHandler.cs deleted file mode 100644 index 849228b3..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableGetHandler.cs +++ /dev/null @@ -1,11 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core.Network; - -public sealed class I_AddressableGetHandler : RouteRPC -{ - protected override async FTask Run(Scene scene, I_AddressableGet_Request request, I_AddressableGet_Response response, Action reply) - { - response.RouteId = await scene.GetComponent().Get(request.AddressableId); - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableGetHandler.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableGetHandler.cs.meta deleted file mode 100644 index 7deb2d8c..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableGetHandler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 24a968aef62bae54f9fef9bc39b94959 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableLockHandler.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableLockHandler.cs deleted file mode 100644 index 297a2187..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableLockHandler.cs +++ /dev/null @@ -1,11 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core.Network; - -public sealed class I_AddressableLockHandler : RouteRPC -{ - protected override async FTask Run(Scene scene, I_AddressableLock_Request request, I_AddressableLock_Response response, Action reply) - { - await scene.GetComponent().Lock(request.AddressableId); - } -} -#endif diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableLockHandler.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableLockHandler.cs.meta deleted file mode 100644 index e6a38cff..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableLockHandler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 95e84c7e22ea5f047a3c524d8472e967 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableRemoveHandler.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableRemoveHandler.cs deleted file mode 100644 index 9cf5b6ae..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableRemoveHandler.cs +++ /dev/null @@ -1,11 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core.Network; - -public sealed class I_AddressableRemoveHandler : RouteRPC -{ - protected override async FTask Run(Scene scene, I_AddressableRemove_Request request, I_AddressableRemove_Response response, Action reply) - { - await scene.GetComponent().Remove(request.AddressableId); - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableRemoveHandler.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableRemoveHandler.cs.meta deleted file mode 100644 index 70cf5b3a..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableRemoveHandler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 660cdf9f50994c94182e3a64c569da85 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableUnLockHandler.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableUnLockHandler.cs deleted file mode 100644 index b86c5854..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableUnLockHandler.cs +++ /dev/null @@ -1,12 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core.Network; - -public sealed class I_AddressableUnLockHandler : RouteRPC -{ - protected override async FTask Run(Scene scene, I_AddressableUnLock_Request request, I_AddressableUnLock_Response response, Action reply) - { - scene.GetComponent().UnLock(request.AddressableId, request.RouteId, request.Source); - await FTask.CompletedTask; - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableUnLockHandler.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableUnLockHandler.cs.meta deleted file mode 100644 index 9d816cf6..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Addressable/Handler/I_AddressableUnLockHandler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c4b465b4daeb9d7498cf33409ee72662 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher.meta deleted file mode 100644 index 88457117..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 77c1999fe41f3b743a8df80748ece7e4 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/MessageDispatcherSystem.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/MessageDispatcherSystem.cs deleted file mode 100644 index db2cabf6..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/MessageDispatcherSystem.cs +++ /dev/null @@ -1,287 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using TEngine.DataStructure; -using TEngine.Core; -using Type = System.Type; -#pragma warning disable CS8602 -#pragma warning disable CS8600 -#pragma warning disable CS8618 - -// ReSharper disable PossibleNullReferenceException - -namespace TEngine.Core.Network -{ - public sealed class HandlerInfo - { - public T Obj; - public Type Type; - } - - public sealed class MessageDispatcherSystem : Singleton - { - private readonly Dictionary _responseTypes = new Dictionary(); - private readonly DoubleMapDictionary _networkProtocols = new DoubleMapDictionary(); - private readonly Dictionary _messageHandlers = new Dictionary(); - - private readonly OneToManyList _assemblyResponseTypes = new OneToManyList(); - private readonly OneToManyList _assemblyNetworkProtocols = new OneToManyList(); - private readonly OneToManyList> _assemblyMessageHandlers = new OneToManyList>(); - -#if TENGINE_NET - private readonly Dictionary _routeMessageHandlers = new Dictionary(); - private readonly OneToManyList> _assemblyRouteMessageHandlers= new OneToManyList>(); -#endif - private static readonly CoroutineLockQueueType ReceiveRouteMessageLock = new CoroutineLockQueueType("ReceiveRouteMessageLock"); - -#if TENGINE_UNITY - - public readonly Dictionary>> MsgHandles = new Dictionary>>(); - - public void RegisterMsgHandler(uint protocolCode,Action ctx) - { - if (!MsgHandles.ContainsKey(protocolCode)) - { - MsgHandles[protocolCode] = new List>(); - } - MsgHandles[protocolCode].Add(ctx); - } - - public void UnRegisterMsgHandler(uint protocolCode,Action ctx) - { - if (MsgHandles.TryGetValue(protocolCode, out var handle)) - { - handle.Remove(ctx); - } - } -#endif - - protected override void OnLoad(int assemblyName) - { - foreach (var type in AssemblyManager.ForEach(assemblyName, typeof(IMessage))) - { - var obj = (IMessage) Activator.CreateInstance(type); - var opCode = obj.OpCode(); - - _networkProtocols.Add(opCode, type); - - var responseType = type.GetProperty("ResponseType"); - - if (responseType != null) - { - _responseTypes.Add(type, responseType.PropertyType); - _assemblyResponseTypes.Add(assemblyName, type); - } - - _assemblyNetworkProtocols.Add(assemblyName, opCode); - } - - foreach (var type in AssemblyManager.ForEach(assemblyName, typeof(IMessageHandler))) - { - var obj = (IMessageHandler) Activator.CreateInstance(type); - - if (obj == null) - { - throw new Exception($"message handle {type.Name} is null"); - } - - var key = obj.Type(); - _messageHandlers.Add(key, obj); - _assemblyMessageHandlers.Add(assemblyName, new HandlerInfo() - { - Obj = obj, Type = key - }); - } -#if TENGINE_NET - foreach (var type in AssemblyManager.ForEach(assemblyName, typeof(IRouteMessageHandler))) - { - var obj = (IRouteMessageHandler) Activator.CreateInstance(type); - - if (obj == null) - { - throw new Exception($"message handle {type.Name} is null"); - } - - var key = obj.Type(); - _routeMessageHandlers.Add(key, obj); - _assemblyRouteMessageHandlers.Add(assemblyName, new HandlerInfo() - { - Obj = obj, Type = key - }); - } -#endif - } - - protected override void OnUnLoad(int assemblyName) - { - if (_assemblyResponseTypes.TryGetValue(assemblyName, out var removeResponseTypes)) - { - foreach (var removeResponseType in removeResponseTypes) - { - _responseTypes.Remove(removeResponseType); - } - - _assemblyResponseTypes.RemoveByKey(assemblyName); - } - - if (_assemblyNetworkProtocols.TryGetValue(assemblyName, out var removeNetworkProtocols)) - { - foreach (var removeNetworkProtocol in removeNetworkProtocols) - { - _networkProtocols.RemoveByKey(removeNetworkProtocol); - } - - _assemblyNetworkProtocols.RemoveByKey(assemblyName); - } - - if (_assemblyMessageHandlers.TryGetValue(assemblyName, out var removeMessageHandlers)) - { - foreach (var removeMessageHandler in removeMessageHandlers) - { - _messageHandlers.Remove(removeMessageHandler.Type); - } - - _assemblyMessageHandlers.Remove(assemblyName); - } -#if TENGINE_NET - if (_assemblyRouteMessageHandlers.TryGetValue(assemblyName, out var removeRouteMessageHandlers)) - { - foreach (var removeRouteMessageHandler in removeRouteMessageHandlers) - { - _routeMessageHandlers.Remove(removeRouteMessageHandler.Type); - } - - _assemblyRouteMessageHandlers.Remove(assemblyName); - } -#endif - } - - public void MessageHandler(Session session, Type type, object message, uint rpcId, uint protocolCode) - { - if (!_messageHandlers.TryGetValue(type, out var messageHandler)) - { - Log.Warning($"Scene:{session.Scene.Id} Found Unhandled Message: {message.GetType()}"); - return; - } - - messageHandler.Handle(session, rpcId, protocolCode, message).Coroutine(); - } -#if TENGINE_NET - public async FTask RouteMessageHandler(Session session, Type type, Entity entity, object message, uint rpcId) - { - if (!_routeMessageHandlers.TryGetValue(type, out var routeMessageHandler)) - { - Log.Warning($"Scene:{session.Scene.Id} Found Unhandled RouteMessage: {message.GetType()}"); - - if (message is IRouteRequest request) - { - FailResponse(session, request, CoreErrorCode.Error_NotFindEntity, rpcId); - } - - return; - } - - var runtimeId = entity.RuntimeId; - var sessionRuntimeId = session.RuntimeId; - - if (entity is Scene) - { - // 如果是Scene的话、就不要加锁了、如果加锁很一不小心就可能会造成死锁 - await routeMessageHandler.Handle(session, entity, rpcId, message); - return; - } - - using (await ReceiveRouteMessageLock.Lock(runtimeId)) - { - if (sessionRuntimeId != session.RuntimeId) - { - return; - } - - if (runtimeId != entity.RuntimeId) - { - if (message is IRouteRequest request) - { - FailResponse(session, request, CoreErrorCode.Error_NotFindEntity, rpcId); - } - - return; - } - - await routeMessageHandler.Handle(session, entity, rpcId, message); - } - } -#endif - public void FailResponse(Session session, IRouteRequest iRouteRequest, uint error, uint rpcId) - { - var response = CreateResponse(iRouteRequest, error); - session.Send(response, rpcId); - } - - public IRouteResponse CreateRouteResponse() - { - return new RouteResponse(); - } - - public IResponse CreateResponse(Type requestType, uint error) - { - IResponse response; - - if (_responseTypes.TryGetValue(requestType, out var responseType)) - { - response = (IResponse) Activator.CreateInstance(responseType); - } - else - { - response = new Response(); - } - - response.ErrorCode = error; - return response; - } - - public IResponse CreateResponse(IRequest iRequest, uint error) - { - IResponse response; - - if (_responseTypes.TryGetValue(iRequest.GetType(), out var responseType)) - { - response = (IResponse) Activator.CreateInstance(responseType); - } - else - { - response = new Response(); - } - - response.ErrorCode = error; - return response; - } - - public IRouteResponse CreateResponse(IRouteRequest iRouteRequest, uint error) - { - IRouteResponse response; - - if (_responseTypes.TryGetValue(iRouteRequest.GetType(), out var responseType)) - { - response = (IRouteResponse) Activator.CreateInstance(responseType); - } - else - { - response = new RouteResponse(); - } - - response.ErrorCode = error; - return response; - } - - public uint GetOpCode(Type type) - { - return _networkProtocols.GetKeyByValue(type); - } - - public Type GetOpCodeType(uint code) - { - return _networkProtocols.GetValueByKey(code); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/MessageDispatcherSystem.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/MessageDispatcherSystem.cs.meta deleted file mode 100644 index e4ecc6fd..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/MessageDispatcherSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d6c1581e1f459cc4295685cafaa63dd4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/Opcode.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/Opcode.cs deleted file mode 100644 index 02693621..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/Opcode.cs +++ /dev/null @@ -1,50 +0,0 @@ -namespace TEngine.Core.Network -{ - public static class Opcode - { - // 外网消息 - public const uint OuterMessage = 100000000; - public const uint OuterRequest = 110000000; - // 内网消息 - public const uint InnerMessage = 120000000; - public const uint InnerRequest = 130000000; - // 内网Bson消息 - public const uint InnerBsonMessage = 140000000; - public const uint InnerBsonRequest = 150000000; - // 回复消息 - public const uint OuterResponse = 160000000; - public const uint InnerResponse = 170000000; - public const uint InnerBsonResponse = 180000000; - // 外网路由消息 - public const uint OuterRouteMessage = 190000000; - public const uint OuterRouteRequest = 200000000; - // 内网路由消息 - public const uint InnerRouteMessage = 210000000; - public const uint InnerRouteRequest = 220000000; - // 内网Bson路由消息 - public const uint InnerBsonRouteMessage = 230000000; - public const uint InnerBsonRouteRequest = 240000000; - // 路由回复消息 - public const uint OuterRouteResponse = 250000000; - public const uint InnerRouteResponse = 260000000; - public const uint InnerBsonRouteResponse = 270000000; - // 心跳消息 - public const uint PingRequest = 1; - public const uint PingResponse = 2; - // 默认回复消息 - public const uint DefaultResponse = 3; - // Addressable可寻址消息 - public const uint AddressableAddRequest = InnerRouteRequest + 1; - public const uint AddressableAddResponse = InnerRouteResponse + 1; - public const uint AddressableGetRequest = InnerRouteRequest + 2; - public const uint AddressableGetResponse = InnerRouteResponse + 2; - public const uint AddressableRemoveRequest = InnerRouteRequest + 3; - public const uint AddressableRemoveResponse = InnerRouteResponse + 3; - public const uint AddressableLockRequest = InnerRouteRequest + 4; - public const uint AddressableLockResponse = InnerRouteResponse + 4; - public const uint AddressableUnLockRequest = InnerRouteRequest + 5; - public const uint AddressableUnLockResponse = InnerRouteResponse + 5; - // 默认的Route返回消息 - public const uint DefaultRouteResponse = InnerRouteResponse + 6; - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/Opcode.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/Opcode.cs.meta deleted file mode 100644 index 2d38bdee..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/Opcode.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6b40c482be660ad4090888728af062ad -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/Response.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/Response.cs deleted file mode 100644 index 78eb7bc8..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/Response.cs +++ /dev/null @@ -1,6 +0,0 @@ -using ProtoBuf; - -namespace TEngine.Core.Network -{ - -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/Response.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/Response.cs.meta deleted file mode 100644 index 0030966e..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Dispatcher/Response.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8516b2b12ce77fb488b1b973adc680f0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Interface.meta deleted file mode 100644 index 3637cda8..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e639a64f385d7164799d03a031c3fabb -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler.meta deleted file mode 100644 index c9a7acc9..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: db5ee92b41263e2478cfb3dbb35e0ccf -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler/IMessageHandler.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler/IMessageHandler.cs deleted file mode 100644 index 8dcb4fd7..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler/IMessageHandler.cs +++ /dev/null @@ -1,87 +0,0 @@ -// ReSharper disable InconsistentNaming - -using System; - -namespace TEngine.Core.Network -{ - public interface IMessageHandler - { - public Type Type(); - FTask Handle(Session session, uint rpcId, uint messageTypeCode, object message); - } - - public abstract class Message : IMessageHandler - { - public Type Type() - { - return typeof(T); - } - - public async FTask Handle(Session session, uint rpcId, uint messageTypeCode, object message) - { - try - { - await Run(session, (T) message); - } - catch (Exception e) - { - Log.Error(e); - } - } - - protected abstract FTask Run(Session session, T message); - } - - public abstract class MessageRPC : IMessageHandler where TRequest : IRequest where TResponse : IResponse - { - public Type Type() - { - return typeof(TRequest); - } - - public async FTask Handle(Session session, uint rpcId, uint messageTypeCode, object message) - { - if (message is not TRequest request) - { - Log.Error($"消息类型转换错误: {message.GetType().Name} to {typeof(TRequest).Name}"); - return; - } - - var response = Activator.CreateInstance(); - var isReply = false; - - void Reply() - { - if (isReply) - { - return; - } - - isReply = true; - - if (session.IsDisposed) - { - return; - } - - session.Send(response, rpcId); - } - - try - { - await Run(session, request, response, Reply); - } - catch (Exception e) - { - Log.Error(e); - response.ErrorCode = CoreErrorCode.ErrRpcFail; - } - finally - { - Reply(); - } - } - - protected abstract FTask Run(Session session, TRequest request, TResponse response, Action reply); - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler/IMessageHandler.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler/IMessageHandler.cs.meta deleted file mode 100644 index 49aac094..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler/IMessageHandler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d0e1cb825e8847a479ac69acee8f0bb6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler/IRouteMessageHandler.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler/IRouteMessageHandler.cs deleted file mode 100644 index edfc26ce..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler/IRouteMessageHandler.cs +++ /dev/null @@ -1,222 +0,0 @@ -#if TENGINE_NET -// ReSharper disable InconsistentNaming - -namespace TEngine.Core.Network -{ - public interface IRouteMessageHandler - { - public Type Type(); - FTask Handle(Session session, Entity entity, uint rpcId, object routeMessage); - } - - public abstract class Route : IRouteMessageHandler where TEntity : Entity where TMessage : IRouteMessage - { - public Type Type() - { - return typeof(TMessage); - } - - public async FTask Handle(Session session, Entity entity, uint rpcId, object routeMessage) - { - if (routeMessage is not TMessage ruteMessage) - { - Log.Error($"Message type conversion error: {routeMessage.GetType().FullName} to {typeof(TMessage).Name}"); - return; - } - - if (entity is not TEntity tEntity) - { - Log.Error($"Route type conversion error: {entity.GetType().Name} to {nameof(TEntity)}"); - return; - } - - try - { - await Run(tEntity, ruteMessage); - } - catch (Exception e) - { - if (entity is not Scene scene) - { - scene = entity.Scene; - } - - Log.Error($"SceneWorld:{session.Scene.World.Id} ServerConfigId:{scene.Server?.Id} SceneType:{scene.SceneType} EntityId {tEntity.Id} : Error {e}"); - } - } - - protected abstract FTask Run(TEntity entity, TMessage message); - } - - public abstract class RouteRPC : IRouteMessageHandler where TEntity : Entity where TRouteRequest : IRouteRequest where TRouteResponse : IRouteResponse - { - public Type Type() - { - return typeof(TRouteRequest); - } - - public async FTask Handle(Session session, Entity entity, uint rpcId, object routeMessage) - { - if (routeMessage is not TRouteRequest tRouteRequest) - { - Log.Error($"Message type conversion error: {routeMessage.GetType().FullName} to {typeof(TRouteRequest).Name}"); - return; - } - - if (entity is not TEntity tEntity) - { - Log.Error($"Route type conversion error: {entity.GetType().Name} to {nameof(TEntity)}"); - return; - } - - var isReply = false; - var response = Activator.CreateInstance(); - - void Reply() - { - if (isReply) - { - return; - } - - isReply = true; - - if (session.IsDisposed) - { - return; - } - - session.Send(response, rpcId); - } - - try - { - await Run(tEntity, tRouteRequest, response, Reply); - } - catch (Exception e) - { - if (entity is not Scene scene) - { - scene = entity.Scene; - } - - Log.Error($"SceneWorld:{session.Scene.World?.Id} ServerConfigId:{scene.Server?.Id} SceneType:{scene.SceneType} EntityId {tEntity.Id} : Error {e}"); - response.ErrorCode = CoreErrorCode.ErrRpcFail; - } - finally - { - Reply(); - } - } - - protected abstract FTask Run(TEntity entity, TRouteRequest request, TRouteResponse response, Action reply); - } - - public abstract class Addressable : IRouteMessageHandler where TEntity : Entity where TMessage : IAddressableRouteMessage - { - public Type Type() - { - return typeof(TMessage); - } - - public async FTask Handle(Session session, Entity entity, uint rpcId, object routeMessage) - { - if (routeMessage is not TMessage ruteMessage) - { - Log.Error($"Message type conversion error: {routeMessage.GetType().FullName} to {typeof(TMessage).Name}"); - return; - } - - if (entity is not TEntity tEntity) - { - Log.Error($"Route type conversion error: {entity.GetType().Name} to {nameof(TEntity)}"); - return; - } - - try - { - await Run(tEntity, ruteMessage); - } - catch (Exception e) - { - if (entity is not Scene scene) - { - scene = entity.Scene; - } - - Log.Error($"SceneWorld:{session.Scene.World.Id} ServerConfigId:{scene.Server?.Id} SceneType:{scene.SceneType} EntityId {tEntity.Id} : Error {e}"); - } - finally - { - session.Send(MessageDispatcherSystem.Instance.CreateRouteResponse(), rpcId); - } - } - - protected abstract FTask Run(TEntity entity, TMessage message); - } - - public abstract class AddressableRPC : IRouteMessageHandler where TEntity : Entity where TRouteRequest : IAddressableRouteRequest where TRouteResponse : IAddressableRouteResponse - { - public Type Type() - { - return typeof(TRouteRequest); - } - - public async FTask Handle(Session session, Entity entity, uint rpcId, object routeMessage) - { - if (routeMessage is not TRouteRequest tRouteRequest) - { - Log.Error($"Message type conversion error: {routeMessage.GetType().FullName} to {typeof(TRouteRequest).Name}"); - return; - } - - if (entity is not TEntity tEntity) - { - Log.Error($"Route type conversion error: {entity.GetType().Name} to {nameof(TEntity)}"); - return; - } - - var isReply = false; - var response = Activator.CreateInstance(); - - void Reply() - { - if (isReply) - { - return; - } - - isReply = true; - - if (session.IsDisposed) - { - return; - } - - session.Send(response, rpcId); - } - - try - { - await Run(tEntity, tRouteRequest, response, Reply); - } - catch (Exception e) - { - if (entity is not Scene scene) - { - scene = entity.Scene; - } - - Log.Error($"SceneWorld:{session.Scene.World?.Id} ServerConfigId:{scene.Server?.Id} SceneType:{scene.SceneType} EntityId {tEntity.Id} : Error {e}"); - response.ErrorCode = CoreErrorCode.ErrRpcFail; - } - finally - { - Reply(); - } - } - - protected abstract FTask Run(TEntity entity, TRouteRequest request, TRouteResponse response, Action reply); - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler/IRouteMessageHandler.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler/IRouteMessageHandler.cs.meta deleted file mode 100644 index 119addb6..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Handler/IRouteMessageHandler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a6de532c5ce565747817a22793fb85c0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol.meta deleted file mode 100644 index 0a08e51c..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4767a374666197f4ab971d74378a5040 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IBsonMessage.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IBsonMessage.cs deleted file mode 100644 index 5aab02be..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IBsonMessage.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace TEngine.Core.Network -{ - public interface IBsonMessage : IMessage - { - - } - - public interface IBsonRequest : IBsonMessage, IRequest - { - - } - - public interface IBsonResponse : IBsonMessage, IResponse - { - - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IBsonMessage.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IBsonMessage.cs.meta deleted file mode 100644 index 0c96d820..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IBsonMessage.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: cb1d2907b6893e643b0f5c4644b412d1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IMessage.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IMessage.cs deleted file mode 100644 index ccfb55ab..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IMessage.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace TEngine.Core.Network -{ - public interface IMessage - { - uint OpCode(); - } - - public interface IRequest : IMessage - { - - } - - public interface IResponse : IMessage - { - uint ErrorCode { get; set; } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IMessage.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IMessage.cs.meta deleted file mode 100644 index 325caa10..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IMessage.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e0828643e6b72684fb0e4917cef34b97 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IRouteMessage.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IRouteMessage.cs deleted file mode 100644 index 9eb9429d..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IRouteMessage.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace TEngine.Core.Network -{ - // 普通路由消息 - public interface IRouteMessage : IRequest - { - long RouteTypeOpCode(); - } - public interface IRouteRequest : IRouteMessage { } - public interface IRouteResponse : IResponse { } - // 普通路由Bson消息 - public interface IBsonRouteMessage : IBsonMessage, IRouteMessage { } - public interface IBsonRouteRequest : IBsonRouteMessage, IRouteRequest { } - public interface IBsonRouteResponse : IBsonResponse, IRouteResponse { } - // 可寻址协议 - public interface IAddressableRouteMessage : IRouteMessage { } - public interface IAddressableRouteRequest : IRouteRequest { } - public interface IAddressableRouteResponse : IRouteResponse { } - // 可寻址Bson协议 - public interface IBsonAddressableRouteMessage : IBsonMessage, IAddressableRouteMessage { } - public interface IBsonAddressableRouteRequest : IBsonRouteMessage, IAddressableRouteRequest { } - public interface IBsonAddressableRouteResponse : IBsonResponse, IAddressableRouteResponse { } - // 自定义Route协议 - public interface ICustomRouteMessage : IRouteMessage { } - public interface ICustomRouteRequest : IRouteRequest { } - public interface ICustomRouteResponse : IRouteResponse { } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IRouteMessage.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IRouteMessage.cs.meta deleted file mode 100644 index cd1aa99e..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Protocol/IRouteMessage.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0d836956c7e220f4d945807e0fd90c1c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler.meta deleted file mode 100644 index b25478c1..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e8ff64952cfa44645a9410738b63d26b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler/ANetworkMessageScheduler.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler/ANetworkMessageScheduler.cs deleted file mode 100644 index e7a4586b..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler/ANetworkMessageScheduler.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using System.IO; - -namespace TEngine.Core.Network -{ - public abstract class ANetworkMessageScheduler - { - protected bool DisposePackInfo; - private readonly PingResponse _pingResponse = new PingResponse(); - - public async FTask Scheduler(Session session, APackInfo packInfo) - { - Type messageType = null; - DisposePackInfo = true; - - try - { - if (session.IsDisposed) - { - return; - } - - if (packInfo.ProtocolCode == Opcode.PingRequest) - { - _pingResponse.Now = TimeHelper.Now; - session.Send(_pingResponse, packInfo.RpcId); - return; - } - - messageType = MessageDispatcherSystem.Instance.GetOpCodeType(packInfo.ProtocolCode); - - if (messageType == null) - { - throw new Exception($"可能遭受到恶意发包或没有协议定义ProtocolCode ProtocolCode:{packInfo.ProtocolCode}"); - } - - switch (packInfo.ProtocolCode) - { - case Opcode.PingResponse: - case >= Opcode.OuterRouteMessage: - { - await Handler(session, messageType, packInfo); - return; - } - case < Opcode.OuterResponse: - { - var message = packInfo.Deserialize(messageType); - MessageDispatcherSystem.Instance.MessageHandler(session, messageType, message, packInfo.RpcId, packInfo.ProtocolCode); - return; - } - default: - { - var aResponse = (IResponse)packInfo.Deserialize(messageType); -#if TENGINE_NET - // 服务器之间发送消息因为走的是MessageHelper、所以接收消息的回调也应该放到MessageHelper里处理 - MessageHelper.ResponseHandler(packInfo.RpcId, aResponse); -#else - // 这个一般是客户端Session.Call发送时使用的、目前这个逻辑只有Unity客户端时使用 - - if (!session.RequestCallback.TryGetValue(packInfo.RpcId, out var action)) - { - Log.Error($"not found rpc {packInfo.RpcId}, response message: {aResponse.GetType().Name}"); - return; - } - - session.RequestCallback.Remove(packInfo.RpcId); - action.SetResult(aResponse); -#endif - return; - } - } - } - catch (Exception e) - { - Log.Error($"NetworkMessageScheduler error messageProtocolCode:{packInfo.ProtocolCode} messageType:{messageType} SessionId {session.Id} IsDispose {session.IsDisposed} {e}"); - } - finally - { - if (DisposePackInfo) - { - NetworkThread.Instance.SynchronizationContext.Post(packInfo.Dispose); - } - } - } - - public async FTask InnerScheduler(Session session, uint rpcId, long routeId, uint protocolCode, long routeTypeCode, object message) - { - var messageType = message.GetType(); - - try - { - if (session.IsDisposed) - { - return; - } - - switch (protocolCode) - { - case >= Opcode.OuterRouteMessage: - { - await InnerHandler(session, rpcId, routeId, protocolCode, routeTypeCode, messageType, message); - return; - } - case < Opcode.OuterResponse: - { - MessageDispatcherSystem.Instance.MessageHandler(session, messageType, message, rpcId, protocolCode); - return; - } - default: - { -#if TENGINE_NET - // 服务器之间发送消息因为走的是MessageHelper、所以接收消息的回调也应该放到MessageHelper里处理 - MessageHelper.ResponseHandler(rpcId, (IResponse)message); -#endif - return; - } - } - } - catch (Exception e) - { - Log.Error($"NetworkMessageScheduler error messageProtocolCode:{protocolCode} messageType:{messageType} SessionId {session.Id} IsDispose {session.IsDisposed} {e}"); - } - } - - protected abstract FTask Handler(Session session, Type messageType, APackInfo packInfo); - protected abstract FTask InnerHandler(Session session, uint rpcId, long routeId, uint protocolCode, long routeTypeCode, Type messageType, object message); - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler/ANetworkMessageScheduler.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler/ANetworkMessageScheduler.cs.meta deleted file mode 100644 index 629d2dc2..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler/ANetworkMessageScheduler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b71e62d5efece8a408fc90048164af53 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler/INetworkMessageSchedulerHandler.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler/INetworkMessageSchedulerHandler.cs deleted file mode 100644 index 2866f1da..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler/INetworkMessageSchedulerHandler.cs +++ /dev/null @@ -1,21 +0,0 @@ -// using System; -// using System.IO; -// -// namespace TEngine.Core.Network -// { -// public enum NetworkMessageSchedulerHandlerType -// { -// None = 0, -// ClientMessage = 1, -// OuterMessageRoute = 2, -// InnerMessage = 3, -// ServerInnerMessage = 4 -// } -// -// public interface INetworkMessageSchedulerHandler -// { -// NetworkMessageSchedulerHandlerType HandlerType(); -// -// FTask Handler(Session session, Type messageType, APackInfo packInfo); -// } -// } \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler/INetworkMessageSchedulerHandler.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler/INetworkMessageSchedulerHandler.cs.meta deleted file mode 100644 index e66bde52..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Interface/Scheduler/INetworkMessageSchedulerHandler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d5653343ec7befa48a924bed253321ba -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/MessageHelper.cs b/Assets/GameScripts/DotNet/Core/Network/Message/MessageHelper.cs deleted file mode 100644 index 809dfa82..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/MessageHelper.cs +++ /dev/null @@ -1,196 +0,0 @@ -using TEngine.Core; -#pragma warning disable CS8603 - -#if TENGINE_NET -namespace TEngine.Core.Network; - -public static class MessageHelper -{ - private static uint _rpcId; - public const long Timeout = 40000; - public static readonly SortedDictionary RequestCallback = new(); - public static readonly Dictionary TimeoutRouteMessageSenders = new(); - - /// - /// 定时检查过期的Call消息事件。 - /// - public struct NetworkMessageUpdate { } - - static MessageHelper() - { - TimerScheduler.Instance.Core.RepeatedTimer(10000, new NetworkMessageUpdate()); - } - - public static void SendInnerServer(Scene scene, uint routeId, IMessage message) - { - scene.Server.GetSession(routeId).Send(message); - } - - public static void SendInnerRoute(Scene scene, long entityId, IRouteMessage message) - { - if (entityId == 0) - { - Log.Error($"SendInnerRoute appId == 0"); - return; - } - - EntityIdStruct entityIdStruct = entityId; - var session = scene.Server.GetSession(entityIdStruct.LocationId); - session.Send(message, 0, entityId); - } - - public static void SendInnerRoute(Scene scene, long entityId, long routeTypeOpCode, MemoryStream message) - { - if (entityId == 0) - { - Log.Error($"SendInnerRoute appId == 0"); - return; - } - - EntityIdStruct entityIdStruct = entityId; - var session = scene.Server.GetSession(entityIdStruct.LocationId); - session.Send(message, 0, routeTypeOpCode, entityId); - } - - public static void SendInnerRoute(Scene scene, ICollection routeIdCollection, IRouteMessage message) - { - if (routeIdCollection.Count <= 0) - { - Log.Error($"SendInnerRoute routeId.Count <= 0"); - return; - } - - foreach (var routeId in routeIdCollection) - { - SendInnerRoute(scene, routeId, message); - } - } - - public static void SendAddressable(Scene scene, long addressableId, IRouteMessage message) - { - CallAddressable(scene, addressableId, message).Coroutine(); - } - - public static async FTask CallInnerRoute(Scene scene, long entityId, long routeTypeOpCode, Type requestType, MemoryStream request) - { - if (entityId == 0) - { - Log.Error($"CallInnerRoute appId == 0"); - return null; - } - - EntityIdStruct entityIdStruct = entityId; - var rpcId = ++_rpcId; - var session = scene.Server.GetSession(entityIdStruct.LocationId); - var requestCallback = FTask.Create(false); - RequestCallback.Add(rpcId, MessageSender.Create(rpcId, requestType, requestCallback)); - session.Send(request, rpcId, routeTypeOpCode, entityId); - return await requestCallback; - } - - public static async FTask CallInnerRoute(Scene scene, long entityId, IRouteMessage request) - { - if (entityId == 0) - { - Log.Error($"CallInnerRoute appId == 0"); - return null; - } - - EntityIdStruct entityIdStruct = entityId; - var rpcId = ++_rpcId; - var session = scene.Server.GetSession(entityIdStruct.LocationId); - var requestCallback = FTask.Create(false); - RequestCallback.Add(rpcId, MessageSender.Create(rpcId, request, requestCallback)); - session.Send(request, rpcId, entityId); - return await requestCallback; - } - - public static async FTask CallInnerServer(Scene scene, uint targetServerId, IRequest request) - { - var rpcId = ++_rpcId; - var session = scene.Server.GetSession(targetServerId); - var requestCallback = FTask.Create(false); - RequestCallback.Add(rpcId, MessageSender.Create(rpcId, request, requestCallback)); - session.Send(request, rpcId); - return await requestCallback; - } - - public static async FTask CallAddressable(Scene scene, long addressableId, IRouteMessage request) - { - var failCount = 0; - - using (await AddressableRouteComponent.AddressableRouteMessageLock.Lock(addressableId,"CallAddressable")) - { - var addressableRouteId = await AddressableHelper.GetAddressableRouteId(scene, addressableId); - - while (true) - { - if (addressableRouteId == 0) - { - addressableRouteId = await AddressableHelper.GetAddressableRouteId(scene, addressableId); - } - - if (addressableRouteId == 0) - { - return MessageDispatcherSystem.Instance.CreateResponse(request, CoreErrorCode.ErrNotFoundRoute); - } - - var iRouteResponse = await MessageHelper.CallInnerRoute(scene, addressableRouteId, request); - - switch (iRouteResponse.ErrorCode) - { - case CoreErrorCode.ErrNotFoundRoute: - { - if (++failCount > 20) - { - Log.Error($"AddressableComponent.Call failCount > 20 route send message fail, routeId: {addressableRouteId} AddressableMessageComponent:{addressableId}"); - return iRouteResponse; - } - - await TimerScheduler.Instance.Core.WaitAsync(500); - addressableRouteId = 0; - continue; - } - case CoreErrorCode.ErrRouteTimeout: - { - Log.Error($"CallAddressableRoute ErrorCode.ErrRouteTimeout Error:{iRouteResponse.ErrorCode} Message:{request}"); - return iRouteResponse; - } - default: - { - return iRouteResponse; - } - } - } - } - } - - public static void ResponseHandler(uint rpcId, IResponse response) - { - if (!RequestCallback.Remove(rpcId, out var routeMessageSender)) - { - throw new Exception($"not found rpc, response.RpcId:{rpcId} response message: {response.GetType().Name}"); - } - - ResponseHandler(routeMessageSender, response); - } - - private static void ResponseHandler(MessageSender messageSender, IResponse response) - { - if (response.ErrorCode == CoreErrorCode.ErrRouteTimeout) - { -#if TENGINE_DEVELOP - messageSender.Tcs.SetException(new Exception($"Rpc error: request, 注意RouteId消息超时,请注意查看是否死锁或者没有reply: RouteId: {messageSender.RouteId} {messageSender.Request.ToJson()}, response: {response}")); -#else - messageSender.Tcs.SetException(new Exception($"Rpc error: request, 注意RouteId消息超时,请注意查看是否死锁或者没有reply: RouteId: {messageSender.RouteId} {messageSender.Request}, response: {response}")); -#endif - messageSender.Dispose(); - return; - } - - messageSender.Tcs.SetResult(response); - messageSender.Dispose(); - } -} - -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/MessageHelper.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/MessageHelper.cs.meta deleted file mode 100644 index a38d2c99..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/MessageHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e2dce1a84fcf96e4a8dfbe49a155660a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/MessageSender.cs b/Assets/GameScripts/DotNet/Core/Network/Message/MessageSender.cs deleted file mode 100644 index 129cf20b..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/MessageSender.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using TEngine.Core; -#pragma warning disable CS8625 -#pragma warning disable CS8618 - -namespace TEngine.Core.Network -{ - public sealed class MessageSender : IDisposable - { - public uint RpcId { get; private set; } - public long RouteId { get; private set; } - public long CreateTime { get; private set; } - public Type MessageType { get; private set; } - public IMessage Request { get; private set; } - public FTask Tcs { get; private set; } - - public void Dispose() - { - RpcId = 0; - RouteId = 0; - CreateTime = 0; - Tcs = null; - Request = null; - MessageType = null; - Pool.Return(this); - } - - public static MessageSender Create(uint rpcId, Type requestType, FTask tcs) - { - var routeMessageSender = Pool.Rent(); - routeMessageSender.Tcs = tcs; - routeMessageSender.RpcId = rpcId; - routeMessageSender.MessageType = requestType; - routeMessageSender.CreateTime = TimeHelper.Now; - return routeMessageSender; - } - - public static MessageSender Create(uint rpcId, IRequest request, FTask tcs) - { - var routeMessageSender = Pool.Rent(); - routeMessageSender.Tcs = tcs; - routeMessageSender.RpcId = rpcId; - routeMessageSender.Request = request; - routeMessageSender.CreateTime = TimeHelper.Now; - return routeMessageSender; - } - - public static MessageSender Create(uint rpcId, long routeId, IRouteMessage request, FTask tcs) - { - var routeMessageSender = Pool.Rent(); - routeMessageSender.Tcs = tcs; - routeMessageSender.RpcId = rpcId; - routeMessageSender.RouteId = routeId; - routeMessageSender.Request = request; - routeMessageSender.CreateTime = TimeHelper.Now; - return routeMessageSender; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/MessageSender.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/MessageSender.cs.meta deleted file mode 100644 index 0624a9ea..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/MessageSender.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 39b99a8dcf9c7e946a72b1008bbfe1ae -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/OnNetworkMessageUpdateCheckTimeout.cs b/Assets/GameScripts/DotNet/Core/Network/Message/OnNetworkMessageUpdateCheckTimeout.cs deleted file mode 100644 index 1fbddb2f..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/OnNetworkMessageUpdateCheckTimeout.cs +++ /dev/null @@ -1,71 +0,0 @@ -#if TENGINE_NET -using TEngine.Core; - -namespace TEngine.Core.Network; - -public sealed class OnNetworkMessageUpdateCheckTimeout : TimerHandler -{ - public override void Handler(MessageHelper.NetworkMessageUpdate self) - { - var timeNow = TimeHelper.Now; - - foreach (var (rpcId, value) in MessageHelper.RequestCallback) - { - if (timeNow < value.CreateTime + MessageHelper.Timeout) - { - break; - } - - MessageHelper.TimeoutRouteMessageSenders.Add(rpcId, value); - } - - if (MessageHelper.TimeoutRouteMessageSenders.Count == 0) - { - return; - } - - foreach (var (rpcId, routeMessageSender) in MessageHelper.TimeoutRouteMessageSenders) - { - uint responseRpcId = 0; - - try - { - switch (routeMessageSender.Request) - { - case IRouteMessage iRouteMessage: - { - // var routeResponse = RouteMessageDispatcher.CreateResponse(iRouteMessage, ErrorCode.ErrRouteTimeout); - // responseRpcId = routeResponse.RpcId; - // routeResponse.RpcId = routeMessageSender.RpcId; - // MessageHelper.ResponseHandler(routeResponse); - break; - } - case IRequest iRequest: - { - var response = MessageDispatcherSystem.Instance.CreateResponse(iRequest, CoreErrorCode.ErrRpcFail); - responseRpcId = routeMessageSender.RpcId; - MessageHelper.ResponseHandler(responseRpcId, response); - Log.Warning($"timeout rpcId:{rpcId} responseRpcId:{responseRpcId} {iRequest.ToJson()}"); - break; - } - default: - { - Log.Error(routeMessageSender.Request != null - ? $"Unsupported protocol type {routeMessageSender.Request.GetType()} rpcId:{rpcId}" - : $"Unsupported protocol type:{routeMessageSender.MessageType.FullName} rpcId:{rpcId}"); - - MessageHelper.RequestCallback.Remove(rpcId); - break; - } - } - } - catch (Exception e) - { - Log.Error($"responseRpcId:{responseRpcId} routeMessageSender.RpcId:{routeMessageSender.RpcId} {e}"); - } - } - - MessageHelper.TimeoutRouteMessageSenders.Clear(); - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/OnNetworkMessageUpdateCheckTimeout.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/OnNetworkMessageUpdateCheckTimeout.cs.meta deleted file mode 100644 index 6ac0b85f..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/OnNetworkMessageUpdateCheckTimeout.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3152b1d220a7acb45b874cf286c4a341 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Protocols.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Protocols.meta deleted file mode 100644 index ebec6188..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Protocols.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 1eb9f0783453cf7439a4f31708fde2d6 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Protocols/CoreMessageProtocols.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Protocols/CoreMessageProtocols.cs deleted file mode 100644 index 9c488e5d..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Protocols/CoreMessageProtocols.cs +++ /dev/null @@ -1,162 +0,0 @@ -using TEngine.Core.Network; -using ProtoBuf; - -namespace TEngine -{ - [ProtoContract] - public sealed class Response : AProto, IResponse - { - public uint OpCode() - { - return Opcode.DefaultResponse; - } - - [ProtoMember(90)] public long RpcId { get; set; } - [ProtoMember(91, IsRequired = true)] public uint ErrorCode { get; set; } - } - - [ProtoContract] - public sealed class RouteResponse : AProto, IRouteResponse - { - public uint OpCode() - { - return Opcode.DefaultRouteResponse; - } - - [ProtoMember(90)] public long RpcId { get; set; } - [ProtoMember(91, IsRequired = true)] public uint ErrorCode { get; set; } - } - [ProtoContract] - public class PingRequest : AProto, IRequest - { - public uint OpCode() - { - return Opcode.PingRequest; - } - - [ProtoIgnore] public PingResponse ResponseType { get; set; } - [ProtoMember(90)] public long RpcId { get; set; } - } - [ProtoContract] - public class PingResponse : AProto, IResponse - { - public uint OpCode() - { - return Opcode.PingResponse; - } - - [ProtoMember(90)] public long RpcId { get; set; } - [ProtoMember(91, IsRequired = true)] public uint ErrorCode { get; set; } - [ProtoMember(1)] public long Now; - } - /// - /// 添加一个可寻址地址 - /// - [ProtoContract] - public partial class I_AddressableAdd_Request : AProto, IRouteRequest - { - [ProtoIgnore] - public I_AddressableAdd_Response ResponseType { get; set; } - public uint OpCode() { return Opcode.AddressableAddRequest; } - public long RouteTypeOpCode() { return 1; } - [ProtoMember(1)] - public long AddressableId { get; set; } - [ProtoMember(2)] - public long RouteId { get; set; } - [ProtoMember(3)] - public bool IsLock { get; set; } - } - [ProtoContract] - public partial class I_AddressableAdd_Response : AProto, IRouteResponse - { - public uint OpCode() { return Opcode.AddressableAddResponse; } - [ProtoMember(91, IsRequired = true)] - public uint ErrorCode { get; set; } - } - /// - /// 查询一个可寻址 - /// - [ProtoContract] - public partial class I_AddressableGet_Request : AProto, IRouteRequest - { - [ProtoIgnore] - public I_AddressableGet_Response ResponseType { get; set; } - public uint OpCode() { return Opcode.AddressableGetRequest; } - public long RouteTypeOpCode() { return 1; } - [ProtoMember(1)] - public long AddressableId { get; set; } - } - [ProtoContract] - public partial class I_AddressableGet_Response : AProto, IRouteResponse - { - public uint OpCode() { return Opcode.AddressableGetResponse; } - [ProtoMember(91, IsRequired = true)] - public uint ErrorCode { get; set; } - [ProtoMember(1)] - public long RouteId { get; set; } - } - /// - /// 删除一个可寻址 - /// - [ProtoContract] - public partial class I_AddressableRemove_Request : AProto, IRouteRequest - { - [ProtoIgnore] - public I_AddressableRemove_Response ResponseType { get; set; } - public uint OpCode() { return Opcode.AddressableRemoveRequest; } - public long RouteTypeOpCode() { return 1; } - [ProtoMember(1)] - public long AddressableId { get; set; } - } - [ProtoContract] - public partial class I_AddressableRemove_Response : AProto, IRouteResponse - { - public uint OpCode() { return Opcode.AddressableRemoveResponse; } - [ProtoMember(91, IsRequired = true)] - public uint ErrorCode { get; set; } - } - /// - /// 锁定一个可寻址 - /// - [ProtoContract] - public partial class I_AddressableLock_Request : AProto, IRouteRequest - { - [ProtoIgnore] - public I_AddressableLock_Response ResponseType { get; set; } - public uint OpCode() { return Opcode.AddressableLockRequest; } - public long RouteTypeOpCode() { return 1; } - [ProtoMember(1)] - public long AddressableId { get; set; } - } - [ProtoContract] - public partial class I_AddressableLock_Response : AProto, IRouteResponse - { - public uint OpCode() { return Opcode.AddressableLockResponse; } - [ProtoMember(91, IsRequired = true)] - public uint ErrorCode { get; set; } - } - /// - /// 解锁一个可寻址 - /// - [ProtoContract] - public partial class I_AddressableUnLock_Request : AProto, IRouteRequest - { - [ProtoIgnore] - public I_AddressableUnLock_Response ResponseType { get; set; } - public uint OpCode() { return Opcode.AddressableUnLockRequest; } - public long RouteTypeOpCode() { return 1; } - [ProtoMember(1)] - public long AddressableId { get; set; } - [ProtoMember(2)] - public long RouteId { get; set; } - [ProtoMember(3)] - public string Source { get; set; } - } - [ProtoContract] - public partial class I_AddressableUnLock_Response : AProto, IRouteResponse - { - public uint OpCode() { return Opcode.AddressableUnLockResponse; } - [ProtoMember(91, IsRequired = true)] - public uint ErrorCode { get; set; } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Protocols/CoreMessageProtocols.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Protocols/CoreMessageProtocols.cs.meta deleted file mode 100644 index fe28cecc..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Protocols/CoreMessageProtocols.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f6c821a26b3bfad4e9e240a15cf3a745 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Route.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Route.meta deleted file mode 100644 index 7dbb1653..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Route.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8099ddc29c0dd8748ba72a0c621a9df9 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Route/RouteComponent.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Route/RouteComponent.cs deleted file mode 100644 index 08eb3abb..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Route/RouteComponent.cs +++ /dev/null @@ -1,37 +0,0 @@ -#if TENGINE_NET -namespace TEngine.Core.Network; - -/// -/// 自定义Route组件、如果要自定义Route协议必须使用这个组件 -/// -public sealed class RouteComponent : Entity -{ - public readonly Dictionary RouteAddress = new Dictionary(); - - public void AddAddress(long routeType, long routeId) - { - this.RouteAddress.Add(routeType, routeId); - } - - public void RemoveAddress(long routeType) - { - this.RouteAddress.Remove(routeType); - } - - public long GetRouteId(long routeType) - { - return this.RouteAddress.TryGetValue(routeType, out var routeId) ? routeId : 0; - } - - public bool TryGetRouteId(long routeType, out long routeId) - { - return this.RouteAddress.TryGetValue(routeType, out routeId); - } - - public override void Dispose() - { - this.RouteAddress.Clear(); - base.Dispose(); - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Route/RouteComponent.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Route/RouteComponent.cs.meta deleted file mode 100644 index 34d9eaba..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Route/RouteComponent.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ef3b01b95662a0e47abe0576ff53efc5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler.meta deleted file mode 100644 index b9e14c3e..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 756c1c61f6e131d4aaf2f05901bc343a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/ClientMessageScheduler.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/ClientMessageScheduler.cs deleted file mode 100644 index 225a16da..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/ClientMessageScheduler.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; - -namespace TEngine.Core.Network -{ -#if TENGINE_UNITY - public sealed class ClientMessageScheduler : ANetworkMessageScheduler - { - protected override async FTask Handler(Session session, Type messageType, APackInfo packInfo) - { - try - { - DisposePackInfo = false; - switch (packInfo.ProtocolCode) - { - case > Opcode.InnerRouteResponse: - { - throw new NotSupportedException($"Received unsupported message protocolCode:{packInfo.ProtocolCode} messageType:{messageType}"); - } - case Opcode.PingResponse: - case > Opcode.OuterRouteResponse: - { - // 这个一般是客户端Session.Call发送时使用的、目前这个逻辑只有Unity客户端时使用 - var aResponse = (IResponse)packInfo.Deserialize(messageType); - - if (!session.RequestCallback.TryGetValue(packInfo.RpcId, out var action)) - { - Log.Error($"not found rpc {packInfo.RpcId}, response message: {aResponse.GetType().Name}"); - return; - } - - session.RequestCallback.Remove(packInfo.RpcId); - action.SetResult(aResponse); - return; - } - case < Opcode.OuterRouteRequest: - { - var message = packInfo.Deserialize(messageType); - MessageDispatcherSystem.Instance.MessageHandler(session, messageType, message, packInfo.RpcId, packInfo.ProtocolCode); - return; - } - } - } - catch (Exception e) - { - Log.Error(e); - return; - } - finally - { - NetworkThread.Instance.SynchronizationContext.Post(packInfo.Dispose); - } - - await FTask.CompletedTask; - throw new NotSupportedException($"Received unsupported message protocolCode:{packInfo.ProtocolCode} messageType:{messageType}"); - } - - protected override FTask InnerHandler(Session session, uint rpcId, long routeId, uint protocolCode, long routeTypeCode, Type messageType, object message) - { - throw new NotImplementedException(); - } - } -#endif -#if TENGINE_NET - public sealed class ClientMessageScheduler : ANetworkMessageScheduler - { - protected override FTask Handler(Session session, Type messageType, APackInfo packInfo) - { - throw new NotSupportedException($"Received unsupported message protocolCode:{packInfo.ProtocolCode} messageType:{messageType}"); - } - - protected override FTask InnerHandler(Session session, uint rpcId, long routeId, uint protocolCode, long routeTypeCode, Type messageType, object message) - { - throw new NotSupportedException($"Received unsupported message protocolCode:{protocolCode} messageType:{messageType}"); - } - } -#endif -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/ClientMessageScheduler.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/ClientMessageScheduler.cs.meta deleted file mode 100644 index d86b2bba..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/ClientMessageScheduler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 14525ca558e639341992505398c7aae5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/CoreRouteType.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/CoreRouteType.cs deleted file mode 100644 index 28be4b76..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/CoreRouteType.cs +++ /dev/null @@ -1,22 +0,0 @@ -namespace TEngine.Core.Network -{ - public class CoreRouteType - { - /// - /// 基础Route协议、框架内置千万不要删除 - /// - public const long Route = 1; - /// - /// 基础BsonRoute协议、框架内置千万不要删除 - /// - public const long BsonRoute = 2; - /// - /// 基础Addressable协议、框架内置千万不要删除 - /// - public const long Addressable = 3; - /// - /// 自定义RouteType、框架内置千万不要删除 - /// - public const long CustomRouteType = 1000; - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/CoreRouteType.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/CoreRouteType.cs.meta deleted file mode 100644 index 80280bc6..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/CoreRouteType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0061d503cf7e47544addd8730096469d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/InnerMessageScheduler.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/InnerMessageScheduler.cs deleted file mode 100644 index d040a77e..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/InnerMessageScheduler.cs +++ /dev/null @@ -1,201 +0,0 @@ -// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract -#if TENGINE_NET - -namespace TEngine.Core.Network -{ - public sealed class InnerMessageScheduler : ANetworkMessageScheduler - { - protected override async FTask Handler(Session session, Type messageType, APackInfo packInfo) - { - try - { - DisposePackInfo = false; - - switch (packInfo.ProtocolCode) - { - case >= Opcode.InnerBsonRouteResponse: - case >= Opcode.InnerRouteResponse: - { - var response = (IRouteResponse)packInfo.Deserialize(messageType); - MessageHelper.ResponseHandler(packInfo.RpcId, response); - return; - } - case >= Opcode.OuterRouteResponse: - { - // 如果Gate服务器、需要转发Addressable协议、所以这里有可能会接收到该类型协议 - var aResponse = (IResponse)packInfo.Deserialize(messageType); - MessageHelper.ResponseHandler(packInfo.RpcId, aResponse); - return; - } - case > Opcode.InnerBsonRouteMessage: - { - var obj = packInfo.Deserialize(messageType); - var entity = Entity.GetEntity(packInfo.RouteId); - - if (entity == null) - { - if (packInfo.ProtocolCode > Opcode.InnerBsonRouteRequest) - { - MessageDispatcherSystem.Instance.FailResponse(session, (IRouteRequest)obj, CoreErrorCode.ErrNotFoundRoute, packInfo.RpcId); - } - - return; - } - - await MessageDispatcherSystem.Instance.RouteMessageHandler(session, messageType, entity, obj, packInfo.RpcId); - return; - } - case > Opcode.InnerRouteMessage: - { - var obj = packInfo.Deserialize(messageType); - var entity = Entity.GetEntity(packInfo.RouteId); - - if (entity == null) - { - if (packInfo.ProtocolCode > Opcode.InnerRouteRequest) - { - MessageDispatcherSystem.Instance.FailResponse(session, (IRouteRequest)obj, CoreErrorCode.ErrNotFoundRoute, packInfo.RpcId); - } - - return; - } - - await MessageDispatcherSystem.Instance.RouteMessageHandler(session, messageType, entity, obj, packInfo.RpcId); - return; - } - case > Opcode.OuterRouteMessage: - { - var entity = Entity.GetEntity(packInfo.RouteId); - - switch (entity) - { - case null: - { - var obj = packInfo.Deserialize(messageType); - var response = MessageDispatcherSystem.Instance.CreateResponse((IRouteMessage)obj, CoreErrorCode.ErrNotFoundRoute); - session.Send(response, packInfo.RpcId, packInfo.RouteId); - return; - } - case Session gateSession: - { - // 这里如果是Session只可能是Gate的Session、如果是的话、肯定是转发Address消息 - gateSession.Send(packInfo.CreateMemoryStream(), packInfo.RpcId); - return; - } - default: - { - var obj = packInfo.Deserialize(messageType); - await MessageDispatcherSystem.Instance.RouteMessageHandler(session, messageType, entity, obj, packInfo.RpcId); - return; - } - } - } - default: - { - throw new NotSupportedException( - $"Received unsupported message protocolCode:{packInfo.ProtocolCode} messageType:{messageType}"); - } - } - } - catch (Exception e) - { - Log.Error($"InnerMessageSchedulerHandler error messageProtocolCode:{packInfo.ProtocolCode} messageType:{messageType} {e}"); - } - finally - { - NetworkThread.Instance.SynchronizationContext.Post(packInfo.Dispose); - } - } - - protected override async FTask InnerHandler(Session session, uint rpcId, long routeId, uint protocolCode, long routeTypeCode, Type messageType, object message) - { - try - { - switch (protocolCode) - { - case >= Opcode.InnerBsonRouteResponse: - case >= Opcode.InnerRouteResponse: - { - MessageHelper.ResponseHandler(rpcId, (IRouteResponse)message); - return; - } - case >= Opcode.OuterRouteResponse: - { - // 如果Gate服务器、需要转发Addressable协议、所以这里有可能会接收到该类型协议 - MessageHelper.ResponseHandler(rpcId, (IResponse)message); - return; - } - case > Opcode.InnerBsonRouteMessage: - { - var entity = Entity.GetEntity(routeId); - - if (entity == null) - { - if (protocolCode > Opcode.InnerBsonRouteRequest) - { - MessageDispatcherSystem.Instance.FailResponse(session, (IRouteRequest)message, CoreErrorCode.ErrNotFoundRoute, rpcId); - } - - return; - } - - await MessageDispatcherSystem.Instance.RouteMessageHandler(session, messageType, entity, message, rpcId); - return; - } - case > Opcode.InnerRouteMessage: - { - var entity = Entity.GetEntity(routeId); - - if (entity == null) - { - if (protocolCode > Opcode.InnerRouteRequest) - { - MessageDispatcherSystem.Instance.FailResponse(session, (IRouteRequest)message, CoreErrorCode.ErrNotFoundRoute, rpcId); - } - - return; - } - - await MessageDispatcherSystem.Instance.RouteMessageHandler(session, messageType, entity, message, rpcId); - return; - } - case > Opcode.OuterRouteMessage: - { - var entity = Entity.GetEntity(routeId); - - switch (entity) - { - case null: - { - var response = MessageDispatcherSystem.Instance.CreateResponse((IRouteMessage)message, CoreErrorCode.ErrNotFoundRoute); - session.Send(response, rpcId, routeId); - return; - } - case Session gateSession: - { - // 这里如果是Session只可能是Gate的Session、如果是的话、肯定是转发Address消息 - gateSession.Send(message, rpcId); - return; - } - default: - { - await MessageDispatcherSystem.Instance.RouteMessageHandler(session, messageType, entity, message, rpcId); - return; - } - } - } - default: - { - throw new NotSupportedException($"Received unsupported message protocolCode:{protocolCode} messageType:{messageType}"); - } - } - } - catch (Exception e) - { - Log.Error($"InnerMessageSchedulerHandler error messageProtocolCode:{protocolCode} messageType:{messageType} {e}"); - } - } - } -} -#endif - diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/InnerMessageScheduler.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/InnerMessageScheduler.cs.meta deleted file mode 100644 index e5ec78c8..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/InnerMessageScheduler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: dcfa2c899967c7f45bd265785358ad93 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/OuterMessageScheduler.cs b/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/OuterMessageScheduler.cs deleted file mode 100644 index af991df9..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/OuterMessageScheduler.cs +++ /dev/null @@ -1,135 +0,0 @@ -using System; -using TEngine.IO; -// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract - -namespace TEngine.Core.Network -{ -#if TENGINE_UNITY - public sealed class OuterMessageScheduler : ANetworkMessageScheduler - { - protected override FTask Handler(Session session, Type messageType, APackInfo packInfo) - { - throw new NotSupportedException($"Received unsupported message protocolCode:{packInfo.ProtocolCode} messageType:{messageType}"); - } - - protected override FTask InnerHandler(Session session, uint rpcId, long routeId, uint protocolCode, long routeTypeCode, Type messageType, object message) - { - throw new NotImplementedException(); - } - } -#endif -#if TENGINE_NET - public sealed class OuterMessageScheduler : ANetworkMessageScheduler - { - protected override async FTask Handler(Session session, Type messageType, APackInfo packInfo) - { - if (packInfo.ProtocolCode >= Opcode.InnerRouteMessage) - { - throw new NotSupportedException($"Received unsupported message protocolCode:{packInfo.ProtocolCode} messageType:{messageType}"); - } - - try - { - DisposePackInfo = false; - - switch (packInfo.RouteTypeCode) - { - case CoreRouteType.Route: - case CoreRouteType.BsonRoute: - { - break; - } - case CoreRouteType.Addressable: - { - var addressableRouteComponent = session.GetComponent(); - - if (addressableRouteComponent == null) - { - Log.Error("Session does not have an AddressableRouteComponent component"); - return; - } - - switch (packInfo.ProtocolCode) - { - case > Opcode.OuterRouteRequest: - { - var runtimeId = session.RuntimeId; - var response = await addressableRouteComponent.Call(packInfo.RouteTypeCode, messageType, packInfo.CreateMemoryStream()); - // session可能已经断开了,所以这里需要判断 - if (session.RuntimeId == runtimeId) - { - session.Send(response, packInfo.RpcId); - } - - return; - } - case > Opcode.OuterRouteMessage: - { - addressableRouteComponent.Send(packInfo.RouteTypeCode, messageType, packInfo.CreateMemoryStream()); - return; - } - } - - return; - } - case > CoreRouteType.CustomRouteType: - { - var routeComponent = session.GetComponent(); - - if (routeComponent == null) - { - Log.Error("Session does not have an routeComponent component"); - return; - } - - if (!routeComponent.TryGetRouteId(packInfo.RouteTypeCode, out var routeId)) - { - Log.Error($"RouteComponent cannot find RouteId with RouteTypeCode {packInfo.RouteTypeCode}"); - return; - } - - switch (packInfo.ProtocolCode) - { - case > Opcode.OuterRouteRequest: - { - var runtimeId = session.RuntimeId; - var response = await MessageHelper.CallInnerRoute(session.Scene, routeId, packInfo.RouteTypeCode, messageType, packInfo.CreateMemoryStream()); - // session可能已经断开了,所以这里需要判断 - if (session.RuntimeId == runtimeId) - { - session.Send(response, packInfo.RpcId); - } - - return; - } - case > Opcode.OuterRouteMessage: - { - MessageHelper.SendInnerRoute(session.Scene, routeId, packInfo.RouteTypeCode, packInfo.CreateMemoryStream()); - return; - } - } - - return; - } - } - } - catch (Exception e) - { - Log.Error(e); - return; - } - finally - { - NetworkThread.Instance.SynchronizationContext.Post(packInfo.Dispose); - } - - throw new NotSupportedException($"Received unsupported message protocolCode:{packInfo.ProtocolCode} messageType:{messageType}"); - } - - protected override FTask InnerHandler(Session session, uint rpcId, long routeId, uint protocolCode, long routeTypeCode, Type messageType, object message) - { - throw new NotSupportedException($"OuterMessageScheduler NotSupported InnerHandler"); - } - } -#endif -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/OuterMessageScheduler.cs.meta b/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/OuterMessageScheduler.cs.meta deleted file mode 100644 index 224b0d07..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/Message/Scheduler/OuterMessageScheduler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4433fa0a9cf819a4593784711b023154 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol.meta deleted file mode 100644 index f5c0bcb2..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f3117a3ccddcf1a41b63d24c87945e51 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP.meta deleted file mode 100644 index 9a4763d2..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d4432f2a80d63c44f9b38176ebd993f2 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base.meta deleted file mode 100644 index 911531f1..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 822cde18961b6d54db72134259341fac -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/KCPSettings.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/KCPSettings.cs deleted file mode 100644 index bc1c70ff..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/KCPSettings.cs +++ /dev/null @@ -1,51 +0,0 @@ -using System; - -namespace TEngine.Core.Network -{ - public class KCPSettings - { - public uint Mtu { get; private set; } - public uint SendWindowSize { get; private set; } - public uint ReceiveWindowSize { get; private set; } - public int MaxSendWindowSize { get; private set; } - - public static KCPSettings Create(NetworkTarget networkTarget) - { - var settings = new KCPSettings(); - - switch (networkTarget) - { - case NetworkTarget.Outer: - { - // 外网设置470的原因: - // 1、mtu设置过大有可能路由器过滤掉 - // 2、降低 mtu 到 470,同样数据虽然会发更多的包,但是小包在路由层优先级更高 - settings.Mtu = 470; - settings.SendWindowSize = 256; - settings.ReceiveWindowSize = 256; - settings.MaxSendWindowSize = 256 * 2; - break; - } - case NetworkTarget.Inner: - { - // 内网设置1400的原因 - // 1、一般都是同一台服务器来运行多个进程来处理 - // 2、内网每个进程跟其他进程只有一个通道进行发送、所以发送的数量会比较大 - // 3、如果不把窗口设置大点、会出现消息滞后。 - // 4、因为内网发送的可不只是外网转发数据、还有可能是其他进程的通讯 - settings.Mtu = 1400; - settings.SendWindowSize = 1024; - settings.ReceiveWindowSize = 1024; - settings.MaxSendWindowSize = 1024 * 2; - break; - } - default: - { - throw new NotSupportedException($"KCPServerNetwork NotSupported NetworkType:{networkTarget}"); - } - } - - return settings; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/KCPSettings.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/KCPSettings.cs.meta deleted file mode 100644 index ff2942c1..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/KCPSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 756afce4e7fb29b4fab97d429a0aea90 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/KcpHeader.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/KcpHeader.cs deleted file mode 100644 index 9989d5ab..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/KcpHeader.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace TEngine.Core.Network -{ - public enum KcpHeader : byte - { - None = 0x00, - RequestConnection = 0x01, - WaitConfirmConnection = 0x02, - ConfirmConnection = 0x03, - // InnerHandshake = 0x03, - RepeatChannelId = 0x04, - // ConfirmHandshake = 0x05, - ReceiveData = 0x06, - Disconnect = 0x07 - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/KcpHeader.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/KcpHeader.cs.meta deleted file mode 100644 index a276ad44..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/KcpHeader.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8e5f946dde2d78f4b9e3425a3ad647b5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k.meta deleted file mode 100644 index fcca0b6e..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b6517b73296f4564a8411993d86fcafb -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/LICENSE b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/LICENSE deleted file mode 100644 index c77582e8..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -MIT License - -Copyright (c) 2016 limpo1989 -Copyright (c) 2020 Paul Pacheco -Copyright (c) 2020 Lymdun -Copyright (c) 2020 vis2k - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/LICENSE.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/LICENSE.meta deleted file mode 100644 index 16bff191..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/LICENSE.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 60e959aa2b0fc774fb97f3a52197e41b -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/LICENSE.txt b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/LICENSE.txt deleted file mode 100644 index c77582e8..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/LICENSE.txt +++ /dev/null @@ -1,24 +0,0 @@ -MIT License - -Copyright (c) 2016 limpo1989 -Copyright (c) 2020 Paul Pacheco -Copyright (c) 2020 Lymdun -Copyright (c) 2020 vis2k - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/LICENSE.txt.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/LICENSE.txt.meta deleted file mode 100644 index 90dee819..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/LICENSE.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: e29e0db9c79ad6348aa2997ac1326446 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/README.md b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/README.md deleted file mode 100644 index d8d6ba56..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# kcp2k -C# KCP based on the original C [kcp](https://github.com/skywind3000/kcp). - -Works with **netcore** and **Unity**. - -Developed for [Mirror Networking](https://github.com/MirrorNetworking/Mirror). - -# Features -* Kcp.cs based on kcp.c v1.7, line-by-line translation to C# -* Heavy test coverage -* Fixed [WND_RCV bug](https://github.com/skywind3000/kcp/pull/291) from original kcp -* Optional high level C# code for client/server connection handling -* Optional high level Unreliable channel added - -Pull requests for bug fixes & tests welcome. - -# Unity -kcp2k works perfectly with Unity, see the Mirror repository's KcpTransport. - -# Allocations -The client is allocation free. -The server's SendTo/ReceiveFrom still allocate. - -Previously, [where-allocation](https://github.com/vis2k/where-allocation) for a 25x reduction in server allocations. However: -- It only worked with Unity's old Mono version. -- It didn't work in Unity's IL2CPP builds, which are still faster than Mono + NonAlloc -- It didn't work in regular C# projects. -- Overall, the extra complexity is not worth it. Use IL2CPP instead. -- Microsoft is considering to [remove the allocation](https://github.com/dotnet/runtime/issues/30797#issuecomment-1308599410). - -# Remarks -- **Congestion Control** should be left disabled. It seems to be broken in KCP. diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/VERSION.txt b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/VERSION.txt deleted file mode 100644 index b92a8aed..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/VERSION.txt +++ /dev/null @@ -1,234 +0,0 @@ -V1.36 [2023-06-08] -- fix: #49 KcpPeer.RawInput message size check now considers cookie as well -- kcp.cs cleanups - -V1.35 [2023-04-05] -- fix: KcpClients now need to validate with a secure cookie in order to protect against - UDP spoofing. fixes: - https://github.com/MirrorNetworking/Mirror/issues/3286 - [disclosed by IncludeSec] -- KcpClient/Server: change callbacks to protected so inheriting classes can use them too -- KcpClient/Server: change config visibility to protected - -V1.34 [2023-03-15] -- Send/SendTo/Receive/ReceiveFrom NonBlocking extensions. - to encapsulate WouldBlock allocations, exceptions, etc. - allows for reuse when overwriting KcpServer/Client (i.e. for relays). - -V1.33 [2023-03-14] -- perf: KcpServer/Client RawReceive now call socket.Poll to avoid non-blocking - socket's allocating a new SocketException in case they WouldBlock. - fixes https://github.com/MirrorNetworking/Mirror/issues/3413 -- perf: KcpServer/Client RawSend now call socket.Poll to avoid non-blocking - socket's allocating a new SocketException in case they WouldBlock. - fixes https://github.com/MirrorNetworking/Mirror/issues/3413 - -V1.32 [2023-03-12] -- fix: KcpPeer RawInput now doesn't disconnect in case of random internet noise - -V1.31 [2023-03-05] -- KcpClient: Tick/Incoming/Outgoing can now be overwritten (virtual) -- breaking: KcpClient now takes KcpConfig in constructor instead of in Connect. - cleaner, and prepares for KcpConfig.MTU setting. -- KcpConfig now includes MTU; KcpPeer now works with KcpConfig's MTU, KcpServer/Client - buffers are now created with config's MTU. - -V1.30 [2023-02-20] -- fix: set send/recv buffer sizes directly instead of iterating to find the limit. - fixes: https://github.com/MirrorNetworking/Mirror/issues/3390 -- fix: server & client sockets are now always non-blocking to ensure main thread never - blocks on socket.recv/send. Send() now also handles WouldBlock. -- fix: socket.Receive/From directly with non-blocking sockets and handle WouldBlock, - instead of socket.Poll. faster, more obvious, and fixes Poll() looping forever while - socket is in error state. fixes: https://github.com/MirrorNetworking/Mirror/issues/2733 - -V1.29 [2023-01-28] -- fix: KcpServer.CreateServerSocket now handles NotSupportedException when setting DualMode - https://github.com/MirrorNetworking/Mirror/issues/3358 - -V1.28 [2023-01-28] -- fix: KcpClient.Connect now resolves hostname before creating peer - https://github.com/MirrorNetworking/Mirror/issues/3361 - -V1.27 [2023-01-08] -- KcpClient.Connect: invoke own events directly instead of going through peer, - which calls our own events anyway -- fix: KcpPeer/Client/Server callbacks are readonly and assigned in constructor - to ensure they are safe to use at all times. - fixes https://github.com/MirrorNetworking/Mirror/issues/3337 - -V1.26 [2022-12-22] -- KcpPeer.RawInput: fix compile error in old Unity Mono versions -- fix: KcpServer sets up a new connection's OnError immediately. - fixes KcpPeer throwing NullReferenceException when attempting to call OnError - after authentication errors. -- improved log messages - -V1.25 [2022-12-14] -- breaking: removed where-allocation. use IL2CPP on servers instead. -- breaking: KcpConfig to simplify configuration -- high level cleanups - -V1.24 [2022-12-14] -- KcpClient: fixed NullReferenceException when connection without a server. - added test coverage to ensure this never happens again. - -V1.23 [2022-12-07] -- KcpClient: rawReceiveBuffer exposed -- fix: KcpServer RawSend uses connection.remoteEndPoint instead of the helper - 'newClientEP'. fixes clients receiving the wrong messages meant for others. - https://github.com/MirrorNetworking/Mirror/issues/3296 - -V1.22 [2022-11-30] -- high level refactor, part two. - -V1.21 [2022-11-24] -- high level refactor, part one. - - KcpPeer instead of KcpConnection, KcpClientConnection, KcpServerConnection - - RawSend/Receive can now easily be overwritten in KcpClient/Server. - for non-alloc, relays, etc. - -V1.20 [2022-11-22] -- perf: KcpClient receive allocation was removed entirely. - reduces Mirror benchmark client sided allocations from 4.9 KB / 1.7 KB (non-alloc) to 0B. -- fix: KcpConnection.Disconnect does not check socket.Connected anymore. - UDP sockets don't have a connection. - fixes Disconnects not being sent to clients in netcore. -- KcpConnection.SendReliable: added OnError instead of logs - -V1.19 [2022-05-12] -- feature: OnError ErrorCodes - -V1.18 [2022-05-08] -- feature: OnError to allow higher level to show popups etc. -- feature: KcpServer.GetClientAddress is now GetClientEndPoint in order to - expose more details -- ResolveHostname: include exception in log for easier debugging -- fix: KcpClientConnection.RawReceive now logs the SocketException even if - it was expected. makes debugging easier. -- fix: KcpServer.TickIncoming now logs the SocketException even if it was - expected. makes debugging easier. -- fix: KcpClientConnection.RawReceive now calls Disconnect() if the other end - has closed the connection. better than just remaining in a state with unusable - sockets. - -V1.17 [2022-01-09] -- perf: server/client MaximizeSendReceiveBuffersToOSLimit option to set send/recv - buffer sizes to OS limit. avoids drops due to small buffers under heavy load. - -V1.16 [2022-01-06] -- fix: SendUnreliable respects ArraySegment.Offset -- fix: potential bug with negative length (see PR #2) -- breaking: removed pause handling because it's not necessary for Mirror anymore - -V1.15 [2021-12-11] -- feature: feature: MaxRetransmits aka dead_link now configurable -- dead_link disconnect message improved to show exact retransmit count - -V1.14 [2021-11-30] -- fix: Send() now throws an exception for messages which require > 255 fragments -- fix: ReliableMaxMessageSize is now limited to messages which require <= 255 fragments - -V1.13 [2021-11-28] -- fix: perf: uncork max message size from 144 KB to as much as we want based on - receive window size. - fixes https://github.com/vis2k/kcp2k/issues/22 - fixes https://github.com/skywind3000/kcp/pull/291 -- feature: OnData now includes channel it was received on - -V1.12 [2021-07-16] -- Tests: don't depend on Unity anymore -- fix: #26 - Kcp now catches exception if host couldn't be resolved, and calls - OnDisconnected to let the user now. -- fix: KcpServer.DualMode is now configurable in the constructor instead of - using #if UNITY_SWITCH. makes it run on all other non dual mode platforms too. -- fix: where-allocation made optional via virtuals and inheriting - KcpServer/Client/Connection NonAlloc classes. fixes a bug where some platforms - might not support where-allocation. - -V1.11 rollback [2021-06-01] -- perf: Segment MemoryStream initial capacity set to MTU to avoid early runtime - resizing/allocations - -V1.10 [2021-05-28] -- feature: configurable Timeout -- allocations explained with comments (C# ReceiveFrom / IPEndPoint.GetHashCode) -- fix: #17 KcpConnection.ReceiveNextReliable now assigns message default so it - works in .net too -- fix: Segment pool is not static anymore. Each kcp instance now has it's own - Pool. fixes #18 concurrency issues - -V1.9 [2021-03-02] -- Tick() split into TickIncoming()/TickOutgoing() to use in Mirror's new update - functions. allows to minimize latency. - => original Tick() is still supported for convenience. simply processes both! - -V1.8 [2021-02-14] -- fix: Unity IPv6 errors on Nintendo Switch -- fix: KcpConnection now disconnects if data message was received without content. - previously it would call OnData with an empty ArraySegment, causing all kinds of - weird behaviour in Mirror/DOTSNET. Added tests too. -- fix: KcpConnection.SendData: don't allow sending empty messages anymore. disconnect - and log a warning to make it completely obvious. - -V1.7 [2021-01-13] -- fix: unreliable messages reset timeout now too -- perf: KcpConnection OnCheckEnabled callback changed to a simple 'paused' boolean. - This is faster than invoking a Func every time and allows us to fix #8 more - easily later by calling .Pause/.Unpause from OnEnable/OnDisable in MirrorTransport. -- fix #8: Unpause now resets timeout to fix a bug where Mirror would pause kcp, - change the scene which took >10s, then unpause and kcp would detect the lack of - any messages for >10s as timeout. Added test to make sure it never happens again. -- MirrorTransport: statistics logging for headless servers -- Mirror Transport: Send/Receive window size increased once more from 2048 to 4096. - -V1.6 [2021-01-10] -- Unreliable channel added! -- perf: KcpHeader byte added to every kcp message to indicate - Handshake/Data/Ping/Disconnect instead of scanning each message for Hello/Byte/Ping - content via SegmentEquals. It's a lot cleaner, should be faster and should avoid - edge cases where a message content would equal Hello/Ping/Bye sequence accidentally. -- Kcp.Input: offset moved to parameters for cases where it's needed -- Kcp.SetMtu from original Kcp.c - -V1.5 [2021-01-07] -- KcpConnection.MaxSend/ReceiveRate calculation based on the article -- MirrorTransport: large send/recv window size defaults to avoid high latencies caused - by packets not being processed fast enough -- MirrorTransport: show MaxSend/ReceiveRate in debug gui -- MirrorTransport: don't Log.Info to console in headless mode if debug log is disabled - -V1.4 [2020-11-27] -- fix: OnCheckEnabled added. KcpConnection message processing while loop can now - be interrupted immediately. fixes Mirror Transport scene changes which need to stop - processing any messages immediately after a scene message) -- perf: Mirror KcpTransport: FastResend enabled by default. turbo mode according to: - https://github.com/skywind3000/kcp/blob/master/README.en.md#protocol-configuration -- perf: Mirror KcpTransport: CongestionControl disabled by default (turbo mode) - -V1.3 [2020-11-17] -- Log.Info/Warning/Error so logging doesn't depend on UnityEngine anymore -- fix: Server.Tick catches SocketException which happens if Android client is killed -- MirrorTransport: debugLog option added that can be checked in Unity Inspector -- Utils.Clamp so Kcp.cs doesn't depend on UnityEngine -- Utils.SegmentsEqual: use Linq SequenceEqual so it doesn't depend on UnityEngine -=> kcp2k can now be used in any C# project even without Unity - -V1.2 [2020-11-10] -- more tests added -- fix: raw receive buffers are now all of MTU size -- fix: raw receive detects error where buffer was too small for msgLength and - result in excess data being dropped silently -- KcpConnection.MaxMessageSize added for use in high level -- KcpConnection.MaxMessageSize increased from 1200 bytes to to maximum allowed - message size of 145KB for kcp (based on mtu, overhead, wnd_rcv) - -V1.1 [2020-10-30] -- high level cleanup, fixes, improvements - -V1.0 [2020-10-22] -- Kcp.cs now mirrors original Kcp.c behaviour - (this fixes dozens of bugs) - -V0.1 -- initial kcp-csharp based version \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/VERSION.txt.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/VERSION.txt.meta deleted file mode 100644 index e736fdac..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/VERSION.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 0d1fd9853ebb3d047acd92fae8441350 -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp.meta deleted file mode 100644 index a8cad8ed..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d84ce75a45b625749bb2ee11dadf14e9 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/AckItem.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/AckItem.cs deleted file mode 100644 index 820f4511..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/AckItem.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace kcp2k -{ - internal struct AckItem - { - internal uint serialNumber; - internal uint timestamp; - } -} diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/AckItem.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/AckItem.cs.meta deleted file mode 100644 index 7df7cf99..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/AckItem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: cbc45820dcb825444a1e4b3a1bcba94a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/AssemblyInfo.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/AssemblyInfo.cs deleted file mode 100644 index 5fe5547e..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("kcp2k.Tests")] \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/AssemblyInfo.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/AssemblyInfo.cs.meta deleted file mode 100644 index 6aa2576f..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/AssemblyInfo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1731c38e547afe045bd600f9082a0f33 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Kcp.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Kcp.cs deleted file mode 100644 index bddfa980..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Kcp.cs +++ /dev/null @@ -1,1267 +0,0 @@ -// Kcp based on https://github.com/skywind3000/kcp -// Kept as close to original as possible. -using System; -using System.Collections.Generic; - -namespace kcp2k -{ - public class Kcp - { - // original Kcp has a define option, which is not defined by default: - // #define FASTACK_CONSERVE - - public const int RTO_NDL = 30; // no delay min rto - public const int RTO_MIN = 100; // normal min rto - public const int RTO_DEF = 200; // default RTO - public const int RTO_MAX = 60000; // maximum RTO - public const int CMD_PUSH = 81; // cmd: push data - public const int CMD_ACK = 82; // cmd: ack - public const int CMD_WASK = 83; // cmd: window probe (ask) - public const int CMD_WINS = 84; // cmd: window size (tell/insert) - public const int ASK_SEND = 1; // need to send CMD_WASK - public const int ASK_TELL = 2; // need to send CMD_WINS - public const int WND_SND = 32; // default send window - public const int WND_RCV = 128; // default receive window. must be >= max fragment size - public const int MTU_DEF = 1200; // default MTU (reduced to 1200 to fit all cases: https://en.wikipedia.org/wiki/Maximum_transmission_unit ; steam uses 1200 too!) - public const int ACK_FAST = 3; - public const int INTERVAL = 100; - public const int OVERHEAD = 24; - public const int FRG_MAX = byte.MaxValue; // kcp encodes 'frg' as byte. so we can only ever send up to 255 fragments. - public const int DEADLINK = 20; // default maximum amount of 'xmit' retransmissions until a segment is considered lost - public const int THRESH_INIT = 2; - public const int THRESH_MIN = 2; - public const int PROBE_INIT = 7000; // 7 secs to probe window size - public const int PROBE_LIMIT = 120000; // up to 120 secs to probe window - public const int FASTACK_LIMIT = 5; // max times to trigger fastack - - // kcp members. - internal int state; - readonly uint conv; // conversation - internal uint mtu; - internal uint mss; // maximum segment size := MTU - OVERHEAD - internal uint snd_una; // unacknowledged. e.g. snd_una is 9 it means 8 has been confirmed, 9 and 10 have been sent - internal uint snd_nxt; // forever growing send counter for sequence numbers - internal uint rcv_nxt; // forever growing receive counter for sequence numbers - internal uint ssthresh; // slow start threshold - internal int rx_rttval; // average deviation of rtt, used to measure the jitter of rtt - internal int rx_srtt; // smoothed round trip time (a weighted average of rtt) - internal int rx_rto; - internal int rx_minrto; - internal uint snd_wnd; // send window - internal uint rcv_wnd; // receive window - internal uint rmt_wnd; // remote window - internal uint cwnd; // congestion window - internal uint probe; - internal uint interval; - internal uint ts_flush; // last flush timestamp in milliseconds - internal uint xmit; - internal uint nodelay; // not a bool. original Kcp has '<2 else' check. - internal bool updated; - internal uint ts_probe; // probe timestamp - internal uint probe_wait; - internal uint dead_link; // maximum amount of 'xmit' retransmissions until a segment is considered lost - internal uint incr; - internal uint current; // current time (milliseconds). set by Update. - - internal int fastresend; - internal int fastlimit; - internal bool nocwnd; // congestion control, negated. heavily restricts send/recv window sizes. - internal readonly Queue snd_queue = new Queue(16); // send queue - internal readonly Queue rcv_queue = new Queue(16); // receive queue - // snd_buffer needs index removals. - // C# LinkedList allocates for each entry, so let's keep List for now. - internal readonly List snd_buf = new List(16); // send buffer - // rcv_buffer needs index insertions and backwards iteration. - // C# LinkedList allocates for each entry, so let's keep List for now. - internal readonly List rcv_buf = new List(16); // receive buffer - internal readonly List acklist = new List(16); - - // memory buffer - // size depends on MTU. - // MTU can be changed at runtime, which resizes the buffer. - internal byte[] buffer; - - // output function of type - readonly Action output; - - // segment pool to avoid allocations in C#. - // this is not part of the original C code. - readonly Pool SegmentPool = new Pool( - // create new segment - () => new Segment(), - // reset segment before reuse - (segment) => segment.Reset(), - // initial capacity - 32 - ); - - // ikcp_create - // create a new kcp control object, 'conv' must equal in two endpoint - // from the same connection. - public Kcp(uint conv, Action output) - { - this.conv = conv; - this.output = output; - snd_wnd = WND_SND; - rcv_wnd = WND_RCV; - rmt_wnd = WND_RCV; - mtu = MTU_DEF; - mss = mtu - OVERHEAD; - rx_rto = RTO_DEF; - rx_minrto = RTO_MIN; - interval = INTERVAL; - ts_flush = INTERVAL; - ssthresh = THRESH_INIT; - fastlimit = FASTACK_LIMIT; - dead_link = DEADLINK; - buffer = new byte[(mtu + OVERHEAD) * 3]; - } - - // ikcp_segment_new - // we keep the original function and add our pooling to it. - // this way we'll never miss it anywhere. - Segment SegmentNew() => SegmentPool.Take(); - - // ikcp_segment_delete - // we keep the original function and add our pooling to it. - // this way we'll never miss it anywhere. - void SegmentDelete(Segment seg) => SegmentPool.Return(seg); - - // calculate how many packets are waiting to be sent - public int WaitSnd => snd_buf.Count + snd_queue.Count; - - // ikcp_wnd_unused - // returns the remaining space in receive window (rcv_wnd - rcv_queue) - internal uint WndUnused() - { - if (rcv_queue.Count < rcv_wnd) - return rcv_wnd - (uint)rcv_queue.Count; - return 0; - } - - public int Receive(Memory memory, int len) - { - // kcp's ispeek feature is not supported. - // this makes 'merge fragment' code significantly easier because - // we can iterate while queue.Count > 0 and dequeue each time. - // if we had to consider ispeek then count would always be > 0 and - // we would have to remove only after the loop. - // - //bool ispeek = len < 0; - if (len < 0) - throw new NotSupportedException("Receive ispeek for negative len is not supported!"); - - if (rcv_queue.Count == 0) - return -1; - - if (len < 0) len = -len; - - int peeksize = PeekSize(); - - if (peeksize < 0) - return -2; - - if (peeksize > len) - return -3; - - bool recover = rcv_queue.Count >= rcv_wnd; - - // merge fragment. - int offset = 0; - len = 0; - // original KCP iterates rcv_queue and deletes if !ispeek. - // removing from a c# queue while iterating is not possible, but - // we can change to 'while Count > 0' and remove every time. - // (we can remove every time because we removed ispeek support!) - while (rcv_queue.Count > 0) - { - // unlike original kcp, we dequeue instead of just getting the - // entry. this is fine because we remove it in ANY case. - Segment seg = rcv_queue.Dequeue(); - // copy segment data into our buffer - var asMemory = seg.data.GetBuffer().AsMemory(); - var slice = asMemory.Slice(0, (int)seg.data.Position); - var offsetMemory = memory.Slice(offset); - slice.CopyTo(offsetMemory); - offset += (int)seg.data.Position; - len += (int)seg.data.Position; - uint fragment = seg.frg; - - // note: ispeek is not supported in order to simplify this loop - - // unlike original kcp, we don't need to remove seg from queue - // because we already dequeued it. - // simply delete it - SegmentDelete(seg); - - if (fragment == 0) - break; - } - - // move available data from rcv_buf -> rcv_queue - int removed = 0; - foreach (Segment seg in rcv_buf) - { - if (seg.sn == rcv_nxt && rcv_queue.Count < rcv_wnd) - { - // can't remove while iterating. remember how many to remove - // and do it after the loop. - // note: don't return segment. we only add it to rcv_queue - ++removed; - // add - rcv_queue.Enqueue(seg); - // increase sequence number for next segment - rcv_nxt++; - } - else - { - break; - } - } - - rcv_buf.RemoveRange(0, removed); - - // fast recover - if (rcv_queue.Count < rcv_wnd && recover) - { - // ready to send back CMD_WINS in flush - // tell remote my window size - probe |= ASK_TELL; - } - - return len; - } - - // ikcp_recv - // receive data from kcp state machine - // returns number of bytes read. - // returns negative on error. - // note: pass negative length to peek. - public int Receive(byte[] buffer, int len) - { - // kcp's ispeek feature is not supported. - // this makes 'merge fragment' code significantly easier because - // we can iterate while queue.Count > 0 and dequeue each time. - // if we had to consider ispeek then count would always be > 0 and - // we would have to remove only after the loop. - // - //bool ispeek = len < 0; - if (len < 0) - throw new NotSupportedException("Receive ispeek for negative len is not supported!"); - - if (rcv_queue.Count == 0) - return -1; - - if (len < 0) len = -len; - - int peeksize = PeekSize(); - - if (peeksize < 0) - return -2; - - if (peeksize > len) - return -3; - - bool recover = rcv_queue.Count >= rcv_wnd; - - // merge fragment. - int offset = 0; - len = 0; - // original KCP iterates rcv_queue and deletes if !ispeek. - // removing from a c# queue while iterating is not possible, but - // we can change to 'while Count > 0' and remove every time. - // (we can remove every time because we removed ispeek support!) - while (rcv_queue.Count > 0) - { - // unlike original kcp, we dequeue instead of just getting the - // entry. this is fine because we remove it in ANY case. - Segment seg = rcv_queue.Dequeue(); - - // copy segment data into our buffer - Buffer.BlockCopy(seg.data.GetBuffer(), 0, buffer, offset, (int)seg.data.Position); - offset += (int)seg.data.Position; - - len += (int)seg.data.Position; - uint fragment = seg.frg; - - // note: ispeek is not supported in order to simplify this loop - - // unlike original kcp, we don't need to remove seg from queue - // because we already dequeued it. - // simply delete it - SegmentDelete(seg); - - if (fragment == 0) - break; - } - - // move available data from rcv_buf -> rcv_queue - int removed = 0; - foreach (Segment seg in rcv_buf) - { - if (seg.sn == rcv_nxt && rcv_queue.Count < rcv_wnd) - { - // can't remove while iterating. remember how many to remove - // and do it after the loop. - // note: don't return segment. we only add it to rcv_queue - ++removed; - // add - rcv_queue.Enqueue(seg); - // increase sequence number for next segment - rcv_nxt++; - } - else - { - break; - } - } - rcv_buf.RemoveRange(0, removed); - - // fast recover - if (rcv_queue.Count < rcv_wnd && recover) - { - // ready to send back CMD_WINS in flush - // tell remote my window size - probe |= ASK_TELL; - } - - return len; - } - - // ikcp_peeksize - // check the size of next message in the recv queue. - // returns -1 if there is no message, or if the message is still incomplete. - public int PeekSize() - { - int length = 0; - - // empty queue? - if (rcv_queue.Count == 0) return -1; - - // peek the first segment - Segment seq = rcv_queue.Peek(); - - // seg.frg is 0 if the message requires no fragmentation. - // in that case, the segment's size is the final message size. - if (seq.frg == 0) return (int)seq.data.Position; - - // check if all fragment parts were received yet. - // seg.frg is the n-th fragment, but in reverse. - // this way the first received segment tells us how many fragments there are for the message. - // for example, if a message contains 3 segments: - // first segment: .frg is 2 (index in reverse) - // second segment: .frg is 1 (index in reverse) - // third segment: .frg is 0 (index in reverse) - if (rcv_queue.Count < seq.frg + 1) return -1; - - // recv_queue contains all the fragments necessary to reconstruct the message. - // sum all fragment's sizes to get the full message size. - foreach (Segment seg in rcv_queue) - { - length += (int)seg.data.Position; - if (seg.frg == 0) break; - } - - return length; - } - - public int Send(Memory memory) - { - // fragment count - int count; - var len = memory.Length; - if (len < 0) return -1; - - // streaming mode: removed. we never want to send 'hello' and - // receive 'he' 'll' 'o'. we want to always receive 'hello'. - - // calculate amount of fragments necessary for 'len' - if (len <= mss) count = 1; - else count = (int)((len + mss - 1) / mss); - - // IMPORTANT kcp encodes 'frg' as 1 byte. - // so we can only support up to 255 fragments. - // (which limits max message size to around 288 KB) - // this is difficult to debug. let's make this 100% obvious. - if (count > FRG_MAX) - throw new Exception($"Send len={len} requires {count} fragments, but kcp can only handle up to {FRG_MAX} fragments."); - - // original kcp uses WND_RCV const instead of rcv_wnd runtime: - // https://github.com/skywind3000/kcp/pull/291/files - // which always limits max message size to 144 KB: - //if (count >= WND_RCV) return -2; - // using configured rcv_wnd uncorks max message size to 'any': - if (count >= rcv_wnd) return -2; - - if (count == 0) count = 1; - - // fragment - var offset = 0; - for (int i = 0; i < count; i++) - { - int size = len > (int)mss ? (int)mss : len; - Segment seg = SegmentNew(); - - if (len > 0) - { - var slice = memory.Span.Slice(offset, size); - seg.data.Write(slice); - } - // seg.len = size: WriteBytes sets segment.Position! - - // set fragment number. - // if the message requires no fragmentation, then - // seg.frg becomes 1-0-1 = 0 - seg.frg = (uint)(count - i - 1); - snd_queue.Enqueue(seg); - offset += size; - len -= size; - } - - return 0; - } - - // ikcp_send - // splits message into MTU sized fragments, adds them to snd_queue. - public int Send(byte[] buffer, int offset, int len) - { - // fragment count - int count; - - if (len < 0) return -1; - - // streaming mode: removed. we never want to send 'hello' and - // receive 'he' 'll' 'o'. we want to always receive 'hello'. - - // calculate amount of fragments necessary for 'len' - if (len <= mss) count = 1; - else count = (int)((len + mss - 1) / mss); - - // IMPORTANT kcp encodes 'frg' as 1 byte. - // so we can only support up to 255 fragments. - // (which limits max message size to around 288 KB) - // this is difficult to debug. let's make this 100% obvious. - if (count > FRG_MAX) - throw new Exception($"Send len={len} requires {count} fragments, but kcp can only handle up to {FRG_MAX} fragments."); - - // original kcp uses WND_RCV const instead of rcv_wnd runtime: - // https://github.com/skywind3000/kcp/pull/291/files - // which always limits max message size to 144 KB: - //if (count >= WND_RCV) return -2; - // using configured rcv_wnd uncorks max message size to 'any': - if (count >= rcv_wnd) return -2; - - if (count == 0) count = 1; - - // fragment - for (int i = 0; i < count; i++) - { - int size = len > (int)mss ? (int)mss : len; - Segment seg = SegmentNew(); - - if (len > 0) - { - seg.data.Write(buffer, offset, size); - } - // seg.len = size: WriteBytes sets segment.Position! - - // set fragment number. - // if the message requires no fragmentation, then - // seg.frg becomes 1-0-1 = 0 - seg.frg = (uint)(count - i - 1); - snd_queue.Enqueue(seg); - offset += size; - len -= size; - } - - return 0; - } - - // ikcp_update_ack - void UpdateAck(int rtt) // round trip time - { - // https://tools.ietf.org/html/rfc6298 - if (rx_srtt == 0) - { - rx_srtt = rtt; - rx_rttval = rtt / 2; - } - else - { - int delta = rtt - rx_srtt; - if (delta < 0) delta = -delta; - rx_rttval = (3 * rx_rttval + delta) / 4; - rx_srtt = (7 * rx_srtt + rtt) / 8; - if (rx_srtt < 1) rx_srtt = 1; - } - int rto = rx_srtt + Math.Max((int)interval, 4 * rx_rttval); - rx_rto = Utils.Clamp(rto, rx_minrto, RTO_MAX); - } - - // ikcp_shrink_buf - internal void ShrinkBuf() - { - if (snd_buf.Count > 0) - { - Segment seg = snd_buf[0]; - snd_una = seg.sn; - } - else - { - snd_una = snd_nxt; - } - } - - // ikcp_parse_ack - // removes the segment with 'sn' from send buffer - internal void ParseAck(uint sn) - { - if (Utils.TimeDiff(sn, snd_una) < 0 || Utils.TimeDiff(sn, snd_nxt) >= 0) - return; - - // for-int so we can erase while iterating - for (int i = 0; i < snd_buf.Count; ++i) - { - // is this the segment? - Segment seg = snd_buf[i]; - if (sn == seg.sn) - { - // remove and return - snd_buf.RemoveAt(i); - SegmentDelete(seg); - break; - } - if (Utils.TimeDiff(sn, seg.sn) < 0) - { - break; - } - } - } - - // ikcp_parse_una - // removes all unacknowledged segments with sequence numbers < una from send buffer - internal void ParseUna(uint una) - { - int removed = 0; - foreach (Segment seg in snd_buf) - { - // if (Utils.TimeDiff(una, seg.sn) > 0) - if (seg.sn < una) - { - // can't remove while iterating. remember how many to remove - // and do it after the loop. - ++removed; - SegmentDelete(seg); - } - else - { - break; - } - } - snd_buf.RemoveRange(0, removed); - } - - // ikcp_parse_fastack - internal void ParseFastack(uint sn, uint ts) // serial number, timestamp - { - // sn needs to be between snd_una and snd_nxt - // if !(snd_una <= sn && sn < snd_nxt) return; - - // if (Utils.TimeDiff(sn, snd_una) < 0) - if (sn < snd_una) - return; - - // if (Utils.TimeDiff(sn, snd_nxt) >= 0) - if (sn >= snd_nxt) - return; - - foreach (Segment seg in snd_buf) - { - // if (Utils.TimeDiff(sn, seg.sn) < 0) - if (sn < seg.sn) - { - break; - } - else if (sn != seg.sn) - { -#if !FASTACK_CONSERVE - seg.fastack++; -#else - if (Utils.TimeDiff(ts, seg.ts) >= 0) - seg.fastack++; -#endif - } - } - } - - // ikcp_ack_push - // appends an ack. - void AckPush(uint sn, uint ts) // serial number, timestamp - { - acklist.Add(new AckItem{ serialNumber = sn, timestamp = ts }); - } - - // ikcp_parse_data - void ParseData(Segment newseg) - { - uint sn = newseg.sn; - - if (Utils.TimeDiff(sn, rcv_nxt + rcv_wnd) >= 0 || - Utils.TimeDiff(sn, rcv_nxt) < 0) - { - SegmentDelete(newseg); - return; - } - - InsertSegmentInReceiveBuffer(newseg); - MoveReceiveBufferReadySegmentsToQueue(); - } - - // inserts the segment into rcv_buf, ordered by seg.sn. - // drops the segment if one with the same seg.sn already exists. - // goes through receive buffer in reverse order for performance. - // - // note: see KcpTests.InsertSegmentInReceiveBuffer test! - // note: 'insert or delete' can be done in different ways, but let's - // keep consistency with original C kcp. - internal void InsertSegmentInReceiveBuffer(Segment newseg) - { - bool repeat = false; // 'duplicate' - - // original C iterates backwards, so we need to do that as well. - // note if rcv_buf.Count == 0, i becomes -1 and no looping happens. - int i; - for (i = rcv_buf.Count - 1; i >= 0; i--) - { - Segment seg = rcv_buf[i]; - if (seg.sn == newseg.sn) - { - // duplicate segment found. nothing will be added. - repeat = true; - break; - } - if (Utils.TimeDiff(newseg.sn, seg.sn) > 0) - { - // this entry's sn is < newseg.sn, so let's stop - break; - } - } - - // no duplicate? then insert. - if (!repeat) - { - rcv_buf.Insert(i + 1, newseg); - } - // duplicate. just delete it. - else - { - SegmentDelete(newseg); - } - } - - // move ready segments from rcv_buf -> rcv_queue. - // moves only the ready segments which are in rcv_nxt sequence order. - // some may still be missing an inserted later. - void MoveReceiveBufferReadySegmentsToQueue() - { - int removed = 0; - foreach (Segment seg in rcv_buf) - { - // move segments while they are in 'rcv_nxt' sequence order. - // some may still be missing and inserted later, in this case it stops immediately - // because segments always need to be received in the exact sequence order. - if (seg.sn == rcv_nxt && rcv_queue.Count < rcv_wnd) - { - // can't remove while iterating. remember how many to remove - // and do it after the loop. - ++removed; - rcv_queue.Enqueue(seg); - // increase sequence number for next segment - rcv_nxt++; - } - else - { - break; - } - } - rcv_buf.RemoveRange(0, removed); - } - - // ikcp_input - // used when you receive a low level packet (e.g. UDP packet) - // => original kcp uses offset=0, we made it a parameter so that high - // level can skip the channel byte more easily - public int Input(byte[] data, int offset, int size) - { - uint prev_una = snd_una; - uint maxack = 0; - uint latest_ts = 0; - int flag = 0; - - if (data == null || size < OVERHEAD) return -1; - - while (true) - { - // enough data left to decode segment (aka OVERHEAD bytes)? - if (size < OVERHEAD) break; - - // decode segment - offset += Utils.Decode32U(data, offset, out uint conv_); - if (conv_ != conv) return -1; - - offset += Utils.Decode8u(data, offset, out byte cmd); - // IMPORTANT kcp encodes 'frg' as 1 byte. - // so we can only support up to 255 fragments. - // (which limits max message size to around 288 KB) - offset += Utils.Decode8u(data, offset, out byte frg); - offset += Utils.Decode16U(data, offset, out ushort wnd); - offset += Utils.Decode32U(data, offset, out uint ts); - offset += Utils.Decode32U(data, offset, out uint sn); - offset += Utils.Decode32U(data, offset, out uint una); - offset += Utils.Decode32U(data, offset, out uint len); - - // reduce remaining size by what was read - size -= OVERHEAD; - - // enough remaining to read 'len' bytes of the actual payload? - // note: original kcp casts uint len to int for <0 check. - if (size < len || (int)len < 0) return -2; - - // validate command type - if (cmd != CMD_PUSH && cmd != CMD_ACK && - cmd != CMD_WASK && cmd != CMD_WINS) - return -3; - - rmt_wnd = wnd; - ParseUna(una); - ShrinkBuf(); - - if (cmd == CMD_ACK) - { - if (Utils.TimeDiff(current, ts) >= 0) - { - UpdateAck(Utils.TimeDiff(current, ts)); - } - ParseAck(sn); - ShrinkBuf(); - if (flag == 0) - { - flag = 1; - maxack = sn; - latest_ts = ts; - } - else - { - if (Utils.TimeDiff(sn, maxack) > 0) - { -#if !FASTACK_CONSERVE - maxack = sn; - latest_ts = ts; -#else - if (Utils.TimeDiff(ts, latest_ts) > 0) - { - maxack = sn; - latest_ts = ts; - } -#endif - } - } - } - else if (cmd == CMD_PUSH) - { - if (Utils.TimeDiff(sn, rcv_nxt + rcv_wnd) < 0) - { - AckPush(sn, ts); - if (Utils.TimeDiff(sn, rcv_nxt) >= 0) - { - Segment seg = SegmentNew(); - seg.conv = conv_; - seg.cmd = cmd; - seg.frg = frg; - seg.wnd = wnd; - seg.ts = ts; - seg.sn = sn; - seg.una = una; - if (len > 0) - { - seg.data.Write(data, offset, (int)len); - } - ParseData(seg); - } - } - } - else if (cmd == CMD_WASK) - { - // ready to send back CMD_WINS in flush - // tell remote my window size - probe |= ASK_TELL; - } - else if (cmd == CMD_WINS) - { - // do nothing - } - else - { - return -3; - } - - offset += (int)len; - size -= (int)len; - } - - if (flag != 0) - { - ParseFastack(maxack, latest_ts); - } - - // cwnd update when packet arrived - if (Utils.TimeDiff(snd_una, prev_una) > 0) - { - if (cwnd < rmt_wnd) - { - if (cwnd < ssthresh) - { - cwnd++; - incr += mss; - } - else - { - if (incr < mss) incr = mss; - incr += (mss * mss) / incr + (mss / 16); - if ((cwnd + 1) * mss <= incr) - { - cwnd = (incr + mss - 1) / ((mss > 0) ? mss : 1); - } - } - if (cwnd > rmt_wnd) - { - cwnd = rmt_wnd; - incr = rmt_wnd * mss; - } - } - } - - return 0; - } - - // flush helper function - void MakeSpace(ref int size, int space) - { - if (size + space > mtu) - { - output(buffer, size); - size = 0; - } - } - - // flush helper function - void FlushBuffer(int size) - { - // flush buffer up to 'offset' (<= MTU) - if (size > 0) - { - output(buffer, size); - } - } - - // ikcp_flush - // flush remain ack segments. - // flush may output multiple <= MTU messages from MakeSpace / FlushBuffer. - // the amount of messages depends on the sliding window. - // configured by send/receive window sizes + congestion control. - // with congestion control, the window will be extremely small(!). - public void Flush() - { - int size = 0; // amount of bytes to flush. 'buffer ptr' in C. - bool lost = false; // lost segments - - // update needs to be called before flushing - if (!updated) return; - - // kcp only stack allocates a segment here for performance, leaving - // its data buffer null because this segment's data buffer is never - // used. that's fine in C, but in C# our segment is a class so we - // need to allocate and most importantly, not forget to deallocate - // it before returning. - Segment seg = SegmentNew(); - seg.conv = conv; - seg.cmd = CMD_ACK; - seg.wnd = WndUnused(); - seg.una = rcv_nxt; - - // flush acknowledges - foreach (AckItem ack in acklist) - { - MakeSpace(ref size, OVERHEAD); - // ikcp_ack_get assigns ack[i] to seg.sn, seg.ts - seg.sn = ack.serialNumber; - seg.ts = ack.timestamp; - size += seg.Encode(buffer, size); - } - acklist.Clear(); - - // probe window size (if remote window size equals zero) - if (rmt_wnd == 0) - { - if (probe_wait == 0) - { - probe_wait = PROBE_INIT; - ts_probe = current + probe_wait; - } - else - { - if (Utils.TimeDiff(current, ts_probe) >= 0) - { - if (probe_wait < PROBE_INIT) - probe_wait = PROBE_INIT; - probe_wait += probe_wait / 2; - if (probe_wait > PROBE_LIMIT) - probe_wait = PROBE_LIMIT; - ts_probe = current + probe_wait; - probe |= ASK_SEND; - } - } - } - else - { - ts_probe = 0; - probe_wait = 0; - } - - // flush window probing commands - if ((probe & ASK_SEND) != 0) - { - seg.cmd = CMD_WASK; - MakeSpace(ref size, OVERHEAD); - size += seg.Encode(buffer, size); - } - - // flush window probing commands - if ((probe & ASK_TELL) != 0) - { - seg.cmd = CMD_WINS; - MakeSpace(ref size, OVERHEAD); - size += seg.Encode(buffer, size); - } - - probe = 0; - - // calculate the window size which is currently safe to send. - // it's send window, or remote window, whatever is smaller. - // for our max - uint cwnd_ = Math.Min(snd_wnd, rmt_wnd); - - // double negative: if congestion window is enabled: - // limit window size to cwnd. - // - // note this may heavily limit window sizes. - // for our max message size test with super large windows of 32k, - // 'congestion window' limits it down from 32.000 to 2. - if (!nocwnd) cwnd_ = Math.Min(cwnd, cwnd_); - - // move cwnd_ 'window size' messages from snd_queue to snd_buf - // 'snd_nxt' is what we want to send. - // 'snd_una' is what hasn't been acked yet. - // copy up to 'cwnd_' difference between them (sliding window) - while (Utils.TimeDiff(snd_nxt, snd_una + cwnd_) < 0) - { - if (snd_queue.Count == 0) break; - - Segment newseg = snd_queue.Dequeue(); - - newseg.conv = conv; - newseg.cmd = CMD_PUSH; - newseg.wnd = seg.wnd; - newseg.ts = current; - newseg.sn = snd_nxt; - snd_nxt += 1; // increase sequence number for next segment - newseg.una = rcv_nxt; - newseg.resendts = current; - newseg.rto = rx_rto; - newseg.fastack = 0; - newseg.xmit = 0; - snd_buf.Add(newseg); - } - - // calculate resent - uint resent = fastresend > 0 ? (uint)fastresend : 0xffffffff; - uint rtomin = nodelay == 0 ? (uint)rx_rto >> 3 : 0; - - // flush data segments - int change = 0; - foreach (Segment segment in snd_buf) - { - bool needsend = false; - - // initial transmit - if (segment.xmit == 0) - { - needsend = true; - segment.xmit++; - segment.rto = rx_rto; - segment.resendts = current + (uint)segment.rto + rtomin; - } - // RTO - else if (Utils.TimeDiff(current, segment.resendts) >= 0) - { - needsend = true; - segment.xmit++; - xmit++; - if (nodelay == 0) - { - segment.rto += Math.Max(segment.rto, rx_rto); - } - else - { - int step = (nodelay < 2) ? segment.rto : rx_rto; - segment.rto += step / 2; - } - segment.resendts = current + (uint)segment.rto; - lost = true; - } - // fast retransmit - else if (segment.fastack >= resent) - { - if (segment.xmit <= fastlimit || fastlimit <= 0) - { - needsend = true; - segment.xmit++; - segment.fastack = 0; - segment.resendts = current + (uint)segment.rto; - change++; - } - } - - if (needsend) - { - segment.ts = current; - segment.wnd = seg.wnd; - segment.una = rcv_nxt; - - int need = OVERHEAD + (int)segment.data.Position; - MakeSpace(ref size, need); - - size += segment.Encode(buffer, size); - - if (segment.data.Position > 0) - { - Buffer.BlockCopy(segment.data.GetBuffer(), 0, buffer, size, (int)segment.data.Position); - size += (int)segment.data.Position; - } - - // dead link happens if a message was resent N times, but an - // ack was still not received. - if (segment.xmit >= dead_link) - { - state = -1; - } - } - } - - // kcp stackallocs 'seg'. our C# segment is a class though, so we - // need to properly delete and return it to the pool now that we are - // done with it. - SegmentDelete(seg); - - // flush remaining segments - FlushBuffer(size); - - // update ssthresh - // rate halving, https://tools.ietf.org/html/rfc6937 - if (change > 0) - { - uint inflight = snd_nxt - snd_una; - ssthresh = inflight / 2; - if (ssthresh < THRESH_MIN) - ssthresh = THRESH_MIN; - cwnd = ssthresh + resent; - incr = cwnd * mss; - } - - // congestion control, https://tools.ietf.org/html/rfc5681 - if (lost) - { - // original C uses 'cwnd', not kcp->cwnd! - ssthresh = cwnd_ / 2; - if (ssthresh < THRESH_MIN) - ssthresh = THRESH_MIN; - cwnd = 1; - incr = mss; - } - - if (cwnd < 1) - { - cwnd = 1; - incr = mss; - } - } - - // ikcp_update - // update state (call it repeatedly, every 10ms-100ms), or you can ask - // Check() when to call it again (without Input/Send calling). - // - // 'current' - current timestamp in millisec. pass it to Kcp so that - // Kcp doesn't have to do any stopwatch/deltaTime/etc. code - // - // time as uint, likely to minimize bandwidth. - // uint.max = 4294967295 ms = 1193 hours = 49 days - public void Update(uint currentTimeMilliSeconds) - { - current = currentTimeMilliSeconds; - - // not updated yet? then set updated and last flush time. - if (!updated) - { - updated = true; - ts_flush = current; - } - - // slap is time since last flush in milliseconds - int slap = Utils.TimeDiff(current, ts_flush); - - // hard limit: if 10s elapsed, always flush no matter what - if (slap >= 10000 || slap < -10000) - { - ts_flush = current; - slap = 0; - } - - // last flush is increased by 'interval' each time. - // so slap >= is a strange way to check if interval has elapsed yet. - if (slap >= 0) - { - // increase last flush time by one interval - ts_flush += interval; - - // if last flush is still behind, increase it to current + interval - // if (Utils.TimeDiff(current, ts_flush) >= 0) // original kcp.c - if (current >= ts_flush) // less confusing - { - ts_flush = current + interval; - } - Flush(); - } - } - - // ikcp_check - // Determine when should you invoke update - // Returns when you should invoke update in millisec, if there is no - // input/send calling. you can call update in that time, instead of - // call update repeatly. - // - // Important to reduce unnecessary update invoking. use it to schedule - // update (e.g. implementing an epoll-like mechanism, or optimize update - // when handling massive kcp connections). - public uint Check(uint current_) - { - uint ts_flush_ = ts_flush; - // int tm_flush = 0x7fffffff; original kcp: useless assignment - int tm_packet = 0x7fffffff; - - if (!updated) - { - return current_; - } - - if (Utils.TimeDiff(current_, ts_flush_) >= 10000 || - Utils.TimeDiff(current_, ts_flush_) < -10000) - { - ts_flush_ = current_; - } - - if (Utils.TimeDiff(current_, ts_flush_) >= 0) - { - return current_; - } - - int tm_flush = Utils.TimeDiff(ts_flush_, current_); - - foreach (Segment seg in snd_buf) - { - int diff = Utils.TimeDiff(seg.resendts, current_); - if (diff <= 0) - { - return current_; - } - if (diff < tm_packet) tm_packet = diff; - } - - uint minimal = (uint)(tm_packet < tm_flush ? tm_packet : tm_flush); - if (minimal >= interval) minimal = interval; - - return current_ + minimal; - } - - // ikcp_setmtu - // Change MTU (Maximum Transmission Unit) size. - public void SetMtu(uint mtu) - { - if (mtu < 50 || mtu < OVERHEAD) - throw new ArgumentException("MTU must be higher than 50 and higher than OVERHEAD"); - - buffer = new byte[(mtu + OVERHEAD) * 3]; - this.mtu = mtu; - mss = mtu - OVERHEAD; - } - - // ikcp_interval - public void SetInterval(uint interval) - { - // clamp interval between 10 and 5000 - if (interval > 5000) interval = 5000; - else if (interval < 10) interval = 10; - this.interval = interval; - } - - // ikcp_nodelay - // configuration: https://github.com/skywind3000/kcp/blob/master/README.en.md#protocol-configuration - // nodelay : Whether nodelay mode is enabled, 0 is not enabled; 1 enabled. - // interval :Protocol internal work interval, in milliseconds, such as 10 ms or 20 ms. - // resend :Fast retransmission mode, 0 represents off by default, 2 can be set (2 ACK spans will result in direct retransmission) - // nc :Whether to turn off flow control, 0 represents “Do not turn off” by default, 1 represents “Turn off”. - // Normal Mode: ikcp_nodelay(kcp, 0, 40, 0, 0); - // Turbo Mode: ikcp_nodelay(kcp, 1, 10, 2, 1); - public void SetNoDelay(uint nodelay, uint interval = INTERVAL, int resend = 0, bool nocwnd = false) - { - this.nodelay = nodelay; - if (nodelay != 0) - { - rx_minrto = RTO_NDL; - } - else - { - rx_minrto = RTO_MIN; - } - - if (interval >= 0) - { - // clamp interval between 10 and 5000 - if (interval > 5000) interval = 5000; - else if (interval < 10) interval = 10; - this.interval = interval; - } - - if (resend >= 0) - { - fastresend = resend; - } - - this.nocwnd = nocwnd; - } - - // ikcp_wndsize - public void SetWindowSize(uint sendWindow, uint receiveWindow) - { - if (sendWindow > 0) - { - snd_wnd = sendWindow; - } - - if (receiveWindow > 0) - { - // must >= max fragment size - rcv_wnd = Math.Max(receiveWindow, WND_RCV); - } - } - } -} diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Kcp.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Kcp.cs.meta deleted file mode 100644 index 94ac97e2..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Kcp.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c43eaf92abd8f764bb6f94c9b5a701c4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Pool.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Pool.cs deleted file mode 100644 index 81b52895..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Pool.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Pool to avoid allocations (from libuv2k & Mirror) -using System; -using System.Collections.Generic; - -namespace kcp2k -{ - public class Pool - { - // Mirror is single threaded, no need for concurrent collections - readonly Stack objects = new Stack(); - - // some types might need additional parameters in their constructor, so - // we use a Func generator - readonly Func objectGenerator; - - // some types might need additional cleanup for returned objects - readonly Action objectResetter; - - public Pool(Func objectGenerator, Action objectResetter, int initialCapacity) - { - this.objectGenerator = objectGenerator; - this.objectResetter = objectResetter; - - // allocate an initial pool so we have fewer (if any) - // allocations in the first few frames (or seconds). - for (int i = 0; i < initialCapacity; ++i) - objects.Push(objectGenerator()); - } - - // take an element from the pool, or create a new one if empty - public T Take() => objects.Count > 0 ? objects.Pop() : objectGenerator(); - - // return an element to the pool - public void Return(T item) - { - objectResetter(item); - objects.Push(item); - } - - // clear the pool - public void Clear() => objects.Clear(); - - // count to see how many objects are in the pool. useful for tests. - public int Count => objects.Count; - } -} diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Pool.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Pool.cs.meta deleted file mode 100644 index 8bb774ee..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Pool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d78a539c8e8e73a46bd6ffd83d5e9d8c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Segment.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Segment.cs deleted file mode 100644 index d7e41317..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Segment.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System.IO; - -namespace kcp2k -{ - // KCP Segment Definition - internal class Segment - { - internal uint conv; // conversation - internal uint cmd; // command, e.g. Kcp.CMD_ACK etc. - // fragment (sent as 1 byte). - // 0 if unfragmented, otherwise fragment numbers in reverse: N,..,32,1,0 - // this way the first received segment tells us how many fragments there are. - internal uint frg; - internal uint wnd; // window size that the receive can currently receive - internal uint ts; // timestamp - internal uint sn; // sequence number - internal uint una; - internal uint resendts; // resend timestamp - internal int rto; - internal uint fastack; - internal uint xmit; // retransmit count - - // we need an auto scaling byte[] with a WriteBytes function. - // MemoryStream does that perfectly, no need to reinvent the wheel. - // note: no need to pool it, because Segment is already pooled. - // -> default MTU as initial capacity to avoid most runtime resizing/allocations - // - // .data is only used for Encode(), which always fits it into a buffer. - // the buffer is always Kcp.buffer. Kcp ctor creates the buffer of size: - // (mtu + OVERHEAD) * 3 bytes. - // in other words, Encode only ever writes up to the above amount of bytes. - internal MemoryStream data = new MemoryStream(Kcp.MTU_DEF); - - // ikcp_encode_seg - // encode a segment into buffer. - // buffer is always Kcp.buffer. Kcp ctor creates the buffer of size: - // (mtu + OVERHEAD) * 3 bytes. - // in other words, Encode only ever writes up to the above amount of bytes. - internal int Encode(byte[] ptr, int offset) - { - int previousPosition = offset; - - offset += Utils.Encode32U(ptr, offset, conv); - offset += Utils.Encode8u(ptr, offset, (byte)cmd); - // IMPORTANT kcp encodes 'frg' as 1 byte. - // so we can only support up to 255 fragments. - // (which limits max message size to around 288 KB) - offset += Utils.Encode8u(ptr, offset, (byte)frg); - offset += Utils.Encode16U(ptr, offset, (ushort)wnd); - offset += Utils.Encode32U(ptr, offset, ts); - offset += Utils.Encode32U(ptr, offset, sn); - offset += Utils.Encode32U(ptr, offset, una); - offset += Utils.Encode32U(ptr, offset, (uint)data.Position); - - int written = offset - previousPosition; - return written; - } - - // reset to return a fresh segment to the pool - internal void Reset() - { - conv = 0; - cmd = 0; - frg = 0; - wnd = 0; - ts = 0; - sn = 0; - una = 0; - rto = 0; - xmit = 0; - resendts = 0; - fastack = 0; - - // keep buffer for next pool usage, but reset length (= bytes written) - data.SetLength(0); - } - } -} diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Segment.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Segment.cs.meta deleted file mode 100644 index 3e8f7b42..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Segment.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8749c094620ccde478c15165010ffbf1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Utils.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Utils.cs deleted file mode 100644 index 2cb74628..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Utils.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System.Runtime.CompilerServices; - -namespace kcp2k -{ - public static partial class Utils - { - // Clamp so we don't have to depend on UnityEngine - public static int Clamp(int value, int min, int max) - { - if (value < min) return min; - if (value > max) return max; - return value; - } - - // encode 8 bits unsigned int - public static int Encode8u(byte[] p, int offset, byte value) - { - p[0 + offset] = value; - return 1; - } - - // decode 8 bits unsigned int - public static int Decode8u(byte[] p, int offset, out byte value) - { - value = p[0 + offset]; - return 1; - } - - // encode 16 bits unsigned int (lsb) - public static int Encode16U(byte[] p, int offset, ushort value) - { - p[0 + offset] = (byte)(value >> 0); - p[1 + offset] = (byte)(value >> 8); - return 2; - } - - // decode 16 bits unsigned int (lsb) - public static int Decode16U(byte[] p, int offset, out ushort value) - { - ushort result = 0; - result |= p[0 + offset]; - result |= (ushort)(p[1 + offset] << 8); - value = result; - return 2; - } - - // encode 32 bits unsigned int (lsb) - public static int Encode32U(byte[] p, int offset, uint value) - { - p[0 + offset] = (byte)(value >> 0); - p[1 + offset] = (byte)(value >> 8); - p[2 + offset] = (byte)(value >> 16); - p[3 + offset] = (byte)(value >> 24); - return 4; - } - - // decode 32 bits unsigned int (lsb) - public static int Decode32U(byte[] p, int offset, out uint value) - { - uint result = 0; - result |= p[0 + offset]; - result |= (uint)(p[1 + offset] << 8); - result |= (uint)(p[2 + offset] << 16); - result |= (uint)(p[3 + offset] << 24); - value = result; - return 4; - } - - // timediff was a macro in original Kcp. let's inline it if possible. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int TimeDiff(uint later, uint earlier) - { - return (int)(later - earlier); - } - } -} diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Utils.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Utils.cs.meta deleted file mode 100644 index 0835b931..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Base/kcp2k/kcp/Utils.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 927985771e12e4c45b199b20c8477369 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Client.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Client.meta deleted file mode 100644 index ea58fcb9..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Client.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 1473c7e4a4d90be48be9a6350645b8d0 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Client/KCPClientNetwork.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Client/KCPClientNetwork.cs deleted file mode 100644 index 331333e3..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Client/KCPClientNetwork.cs +++ /dev/null @@ -1,569 +0,0 @@ -#if !UNITY_WEBGL -using System; -using System.Buffers; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Net.Sockets; -using System.Runtime.InteropServices; -using System.Threading; -using kcp2k; -// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract -// ReSharper disable PossibleNullReferenceException -// ReSharper disable InconsistentNaming - -namespace TEngine.Core.Network -{ - public sealed class KCPClientNetwork : AClientNetwork, INetworkUpdate - { - #region 逻辑线程 - - private bool _isInit; - private long _connectTimeoutId; - public override event Action OnDispose; - public override event Action OnConnectFail; - public override event Action OnConnectComplete; - public override event Action OnConnectDisconnect; - public override event Action OnChangeChannelId; - public override event Action OnReceiveMemoryStream; - - public KCPClientNetwork(Scene scene, NetworkTarget networkTarget) : base(scene, NetworkType.Client, NetworkProtocolType.KCP, networkTarget) - { - _startTime = TimeHelper.Now; - NetworkThread.Instance.AddNetwork(this); - } - - public override void Dispose() - { - if (IsDisposed) - { - return; - } - - IsDisposed = true; - - NetworkThread.Instance.SynchronizationContext.Post(() => - { - if (!_isDisconnect) - { - SendHeader(KcpHeader.Disconnect); - } - - if (_socket.Connected) - { - if (OnConnectDisconnect != null) - { - ThreadSynchronizationContext.Main.Post(OnConnectDisconnect); - } - - _socket.Close(); - } - - _kcp = null; - _maxSndWnd = 0; - _updateMinTime = 0; - _memoryPool.Dispose(); - _memoryPool = null; - _sendAction = null; - _rawSendBuffer = null; - _rawReceiveBuffer = null; - - _packetParser?.Dispose(); - - ClearConnectTimeout(ref _connectTimeoutId); - - if (_messageCache != null) - { - _messageCache.Clear(); - _messageCache = null; - } -#if NETDEBUG - Log.Debug($"KCPClientNetwork ConnectionPtrChannel:{ConnectionPtrChannel.Count}"); -#endif - _updateTimer.Clear(); - _updateTimeOutTime.Clear(); - ThreadSynchronizationContext.Main.Post(OnDispose); - base.Dispose(); - }); - } - - public override uint Connect(IPEndPoint remoteEndPoint, Action onConnectComplete, Action onConnectFail, Action onConnectDisconnect, int connectTimeout = 5000) - { - if (_isInit) - { - throw new NotSupportedException($"KCPClientNetwork Id:{Id} Has already been initialized. If you want to call Connect again, please re instantiate it."); - } - - _isInit = true; - OnConnectFail = onConnectFail; - OnConnectComplete = onConnectComplete; - OnConnectDisconnect = onConnectDisconnect; - ChannelId = CreateChannelId(); - _kcpSettings = KCPSettings.Create(NetworkTarget); - _maxSndWnd = _kcpSettings.MaxSendWindowSize; - _messageCache = new Queue(); - _rawReceiveBuffer = new byte[_kcpSettings.Mtu + 5]; - _memoryPool = MemoryPool.Shared; - - _sendAction = (rpcId, routeTypeOpCode, routeId, memoryStream, message) => - { - _messageCache.Enqueue(new MessageCacheInfo() - { - RpcId = rpcId, - RouteId = routeId, - RouteTypeOpCode = routeTypeOpCode, - Message = message, - MemoryStream = memoryStream - }); - }; - - _connectTimeoutId = TimerScheduler.Instance.Core.OnceTimer(connectTimeout, () => - { - if (OnConnectFail == null) - { - return; - } - OnConnectFail(); - Dispose(); - }); - - NetworkThread.Instance.SynchronizationContext.Post(() => - { - _socket = new Socket(remoteEndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp); - _socket.SetSocketBufferToOsLimit(); - NetworkHelper.SetSioUdpConnReset(_socket); - _socket.Connect(remoteEndPoint); - SendHeader(KcpHeader.RequestConnection); - }); - - return ChannelId; - } - - #endregion - - #region 网络主线程 - - private Socket _socket; - private int _maxSndWnd; - private Kcp _kcp; - private bool _isDisconnect; - private long _updateMinTime; - private byte[] _rawSendBuffer; - private readonly long _startTime; - private byte[] _rawReceiveBuffer; - private KCPSettings _kcpSettings; - private APacketParser _packetParser; - private MemoryPool _memoryPool; - private Queue _messageCache; - private Action _sendAction; - private readonly Queue _updateTimeOutTime = new Queue(); - private EndPoint _clientEndPoint = new IPEndPoint(IPAddress.Any, 0); - private readonly SortedSet _updateTimer = new SortedSet(); - private uint TimeNow => (uint) (TimeHelper.Now - _startTime); - - private void Receive() - { - while (_socket != null && _socket.Poll(0, SelectMode.SelectRead)) - { - try - { - var receiveLength = _socket.ReceiveFrom(_rawReceiveBuffer, ref _clientEndPoint); - - if (receiveLength > _rawReceiveBuffer.Length) - { - Log.Error($"KCP ClientConnection: message of size {receiveLength} does not fit into buffer of size {_rawReceiveBuffer.Length}. The excess was silently dropped. Disconnecting."); - Dispose(); - return; - } - - var header = (KcpHeader) _rawReceiveBuffer[0]; - var channelId = BitConverter.ToUInt32(_rawReceiveBuffer, 1); - - switch (header) - { - case KcpHeader.RepeatChannelId: - { - if (receiveLength != 5 || channelId != ChannelId) - { - break; - } - - // 到这里是客户端的channelId再服务器上已经存在、需要重新生成一个再次尝试连接 - ChannelId = CreateChannelId(); - SendHeader(KcpHeader.RequestConnection); - // 这里要处理入如果有发送的消息的问题、后面处理 - break; - } - case KcpHeader.WaitConfirmConnection: - { - if (receiveLength != 5 || channelId != ChannelId) - { - break; - } - - SendHeader(KcpHeader.ConfirmConnection); - ClearConnectTimeout(ref _connectTimeoutId); - // 创建KCP和相关的初始化 - _kcp = new Kcp(channelId, Output); - _kcp.SetNoDelay(1, 5, 2, true); - _kcp.SetWindowSize(_kcpSettings.SendWindowSize, _kcpSettings.ReceiveWindowSize); - _kcp.SetMtu(_kcpSettings.Mtu); - _rawSendBuffer = new byte[ushort.MaxValue]; - _packetParser = APacketParser.CreatePacketParser(NetworkTarget); - - // 把缓存的消息全部发送给服务器 - - _sendAction = (rpcId, routeTypeOpCode, routeId, memoryStream, message) => - { - if (IsDisposed) - { - return; - } - - memoryStream = Pack(rpcId, routeTypeOpCode, routeId, memoryStream, message); - Send(memoryStream); - }; - - while (_messageCache.TryDequeue(out var messageCache)) - { - _sendAction( - messageCache.RpcId, - messageCache.RouteTypeOpCode, - messageCache.RouteId, - messageCache.MemoryStream, - messageCache.Message); - } - - _messageCache.Clear(); - _messageCache = null; - // 调用ChannelId改变事件、就算没有改变也要发下、接收事件的地方会判定下 - ThreadSynchronizationContext.Main.Post(() => - { - OnChangeChannelId(ChannelId); - OnConnectComplete?.Invoke(); - }); - // 到这里正确创建上连接了、可以正常发送消息了 - break; - } - case KcpHeader.ReceiveData: - { - var messageLength = receiveLength - 5; - - if (messageLength <= 0) - { - Log.Warning($"KCPClient KcpHeader.Data messageLength <= 0"); - break; - } - - if (channelId != ChannelId) - { - break; - } - - _kcp.Input(_rawReceiveBuffer, 5, messageLength); - AddToUpdate(0); - KcpReceive(); - break; - } - case KcpHeader.Disconnect: - { - if (channelId != ChannelId) - { - break; - } - - _isDisconnect = true; - Dispose(); - break; - } - } - } - // this is fine, the socket might have been closed in the other end - catch (SocketException) { } - catch (Exception e) - { - Log.Error(e); - } - } - } - - private void Send(MemoryStream memoryStream) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - // 检查等待发送的消息,如果超出两倍窗口大小,KCP作者给的建议是要断开连接 - - var waitSendSize = _kcp.WaitSnd; - - if (waitSendSize > _maxSndWnd) - { - Log.Warning($"ERR_KcpWaitSendSizeTooLarge {waitSendSize} > {_maxSndWnd}"); - Dispose(); - return; - } - - _kcp.Send(memoryStream.GetBuffer(), 0, (int)memoryStream.Length); - memoryStream.Dispose(); - AddToUpdate(0); - } - - public override void Send(uint channelId, uint rpcId, long routeTypeOpCode, long entityId, MemoryStream memoryStream) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (IsDisposed) - { - return; - } - - _sendAction(rpcId, routeTypeOpCode, entityId, memoryStream, null); - } - - public override void Send(uint channelId, uint rpcId, long routeTypeOpCode, long entityId, object message) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (IsDisposed) - { - return; - } - - _sendAction(rpcId, routeTypeOpCode, entityId, null, message); - } - - private void Output(byte[] bytes, int count) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (IsDisposed) - { - return; - } - - try - { - if (count == 0) - { - throw new Exception("KcpOutput count 0"); - } - - _rawSendBuffer.WriteTo(0, (byte) KcpHeader.ReceiveData); - _rawSendBuffer.WriteTo(1, ChannelId); - Buffer.BlockCopy(bytes, 0, _rawSendBuffer, 5, count); - _socket.Send(_rawSendBuffer, 0, count + 5, SocketFlags.None); - } - catch (Exception e) - { - Log.Error(e); - } - } - - private void KcpReceive() - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (IsDisposed) - { - return; - } - - for (;;) - { - try - { - // 获得一个完整消息的长度 - - var peekSize = _kcp.PeekSize(); - - // 如果没有接收的消息那就跳出当前循环。 - - if (peekSize < 0) - { - return; - } - - // 如果为0,表示当前消息发生错误。提示下、一般情况不会发生的 - - if (peekSize == 0) - { - throw new Exception("SocketError.NetworkReset"); - } - - var receiveMemoryOwner = _memoryPool.Rent(Packet.OuterPacketMaxLength); - var receiveCount = _kcp.Receive(receiveMemoryOwner.Memory, peekSize); - - // 如果接收的长度跟peekSize不一样,不需要处理,因为消息肯定有问题的(虽然不可能出现)。 - - if (receiveCount != peekSize) - { - Log.Error($"receiveCount != peekSize receiveCount:{receiveCount} peekSize:{peekSize}"); - break; - } - - if (!_packetParser.UnPack(receiveMemoryOwner, out var packInfo)) - { - break; - } - - ThreadSynchronizationContext.Main.Post(() => - { - if (IsDisposed) - { - return; - } - - OnReceiveMemoryStream(packInfo); - }); - } - catch (Exception e) - { - Log.Error(e); - } - } - } - - public void Update() - { - Receive(); - - var nowTime = TimeNow; - - if (_updateTimer.Count == 0 || nowTime < _updateMinTime) - { - return; - } - - foreach (var timeId in _updateTimer) - { - if (timeId > nowTime) - { - _updateMinTime = timeId; - break; - } - - _updateTimeOutTime.Enqueue(timeId); - } - - while (_updateTimeOutTime.TryDequeue(out var time)) - { - KcpUpdate(); - _updateTimer.Remove(time); - } - } - - private void AddToUpdate(uint tillTime) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (tillTime == 0) - { - KcpUpdate(); - return; - } - - if (tillTime < _updateMinTime || _updateMinTime == 0) - { - _updateMinTime = tillTime; - } - - _updateTimer.Add(tillTime); - } - - private void KcpUpdate() - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - var nowTime = TimeNow; - - try - { - _kcp.Update(nowTime); - } - catch (Exception e) - { - Log.Error(e); - } - - AddToUpdate(_kcp.Check(nowTime)); - } - - public override void RemoveChannel(uint channelId) - { - Dispose(); - } - - private uint CreateChannelId() - { - return 0xC0000000 | (uint) new Random().Next(); - } - - private void SendHeader(KcpHeader kcpHeader) - { - if (_socket == null || !_socket.Connected) - { - return; - } - - var buff = new byte[5]; - buff.WriteTo(0, (byte) kcpHeader); - buff.WriteTo(1, ChannelId); - _socket.Send(buff, 5, SocketFlags.None); - } - - private void ClearConnectTimeout(ref long connectTimeoutId) - { - if (connectTimeoutId == 0) - { - return; - } - - if (NetworkThread.Instance.ManagedThreadId == Thread.CurrentThread.ManagedThreadId) - { - var timeoutId = connectTimeoutId; - ThreadSynchronizationContext.Main.Post(() => { TimerScheduler.Instance.Core.Remove(timeoutId); }); - connectTimeoutId = 0; - return; - } - - TimerScheduler.Instance.Core.RemoveByRef(ref connectTimeoutId); - } - - #endregion - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Client/KCPClientNetwork.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Client/KCPClientNetwork.cs.meta deleted file mode 100644 index 6f34f121..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Client/KCPClientNetwork.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1d5d5ba58fd350045bd57bf3ab5d5c12 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server.meta deleted file mode 100644 index cc28e0b4..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 574d8620bd02b254bbf2cc4a821fd371 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server/KCPServerNetwork.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server/KCPServerNetwork.cs deleted file mode 100644 index 2af57363..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server/KCPServerNetwork.cs +++ /dev/null @@ -1,464 +0,0 @@ -#if !UNITY_WEBGL -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Net.Sockets; -using TEngine.DataStructure; -using kcp2k; - -// ReSharper disable InconsistentNaming -// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract - -namespace TEngine.Core.Network -{ - public class KCPServerNetwork : ANetwork, INetworkUpdate - { - #region 逻辑线程 - - public KCPServerNetwork(Scene scene, NetworkTarget networkTarget, IPEndPoint address) : base(scene, NetworkType.Server, NetworkProtocolType.KCP, networkTarget) - { - _startTime = TimeHelper.Now; - NetworkThread.Instance.AddNetwork(this); - - NetworkThread.Instance.SynchronizationContext.Post(() => - { - KcpSettings = KCPSettings.Create(NetworkTarget); - _rawReceiveBuffer = new byte[KcpSettings.Mtu + 5]; - - _socket = new Socket(address.AddressFamily, SocketType.Dgram, ProtocolType.Udp); - _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, false); - - if (address.AddressFamily == AddressFamily.InterNetworkV6) - { - _socket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, false); - } - - _socket.Bind(address); - _socket.SetSocketBufferToOsLimit(); - NetworkHelper.SetSioUdpConnReset(_socket); - }); - } - - public override void Dispose() - { - if (IsDisposed) - { - return; - } - - IsDisposed = true; - - NetworkThread.Instance.SynchronizationContext.Post(() => - { - if (_socket.Connected) - { - _socket.Disconnect(false); - _socket.Close(); - } - - var channels = new List(); - - channels.AddRange(_connectionChannel.Values); - channels.AddRange(_pendingConnection.Values); - - foreach (var channel in channels.Where(channel => !channel.IsDisposed)) - { - channel.Dispose(); - } - - _updateTimeOutTime.Clear(); - _updateChannels.Clear(); - _pendingTimeOutTime.Clear(); - _updateTimer.Clear(); - _pendingConnectionTimer.Clear(); - _pendingConnection.Clear(); - _connectionChannel.Clear(); - - _socket = null; - KcpSettings = null; - _updateMinTime = 0; - _pendingMinTime = 0; - base.Dispose(); - }); - } - - #endregion - - #region 网络主线程 - - private Socket _socket; - private uint _updateMinTime; - private uint _pendingMinTime; - private byte[] _rawReceiveBuffer; - private readonly long _startTime; - private readonly byte[] _sendBuff = new byte[5]; - private EndPoint _clientEndPoint = new IPEndPoint(IPAddress.Any, 0); - private readonly Queue _updateTimeOutTime = new Queue(); - private readonly HashSet _updateChannels = new HashSet(); - private readonly Queue _pendingTimeOutTime = new Queue(); - private readonly SortedOneToManyHashSet _updateTimer = new SortedOneToManyHashSet(); - private readonly SortedOneToManyList _pendingConnectionTimer = new SortedOneToManyList(); - private readonly Dictionary _pendingConnection = new Dictionary(); - private readonly Dictionary _connectionChannel = new Dictionary(); - private KCPSettings KcpSettings { get; set; } - private uint TimeNow => (uint) (TimeHelper.Now - _startTime); - - public override void Send(uint channelId, uint rpcId, long routeTypeOpCode, long routeId, MemoryStream memoryStream) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (!_connectionChannel.TryGetValue(channelId, out var channel)) - { - return; - } - - var sendMemoryStream = Pack(rpcId, routeTypeOpCode, routeId, memoryStream, null); - channel.Send(sendMemoryStream); - } - - public override void Send(uint channelId, uint rpcId, long routeTypeOpCode, long routeId, object message) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (!_connectionChannel.TryGetValue(channelId, out var channel)) - { - return; - } - - var memoryStream = Pack(rpcId, routeTypeOpCode, routeId, null, message); - channel.Send(memoryStream); - } - - private void SendToRepeatChannelId(uint channelId, EndPoint clientEndPoint) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - _sendBuff.WriteTo(0, (byte) KcpHeader.RepeatChannelId); - _sendBuff.WriteTo(1, channelId); - _socket.SendTo(_sendBuff, 0, 5, SocketFlags.None, clientEndPoint); - } - - private void Receive() - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - while (_socket != null && _socket.Available > 0) - { - try - { - var receiveLength = _socket.ReceiveFrom(_rawReceiveBuffer, ref _clientEndPoint); - - if (receiveLength < 1) - { - continue; - } - - var header = (KcpHeader) _rawReceiveBuffer[0]; - var channelId = BitConverter.ToUInt32(_rawReceiveBuffer, 1); - - switch (header) - { - case KcpHeader.RequestConnection: - { - if (receiveLength != 5) - { - break; - } - - if (_pendingConnection.TryGetValue(channelId, out var channel)) - { - if (!_clientEndPoint.Equals(channel.RemoteEndPoint)) - { - SendToRepeatChannelId(channelId, _clientEndPoint); - } - - break; - } - - if (_connectionChannel.ContainsKey(channelId)) - { - SendToRepeatChannelId(channelId, _clientEndPoint); - break; - } - - var timeNow = TimeNow; - var tillTime = timeNow + 10 * 1000; - var pendingChannel = new KCPServerNetworkChannel(Scene, channelId, Id, _clientEndPoint, _socket, timeNow); - - if (tillTime < _pendingMinTime || _pendingMinTime == 0) - { - _pendingMinTime = tillTime; - } - - _pendingConnection.Add(channelId, pendingChannel); - _pendingConnectionTimer.Add(tillTime, channelId); - _sendBuff.WriteTo(0, (byte) KcpHeader.WaitConfirmConnection); - _sendBuff.WriteTo(1, channelId); - _socket.SendTo(_sendBuff, 0, 5, SocketFlags.None, _clientEndPoint); - break; - } - case KcpHeader.ConfirmConnection: - { - if (receiveLength != 5) - { - break; - } - - if (!RemovePendingConnection(channelId, _clientEndPoint, out var channel)) - { - break; - } - - var kcp = new Kcp(channelId, channel.Output); - kcp.SetNoDelay(1, 5, 2, true); - kcp.SetWindowSize(KcpSettings.SendWindowSize, KcpSettings.ReceiveWindowSize); - kcp.SetMtu(KcpSettings.Mtu); - _connectionChannel.Add(channel.Id, channel); - channel.Connect(kcp, AddToUpdate, KcpSettings.MaxSendWindowSize, NetworkTarget, NetworkMessageScheduler); - break; - } - case KcpHeader.ReceiveData: - { - var messageLength = receiveLength - 5; - - if (messageLength <= 0) - { - Log.Warning($"KCP Server KcpHeader.Data messageLength <= 0"); - break; - } - - if (!_connectionChannel.TryGetValue(channelId, out var channel)) - { - break; - } - - channel.Kcp.Input(_rawReceiveBuffer, 5, messageLength); - AddToUpdate(0, channel.Id); - channel.Receive(); - break; - } - case KcpHeader.Disconnect: - { - // Log.Debug("KcpHeader.Disconnect"); - RemoveChannel(channelId); - break; - } - } - } - catch (Exception e) - { - Log.Error(e); - } - } - } - - - private bool RemovePendingConnection(uint channelId, EndPoint remoteEndPoint, out KCPServerNetworkChannel channel) - { -#if TENGINE_DEVELOP - channel = null; - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return false; - } -#endif - if (!_pendingConnection.TryGetValue(channelId, out channel) || channel.IsDisposed) - { - return false; - } - - if (remoteEndPoint != null && !remoteEndPoint.Equals(channel.RemoteEndPoint)) - { - Log.Error($"KCPNetworkChannel syn address diff: {channelId} {channel.RemoteEndPoint} {remoteEndPoint}"); - return false; - } - - _pendingConnection.Remove(channelId); - _pendingConnectionTimer.RemoveValue(channel.CreateTime + 10 * 1000, channelId); -#if NETDEBUG - Log.Debug($"KCPServerNetwork _pendingConnection:{_pendingConnection.Count} _pendingConnectionTimer:{_pendingConnectionTimer.Count}"); -#endif - return true; - } - - public override void RemoveChannel(uint channelId) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (IsDisposed) - { - return; - } - - if (_connectionChannel.Remove(channelId, out var channel)) - { -#if NETDEBUG - Log.Debug($"KCPServerNetwork _connectionChannel:{_connectionChannel.Count}"); -#endif - channel.Dispose(); - return; - } - - if (RemovePendingConnection(channelId, null, out channel) && !channel.IsDisposed) - { - channel.Dispose(); - } - } - - public void Update() - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - Receive(); - - var nowTime = TimeNow; - - if (nowTime >= _updateMinTime && _updateTimer.Count > 0) - { - foreach (var timeId in _updateTimer) - { - var key = timeId.Key; - - if (key > nowTime) - { - _updateMinTime = key; - break; - } - - _updateTimeOutTime.Enqueue(key); - } - - while (_updateTimeOutTime.TryDequeue(out var time)) - { - foreach (var channelId in _updateTimer[time]) - { - _updateChannels.Add(channelId); - } - - _updateTimer.RemoveKey(time); - } - } - - if (_updateChannels.Count > 0) - { - foreach (var channelId in _updateChannels) - { - if (!_connectionChannel.TryGetValue(channelId, out var channel)) - { - continue; - } - - if (channel.IsDisposed) - { - continue; - } - - var channelKcp = channel.Kcp; - try - { - channelKcp.Update(nowTime); - } - catch (Exception e) - { - Log.Error(e); - } - - if (channelKcp != null) - { - AddToUpdate(channelKcp.Check(nowTime), channelId); - } - } - - _updateChannels.Clear(); - } - - if (_pendingConnection.Count <= 0 || nowTime < _pendingMinTime) - { - return; - } - - foreach (var timeId in _pendingConnectionTimer) - { - var key = timeId.Key; - - if (key > nowTime) - { - _pendingMinTime = key; - break; - } - - foreach (var channelId in timeId.Value) - { - _pendingTimeOutTime.Enqueue(channelId); - } - } - - while (_pendingTimeOutTime.TryDequeue(out var channelId)) - { - if (RemovePendingConnection(channelId, null, out var channel)) - { - channel.Dispose(); - } - } - } - - private void AddToUpdate(uint tillTime, uint channelId) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (tillTime == 0) - { - _updateChannels.Add(channelId); - return; - } - - if (tillTime < _updateMinTime || _updateMinTime == 0) - { - _updateMinTime = tillTime; - } - - _updateTimer.Add(tillTime, channelId); - } - - #endregion - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server/KCPServerNetwork.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server/KCPServerNetwork.cs.meta deleted file mode 100644 index aeacb476..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server/KCPServerNetwork.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0a2a741a97ea685468eef08c6f5544fa -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server/KCPServerNetworkChannel.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server/KCPServerNetworkChannel.cs deleted file mode 100644 index 9e3c2d86..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server/KCPServerNetworkChannel.cs +++ /dev/null @@ -1,237 +0,0 @@ -#if !UNITY_WEBGL -using System; -using System.Buffers; -using System.IO; -using System.Net; -using System.Net.Sockets; -using System.Runtime.InteropServices; -using TEngine.DataStructure; -using kcp2k; -// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract - -// ReSharper disable InconsistentNaming - -namespace TEngine.Core.Network -{ - public sealed class KCPServerNetworkChannel : ANetworkChannel - { - #region 网络主线程 - - private int _maxSndWnd; - private byte[] _rawSendBuffer; - public readonly uint CreateTime; - private readonly Socket _socket; - private Action _addToUpdate; - private MemoryPool _memoryPool; - public Kcp Kcp { get; private set; } - - public override event Action OnDispose; - public override event Action OnReceiveMemoryStream; - - public KCPServerNetworkChannel(Scene scene, uint id, long networkId, EndPoint remoteEndPoint, Socket socket, uint createTime) : base(scene, id, networkId) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - _socket = socket; - CreateTime = createTime; - RemoteEndPoint = remoteEndPoint; - _memoryPool = MemoryPool.Shared; - } - - public override void Dispose() - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (IsDisposed) - { - return; - } - - Kcp = null; - var buff = new byte[5]; - buff.WriteTo(0, (byte) KcpHeader.Disconnect); - buff.WriteTo(1, Id); - _socket.SendTo(buff, 5, SocketFlags.None, RemoteEndPoint); -#if NETDEBUG - Log.Debug($"KCPServerNetworkChannel ConnectionPtrChannel:{KCPServerNetwork.ConnectionPtrChannel.Count}"); -#endif - _maxSndWnd = 0; - _addToUpdate = null; - _memoryPool.Dispose(); - _memoryPool = null; - ThreadSynchronizationContext.Main.Post(OnDispose); - base.Dispose(); - } - - public void Connect(Kcp kcp, Action addToUpdate, int maxSndWnd, NetworkTarget networkTarget, ANetworkMessageScheduler networkMessageScheduler) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - Kcp = kcp; - _maxSndWnd = maxSndWnd; - _addToUpdate = addToUpdate; - _rawSendBuffer = new byte[ushort.MaxValue]; - PacketParser = APacketParser.CreatePacketParser(networkTarget); - - ThreadSynchronizationContext.Main.Post(() => - { - if (IsDisposed) - { - return; - } - - Session.Create(networkMessageScheduler, this, networkTarget); - }); - } - - public void Send(MemoryStream memoryStream) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (IsDisposed) - { - return; - } - - // 检查等待发送的消息,如果超出两倍窗口大小,KCP作者给的建议是要断开连接 - - var waitSendSize = Kcp.WaitSnd; - - if (waitSendSize > _maxSndWnd) - { - Log.Warning($"ERR_KcpWaitSendSizeTooLarge {waitSendSize} > {_maxSndWnd}"); - Dispose(); - return; - } - // 发送消息 - Kcp.Send(memoryStream.GetBuffer(), 0, (int)memoryStream.Length); - // 因为memoryStream对象池出来的、所以需要手动回收下 - memoryStream.Dispose(); - _addToUpdate(0, Id); - } - - public void Receive() - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (IsDisposed) - { - return; - } - - for (;;) - { - try - { - // 获得一个完整消息的长度 - - var peekSize = Kcp.PeekSize(); - - // 如果没有接收的消息那就跳出当前循环。 - - if (peekSize < 0) - { - return; - } - - // 如果为0,表示当前消息发生错误。提示下、一般情况不会发生的 - if (peekSize == 0) - { - throw new Exception("SocketError.NetworkReset"); - } - - var receiveMemoryOwner = _memoryPool.Rent(Packet.OuterPacketMaxLength); - var receiveCount = Kcp.Receive(receiveMemoryOwner.Memory, peekSize); - - // 如果接收的长度跟peekSize不一样,不需要处理,因为消息肯定有问题的(虽然不可能出现)。 - - if (receiveCount != peekSize) - { - Log.Error($"receiveCount != peekSize receiveCount:{receiveCount} peekSize:{peekSize}"); - break; - } - - if (!PacketParser.UnPack(receiveMemoryOwner,out var packInfo)) - { - break; - } - - ThreadSynchronizationContext.Main.Post(() => - { - if (IsDisposed) - { - return; - } - - // ReSharper disable once PossibleNullReferenceException - OnReceiveMemoryStream(packInfo); - }); - } - catch (Exception e) - { - Log.Error(e); - } - } - } - - public void Output(byte[] bytes, int count) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (IsDisposed) - { - return; - } - - try - { - if (count == 0) - { - throw new Exception("KcpOutput count 0"); - } - - _rawSendBuffer.WriteTo(0, (byte) KcpHeader.ReceiveData); - _rawSendBuffer.WriteTo(1, Id); - Buffer.BlockCopy(bytes, 0, _rawSendBuffer, 5, count); - _socket.SendTo(_rawSendBuffer, 0, count + 5, SocketFlags.None, RemoteEndPoint); - } - catch (Exception e) - { - Log.Error(e); - } - } - - #endregion - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server/KCPServerNetworkChannel.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server/KCPServerNetworkChannel.cs.meta deleted file mode 100644 index 29fd3f5d..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/KCP/Server/KCPServerNetworkChannel.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ec35331bec12b514fa057b062368710a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP.meta deleted file mode 100644 index b24a42f9..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 47d85ee74f0898440834159ab0083e2e -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Client.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Client.meta deleted file mode 100644 index 84c5cb26..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Client.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a1b4c600a0229c845a8a16b5e3b85099 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Client/TCPClientNetwork.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Client/TCPClientNetwork.cs deleted file mode 100644 index 893a87b2..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Client/TCPClientNetwork.cs +++ /dev/null @@ -1,543 +0,0 @@ -#if !UNITY_WEBGL -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Net.Sockets; -using System.Threading; -using TEngine.DataStructure; -#pragma warning disable CS8622 -#pragma warning disable CS8625 -#pragma warning disable CS8618 - -// ReSharper disable InconsistentNaming - -namespace TEngine.Core.Network -{ - public sealed class TCPClientNetwork : AClientNetwork - { - #region 逻辑线程 - - private bool _isInit; - private long _connectTimeoutId; - public override event Action OnDispose; - public override event Action OnConnectFail; - public override event Action OnConnectComplete; - public override event Action OnConnectDisconnect; - public override event Action OnChangeChannelId = channelId => { }; - public override event Action OnReceiveMemoryStream; - - public TCPClientNetwork(Scene scene, NetworkTarget networkTarget) : base(scene, NetworkType.Client, NetworkProtocolType.TCP, networkTarget) - { - NetworkThread.Instance.AddNetwork(this); - } - - public override uint Connect(IPEndPoint remoteEndPoint, Action onConnectComplete, Action onConnectFail,Action onConnectDisconnect,int connectTimeout = 5000) - { - if (_isInit) - { - throw new NotSupportedException($"TCPClientNetwork Id:{Id} Has already been initialized. If you want to call Connect again, please re instantiate it."); - } - - _isInit = true; - OnConnectFail = onConnectFail; - OnConnectComplete = onConnectComplete; - OnConnectDisconnect = onConnectDisconnect; - ChannelId = 0xC0000000 | (uint) new Random().Next(); - - _sendAction = (rpcId, routeTypeOpCode, routeId, memoryStream, message) => - { - if (IsDisposed) - { - return; - } - - _messageCache.Enqueue(new MessageCacheInfo() - { - RpcId = rpcId, - RouteId = routeId, - RouteTypeOpCode = routeTypeOpCode, - Message = message, - MemoryStream = memoryStream - }); - }; - - _packetParser = APacketParser.CreatePacketParser(NetworkTarget); - - _outArgs.Completed += OnComplete; - _innArgs.Completed += OnComplete; - - _connectTimeoutId = TimerScheduler.Instance.Core.OnceTimer(connectTimeout, () => - { - OnConnectFail?.Invoke(); - Dispose(); - }); - - NetworkThread.Instance.SynchronizationContext.Post(() => - { - var outArgs = new SocketAsyncEventArgs - { - RemoteEndPoint = remoteEndPoint - }; - - outArgs.Completed += OnComplete; - - _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) {NoDelay = true}; - _socket.SetSocketBufferToOsLimit(); - - if (_socket.ConnectAsync(outArgs)) - { - return; - } - - OnNetworkConnectComplete(outArgs); - }); - - return ChannelId; - } - - public override void Dispose() - { - if (IsDisposed) - { - return; - } - - IsDisposed = true; - - NetworkThread.Instance.SynchronizationContext.Post(() => - { - if (_socket.Connected) - { - if (OnConnectDisconnect != null) - { - ThreadSynchronizationContext.Main.Post(OnConnectDisconnect); - } - _socket.Disconnect(true); - _socket.Close(); - } - - _outArgs?.Dispose(); - _innArgs?.Dispose(); - _sendBuffer?.Dispose(); - _receiveBuffer?.Dispose(); - _packetParser?.Dispose(); - - _sendAction = null; - _packetParser = null; - _isSending = false; - - if (_messageCache != null) - { - _messageCache.Clear(); - _messageCache = null; - } - - ThreadSynchronizationContext.Main.Post(OnDispose); - base.Dispose(); - }); - } - - #endregion - - #region 网络主线程 - - private Socket _socket; - private bool _isSending; - private APacketParser _packetParser; - private Action _sendAction; - private readonly CircularBuffer _sendBuffer = new CircularBuffer(); - private readonly CircularBuffer _receiveBuffer = new CircularBuffer(); - private readonly SocketAsyncEventArgs _outArgs = new SocketAsyncEventArgs(); - private readonly SocketAsyncEventArgs _innArgs = new SocketAsyncEventArgs(); - private Queue _messageCache = new Queue(); - - private void OnNetworkConnectComplete(SocketAsyncEventArgs asyncEventArgs) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (IsDisposed) - { - return; - } - - if (asyncEventArgs.SocketError != SocketError.Success) - { - Log.Error($"Unable to connect to the target server asyncEventArgs:{asyncEventArgs.SocketError}"); - - if (OnConnectFail != null) - { - ThreadSynchronizationContext.Main.Post(OnConnectFail); - } - - Dispose(); - return; - } - - Receive(); - ClearConnectTimeout(ref _connectTimeoutId); - - _sendAction = (rpcId, routeTypeOpCode, routeId, memoryStream, message) => - { - if (IsDisposed) - { - return; - } - - memoryStream = Pack(rpcId, routeTypeOpCode, routeId, memoryStream, message); - Send(memoryStream); - }; - - while (_messageCache.TryDequeue(out var messageCacheInfo)) - { - _sendAction( - messageCacheInfo.RpcId, - messageCacheInfo.RouteTypeOpCode, - messageCacheInfo.RouteId, - messageCacheInfo.MemoryStream, - messageCacheInfo.Message); - } - - _messageCache.Clear(); - _messageCache = null; - - if (OnConnectComplete != null) - { - ThreadSynchronizationContext.Main.Post(OnConnectComplete); - } - } - - public override void Send(uint channelId, uint rpcId, long routeTypeOpCode, long routeId, object message) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (channelId != ChannelId || IsDisposed) - { - return; - } - - _sendAction(rpcId, routeTypeOpCode, routeId, null, message); - } - - public override void Send(uint channelId, uint rpcId, long routeTypeOpCode, long routeId, MemoryStream memoryStream) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (channelId != ChannelId || IsDisposed) - { - return; - } - - _sendAction(rpcId, routeTypeOpCode, routeId, memoryStream, null); - } - - private void Send(MemoryStream memoryStream) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - _sendBuffer.Write(memoryStream); - - // 因为memoryStream对象池出来的、所以需要手动回收下 - - memoryStream.Dispose(); - - if (_isSending) - { - return; - } - - Send(); - } - - private void Send() - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (_isSending || IsDisposed) - { - return; - } - - for (;;) - { - try - { - if (_sendBuffer.Length == 0) - { - _isSending = false; - return; - } - - _isSending = true; - - var sendSize = CircularBuffer.ChunkSize - _sendBuffer.FirstIndex; - - if (sendSize > _sendBuffer.Length) - { - sendSize = (int) _sendBuffer.Length; - } - - _outArgs.SetBuffer(_sendBuffer.First, _sendBuffer.FirstIndex, sendSize); - - if (_socket.SendAsync(_outArgs)) - { - return; - } - - SendCompletedHandler(_outArgs); - } - catch (Exception e) - { - Log.Error(e); - } - } - } - - private void SendCompletedHandler(SocketAsyncEventArgs asyncEventArgs) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (asyncEventArgs.SocketError != SocketError.Success || asyncEventArgs.BytesTransferred == 0) - { - return; - } - - _sendBuffer.FirstIndex += asyncEventArgs.BytesTransferred; - - if (_sendBuffer.FirstIndex == CircularBuffer.ChunkSize) - { - _sendBuffer.FirstIndex = 0; - _sendBuffer.RemoveFirst(); - } - } - - private void OnSendComplete(SocketAsyncEventArgs asyncEventArgs) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (IsDisposed) - { - return; - } - - _isSending = false; - SendCompletedHandler(asyncEventArgs); - - if (_sendBuffer.Length > 0) - { - Send(); - } - } - - private void Receive() - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - for (;;) - { - try - { - if (IsDisposed) - { - return; - } - - var size = CircularBuffer.ChunkSize - _receiveBuffer.LastIndex; - _innArgs.SetBuffer(_receiveBuffer.Last, _receiveBuffer.LastIndex, size); - - if (_socket.ReceiveAsync(_innArgs)) - { - return; - } - - ReceiveCompletedHandler(_innArgs); - } - catch (Exception e) - { - Log.Error(e); - } - } - } - - private void ReceiveCompletedHandler(SocketAsyncEventArgs asyncEventArgs) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (asyncEventArgs.SocketError != SocketError.Success) - { - return; - } - - if (asyncEventArgs.BytesTransferred == 0) - { - Dispose(); - return; - } - - _receiveBuffer.LastIndex += asyncEventArgs.BytesTransferred; - - if (_receiveBuffer.LastIndex >= CircularBuffer.ChunkSize) - { - _receiveBuffer.AddLast(); - _receiveBuffer.LastIndex = 0; - } - - for (;;) - { - try - { - if (IsDisposed) - { - return; - } - - if (!_packetParser.UnPack(_receiveBuffer,out var packInfo)) - { - break; - } - - ThreadSynchronizationContext.Main.Post(() => - { - if (IsDisposed) - { - return; - } - - // ReSharper disable once PossibleNullReferenceException - OnReceiveMemoryStream(packInfo); - }); - } - catch (ScanException e) - { - Log.Debug($"{e}"); - Dispose(); - } - catch (Exception e) - { - Log.Error($"{e}"); - Dispose(); - } - } - } - - private void OnReceiveComplete(SocketAsyncEventArgs asyncEventArgs) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - ReceiveCompletedHandler(asyncEventArgs); - Receive(); - } - - public override void RemoveChannel(uint channelId) - { - Dispose(); - } - - private void ClearConnectTimeout(ref long connectTimeoutId) - { - if (connectTimeoutId == 0) - { - return; - } - - if (NetworkThread.Instance.ManagedThreadId == Thread.CurrentThread.ManagedThreadId) - { - var timeoutId = connectTimeoutId; - ThreadSynchronizationContext.Main.Post(() => { TimerScheduler.Instance.Core.Remove(timeoutId); }); - connectTimeoutId = 0; - return; - } - - TimerScheduler.Instance.Core.RemoveByRef(ref connectTimeoutId); - } - - #endregion - - #region 网络线程(由Socket底层产生的线程) - - private void OnComplete(object sender, SocketAsyncEventArgs asyncEventArgs) - { - if (IsDisposed) - { - return; - } - - switch (asyncEventArgs.LastOperation) - { - case SocketAsyncOperation.Connect: - { - NetworkThread.Instance.SynchronizationContext.Post(() => OnNetworkConnectComplete(asyncEventArgs)); - break; - } - case SocketAsyncOperation.Receive: - { - NetworkThread.Instance.SynchronizationContext.Post(() => OnReceiveComplete(asyncEventArgs)); - break; - } - case SocketAsyncOperation.Send: - { - NetworkThread.Instance.SynchronizationContext.Post(() => OnSendComplete(asyncEventArgs)); - break; - } - case SocketAsyncOperation.Disconnect: - { - NetworkThread.Instance.SynchronizationContext.Post(Dispose); - break; - } - } - } - - #endregion - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Client/TCPClientNetwork.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Client/TCPClientNetwork.cs.meta deleted file mode 100644 index 4512c5de..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Client/TCPClientNetwork.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 19a3e65e84ac7eb458f0b4354dabf39a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server.meta deleted file mode 100644 index 3ec11fe5..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 94ad5582981b49347b1daf74950dc59b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server/TCPServerNetwork.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server/TCPServerNetwork.cs deleted file mode 100644 index 44b3fe2c..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server/TCPServerNetwork.cs +++ /dev/null @@ -1,240 +0,0 @@ -#if !UNITY_WEBGL -using System; -using System.Collections.Generic; -using System.IO; -using System.Net; -using System.Net.Sockets; -// ReSharper disable InconsistentNaming -#pragma warning disable CS8625 -#pragma warning disable CS8622 -#pragma warning disable CS8618 - -namespace TEngine.Core.Network -{ - public sealed class TCPServerNetwork : ANetwork - { - #region 逻辑线程 - - public TCPServerNetwork(Scene scene, NetworkTarget networkTarget, IPEndPoint address) : base(scene, NetworkType.Server, NetworkProtocolType.TCP, networkTarget) - { - _acceptAsync = new SocketAsyncEventArgs(); - NetworkThread.Instance.AddNetwork(this); - NetworkThread.Instance.SynchronizationContext.Post(() => - { - _random = new Random(); - _socket = new Socket(address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); - _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, false); - - if (address.AddressFamily == AddressFamily.InterNetworkV6) - { - _socket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, false); - } - - _socket.Bind(address); - _socket.Listen(int.MaxValue); - _socket.SetSocketBufferToOsLimit(); - _acceptAsync.Completed += OnCompleted; - AcceptAsync(); - }); - } - - public override void Dispose() - { - if (IsDisposed) - { - return; - } - - IsDisposed = true; - - NetworkThread.Instance.SynchronizationContext.Post(() => - { - if (_socket.Connected) - { - _socket.Disconnect(true); - _socket.Close(); - } - - _socket = null; - _random = null; - _acceptAsync = null; - - var channels = new List(_connectionChannel.Values); - - foreach (var tcpServerNetworkChannel in channels) - { - tcpServerNetworkChannel.Dispose(); - } - - channels.Clear(); - _connectionChannel.Clear(); - base.Dispose(); - }); - } - - #endregion - - #region 网络主线程 - - private Socket _socket; - private Random _random; - private SocketAsyncEventArgs _acceptAsync; - private readonly Dictionary _connectionChannel = new Dictionary(); - - public override void Send(uint channelId, uint rpcId, long routeTypeOpCode, long routeId, MemoryStream memoryStream) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (!_connectionChannel.TryGetValue(channelId, out var channel) || channel.IsDisposed) - { - return; - } - - var sendMemoryStream = Pack(rpcId, routeTypeOpCode, routeId, memoryStream, null); - channel.Send(sendMemoryStream); - } - - public override void Send(uint channelId, uint rpcId, long routeTypeOpCode, long routeId, object message) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (!_connectionChannel.TryGetValue(channelId, out var channel) || channel.IsDisposed) - { - return; - } - - var memoryStream = Pack(rpcId, routeTypeOpCode, routeId, null, message); - channel.Send(memoryStream); - } - - private void AcceptAsync() - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - _acceptAsync.AcceptSocket = null; - - if (_socket.AcceptAsync(_acceptAsync)) - { - return; - } - - OnAcceptComplete(_acceptAsync); - } - - private void OnAcceptComplete(SocketAsyncEventArgs asyncEventArgs) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (_socket == null || asyncEventArgs.AcceptSocket == null) - { - return; - } - - if (asyncEventArgs.SocketError != SocketError.Success) - { - Log.Error($"Socket Accept Error: {_acceptAsync.SocketError}"); - return; - } - - try - { - var channelId = 0xC0000000 | (uint) _random.Next(); - - while (_connectionChannel.ContainsKey(channelId)) - { - channelId = 0xC0000000 | (uint) _random.Next(); - } - - var channel = new TCPServerNetworkChannel(channelId, asyncEventArgs.AcceptSocket, this); - - ThreadSynchronizationContext.Main.Post(() => - { - if (channel.IsDisposed) - { - return; - } - - Session.Create(NetworkMessageScheduler, channel, this.NetworkTarget); - }); - - _connectionChannel.Add(channelId, channel); - channel.Receive(); - } - catch (Exception e) - { - Log.Error(e); - } - finally - { - AcceptAsync(); - } - } - - public override void RemoveChannel(uint channelId) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (IsDisposed || !_connectionChannel.Remove(channelId, out var channel)) - { - return; - } -#if NETDEBUG - Log.Debug($"TCPServerNetwork _connectionChannel:{_connectionChannel.Count}"); -#endif - if (channel.IsDisposed) - { - return; - } - - channel.Dispose(); - } - - #endregion - - #region 网络线程(由Socket底层产生的线程) - - private void OnCompleted(object sender, SocketAsyncEventArgs asyncEventArgs) - { - switch (asyncEventArgs.LastOperation) - { - case SocketAsyncOperation.Accept: - { - NetworkThread.Instance.SynchronizationContext.Post(() => OnAcceptComplete(asyncEventArgs)); - break; - } - default: - { - throw new Exception($"Socket Accept Error: {asyncEventArgs.LastOperation}"); - } - } - } - - #endregion - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server/TCPServerNetwork.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server/TCPServerNetwork.cs.meta deleted file mode 100644 index 8087603f..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server/TCPServerNetwork.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b02f01e4179665a41801dbb47c1f1266 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server/TCPServerNetworkChannel.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server/TCPServerNetworkChannel.cs deleted file mode 100644 index c7902e23..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server/TCPServerNetworkChannel.cs +++ /dev/null @@ -1,351 +0,0 @@ -#if !UNITY_WEBGL -using System; -using System.IO; -using System.Net.Sockets; -using TEngine.DataStructure; -// ReSharper disable InconsistentNaming -#pragma warning disable CS8622 -#pragma warning disable CS8601 -#pragma warning disable CS8618 - -namespace TEngine.Core.Network -{ - public sealed class TCPServerNetworkChannel : ANetworkChannel - { - #region 网络主线程 - - private bool _isSending; - private readonly Socket _socket; - private readonly CircularBuffer _sendBuffer = new CircularBuffer(); - private readonly CircularBuffer _receiveBuffer = new CircularBuffer(); - private readonly SocketAsyncEventArgs _outArgs = new SocketAsyncEventArgs(); - private readonly SocketAsyncEventArgs _innArgs = new SocketAsyncEventArgs(); - - public override event Action OnDispose; - public override event Action OnReceiveMemoryStream; - - public TCPServerNetworkChannel(uint id, Socket socket, ANetwork network) : base(network.Scene, id, network.Id) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - _socket = socket; - _socket.NoDelay = true; - RemoteEndPoint = _socket.RemoteEndPoint; - - _innArgs.Completed += OnComplete; - _outArgs.Completed += OnComplete; - - PacketParser = APacketParser.CreatePacketParser(network.NetworkTarget); - } - - public override void Dispose() - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (IsDisposed) - { - return; - } - - _isSending = false; - - if (_socket.Connected) - { - _socket.Disconnect(true); - _socket.Close(); - } - - _outArgs.Dispose(); - _innArgs.Dispose(); - _sendBuffer.Dispose(); - _receiveBuffer.Dispose(); - ThreadSynchronizationContext.Main.Post(OnDispose); - base.Dispose(); - } - - public void Send(MemoryStream memoryStream) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - _sendBuffer.Write(memoryStream); - - // 因为memoryStream对象池出来的、所以需要手动回收下 - - memoryStream.Dispose(); - - if (_isSending) - { - return; - } - - Send(); - } - - private void Send() - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (_isSending || IsDisposed) - { - return; - } - - for (;;) - { - try - { - if (IsDisposed) - { - return; - } - - if (_sendBuffer.Length == 0) - { - _isSending = false; - return; - } - - _isSending = true; - - var sendSize = CircularBuffer.ChunkSize - _sendBuffer.FirstIndex; - - if (sendSize > _sendBuffer.Length) - { - sendSize = (int) _sendBuffer.Length; - } - - _outArgs.SetBuffer(_sendBuffer.First, _sendBuffer.FirstIndex, sendSize); - - if (_socket.SendAsync(_outArgs)) - { - return; - } - - SendCompletedHandler(_outArgs); - } - catch (Exception e) - { - Log.Error(e); - } - } - } - - private void SendCompletedHandler(SocketAsyncEventArgs asyncEventArgs) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (asyncEventArgs.SocketError != SocketError.Success || asyncEventArgs.BytesTransferred == 0) - { - return; - } - - _sendBuffer.FirstIndex += asyncEventArgs.BytesTransferred; - - if (_sendBuffer.FirstIndex == CircularBuffer.ChunkSize) - { - _sendBuffer.FirstIndex = 0; - _sendBuffer.RemoveFirst(); - } - } - - private void OnSendComplete(SocketAsyncEventArgs asyncEventArgs) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (IsDisposed) - { - return; - } - - _isSending = false; - SendCompletedHandler(asyncEventArgs); - - if (_sendBuffer.Length > 0) - { - Send(); - } - } - - public void Receive() - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - for (;;) - { - try - { - if (IsDisposed) - { - return; - } - - var size = CircularBuffer.ChunkSize - _receiveBuffer.LastIndex; - _innArgs.SetBuffer(_receiveBuffer.Last, _receiveBuffer.LastIndex, size); - - if (_socket.ReceiveAsync(_innArgs)) - { - return; - } - - ReceiveCompletedHandler(_innArgs); - } - catch (Exception e) - { - Log.Error(e); - } - } - } - - private void ReceiveCompletedHandler(SocketAsyncEventArgs asyncEventArgs) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - if (asyncEventArgs.SocketError != SocketError.Success) - { - return; - } - - if (asyncEventArgs.BytesTransferred == 0) - { - Dispose(); - return; - } - - _receiveBuffer.LastIndex += asyncEventArgs.BytesTransferred; - - if (_receiveBuffer.LastIndex >= CircularBuffer.ChunkSize) - { - _receiveBuffer.AddLast(); - _receiveBuffer.LastIndex = 0; - } - - for (;;) - { - try - { - if (IsDisposed) - { - return; - } - - if (!PacketParser.UnPack(_receiveBuffer, out var packInfo)) - { - break; - } - - ThreadSynchronizationContext.Main.Post(() => - { - if (IsDisposed) - { - return; - } - - // ReSharper disable once PossibleNullReferenceException - OnReceiveMemoryStream(packInfo); - }); - } - catch (ScanException e) - { - Log.Debug($"RemoteAddress:{RemoteEndPoint} \n{e}"); - Dispose(); - } - catch (Exception e) - { - Log.Error($"RemoteAddress:{RemoteEndPoint} \n{e}"); - Dispose(); - } - } - } - - private void OnReceiveComplete(SocketAsyncEventArgs asyncEventArgs) - { -#if TENGINE_DEVELOP - if (NetworkThread.Instance.ManagedThreadId != Thread.CurrentThread.ManagedThreadId) - { - Log.Error("not in NetworkThread!"); - return; - } -#endif - ReceiveCompletedHandler(asyncEventArgs); - Receive(); - } - - #endregion - - #region 网络线程(由Socket底层产生的线程) - - private void OnComplete(object sender, SocketAsyncEventArgs asyncEventArgs) - { - if (IsDisposed) - { - return; - } - - switch (asyncEventArgs.LastOperation) - { - case SocketAsyncOperation.Receive: - { - NetworkThread.Instance.SynchronizationContext.Post(() => OnReceiveComplete(asyncEventArgs)); - break; - } - case SocketAsyncOperation.Send: - { - NetworkThread.Instance.SynchronizationContext.Post(() => OnSendComplete(asyncEventArgs)); - break; - } - case SocketAsyncOperation.Disconnect: - { - NetworkThread.Instance.SynchronizationContext.Post(Dispose); - break; - } - default: - { - throw new Exception($"Socket Error: {asyncEventArgs.LastOperation}"); - } - } - } - - #endregion - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server/TCPServerNetworkChannel.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server/TCPServerNetworkChannel.cs.meta deleted file mode 100644 index 1a766b06..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkProtocol/TCP/Server/TCPServerNetworkChannel.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2aaa818de3923cf45bf97b802b31cf79 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkThread.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkThread.meta deleted file mode 100644 index 929efb9c..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkThread.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 20a4d07783582164381847abd4a5e337 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkThread/NetAction.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkThread/NetAction.cs deleted file mode 100644 index 44018753..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkThread/NetAction.cs +++ /dev/null @@ -1,63 +0,0 @@ -using System; -using System.IO; -#pragma warning disable CS8625 -#pragma warning disable CS8618 - -namespace TEngine.Core.Network -{ - public enum NetActionType - { - None = 0, - Send = 1, - SendMemoryStream = 2, - RemoveChannel = 3, - } - - public struct NetAction : IDisposable - { - public object Obj; - public uint RpcId; - public long EntityId; - public long NetworkId; - public uint ChannelId; - public long RouteTypeOpCode; - public MemoryStream MemoryStream; - public NetActionType NetActionType; - - public NetAction(long networkId, uint channelId, uint rpcId, long routeTypeOpCode, long entityId, NetActionType netActionType, MemoryStream memoryStream) - { - Obj = null; - RpcId = rpcId; - EntityId = entityId; - NetworkId = networkId; - ChannelId = channelId; - RouteTypeOpCode = routeTypeOpCode; - MemoryStream = memoryStream; - NetActionType = netActionType; - } - - public NetAction(long networkId, uint channelId, uint rpcId, long routeTypeOpCode, long entityId, NetActionType netActionType, object obj) - { - Obj = obj; - RpcId = rpcId; - EntityId = entityId; - NetworkId = networkId; - ChannelId = channelId; - MemoryStream = null; - RouteTypeOpCode = routeTypeOpCode; - NetActionType = netActionType; - } - - public void Dispose() - { - Obj = null; - MemoryStream = null; - RpcId = 0; - EntityId = 0; - NetworkId = 0; - ChannelId = 0; - RouteTypeOpCode = 0; - NetActionType = NetActionType.None; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkThread/NetAction.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkThread/NetAction.cs.meta deleted file mode 100644 index 7338d4b4..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkThread/NetAction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 42b0f3cecca4bce48bbb6c5ff23adc31 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkThread/NetworkThread.cs b/Assets/GameScripts/DotNet/Core/Network/NetworkThread/NetworkThread.cs deleted file mode 100644 index 210ee245..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkThread/NetworkThread.cs +++ /dev/null @@ -1,218 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.IO; -using System.Threading; -using System.Threading.Tasks; -using TEngine.Core; -#pragma warning disable CS8625 -#pragma warning disable CS8618 - -namespace TEngine.Core.Network -{ - public sealed class NetworkThread : Singleton - { - #region 逻辑线程 - - private Thread _netWorkThread; - public ThreadSynchronizationContext SynchronizationContext; - private readonly ConcurrentQueue _actions = new ConcurrentQueue(); - - public int ManagedThreadId => _netWorkThread.ManagedThreadId; - - public override async Task Initialize() - { - _netWorkThread = new Thread(Update); - SynchronizationContext = new ThreadSynchronizationContext(_netWorkThread.ManagedThreadId); - _netWorkThread.Start(); - await Task.CompletedTask; - } - - public void Send(long networkId, uint channelId, uint rpcId, long routeTypeOpCode, long entityId, object message) - { - if (IsDisposed) - { - return; - } - - _actions.Enqueue(new NetAction(networkId, channelId, rpcId, routeTypeOpCode, entityId, NetActionType.Send, message)); - } - - public void SendStream(long networkId, uint channelId, uint rpcId, long routeTypeOpCode, long routeId, MemoryStream memoryStream) - { - if (IsDisposed) - { - return; - } - - _actions.Enqueue(new NetAction(networkId, channelId, rpcId, routeTypeOpCode, routeId, NetActionType.SendMemoryStream, memoryStream)); - } - - public void RemoveChannel(long networkId, uint channelId) - { - if (IsDisposed) - { - return; - } - - _actions.Enqueue(new NetAction(networkId, channelId, 0, 0, 0, NetActionType.RemoveChannel, null)); - } - - public override void Dispose() - { - if (IsDisposed) - { - return; - } - - SynchronizationContext.Post(() => - { - if (IsDisposed) - { - return; - } - - IsDisposed = true; - var removeList = new Queue(_networks.Values); - - foreach (var aNetwork in removeList) - { - if (aNetwork.IsDisposed) - { - continue; - } - - aNetwork.Dispose(); - } - - foreach (var netAction in _actions) - { - netAction.Dispose(); - } - - _actions.Clear(); - _networks.Clear(); - removeList.Clear(); - - _netWorkThread = null; - SynchronizationContext = null; - base.Dispose(); - }); - } - - #endregion - - #region 网络线程 - - private readonly Dictionary _networks = new Dictionary(); - private readonly Dictionary _updates = new Dictionary(); - - private void Update() - { - System.Threading.SynchronizationContext.SetSynchronizationContext(SynchronizationContext); - - while (!IsDisposed) - { - Thread.Sleep(1); - - foreach (var (_, aNetwork) in _updates) - { - try - { - aNetwork.Update(); - } - catch (Exception e) - { - Log.Error(e); - } - } - - SynchronizationContext.Update(); - - while (_actions.TryDequeue(out var action)) - { - if (!_networks.TryGetValue(action.NetworkId, out var network) || network.IsDisposed) - { - continue; - } - - try - { - switch (action.NetActionType) - { - case NetActionType.Send: - { - network.Send(action.ChannelId, action.RpcId, action.RouteTypeOpCode, action.EntityId, action.Obj); - break; - } - case NetActionType.SendMemoryStream: - { - network.Send(action.ChannelId, action.RpcId, action.RouteTypeOpCode, action.EntityId, action.MemoryStream); - break; - } - case NetActionType.RemoveChannel: - { - network.RemoveChannel(action.ChannelId); - break; - } - } - } - catch (Exception e) - { - Log.Error(e); - } - finally - { - action.Dispose(); - } - } - } - } - - public void AddNetwork(ANetwork aNetwork) - { - if (IsDisposed) - { - return; - } - - SynchronizationContext.Post(() => - { - if (IsDisposed || aNetwork.IsDisposed) - { - return; - } - - _networks.Add(aNetwork.Id, aNetwork); - - if (aNetwork is INetworkUpdate iNetworkUpdate) - { - _updates.Add(aNetwork.Id, iNetworkUpdate); - } - }); - } - - public void RemoveNetwork(long networkId) - { - if (IsDisposed) - { - return; - } - - SynchronizationContext.Post(() => - { - if (IsDisposed || !_networks.Remove(networkId, out var network)) - { - return; - } - - if (network is INetworkUpdate) - { - _updates.Remove(networkId); - } - }); - } - - #endregion - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/NetworkThread/NetworkThread.cs.meta b/Assets/GameScripts/DotNet/Core/Network/NetworkThread/NetworkThread.cs.meta deleted file mode 100644 index 8725796a..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/NetworkThread/NetworkThread.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a8825296c9217dd4db734cba8527d51a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/PacketParser.meta b/Assets/GameScripts/DotNet/Core/Network/PacketParser.meta deleted file mode 100644 index 66dfe98a..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/PacketParser.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 21eec7ad23e968642a4be2f9d1eb4784 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/PacketParser/InnerPacketParser.cs b/Assets/GameScripts/DotNet/Core/Network/PacketParser/InnerPacketParser.cs deleted file mode 100644 index a291783a..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/PacketParser/InnerPacketParser.cs +++ /dev/null @@ -1,244 +0,0 @@ -#if TENGINE_NET -using System.Buffers; -using TEngine.DataStructure; -using MongoDB.Bson.Serialization; -using MongoDB.Bson.Serialization.Serializers; -// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract - -namespace TEngine.Core.Network; - -public sealed class InnerPackInfo : APackInfo -{ - public static InnerPackInfo Create(IMemoryOwner memoryOwner) - { - var innerPackInfo = Rent(); - innerPackInfo.MemoryOwner = memoryOwner; - return innerPackInfo; - } - - public override MemoryStream CreateMemoryStream() - { - var recyclableMemoryStream = MemoryStreamHelper.GetRecyclableMemoryStream(); - recyclableMemoryStream.Write(MemoryOwner.Memory.Span.Slice(0, Packet.InnerPacketHeadLength + MessagePacketLength)); - recyclableMemoryStream.Seek(0, SeekOrigin.Begin); - return recyclableMemoryStream; - } - - public override void Dispose() - { - base.Dispose(); - Pool.Return(this); - } - - public override object Deserialize(Type messageType) - { - var memoryOwnerMemory = MemoryOwner.Memory; - memoryOwnerMemory = memoryOwnerMemory.Slice(Packet.InnerPacketHeadLength, MessagePacketLength); - - switch (ProtocolCode) - { - case >= Opcode.InnerBsonRouteResponse: - { - return MongoHelper.Instance.Deserialize(memoryOwnerMemory, messageType); - } - case >= Opcode.InnerRouteResponse: - { - return ProtoBufHelper.FromMemory(messageType, memoryOwnerMemory); - } - case >= Opcode.OuterRouteResponse: - { - return ProtoBufHelper.FromMemory(messageType, memoryOwnerMemory); - } - case >= Opcode.InnerBsonRouteMessage: - { - return MongoHelper.Instance.Deserialize(memoryOwnerMemory, messageType); - } - case >= Opcode.InnerRouteMessage: - case >= Opcode.OuterRouteMessage: - { - return ProtoBufHelper.FromMemory(messageType, memoryOwnerMemory); - } - default: - { - Log.Error($"protocolCode:{ProtocolCode} Does not support processing protocol"); - return null; - } - } - } -} - -public sealed class InnerPacketParser : APacketParser -{ - private uint _rpcId; - private long _routeId; - private uint _protocolCode; - private int _messagePacketLength; - private bool _isUnPackHead = true; - private readonly byte[] _messageHead = new byte[Packet.InnerPacketHeadLength]; - - public InnerPacketParser() - { - MemoryPool = MemoryPool.Shared; - } - - public override bool UnPack(CircularBuffer buffer, out APackInfo packInfo) - { - packInfo = null; - - while (!IsDisposed) - { - if (_isUnPackHead) - { - if (buffer.Length < Packet.InnerPacketHeadLength) - { - return false; - } - - _ = buffer.Read(_messageHead, 0, Packet.InnerPacketHeadLength); - _messagePacketLength = BitConverter.ToInt32(_messageHead, 0); - - if (_messagePacketLength > Packet.PacketBodyMaxLength) - { - throw new ScanException($"The received information exceeds the maximum limit = {_messagePacketLength}"); - } - - _protocolCode = BitConverter.ToUInt32(_messageHead, Packet.PacketLength); - _rpcId = BitConverter.ToUInt32(_messageHead, Packet.InnerPacketRpcIdLocation); - _routeId = BitConverter.ToInt64(_messageHead, Packet.InnerPacketRouteRouteIdLocation); - _isUnPackHead = false; - } - - try - { - if (buffer.Length < _messagePacketLength) - { - return false; - } - - _isUnPackHead = true; - // 创建消息包 - var memoryOwner = MemoryPool.Rent(Packet.InnerPacketMaxLength); - packInfo = InnerPackInfo.Create(memoryOwner); - packInfo.RpcId = _rpcId; - packInfo.RouteId = _routeId; - packInfo.ProtocolCode = _protocolCode; - packInfo.MessagePacketLength = _messagePacketLength; - // 写入消息体的信息到内存中 - buffer.Read(memoryOwner.Memory.Slice(Packet.InnerPacketHeadLength), _messagePacketLength); - // 写入消息头的信息到内存中 - _messageHead.AsMemory().CopyTo( memoryOwner.Memory.Slice(0, Packet.InnerPacketHeadLength)); - return true; - } - catch (Exception e) - { - packInfo?.Dispose(); - Log.Error(e); - return false; - } - } - - return false; - } - - public override bool UnPack(IMemoryOwner memoryOwner, out APackInfo packInfo) - { - packInfo = null; - - try - { - var memorySpan = memoryOwner.Memory.Span; - - if (memorySpan.Length < Packet.InnerPacketHeadLength) - { - return false; - } - - _messagePacketLength = BitConverter.ToInt32(memorySpan); - - if (_messagePacketLength > Packet.PacketBodyMaxLength) - { - throw new ScanException($"The received information exceeds the maximum limit = {_messagePacketLength}"); - } - - packInfo = InnerPackInfo.Create(memoryOwner); - packInfo.MessagePacketLength = _messagePacketLength; - packInfo.ProtocolCode = BitConverter.ToUInt32(memorySpan[Packet.PacketLength..]); - packInfo.RpcId = BitConverter.ToUInt32(memorySpan[Packet.OuterPacketRpcIdLocation..]); - packInfo.RouteId = BitConverter.ToInt64(memorySpan[Packet.InnerPacketRouteRouteIdLocation..]); - - if (memorySpan.Length < _messagePacketLength) - { - return false; - } - - return _messagePacketLength >= 0; - } - catch (Exception e) - { - Console.WriteLine(e); - throw; - } - } - - public static MemoryStream Pack(uint rpcId, long routeId, MemoryStream memoryStream) - { - memoryStream.Seek(Packet.InnerPacketRpcIdLocation, SeekOrigin.Begin); - memoryStream.Write(BitConverter.GetBytes(rpcId)); - memoryStream.Write(BitConverter.GetBytes(routeId)); - memoryStream.Seek(0, SeekOrigin.Begin); - return memoryStream; - } - - public static MemoryStream Pack(uint rpcId, long routeId, object message) - { - var opCode = Opcode.PingRequest; - var packetBodyCount = 0; - var memoryStream = MemoryStreamHelper.GetRecyclableMemoryStream(); - - memoryStream.Seek(Packet.InnerPacketHeadLength, SeekOrigin.Begin); - - if (message != null) - { - if (message is IBsonMessage) - { - try - { - - MongoHelper.Instance.SerializeTo(message, memoryStream); - } - catch (Exception e) - { - Log.Fatal(e); - throw; - } - } - else - { - ProtoBufHelper.ToStream(message, memoryStream); - } - - opCode = MessageDispatcherSystem.Instance.GetOpCode(message.GetType()); - packetBodyCount = (int)(memoryStream.Position - Packet.InnerPacketHeadLength); - } - - if (packetBodyCount > Packet.PacketBodyMaxLength) - { - throw new Exception($"Message content exceeds {Packet.PacketBodyMaxLength} bytes"); - } - - memoryStream.Seek(0, SeekOrigin.Begin); - memoryStream.Write(BitConverter.GetBytes(packetBodyCount)); - memoryStream.Write(BitConverter.GetBytes(opCode)); - memoryStream.Write(BitConverter.GetBytes(rpcId)); - memoryStream.Write(BitConverter.GetBytes(routeId)); - memoryStream.Seek(0, SeekOrigin.Begin); - return memoryStream; - } - - public override void Dispose() - { - _messagePacketLength = 0; - base.Dispose(); - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/PacketParser/InnerPacketParser.cs.meta b/Assets/GameScripts/DotNet/Core/Network/PacketParser/InnerPacketParser.cs.meta deleted file mode 100644 index bd55150e..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/PacketParser/InnerPacketParser.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5e64861321cb2b34e9dedd6910bdfb7e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface.meta b/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface.meta deleted file mode 100644 index dba0c76a..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7e60a19276ca5734297e6367b9a9d047 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface/APackInfo.cs b/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface/APackInfo.cs deleted file mode 100644 index 3f2bee72..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface/APackInfo.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Buffers; -using System.IO; - -namespace TEngine.Core.Network -{ - public abstract class APackInfo : IDisposable - { - public uint RpcId; - public long RouteId; - public uint ProtocolCode; - public long RouteTypeCode; - public int MessagePacketLength; - public IMemoryOwner MemoryOwner; - public bool IsDisposed; - - public static T Rent() where T : APackInfo - { - var aPackInfo = Pool.Rent(); - aPackInfo.IsDisposed = false; - return aPackInfo; - } - - public abstract object Deserialize(Type messageType); - public abstract MemoryStream CreateMemoryStream(); - public virtual void Dispose() - { - if (IsDisposed) - { - return; - } - - RpcId = 0; - RouteId = 0; - ProtocolCode = 0; - RouteTypeCode = 0; - MessagePacketLength = 0; - MemoryOwner.Dispose(); - MemoryOwner = null; - IsDisposed = true; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface/APackInfo.cs.meta b/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface/APackInfo.cs.meta deleted file mode 100644 index 4ceb4128..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface/APackInfo.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fe7b65d261a51954cbdcaabc111f1cfb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface/APacketParser.cs b/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface/APacketParser.cs deleted file mode 100644 index ba8973ff..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface/APacketParser.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Buffers; -using System.IO; -using TEngine.DataStructure; - -namespace TEngine.Core.Network -{ - public abstract class APacketParser : IDisposable - { - protected MemoryPool MemoryPool; - protected bool IsDisposed { get; private set; } - - public static APacketParser CreatePacketParser(NetworkTarget networkTarget) - { - switch (networkTarget) - { - case NetworkTarget.Inner: - { -#if TENGINE_NET - return new InnerPacketParser(); -#else - throw new NotSupportedException($"PacketParserHelper Create NotSupport {networkTarget}"); -#endif - } - case NetworkTarget.Outer: - { - return new OuterPacketParser(); - } - default: - { - throw new NotSupportedException($"PacketParserHelper Create NotSupport {networkTarget}"); - } - } - } - - public abstract bool UnPack(CircularBuffer buffer, out APackInfo packInfo); - public abstract bool UnPack(IMemoryOwner memoryOwner, out APackInfo packInfo); - public virtual void Dispose() - { - IsDisposed = true; - MemoryPool.Dispose(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface/APacketParser.cs.meta b/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface/APacketParser.cs.meta deleted file mode 100644 index ed8d80eb..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/PacketParser/Interface/APacketParser.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 64efc3c3308da5540a15195e8b1e10ca -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/PacketParser/OuterPacketParser.cs b/Assets/GameScripts/DotNet/Core/Network/PacketParser/OuterPacketParser.cs deleted file mode 100644 index 1e5a9203..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/PacketParser/OuterPacketParser.cs +++ /dev/null @@ -1,198 +0,0 @@ -using System; -using System.Buffers; -using System.IO; -using TEngine.DataStructure; -// ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract - -namespace TEngine.Core.Network -{ - public sealed class OuterPackInfo : APackInfo - { - public static OuterPackInfo Create(IMemoryOwner memoryOwner) - { - var outerPackInfo = Rent();; - outerPackInfo.MemoryOwner = memoryOwner; - return outerPackInfo; - } - - public override MemoryStream CreateMemoryStream() - { - var recyclableMemoryStream = MemoryStreamHelper.GetRecyclableMemoryStream(); - recyclableMemoryStream.Write(MemoryOwner.Memory.Span.Slice(0, Packet.InnerPacketHeadLength + MessagePacketLength)); - recyclableMemoryStream.Seek(0, SeekOrigin.Begin); - return recyclableMemoryStream; - } - - public override void Dispose() - { - base.Dispose(); - Pool.Return(this); - } - - public override object Deserialize(Type messageType) - { - var memoryOwnerMemory = MemoryOwner.Memory; - var memory = memoryOwnerMemory.Slice(Packet.OuterPacketHeadLength, MessagePacketLength); - return ProtoBufHelper.FromMemory(messageType, memory); - } - } - - public sealed class OuterPacketParser : APacketParser - { - private uint _rpcId; - private uint _protocolCode; - private long _routeTypeCode; - private int _messagePacketLength; - private bool _isUnPackHead = true; - private readonly byte[] _messageHead = new byte[Packet.OuterPacketHeadLength]; - - public OuterPacketParser() - { - MemoryPool = MemoryPool.Shared; - } - - public override bool UnPack(CircularBuffer buffer, out APackInfo packInfo) - { - packInfo = null; - - while (!IsDisposed) - { - if (_isUnPackHead) - { - if (buffer.Length < Packet.OuterPacketHeadLength) - { - return false; - } - - _ = buffer.Read(_messageHead, 0, Packet.OuterPacketHeadLength); - _messagePacketLength = BitConverter.ToInt32(_messageHead, 0); -#if TENGINE_NET - if (_messagePacketLength > Packet.PacketBodyMaxLength) - { - throw new ScanException($"The received information exceeds the maximum limit = {_messagePacketLength}"); - } -#endif - _protocolCode = BitConverter.ToUInt32(_messageHead, Packet.PacketLength); - _rpcId = BitConverter.ToUInt32(_messageHead, Packet.OuterPacketRpcIdLocation); - _routeTypeCode = BitConverter.ToUInt16(_messageHead, Packet.OuterPacketRouteTypeOpCodeLocation); - _isUnPackHead = false; - } - - try - { - if (buffer.Length < _messagePacketLength) - { - return false; - } - - _isUnPackHead = true; - // 创建消息包 - var memoryOwner = MemoryPool.Rent(Packet.OuterPacketMaxLength); - packInfo = OuterPackInfo.Create(memoryOwner); - packInfo.RpcId = _rpcId; - packInfo.ProtocolCode = _protocolCode; - packInfo.RouteTypeCode = _routeTypeCode; - packInfo.MessagePacketLength = _messagePacketLength; - // 写入消息体的信息到内存中 - buffer.Read(memoryOwner.Memory.Slice(Packet.OuterPacketHeadLength), _messagePacketLength); - // 写入消息头的信息到内存中 - _messageHead.AsMemory().CopyTo(memoryOwner.Memory.Slice(0, Packet.OuterPacketHeadLength)); - return _messagePacketLength > 0; - } - catch (Exception e) - { - packInfo?.Dispose(); - Log.Error(e); - return false; - } - } - - return false; - } - - public override bool UnPack(IMemoryOwner memoryOwner, out APackInfo packInfo) - { - packInfo = null; - var memory = memoryOwner.Memory; - - try - { - if (memory.Length < Packet.OuterPacketHeadLength) - { - return false; - } - - var memorySpan = memory.Span; - _messagePacketLength = BitConverter.ToInt32(memorySpan); -#if TENGINE_NET - if (_messagePacketLength > Packet.PacketBodyMaxLength) - { - throw new ScanException($"The received information exceeds the maximum limit = {_messagePacketLength}"); - } -#endif - packInfo = OuterPackInfo.Create(memoryOwner); - packInfo.MessagePacketLength = _messagePacketLength; - packInfo.ProtocolCode = BitConverter.ToUInt32(memorySpan.Slice(Packet.PacketLength)); - packInfo.RpcId = BitConverter.ToUInt32(memorySpan.Slice(Packet.OuterPacketRpcIdLocation)); - packInfo.RouteTypeCode = BitConverter.ToUInt16(memorySpan.Slice(Packet.OuterPacketRouteTypeOpCodeLocation)); - - if (memory.Length < _messagePacketLength) - { - return false; - } - - return _messagePacketLength >= 0; - } - catch (Exception e) - { - packInfo?.Dispose(); - Log.Error(e); - return false; - } - } - - public static MemoryStream Pack(uint rpcId, long routeTypeOpCode, MemoryStream memoryStream) - { - memoryStream.Seek(Packet.OuterPacketRpcIdLocation, SeekOrigin.Begin); - memoryStream.Write(BitConverter.GetBytes(rpcId)); - memoryStream.Write(BitConverter.GetBytes(routeTypeOpCode)); - memoryStream.Seek(0, SeekOrigin.Begin); - return memoryStream; - } - - public static MemoryStream Pack(uint rpcId, long routeTypeOpCode, object message) - { - var opCode = Opcode.PingRequest; - var packetBodyCount = 0; - var memoryStream = MemoryStreamHelper.GetRecyclableMemoryStream(); - memoryStream.Seek(Packet.OuterPacketHeadLength, SeekOrigin.Begin); - - if (message != null) - { - ProtoBufHelper.ToStream(message, memoryStream); - opCode = MessageDispatcherSystem.Instance.GetOpCode(message.GetType()); - packetBodyCount = (int)(memoryStream.Position - Packet.OuterPacketHeadLength); - } - - if (packetBodyCount > Packet.PacketBodyMaxLength) - { - throw new Exception($"Message content exceeds {Packet.PacketBodyMaxLength} bytes"); - } - - memoryStream.Seek(0, SeekOrigin.Begin); - memoryStream.Write(BitConverter.GetBytes(packetBodyCount)); - memoryStream.Write(BitConverter.GetBytes(opCode)); - memoryStream.Write(BitConverter.GetBytes(rpcId)); - memoryStream.Write(BitConverter.GetBytes(routeTypeOpCode)); - memoryStream.Seek(0, SeekOrigin.Begin); - return memoryStream; - } - - public override void Dispose() - { - _messagePacketLength = 0; - Array.Clear(_messageHead, 0, _messageHead.Length); - base.Dispose(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/PacketParser/OuterPacketParser.cs.meta b/Assets/GameScripts/DotNet/Core/Network/PacketParser/OuterPacketParser.cs.meta deleted file mode 100644 index 1bca875b..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/PacketParser/OuterPacketParser.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a25f5b0703b81ef4598618dca71905f0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Network/PacketParser/Packet.cs b/Assets/GameScripts/DotNet/Core/Network/PacketParser/Packet.cs deleted file mode 100644 index 5809c4cc..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/PacketParser/Packet.cs +++ /dev/null @@ -1,62 +0,0 @@ -namespace TEngine.Core.Network -{ - public struct Packet - { - /// - /// 消息体最大长度 - /// - public const int PacketBodyMaxLength = ushort.MaxValue * 16; - /// - /// 消息体长度在消息头占用的长度 - /// - public const int PacketLength = sizeof(int); - /// - /// 协议编号在消息头占用的长度 - /// - public const int ProtocolCodeLength = sizeof(uint); - /// - /// RouteId长度 - /// - public const int PacketRouteIdLength = sizeof(long); - /// - /// RpcId在消息头占用的长度 - /// - public const int RpcIdLength = sizeof(uint); - /// - /// RouteTypeOpCode在消息头占用的长度 - /// - public const int RouteTypeOpCodeLength = sizeof(long); - /// - /// OuterRPCId所在的位置 - /// - public const int OuterPacketRpcIdLocation = PacketLength + ProtocolCodeLength; - /// - /// InnerRPCId所在的位置 - /// - public const int InnerPacketRpcIdLocation = PacketLength + ProtocolCodeLength; - /// - /// RouteTypeOpCode所在的位置 - /// - public const int OuterPacketRouteTypeOpCodeLocation = OuterPacketRpcIdLocation + RpcIdLength; - /// - /// RouteId所在的位置 - /// - public const int InnerPacketRouteRouteIdLocation = PacketLength + ProtocolCodeLength + RpcIdLength; - /// - /// 外网消息总长度(消息体最大长度 + 外网消息头长度) - /// - public const int OuterPacketMaxLength = OuterPacketHeadLength + PacketBodyMaxLength; - /// - /// 内网消息总长度(消息体最大长度 + 外网消息头长度) - /// - public const int InnerPacketMaxLength = InnerPacketHeadLength + PacketBodyMaxLength; - /// - /// 外网消息头长度(消息体长度在消息头占用的长度 + 协议编号在消息头占用的长度 + RPCId长度 + RouteTypeOpCode长度) - /// - public const int OuterPacketHeadLength = PacketLength + ProtocolCodeLength + RpcIdLength + RouteTypeOpCodeLength; - /// - /// 内网消息头长度(消息体长度在消息头占用的长度 + 协议编号在消息头占用的长度 + RPCId长度 + RouteId长度) - /// - public const int InnerPacketHeadLength = PacketLength + ProtocolCodeLength + RpcIdLength + PacketRouteIdLength; - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Network/PacketParser/Packet.cs.meta b/Assets/GameScripts/DotNet/Core/Network/PacketParser/Packet.cs.meta deleted file mode 100644 index 1b440ef4..00000000 --- a/Assets/GameScripts/DotNet/Core/Network/PacketParser/Packet.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 744a252c35e628f4cb0945449bda29e9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Pool.meta b/Assets/GameScripts/DotNet/Core/Pool.meta deleted file mode 100644 index ee5d507a..00000000 --- a/Assets/GameScripts/DotNet/Core/Pool.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 07ae348aab8e8a34881a9918006b8fcb -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Pool/ConcurrentPool.cs b/Assets/GameScripts/DotNet/Core/Pool/ConcurrentPool.cs deleted file mode 100644 index 4a92a5fb..00000000 --- a/Assets/GameScripts/DotNet/Core/Pool/ConcurrentPool.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Collections.Concurrent; - -namespace TEngine -{ - /// - /// 线程安全的静态通用对象池 - /// - /// - public static class ConcurrentPool - { - private static readonly ConcurrentQueue PoolQueue = new ConcurrentQueue(); - - public static int Count => PoolQueue.Count; - - public static T Rent() - { - return PoolQueue.TryDequeue(out var t) ? t : Activator.CreateInstance(); - } - - public static T Rent(Func generator) - { - return PoolQueue.TryDequeue(out var t) ? t : generator(); - } - - public static void Return(T t) - { - if (t == null) - { - return; - } - - PoolQueue.Enqueue(t); - } - - public static void Return(T t, Action reset) - { - if (t == null) - { - return; - } - - reset(t); - PoolQueue.Enqueue(t); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Pool/ConcurrentPool.cs.meta b/Assets/GameScripts/DotNet/Core/Pool/ConcurrentPool.cs.meta deleted file mode 100644 index eb24d42e..00000000 --- a/Assets/GameScripts/DotNet/Core/Pool/ConcurrentPool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7af82d3e27c94b0498507beb740f96de -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Pool/Pool.cs b/Assets/GameScripts/DotNet/Core/Pool/Pool.cs deleted file mode 100644 index ad0b2bbe..00000000 --- a/Assets/GameScripts/DotNet/Core/Pool/Pool.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TEngine -{ - /// - /// 静态通用对象池 - /// - /// - public static class Pool - { - private static readonly Queue PoolQueue = new Queue(); - - public static int Count => PoolQueue.Count; - - public static T Rent() - { - return PoolQueue.Count == 0 ? Activator.CreateInstance() : PoolQueue.Dequeue(); - } - - public static T Rent(Func generator) - { - return PoolQueue.Count == 0 ? generator() : PoolQueue.Dequeue(); - } - - public static void Return(T t) - { - if (t == null) - { - return; - } - - PoolQueue.Enqueue(t); - } - - public static void Return(T t, Action reset) - { - if (t == null) - { - return; - } - - reset(t); - PoolQueue.Enqueue(t); - } - - public static void Clear() - { - PoolQueue.Clear(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Pool/Pool.cs.meta b/Assets/GameScripts/DotNet/Core/Pool/Pool.cs.meta deleted file mode 100644 index 19f95d8c..00000000 --- a/Assets/GameScripts/DotNet/Core/Pool/Pool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5b3d07ffa12833d4a805acc09d939e7f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Pool/PoolCore.cs b/Assets/GameScripts/DotNet/Core/Pool/PoolCore.cs deleted file mode 100644 index 43c45754..00000000 --- a/Assets/GameScripts/DotNet/Core/Pool/PoolCore.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TEngine -{ - public abstract class PoolCore - { - private readonly Action _reset; - private readonly Func _generator; - private readonly Stack _objects = new Stack(); - public int Count => _objects.Count; - - /// - /// 初始化一个池子 - /// - /// 某些类型的构造函数中可能需要额外的参数,所以使用Func生成器 - /// 某些类型可能需要对返回的对象进行额外清理 - /// 池子的初始大小、可以预先分配 - protected PoolCore(Func generator, Action reset, int initialCapacity = 0) - { - _generator = generator; - _reset = reset; - - for (var i = 0; i < initialCapacity; ++i) - { - _objects.Push(generator()); - } - } - - public T Rent() - { - return _objects.Count > 0 ? _objects.Pop() : _generator(); - } - - public void Return(T item) - { - _reset(item); - _objects.Push(item); - } - - public void Clear() - { - _objects.Clear(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Pool/PoolCore.cs.meta b/Assets/GameScripts/DotNet/Core/Pool/PoolCore.cs.meta deleted file mode 100644 index 09fa56f4..00000000 --- a/Assets/GameScripts/DotNet/Core/Pool/PoolCore.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 89a4d3700191cee49b83574d93b0be08 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Pool/PoolWithDisposable.cs b/Assets/GameScripts/DotNet/Core/Pool/PoolWithDisposable.cs deleted file mode 100644 index 0d9b8bf6..00000000 --- a/Assets/GameScripts/DotNet/Core/Pool/PoolWithDisposable.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TEngine -{ - /// - /// 静态通用对象池 - /// - /// - public static class PoolWithDisposable where T : IDisposable - { - private static readonly Queue PoolQueue = new Queue(); - - public static int Count => PoolQueue.Count; - - public static T Rent() - { - return PoolQueue.Count == 0 ? Activator.CreateInstance() : PoolQueue.Dequeue(); - } - - public static T Rent(Func generator) - { - return PoolQueue.Count == 0 ? Activator.CreateInstance() : PoolQueue.Dequeue(); - } - - public static void Return(T t) - { - if (t == null) - { - return; - } - - PoolQueue.Enqueue(t); - t.Dispose(); - } - - public static void Return(T t, Action reset) - { - if (t == null) - { - return; - } - - reset(t); - PoolQueue.Enqueue(t); - t.Dispose(); - } - - public static void Clear() - { - PoolQueue.Clear(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Pool/PoolWithDisposable.cs.meta b/Assets/GameScripts/DotNet/Core/Pool/PoolWithDisposable.cs.meta deleted file mode 100644 index 824a865f..00000000 --- a/Assets/GameScripts/DotNet/Core/Pool/PoolWithDisposable.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b6c920c7d1f7495459e82d52b6403332 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream.meta b/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream.meta deleted file mode 100644 index 7df2ce4a..00000000 --- a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 90f991de46d843c49b75b75dd03d10b2 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/EventArgs.cs b/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/EventArgs.cs deleted file mode 100644 index a354d34f..00000000 --- a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/EventArgs.cs +++ /dev/null @@ -1,463 +0,0 @@ -namespace TEngine.IO -{ - using System; - - public sealed partial class RecyclableMemoryStreamManager - { - /// - /// Arguments for the event. - /// - public sealed class StreamCreatedEventArgs : EventArgs - { - /// - /// Unique ID for the stream. - /// - public Guid Id { get; } - - /// - /// Optional Tag for the event. - /// - public string Tag { get; } - - /// - /// Requested stream size. - /// - public long RequestedSize { get; } - - /// - /// Actual stream size. - /// - public long ActualSize { get; } - - /// - /// Initializes a new instance of the class. - /// - /// Unique ID of the stream. - /// Tag of the stream. - /// The requested stream size. - /// The actual stream size. - public StreamCreatedEventArgs(Guid guid, string tag, long requestedSize, long actualSize) - { - this.Id = guid; - this.Tag = tag; - this.RequestedSize = requestedSize; - this.ActualSize = actualSize; - } - } - - /// - /// Arguments for the event. - /// - public sealed class StreamDisposedEventArgs : EventArgs - { - /// - /// Unique ID for the stream. - /// - public Guid Id { get; } - - /// - /// Optional Tag for the event. - /// - public string Tag { get; } - - /// - /// Stack where the stream was allocated. - /// - public string AllocationStack { get; } - - /// - /// Stack where stream was disposed. - /// - public string DisposeStack { get; } - - /// - /// Lifetime of the stream. - /// - public TimeSpan Lifetime { get; } - - /// - /// Initializes a new instance of the class. - /// - /// Unique ID of the stream. - /// Tag of the stream. - /// Stack of original allocation. - /// Dispose stack. - [Obsolete("Use another constructor override")] - public StreamDisposedEventArgs(Guid guid, string tag, string allocationStack, string disposeStack) - :this(guid, tag, TimeSpan.Zero, allocationStack, disposeStack) - { - - } - - /// - /// Initializes a new instance of the class. - /// - /// Unique ID of the stream. - /// Tag of the stream. - /// Lifetime of the stream - /// Stack of original allocation. - /// Dispose stack. - public StreamDisposedEventArgs(Guid guid, string tag, TimeSpan lifetime, string allocationStack, string disposeStack) - { - this.Id = guid; - this.Tag = tag; - this.Lifetime = lifetime; - this.AllocationStack = allocationStack; - this.DisposeStack = disposeStack; - } - } - - /// - /// Arguments for the event. - /// - public sealed class StreamDoubleDisposedEventArgs : EventArgs - { - /// - /// Unique ID for the stream. - /// - public Guid Id { get; } - - /// - /// Optional Tag for the event. - /// - public string Tag { get; } - - /// - /// Stack where the stream was allocated. - /// - public string AllocationStack { get; } - - /// - /// First dispose stack. - /// - public string DisposeStack1 { get; } - - /// - /// Second dispose stack. - /// - public string DisposeStack2 { get; } - - /// - /// Initializes a new instance of the class. - /// - /// Unique ID of the stream. - /// Tag of the stream. - /// Stack of original allocation. - /// First dispose stack. - /// Second dispose stack. - public StreamDoubleDisposedEventArgs(Guid guid, string tag, string allocationStack, string disposeStack1, string disposeStack2) - { - this.Id = guid; - this.Tag = tag; - this.AllocationStack = allocationStack; - this.DisposeStack1 = disposeStack1; - this.DisposeStack2 = disposeStack2; - } - } - - /// - /// Arguments for the event. - /// - public sealed class StreamFinalizedEventArgs : EventArgs - { - /// - /// Unique ID for the stream. - /// - public Guid Id { get; } - - /// - /// Optional Tag for the event. - /// - public string Tag { get; } - - /// - /// Stack where the stream was allocated. - /// - public string AllocationStack { get; } - - /// - /// Initializes a new instance of the class. - /// - /// Unique ID of the stream. - /// Tag of the stream. - /// Stack of original allocation. - public StreamFinalizedEventArgs(Guid guid, string tag, string allocationStack) - { - this.Id = guid; - this.Tag = tag; - this.AllocationStack = allocationStack; - } - } - - /// - /// Arguments for the event. - /// - public sealed class StreamConvertedToArrayEventArgs : EventArgs - { - /// - /// Unique ID for the stream. - /// - public Guid Id { get; } - - /// - /// Optional Tag for the event. - /// - public string Tag { get; } - - /// - /// Stack where ToArray was called. - /// - public string Stack { get; } - - /// - /// Length of stack. - /// - public long Length { get; } - - /// - /// Initializes a new instance of the class. - /// - /// Unique ID of the stream. - /// Tag of the stream. - /// Stack of ToArray call. - /// Length of stream. - public StreamConvertedToArrayEventArgs(Guid guid, string tag, string stack, long length) - { - this.Id = guid; - this.Tag = tag; - this.Stack = stack; - this.Length = length; - } - } - - /// - /// Arguments for the event. - /// - public sealed class StreamOverCapacityEventArgs : EventArgs - { - /// - /// Unique ID for the stream. - /// - public Guid Id { get; } - - /// - /// Optional Tag for the event. - /// - public string Tag { get; } - - /// - /// Original allocation stack. - /// - public string AllocationStack { get; } - - /// - /// Requested capacity. - /// - public long RequestedCapacity { get; } - - /// - /// Maximum capacity. - /// - public long MaximumCapacity { get; } - - /// - /// Initializes a new instance of the class. - /// - /// Unique ID of the stream. - /// Tag of the stream. - /// Requested capacity. - /// Maximum stream capacity of the manager. - /// Original allocation stack. - internal StreamOverCapacityEventArgs(Guid guid, string tag, long requestedCapacity, long maximumCapacity, string allocationStack) - { - this.Id = guid; - this.Tag = tag; - this.RequestedCapacity = requestedCapacity; - this.MaximumCapacity = maximumCapacity; - this.AllocationStack = allocationStack; - } - } - - /// - /// Arguments for the event. - /// - public sealed class BlockCreatedEventArgs : EventArgs - { - /// - /// How many bytes are currently in use from the small pool. - /// - public long SmallPoolInUse { get; } - - /// - /// Initializes a new instance of the class. - /// - /// Number of bytes currently in use from the small pool. - internal BlockCreatedEventArgs(long smallPoolInUse) - { - this.SmallPoolInUse = smallPoolInUse; - } - } - - /// - /// Arguments for the events. - /// - public sealed class LargeBufferCreatedEventArgs : EventArgs - { - /// - /// Unique ID for the stream. - /// - public Guid Id { get; } - - /// - /// Optional Tag for the event. - /// - public string Tag { get; } - - /// - /// Whether the buffer was satisfied from the pool or not. - /// - public bool Pooled { get; } - - /// - /// Required buffer size. - /// - public long RequiredSize { get; } - - /// - /// How many bytes are in use from the large pool. - /// - public long LargePoolInUse { get; } - - /// - /// If the buffer was not satisfied from the pool, and is turned on, then. - /// this will contain the callstack of the allocation request. - /// - public string CallStack { get; } - - /// - /// Initializes a new instance of the class. - /// - /// Unique ID of the stream. - /// Tag of the stream. - /// Required size of the new buffer. - /// How many bytes from the large pool are currently in use. - /// Whether the buffer was satisfied from the pool or not. - /// Callstack of the allocation, if it wasn't pooled. - internal LargeBufferCreatedEventArgs(Guid guid, string tag, long requiredSize, long largePoolInUse, bool pooled, string callStack) - { - this.RequiredSize = requiredSize; - this.LargePoolInUse = largePoolInUse; - this.Pooled = pooled; - this.Id = guid; - this.Tag = tag; - this.CallStack = callStack; - } - } - - /// - /// Arguments for the event. - /// - public sealed class BufferDiscardedEventArgs : EventArgs - { - /// - /// Unique ID for the stream. - /// - public Guid Id { get; } - - /// - /// Optional Tag for the event. - /// - public string Tag { get; } - - /// - /// Type of the buffer. - /// - public Events.MemoryStreamBufferType BufferType { get; } - - /// - /// The reason this buffer was discarded. - /// - public Events.MemoryStreamDiscardReason Reason { get; } - - /// - /// Initializes a new instance of the class. - /// - /// Unique ID of the stream. - /// Tag of the stream. - /// Type of buffer being discarded. - /// The reason for the discard. - internal BufferDiscardedEventArgs(Guid guid, string tag, Events.MemoryStreamBufferType bufferType, Events.MemoryStreamDiscardReason reason) - { - this.Id = guid; - this.Tag = tag; - this.BufferType = bufferType; - this.Reason = reason; - } - } - - /// - /// Arguments for the event. - /// - public sealed class StreamLengthEventArgs : EventArgs - { - /// - /// Length of the stream. - /// - public long Length { get; } - - /// - /// Initializes a new instance of the class. - /// - /// Length of the strength. - public StreamLengthEventArgs(long length) - { - this.Length = length; - } - } - - /// - /// Arguments for the event. - /// - public sealed class UsageReportEventArgs : EventArgs - { - /// - /// Bytes from the small pool currently in use. - /// - public long SmallPoolInUseBytes { get; } - - /// - /// Bytes from the small pool currently available. - /// - public long SmallPoolFreeBytes { get; } - - /// - /// Bytes from the large pool currently in use. - /// - public long LargePoolInUseBytes { get; } - - /// - /// Bytes from the large pool currently available. - /// - public long LargePoolFreeBytes { get; } - - /// - /// Initializes a new instance of the class. - /// - /// Bytes from the small pool currently in use. - /// Bytes from the small pool currently available. - /// Bytes from the large pool currently in use. - /// Bytes from the large pool currently available. - public UsageReportEventArgs( - long smallPoolInUseBytes, - long smallPoolFreeBytes, - long largePoolInUseBytes, - long largePoolFreeBytes) - { - this.SmallPoolInUseBytes = smallPoolInUseBytes; - this.SmallPoolFreeBytes = smallPoolFreeBytes; - this.LargePoolInUseBytes = largePoolInUseBytes; - this.LargePoolFreeBytes = largePoolFreeBytes; - } - } - } -} diff --git a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/EventArgs.cs.meta b/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/EventArgs.cs.meta deleted file mode 100644 index 36b16e51..00000000 --- a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/EventArgs.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 245f4b325bce62948854e163f9e6f56c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/Events.cs b/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/Events.cs deleted file mode 100644 index 53eeeb63..00000000 --- a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/Events.cs +++ /dev/null @@ -1,258 +0,0 @@ -// --------------------------------------------------------------------- -// Copyright (c) 2015 Microsoft -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// --------------------------------------------------------------------- - -namespace TEngine.IO -{ - using System; - using System.Diagnostics.Tracing; - - public sealed partial class RecyclableMemoryStreamManager - { - /// - /// ETW events for RecyclableMemoryStream. - /// - [EventSource(Name = "Microsoft-IO-RecyclableMemoryStream", Guid = "{B80CD4E4-890E-468D-9CBA-90EB7C82DFC7}")] - public sealed class Events : EventSource - { - /// - /// Static log object, through which all events are written. - /// - public static Events Writer = new(); - - /// - /// Type of buffer. - /// - public enum MemoryStreamBufferType - { - /// - /// Small block buffer. - /// - Small, - /// - /// Large pool buffer. - /// - Large - } - - /// - /// The possible reasons for discarding a buffer. - /// - public enum MemoryStreamDiscardReason - { - /// - /// Buffer was too large to be re-pooled. - /// - TooLarge, - /// - /// There are enough free bytes in the pool. - /// - EnoughFree - } - - /// - /// Logged when a stream object is created. - /// - /// A unique ID for this stream. - /// A temporary ID for this stream, usually indicates current usage. - /// Requested size of the stream. - /// Actual size given to the stream from the pool. - [Event(1, Level = EventLevel.Verbose, Version = 2)] - public void MemoryStreamCreated(Guid guid, string tag, long requestedSize, long actualSize) - { - if (this.IsEnabled(EventLevel.Verbose, EventKeywords.None)) - { - WriteEvent(1, guid, tag ?? string.Empty, requestedSize, actualSize); - } - } - - /// - /// Logged when the stream is disposed. - /// - /// A unique ID for this stream. - /// A temporary ID for this stream, usually indicates current usage. - /// Lifetime in milliseconds of the stream - /// Call stack of initial allocation. - /// Call stack of the dispose. - [Event(2, Level = EventLevel.Verbose, Version = 3)] - public void MemoryStreamDisposed(Guid guid, string tag, long lifetimeMs, string allocationStack, string disposeStack) - { - if (this.IsEnabled(EventLevel.Verbose, EventKeywords.None)) - { - WriteEvent(2, guid, tag ?? string.Empty, lifetimeMs, allocationStack ?? string.Empty, disposeStack ?? string.Empty); - } - } - - /// - /// Logged when the stream is disposed for the second time. - /// - /// A unique ID for this stream. - /// A temporary ID for this stream, usually indicates current usage. - /// Call stack of initial allocation. - /// Call stack of the first dispose. - /// Call stack of the second dispose. - /// Note: Stacks will only be populated if RecyclableMemoryStreamManager.GenerateCallStacks is true. - [Event(3, Level = EventLevel.Critical)] - public void MemoryStreamDoubleDispose(Guid guid, string tag, string allocationStack, string disposeStack1, - string disposeStack2) - { - if (this.IsEnabled()) - { - this.WriteEvent(3, guid, tag ?? string.Empty, allocationStack ?? string.Empty, - disposeStack1 ?? string.Empty, disposeStack2 ?? string.Empty); - } - } - - /// - /// Logged when a stream is finalized. - /// - /// A unique ID for this stream. - /// A temporary ID for this stream, usually indicates current usage. - /// Call stack of initial allocation. - /// Note: Stacks will only be populated if RecyclableMemoryStreamManager.GenerateCallStacks is true. - [Event(4, Level = EventLevel.Error)] - public void MemoryStreamFinalized(Guid guid, string tag, string allocationStack) - { - if (this.IsEnabled()) - { - WriteEvent(4, guid, tag ?? string.Empty, allocationStack ?? string.Empty); - } - } - - /// - /// Logged when ToArray is called on a stream. - /// - /// A unique ID for this stream. - /// A temporary ID for this stream, usually indicates current usage. - /// Call stack of the ToArray call. - /// Length of stream. - /// Note: Stacks will only be populated if RecyclableMemoryStreamManager.GenerateCallStacks is true. - [Event(5, Level = EventLevel.Verbose, Version = 2)] - public void MemoryStreamToArray(Guid guid, string tag, string stack, long size) - { - if (this.IsEnabled(EventLevel.Verbose, EventKeywords.None)) - { - WriteEvent(5, guid, tag ?? string.Empty, stack ?? string.Empty, size); - } - } - - /// - /// Logged when the RecyclableMemoryStreamManager is initialized. - /// - /// Size of blocks, in bytes. - /// Size of the large buffer multiple, in bytes. - /// Maximum buffer size, in bytes. - [Event(6, Level = EventLevel.Informational)] - public void MemoryStreamManagerInitialized(int blockSize, int largeBufferMultiple, int maximumBufferSize) - { - if (this.IsEnabled()) - { - WriteEvent(6, blockSize, largeBufferMultiple, maximumBufferSize); - } - } - - /// - /// Logged when a new block is created. - /// - /// Number of bytes in the small pool currently in use. - [Event(7, Level = EventLevel.Warning, Version = 2)] - public void MemoryStreamNewBlockCreated(long smallPoolInUseBytes) - { - if (this.IsEnabled(EventLevel.Warning, EventKeywords.None)) - { - WriteEvent(7, smallPoolInUseBytes); - } - } - - /// - /// Logged when a new large buffer is created. - /// - /// Requested size. - /// Number of bytes in the large pool in use. - [Event(8, Level = EventLevel.Warning, Version = 3)] - public void MemoryStreamNewLargeBufferCreated(long requiredSize, long largePoolInUseBytes) - { - if (this.IsEnabled(EventLevel.Warning, EventKeywords.None)) - { - WriteEvent(8, requiredSize, largePoolInUseBytes); - } - } - - /// - /// Logged when a buffer is created that is too large to pool. - /// - /// Unique stream ID. - /// A temporary ID for this stream, usually indicates current usage. - /// Size requested by the caller. - /// Call stack of the requested stream. - /// Note: Stacks will only be populated if RecyclableMemoryStreamManager.GenerateCallStacks is true. - [Event(9, Level = EventLevel.Verbose, Version = 3)] - public void MemoryStreamNonPooledLargeBufferCreated(Guid guid, string tag, long requiredSize, string allocationStack) - { - if (this.IsEnabled(EventLevel.Verbose, EventKeywords.None)) - { - WriteEvent(9, guid, tag ?? string.Empty, requiredSize, allocationStack ?? string.Empty); - } - } - - /// - /// Logged when a buffer is discarded (not put back in the pool, but given to GC to clean up). - /// - /// Unique stream ID. - /// A temporary ID for this stream, usually indicates current usage. - /// Type of the buffer being discarded. - /// Reason for the discard. - /// Number of free small pool blocks. - /// Bytes free in the small pool. - /// Bytes in use from the small pool. - /// Number of free large pool blocks. - /// Bytes free in the large pool. - /// Bytes in use from the large pool. - [Event(10, Level = EventLevel.Warning, Version = 2)] - public void MemoryStreamDiscardBuffer(Guid guid, string tag, MemoryStreamBufferType bufferType, - MemoryStreamDiscardReason reason, long smallBlocksFree, long smallPoolBytesFree, long smallPoolBytesInUse, long largeBlocksFree, long largePoolBytesFree, long largePoolBytesInUse) - { - if (this.IsEnabled(EventLevel.Warning, EventKeywords.None)) - { - WriteEvent(10, guid, tag ?? string.Empty, bufferType, reason, smallBlocksFree, smallPoolBytesFree, smallPoolBytesInUse, largeBlocksFree, largePoolBytesFree, largePoolBytesInUse); - } - } - - /// - /// Logged when a stream grows beyond the maximum capacity. - /// - /// Unique stream ID - /// The requested capacity. - /// Maximum capacity, as configured by RecyclableMemoryStreamManager. - /// A temporary ID for this stream, usually indicates current usage. - /// Call stack for the capacity request. - /// Note: Stacks will only be populated if RecyclableMemoryStreamManager.GenerateCallStacks is true. - [Event(11, Level = EventLevel.Error, Version = 3)] - public void MemoryStreamOverCapacity(Guid guid, string tag, long requestedCapacity, long maxCapacity, string allocationStack) - { - if (this.IsEnabled()) - { - WriteEvent(11, guid, tag ?? string.Empty, requestedCapacity, maxCapacity, allocationStack ?? string.Empty); - } - } - } - } -} diff --git a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/Events.cs.meta b/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/Events.cs.meta deleted file mode 100644 index a916c8e6..00000000 --- a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/Events.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 25287e2fc3cca8444a5514df30ac7c13 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/RecyclableMemoryStream.cs b/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/RecyclableMemoryStream.cs deleted file mode 100644 index 9ab892f3..00000000 --- a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/RecyclableMemoryStream.cs +++ /dev/null @@ -1,1613 +0,0 @@ -// The MIT License (MIT) -// -// Copyright (c) 2015-2016 Microsoft -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -#pragma warning disable CS8604 -#pragma warning disable CS8618 -#pragma warning disable CS8625 -#pragma warning disable CS8600 -namespace TEngine.IO -{ - using System; - using System.Buffers; - using System.Collections.Generic; - using System.Diagnostics; - using System.IO; - using System.Runtime.CompilerServices; - using System.Threading; - using System.Threading.Tasks; - - /// - /// MemoryStream implementation that deals with pooling and managing memory streams which use potentially large - /// buffers. - /// - /// - /// This class works in tandem with the to supply MemoryStream-derived - /// objects to callers, while avoiding these specific problems: - /// - /// - /// LOH allocations - /// Since all large buffers are pooled, they will never incur a Gen2 GC - /// - /// - /// Memory wasteA standard memory stream doubles its size when it runs out of room. This - /// leads to continual memory growth as each stream approaches the maximum allowed size. - /// - /// - /// Memory copying - /// Each time a MemoryStream grows, all the bytes are copied into new buffers. - /// This implementation only copies the bytes when is called. - /// - /// - /// Memory fragmentation - /// By using homogeneous buffer sizes, it ensures that blocks of memory - /// can be easily reused. - /// - /// - /// - /// - /// The stream is implemented on top of a series of uniformly-sized blocks. As the stream's length grows, - /// additional blocks are retrieved from the memory manager. It is these blocks that are pooled, not the stream - /// object itself. - /// - /// - /// The biggest wrinkle in this implementation is when is called. This requires a single - /// contiguous buffer. If only a single block is in use, then that block is returned. If multiple blocks - /// are in use, we retrieve a larger buffer from the memory manager. These large buffers are also pooled, - /// split by size--they are multiples/exponentials of a chunk size (1 MB by default). - /// - /// - /// Once a large buffer is assigned to the stream the small blocks are NEVER again used for this stream. All operations take place on the - /// large buffer. The large buffer can be replaced by a larger buffer from the pool as needed. All blocks and large buffers - /// are maintained in the stream until the stream is disposed (unless AggressiveBufferReturn is enabled in the stream manager). - /// - /// - /// A further wrinkle is what happens when the stream is longer than the maximum allowable array length under .NET. This is allowed - /// when only blocks are in use, and only the Read/Write APIs are used. Once a stream grows to this size, any attempt to convert it - /// to a single buffer will result in an exception. Similarly, if a stream is already converted to use a single larger buffer, then - /// it cannot grow beyond the limits of the maximum allowable array size. - /// - /// - /// Any method that modifies the stream has the potential to throw an OutOfMemoryException, either because - /// the stream is beyond the limits set in RecyclableStreamManager, or it would result in a buffer larger than - /// the maximum array size supported by .NET. - /// - /// - public sealed class RecyclableMemoryStream : MemoryStream, IBufferWriter - { - private static readonly byte[] emptyArray = new byte[0]; - - /// - /// All of these blocks must be the same size. - /// - private readonly List blocks; - - private readonly Guid id; - - private readonly RecyclableMemoryStreamManager memoryManager; - - private readonly string tag; - - private readonly long creationTimestamp; - - /// - /// This list is used to store buffers once they're replaced by something larger. - /// This is for the cases where you have users of this class that may hold onto the buffers longer - /// than they should and you want to prevent race conditions which could corrupt the data. - /// - private List dirtyBuffers; - - private bool disposed; - - /// - /// This is only set by GetBuffer() if the necessary buffer is larger than a single block size, or on - /// construction if the caller immediately requests a single large buffer. - /// - /// If this field is non-null, it contains the concatenation of the bytes found in the individual - /// blocks. Once it is created, this (or a larger) largeBuffer will be used for the life of the stream. - /// - private byte[] largeBuffer; - - /// - /// Unique identifier for this stream across its entire lifetime. - /// - /// Object has been disposed. - internal Guid Id - { - get - { - this.CheckDisposed(); - return this.id; - } - } - - /// - /// A temporary identifier for the current usage of this stream. - /// - /// Object has been disposed. - internal string Tag - { - get - { - this.CheckDisposed(); - return this.tag; - } - } - - /// - /// Gets the memory manager being used by this stream. - /// - /// Object has been disposed. - internal RecyclableMemoryStreamManager MemoryManager - { - get - { - this.CheckDisposed(); - return this.memoryManager; - } - } - - /// - /// Callstack of the constructor. It is only set if is true, - /// which should only be in debugging situations. - /// - internal string AllocationStack { get; } - - /// - /// Callstack of the call. It is only set if is true, - /// which should only be in debugging situations. - /// - internal string DisposeStack { get; private set; } - - #region Constructors - /// - /// Initializes a new instance of the class. - /// - /// The memory manager. - public RecyclableMemoryStream(RecyclableMemoryStreamManager memoryManager) - : this(memoryManager, Guid.NewGuid(), null, 0, null) { } - - /// - /// Initializes a new instance of the class. - /// - /// The memory manager. - /// A unique identifier which can be used to trace usages of the stream. - public RecyclableMemoryStream(RecyclableMemoryStreamManager memoryManager, Guid id) - : this(memoryManager, id, null, 0, null) { } - - /// - /// Initializes a new instance of the class. - /// - /// The memory manager. - /// A string identifying this stream for logging and debugging purposes. - public RecyclableMemoryStream(RecyclableMemoryStreamManager memoryManager, string tag) - : this(memoryManager, Guid.NewGuid(), tag, 0, null) { } - - /// - /// Initializes a new instance of the class. - /// - /// The memory manager. - /// A unique identifier which can be used to trace usages of the stream. - /// A string identifying this stream for logging and debugging purposes. - public RecyclableMemoryStream(RecyclableMemoryStreamManager memoryManager, Guid id, string tag) - : this(memoryManager, id, tag, 0, null) { } - - /// - /// Initializes a new instance of the class. - /// - /// The memory manager - /// A string identifying this stream for logging and debugging purposes. - /// The initial requested size to prevent future allocations. - public RecyclableMemoryStream(RecyclableMemoryStreamManager memoryManager, string tag, int requestedSize) - : this(memoryManager, Guid.NewGuid(), tag, requestedSize, null) { } - - /// - /// Initializes a new instance of the class. - /// - /// The memory manager. - /// A string identifying this stream for logging and debugging purposes. - /// The initial requested size to prevent future allocations. - public RecyclableMemoryStream(RecyclableMemoryStreamManager memoryManager, string tag, long requestedSize) - : this(memoryManager, Guid.NewGuid(), tag, requestedSize, null) { } - - /// - /// Initializes a new instance of the class. - /// - /// The memory manager. - /// A unique identifier which can be used to trace usages of the stream. - /// A string identifying this stream for logging and debugging purposes. - /// The initial requested size to prevent future allocations. - public RecyclableMemoryStream(RecyclableMemoryStreamManager memoryManager, Guid id, string tag, int requestedSize) - : this(memoryManager, id, tag, (long)requestedSize) { } - - /// - /// Initializes a new instance of the class. - /// - /// The memory manager - /// A unique identifier which can be used to trace usages of the stream. - /// A string identifying this stream for logging and debugging purposes. - /// The initial requested size to prevent future allocations. - public RecyclableMemoryStream(RecyclableMemoryStreamManager memoryManager, Guid id, string tag, long requestedSize) - : this(memoryManager, id, tag, requestedSize, null) { } - - /// - /// Initializes a new instance of the class. - /// - /// The memory manager. - /// A unique identifier which can be used to trace usages of the stream. - /// A string identifying this stream for logging and debugging purposes. - /// The initial requested size to prevent future allocations. - /// An initial buffer to use. This buffer will be owned by the stream and returned to the memory manager upon Dispose. - internal RecyclableMemoryStream(RecyclableMemoryStreamManager memoryManager, Guid id, string tag, long requestedSize, byte[] initialLargeBuffer) - : base(emptyArray) - { - this.memoryManager = memoryManager; - this.id = id; - this.tag = tag; - this.blocks = new List(); - this.creationTimestamp = Stopwatch.GetTimestamp(); - - var actualRequestedSize = Math.Max(requestedSize, this.memoryManager.BlockSize); - - if (initialLargeBuffer == null) - { - this.EnsureCapacity(actualRequestedSize); - } - else - { - this.largeBuffer = initialLargeBuffer; - } - - if (this.memoryManager.GenerateCallStacks) - { - this.AllocationStack = Environment.StackTrace; - } - - this.memoryManager.ReportStreamCreated(this.id, this.tag, requestedSize, actualRequestedSize); - this.memoryManager.ReportUsageReport(); - } - #endregion - - #region Dispose and Finalize - /// - /// The finalizer will be called when a stream is not disposed properly. - /// - /// Failing to dispose indicates a bug in the code using streams. Care should be taken to properly account for stream lifetime. - ~RecyclableMemoryStream() - { - this.Dispose(false); - } - - /// - /// Returns the memory used by this stream back to the pool. - /// - /// Whether we're disposing (true), or being called by the finalizer (false). - protected override void Dispose(bool disposing) - { - if (this.disposed) - { - string doubleDisposeStack = null; - if (this.memoryManager.GenerateCallStacks) - { - doubleDisposeStack = Environment.StackTrace; - } - - this.memoryManager.ReportStreamDoubleDisposed(this.id, this.tag, this.AllocationStack, this.DisposeStack, doubleDisposeStack); - return; - } - - this.disposed = true; - var lifetime = TimeSpan.FromTicks((Stopwatch.GetTimestamp() - this.creationTimestamp) * TimeSpan.TicksPerSecond / Stopwatch.Frequency); - - if (this.memoryManager.GenerateCallStacks) - { - this.DisposeStack = Environment.StackTrace; - } - - this.memoryManager.ReportStreamDisposed(this.id, this.tag, lifetime, this.AllocationStack, this.DisposeStack); - - if (disposing) - { - GC.SuppressFinalize(this); - } - else - { - // We're being finalized. - this.memoryManager.ReportStreamFinalized(this.id, this.tag, this.AllocationStack); - - if (AppDomain.CurrentDomain.IsFinalizingForUnload()) - { - // If we're being finalized because of a shutdown, don't go any further. - // We have no idea what's already been cleaned up. Triggering events may cause - // a crash. - base.Dispose(disposing); - return; - } - } - - this.memoryManager.ReportStreamLength(this.length); - - if (this.largeBuffer != null) - { - this.memoryManager.ReturnLargeBuffer(this.largeBuffer, this.id, this.tag); - } - - if (this.dirtyBuffers != null) - { - foreach (var buffer in this.dirtyBuffers) - { - this.memoryManager.ReturnLargeBuffer(buffer, this.id, this.tag); - } - } - - this.memoryManager.ReturnBlocks(this.blocks, this.id, this.tag); - this.memoryManager.ReportUsageReport(); - this.blocks.Clear(); - - base.Dispose(disposing); - } - - /// - /// Equivalent to Dispose. - /// - public override void Close() - { - this.Dispose(true); - } - #endregion - - #region MemoryStream overrides - /// - /// Gets or sets the capacity. - /// - /// - /// - /// Capacity is always in multiples of the memory manager's block size, unless - /// the large buffer is in use. Capacity never decreases during a stream's lifetime. - /// Explicitly setting the capacity to a lower value than the current value will have no effect. - /// This is because the buffers are all pooled by chunks and there's little reason to - /// allow stream truncation. - /// - /// - /// Writing past the current capacity will cause to automatically increase, until MaximumStreamCapacity is reached. - /// - /// - /// If the capacity is larger than int.MaxValue, then InvalidOperationException will be thrown. If you anticipate using - /// larger streams, use the property instead. - /// - /// - /// Object has been disposed. - /// Capacity is larger than int.MaxValue. - public override int Capacity - { - get - { - this.CheckDisposed(); - if (this.largeBuffer != null) - { - return this.largeBuffer.Length; - } - - long size = (long)this.blocks.Count * this.memoryManager.BlockSize; - if (size > int.MaxValue) - { - throw new InvalidOperationException($"{nameof(Capacity)} is larger than int.MaxValue. Use {nameof(Capacity64)} instead."); - } - return (int)size; - } - set - { - this.Capacity64 = value; - } - } - - /// - /// Returns a 64-bit version of capacity, for streams larger than int.MaxValue in length. - /// - public long Capacity64 - { - get - { - this.CheckDisposed(); - if (this.largeBuffer != null) - { - return this.largeBuffer.Length; - } - - long size = (long)this.blocks.Count * this.memoryManager.BlockSize; - return size; - } - set - { - this.CheckDisposed(); - this.EnsureCapacity(value); - } - } - - private long length; - - /// - /// Gets the number of bytes written to this stream. - /// - /// Object has been disposed. - /// If the buffer has already been converted to a large buffer, then the maximum length is limited by the maximum allowed array length in .NET. - public override long Length - { - get - { - this.CheckDisposed(); - return this.length; - } - } - - private long position; - - /// - /// Gets the current position in the stream. - /// - /// Object has been disposed. - /// A negative value was passed. - /// Stream is in large-buffer mode, but an attempt was made to set the position past the maximum allowed array length. - /// If the buffer has already been converted to a large buffer, then the maximum length (and thus position) is limited by the maximum allowed array length in .NET. - public override long Position - { - get - { - this.CheckDisposed(); - return this.position; - } - set - { - this.CheckDisposed(); - if (value < 0) - { - throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(value)} must be non-negative."); - } - - if (this.largeBuffer != null && value > RecyclableMemoryStreamManager.MaxArrayLength) - { - throw new InvalidOperationException($"Once the stream is converted to a single large buffer, position cannot be set past {RecyclableMemoryStreamManager.MaxArrayLength}."); - } - this.position = value; - } - } - - /// - /// Whether the stream can currently read. - /// - public override bool CanRead => !this.Disposed; - - /// - /// Whether the stream can currently seek. - /// - public override bool CanSeek => !this.Disposed; - - /// - /// Always false. - /// - public override bool CanTimeout => false; - - /// - /// Whether the stream can currently write. - /// - public override bool CanWrite => !this.Disposed; - - /// - /// Returns a single buffer containing the contents of the stream. - /// The buffer may be longer than the stream length. - /// - /// A byte[] buffer. - /// IMPORTANT: Doing a after calling GetBuffer invalidates the buffer. The old buffer is held onto - /// until is called, but the next time GetBuffer is called, a new buffer from the pool will be required. - /// Object has been disposed. - /// stream is too large for a contiguous buffer. - public override byte[] GetBuffer() - { - this.CheckDisposed(); - - if (this.largeBuffer != null) - { - return this.largeBuffer; - } - - if (this.blocks.Count == 1) - { - return this.blocks[0]; - } - - // Buffer needs to reflect the capacity, not the length, because - // it's possible that people will manipulate the buffer directly - // and set the length afterward. Capacity sets the expectation - // for the size of the buffer. - - var newBuffer = this.memoryManager.GetLargeBuffer(this.Capacity64, this.id, this.tag); - - // InternalRead will check for existence of largeBuffer, so make sure we - // don't set it until after we've copied the data. - this.AssertLengthIsSmall(); - this.InternalRead(newBuffer, 0, (int)this.length, 0); - this.largeBuffer = newBuffer; - - if (this.blocks.Count > 0 && this.memoryManager.AggressiveBufferReturn) - { - this.memoryManager.ReturnBlocks(this.blocks, this.id, this.tag); - this.blocks.Clear(); - } - - return this.largeBuffer; - } - -#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1 - /// - public override void CopyTo(Stream destination, int bufferSize) - { - WriteTo(destination, this.position, this.length - this.position); - } -#endif - - /// Asynchronously reads all the bytes from the current position in this stream and writes them to another stream. - /// The stream to which the contents of the current stream will be copied. - /// This parameter is ignored. - /// The token to monitor for cancellation requests. - /// A task that represents the asynchronous copy operation. - /// - /// is . - /// Either the current stream or the destination stream is disposed. - /// The current stream does not support reading, or the destination stream does not support writing. - /// Similarly to MemoryStream's behavior, CopyToAsync will adjust the source stream's position by the number of bytes written to the destination stream, as a Read would do. - public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken) - { - if (destination == null) - { - throw new ArgumentNullException(nameof(destination)); - } - - this.CheckDisposed(); - - if (this.length == 0) - { - return Task.CompletedTask; - } - - long startPos = this.position; - var count = this.length - startPos; - this.position += count; - - if (destination is MemoryStream destinationRMS) - { - this.WriteTo(destinationRMS, startPos, count); - return Task.CompletedTask; - } - else - { - if (this.largeBuffer == null) - { - if (this.blocks.Count == 1) - { - AssertLengthIsSmall(); - return destination.WriteAsync(this.blocks[0], (int)startPos, (int)count, cancellationToken); - } - else - { - return CopyToAsyncImpl(destination, this.GetBlockAndRelativeOffset(startPos), count, this.blocks, cancellationToken); - } - } - else - { - AssertLengthIsSmall(); - return destination.WriteAsync(this.largeBuffer, (int)startPos, (int)count, cancellationToken); - } - } - - static async Task CopyToAsyncImpl(Stream destination, BlockAndOffset blockAndOffset, long count, List blocks, CancellationToken cancellationToken) - { - var bytesRemaining = count; - int currentBlock = blockAndOffset.Block; - var currentOffset = blockAndOffset.Offset; - while (bytesRemaining > 0) - { - byte[] block = blocks[currentBlock]; - int amountToCopy = (int)Math.Min(block.Length - currentOffset, bytesRemaining); - await destination.WriteAsync(block, currentOffset, amountToCopy, cancellationToken); - bytesRemaining -= amountToCopy; - ++currentBlock; - currentOffset = 0; - } - } - } - - private byte[] bufferWriterTempBuffer; - - /// - /// Notifies the stream that bytes were written to the buffer returned by or . - /// Seeks forward by bytes. - /// - /// - /// You must request a new buffer after calling Advance to continue writing more data and cannot write to a previously acquired buffer. - /// - /// How many bytes to advance. - /// Object has been disposed. - /// is negative. - /// is larger than the size of the previously requested buffer. - public void Advance(int count) - { - this.CheckDisposed(); - if (count < 0) - { - throw new ArgumentOutOfRangeException(nameof(count), $"{nameof(count)} must be non-negative."); - } - - byte[] buffer = this.bufferWriterTempBuffer; - if (buffer != null) - { - if (count > buffer.Length) - { - throw new InvalidOperationException($"Cannot advance past the end of the buffer, which has a size of {buffer.Length}."); - } - - this.Write(buffer, 0, count); - this.ReturnTempBuffer(buffer); - this.bufferWriterTempBuffer = null; - } - else - { - long bufferSize = this.largeBuffer == null - ? this.memoryManager.BlockSize - this.GetBlockAndRelativeOffset(this.position).Offset - : this.largeBuffer.Length - this.position; - - if (count > bufferSize) - { - throw new InvalidOperationException($"Cannot advance past the end of the buffer, which has a size of {bufferSize}."); - } - - this.position += count; - this.length = Math.Max(this.position, this.length); - } - } - - private void ReturnTempBuffer(byte[] buffer) - { - if (buffer.Length == this.memoryManager.BlockSize) - { - this.memoryManager.ReturnBlock(buffer, this.id, this.tag); - } - else - { - this.memoryManager.ReturnLargeBuffer(buffer, this.id, this.tag); - } - } - - /// - /// - /// IMPORTANT: Calling Write(), GetBuffer(), TryGetBuffer(), Seek(), GetLength(), Advance(), - /// or setting Position after calling GetMemory() invalidates the memory. - /// - public Memory GetMemory(int sizeHint = 0) => this.GetWritableBuffer(sizeHint); - - /// - /// - /// IMPORTANT: Calling Write(), GetBuffer(), TryGetBuffer(), Seek(), GetLength(), Advance(), - /// or setting Position after calling GetSpan() invalidates the span. - /// - public Span GetSpan(int sizeHint = 0) => this.GetWritableBuffer(sizeHint); - - /// - /// When callers to GetSpan() or GetMemory() request a buffer that is larger than the remaining size of the current block - /// this method return a temp buffer. When Advance() is called, that temp buffer is then copied into the stream. - /// - private ArraySegment GetWritableBuffer(int sizeHint) - { - this.CheckDisposed(); - if (sizeHint < 0) - { - throw new ArgumentOutOfRangeException(nameof(sizeHint), $"{nameof(sizeHint)} must be non-negative."); - } - - var minimumBufferSize = Math.Max(sizeHint, 1); - - this.EnsureCapacity(this.position + minimumBufferSize); - if (this.bufferWriterTempBuffer != null) - { - this.ReturnTempBuffer(this.bufferWriterTempBuffer); - this.bufferWriterTempBuffer = null; - } - - if (this.largeBuffer != null) - { - return new ArraySegment(this.largeBuffer, (int)this.position, this.largeBuffer.Length - (int)this.position); - } - - BlockAndOffset blockAndOffset = this.GetBlockAndRelativeOffset(this.position); - int remainingBytesInBlock = this.MemoryManager.BlockSize - blockAndOffset.Offset; - if (remainingBytesInBlock >= minimumBufferSize) - { - return new ArraySegment(this.blocks[blockAndOffset.Block], blockAndOffset.Offset, this.MemoryManager.BlockSize - blockAndOffset.Offset); - } - - this.bufferWriterTempBuffer = minimumBufferSize > this.memoryManager.BlockSize ? - this.memoryManager.GetLargeBuffer(minimumBufferSize, this.id, this.tag) : - this.memoryManager.GetBlock(); - - return new ArraySegment(this.bufferWriterTempBuffer); - } - - /// - /// Returns a sequence containing the contents of the stream. - /// - /// A ReadOnlySequence of bytes. - /// IMPORTANT: Calling Write(), GetMemory(), GetSpan(), Dispose(), or Close() after calling GetReadOnlySequence() invalidates the sequence. - /// Object has been disposed. - public ReadOnlySequence GetReadOnlySequence() - { - this.CheckDisposed(); - - if (this.largeBuffer != null) - { - AssertLengthIsSmall(); - return new ReadOnlySequence(this.largeBuffer, 0, (int)this.length); - } - - if (this.blocks.Count == 1) - { - AssertLengthIsSmall(); - return new ReadOnlySequence(this.blocks[0], 0, (int)this.length); - } - - var first = new BlockSegment(this.blocks[0]); - var last = first; - - for (int blockIdx = 1; last.RunningIndex + last.Memory.Length < this.length; blockIdx++) - { - last = last.Append(this.blocks[blockIdx]); - } - - return new ReadOnlySequence(first, 0, last, (int)(this.length - last.RunningIndex)); - } - - private sealed class BlockSegment : ReadOnlySequenceSegment - { - public BlockSegment(Memory memory) => Memory = memory; - - public BlockSegment Append(Memory memory) - { - var nextSegment = new BlockSegment(memory) { RunningIndex = RunningIndex + Memory.Length }; - Next = nextSegment; - return nextSegment; - } - } - - /// - /// Returns an ArraySegment that wraps a single buffer containing the contents of the stream. - /// - /// An ArraySegment containing a reference to the underlying bytes. - /// Returns if a buffer can be returned; otherwise, . - public override bool TryGetBuffer(out ArraySegment buffer) - { - this.CheckDisposed(); - - try - { - if (this.length <= RecyclableMemoryStreamManager.MaxArrayLength) - { - buffer = new ArraySegment(this.GetBuffer(), 0, (int)this.Length); - return true; - } - } - catch (OutOfMemoryException) - { - } - -#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1 - buffer = ArraySegment.Empty; -#else - buffer = new ArraySegment(); -#endif - return false; - } - - /// - /// Returns a new array with a copy of the buffer's contents. You should almost certainly be using combined with the to - /// access the bytes in this stream. Calling ToArray will destroy the benefits of pooled buffers, but it is included - /// for the sake of completeness. - /// - /// Object has been disposed. - /// The current object disallows ToArray calls. - /// The length of the stream is too long for a contiguous array. -#pragma warning disable CS0809 - [Obsolete("This method has degraded performance vs. GetBuffer and should be avoided.")] - public override byte[] ToArray() - { - this.CheckDisposed(); - - string stack = this.memoryManager.GenerateCallStacks ? Environment.StackTrace : null; - this.memoryManager.ReportStreamToArray(this.id, this.tag, stack, this.length); - - if (this.memoryManager.ThrowExceptionOnToArray) - { - throw new NotSupportedException("The underlying RecyclableMemoryStreamManager is configured to not allow calls to ToArray."); - } - - var newBuffer = new byte[this.Length]; - - Debug.Assert(this.length <= int.MaxValue); - this.InternalRead(newBuffer, 0, (int)this.length, 0); - - return newBuffer; - } -#pragma warning restore CS0809 - - /// - /// Reads from the current position into the provided buffer. - /// - /// Destination buffer. - /// Offset into buffer at which to start placing the read bytes. - /// Number of bytes to read. - /// The number of bytes read. - /// buffer is null. - /// offset or count is less than 0. - /// offset subtracted from the buffer length is less than count. - /// Object has been disposed. - public override int Read(byte[] buffer, int offset, int count) - { - return this.SafeRead(buffer, offset, count, ref this.position); - } - - /// - /// Reads from the specified position into the provided buffer. - /// - /// Destination buffer. - /// Offset into buffer at which to start placing the read bytes. - /// Number of bytes to read. - /// Position in the stream to start reading from. - /// The number of bytes read. - /// is null. - /// or is less than 0. - /// subtracted from the buffer length is less than . - /// Object has been disposed. - /// Stream position is beyond int.MaxValue. - public int SafeRead(byte[] buffer, int offset, int count, ref int streamPosition) - { - long longPosition = streamPosition; - var retVal = this.SafeRead(buffer, offset, count, ref longPosition); - if (longPosition > int.MaxValue) - { - throw new InvalidOperationException("Stream position is beyond int.MaxValue. Use SafeRead(byte[], int, int, ref long) override."); - } - streamPosition = (int)longPosition; - return retVal; - } - - /// - /// Reads from the specified position into the provided buffer. - /// - /// Destination buffer. - /// Offset into buffer at which to start placing the read bytes. - /// Number of bytes to read. - /// Position in the stream to start reading from. - /// The number of bytes read. - /// is null. - /// or is less than 0. - /// subtracted from the buffer length is less than . - /// Object has been disposed. - public int SafeRead(byte[] buffer, int offset, int count, ref long streamPosition) - { - this.CheckDisposed(); - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if (offset < 0) - { - throw new ArgumentOutOfRangeException(nameof(offset), $"{nameof(offset)} cannot be negative."); - } - - if (count < 0) - { - throw new ArgumentOutOfRangeException(nameof(count), $"{nameof(count)} cannot be negative."); - } - - if (offset + count > buffer.Length) - { - throw new ArgumentException($"{nameof(buffer)} length must be at least {nameof(offset)} + {nameof(count)}."); - } - - int amountRead = this.InternalRead(buffer, offset, count, streamPosition); - streamPosition += amountRead; - return amountRead; - } - - /// - /// Reads from the current position into the provided buffer. - /// - /// Destination buffer. - /// The number of bytes read. - /// Object has been disposed. -#if NETSTANDARD2_0 || NET462 - public int Read(Span buffer) -#else - public override int Read(Span buffer) -#endif - { - return this.SafeRead(buffer, ref this.position); - } - - /// - /// Reads from the specified position into the provided buffer. - /// - /// Destination buffer. - /// Position in the stream to start reading from. - /// The number of bytes read. - /// Object has been disposed. - /// Stream position is beyond int.MaxValue. - public int SafeRead(Span buffer, ref int streamPosition) - { - long longPosition = streamPosition; - int retVal = this.SafeRead(buffer, ref longPosition); - if (longPosition > int.MaxValue) - { - throw new InvalidOperationException("Stream position is beyond int.MaxValue. Use SafeRead(Span, ref long) override."); - } - streamPosition = (int)longPosition; - return retVal; - } - - /// - /// Reads from the specified position into the provided buffer. - /// - /// Destination buffer. - /// Position in the stream to start reading from. - /// The number of bytes read. - /// Object has been disposed. - public int SafeRead(Span buffer, ref long streamPosition) - { - this.CheckDisposed(); - - int amountRead = this.InternalRead(buffer, streamPosition); - streamPosition += amountRead; - return amountRead; - } - - /// - /// Writes the buffer to the stream. - /// - /// Source buffer. - /// Start position. - /// Number of bytes to write. - /// buffer is null. - /// offset or count is negative. - /// buffer.Length - offset is not less than count. - /// Object has been disposed. - public override void Write(byte[] buffer, int offset, int count) - { - this.CheckDisposed(); - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if (offset < 0) - { - throw new ArgumentOutOfRangeException(nameof(offset), offset, - $"{nameof(offset)} must be in the range of 0 - {nameof(buffer)}.{nameof(buffer.Length)}-1."); - } - - if (count < 0) - { - throw new ArgumentOutOfRangeException(nameof(count), count, $"{nameof(count)} must be non-negative."); - } - - if (count + offset > buffer.Length) - { - throw new ArgumentException($"{nameof(count)} must be greater than {nameof(buffer)}.{nameof(buffer.Length)} - {nameof(offset)}."); - } - - int blockSize = this.memoryManager.BlockSize; - long end = (long)this.position + count; - - this.EnsureCapacity(end); - - if (this.largeBuffer == null) - { - int bytesRemaining = count; - int bytesWritten = 0; - var blockAndOffset = this.GetBlockAndRelativeOffset(this.position); - - while (bytesRemaining > 0) - { - byte[] currentBlock = this.blocks[blockAndOffset.Block]; - int remainingInBlock = blockSize - blockAndOffset.Offset; - int amountToWriteInBlock = Math.Min(remainingInBlock, bytesRemaining); - - Buffer.BlockCopy(buffer, offset + bytesWritten, currentBlock, blockAndOffset.Offset, - amountToWriteInBlock); - - bytesRemaining -= amountToWriteInBlock; - bytesWritten += amountToWriteInBlock; - - ++blockAndOffset.Block; - blockAndOffset.Offset = 0; - } - } - else - { - Buffer.BlockCopy(buffer, offset, this.largeBuffer, (int)this.position, count); - } - this.position = end; - this.length = Math.Max(this.position, this.length); - } - - /// - /// Writes the buffer to the stream. - /// - /// Source buffer. - /// buffer is null. - /// Object has been disposed. -#if NETSTANDARD2_0 || NET462 - public void Write(ReadOnlySpan source) -#else - public override void Write(ReadOnlySpan source) -#endif - - { - this.CheckDisposed(); - - int blockSize = this.memoryManager.BlockSize; - long end = (long)this.position + source.Length; - - this.EnsureCapacity(end); - - if (this.largeBuffer == null) - { - var blockAndOffset = this.GetBlockAndRelativeOffset(this.position); - - while (source.Length > 0) - { - byte[] currentBlock = this.blocks[blockAndOffset.Block]; - int remainingInBlock = blockSize - blockAndOffset.Offset; - int amountToWriteInBlock = Math.Min(remainingInBlock, source.Length); - - source.Slice(0, amountToWriteInBlock) - .CopyTo(currentBlock.AsSpan(blockAndOffset.Offset)); - - source = source.Slice(amountToWriteInBlock); - - ++blockAndOffset.Block; - blockAndOffset.Offset = 0; - } - } - else - { - source.CopyTo(this.largeBuffer.AsSpan((int)this.position)); - } - this.position = end; - this.length = Math.Max(this.position, this.length); - } - - /// - /// Returns a useful string for debugging. This should not normally be called in actual production code. - /// - public override string ToString() - { - if (!this.disposed) - { - return $"Id = {this.Id}, Tag = {this.Tag}, Length = {this.Length:N0} bytes"; - } - else - { - // Avoid properties because of the dispose check, but the fields themselves are not cleared. - return $"Disposed: Id = {this.id}, Tag = {this.tag}, Final Length: {this.length:N0} bytes"; - } - } - - /// - /// Writes a single byte to the current position in the stream. - /// - /// byte value to write. - /// Object has been disposed. - public override void WriteByte(byte value) - { - this.CheckDisposed(); - - long end = (long)this.position + 1; - - if (this.largeBuffer == null) - { - var blockSize = this.memoryManager.BlockSize; - - var block = (int)Math.DivRem(this.position, blockSize, out var index); - - if (block >= this.blocks.Count) - { - this.EnsureCapacity(end); - } - - this.blocks[block][index] = value; - } - else - { - if (this.position >= this.largeBuffer.Length) - { - this.EnsureCapacity(end); - } - - this.largeBuffer[this.position] = value; - } - - this.position = end; - - if (this.position > this.length) - { - this.length = this.position; - } - } - - /// - /// Reads a single byte from the current position in the stream. - /// - /// The byte at the current position, or -1 if the position is at the end of the stream. - /// Object has been disposed. - public override int ReadByte() - { - return this.SafeReadByte(ref this.position); - } - - /// - /// Reads a single byte from the specified position in the stream. - /// - /// The position in the stream to read from. - /// The byte at the current position, or -1 if the position is at the end of the stream. - /// Object has been disposed. - /// Stream position is beyond int.MaxValue. - public int SafeReadByte(ref int streamPosition) - { - long longPosition = streamPosition; - int retVal = this.SafeReadByte(ref longPosition); - if (longPosition > int.MaxValue) - { - throw new InvalidOperationException("Stream position is beyond int.MaxValue. Use SafeReadByte(ref long) override."); - } - streamPosition = (int)longPosition; - return retVal; - } - - /// - /// Reads a single byte from the specified position in the stream. - /// - /// The position in the stream to read from. - /// The byte at the current position, or -1 if the position is at the end of the stream. - /// Object has been disposed. - public int SafeReadByte(ref long streamPosition) - { - this.CheckDisposed(); - if (streamPosition == this.length) - { - return -1; - } - byte value; - if (this.largeBuffer == null) - { - var blockAndOffset = this.GetBlockAndRelativeOffset(streamPosition); - value = this.blocks[blockAndOffset.Block][blockAndOffset.Offset]; - } - else - { - value = this.largeBuffer[streamPosition]; - } - streamPosition++; - return value; - } - - /// - /// Sets the length of the stream. - /// - /// value is negative or larger than . - /// Object has been disposed. - public override void SetLength(long value) - { - this.CheckDisposed(); - if (value < 0) - { - throw new ArgumentOutOfRangeException(nameof(value), $"{nameof(value)} must be non-negative."); - } - - this.EnsureCapacity(value); - - this.length = value; - if (this.position > value) - { - this.position = value; - } - } - - /// - /// Sets the position to the offset from the seek location. - /// - /// How many bytes to move. - /// From where. - /// The new position. - /// Object has been disposed. - /// is larger than . - /// Invalid seek origin. - /// Attempt to set negative position. - public override long Seek(long offset, SeekOrigin loc) - { - this.CheckDisposed(); - long newPosition = loc switch - { - SeekOrigin.Begin => offset, - SeekOrigin.Current => offset + this.position, - SeekOrigin.End => offset + this.length, - _ => throw new ArgumentException("Invalid seek origin.", nameof(loc)), - }; - if (newPosition < 0) - { - throw new IOException("Seek before beginning."); - } - this.position = newPosition; - return this.position; - } - - /// - /// Synchronously writes this stream's bytes to the argument stream. - /// - /// Destination stream. - /// Important: This does a synchronous write, which may not be desired in some situations. - /// is null. - /// Object has been disposed. - public override void WriteTo(Stream stream) - { - this.WriteTo(stream, 0, this.length); - } - - /// - /// Synchronously writes this stream's bytes, starting at offset, for count bytes, to the argument stream. - /// - /// Destination stream. - /// Offset in source. - /// Number of bytes to write. - /// is null. - /// - /// is less than 0, or + is beyond this 's length. - /// - /// Object has been disposed. - public void WriteTo(Stream stream, int offset, int count) - { - this.WriteTo(stream, (long)offset, (long)count); - } - - /// - /// Synchronously writes this stream's bytes, starting at offset, for count bytes, to the argument stream. - /// - /// Destination stream. - /// Offset in source. - /// Number of bytes to write. - /// is null. - /// - /// is less than 0, or + is beyond this 's length. - /// - /// Object has been disposed. - public void WriteTo(Stream stream, long offset, long count) - { - this.CheckDisposed(); - if (stream == null) - { - throw new ArgumentNullException(nameof(stream)); - } - - if (offset < 0 || offset + count > this.length) - { - throw new ArgumentOutOfRangeException( - message: $"{nameof(offset)} must not be negative and {nameof(offset)} + {nameof(count)} must not exceed the length of the {nameof(stream)}.", - innerException: null); - } - - if (this.largeBuffer == null) - { - var blockAndOffset = this.GetBlockAndRelativeOffset(offset); - long bytesRemaining = count; - int currentBlock = blockAndOffset.Block; - int currentOffset = blockAndOffset.Offset; - - while (bytesRemaining > 0) - { - byte[] block = this.blocks[currentBlock]; - int amountToCopy = (int)Math.Min((long)block.Length - currentOffset, bytesRemaining); - stream.Write(block, currentOffset, amountToCopy); - - bytesRemaining -= amountToCopy; - - ++currentBlock; - currentOffset = 0; - } - } - else - { - stream.Write(this.largeBuffer, (int)offset, (int)count); - } - } - - /// - /// Writes bytes from the current stream to a destination byte array. - /// - /// Target buffer. - /// The entire stream is written to the target array. - /// > is null. - /// Object has been disposed. - public void WriteTo(byte[] buffer) - { - this.WriteTo(buffer, 0, this.Length); - } - - /// - /// Writes bytes from the current stream to a destination byte array. - /// - /// Target buffer. - /// Offset in the source stream, from which to start. - /// Number of bytes to write. - /// > is null. - /// - /// is less than 0, or + is beyond this stream's length. - /// - /// Object has been disposed. - public void WriteTo(byte[] buffer, long offset, long count) - { - this.WriteTo(buffer, offset, count, 0); - } - - /// - /// Writes bytes from the current stream to a destination byte array. - /// - /// Target buffer. - /// Offset in the source stream, from which to start. - /// Number of bytes to write. - /// Offset in the target byte array to start writing - /// buffer is null - /// - /// is less than 0, or + is beyond this stream's length. - /// - /// - /// is less than 0, or + is beyond the target 's length. - /// - /// Object has been disposed. - public void WriteTo(byte[] buffer, long offset, long count, int targetOffset) - { - this.CheckDisposed(); - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if (offset < 0 || offset + count > this.length) - { - throw new ArgumentOutOfRangeException( - message: $"{nameof(offset)} must not be negative and {nameof(offset)} + {nameof(count)} must not exceed the length of the stream.", - innerException: null); - } - - if (targetOffset < 0 || count + targetOffset > buffer.Length) - { - throw new ArgumentOutOfRangeException( - message: $"{nameof(targetOffset)} must not be negative and {nameof(targetOffset)} + {nameof(count)} must not exceed the length of the target {nameof(buffer)}.", - innerException: null); - } - - if (this.largeBuffer == null) - { - var blockAndOffset = GetBlockAndRelativeOffset(offset); - long bytesRemaining = count; - int currentBlock = blockAndOffset.Block; - int currentOffset = blockAndOffset.Offset; - int currentTargetOffset = targetOffset; - - while (bytesRemaining > 0) - { - byte[] block = this.blocks[currentBlock]; - int amountToCopy = (int)Math.Min((long)block.Length - currentOffset, bytesRemaining); - Buffer.BlockCopy(block, currentOffset, buffer, currentTargetOffset, amountToCopy); - - bytesRemaining -= amountToCopy; - - ++currentBlock; - currentOffset = 0; - currentTargetOffset += amountToCopy; - } - } - else - { - AssertLengthIsSmall(); - Buffer.BlockCopy(this.largeBuffer, (int)offset, buffer, targetOffset, (int)count); - } - } - #endregion - - #region Helper Methods - private bool Disposed => this.disposed; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void CheckDisposed() - { - if (this.Disposed) - { - this.ThrowDisposedException(); - } - } - - [MethodImpl(MethodImplOptions.NoInlining)] - private void ThrowDisposedException() - { - throw new ObjectDisposedException($"The stream with Id {this.id} and Tag {this.tag} is disposed."); - } - - private int InternalRead(byte[] buffer, int offset, int count, long fromPosition) - { - if (this.length - fromPosition <= 0) - { - return 0; - } - - int amountToCopy; - - if (this.largeBuffer == null) - { - var blockAndOffset = this.GetBlockAndRelativeOffset(fromPosition); - int bytesWritten = 0; - int bytesRemaining = (int)Math.Min((long)count, this.length - fromPosition); - - while (bytesRemaining > 0) - { - byte[] block = this.blocks[blockAndOffset.Block]; - amountToCopy = Math.Min(block.Length - blockAndOffset.Offset, - bytesRemaining); - Buffer.BlockCopy(block, blockAndOffset.Offset, buffer, - bytesWritten + offset, amountToCopy); - - bytesWritten += amountToCopy; - bytesRemaining -= amountToCopy; - - ++blockAndOffset.Block; - blockAndOffset.Offset = 0; - } - return bytesWritten; - } - amountToCopy = (int)Math.Min((long)count, this.length - fromPosition); - Buffer.BlockCopy(this.largeBuffer, (int)fromPosition, buffer, offset, amountToCopy); - return amountToCopy; - } - - private int InternalRead(Span buffer, long fromPosition) - { - if (this.length - fromPosition <= 0) - { - return 0; - } - - int amountToCopy; - - if (this.largeBuffer == null) - { - var blockAndOffset = this.GetBlockAndRelativeOffset(fromPosition); - int bytesWritten = 0; - int bytesRemaining = (int)Math.Min(buffer.Length, this.length - fromPosition); - - while (bytesRemaining > 0) - { - byte[] block = this.blocks[blockAndOffset.Block]; - amountToCopy = Math.Min(block.Length - blockAndOffset.Offset, - bytesRemaining); - block.AsSpan(blockAndOffset.Offset, amountToCopy) - .CopyTo(buffer.Slice(bytesWritten)); - - bytesWritten += amountToCopy; - bytesRemaining -= amountToCopy; - - ++blockAndOffset.Block; - blockAndOffset.Offset = 0; - } - return bytesWritten; - } - amountToCopy = (int)Math.Min((long)buffer.Length, this.length - fromPosition); - this.largeBuffer.AsSpan((int)fromPosition, amountToCopy).CopyTo(buffer); - return amountToCopy; - } - - private struct BlockAndOffset - { - public int Block; - public int Offset; - - public BlockAndOffset(int block, int offset) - { - this.Block = block; - this.Offset = offset; - } - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private BlockAndOffset GetBlockAndRelativeOffset(long offset) - { - var blockSize = this.memoryManager.BlockSize; - int blockIndex = (int)Math.DivRem(offset, blockSize, out long offsetIndex); - return new BlockAndOffset(blockIndex, (int)offsetIndex); - } - - private void EnsureCapacity(long newCapacity) - { - if (newCapacity > this.memoryManager.MaximumStreamCapacity && this.memoryManager.MaximumStreamCapacity > 0) - { - this.memoryManager.ReportStreamOverCapacity(this.id, this.tag, newCapacity, this.AllocationStack); - - throw new OutOfMemoryException($"Requested capacity is too large: {newCapacity}. Limit is {this.memoryManager.MaximumStreamCapacity}."); - } - - if (this.largeBuffer != null) - { - if (newCapacity > this.largeBuffer.Length) - { - var newBuffer = this.memoryManager.GetLargeBuffer(newCapacity, this.id, this.tag); - Debug.Assert(this.length <= Int32.MaxValue); - this.InternalRead(newBuffer, 0, (int)this.length, 0); - this.ReleaseLargeBuffer(); - this.largeBuffer = newBuffer; - } - } - else - { - // Let's save some re-allocs of the blocks list - var blocksRequired = (newCapacity / this.memoryManager.BlockSize) + 1; - if (this.blocks.Capacity < blocksRequired) - { - this.blocks.Capacity = (int)blocksRequired; - } - while (this.Capacity64 < newCapacity) - { - this.blocks.Add((this.memoryManager.GetBlock())); - } - } - } - - /// - /// Release the large buffer (either stores it for eventual release or returns it immediately). - /// - private void ReleaseLargeBuffer() - { - if (this.memoryManager.AggressiveBufferReturn) - { - this.memoryManager.ReturnLargeBuffer(this.largeBuffer, this.id, this.tag); - } - else - { - // We most likely will only ever need space for one - this.dirtyBuffers ??= new List(1); - this.dirtyBuffers.Add(this.largeBuffer); - } - - this.largeBuffer = null; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void AssertLengthIsSmall() - { - Debug.Assert(this.length <= Int32.MaxValue, "this.length was assumed to be <= Int32.MaxValue, but was larger."); - } -#endregion - } -} diff --git a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/RecyclableMemoryStream.cs.meta b/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/RecyclableMemoryStream.cs.meta deleted file mode 100644 index fc7b6212..00000000 --- a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/RecyclableMemoryStream.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 943657a525c4a1f469a62b5e8cb2c319 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/RecyclableMemoryStreamManager.cs b/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/RecyclableMemoryStreamManager.cs deleted file mode 100644 index c8a733aa..00000000 --- a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/RecyclableMemoryStreamManager.cs +++ /dev/null @@ -1,1077 +0,0 @@ -// --------------------------------------------------------------------- -// Copyright (c) 2015-2016 Microsoft -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// --------------------------------------------------------------------- - -#pragma warning disable CS8625 -#pragma warning disable CS8604 -#pragma warning disable CS8600 -#pragma warning disable CS8618 -namespace TEngine.IO -{ - using System; - using System.Collections.Concurrent; - using System.Collections.Generic; - using System.IO; - using System.Runtime.CompilerServices; - using System.Threading; - - /// - /// Manages pools of objects. - /// - /// - /// - /// There are two pools managed in here. The small pool contains same-sized buffers that are handed to streams - /// as they write more data. - /// - /// - /// For scenarios that need to call , the large pool contains buffers of various sizes, all - /// multiples/exponentials of (1 MB by default). They are split by size to avoid overly-wasteful buffer - /// usage. There should be far fewer 8 MB buffers than 1 MB buffers, for example. - /// - /// - public partial class RecyclableMemoryStreamManager - { - /// - /// Maximum length of a single array. - /// - /// See documentation at https://docs.microsoft.com/dotnet/api/system.array?view=netcore-3.1 - /// - internal const int MaxArrayLength = 0X7FFFFFC7; - - /// - /// Default block size, in bytes. - /// - public const int DefaultBlockSize = 128 * 1024; - - /// - /// Default large buffer multiple, in bytes. - /// - public const int DefaultLargeBufferMultiple = 1024 * 1024; - - /// - /// Default maximum buffer size, in bytes. - /// - public const int DefaultMaximumBufferSize = 128 * 1024 * 1024; - - // 0 to indicate unbounded - private const long DefaultMaxSmallPoolFreeBytes = 0L; - private const long DefaultMaxLargePoolFreeBytes = 0L; - - private readonly long[] largeBufferFreeSize; - private readonly long[] largeBufferInUseSize; - - private readonly ConcurrentStack[] largePools; - - private readonly ConcurrentStack smallPool; - - private long smallPoolFreeSize; - private long smallPoolInUseSize; - - /// - /// Initializes the memory manager with the default block/buffer specifications. This pool may have unbounded growth unless you modify and . - /// - public RecyclableMemoryStreamManager() - : this(DefaultBlockSize, DefaultLargeBufferMultiple, DefaultMaximumBufferSize, false, DefaultMaxSmallPoolFreeBytes, DefaultMaxLargePoolFreeBytes) { } - - /// - /// Initializes the memory manager with the default block/buffer specifications and maximum free bytes specifications. - /// - /// Maximum number of bytes to keep available in the small pool before future buffers get dropped for garbage collection - /// Maximum number of bytes to keep available in the large pool before future buffers get dropped for garbage collection - /// is negative, or is negative. - public RecyclableMemoryStreamManager(long maximumSmallPoolFreeBytes, long maximumLargePoolFreeBytes) - :this(DefaultBlockSize, DefaultLargeBufferMultiple, DefaultMaximumBufferSize, useExponentialLargeBuffer:false, maximumSmallPoolFreeBytes, maximumLargePoolFreeBytes) - { - } - - /// - /// Initializes the memory manager with the given block requiredSize. This pool may have unbounded growth unless you modify and . - /// - /// Size of each block that is pooled. Must be > 0. - /// Each large buffer will be a multiple of this value. - /// Buffers larger than this are not pooled - /// - /// is not a positive number, - /// or is not a positive number, - /// or is less than . - /// is not a multiple of . - public RecyclableMemoryStreamManager(int blockSize, int largeBufferMultiple, int maximumBufferSize) - : this(blockSize, largeBufferMultiple, maximumBufferSize, false, DefaultMaxSmallPoolFreeBytes, DefaultMaxLargePoolFreeBytes) { } - - /// - /// Initializes the memory manager with the given block requiredSize. - /// - /// Size of each block that is pooled. Must be > 0. - /// Each large buffer will be a multiple of this value. - /// Buffers larger than this are not pooled - /// Maximum number of bytes to keep available in the small pool before future buffers get dropped for garbage collection - /// Maximum number of bytes to keep available in the large pool before future buffers get dropped for garbage collection - /// - /// is not a positive number, - /// or is not a positive number, - /// or is less than , - /// or is negative, - /// or is negative. - /// - /// is not a multiple of . - public RecyclableMemoryStreamManager(int blockSize, int largeBufferMultiple, int maximumBufferSize, long maximumSmallPoolFreeBytes, long maximumLargePoolFreeBytes) - : this(blockSize, largeBufferMultiple, maximumBufferSize, false, maximumSmallPoolFreeBytes, maximumLargePoolFreeBytes) { } - - - /// - /// Initializes the memory manager with the given block requiredSize. This pool may have unbounded growth unless you modify and . - /// - /// Size of each block that is pooled. Must be > 0. - /// Each large buffer will be a multiple/exponential of this value. - /// Buffers larger than this are not pooled - /// Switch to exponential large buffer allocation strategy - /// - /// is not a positive number, - /// or is not a positive number, - /// or is less than . - /// is not a multiple/exponential of . - public RecyclableMemoryStreamManager(int blockSize, int largeBufferMultiple, int maximumBufferSize, bool useExponentialLargeBuffer) - :this(blockSize, largeBufferMultiple, maximumBufferSize, useExponentialLargeBuffer, DefaultMaxSmallPoolFreeBytes, DefaultMaxLargePoolFreeBytes) - { - } - - /// - /// Initializes the memory manager with the given block requiredSize. - /// - /// Size of each block that is pooled. Must be > 0. - /// Each large buffer will be a multiple/exponential of this value. - /// Buffers larger than this are not pooled. - /// Switch to exponential large buffer allocation strategy. - /// Maximum number of bytes to keep available in the small pool before future buffers get dropped for garbage collection. - /// Maximum number of bytes to keep available in the large pool before future buffers get dropped for garbage collection. - /// - /// is not a positive number, - /// or is not a positive number, - /// or is less than , - /// or is negative, - /// or is negative. - /// - /// is not a multiple/exponential of . - public RecyclableMemoryStreamManager(int blockSize, int largeBufferMultiple, int maximumBufferSize, bool useExponentialLargeBuffer, long maximumSmallPoolFreeBytes, long maximumLargePoolFreeBytes) - { - if (blockSize <= 0) - { - throw new ArgumentOutOfRangeException(nameof(blockSize), blockSize, $"{nameof(blockSize)} must be a positive number"); - } - - if (largeBufferMultiple <= 0) - { - throw new ArgumentOutOfRangeException(nameof(largeBufferMultiple), $"{nameof(largeBufferMultiple)} must be a positive number"); - } - - if (maximumBufferSize < blockSize) - { - throw new ArgumentOutOfRangeException(nameof(maximumBufferSize), $"{nameof(maximumBufferSize)} must be at least {nameof(blockSize)}"); - } - - if (maximumSmallPoolFreeBytes < 0) - { - throw new ArgumentOutOfRangeException(nameof(maximumSmallPoolFreeBytes), $"{nameof(maximumSmallPoolFreeBytes)} must be non-negative"); - } - - if (maximumLargePoolFreeBytes < 0) - { - throw new ArgumentOutOfRangeException(nameof(maximumLargePoolFreeBytes), $"{nameof(maximumLargePoolFreeBytes)} must be non-negative"); - } - - this.BlockSize = blockSize; - this.LargeBufferMultiple = largeBufferMultiple; - this.MaximumBufferSize = maximumBufferSize; - this.UseExponentialLargeBuffer = useExponentialLargeBuffer; - this.MaximumFreeSmallPoolBytes = maximumSmallPoolFreeBytes; - this.MaximumFreeLargePoolBytes = maximumLargePoolFreeBytes; - - if (!this.IsLargeBufferSize(maximumBufferSize)) - { - throw new ArgumentException( - $"{nameof(maximumBufferSize)} is not {(this.UseExponentialLargeBuffer ? "an exponential" : "a multiple")} of {nameof(largeBufferMultiple)}.", - nameof(maximumBufferSize)); - } - - this.smallPool = new ConcurrentStack(); - var numLargePools = useExponentialLargeBuffer - ? ((int)Math.Log(maximumBufferSize / largeBufferMultiple, 2) + 1) - : (maximumBufferSize / largeBufferMultiple); - - // +1 to store size of bytes in use that are too large to be pooled - this.largeBufferInUseSize = new long[numLargePools + 1]; - this.largeBufferFreeSize = new long[numLargePools]; - - this.largePools = new ConcurrentStack[numLargePools]; - - for (var i = 0; i < this.largePools.Length; ++i) - { - this.largePools[i] = new ConcurrentStack(); - } - - Events.Writer.MemoryStreamManagerInitialized(blockSize, largeBufferMultiple, maximumBufferSize); - } - - /// - /// The size of each block. It must be set at creation and cannot be changed. - /// - public int BlockSize { get; } - - /// - /// All buffers are multiples/exponentials of this number. It must be set at creation and cannot be changed. - /// - public int LargeBufferMultiple { get; } - - /// - /// Use multiple large buffer allocation strategy. It must be set at creation and cannot be changed. - /// - public bool UseMultipleLargeBuffer => !this.UseExponentialLargeBuffer; - - /// - /// Use exponential large buffer allocation strategy. It must be set at creation and cannot be changed. - /// - public bool UseExponentialLargeBuffer { get; } - - /// - /// Gets the maximum buffer size. - /// - /// Any buffer that is returned to the pool that is larger than this will be - /// discarded and garbage collected. - public int MaximumBufferSize { get; } - - /// - /// Number of bytes in small pool not currently in use. - /// - public long SmallPoolFreeSize => this.smallPoolFreeSize; - - /// - /// Number of bytes currently in use by stream from the small pool. - /// - public long SmallPoolInUseSize => this.smallPoolInUseSize; - - /// - /// Number of bytes in large pool not currently in use. - /// - public long LargePoolFreeSize - { - get - { - long sum = 0; - foreach (long freeSize in this.largeBufferFreeSize) - { - sum += freeSize; - } - - return sum; - } - } - - /// - /// Number of bytes currently in use by streams from the large pool. - /// - public long LargePoolInUseSize - { - get - { - long sum = 0; - foreach (long inUseSize in this.largeBufferInUseSize) - { - sum += inUseSize; - } - - return sum; - } - } - - /// - /// How many blocks are in the small pool. - /// - public long SmallBlocksFree => this.smallPool.Count; - - /// - /// How many buffers are in the large pool. - /// - public long LargeBuffersFree - { - get - { - long free = 0; - foreach (var pool in this.largePools) - { - free += pool.Count; - } - return free; - } - } - - /// - /// How many bytes of small free blocks to allow before we start dropping - /// those returned to us. - /// - /// The default value is 0, meaning the pool is unbounded. - public long MaximumFreeSmallPoolBytes { get; set; } - - /// - /// How many bytes of large free buffers to allow before we start dropping - /// those returned to us. - /// - /// The default value is 0, meaning the pool is unbounded. - public long MaximumFreeLargePoolBytes { get; set; } - - /// - /// Maximum stream capacity in bytes. Attempts to set a larger capacity will - /// result in an exception. - /// - /// A value of 0 indicates no limit. - public long MaximumStreamCapacity { get; set; } - - /// - /// Whether to save callstacks for stream allocations. This can help in debugging. - /// It should NEVER be turned on generally in production. - /// - public bool GenerateCallStacks { get; set; } - - /// - /// Whether dirty buffers can be immediately returned to the buffer pool. - /// - /// - /// - /// When is called on a stream and creates a single large buffer, if this setting is enabled, the other blocks will be returned - /// to the buffer pool immediately. - /// - /// - /// Note when enabling this setting that the user is responsible for ensuring that any buffer previously - /// retrieved from a stream which is subsequently modified is not used after modification (as it may no longer - /// be valid). - /// - /// - public bool AggressiveBufferReturn { get; set; } - - /// - /// Causes an exception to be thrown if is ever called. - /// - /// Calling defeats the purpose of a pooled buffer. Use this property to discover code that is calling . If this is - /// set and is called, a NotSupportedException will be thrown. - public bool ThrowExceptionOnToArray { get; set; } - - /// - /// Removes and returns a single block from the pool. - /// - /// A byte[] array. - internal byte[] GetBlock() - { - Interlocked.Add(ref this.smallPoolInUseSize, this.BlockSize); - - if (!this.smallPool.TryPop(out byte[] block)) - { - // We'll add this back to the pool when the stream is disposed - // (unless our free pool is too large) -#if NET5_0_OR_GREATER - block = GC.AllocateUninitializedArray(this.BlockSize); -#else - block = new byte[this.BlockSize]; -#endif - ReportBlockCreated(); - } - else - { - Interlocked.Add(ref this.smallPoolFreeSize, -this.BlockSize); - } - - return block; - } - - /// - /// Returns a buffer of arbitrary size from the large buffer pool. This buffer - /// will be at least the requiredSize and always be a multiple/exponential of largeBufferMultiple. - /// - /// The minimum length of the buffer. - /// Unique ID for the stream. - /// The tag of the stream returning this buffer, for logging if necessary. - /// A buffer of at least the required size. - /// Requested array size is larger than the maximum allowed. - internal byte[] GetLargeBuffer(long requiredSize, Guid id, string tag) - { - if (requiredSize > MaxArrayLength) - { - throw new OutOfMemoryException($"Requested size exceeds maximum array length of {MaxArrayLength}."); - } - - requiredSize = this.RoundToLargeBufferSize(requiredSize); - - var poolIndex = this.GetPoolIndex(requiredSize); - - bool createdNew = false; - bool pooled = true; - string callStack = null; - - byte[] buffer; - if (poolIndex < this.largePools.Length) - { - if (!this.largePools[poolIndex].TryPop(out buffer)) - { - buffer = AllocateArray(requiredSize); - createdNew = true; - } - else - { - Interlocked.Add(ref this.largeBufferFreeSize[poolIndex], -buffer.Length); - } - } - else - { - // Buffer is too large to pool. They get a new buffer. - - // We still want to track the size, though, and we've reserved a slot - // in the end of the inuse array for nonpooled bytes in use. - poolIndex = this.largeBufferInUseSize.Length - 1; - - // We still want to round up to reduce heap fragmentation. - buffer = AllocateArray(requiredSize); - if (this.GenerateCallStacks) - { - // Grab the stack -- we want to know who requires such large buffers - callStack = Environment.StackTrace; - } - createdNew = true; - pooled = false; - } - - Interlocked.Add(ref this.largeBufferInUseSize[poolIndex], buffer.Length); - if (createdNew) - { - ReportLargeBufferCreated(id, tag, requiredSize, pooled: pooled, callStack); - } - - return buffer; - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - static byte[] AllocateArray(long requiredSize) => -#if NET5_0_OR_GREATER - GC.AllocateUninitializedArray((int)requiredSize); -#else - new byte[requiredSize]; -#endif - } - - private long RoundToLargeBufferSize(long requiredSize) - { - if (this.UseExponentialLargeBuffer) - { - long pow = 1; - while (this.LargeBufferMultiple * pow < requiredSize) - { - pow <<= 1; - } - return this.LargeBufferMultiple * pow; - } - else - { - return ((requiredSize + this.LargeBufferMultiple - 1) / this.LargeBufferMultiple) * this.LargeBufferMultiple; - } - } - - private bool IsLargeBufferSize(int value) - { - return (value != 0) && (this.UseExponentialLargeBuffer - ? (value == RoundToLargeBufferSize(value)) - : (value % this.LargeBufferMultiple) == 0); - } - - private int GetPoolIndex(long length) - { - if (this.UseExponentialLargeBuffer) - { - int index = 0; - while ((this.LargeBufferMultiple << index) < length) - { - ++index; - } - return index; - } - else - { - return (int)(length / this.LargeBufferMultiple - 1); - } - } - - /// - /// Returns the buffer to the large pool. - /// - /// The buffer to return. - /// Unique stream ID. - /// The tag of the stream returning this buffer, for logging if necessary. - /// is null. - /// buffer.Length is not a multiple/exponential of (it did not originate from this pool). - internal void ReturnLargeBuffer(byte[] buffer, Guid id, string tag) - { - if (buffer == null) - { - throw new ArgumentNullException(nameof(buffer)); - } - - if (!this.IsLargeBufferSize(buffer.Length)) - { - throw new ArgumentException($"{nameof(buffer)} did not originate from this memory manager. The size is not " + - $"{(this.UseExponentialLargeBuffer ? "an exponential" : "a multiple")} of {this.LargeBufferMultiple}."); - } - - var poolIndex = this.GetPoolIndex(buffer.Length); - - if (poolIndex < this.largePools.Length) - { - if ((this.largePools[poolIndex].Count + 1) * buffer.Length <= this.MaximumFreeLargePoolBytes || - this.MaximumFreeLargePoolBytes == 0) - { - this.largePools[poolIndex].Push(buffer); - Interlocked.Add(ref this.largeBufferFreeSize[poolIndex], buffer.Length); - } - else - { - ReportBufferDiscarded(id, tag, Events.MemoryStreamBufferType.Large, Events.MemoryStreamDiscardReason.EnoughFree); - } - } - else - { - // This is a non-poolable buffer, but we still want to track its size for inuse - // analysis. We have space in the inuse array for this. - poolIndex = this.largeBufferInUseSize.Length - 1; - - ReportBufferDiscarded(id, tag, Events.MemoryStreamBufferType.Large, Events.MemoryStreamDiscardReason.TooLarge); - } - - Interlocked.Add(ref this.largeBufferInUseSize[poolIndex], -buffer.Length); - } - - /// - /// Returns the blocks to the pool. - /// - /// Collection of blocks to return to the pool. - /// Unique Stream ID. - /// The tag of the stream returning these blocks, for logging if necessary. - /// is null. - /// contains buffers that are the wrong size (or null) for this memory manager. - internal void ReturnBlocks(List blocks, Guid id, string tag) - { - if (blocks == null) - { - throw new ArgumentNullException(nameof(blocks)); - } - - long bytesToReturn = (long)blocks.Count * (long)this.BlockSize; - Interlocked.Add(ref this.smallPoolInUseSize, -bytesToReturn); - - foreach (var block in blocks) - { - if (block == null || block.Length != this.BlockSize) - { - throw new ArgumentException($"{nameof(blocks)} contains buffers that are not {nameof(BlockSize)} in length.", nameof(blocks)); - } - } - - foreach (var block in blocks) - { - if (this.MaximumFreeSmallPoolBytes == 0 || this.SmallPoolFreeSize < this.MaximumFreeSmallPoolBytes) - { - Interlocked.Add(ref this.smallPoolFreeSize, this.BlockSize); - this.smallPool.Push(block); - } - else - { - ReportBufferDiscarded(id, tag, Events.MemoryStreamBufferType.Small, Events.MemoryStreamDiscardReason.EnoughFree); - break; - } - } - } - - /// - /// Returns a block to the pool. - /// - /// Block to return to the pool. - /// Unique Stream ID. - /// The tag of the stream returning this, for logging if necessary. - /// is null. - /// is the wrong size for this memory manager. - internal void ReturnBlock(byte[] block, Guid id, string tag) - { - var bytesToReturn = this.BlockSize; - Interlocked.Add(ref this.smallPoolInUseSize, -bytesToReturn); - - if (block == null) - { - throw new ArgumentNullException(nameof(block)); - } - - if (block.Length != this.BlockSize) - { - throw new ArgumentException($"{nameof(block)} is not not {nameof(BlockSize)} in length."); - } - - if (this.MaximumFreeSmallPoolBytes == 0 || this.SmallPoolFreeSize < this.MaximumFreeSmallPoolBytes) - { - Interlocked.Add(ref this.smallPoolFreeSize, this.BlockSize); - this.smallPool.Push(block); - } - else - { - ReportBufferDiscarded(id, tag, Events.MemoryStreamBufferType.Small, Events.MemoryStreamDiscardReason.EnoughFree); - } - } - - internal void ReportBlockCreated() - { - Events.Writer.MemoryStreamNewBlockCreated(this.smallPoolInUseSize); - this.BlockCreated?.Invoke(this, new BlockCreatedEventArgs(this.smallPoolInUseSize)); - } - - internal void ReportLargeBufferCreated(Guid id, string tag, long requiredSize, bool pooled, string callStack) - { - if (pooled) - { - Events.Writer.MemoryStreamNewLargeBufferCreated(requiredSize, this.LargePoolInUseSize); - } - else - { - Events.Writer.MemoryStreamNonPooledLargeBufferCreated(id, tag, requiredSize, callStack); - } - this.LargeBufferCreated?.Invoke(this, new LargeBufferCreatedEventArgs(id, tag, requiredSize, this.LargePoolInUseSize, pooled, callStack)); - } - - internal void ReportBufferDiscarded(Guid id, string tag, Events.MemoryStreamBufferType bufferType, Events.MemoryStreamDiscardReason reason) - { - Events.Writer.MemoryStreamDiscardBuffer(id, tag, bufferType, reason, - this.SmallBlocksFree, this.smallPoolFreeSize, this.smallPoolInUseSize, - this.LargeBuffersFree, this.LargePoolFreeSize, this.LargePoolInUseSize); - this.BufferDiscarded?.Invoke(this, new BufferDiscardedEventArgs(id, tag, bufferType, reason)); - } - - internal void ReportStreamCreated(Guid id, string tag, long requestedSize, long actualSize) - { - Events.Writer.MemoryStreamCreated(id, tag, requestedSize, actualSize); - this.StreamCreated?.Invoke(this, new StreamCreatedEventArgs(id, tag, requestedSize, actualSize)); - } - - internal void ReportStreamDisposed(Guid id, string tag, TimeSpan lifetime, string allocationStack, string disposeStack) - { - Events.Writer.MemoryStreamDisposed(id, tag, (long)lifetime.TotalMilliseconds, allocationStack, disposeStack); - this.StreamDisposed?.Invoke(this, new StreamDisposedEventArgs(id, tag, lifetime, allocationStack, disposeStack)); - } - - internal void ReportStreamDoubleDisposed(Guid id, string tag, string allocationStack, string disposeStack1, string disposeStack2) - { - Events.Writer.MemoryStreamDoubleDispose(id, tag, allocationStack, disposeStack1, disposeStack2); - this.StreamDoubleDisposed?.Invoke(this, new StreamDoubleDisposedEventArgs(id, tag, allocationStack,disposeStack1, disposeStack2)); - } - - internal void ReportStreamFinalized(Guid id, string tag, string allocationStack) - { - Events.Writer.MemoryStreamFinalized(id, tag, allocationStack); - this.StreamFinalized?.Invoke(this, new StreamFinalizedEventArgs(id, tag, allocationStack)); - } - - internal void ReportStreamLength(long bytes) - { - this.StreamLength?.Invoke(this, new StreamLengthEventArgs(bytes)); - } - - internal void ReportStreamToArray(Guid id, string tag, string stack, long length) - { - Events.Writer.MemoryStreamToArray(id, tag, stack, length); - this.StreamConvertedToArray?.Invoke(this, new StreamConvertedToArrayEventArgs(id, tag, stack, length)); - } - - internal void ReportStreamOverCapacity(Guid id, string tag, long requestedCapacity, string allocationStack) - { - Events.Writer.MemoryStreamOverCapacity(id, tag, requestedCapacity, this.MaximumStreamCapacity, allocationStack); - this.StreamOverCapacity?.Invoke(this, new StreamOverCapacityEventArgs(id, tag, requestedCapacity, this.MaximumStreamCapacity, allocationStack)); - } - - internal void ReportUsageReport() - { - this.UsageReport?.Invoke(this, new UsageReportEventArgs(this.smallPoolInUseSize, this.smallPoolFreeSize, this.LargePoolInUseSize, this.LargePoolFreeSize)); - } - - /// - /// Retrieve a new MemoryStream object with no tag and a default initial capacity. - /// - /// A MemoryStream. - public MemoryStream GetStream() - { - return new RecyclableMemoryStream(this); - } - - /// - /// Retrieve a new MemoryStream object with no tag and a default initial capacity. - /// - /// A unique identifier which can be used to trace usages of the stream. - /// A MemoryStream. - public MemoryStream GetStream(Guid id) - { - return new RecyclableMemoryStream(this, id); - } - - /// - /// Retrieve a new MemoryStream object with the given tag and a default initial capacity. - /// - /// A tag which can be used to track the source of the stream. - /// A MemoryStream. - public MemoryStream GetStream(string tag) - { - return new RecyclableMemoryStream(this, tag); - } - - /// - /// Retrieve a new MemoryStream object with the given tag and a default initial capacity. - /// - /// A unique identifier which can be used to trace usages of the stream. - /// A tag which can be used to track the source of the stream. - /// A MemoryStream. - public MemoryStream GetStream(Guid id, string tag) - { - return new RecyclableMemoryStream(this, id, tag); - } - - /// - /// Retrieve a new MemoryStream object with the given tag and at least the given capacity. - /// - /// A tag which can be used to track the source of the stream. - /// The minimum desired capacity for the stream. - /// A MemoryStream. - public MemoryStream GetStream(string tag, int requiredSize) - { - return new RecyclableMemoryStream(this, tag, requiredSize); - } - - /// - /// Retrieve a new MemoryStream object with the given tag and at least the given capacity. - /// - /// A unique identifier which can be used to trace usages of the stream. - /// A tag which can be used to track the source of the stream. - /// The minimum desired capacity for the stream. - /// A MemoryStream. - public MemoryStream GetStream(Guid id, string tag, int requiredSize) - { - return new RecyclableMemoryStream(this, id, tag, requiredSize); - } - - /// - /// Retrieve a new MemoryStream object with the given tag and at least the given capacity. - /// - /// A unique identifier which can be used to trace usages of the stream. - /// A tag which can be used to track the source of the stream. - /// The minimum desired capacity for the stream. - /// A MemoryStream. - public MemoryStream GetStream(Guid id, string tag, long requiredSize) - { - return new RecyclableMemoryStream(this, id, tag, requiredSize); - } - - /// - /// Retrieve a new MemoryStream object with the given tag and at least the given capacity, possibly using - /// a single contiguous underlying buffer. - /// - /// Retrieving a MemoryStream which provides a single contiguous buffer can be useful in situations - /// where the initial size is known and it is desirable to avoid copying data between the smaller underlying - /// buffers to a single large one. This is most helpful when you know that you will always call - /// on the underlying stream. - /// A unique identifier which can be used to trace usages of the stream. - /// A tag which can be used to track the source of the stream. - /// The minimum desired capacity for the stream. - /// Whether to attempt to use a single contiguous buffer. - /// A MemoryStream. - public MemoryStream GetStream(Guid id, string tag, int requiredSize, bool asContiguousBuffer) - { - return this.GetStream(id, tag, (long)requiredSize, asContiguousBuffer); - } - - /// - /// Retrieve a new MemoryStream object with the given tag and at least the given capacity, possibly using - /// a single contiguous underlying buffer. - /// - /// Retrieving a MemoryStream which provides a single contiguous buffer can be useful in situations - /// where the initial size is known and it is desirable to avoid copying data between the smaller underlying - /// buffers to a single large one. This is most helpful when you know that you will always call - /// on the underlying stream. - /// A unique identifier which can be used to trace usages of the stream. - /// A tag which can be used to track the source of the stream. - /// The minimum desired capacity for the stream. - /// Whether to attempt to use a single contiguous buffer. - /// A MemoryStream. - public MemoryStream GetStream(Guid id, string tag, long requiredSize, bool asContiguousBuffer) - { - if (!asContiguousBuffer || requiredSize <= this.BlockSize) - { - return this.GetStream(id, tag, requiredSize); - } - - return new RecyclableMemoryStream(this, id, tag, requiredSize, this.GetLargeBuffer(requiredSize, id, tag)); - } - - /// - /// Retrieve a new MemoryStream object with the given tag and at least the given capacity, possibly using - /// a single contiguous underlying buffer. - /// - /// Retrieving a MemoryStream which provides a single contiguous buffer can be useful in situations - /// where the initial size is known and it is desirable to avoid copying data between the smaller underlying - /// buffers to a single large one. This is most helpful when you know that you will always call - /// on the underlying stream. - /// A tag which can be used to track the source of the stream. - /// The minimum desired capacity for the stream. - /// Whether to attempt to use a single contiguous buffer. - /// A MemoryStream. - public MemoryStream GetStream(string tag, int requiredSize, bool asContiguousBuffer) - { - return GetStream(tag, (long)requiredSize, asContiguousBuffer); - } - - /// - /// Retrieve a new MemoryStream object with the given tag and at least the given capacity, possibly using - /// a single contiguous underlying buffer. - /// - /// Retrieving a MemoryStream which provides a single contiguous buffer can be useful in situations - /// where the initial size is known and it is desirable to avoid copying data between the smaller underlying - /// buffers to a single large one. This is most helpful when you know that you will always call - /// on the underlying stream. - /// A tag which can be used to track the source of the stream. - /// The minimum desired capacity for the stream. - /// Whether to attempt to use a single contiguous buffer. - /// A MemoryStream. - public MemoryStream GetStream(string tag, long requiredSize, bool asContiguousBuffer) - { - return GetStream(Guid.NewGuid(), tag, requiredSize, asContiguousBuffer); - } - - /// - /// Retrieve a new MemoryStream object with the given tag and with contents copied from the provided - /// buffer. The provided buffer is not wrapped or used after construction. - /// - /// The new stream's position is set to the beginning of the stream when returned. - /// A unique identifier which can be used to trace usages of the stream. - /// A tag which can be used to track the source of the stream. - /// The byte buffer to copy data from. - /// The offset from the start of the buffer to copy from. - /// The number of bytes to copy from the buffer. - /// A MemoryStream. - public MemoryStream GetStream(Guid id, string tag, byte[] buffer, int offset, int count) - { - RecyclableMemoryStream stream = null; - try - { - stream = new RecyclableMemoryStream(this, id, tag, count); - stream.Write(buffer, offset, count); - stream.Position = 0; - return stream; - } - catch - { - stream?.Dispose(); - throw; - } - } - - /// - /// Retrieve a new MemoryStream object with the contents copied from the provided - /// buffer. The provided buffer is not wrapped or used after construction. - /// - /// The new stream's position is set to the beginning of the stream when returned. - /// The byte buffer to copy data from. - /// A MemoryStream. - public MemoryStream GetStream(byte[] buffer) - { - return GetStream(null, buffer, 0, buffer.Length); - } - - /// - /// Retrieve a new MemoryStream object with the given tag and with contents copied from the provided - /// buffer. The provided buffer is not wrapped or used after construction. - /// - /// The new stream's position is set to the beginning of the stream when returned. - /// A tag which can be used to track the source of the stream. - /// The byte buffer to copy data from. - /// The offset from the start of the buffer to copy from. - /// The number of bytes to copy from the buffer. - /// A MemoryStream. - public MemoryStream GetStream(string tag, byte[] buffer, int offset, int count) - { - return GetStream(Guid.NewGuid(), tag, buffer, offset, count); - } - - /// - /// Retrieve a new MemoryStream object with the given tag and with contents copied from the provided - /// buffer. The provided buffer is not wrapped or used after construction. - /// - /// The new stream's position is set to the beginning of the stream when returned. - /// A unique identifier which can be used to trace usages of the stream. - /// A tag which can be used to track the source of the stream. - /// The byte buffer to copy data from. - /// A MemoryStream. - [Obsolete("Use the ReadOnlySpan version of this method instead.")] - public MemoryStream GetStream(Guid id, string tag, Memory buffer) - { - RecyclableMemoryStream stream = null; - try - { - stream = new RecyclableMemoryStream(this, id, tag, buffer.Length); - stream.Write(buffer.Span); - stream.Position = 0; - return stream; - } - catch - { - stream?.Dispose(); - throw; - } - } - - /// - /// Retrieve a new MemoryStream object with the given tag and with contents copied from the provided - /// buffer. The provided buffer is not wrapped or used after construction. - /// - /// The new stream's position is set to the beginning of the stream when returned. - /// A unique identifier which can be used to trace usages of the stream. - /// A tag which can be used to track the source of the stream. - /// The byte buffer to copy data from. - /// A MemoryStream. - public MemoryStream GetStream(Guid id, string tag, ReadOnlySpan buffer) - { - RecyclableMemoryStream stream = null; - try - { - stream = new RecyclableMemoryStream(this, id, tag, buffer.Length); - stream.Write(buffer); - stream.Position = 0; - return stream; - } - catch - { - stream?.Dispose(); - throw; - } - } - - /// - /// Retrieve a new MemoryStream object with the contents copied from the provided - /// buffer. The provided buffer is not wrapped or used after construction. - /// - /// The new stream's position is set to the beginning of the stream when returned. - /// The byte buffer to copy data from. - /// A MemoryStream. - [Obsolete("Use the ReadOnlySpan version of this method instead.")] - public MemoryStream GetStream(Memory buffer) - { - return GetStream(null, buffer); - } - - /// - /// Retrieve a new MemoryStream object with the contents copied from the provided - /// buffer. The provided buffer is not wrapped or used after construction. - /// - /// The new stream's position is set to the beginning of the stream when returned. - /// The byte buffer to copy data from. - /// A MemoryStream. - public MemoryStream GetStream(ReadOnlySpan buffer) - { - return GetStream(null, buffer); - } - - /// - /// Retrieve a new MemoryStream object with the given tag and with contents copied from the provided - /// buffer. The provided buffer is not wrapped or used after construction. - /// - /// The new stream's position is set to the beginning of the stream when returned. - /// A tag which can be used to track the source of the stream. - /// The byte buffer to copy data from. - /// A MemoryStream. - [Obsolete("Use the ReadOnlySpan version of this method instead.")] - public MemoryStream GetStream(string tag, Memory buffer) - { - return GetStream(Guid.NewGuid(), tag, buffer); - } - - /// - /// Retrieve a new MemoryStream object with the given tag and with contents copied from the provided - /// buffer. The provided buffer is not wrapped or used after construction. - /// - /// The new stream's position is set to the beginning of the stream when returned. - /// A tag which can be used to track the source of the stream. - /// The byte buffer to copy data from. - /// A MemoryStream. - public MemoryStream GetStream(string tag, ReadOnlySpan buffer) - { - return GetStream(Guid.NewGuid(), tag, buffer); - } - - /// - /// Triggered when a new block is created. - /// - public event EventHandler BlockCreated; - - /// - /// Triggered when a new large buffer is created. - /// - public event EventHandler LargeBufferCreated; - - /// - /// Triggered when a new stream is created. - /// - public event EventHandler StreamCreated; - - /// - /// Triggered when a stream is disposed. - /// - public event EventHandler StreamDisposed; - - /// - /// Triggered when a stream is disposed of twice (an error). - /// - public event EventHandler StreamDoubleDisposed; - - /// - /// Triggered when a stream is finalized. - /// - public event EventHandler StreamFinalized; - - /// - /// Triggered when a stream is disposed to report the stream's length. - /// - public event EventHandler StreamLength; - - /// - /// Triggered when a user converts a stream to array. - /// - public event EventHandler StreamConvertedToArray; - - /// - /// Triggered when a stream is requested to expand beyond the maximum length specified by the responsible RecyclableMemoryStreamManager. - /// - public event EventHandler StreamOverCapacity; - - /// - /// Triggered when a buffer of either type is discarded, along with the reason for the discard. - /// - public event EventHandler BufferDiscarded; - - /// - /// Periodically triggered to report usage statistics. - /// - public event EventHandler UsageReport; - } -} diff --git a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/RecyclableMemoryStreamManager.cs.meta b/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/RecyclableMemoryStreamManager.cs.meta deleted file mode 100644 index 2b866afc..00000000 --- a/Assets/GameScripts/DotNet/Core/RecyclableMemoryStream/RecyclableMemoryStreamManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1e251d7371d835143ab1ba00fe110831 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/SingleCollection.meta b/Assets/GameScripts/DotNet/Core/SingleCollection.meta deleted file mode 100644 index aecbb89a..00000000 --- a/Assets/GameScripts/DotNet/Core/SingleCollection.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: e35142e7e2685824486acc859cda6f0d -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/SingleCollection/SingleCollection.cs b/Assets/GameScripts/DotNet/Core/SingleCollection/SingleCollection.cs deleted file mode 100644 index c159dacd..00000000 --- a/Assets/GameScripts/DotNet/Core/SingleCollection/SingleCollection.cs +++ /dev/null @@ -1,108 +0,0 @@ -#if TENGINE_NET -using TEngine.Core.DataBase; -using TEngine.DataStructure; -// ReSharper disable SuspiciousTypeConversion.Global - -namespace TEngine.Core; - -public class SingleCollection : Singleton -{ - private readonly OneToManyHashSet _collection = new OneToManyHashSet(); - private readonly OneToManyList _assemblyCollections = new OneToManyList(); - - private sealed class SingleCollectionInfo - { - public readonly Type RootType; - public readonly string CollectionName; - - public SingleCollectionInfo(Type rootType, string collectionName) - { - RootType = rootType; - CollectionName = collectionName; - } - } - - protected override void OnLoad(int assemblyName) - { - foreach (var type in AssemblyManager.ForEach(assemblyName, typeof(ISupportedSingleCollection))) - { - var customAttributes = type.GetCustomAttributes(typeof(SingleCollectionAttribute), false); - - if (customAttributes.Length == 0) - { - Log.Error($"type {type.FullName} Implemented the interface of ISingleCollection, requiring the implementation of SingleCollectionAttribute"); - continue; - } - - var singleCollectionAttribute = (SingleCollectionAttribute)customAttributes[0]; - var rootType = singleCollectionAttribute.RootType; - var collectionName = singleCollectionAttribute.CollectionName; - _collection.Add(rootType, collectionName); - _assemblyCollections.Add(assemblyName, new SingleCollectionInfo(rootType, collectionName)); - } - } - - protected override void OnUnLoad(int assemblyName) - { - if (!_assemblyCollections.TryGetValue(assemblyName, out var types)) - { - return; - } - - foreach (var singleCollectionInfo in types) - { - _collection.RemoveValue(singleCollectionInfo.RootType, singleCollectionInfo.CollectionName); - } - - _assemblyCollections.RemoveByKey(assemblyName); - } - - public async FTask GetCollections(Entity entity) - { - if (entity is not ISingleCollectionRoot) - { - return; - } - - if (!_collection.TryGetValue(entity.GetType(), out var collections)) - { - return; - } - - var scene = entity.Scene; - var worldDateBase = scene.World.DateBase; - - using (await IDateBase.DataBaseLock.Lock(entity.Id)) - { - foreach (var collectionName in collections) - { - var singleCollection = await worldDateBase.QueryNotLock(entity.Id, collectionName); - singleCollection.Deserialize(scene); - entity.AddComponent(singleCollection); - } - } - } - - public async FTask SaveCollections(Entity entity) - { - if (entity is not ISingleCollectionRoot) - { - return; - } - - using var collections = ListPool.Create(); - - foreach (var treeEntity in entity.ForEachSingleCollection) - { - if (treeEntity is not ISupportedSingleCollection) - { - continue; - } - - collections.Add(treeEntity); - } - - await entity.Scene.World.DateBase.Save(entity.Id, collections); - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/SingleCollection/SingleCollection.cs.meta b/Assets/GameScripts/DotNet/Core/SingleCollection/SingleCollection.cs.meta deleted file mode 100644 index f5d2d079..00000000 --- a/Assets/GameScripts/DotNet/Core/SingleCollection/SingleCollection.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 533ab9c301a66054cbcd8cc8ec8b1bc0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Singleton.meta b/Assets/GameScripts/DotNet/Core/Singleton.meta deleted file mode 100644 index 0382e085..00000000 --- a/Assets/GameScripts/DotNet/Core/Singleton.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 9ca744a370ba21f4aafc2a807adf97dd -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Singleton/Interface.meta b/Assets/GameScripts/DotNet/Core/Singleton/Interface.meta deleted file mode 100644 index a94cf9df..00000000 --- a/Assets/GameScripts/DotNet/Core/Singleton/Interface.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 12455eea4412a9e468f0a3a4cc929a78 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Singleton/Interface/ISingleton.cs b/Assets/GameScripts/DotNet/Core/Singleton/Interface/ISingleton.cs deleted file mode 100644 index 9c325092..00000000 --- a/Assets/GameScripts/DotNet/Core/Singleton/Interface/ISingleton.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Threading.Tasks; - -namespace TEngine.Core -{ - public interface ISingleton : IDisposable - { - public bool IsDisposed { get; set; } - public Task Initialize(); - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Singleton/Interface/ISingleton.cs.meta b/Assets/GameScripts/DotNet/Core/Singleton/Interface/ISingleton.cs.meta deleted file mode 100644 index f2eb804f..00000000 --- a/Assets/GameScripts/DotNet/Core/Singleton/Interface/ISingleton.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 74fd4adc991154043a4cb8a74e974c55 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Singleton/Interface/IUpdateSingleton.cs b/Assets/GameScripts/DotNet/Core/Singleton/Interface/IUpdateSingleton.cs deleted file mode 100644 index f483262f..00000000 --- a/Assets/GameScripts/DotNet/Core/Singleton/Interface/IUpdateSingleton.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace TEngine.Core -{ - public interface IUpdateSingleton : ISingleton - { - public abstract void Update(); - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Singleton/Interface/IUpdateSingleton.cs.meta b/Assets/GameScripts/DotNet/Core/Singleton/Interface/IUpdateSingleton.cs.meta deleted file mode 100644 index 01e7e243..00000000 --- a/Assets/GameScripts/DotNet/Core/Singleton/Interface/IUpdateSingleton.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1cacc43db095ef646b8e9894d0da431b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Singleton/Singleton.cs b/Assets/GameScripts/DotNet/Core/Singleton/Singleton.cs deleted file mode 100644 index b8439c6c..00000000 --- a/Assets/GameScripts/DotNet/Core/Singleton/Singleton.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System.Threading.Tasks; -#pragma warning disable CS8601 -#pragma warning disable CS8618 - -namespace TEngine.Core -{ - public abstract class Singleton : ISingleton where T : ISingleton, new() - { - public bool IsDisposed { get; set; } - - public static T Instance { get; private set; } - - private void RegisterSingleton(ISingleton singleton) - { - Instance = (T) singleton; - AssemblyManager.OnLoadAssemblyEvent += OnLoad; - AssemblyManager.OnUnLoadAssemblyEvent += OnUnLoad; - } - - /// - /// 特殊情况调用设置。 - /// - public static T TempInstance - { - get - { - return Instance; - } - set - { - if (Instance != null) - { - return; - } - - Instance = value; - } - } - - public virtual Task Initialize() - { - return Task.CompletedTask; - } - - protected virtual void OnLoad(int assemblyName) { } - - protected virtual void OnUnLoad(int assemblyName) { } - - public virtual void Dispose() - { - IsDisposed = true; - Instance = default; - AssemblyManager.OnLoadAssemblyEvent -= OnLoad; - AssemblyManager.OnUnLoadAssemblyEvent -= OnUnLoad; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Singleton/Singleton.cs.meta b/Assets/GameScripts/DotNet/Core/Singleton/Singleton.cs.meta deleted file mode 100644 index 377761db..00000000 --- a/Assets/GameScripts/DotNet/Core/Singleton/Singleton.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0b54004d9250cf744a5b58a655d7f4d5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Singleton/SingletonSystem.cs b/Assets/GameScripts/DotNet/Core/Singleton/SingletonSystem.cs deleted file mode 100644 index c95a21b8..00000000 --- a/Assets/GameScripts/DotNet/Core/Singleton/SingletonSystem.cs +++ /dev/null @@ -1,142 +0,0 @@ -// ReSharper disable StaticMemberInGenericType - -using System; -using System.Collections.Generic; -using System.Reflection; -#if UNITY_WEBGL -using Cysharp.Threading.Tasks; -#else -using System.Threading.Tasks; -#endif -using TEngine.DataStructure; -#pragma warning disable CS8601 -#pragma warning disable CS8604 -#pragma warning disable CS8600 - -namespace TEngine.Core -{ - public static class SingletonSystem - { - private static readonly Queue Updates = new Queue(); - private static readonly OneToManyQueue Singletons = new OneToManyQueue(); - - public static void Initialize() - { - AssemblyManager.OnLoadAssemblyEvent += Load; - AssemblyManager.OnUnLoadAssemblyEvent += UnLoad; - } - - private static void Load(int assemblyName) - { - var count = 0; -#if !UNITY_WEBGL - var task = new List(); -#endif - UnLoad(assemblyName); - foreach (var singletonType in AssemblyManager.ForEach(assemblyName, typeof(ISingleton))) - { - var instance = (ISingleton) Activator.CreateInstance(singletonType); - var registerMethodInfo = singletonType.BaseType?.GetMethod("RegisterSingleton", BindingFlags.Instance | BindingFlags.NonPublic); - var initializeMethodInfo = singletonType.GetMethod("Initialize", BindingFlags.Instance | BindingFlags.Public); - var onLoadMethodInfo = singletonType.GetMethod("OnLoad", BindingFlags.Instance | BindingFlags.NonPublic); - - if (initializeMethodInfo != null) - { -#if !UNITY_WEBGL - task.Add((Task) initializeMethodInfo.Invoke(instance, null)); -#else - initializeMethodInfo.Invoke(instance, null); -#endif - } - - registerMethodInfo?.Invoke(instance, new object[] {instance}); - onLoadMethodInfo?.Invoke(instance, new object[] {assemblyName}); - - count++; - - switch (instance) - { - case IUpdateSingleton iUpdateSingleton: - { - Updates.Enqueue(iUpdateSingleton); - break; - } - } - - Singletons.Enqueue(assemblyName, instance); - } - -#if !UNITY_WEBGL - Task.WaitAll(task.ToArray()); -#endif - Log.Info($"assembly:{assemblyName} load Singleton count:{count}"); - } - - private static void UnLoad(Queue singletons) - { - while (singletons.Count > 0) - { - try - { - singletons.Dequeue().Dispose(); - } - catch (Exception e) - { - Log.Error(e); - } - } - } - - private static void UnLoad(int assemblyName) - { - if (!Singletons.TryGetValue(assemblyName, out var singletons)) - { - return; - } - - var count = singletons.Count; - UnLoad(singletons); - Singletons.RemoveKey(assemblyName); - // Log.Info($"assembly:{assemblyName} Unload Singleton count:{count}"); - } - - public static void Update() - { - var updatesCount = Updates.Count; - - while (updatesCount-- > 0) - { - var updateSingleton = Updates.Dequeue(); - - if (updateSingleton.IsDisposed) - { - continue; - } - - Updates.Enqueue(updateSingleton); - - try - { - updateSingleton.Update(); - } - catch (Exception e) - { - Log.Error(e); - } - } - } - - public static void Dispose() - { - foreach (var (_, singletons) in Singletons) - { - UnLoad(singletons); - } - - Updates.Clear(); - Singletons.Clear(); - AssemblyManager.OnLoadAssemblyEvent -= Load; - AssemblyManager.OnUnLoadAssemblyEvent -= UnLoad; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Singleton/SingletonSystem.cs.meta b/Assets/GameScripts/DotNet/Core/Singleton/SingletonSystem.cs.meta deleted file mode 100644 index 17dc8955..00000000 --- a/Assets/GameScripts/DotNet/Core/Singleton/SingletonSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 31f7155596debed429793d1d408935d7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/SynchronizationContext.meta b/Assets/GameScripts/DotNet/Core/SynchronizationContext.meta deleted file mode 100644 index 30321b93..00000000 --- a/Assets/GameScripts/DotNet/Core/SynchronizationContext.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 8ca2dbcc3024e6345808b8f3c07b3630 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/SynchronizationContext/ThreadSynchronizationContext.cs b/Assets/GameScripts/DotNet/Core/SynchronizationContext/ThreadSynchronizationContext.cs deleted file mode 100644 index daee88b6..00000000 --- a/Assets/GameScripts/DotNet/Core/SynchronizationContext/ThreadSynchronizationContext.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Threading; -using TEngine.Core.Network; -#pragma warning disable CS8765 -#pragma warning disable CS8601 -#pragma warning disable CS8618 - -namespace TEngine -{ - public sealed class ThreadSynchronizationContext : SynchronizationContext - { - public readonly int ThreadId; - private Action _actionHandler; - private readonly ConcurrentQueue _queue = new(); - public static ThreadSynchronizationContext Main { get; } = new(Environment.CurrentManagedThreadId); - - public ThreadSynchronizationContext(int threadId) - { - ThreadId = threadId; - } - - public void Update() - { - while (_queue.TryDequeue(out _actionHandler)) - { - try - { - _actionHandler(); - } - catch (Exception e) - { - Log.Error(e); - } - } - } - - public override void Post(SendOrPostCallback callback, object state) - { - Post(() => callback(state)); - } - - public void Post(Action action) - { - _queue.Enqueue(action); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/SynchronizationContext/ThreadSynchronizationContext.cs.meta b/Assets/GameScripts/DotNet/Core/SynchronizationContext/ThreadSynchronizationContext.cs.meta deleted file mode 100644 index ec80feb3..00000000 --- a/Assets/GameScripts/DotNet/Core/SynchronizationContext/ThreadSynchronizationContext.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: cdf9a97b5cd42dd498c020b421ee8b23 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/TEngineSettingsHelper.cs b/Assets/GameScripts/DotNet/Core/TEngineSettingsHelper.cs deleted file mode 100644 index 01b8dfcc..00000000 --- a/Assets/GameScripts/DotNet/Core/TEngineSettingsHelper.cs +++ /dev/null @@ -1,78 +0,0 @@ -#if TENGINE_NET -using Microsoft.Extensions.Configuration; -#pragma warning disable CS8604 -#pragma warning disable CS8601 -#pragma warning disable CS8618 - -namespace TEngine.Core; - -public static class TEngineSettingsHelper -{ - public static void Initialize() - { - const string settingsName = "TEngineSettings.json"; - var currentDirectory = Directory.GetCurrentDirectory(); - - if (!File.Exists(Path.Combine(currentDirectory, settingsName))) - { - throw new FileNotFoundException($"not found {settingsName} in OutputDirectory"); - } - - var configurationRoot = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile(settingsName).Build(); - // 加载网络配置 - LoadNetworkConfig(configurationRoot); - // 加载ProtoBuf配置 - LoadProtoConfig(configurationRoot); - // 加载Excel配置 - LoadExcelConfig(configurationRoot); - } - - private static void LoadNetworkConfig(IConfigurationRoot root) - { - Define.SessionIdleCheckerInterval = Convert.ToInt32(root["Network:SessionIdleCheckerInterval:Value"]); - Define.SessionIdleCheckerTimeout = Convert.ToInt32(root["Network:SessionIdleCheckerTimeout:Value"]); - } - - private static void LoadProtoConfig(IConfigurationRoot root) - { - // ProtoBuf文件所在的位置文件夹位置 - Define.ProtoBufDirectory = FileHelper.GetFullPath(root["Export:ProtoBufDirectory:Value"]); - // ProtoBuf生成到服务端的文件夹位置 - Define.ProtoBufServerDirectory = FileHelper.GetFullPath(root["Export:ProtoBufServerDirectory:Value"]); - // ProtoBuf生成到客户端的文件夹位置 - Define.ProtoBufClientDirectory = FileHelper.GetFullPath(root["Export:ProtoBufClientDirectory:Value"]); - // ProtoBuf生成代码模板的位置 - Define.ProtoBufTemplatePath = FileHelper.GetFullPath(root["Export:ProtoBufTemplatePath:Value"]); - } - - private static void LoadExcelConfig(IConfigurationRoot root) - { - // Excel配置文件根目录 - Define.ExcelProgramPath = FileHelper.GetFullPath(root["Export:ExcelProgramPath:Value"]); - // Excel版本文件的位置 - Define.ExcelVersionFile = FileHelper.GetFullPath(root["Export:ExcelVersionFile:Value"]); - // Excel生成服务器代码的文件夹位置 - Define.ExcelServerFileDirectory = FileHelper.GetFullPath(root["Export:ExcelServerFileDirectory:Value"]); - // Excel生成客户端代码文件夹位置 - Define.ExcelClientFileDirectory = FileHelper.GetFullPath(root["Export:ExcelClientFileDirectory:Value"]); - // Excel生成服务器二进制数据文件夹位置 - Define.ExcelServerBinaryDirectory = FileHelper.GetFullPath(root["Export:ExcelServerBinaryDirectory:Value"]); - // Excel生成客户端二进制数据文件夹位置 - Define.ExcelClientBinaryDirectory = FileHelper.GetFullPath(root["Export:ExcelClientBinaryDirectory:Value"]); - // Excel生成服务器Json数据文件夹位置 - Define.ExcelServerJsonDirectory = FileHelper.GetFullPath(root["Export:ExcelServerJsonDirectory:Value"]); - // Excel生成客户端Json数据文件夹位置 - Define.ExcelClientJsonDirectory = FileHelper.GetFullPath(root["Export:ExcelClientJsonDirectory:Value"]); - // Excel生成代码模板的位置 - Define.ExcelTemplatePath = FileHelper.GetFullPath(root["Export:ExcelTemplatePath:Value"]); - // 服务器自定义导出代码文件夹位置 - Define.ServerCustomExportDirectory = FileHelper.GetFullPath(root["Export:ServerCustomExportDirectory:Value"]); - // 客户端自定义导出代码 - Define.ClientCustomExportDirectory = FileHelper.GetFullPath(root["Export:ClientCustomExportDirectory:Value"]); - // SceneConfig.xlsx的位置 - Define.SceneConfigPath = FileHelper.GetFullPath(root["Export:SceneConfigPath:Value"]); - // 自定义导出代码存放的程序集 - Define.CustomExportAssembly = FileHelper.GetFullPath(root["Export:CustomExportAssembly:Value"]); - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/TEngineSettingsHelper.cs.meta b/Assets/GameScripts/DotNet/Core/TEngineSettingsHelper.cs.meta deleted file mode 100644 index b25e9c01..00000000 --- a/Assets/GameScripts/DotNet/Core/TEngineSettingsHelper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4070f130fd645b9459fe147291285436 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Task.meta b/Assets/GameScripts/DotNet/Core/Task.meta deleted file mode 100644 index ca914f7d..00000000 --- a/Assets/GameScripts/DotNet/Core/Task.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7be5b356ee4841f4dbfce44b09b08e83 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Task/Builder.meta b/Assets/GameScripts/DotNet/Core/Task/Builder.meta deleted file mode 100644 index d333df8b..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/Builder.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 00f992eda26fe684e8b9d529843d2a25 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFTaskCompletedMethodBuilder.cs b/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFTaskCompletedMethodBuilder.cs deleted file mode 100644 index da4cabf9..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFTaskCompletedMethodBuilder.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Runtime.ExceptionServices; -using System.Runtime.InteropServices; -using System.Security; - -namespace TEngine -{ - [StructLayout(LayoutKind.Auto)] - public struct AsyncFTaskCompletedMethodBuilder - { - // 1. Static Create method. - [DebuggerHidden] - public static AsyncFTaskCompletedMethodBuilder Create() - { - return new AsyncFTaskCompletedMethodBuilder(); - } - - // 2. TaskLike Task property(void) - public FTaskCompleted Task => default; - - // 3. SetException - [DebuggerHidden] - public void SetException(Exception exception) - { - Log.Error(exception); - // ExceptionDispatchInfo.Capture(exception).Throw(); - } - - // 4. SetResult - [DebuggerHidden] - public void SetResult() - { - } - - // 5. AwaitOnCompleted - [DebuggerHidden] - public void AwaitOnCompleted(ref TAwaiter awaiter, ref TStateMachine stateMachine) - where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine - { - awaiter.OnCompleted(stateMachine.MoveNext); - } - - // 6. AwaitUnsafeOnCompleted - [DebuggerHidden] - [SecuritySafeCritical] - public void AwaitUnsafeOnCompleted(ref TAwaiter awaiter, - ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion - where TStateMachine : IAsyncStateMachine - { - awaiter.UnsafeOnCompleted(stateMachine.MoveNext); - } - - // 7. Start - [DebuggerHidden] - public void Start(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine - { - stateMachine.MoveNext(); - } - - // 8. SetStateMachine - [DebuggerHidden] - public void SetStateMachine(IAsyncStateMachine stateMachine) - { - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFTaskCompletedMethodBuilder.cs.meta b/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFTaskCompletedMethodBuilder.cs.meta deleted file mode 100644 index 839283f6..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFTaskCompletedMethodBuilder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d9e4e2f1fe1bb0d42be6152751f563ff -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFTaskMethodBuilder.cs b/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFTaskMethodBuilder.cs deleted file mode 100644 index 2be542c4..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFTaskMethodBuilder.cs +++ /dev/null @@ -1,151 +0,0 @@ -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace TEngine -{ - [StructLayout(LayoutKind.Auto)] - public readonly struct AsyncFTaskMethodBuilder - { - // 1. Static Create method. - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static AsyncFTaskMethodBuilder Create() - { - return new AsyncFTaskMethodBuilder(FTask.Create()); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private AsyncFTaskMethodBuilder(FTask fTask) - { - Task = fTask; - } - - // 4. Return to task - public FTask Task - { - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get; - } - - // 2. Start - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Start(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine - { - stateMachine.MoveNext(); - } - - // 3. SetResult - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void SetResult() - { - Task.SetResult(); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void SetException(Exception exception) - { - Task.SetException(exception); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AwaitOnCompleted(ref TAwaiter awaiter, ref TStateMachine stateMachine) - where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine - { - awaiter.OnCompleted(stateMachine.MoveNext); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AwaitUnsafeOnCompleted(ref TAwaiter awaiter, - ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion - where TStateMachine : IAsyncStateMachine - { - awaiter.UnsafeOnCompleted(stateMachine.MoveNext); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void SetStateMachine(IAsyncStateMachine stateMachine) - { - } - } - - [StructLayout(LayoutKind.Auto)] - public readonly struct AsyncFTaskMethodBuilder - { - // 1. Static Create method. - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static AsyncFTaskMethodBuilder Create() - { - return new AsyncFTaskMethodBuilder(FTask.Create()); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private AsyncFTaskMethodBuilder(FTask fTask) - { - Task = fTask; - } - - // 4. Return to task - public FTask Task - { - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get; - } - - // 2. Start - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Start(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine - { - stateMachine.MoveNext(); - } - - // 3. SetResult - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void SetResult(T value) - { - Task.SetResult(value); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void SetException(Exception exception) - { - Task.SetException(exception); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AwaitOnCompleted(ref TAwaiter awaiter, ref TStateMachine stateMachine) - where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine - { - awaiter.OnCompleted(stateMachine.MoveNext); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AwaitUnsafeOnCompleted(ref TAwaiter awaiter, - ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion - where TStateMachine : IAsyncStateMachine - { - awaiter.UnsafeOnCompleted(stateMachine.MoveNext); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void SetStateMachine(IAsyncStateMachine stateMachine) - { - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFTaskMethodBuilder.cs.meta b/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFTaskMethodBuilder.cs.meta deleted file mode 100644 index d76038f5..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFTaskMethodBuilder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b8973ac6e4512594b9787095beaa62c6 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFVoidMethodBuilder.cs b/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFVoidMethodBuilder.cs deleted file mode 100644 index 9e1527c4..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFVoidMethodBuilder.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Runtime.ExceptionServices; -using System.Runtime.InteropServices; - -namespace TEngine -{ - [StructLayout(LayoutKind.Auto)] - internal struct AsyncFVoidMethodBuilder - { - // 1. Static Create method. - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static AsyncFVoidMethodBuilder Create() - { - return default; - } - - // 2. Start - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Start(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine - { - stateMachine.MoveNext(); - } - - // 3. SetResult - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void SetResult() - { - } - - // 4. Return to task - public FVoid Task - { - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => default; - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void SetException(Exception exception) - { - ExceptionDispatchInfo.Capture(exception).Throw(); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AwaitOnCompleted(ref TAwaiter awaiter, ref TStateMachine stateMachine) - where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine - { - awaiter.OnCompleted(stateMachine.MoveNext); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void AwaitUnsafeOnCompleted(ref TAwaiter awaiter, - ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion - where TStateMachine : IAsyncStateMachine - { - awaiter.UnsafeOnCompleted(stateMachine.MoveNext); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void SetStateMachine(IAsyncStateMachine stateMachine) - { - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFVoidMethodBuilder.cs.meta b/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFVoidMethodBuilder.cs.meta deleted file mode 100644 index d49c5703..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/Builder/AsyncFVoidMethodBuilder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 97a3c8247dd2a854485df3f751feb710 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Task/FCancellationToken.cs b/Assets/GameScripts/DotNet/Core/Task/FCancellationToken.cs deleted file mode 100644 index 2b4ca722..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/FCancellationToken.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using System.Collections.Generic; - -#pragma warning disable CS8625 -namespace TEngine -{ - public sealed class FCancellationToken - { - private HashSet _actions = new HashSet(); - public bool IsCancel => _actions == null; - - public void Add(Action action) - { - _actions.Add(action); - } - - public void Remove(Action action) - { - _actions.Remove(action); - } - - public void Cancel() - { - if (_actions == null) - { - return; - } - - var runActions = _actions; - _actions = null; - - foreach (var action in runActions) - { - try - { - action.Invoke(); - } - catch (Exception e) - { - Log.Error(e); - } - } - } - } -} - diff --git a/Assets/GameScripts/DotNet/Core/Task/FCancellationToken.cs.meta b/Assets/GameScripts/DotNet/Core/Task/FCancellationToken.cs.meta deleted file mode 100644 index cae41dc1..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/FCancellationToken.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 619ea7efe37fc984ea5b11c2e3400e9b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Task/FTask.cs b/Assets/GameScripts/DotNet/Core/Task/FTask.cs deleted file mode 100644 index d11674f4..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/FTask.cs +++ /dev/null @@ -1,299 +0,0 @@ -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Runtime.ExceptionServices; -#pragma warning disable CS8601 -#pragma warning disable CS8603 -#pragma warning disable CS8625 -#pragma warning disable CS8618 - -namespace TEngine -{ - public enum STaskStatus : byte - { - /// The operation has not yet completed. - Pending = 0, - - /// The operation completed successfully. - Succeeded = 1, - - /// The operation completed with an error. - Faulted = 2 - } - - [AsyncMethodBuilder(typeof(AsyncFTaskMethodBuilder))] - public sealed partial class FTask : ICriticalNotifyCompletion - { - private Action _callBack; - private ExceptionDispatchInfo _exception; - private bool _isFromPool; - private STaskStatus _status; - - public bool IsCompleted - { - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => _status != STaskStatus.Pending; - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FTask GetAwaiter() - { - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [DebuggerHidden] - private async FVoid InnerCoroutine() - { - await this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [DebuggerHidden] - public void Coroutine() - { - InnerCoroutine().Coroutine(); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void GetResult() - { - switch (_status) - { - case STaskStatus.Succeeded: - { - Recycle(); - break; - } - case STaskStatus.Faulted: - { - Recycle(); - - if (_exception != null) - { - var exception = _exception; - _exception = null; - exception.Throw(); - } - - break; - } - default: - throw new NotSupportedException("Direct call to getResult is not allowed"); - } - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void Recycle() - { - if (!_isFromPool) - { - return; - } - - _status = STaskStatus.Pending; - _callBack = null; - Pool.Return(this); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void SetResult() - { - if (_status != STaskStatus.Pending) - { - throw new InvalidOperationException("The task has been completed"); - } - - _status = STaskStatus.Succeeded; - - if (_callBack == null) - { - return; - } - - var callBack = _callBack; - _callBack = null; - callBack.Invoke(); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void UnsafeOnCompleted(Action continuation) - { - if (_status != STaskStatus.Pending) - { - continuation?.Invoke(); - return; - } - - _callBack = continuation; - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void SetException(Exception exception) - { - if (_status != STaskStatus.Pending) - { - throw new InvalidOperationException("The task has been completed"); - } - - _status = STaskStatus.Faulted; - _exception = ExceptionDispatchInfo.Capture(exception); - _callBack?.Invoke(); - } - } - - [AsyncMethodBuilder(typeof(AsyncFTaskMethodBuilder<>))] - public sealed partial class FTask : ICriticalNotifyCompletion - { - private Action _callBack; - private ExceptionDispatchInfo _exception; - private bool _isFromPool; - private STaskStatus _status; - private T _value; - - public bool IsCompleted - { - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - get => _status != STaskStatus.Pending; - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void OnCompleted(Action continuation) - { - UnsafeOnCompleted(continuation); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public FTask GetAwaiter() - { - return this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [DebuggerHidden] - private async FVoid InnerCoroutine() - { - await this; - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - [DebuggerHidden] - public void Coroutine() - { - InnerCoroutine().Coroutine(); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public T GetResult() - { - switch (_status) - { - case STaskStatus.Succeeded: - { - var value = _value; - Recycle(); - return value; - } - case STaskStatus.Faulted: - { - Recycle(); - - if (_exception == null) - { - return default; - } - - var exception = _exception; - _exception = null; - exception.Throw(); - return default; - } - default: - throw new NotSupportedException("Direct call to getResult is not allowed"); - } - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void Recycle() - { - if (!_isFromPool) - { - return; - } - - _status = STaskStatus.Pending; - _callBack = null; - _value = default; - Pool>.Return(this); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void SetResult(T value) - { - if (_status != STaskStatus.Pending) - { - throw new InvalidOperationException("The task has been completed"); - } - - _value = value; - _status = STaskStatus.Succeeded; - - if (_callBack == null) - { - return; - } - - var callBack = _callBack; - _callBack = null; - callBack.Invoke(); - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void UnsafeOnCompleted(Action continuation) - { - if (_status != STaskStatus.Pending) - { - continuation?.Invoke(); - return; - } - - _callBack = continuation; - } - - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void SetException(Exception exception) - { - if (_status != STaskStatus.Pending) - { - throw new InvalidOperationException("The task has been completed"); - } - - _status = STaskStatus.Faulted; - _exception = ExceptionDispatchInfo.Capture(exception); - _callBack?.Invoke(); - } - } -} - diff --git a/Assets/GameScripts/DotNet/Core/Task/FTask.cs.meta b/Assets/GameScripts/DotNet/Core/Task/FTask.cs.meta deleted file mode 100644 index eea61879..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/FTask.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a4bfba30d0ddf4d4fb0da92631ce965b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Task/FTaskCompleted.cs b/Assets/GameScripts/DotNet/Core/Task/FTaskCompleted.cs deleted file mode 100644 index 43c26f26..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/FTaskCompleted.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace TEngine -{ - [AsyncMethodBuilder(typeof(AsyncFTaskCompletedMethodBuilder))] - [StructLayout(LayoutKind.Auto)] - public struct FTaskCompleted : INotifyCompletion - { - [DebuggerHidden] - public FTaskCompleted GetAwaiter() - { - return this; - } - - [DebuggerHidden] public bool IsCompleted => true; - - [DebuggerHidden] - public void GetResult() - { - } - - [DebuggerHidden] - public void OnCompleted(Action continuation) - { - } - - [DebuggerHidden] - public void UnsafeOnCompleted(Action continuation) - { - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Task/FTaskCompleted.cs.meta b/Assets/GameScripts/DotNet/Core/Task/FTaskCompleted.cs.meta deleted file mode 100644 index 2010bf6e..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/FTaskCompleted.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 5bebfd7b883cd6b41892cf411a3532fd -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Task/FVoid.cs b/Assets/GameScripts/DotNet/Core/Task/FVoid.cs deleted file mode 100644 index e1243196..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/FVoid.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace TEngine -{ - [AsyncMethodBuilder(typeof(AsyncFVoidMethodBuilder))] - [StructLayout(LayoutKind.Auto)] - internal struct FVoid : ICriticalNotifyCompletion - { - [DebuggerHidden] - public void Coroutine() - { - - } - - [DebuggerHidden] - public void OnCompleted(Action continuation) - { - - } - - [DebuggerHidden] - public void UnsafeOnCompleted(Action continuation) - { - - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Task/FVoid.cs.meta b/Assets/GameScripts/DotNet/Core/Task/FVoid.cs.meta deleted file mode 100644 index 2c704b69..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/FVoid.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c43e35df403ff9a468b6805bd64181f7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Task/Partial.meta b/Assets/GameScripts/DotNet/Core/Task/Partial.meta deleted file mode 100644 index f02cda2c..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/Partial.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 2cc519fac78a9574594b7ee2811a1c68 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.Factory.cs b/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.Factory.cs deleted file mode 100644 index 0732e6d1..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.Factory.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; - -namespace TEngine -{ - public partial class FTask - { - public static FTaskCompleted CompletedTask => new(); - - public static FTask Run(Func factory) - { - return factory(); - } - - public static FTask Run(Func> factory) - { - return factory(); - } - - public static FTask FromResult(T value) - { - var sAwaiter = FTask.Create(); - sAwaiter.SetResult(value); - return sAwaiter; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.Factory.cs.meta b/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.Factory.cs.meta deleted file mode 100644 index cabd9082..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.Factory.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ac04f3959fd37ad48b2bb6bb7ddb4d46 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.Pool.cs b/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.Pool.cs deleted file mode 100644 index 3bafd6a5..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.Pool.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Diagnostics; -using System.Runtime.CompilerServices; - -namespace TEngine -{ - public partial class FTask - { - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FTask Create(bool isFromPool = true) - { - var task = isFromPool ? Pool.Rent() : new FTask(); - task._isFromPool = isFromPool; - return task; - } - } - - public partial class FTask - { - [DebuggerHidden] - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static FTask Create(bool isFromPool = true) - { - var task = isFromPool ? Pool>.Rent() : new FTask(); - task._isFromPool = isFromPool; - return task; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.Pool.cs.meta b/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.Pool.cs.meta deleted file mode 100644 index fd58eb21..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.Pool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: dfe1e7044d17abb41a98dd6e2ad51896 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.WhenAll.cs b/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.WhenAll.cs deleted file mode 100644 index de23bd83..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.WhenAll.cs +++ /dev/null @@ -1,157 +0,0 @@ -using System.Collections.Generic; - -namespace TEngine -{ - public partial class FTask - { - public static async FTask WhenAll(List tasks) - { - if (tasks.Count <= 0) - { - return; - } - - var count = tasks.Count; - var sTaskCompletionSource = Create(); - - foreach (var task in tasks) - { - RunSTask(sTaskCompletionSource, task).Coroutine(); - } - - await sTaskCompletionSource; - - async FVoid RunSTask(FTask tcs, FTask task) - { - await task; - count--; - - if (count <= 0) - { - tcs.SetResult(); - } - } - } - - public static async FTask Any(params FTask[] tasks) - { - if (tasks == null || tasks.Length <= 0) - { - return; - } - - var tcs = FTask.Create(); - - int count = 1; - - foreach (FTask task in tasks) - { - RunSTask(task).Coroutine(); - } - - await tcs; - - async FVoid RunSTask(FTask task) - { - await task; - - count--; - - if (count == 0) - { - tcs.SetResult(); - } - } - } - } - - public partial class FTask - { - public static async FTask WhenAll(List> tasks) - { - if (tasks.Count <= 0) - { - return; - } - - var count = tasks.Count; - var sTaskCompletionSource = FTask.Create(); - - foreach (var task in tasks) - { - RunSTask(sTaskCompletionSource, task).Coroutine(); - } - - await sTaskCompletionSource; - - async FVoid RunSTask(FTask tcs, FTask task) - { - await task; - count--; - if (count == 0) - { - tcs.SetResult(); - } - } - } - - public static async FTask WhenAll(params FTask[] tasks) - { - if (tasks == null || tasks.Length <= 0) - { - return; - } - - var count = tasks.Length; - var tcs = FTask.Create(); - - foreach (var task in tasks) - { - RunSTask(task).Coroutine(); - } - - await tcs; - - async FVoid RunSTask(FTask task) - { - await task; - count--; - if (count == 0) - { - tcs.SetResult(); - } - } - } - - public static async FTask WaitAny(params FTask[] tasks) - { - if (tasks == null || tasks.Length <= 0) - { - return; - } - - var tcs = FTask.Create(); - - int count = 1; - - foreach (FTask task in tasks) - { - RunSTask(task).Coroutine(); - } - - await tcs; - - async FVoid RunSTask(FTask task) - { - await task; - - count--; - - if (count == 0) - { - tcs.SetResult(); - } - } - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.WhenAll.cs.meta b/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.WhenAll.cs.meta deleted file mode 100644 index 22cbc049..00000000 --- a/Assets/GameScripts/DotNet/Core/Task/Partial/FTask.WhenAll.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ef20b979a90164a45ad1e3ee2e5b1b09 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/TimerScheduler.meta b/Assets/GameScripts/DotNet/Core/TimerScheduler.meta deleted file mode 100644 index ffc15c33..00000000 --- a/Assets/GameScripts/DotNet/Core/TimerScheduler.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 391584e0a2fa16849bec5654b30a8cdf -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/TimerScheduler/Interface.meta b/Assets/GameScripts/DotNet/Core/TimerScheduler/Interface.meta deleted file mode 100644 index c0063ec7..00000000 --- a/Assets/GameScripts/DotNet/Core/TimerScheduler/Interface.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 18fd7fd9904bb6a448e89c953dbfa432 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/TimerScheduler/Interface/TimerHandler.cs b/Assets/GameScripts/DotNet/Core/TimerScheduler/Interface/TimerHandler.cs deleted file mode 100644 index ac9fb217..00000000 --- a/Assets/GameScripts/DotNet/Core/TimerScheduler/Interface/TimerHandler.cs +++ /dev/null @@ -1,4 +0,0 @@ -namespace TEngine -{ - public abstract class TimerHandler : EventSystem { } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/TimerScheduler/Interface/TimerHandler.cs.meta b/Assets/GameScripts/DotNet/Core/TimerScheduler/Interface/TimerHandler.cs.meta deleted file mode 100644 index e2a9af3b..00000000 --- a/Assets/GameScripts/DotNet/Core/TimerScheduler/Interface/TimerHandler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b512d458640f63d43983b335c0c71f12 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerAction.cs b/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerAction.cs deleted file mode 100644 index 8de42860..00000000 --- a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerAction.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using TEngine.Core; -#pragma warning disable CS8625 -#pragma warning disable CS8618 - -namespace TEngine -{ - public sealed class TimerAction : IDisposable - { - public long Id; - public long Time; - public object Callback; - public TimerType TimerType; - - public static TimerAction Create() - { - var timerAction = Pool.Rent(); - timerAction.Id = IdFactory.NextRunTimeId(); - return timerAction; - } - - public void Dispose() - { - Id = 0; - Time = 0; - Callback = null; - TimerType = TimerType.None; - Pool.Return(this); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerAction.cs.meta b/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerAction.cs.meta deleted file mode 100644 index 780593c0..00000000 --- a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerAction.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c079aa22ce14d364689992037fcb7184 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerScheduler.cs b/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerScheduler.cs deleted file mode 100644 index 0d133329..00000000 --- a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerScheduler.cs +++ /dev/null @@ -1,21 +0,0 @@ -using TEngine.Core; -#if TENGINE_UNITY -using UnityEngine; -#endif -namespace TEngine -{ - public sealed class TimerScheduler : Singleton, IUpdateSingleton - { - public readonly TimerSchedulerCore Core = new TimerSchedulerCore(() => TimeHelper.Now); -#if TENGINE_UNITY - public readonly TimerSchedulerCore Unity = new TimerSchedulerCore(() => (long) (Time.time * 1000)); -#endif - public void Update() - { - Core.Update(); -#if TENGINE_UNITY - Unity.Update(); -#endif - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerScheduler.cs.meta b/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerScheduler.cs.meta deleted file mode 100644 index f32177ae..00000000 --- a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerScheduler.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b3565301ee18ba443b84827cd7a38d5a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerSchedulerCore.cs b/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerSchedulerCore.cs deleted file mode 100644 index 4e3fe27d..00000000 --- a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerSchedulerCore.cs +++ /dev/null @@ -1,264 +0,0 @@ -using System; -using System.Collections.Generic; -using TEngine.DataStructure; -using TEngine.Core; -#pragma warning disable CS8625 - -namespace TEngine -{ - public class TimerSchedulerCore - { - private long _minTime; - private readonly Func _now; - private readonly Queue _timeOutTime = new(); - private readonly Queue _timeOutTimerIds = new(); - private readonly Dictionary _timers = new(); - private readonly SortedOneToManyList _timeId = new(); - - public TimerSchedulerCore(Func now) - { - _now = now; - } - - public void Update() - { - try - { - var currentTime = _now(); - - if (_timeId.Count == 0) - { - return; - } - - if (currentTime < _minTime) - { - return; - } - - _timeOutTime.Clear(); - _timeOutTimerIds.Clear(); - - foreach (var (key, _) in _timeId) - { - if (key > currentTime) - { - _minTime = key; - break; - } - - _timeOutTime.Enqueue(key); - } - - while (_timeOutTime.TryDequeue(out var time)) - { - foreach (var timerId in _timeId[time]) - { - _timeOutTimerIds.Enqueue(timerId); - } - - _timeId.RemoveKey(time); - } - - while (_timeOutTimerIds.TryDequeue(out var timerId)) - { - if (!_timers.TryGetValue(timerId, out var timer)) - { - continue; - } - - _timers.Remove(timer.Id); - - switch (timer.TimerType) - { - case TimerType.OnceWaitTimer: - { - var tcs = (FTask) timer.Callback; - timer.Dispose(); - tcs.SetResult(true); - break; - } - case TimerType.OnceTimer: - { - var action = (Action) timer.Callback; - timer.Dispose(); - - if (action == null) - { - Log.Error($"timer {timer.ToJson()}"); - break; - } - - action(); - break; - } - case TimerType.RepeatedTimer: - { - var action = (Action) timer.Callback; - AddTimer(_now() + timer.Time, timer); - - if (action == null) - { - Log.Error($"timer {timer.ToJson()}"); - break; - } - - action(); - break; - } - } - } - } - catch (Exception e) - { - Log.Error(e); - } - } - - private void AddTimer(long tillTime, TimerAction timer) - { - _timers.Add(timer.Id, timer); - _timeId.Add(tillTime, timer.Id); - - if (tillTime < _minTime) - { - _minTime = tillTime; - } - } - - public async FTask WaitFrameAsync() - { - return await WaitAsync(1); - } - - public async FTask WaitAsync(long time, FCancellationToken cancellationToken = null) - { - return await WaitTillAsync(_now() + time, cancellationToken); - } - - public async FTask WaitTillAsync(long tillTime, FCancellationToken cancellationToken = null) - { - if (_now() > tillTime) - { - return true; - } - - var tcs = FTask.Create(); - var timerAction = TimerAction.Create(); - var timerId = timerAction.Id; - timerAction.Callback = tcs; - timerAction.TimerType = TimerType.OnceWaitTimer; - - void CancelActionVoid() - { - if (!_timers.ContainsKey(timerId)) - { - return; - } - - Remove(timerId); - tcs.SetResult(false); - } - - bool b; - try - { - cancellationToken?.Add(CancelActionVoid); - AddTimer(tillTime, timerAction); - b = await tcs; - } - finally - { - cancellationToken?.Remove(CancelActionVoid); - } - - return b; - } - - public long NewFrameTimer(Action action) - { - return RepeatedTimer(100, action); - } - - public long RepeatedTimer(long time, Action action) - { - if (time <= 0) - { - throw new Exception("repeated time <= 0"); - } - - var tillTime = _now() + time; - var timer = TimerAction.Create(); - timer.TimerType = TimerType.RepeatedTimer; - timer.Time = time; - timer.Callback = action; - AddTimer(tillTime, timer); - return timer.Id; - } - - public long RepeatedTimer(long time, T timerHandlerType) where T : struct - { - void RepeatedTimerVoid() - { - EventSystem.Instance.Publish(timerHandlerType); - } - - return RepeatedTimer(time, RepeatedTimerVoid); - } - - public long OnceTimer(long time, Action action) - { - return OnceTillTimer(_now() + time, action); - } - - public long OnceTimer(long time, T timerHandlerType) where T : struct - { - void OnceTimerVoid() - { - EventSystem.Instance.Publish(timerHandlerType); - } - - return OnceTimer(time, OnceTimerVoid); - } - - public long OnceTillTimer(long tillTime, Action action) - { - if (tillTime < _now()) - { - Log.Error($"new once time too small tillTime:{tillTime} Now:{_now()}"); - } - - var timer = TimerAction.Create(); - timer.TimerType = TimerType.OnceTimer; - timer.Callback = action; - AddTimer(tillTime, timer); - return timer.Id; - } - - public long OnceTillTimer(long tillTime, T timerHandlerType) where T : struct - { - void OnceTillTimerVoid() - { - EventSystem.Instance.Publish(timerHandlerType); - } - - return OnceTillTimer(tillTime, OnceTillTimerVoid); - } - - public void RemoveByRef(ref long id) - { - Remove(id); - id = 0; - } - - public void Remove(long id) - { - if (id == 0 || !_timers.Remove(id, out var timer)) - { - return; - } - - timer?.Dispose(); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerSchedulerCore.cs.meta b/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerSchedulerCore.cs.meta deleted file mode 100644 index 7a04957f..00000000 --- a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerSchedulerCore.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d7936ad23c011d3419f3254b935c96a5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerType.cs b/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerType.cs deleted file mode 100644 index ac8a321e..00000000 --- a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerType.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace TEngine -{ - public enum TimerType - { - None, - OnceWaitTimer, - OnceTimer, - RepeatedTimer - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerType.cs.meta b/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerType.cs.meta deleted file mode 100644 index f330e16c..00000000 --- a/Assets/GameScripts/DotNet/Core/TimerScheduler/TimerType.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6919ca6608e0e8840aaedf1f8d09f53f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Unity.meta b/Assets/GameScripts/DotNet/Core/Unity.meta deleted file mode 100644 index 752640e4..00000000 --- a/Assets/GameScripts/DotNet/Core/Unity.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5f7ad3b14e2e19c43b6112100cce6c42 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Unity/AssemblyName.cs b/Assets/GameScripts/DotNet/Core/Unity/AssemblyName.cs deleted file mode 100644 index d50efded..00000000 --- a/Assets/GameScripts/DotNet/Core/Unity/AssemblyName.cs +++ /dev/null @@ -1,16 +0,0 @@ -public static class AssemblyName -{ - // 这个对应的是NetCore工程 - public const int AssemblyDotNet = 1; - - public const int GameBase = 10; - - public const int GameLogic = 20; - - public const int GameProto = 30; - - // 你可以添加多个工程、如果有新添加的可以在这里添加、 - // 并在AssemblyLoadHelper里添加对应的加载逻辑 - // 参考LoadModelDll这个方法 - // 这样添加是为了方便后面热重载使用 -} diff --git a/Assets/GameScripts/DotNet/Core/Unity/AssemblyName.cs.meta b/Assets/GameScripts/DotNet/Core/Unity/AssemblyName.cs.meta deleted file mode 100644 index dd72fd39..00000000 --- a/Assets/GameScripts/DotNet/Core/Unity/AssemblyName.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 44af1c6e3b8a24b40a198c068993596d -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Unity/GameContext.cs b/Assets/GameScripts/DotNet/Core/Unity/GameContext.cs deleted file mode 100644 index dd5a6a7e..00000000 --- a/Assets/GameScripts/DotNet/Core/Unity/GameContext.cs +++ /dev/null @@ -1,36 +0,0 @@ -#if TENGINE_UNITY -using System.Threading; -using TEngine.Core; - -namespace TEngine -{ - public struct OnAppStart - { - public Scene ClientScene; - } - - public struct OnAppClosed { } - - public static class GameContext - { - public static void Init() - { - // 设置默认的线程的同步上下文 - SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Main); - // 初始化SingletonSystemCenter这个一定要放到最前面 - // 因为SingletonSystem会注册AssemblyManager的OnLoadAssemblyEvent和OnUnLoadAssemblyEvent的事件 - // 如果不这样、会无法把程序集的单例注册到SingletonManager中 - SingletonSystem.Initialize(); - // 加载核心程序集 - AssemblyManager.Initialize(); - } - - public static void Close() - { - SingletonSystem.Dispose(); - AssemblyManager.Dispose(); - Scene.DisposeAllScene(); - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Unity/GameContext.cs.meta b/Assets/GameScripts/DotNet/Core/Unity/GameContext.cs.meta deleted file mode 100644 index 65e2a5ef..00000000 --- a/Assets/GameScripts/DotNet/Core/Unity/GameContext.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7db9c21fafd32054580caf1503ba2f17 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Core/Unity/GameSystem.cs b/Assets/GameScripts/DotNet/Core/Unity/GameSystem.cs deleted file mode 100644 index 5c1c1c9d..00000000 --- a/Assets/GameScripts/DotNet/Core/Unity/GameSystem.cs +++ /dev/null @@ -1,40 +0,0 @@ -#if TENGINE_UNITY -using TEngine.Core; -using UnityEngine; - -namespace TEngine -{ - public class GameSystem : MonoBehaviour - { - /// - /// 初始化框架。 - /// - public static Scene Init() - { - // 初始化框架 - GameContext.Init(); - new GameObject("[EntitySystem]").AddComponent(); - // 框架需要一个Scene来驱动、所以要创建一个Scene、后面所有的框架都会在这个Scene下 - // 也就是把这个Scene给卸载掉、框架的东西都会清除掉 - return Scene.Create("Unity"); - } - - public void Awake() - { - DontDestroyOnLoad(gameObject); - } - - private void Update() - { - ThreadSynchronizationContext.Main.Update(); - SingletonSystem.Update(); - } - - private void OnApplicationQuit() - { - EventSystem.Instance?.Publish(new OnAppClosed()); - GameContext.Close(); - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Core/Unity/GameSystem.cs.meta b/Assets/GameScripts/DotNet/Core/Unity/GameSystem.cs.meta deleted file mode 100644 index f32a97cc..00000000 --- a/Assets/GameScripts/DotNet/Core/Unity/GameSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fcb9cd4fe550bbe4083cc7c54ae9c0ef -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/DotNet.asmdef b/Assets/GameScripts/DotNet/DotNet.asmdef deleted file mode 100644 index f42a0504..00000000 --- a/Assets/GameScripts/DotNet/DotNet.asmdef +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "DotNet", - "rootNamespace": "", - "references": [ - "GUID:d8b63aba1907145bea998dd612889d6b", - "GUID:aa06d4cc755c979489c256c1bcca1dfb" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": true, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [ - "!ENABLE_DLL" - ], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/DotNet.asmdef.meta b/Assets/GameScripts/DotNet/DotNet.asmdef.meta deleted file mode 100644 index 80f1919d..00000000 --- a/Assets/GameScripts/DotNet/DotNet.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: ecba4a58c7f7a4842b72ce2c77aecf9b -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Logic.meta b/Assets/GameScripts/DotNet/Logic.meta deleted file mode 100644 index 2ee902d6..00000000 --- a/Assets/GameScripts/DotNet/Logic.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: af6fed2b79cb79e4593f921943c3357d -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/Logic/ErrorCode.cs b/Assets/GameScripts/DotNet/Logic/ErrorCode.cs deleted file mode 100644 index 6c998833..00000000 --- a/Assets/GameScripts/DotNet/Logic/ErrorCode.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace TEngine.Logic -{ - public static partial class ErrorCode - { - public const int ERR_SignError = 10000; - public const int ERR_Disconnect = 210000; - public const int ERR_LoginError = 210005; - - //300000开始自定义错误 - public const int ERR_AccountAlreadyRegisted = 300001; - public const int ERR_AccountOrPasswordError = 300002; - public const int ERR_UserNotOnline = 300003; - public const int ERR_ConnectGateKeyError = 300004; - public const int ERR_CreateNewCharacter = 300007; - public const int ERR_CannotCreateMoreCharacter = 300008; - public const int ERR_CharacterAlreadyRegisted = 300009; - public const int ERR_AccountIsForbid = 300010; - public const int ERR_AccountIsInGame = 300011; - } -} \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/ErrorCode.cs.meta b/Assets/GameScripts/DotNet/Logic/ErrorCode.cs.meta deleted file mode 100644 index c1abaff7..00000000 --- a/Assets/GameScripts/DotNet/Logic/ErrorCode.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 6977010e71da47eaaf96a40a1db7c021 -timeCreated: 1689435709 \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/Logic/Share.cs b/Assets/GameScripts/DotNet/Logic/Share.cs deleted file mode 100644 index 786aea24..00000000 --- a/Assets/GameScripts/DotNet/Logic/Share.cs +++ /dev/null @@ -1,4 +0,0 @@ -public class Share -{ - -} diff --git a/Assets/GameScripts/DotNet/Logic/Share.cs.meta b/Assets/GameScripts/DotNet/Logic/Share.cs.meta deleted file mode 100644 index abe80f28..00000000 --- a/Assets/GameScripts/DotNet/Logic/Share.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b0b267713d913c84c860dc88be4ff70e -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/DotNet/csc.rsp b/Assets/GameScripts/DotNet/csc.rsp deleted file mode 100644 index 36fdced9..00000000 --- a/Assets/GameScripts/DotNet/csc.rsp +++ /dev/null @@ -1 +0,0 @@ --define:TENGINE_UNITY \ No newline at end of file diff --git a/Assets/GameScripts/DotNet/csc.rsp.meta b/Assets/GameScripts/DotNet/csc.rsp.meta deleted file mode 100644 index dc06f14c..00000000 --- a/Assets/GameScripts/DotNet/csc.rsp.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 8444a333021244b3aa1559b112073e61 -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor.meta b/Assets/GameScripts/Editor.meta deleted file mode 100644 index 97a32d77..00000000 --- a/Assets/GameScripts/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f69993ae3e14f924aa33b8747244c587 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas.meta b/Assets/GameScripts/Editor/Entitas.meta deleted file mode 100644 index db854cf5..00000000 --- a/Assets/GameScripts/Editor/Entitas.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 4c152230ddf4e46458f1bd516e896129 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/ComponentViewEditor.cs b/Assets/GameScripts/Editor/Entitas/ComponentViewEditor.cs deleted file mode 100644 index f570a027..00000000 --- a/Assets/GameScripts/Editor/Entitas/ComponentViewEditor.cs +++ /dev/null @@ -1,102 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; -using Sirenix.OdinInspector.Editor; -using TEngine; -using UnityEditor; -using UnityEngine; - -[CustomEditor(typeof(ComponentView))] -public class ComponentViewEditor : OdinEditor -{ - public override void OnInspectorGUI() - { - ComponentView componentView = (ComponentView)target; - Entity component = componentView.Component; - ComponentViewHelper.Draw(component); - } -} - -public static class ComponentViewHelper -{ - private static readonly List typeDrawers = new List(); - - static ComponentViewHelper() - { - Assembly assembly = typeof(ComponentViewHelper).Assembly; - foreach (Type type in assembly.GetTypes()) - { - if (!type.IsDefined(typeof(TypeDrawerAttribute))) - { - continue; - } - - ITypeDrawer iTypeDrawer = (ITypeDrawer)Activator.CreateInstance(type); - typeDrawers.Add(iTypeDrawer); - } - } - - public static void Draw(Entity entity) - { - try - { - FieldInfo[] fields = entity.GetType() - .GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | - BindingFlags.FlattenHierarchy); - - EditorGUILayout.BeginVertical(); - - EditorGUILayout.LongField("RuntimeId: ", entity.RuntimeId); - - EditorGUILayout.LongField("Id: ", entity.Id); - - foreach (FieldInfo fieldInfo in fields) - { - Type type = fieldInfo.FieldType; - if (type.IsDefined(typeof(HideInInspector), false)) - { - continue; - } - - if (fieldInfo.IsDefined(typeof(HideInInspector), false)) - { - continue; - } - - object value = fieldInfo.GetValue(entity); - - foreach (ITypeDrawer typeDrawer in typeDrawers) - { - if (!typeDrawer.HandlesType(type)) - { - continue; - } - - string fieldName = fieldInfo.Name; - if (fieldName.Length > 17 && fieldName.Contains("k__BackingField")) - { - fieldName = fieldName.Substring(1, fieldName.Length - 17); - } - - try - { - value = typeDrawer.DrawAndGetNewValue(type, fieldName, value, null); - } - catch (Exception e) - { - Debug.LogError(e); - } - - fieldInfo.SetValue(entity, value); - break; - } - } - - EditorGUILayout.EndVertical(); - } - catch (Exception e) - { - Debug.Log($"component view error: {entity.GetType().FullName} {e}"); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/ComponentViewEditor.cs.meta b/Assets/GameScripts/Editor/Entitas/ComponentViewEditor.cs.meta deleted file mode 100644 index 5daa476c..00000000 --- a/Assets/GameScripts/Editor/Entitas/ComponentViewEditor.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fe2aac3a6ed717d4da185a29f2d2a386 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/ITypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/ITypeDrawer.cs deleted file mode 100644 index 42be5f8d..00000000 --- a/Assets/GameScripts/Editor/Entitas/ITypeDrawer.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace TEngine -{ - public interface ITypeDrawer - { - bool HandlesType(Type type); - - object DrawAndGetNewValue(Type memberType, string memberName, object value, object target); - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/ITypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/ITypeDrawer.cs.meta deleted file mode 100644 index 298ae324..00000000 --- a/Assets/GameScripts/Editor/Entitas/ITypeDrawer.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: ba82988cd3f6426cbb858d18eed4a8bb -timeCreated: 1689578308 \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer.meta deleted file mode 100644 index 32d1fbf2..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 965c500db0aa46ac9a6ff0fe19a9adda -timeCreated: 1689578308 \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/AnimationCurveTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/AnimationCurveTypeDrawer.cs deleted file mode 100644 index 32db764c..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/AnimationCurveTypeDrawer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using UnityEditor; -using UnityEngine; - -namespace TEngine -{ - [TypeDrawer] - public class AnimationCurveTypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (AnimationCurve); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - return EditorGUILayout.CurveField(memberName, (AnimationCurve) value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/AnimationCurveTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/AnimationCurveTypeDrawer.cs.meta deleted file mode 100644 index 0704da21..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/AnimationCurveTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ae2555143c20c6b49825eaa645fc626b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoolTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoolTypeDrawer.cs deleted file mode 100644 index 15232da1..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoolTypeDrawer.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using UnityEditor; - -namespace TEngine -{ - [TypeDrawer] - public class BoolTypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (bool); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - return EditorGUILayout.Toggle(memberName, (bool) value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoolTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoolTypeDrawer.cs.meta deleted file mode 100644 index 5ffe1919..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoolTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e8022a6e902073946b421230f287c214 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoundsTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoundsTypeDrawer.cs deleted file mode 100644 index 71361ca5..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoundsTypeDrawer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using UnityEditor; -using UnityEngine; - -namespace TEngine -{ - [TypeDrawer] - public class BoundsTypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (Bounds); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - return EditorGUILayout.BoundsField(memberName, (Bounds) value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoundsTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoundsTypeDrawer.cs.meta deleted file mode 100644 index 6a4c5ffb..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/BoundsTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 56a153b48484f394cae46d7f2eed3b1b -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/CharTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/CharTypeDrawer.cs deleted file mode 100644 index a85d72ff..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/CharTypeDrawer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using UnityEditor; - -namespace TEngine -{ - [TypeDrawer] - public class CharTypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (char); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - var str = EditorGUILayout.TextField(memberName, ((char) value).ToString()); - return str.Length > 0? str[0] : default (char); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/CharTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/CharTypeDrawer.cs.meta deleted file mode 100644 index df5a8024..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/CharTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 0ec6e79217cb2ea4abbd149361850719 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/ColorTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/ColorTypeDrawer.cs deleted file mode 100644 index ca239b30..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/ColorTypeDrawer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using UnityEditor; -using UnityEngine; - -namespace TEngine -{ - [TypeDrawer] - public class ColorTypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (Color); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - return EditorGUILayout.ColorField(memberName, (Color) value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/ColorTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/ColorTypeDrawer.cs.meta deleted file mode 100644 index a8f9d022..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/ColorTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 89557fe3279f2cf43b9ab573d50af140 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DateTimeTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DateTimeTypeDrawer.cs deleted file mode 100644 index e9afa59c..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DateTimeTypeDrawer.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using UnityEditor; - -namespace TEngine -{ - [TypeDrawer] - public class DateTimeTypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (DateTime); - } - - // Note: This is a very basic implementation. The ToString() method conversion will cut off milliseconds. - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - var dateString = value.ToString(); - var newDateString = EditorGUILayout.TextField(memberName, dateString); - - return newDateString != dateString - ? DateTime.Parse(newDateString) - : value; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DateTimeTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DateTimeTypeDrawer.cs.meta deleted file mode 100644 index f827d41d..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DateTimeTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f0d0ce2464429cf4da779507e0707feb -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DictionaryIntLongTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DictionaryIntLongTypeDrawer.cs deleted file mode 100644 index 22f756a8..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DictionaryIntLongTypeDrawer.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEditor; - -namespace TEngine -{ - [TypeDrawer] - public class DictionaryIntLongTypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (Dictionary); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - Dictionary dictionary = value as Dictionary; - - EditorGUILayout.LabelField($"{memberName}:"); - foreach ((int k, long v) in dictionary) - { - if (v == 0) - { - continue; - } - EditorGUILayout.LongField($" {k} :", v); - } - return value; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DictionaryIntLongTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DictionaryIntLongTypeDrawer.cs.meta deleted file mode 100644 index 8ef49af3..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DictionaryIntLongTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b4f3ad48c3023dd4f9dbe2a6145be126 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DoubleTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DoubleTypeDrawer.cs deleted file mode 100644 index 74af1e78..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DoubleTypeDrawer.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using UnityEditor; - -namespace TEngine -{ - [TypeDrawer] - public class DoubleTypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (double); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - return EditorGUILayout.DoubleField(memberName, (double) value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DoubleTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/DoubleTypeDrawer.cs.meta deleted file mode 100644 index fe193096..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/DoubleTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f7fb2f1ae08fdc643932c03d2fbdf7e5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/EntityRefTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/EntityRefTypeDrawer.cs deleted file mode 100644 index 0b120d4a..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/EntityRefTypeDrawer.cs +++ /dev/null @@ -1,39 +0,0 @@ -#if ENABLE_VIEW - -using System; -using System.Reflection; -using UnityEditor; -using UnityEngine; - -namespace TEngine -{ - [TypeDrawer] - public class EntityRefTypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - if (!type.IsGenericType) - { - return false; - } - - if (type.GetGenericTypeDefinition() == typeof (EntityRef<>)) - { - return true; - } - - return false; - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - FieldInfo fieldInfo = memberType.GetField("entity", BindingFlags.NonPublic | BindingFlags.Instance); - Entity entity = (Entity)fieldInfo.GetValue(value); - GameObject go = entity?.ViewGO; - EditorGUILayout.ObjectField(memberName, go, memberType, true); - return value; - } - } -} - -#endif \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/EntityRefTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/EntityRefTypeDrawer.cs.meta deleted file mode 100644 index 91568bc0..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/EntityRefTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: e13b5d8e25f279649895512cc6b21123 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/EnumTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/EnumTypeDrawer.cs deleted file mode 100644 index ea18caad..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/EnumTypeDrawer.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using UnityEditor; - -namespace TEngine -{ - [TypeDrawer] - public class EnumTypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type.IsEnum; - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - if (memberType.IsDefined(typeof (FlagsAttribute), false)) - { - return EditorGUILayout.EnumFlagsField(memberName, (Enum) value); - } - - return EditorGUILayout.EnumPopup(memberName, (Enum) value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/EnumTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/EnumTypeDrawer.cs.meta deleted file mode 100644 index 9554e520..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/EnumTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 29e6926674d4e6f49ad2bb925191c912 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/FloatTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/FloatTypeDrawer.cs deleted file mode 100644 index b1be3db9..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/FloatTypeDrawer.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using UnityEditor; - -namespace TEngine -{ - [TypeDrawer] - public class FloatTypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (float); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - return EditorGUILayout.FloatField(memberName, (float) value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/FloatTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/FloatTypeDrawer.cs.meta deleted file mode 100644 index 71d727c8..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/FloatTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a812828c88a51f5438ac4f10d680daec -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/IntTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/IntTypeDrawer.cs deleted file mode 100644 index b0e73725..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/IntTypeDrawer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using UnityEditor; - -namespace TEngine -{ - [TypeDrawer] - public class IntTypeDrawer: ITypeDrawer - { - [TypeDrawer] - public bool HandlesType(Type type) - { - return type == typeof (int); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - return EditorGUILayout.IntField(memberName, (int) value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/IntTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/IntTypeDrawer.cs.meta deleted file mode 100644 index c1db52fd..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/IntTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bd314885fe993aa4995e2664c02d4aa5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/LongTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/LongTypeDrawer.cs deleted file mode 100644 index 43fbed88..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/LongTypeDrawer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using UnityEditor; - -namespace TEngine -{ - [TypeDrawer] - public class LongTypeDrawer: ITypeDrawer - { - [TypeDrawer] - public bool HandlesType(Type type) - { - return type == typeof (long); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - return EditorGUILayout.LongField(memberName, (long) value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/LongTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/LongTypeDrawer.cs.meta deleted file mode 100644 index f35e073d..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/LongTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: d89f15e267d1ef04896ceed73e57d8f0 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/RectTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/RectTypeDrawer.cs deleted file mode 100644 index 57fe2bd1..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/RectTypeDrawer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using UnityEditor; -using UnityEngine; - -namespace TEngine -{ - [TypeDrawer] - public class RectTypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (Rect); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - return EditorGUILayout.RectField(memberName, (Rect) value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/RectTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/RectTypeDrawer.cs.meta deleted file mode 100644 index e4a1725d..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/RectTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 051d3ab57c4efe346abdff5c64a4feee -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/StringTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/StringTypeDrawer.cs deleted file mode 100644 index c3e08f5b..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/StringTypeDrawer.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using UnityEditor; - -namespace TEngine -{ - [TypeDrawer] - public class StringTypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (string); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - return EditorGUILayout.DelayedTextField(memberName, (string) value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/StringTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/StringTypeDrawer.cs.meta deleted file mode 100644 index 107bbbaa..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/StringTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 30bc09383e1bc14409c952170fe70661 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/UnityObjectTypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/UnityObjectTypeDrawer.cs deleted file mode 100644 index 37de1c28..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/UnityObjectTypeDrawer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using UnityEditor; - -namespace TEngine -{ - [TypeDrawer] - public class UnityObjectTypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (UnityEngine.Object) || - type.IsSubclassOf(typeof (UnityEngine.Object)); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - return EditorGUILayout.ObjectField(memberName, (UnityEngine.Object) value, memberType, true); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/UnityObjectTypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/UnityObjectTypeDrawer.cs.meta deleted file mode 100644 index 68b93971..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/UnityObjectTypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a810aa11d0c17e548848c1745dbdb30c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector2TypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector2TypeDrawer.cs deleted file mode 100644 index 7b2a96e4..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector2TypeDrawer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using UnityEditor; -using UnityEngine; - -namespace TEngine -{ - [TypeDrawer] - public class Vector2TypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (Vector2); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - return EditorGUILayout.Vector2Field(memberName, (Vector2) value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector2TypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector2TypeDrawer.cs.meta deleted file mode 100644 index 7faedc90..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector2TypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fac773feb8b254c409b8568ff7fbca16 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector3TypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector3TypeDrawer.cs deleted file mode 100644 index 69e119eb..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector3TypeDrawer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using UnityEditor; -using UnityEngine; - -namespace TEngine -{ - [TypeDrawer] - public class Vector3TypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (Vector3); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - return EditorGUILayout.Vector3Field(memberName, (Vector3) value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector3TypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector3TypeDrawer.cs.meta deleted file mode 100644 index 83145e0d..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector3TypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b3229d49b3d935d41ae02afae1cc675f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector4TypeDrawer.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector4TypeDrawer.cs deleted file mode 100644 index 881f58fb..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector4TypeDrawer.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using UnityEditor; -using UnityEngine; - -namespace TEngine -{ - [TypeDrawer] - public class Vector4TypeDrawer: ITypeDrawer - { - public bool HandlesType(Type type) - { - return type == typeof (Vector4); - } - - public object DrawAndGetNewValue(Type memberType, string memberName, object value, object target) - { - return EditorGUILayout.Vector4Field(memberName, (Vector4) value); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector4TypeDrawer.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector4TypeDrawer.cs.meta deleted file mode 100644 index 497df48f..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawer/Vector4TypeDrawer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8455282b831decd44b5b15289adbe6db -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawerAttribute.cs b/Assets/GameScripts/Editor/Entitas/TypeDrawerAttribute.cs deleted file mode 100644 index bfd77ec9..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawerAttribute.cs +++ /dev/null @@ -1,6 +0,0 @@ -using System; - -namespace TEngine -{ - public class TypeDrawerAttribute: Attribute { } -} \ No newline at end of file diff --git a/Assets/GameScripts/Editor/Entitas/TypeDrawerAttribute.cs.meta b/Assets/GameScripts/Editor/Entitas/TypeDrawerAttribute.cs.meta deleted file mode 100644 index 71318212..00000000 --- a/Assets/GameScripts/Editor/Entitas/TypeDrawerAttribute.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 64d93f1343d249ea98a11ad1dfe9dc7d -timeCreated: 1689578308 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/BattleCore.meta b/Assets/GameScripts/HotFix/BattleCore.meta deleted file mode 100644 index 260f6354..00000000 --- a/Assets/GameScripts/HotFix/BattleCore.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: b6b7bfca93e005f45999c16054d999e7 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/BattleCore/BattleCore.Runtime.asmdef b/Assets/GameScripts/HotFix/BattleCore/BattleCore.Runtime.asmdef deleted file mode 100644 index 9a08beea..00000000 --- a/Assets/GameScripts/HotFix/BattleCore/BattleCore.Runtime.asmdef +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "BattleCore.Runtime", - "rootNamespace": "BattleCore.Runtime", - "references": [ - "GUID:aa06d4cc755c979489c256c1bcca1dfb", - "GUID:d8b63aba1907145bea998dd612889d6b", - "GUID:a90b2d3377c5e4a4db95cc44fb82045e" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/BattleCore/BattleCore.Runtime.asmdef.meta b/Assets/GameScripts/HotFix/BattleCore/BattleCore.Runtime.asmdef.meta deleted file mode 100644 index 55fa9cbf..00000000 --- a/Assets/GameScripts/HotFix/BattleCore/BattleCore.Runtime.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 641632c4f8079b94f963b5284d859a12 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/BattleCore/ECSExtension.meta b/Assets/GameScripts/HotFix/BattleCore/ECSExtension.meta deleted file mode 100644 index bc0e1a56..00000000 --- a/Assets/GameScripts/HotFix/BattleCore/ECSExtension.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 890abd3a957e406ab422fc468ba6c169 -timeCreated: 1682353243 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/BattleCore/ECSExtension/EntityExtension.cs b/Assets/GameScripts/HotFix/BattleCore/ECSExtension/EntityExtension.cs deleted file mode 100644 index 582c0d86..00000000 --- a/Assets/GameScripts/HotFix/BattleCore/ECSExtension/EntityExtension.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace BattleCore.Runtime -{ - public static class EntityExtension - { - } -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/BattleCore/ECSExtension/EntityExtension.cs.meta b/Assets/GameScripts/HotFix/BattleCore/ECSExtension/EntityExtension.cs.meta deleted file mode 100644 index 7f82c3e7..00000000 --- a/Assets/GameScripts/HotFix/BattleCore/ECSExtension/EntityExtension.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b4ef2dfa5ceac99458eb1745131a9c83 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/BattleCore/ECSExtension/MathematicsExtension.cs b/Assets/GameScripts/HotFix/BattleCore/ECSExtension/MathematicsExtension.cs deleted file mode 100644 index 2d9ce577..00000000 --- a/Assets/GameScripts/HotFix/BattleCore/ECSExtension/MathematicsExtension.cs +++ /dev/null @@ -1,27 +0,0 @@ -using UnityEngine; -using Unity.Mathematics; - -namespace BattleCore.Runtime -{ - public static class MathematicsExt - { - public static int2 ToInt2(this Vector2Int vec) => new int2(vec.x, vec.y); - public static int3 ToInt3(this Vector3Int vec) => new int3(vec.x, vec.y, vec.z); - public static float2 ToFloat2(this Vector2 vec) => new float2(vec.x, vec.y); - public static float3 ToFloat3(this Vector3 vec) => new float3(vec.x, vec.y, vec.z); - - public static bool IsEquals(this int2 a, int2 b) => math.all(a == b); - public static bool IsEquals(this int3 a, int3 b) => math.all(a == b); - - - public static Vector2Int ToVec2(this int2 vec) => new Vector2Int(vec.x, vec.y); - public static Vector3Int ToVec3(this int2 vec) => new Vector3Int(vec.x, vec.y, 0); - public static Vector3Int ToVec3(this int3 vec) => new Vector3Int(vec.x, vec.y, vec.z); - public static Vector2 ToVec2(this float2 vec) => new Vector2(vec.x, vec.y); - public static Vector3 ToVec3(this float3 vec) => new Vector3(vec.x, vec.y, vec.z); - public static int ManhattanDist(this int2 vec) => vec.x + vec.y; - public static int ManhattanDist(this int3 vec) => vec.x + vec.y + vec.z; - public static float ManhattanDist(this float2 vec) => vec.x + vec.y; - public static float ManhattanDist(this float3 vec) => vec.x + vec.y + vec.z; - } -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/BattleCore/ECSExtension/MathematicsExtension.cs.meta b/Assets/GameScripts/HotFix/BattleCore/ECSExtension/MathematicsExtension.cs.meta deleted file mode 100644 index 727a2123..00000000 --- a/Assets/GameScripts/HotFix/BattleCore/ECSExtension/MathematicsExtension.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 2b0e288b918a41698571ec3d36059851 -timeCreated: 1682353251 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/BattleCore/Empty.cs b/Assets/GameScripts/HotFix/BattleCore/Empty.cs deleted file mode 100644 index ff2bccb0..00000000 --- a/Assets/GameScripts/HotFix/BattleCore/Empty.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -namespace BattleCore.Runtime -{ - public class Empty : MonoBehaviour - { - // Start is called before the first frame update - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } - } -} diff --git a/Assets/GameScripts/HotFix/BattleCore/Empty.cs.meta b/Assets/GameScripts/HotFix/BattleCore/Empty.cs.meta deleted file mode 100644 index 94b676bf..00000000 --- a/Assets/GameScripts/HotFix/BattleCore/Empty.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1fc394f8c6ad5304a82ff84b4263756f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/GameBase/Attribute.cs b/Assets/GameScripts/HotFix/GameBase/Attribute.cs deleted file mode 100644 index 1c7fbddc..00000000 --- a/Assets/GameScripts/HotFix/GameBase/Attribute.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System; - -namespace TEngine -{ - #region Attribute - - [AttributeUsage(AttributeTargets.Class)] - public class UpdateAttribute : Attribute - { - } - - [AttributeUsage(AttributeTargets.Class)] - public class FixedUpdateAttribute : Attribute - { - } - - [AttributeUsage(AttributeTargets.Class)] - public class LateUpdateAttribute : Attribute - { - } - - [AttributeUsage(AttributeTargets.Class)] - public class RoleLoginAttribute : Attribute - { - } - - [AttributeUsage(AttributeTargets.Class)] - public class RoleLogoutAttribute : Attribute - { - } - - #endregion -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameBase/Loom.meta b/Assets/GameScripts/HotFix/GameBase/Loom.meta deleted file mode 100644 index e104ca98..00000000 --- a/Assets/GameScripts/HotFix/GameBase/Loom.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: dab5f3e08b4367d41b801af29d381ca8 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/GameBase/Loom/Loom.cs b/Assets/GameScripts/HotFix/GameBase/Loom/Loom.cs deleted file mode 100644 index 4b6b645c..00000000 --- a/Assets/GameScripts/HotFix/GameBase/Loom/Loom.cs +++ /dev/null @@ -1,191 +0,0 @@ -#if !UNITY_WEBGL -using UnityEngine; -using System.Collections.Generic; -using System; -using System.Threading; -using System.Linq; - -/******************************************************************************* - //开启一个Loom进程 - Loom.RunAsync(() => - { - aucThread = new Thread(ReceiveMsg); - aucThread.Start(); - } - - //进程调用主线程方法 - MainPack pack = (MainPack)MainPack.Descriptor.Parser.ParseFrom(buffer, 0, len); - Loom.QueueOnMainThread((param) => - { - UdpHandleResponse(pack); - }, null); - - *******************************************************************************/ -namespace GameBase -{ - /// - /// Loom多线程通信。 - /// - /// - public class Loom : MonoBehaviour - { - public Dictionary TokenSourcesDictionary = new Dictionary(); - private static readonly int MaxThreads = 8; - private static int _numThreads; - private static Loom _current; - - public static Loom Current - { - get - { - Initialize(); - return _current; - } - } - - public void Awake() - { - _current = this; - _initialized = true; - } - - protected void OnDestroy() - { - } - - private static bool _initialized; - - private static void Initialize() - { - if (!_initialized) - { - if (!Application.isPlaying) - { - return; - } - - _initialized = true; - - var obj = new GameObject("[Loom]"); - - _current = obj.AddComponent(); - - DontDestroyOnLoad(obj); - } - } - - public struct NoDelayedQueueItem - { - public Action Action; - public object Param; - } - - private readonly List _actions = new List(); - - public struct DelayedQueueItem - { - public float Time; - public Action Action; - public object Param; - } - - private readonly List _delayed = new List(); - - private readonly List _currentDelayed = new List(); - - public static void QueueOnMainThread(Action taction, object param, float time = 0f) - { - if (time != 0f) - { - lock (Current._delayed) - { - Current._delayed.Add(new DelayedQueueItem { Time = Time.time + time, Action = taction, Param = param }); - } - } - else - { - lock (Current._actions) - { - Current._actions.Add(new NoDelayedQueueItem { Action = taction, Param = param }); - } - } - } - - public static Thread RunAsync(Action action) - { - Initialize(); - while (_numThreads >= MaxThreads) - { - Thread.Sleep(100); - } - - Interlocked.Increment(ref _numThreads); - ThreadPool.QueueUserWorkItem(RunAction, action); - return null; - } - - private static void RunAction(object action) - { - try - { - ((Action)action)(); - } - catch - { - // ignored - } - finally - { - Interlocked.Decrement(ref _numThreads); - } - } - - - void OnDisable() - { - if (_current == this) - { - _current = null; - } - } - - private readonly List _currentActions = new List(); - - void Update() - { - if (_actions.Count > 0) - { - lock (_actions) - { - _currentActions.Clear(); - _currentActions.AddRange(_actions); - _actions.Clear(); - } - - for (int i = 0; i < _currentActions.Count; i++) - { - _currentActions[i].Action(_currentActions[i].Param); - } - } - - if (_delayed.Count > 0) - { - lock (_delayed) - { - _currentDelayed.Clear(); - _currentDelayed.AddRange(_delayed.Where(d => d.Time <= Time.time)); - for (int i = 0; i < _currentDelayed.Count; i++) - { - _delayed.Remove(_currentDelayed[i]); - } - } - - for (int i = 0; i < _currentDelayed.Count; i++) - { - _currentDelayed[i].Action(_currentDelayed[i].Param); - } - } - } - } -} -#endif \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameBase/Loom/Loom.cs.meta b/Assets/GameScripts/HotFix/GameBase/Loom/Loom.cs.meta deleted file mode 100644 index b89d6a2d..00000000 --- a/Assets/GameScripts/HotFix/GameBase/Loom/Loom.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: eea4adc555e37f842abf5dd24c191d93 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/GameBase/Redux.cs b/Assets/GameScripts/HotFix/GameBase/Redux.cs deleted file mode 100644 index 24a18d4a..00000000 --- a/Assets/GameScripts/HotFix/GameBase/Redux.cs +++ /dev/null @@ -1,1118 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; - -namespace TEngine -{ - #region Architecture - - abstract class Architecture : ILogicSys, IArchitecture where T : Architecture, new() - { - private bool _init; - - private readonly List _systems = new List(); - - private readonly List _models = new List(); - - public static readonly Action OnRegisterPatch = architecture => { }; - - private static T _architecture; - - #region AttributeList - - private List _updateSystems; - private List _lateUpdateSystems; - private List _fixedUpdateSystems; - private List _roleLoginSystems; - private List _roleLogoutSystems; - - #endregion - - public static IArchitecture Interface - { - get - { - if (_architecture == null) - { - MakeSureArchitecture(); - } - - return _architecture; - } - } - - public static T Instance - { - get - { - if (_architecture == null) - { - MakeSureArchitecture(); - } - - return _architecture; - } - } - - static void MakeSureArchitecture() - { - if (_architecture == null) - { - _architecture = new T(); - _architecture.Init(); - - if (OnRegisterPatch != null) - { - OnRegisterPatch.Invoke(_architecture); - } - - foreach (var architectureModel in _architecture._models) - { - architectureModel.Init(); - } - - _architecture._models.Clear(); - - foreach (var architectureSystem in _architecture._systems) - { - architectureSystem.Init(); - } - - _architecture._systems.Clear(); - - _architecture._init = true; - } - } - - protected abstract void Init(); - - private readonly Container _container = new Container(); - - public void RegisterSystem(TSystem system) where TSystem : ISystem - { - system.SetArchitecture(this); - _container.Register(system); - - if (!_init) - { - ProcessAttribute(system); - _systems.Add(system); - } - else - { - system.Init(); - } - } - - public void ProcessAttribute(TSystem system) where TSystem : ISystem - { - Type systemType = system.GetType(); - SubSystem instance = system as SubSystem; - if (HadAttribute(systemType)) - { - if (_updateSystems == null) - { - _updateSystems = new List(); - } - - _updateSystems.Add(instance); - } - - if (HadAttribute(systemType)) - { - if (_lateUpdateSystems == null) - { - _lateUpdateSystems = new List(); - } - - _lateUpdateSystems.Add(instance); - } - - if (HadAttribute(systemType)) - { - if (_fixedUpdateSystems == null) - { - _fixedUpdateSystems = new List(); - } - - _fixedUpdateSystems.Add(instance); - } - - if (HadAttribute(systemType)) - { - if (_roleLoginSystems == null) - { - _roleLoginSystems = new List(); - } - - _roleLoginSystems.Add(instance); - } - - if (HadAttribute(systemType)) - { - if (_roleLogoutSystems == null) - { - _roleLogoutSystems = new List(); - } - - _roleLogoutSystems.Add(instance); - } - } - - private bool HadAttribute(Type type) where TAttribute : Attribute - { - TAttribute attribute = Attribute.GetCustomAttribute(type, typeof(TAttribute)) as TAttribute; - - return attribute != null; - } - - public void RegisterModel(TModel model) where TModel : IModel - { - model.SetArchitecture(this); - _container.Register(model); - - if (!_init) - { - _models.Add(model); - } - else - { - model.Init(); - } - } - - public void RegisterUtility(TUtility utility) where TUtility : IUtility - { - _container.Register(utility); - } - - public TSystem GetSystem() where TSystem : class, ISystem - { - return _container.Get(); - } - - public TModel GetModel() where TModel : class, IModel - { - return _container.Get(); - } - - public TUtility GetUtility() where TUtility : class, IUtility - { - return _container.Get(); - } - - public void SendCommand() where TCommand : ICommand, new() - { - var command = new TCommand(); - command.SetArchitecture(this); - command.Execute(); - } - - public void SendCommand(TCommand command) where TCommand : ICommand - { - command.SetArchitecture(this); - command.Execute(); - } - - public TResult SendQuery(IQuery query) - { - query.SetArchitecture(this); - return query.Do(); - } - - private readonly TypeEventSystem _typeEventSystem = new TypeEventSystem(); - - public void SendEvent() where TEvent : new() - { - _typeEventSystem.Send(); - } - - public void SendEvent(TEvent e) - { - _typeEventSystem.Send(e); - } - - public IUnRegister RegisterEvent(Action onEvent) - { - return _typeEventSystem.Register(onEvent); - } - - public void UnRegisterEvent(Action onEvent) - { - _typeEventSystem.UnRegister(onEvent); - } - - #region 生命周期 - - public virtual void OnActive() - { - } - - public virtual bool OnInit() - { - return true; - } - - public virtual void OnDestroy() - { - } - - public virtual void OnStart() - { - } - - public virtual void OnUpdate() - { - if (_updateSystems != null) - { - foreach (var system in _updateSystems) - { - system.OnUpdate(); - } - } - } - - public virtual void OnLateUpdate() - { - if (_lateUpdateSystems != null) - { - foreach (var system in _lateUpdateSystems) - { - system.OnLateUpdate(); - } - } - } - - public virtual void OnFixedUpdate() - { - if (_fixedUpdateSystems != null) - { - foreach (var system in _fixedUpdateSystems) - { - system.OnLateUpdate(); - } - } - } - - public virtual void OnRoleLogin() - { - if (_roleLoginSystems != null) - { - foreach (var system in _roleLoginSystems) - { - system.OnRoleLogin(); - } - } - } - - public virtual void OnRoleLogout() - { - if (_roleLogoutSystems != null) - { - foreach (var system in _roleLogoutSystems) - { - system.OnRoleLogout(); - } - } - } - - public virtual void OnDrawGizmos() - { - } - - public virtual void OnApplicationPause(bool pause) - { - } - - #endregion - } - - public interface IArchitecture - { - void RegisterSystem(T system) where T : ISystem; - - void RegisterModel(T model) where T : IModel; - - void RegisterUtility(T utility) where T : IUtility; - - T GetSystem() where T : class, ISystem; - - T GetModel() where T : class, IModel; - - T GetUtility() where T : class, IUtility; - - void SendCommand() where T : ICommand, new(); - - void SendCommand(T command) where T : ICommand; - - TResult SendQuery(IQuery query); - - void SendEvent() where T : new(); - - void SendEvent(T e); - - IUnRegister RegisterEvent(Action onEvent); - - void UnRegisterEvent(Action onEvent); - } - - public interface IOnEvent - { - void OnEvent(T e); - } - - public static class OnGlobalEventExtension - { - public static IUnRegister RegisterEvent(this IOnEvent self) where T : struct - { - return TypeEventSystem.Global.Register(self.OnEvent); - } - - public static void UnRegisterEvent(this IOnEvent self) where T : struct - { - TypeEventSystem.Global.UnRegister(self.OnEvent); - } - } - - #endregion - - #region Controller - - public interface IController : IBelongToArchitecture, ICanSendCommand, ICanGetSystem, ICanGetModel, - ICanRegisterEvent, ICanSendQuery - { - } - - #endregion - - #region System - - public interface ISystem : IBelongToArchitecture, ICanSetArchitecture, ICanGetModel, ICanGetUtility, - ICanRegisterEvent, ICanSendEvent, ICanGetSystem - { - void Init(); - } - - abstract class SubSystem : ISystem, ILogicSys - { - private IArchitecture _architecture; - - IArchitecture IBelongToArchitecture.GetArchitecture() - { - return _architecture; - } - - void ICanSetArchitecture.SetArchitecture(IArchitecture architecture) - { - _architecture = architecture; - } - - void ISystem.Init() - { - OnInit(); - } - - protected abstract void OnInit(); - - public virtual void OnDestroy() - { - } - - public virtual void OnStart() - { - } - - public virtual void OnUpdate() - { - } - - public virtual void OnLateUpdate() - { - } - - public virtual void OnFixedUpdate() - { - } - - public virtual void OnRoleLogin() - { - } - - public virtual void OnRoleLogout() - { - } - - public virtual void OnDrawGizmos() - { - } - - public virtual void OnApplicationPause(bool pause) - { - } - - bool ILogicSys.OnInit() - { - return true; - } - } - - #endregion - - #region Model - - public interface IModel : IBelongToArchitecture, ICanSetArchitecture, ICanGetUtility, ICanSendEvent - { - void Init(); - } - - public abstract class AbstractModel : IModel - { - private IArchitecture _architecture; - - IArchitecture IBelongToArchitecture.GetArchitecture() - { - return _architecture; - } - - void ICanSetArchitecture.SetArchitecture(IArchitecture architecture) - { - _architecture = architecture; - } - - void IModel.Init() - { - OnInit(); - } - - protected abstract void OnInit(); - } - - #endregion - - #region Utility - - public interface IUtility - { - } - - #endregion - - #region Command - - public interface ICommand : IBelongToArchitecture, ICanSetArchitecture, ICanGetSystem, ICanGetModel, ICanGetUtility, - ICanSendEvent, ICanSendCommand, ICanSendQuery - { - void Execute(); - } - - public abstract class AbstractCommand : ICommand - { - private IArchitecture _architecture; - - IArchitecture IBelongToArchitecture.GetArchitecture() - { - return _architecture; - } - - void ICanSetArchitecture.SetArchitecture(IArchitecture architecture) - { - _architecture = architecture; - } - - void ICommand.Execute() - { - OnExecute(); - } - - protected abstract void OnExecute(); - } - - #endregion - - #region Query - - public interface IQuery : IBelongToArchitecture, ICanSetArchitecture, ICanGetModel, ICanGetSystem, - ICanSendQuery - { - TResult Do(); - } - - public abstract class AbstractQuery : IQuery - { - public T Do() - { - return OnDo(); - } - - protected abstract T OnDo(); - - - private IArchitecture _architecture; - - public IArchitecture GetArchitecture() - { - return _architecture; - } - - public void SetArchitecture(IArchitecture architecture) - { - _architecture = architecture; - } - } - - #endregion - - #region Rule - - public interface IBelongToArchitecture - { - IArchitecture GetArchitecture(); - } - - public interface ICanSetArchitecture - { - void SetArchitecture(IArchitecture architecture); - } - - public interface ICanGetModel : IBelongToArchitecture - { - } - - public static class CanGetModelExtension - { - public static T GetModel(this ICanGetModel self) where T : class, IModel - { - return self.GetArchitecture().GetModel(); - } - } - - public interface ICanGetSystem : IBelongToArchitecture - { - } - - public static class CanGetSystemExtension - { - public static T GetSystem(this ICanGetSystem self) where T : class, ISystem - { - return self.GetArchitecture().GetSystem(); - } - } - - public interface ICanGetUtility : IBelongToArchitecture - { - } - - public static class CanGetUtilityExtension - { - public static T GetUtility(this ICanGetUtility self) where T : class, IUtility - { - return self.GetArchitecture().GetUtility(); - } - } - - public interface ICanRegisterEvent : IBelongToArchitecture - { - } - - public static class CanRegisterEventExtension - { - public static IUnRegister RegisterEvent(this ICanRegisterEvent self, Action onEvent) - { - return self.GetArchitecture().RegisterEvent(onEvent); - } - - public static void UnRegisterEvent(this ICanRegisterEvent self, Action onEvent) - { - self.GetArchitecture().UnRegisterEvent(onEvent); - } - } - - public interface ICanSendCommand : IBelongToArchitecture - { - } - - public static class CanSendCommandExtension - { - public static void SendCommand(this ICanSendCommand self) where T : ICommand, new() - { - self.GetArchitecture().SendCommand(); - } - - public static void SendCommand(this ICanSendCommand self, T command) where T : ICommand - { - self.GetArchitecture().SendCommand(command); - } - } - - public interface ICanSendEvent : IBelongToArchitecture - { - } - - public static class CanSendEventExtension - { - public static void SendEvent(this ICanSendEvent self) where T : new() - { - self.GetArchitecture().SendEvent(); - } - - public static void SendEvent(this ICanSendEvent self, T e) - { - self.GetArchitecture().SendEvent(e); - } - } - - public interface ICanSendQuery : IBelongToArchitecture - { - } - - public static class CanSendQueryExtension - { - public static TResult SendQuery(this ICanSendQuery self, IQuery query) - { - return self.GetArchitecture().SendQuery(query); - } - } - - #endregion - - #region TypeEventSystem - - public interface IUnRegister - { - void UnRegister(); - } - - public interface IUnRegisterList - { - List UnregisterList { get; } - } - - public static class UnRegisterListExtension - { - public static void AddToUnregisterList(this IUnRegister self, IUnRegisterList unRegisterList) - { - unRegisterList.UnregisterList.Add(self); - } - - public static void UnRegisterAll(this IUnRegisterList self) - { - foreach (var unRegister in self.UnregisterList) - { - unRegister.UnRegister(); - } - - self.UnregisterList.Clear(); - } - } - - /// - /// 自定义可注销的类 - /// - public struct CustomUnRegister : IUnRegister - { - /// - /// 委托对象 - /// - private Action _onUnRegister; - - /// - /// 带参构造函数 - /// - /// - public CustomUnRegister(Action onUnRegister) - { - _onUnRegister = onUnRegister; - } - - /// - /// 资源释放 - /// - public void UnRegister() - { - _onUnRegister.Invoke(); - _onUnRegister = null; - } - } - - public class UnRegisterOnDestroyTrigger : MonoBehaviour - { - private readonly HashSet _unRegisters = new HashSet(); - - public void AddUnRegister(IUnRegister unRegister) - { - _unRegisters.Add(unRegister); - } - - public void RemoveUnRegister(IUnRegister unRegister) - { - _unRegisters.Remove(unRegister); - } - - private void OnDestroy() - { - foreach (var unRegister in _unRegisters) - { - unRegister.UnRegister(); - } - - _unRegisters.Clear(); - } - } - - public static class UnRegisterExtension - { - public static IUnRegister UnRegisterWhenGameObjectDestroyed(this IUnRegister unRegister, GameObject gameObject) - { - var trigger = gameObject.GetComponent(); - - if (!trigger) - { - trigger = gameObject.AddComponent(); - } - - trigger.AddUnRegister(unRegister); - - return unRegister; - } - } - - public class TypeEventSystem - { - private readonly EasyEvents _events = new EasyEvents(); - - - public static readonly TypeEventSystem Global = new TypeEventSystem(); - - public void Send() where T : new() - { - var eventInfo = _events.GetEvent>(); - if (eventInfo != null) - { - eventInfo.Trigger(new T()); - } - } - - public void Send(T e) - { - var eventInfo = _events.GetEvent>(); - if (eventInfo != null) - { - eventInfo.Trigger(e); - } - } - - public IUnRegister Register(Action onEvent) - { - var e = _events.GetOrAddEvent>(); - return e.Register(onEvent); - } - - public void UnRegister(Action onEvent) - { - var e = _events.GetEvent>(); - if (e != null) - { - e.UnRegister(onEvent); - } - } - } - - #endregion - - #region Redux - - public class Container - { - private readonly Dictionary _instances = new Dictionary(); - - public void Register(T instance) - { - var key = typeof(T); - - if (_instances.ContainsKey(key)) - { - _instances[key] = instance; - } - else - { - _instances.Add(key, instance); - } - } - - public T Get() where T : class - { - var key = typeof(T); - - object ret; - if (_instances.TryGetValue(key, out ret)) - { - return ret as T; - } - - return null; - } - } - - #endregion - - #region BindableProperty - - public interface IBindableProperty : IReadonlyBindableProperty - { - new T Value { get; set; } - void SetValueWithoutEvent(T newValue); - } - - public interface IReadonlyBindableProperty - { - T Value { get; } - - IUnRegister RegisterWithInitValue(Action action); - void UnRegister(Action onValueChanged); - IUnRegister Register(Action onValueChanged); - } - - public abstract class BindAbleProperty : IBindableProperty - { - public BindAbleProperty(T defaultValue = default(T)) - { - _value = defaultValue; - } - - protected T _value; - - public T Value - { - get { return GetValue(); } - set - { - if (value == null && _value == null) return; - if (value != null && value.Equals(_value)) return; - - SetValue(value); - if (_onValueChanged != null) - { - _onValueChanged.Invoke(value); - } - } - } - - protected virtual void SetValue(T newValue) - { - _value = newValue; - } - - protected virtual T GetValue() - { - return _value; - } - - public void SetValueWithoutEvent(T newValue) - { - _value = newValue; - } - - private Action _onValueChanged = v => { }; - - public IUnRegister Register(Action onValueChanged) - { - _onValueChanged += onValueChanged; - return new BindablePropertyUnRegister() - { - BindAbleProperty = this, - OnValueChanged = onValueChanged - }; - } - - public IUnRegister RegisterWithInitValue(Action onValueChanged) - { - onValueChanged(_value); - return Register(onValueChanged); - } - - public static implicit operator T(BindAbleProperty property) - { - return property.Value; - } - - public override string ToString() - { - return Value.ToString(); - } - - public void UnRegister(Action onValueChanged) - { - _onValueChanged -= onValueChanged; - } - } - - public class BindablePropertyUnRegister : IUnRegister - { - public BindAbleProperty BindAbleProperty { get; set; } - - public Action OnValueChanged { get; set; } - - public void UnRegister() - { - BindAbleProperty.UnRegister(OnValueChanged); - - BindAbleProperty = null; - OnValueChanged = null; - } - } - - #endregion - - #region EasyEvent - - public interface IEasyEvent - { - } - - public class EasyEvent : IEasyEvent - { - private Action _onEvent = () => { }; - - public IUnRegister Register(Action onEvent) - { - _onEvent += onEvent; - return new CustomUnRegister(() => { UnRegister(onEvent); }); - } - - public void UnRegister(Action onEvent) - { - _onEvent -= onEvent; - } - - public void Trigger() - { - if (_onEvent != null) - { - _onEvent.Invoke(); - } - } - } - - public class EasyEvent : IEasyEvent - { - private Action _onEvent = e => { }; - - public IUnRegister Register(Action onEvent) - { - _onEvent += onEvent; - return new CustomUnRegister(() => { UnRegister(onEvent); }); - } - - public void UnRegister(Action onEvent) - { - _onEvent -= onEvent; - } - - public void Trigger(T t) - { - if (_onEvent != null) - { - _onEvent.Invoke(t); - } - } - } - - public class EasyEvent : IEasyEvent - { - private Action _onEvent = (t, k) => { }; - - public IUnRegister Register(Action onEvent) - { - _onEvent += onEvent; - return new CustomUnRegister(() => { UnRegister(onEvent); }); - } - - public void UnRegister(Action onEvent) - { - _onEvent -= onEvent; - } - - public void Trigger(T t, K k) - { - if (_onEvent != null) - { - _onEvent.Invoke(t, k); - } - } - } - - public class EasyEvent : IEasyEvent - { - private Action _onEvent = (t, k, s) => { }; - - public IUnRegister Register(Action onEvent) - { - _onEvent += onEvent; - return new CustomUnRegister(() => { UnRegister(onEvent); }); - } - - public void UnRegister(Action onEvent) - { - _onEvent -= onEvent; - } - - public void Trigger(T t, K k, S s) - { - if (_onEvent != null) - { - _onEvent.Invoke(t, k, s); - } - } - } - - public class EasyEvents - { - private static readonly EasyEvents GlobalEvents = new EasyEvents(); - - public static T Get() where T : IEasyEvent - { - return GlobalEvents.GetEvent(); - } - - - public static void Register() where T : IEasyEvent, new() - { - GlobalEvents.AddEvent(); - } - - private readonly Dictionary _typeEvents = new Dictionary(); - - public void AddEvent() where T : IEasyEvent, new() - { - _typeEvents.Add(typeof(T), new T()); - } - - public T GetEvent() where T : IEasyEvent - { - IEasyEvent e; - - if (_typeEvents.TryGetValue(typeof(T), out e)) - { - return (T)e; - } - - return default(T); - } - - public T GetOrAddEvent() where T : IEasyEvent, new() - { - var eType = typeof(T); - IEasyEvent e; - if (_typeEvents.TryGetValue(eType, out e)) - { - return (T)e; - } - - var t = new T(); - _typeEvents.Add(eType, t); - return t; - } - } - - #endregion -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameBase/Redux.cs.meta b/Assets/GameScripts/HotFix/GameBase/Redux.cs.meta deleted file mode 100644 index 82889665..00000000 --- a/Assets/GameScripts/HotFix/GameBase/Redux.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 464445719fff48a78021df4a4a6b05a5 -timeCreated: 1684552621 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameBase/Singleton.meta b/Assets/GameScripts/HotFix/GameBase/Singleton.meta deleted file mode 100644 index 614abc11..00000000 --- a/Assets/GameScripts/HotFix/GameBase/Singleton.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 00565f0d362f4c36836804455e19c3df -timeCreated: 1681990210 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameBase/Singleton/TSingleton.cs b/Assets/GameScripts/HotFix/GameBase/Singleton/TSingleton.cs deleted file mode 100644 index d6e2a5d1..00000000 --- a/Assets/GameScripts/HotFix/GameBase/Singleton/TSingleton.cs +++ /dev/null @@ -1,214 +0,0 @@ -using System.Collections.Generic; -using TEngine; -using UnityEngine; -using UnityEngine.SceneManagement; - -namespace GameBase -{ - /// - /// 单例接口。 - /// - public interface ISingleton - { - void Active(); - - void Release(); - } - - /// - /// 单例管理器(统一化持久和释放)。 - /// - public static class SingletonMgr - { - private static List _singletonList; - private static Dictionary _gameObjects; - private static GameObject _root; - - public static GameObject Root - { - get - { - if (_root == null) - { - _root = GameObject.Find("[GameModule]"); - - if (_root == null) - { - _root = new GameObject("[GameModule]") - { - transform = - { - position = Vector3.zero - } - }; - } - Object.DontDestroyOnLoad(_root); - } - return _root; - } - } - - public static void Retain(ISingleton go) - { - if (_singletonList == null) - { - _singletonList = new List(); - } - - _singletonList.Add(go); - } - - public static void Retain(GameObject go) - { - if (_gameObjects == null) - { - _gameObjects = new Dictionary(); - } - - if (!_gameObjects.ContainsKey(go.name)) - { - _gameObjects.Add(go.name, go); - if (Application.isPlaying) - { - Object.DontDestroyOnLoad(go); - } - } - } - - public static void Release(GameObject go) - { - if (_gameObjects != null && _gameObjects.ContainsKey(go.name)) - { - _gameObjects.Remove(go.name); - Object.Destroy(go); - } - } - - public static void Release(ISingleton go) - { - if (_singletonList != null && _singletonList.Contains(go)) - { - _singletonList.Remove(go); - } - } - - public static void Release() - { - if (_gameObjects != null) - { - foreach (var item in _gameObjects) - { - UnityEngine.Object.Destroy(item.Value); - } - - _gameObjects.Clear(); - } - - if (_singletonList != null) - { - for (int i = 0; i < _singletonList.Count; ++i) - { - _singletonList[i].Release(); - } - - _singletonList.Clear(); - } - - Resources.UnloadUnusedAssets(); - } - - public static GameObject GetGameObject(string name) - { - GameObject go = null; - if (_gameObjects != null) - { - _gameObjects.TryGetValue(name, out go); - } - - return go; - } - - internal static bool ContainsKey(string name) - { - if (_gameObjects != null) - { - return _gameObjects.ContainsKey(name); - } - - return false; - } - - internal static ISingleton GetSingleton(string name) - { - for (int i = 0; i < _singletonList.Count; ++i) - { - if (_singletonList[i].ToString() == name) - { - return _singletonList[i]; - } - } - - return null; - } - - /// - /// 释放所有单例。 - /// - public static void ReStart() - { - Release(); - - SceneManager.LoadScene(0); - } - } - - /// - /// 全局单例对象(非线程安全)。 - /// - /// 泛型T。 - public abstract class TSingleton : ISingleton where T : TSingleton, new() - { - private static T _instance; - - public static T Instance - { - get - { - if (null == _instance) - { - _instance = new T(); - _instance.Init(); -#if UNITY_EDITOR - Log.Info($"TSingleton Instance:{typeof(T).Name}"); -#endif - SingletonMgr.Retain(_instance); - } - - return _instance; - } - } - - public static bool IsValid => _instance != null; - - protected TSingleton() - { - } - - protected virtual void Init() - { - } - - public virtual void Active() - { - } - - public virtual void Release() - { - if (_instance != null) - { - SingletonMgr.Release(_instance); - _instance = null; - } - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameBase/Singleton/TSingleton.cs.meta b/Assets/GameScripts/HotFix/GameBase/Singleton/TSingleton.cs.meta deleted file mode 100644 index 70380313..00000000 --- a/Assets/GameScripts/HotFix/GameBase/Singleton/TSingleton.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: aa2cb5bb622045d7a6f2a4c4faea3ca6 -timeCreated: 1681989590 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameBase/Singleton/UnitySingleton.cs b/Assets/GameScripts/HotFix/GameBase/Singleton/UnitySingleton.cs deleted file mode 100644 index abc92311..00000000 --- a/Assets/GameScripts/HotFix/GameBase/Singleton/UnitySingleton.cs +++ /dev/null @@ -1,114 +0,0 @@ -using TEngine; -using UnityEngine; - -namespace GameBase -{ - /// - /// 具备Unity完整生命周期的单例。 - /// - /// - public abstract class UnitySingleton : MonoBehaviour where T : MonoBehaviour - { - private static T _instance; - - public static T Instance - { - get - { - if (_instance == null) - { - var ins = FindObjectOfType(); - if (ins != null) - { - var obj = ins.gameObject; - obj.name = typeof(T).Name; - _instance = ins; - SingletonMgr.Retain(obj); - return Instance; - } - - System.Type thisType = typeof(T); - string instName = thisType.Name; - GameObject go = SingletonMgr.GetGameObject(instName); - if (go == null) - { - go = GameObject.Find($"[{instName}]"); - if (go == null) - { - go = new GameObject($"[{instName}]") - { - transform = - { - position = Vector3.zero - } - }; - } - } - - _instance = go.GetComponent(); - if (_instance == null) - { - _instance = go.AddComponent(); - } - - if (_instance == null) - { - Log.Error($"Can't create UnitySingleton<{typeof(T)}>"); - } - } - - return _instance; - } - } - - public static T Active() - { - return Instance; - } - - public static bool IsValid => _instance != null; - - private bool CheckInstance() - { - if (this == Instance) - { - return true; - } - - GameObject.Destroy(gameObject); - return false; - } - - protected virtual void OnLoad() - { - } - - public virtual void Awake() - { - if (CheckInstance()) - { - OnLoad(); - } -#if UNITY_EDITOR - Log.Debug($"UnitySingleton Instance:{typeof(T).Name}"); -#endif - GameObject tEngine = SingletonMgr.Root; - if (tEngine != null) - { - this.gameObject.transform.SetParent(tEngine.transform); - } - } - - protected virtual void OnDestroy() - { - Release(); - } - - public static void Release() - { - if (_instance == null) return; - SingletonMgr.Release(_instance.gameObject); - _instance = null; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameBase/Singleton/UnitySingleton.cs.meta b/Assets/GameScripts/HotFix/GameBase/Singleton/UnitySingleton.cs.meta deleted file mode 100644 index c0330e3f..00000000 --- a/Assets/GameScripts/HotFix/GameBase/Singleton/UnitySingleton.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 25c99243aa534df5870e36fdf9d36afd -timeCreated: 1681990223 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/Camera.meta b/Assets/GameScripts/HotFix/GameLogic/Camera.meta deleted file mode 100644 index e205f55f..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/Camera.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 1d862c80fdc1e684e8ff3b6ae7707b79 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/GameLogic/Camera/CameraUtils.cs b/Assets/GameScripts/HotFix/GameLogic/Camera/CameraUtils.cs deleted file mode 100644 index 6afe6eae..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/Camera/CameraUtils.cs +++ /dev/null @@ -1,24 +0,0 @@ -using TEngine; -using UnityEngine; -#if ENABLE_URP -using UnityEngine.Rendering.Universal; -#endif - -namespace GameLogic -{ - public class CameraUtils - { - public static void AddCameraStack(Camera camera,Camera mainCamera) - { -#if ENABLE_URP - if (mainCamera != null) - { - // 通过脚本的方式,只要能找到 camera 不轮是否跨 base 相机的场景,都可以 Add 进 Stack - mainCamera.GetComponent().cameraStack.Add(GameModule.UI.UICamera); - } -#else - Log.Fatal("Could not add camera stack because had no URP-Render-Pip"); -#endif - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/Camera/CameraUtils.cs.meta b/Assets/GameScripts/HotFix/GameLogic/Camera/CameraUtils.cs.meta deleted file mode 100644 index f6aeea1f..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/Camera/CameraUtils.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6375b5490bbdcc145a24706a6c4e9cb7 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/GameLogic/DataCenter.meta b/Assets/GameScripts/HotFix/GameLogic/DataCenter.meta deleted file mode 100644 index 72a51642..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/DataCenter.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 7de46f8a9c58a584289bbc481e85271a -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/GameLogic/DataCenter/DataCenterModule.cs b/Assets/GameScripts/HotFix/GameLogic/DataCenter/DataCenterModule.cs deleted file mode 100644 index 2d9270c4..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/DataCenter/DataCenterModule.cs +++ /dev/null @@ -1,58 +0,0 @@ -using TEngine; - -namespace GameLogic -{ - public interface IDataCenterModule - { - void Init(); - - void OnRoleLogin(); - - void OnRoleLogout(); - - void OnUpdate(); - - void OnMainPlayerMapChange(); - } - public class DataCenterModule : IDataCenterModule where T : new() - { - private static T _instance; - public static T Instance - { - get - { - if (null == _instance) - { - _instance = new T(); - Log.Assert(_instance != null); - } - return _instance; - } - } - - public virtual void Init() - { - - } - - public virtual void OnRoleLogin() - { - - } - - public virtual void OnRoleLogout() - { - - } - - public virtual void OnUpdate() - { - - } - - public virtual void OnMainPlayerMapChange() - { - - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/DataCenter/DataCenterModule.cs.meta b/Assets/GameScripts/HotFix/GameLogic/DataCenter/DataCenterModule.cs.meta deleted file mode 100644 index 579590b4..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/DataCenter/DataCenterModule.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 1ef4b9e7ceb44a37b83ee7bca1726d93 -timeCreated: 1689248879 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/DataCenter/DataCenterSys.cs b/Assets/GameScripts/HotFix/GameLogic/DataCenter/DataCenterSys.cs deleted file mode 100644 index f8d730b2..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/DataCenter/DataCenterSys.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System.Collections.Generic; -using TEngine; - -namespace GameLogic -{ - /// - /// 数据中心模块。 - /// - public class DataCenterSys : BaseLogicSys - { - /// - /// 子模块集合。 - /// - private readonly List _listModule = new List(); - - /// - /// 初始化数据中心。 - /// - /// - public override bool OnInit() - { - InitModule(); - InitOtherModule(); - return true; - } - - /// - /// 初始化数据中心接口。 - /// - /// - public void InitModule(IDataCenterModule module) - { - if (_listModule.Contains(module)) - { - return; - } - module.Init(); - _listModule.Add(module); - } - - /// - /// 初始化数据中心模块。 - /// - void InitModule() - { - InitModule(PlayerNetSys.Instance); - } - - /// - /// 初始化数据中心其他模块。 - /// 优先级低于InitModule。 - /// - void InitOtherModule() - { - - } - - /// - /// 帧更新驱动。 - /// - public override void OnUpdate() - { - var listModule = _listModule; - foreach (var module in listModule) - { - TProfiler.BeginSample(module.GetType().FullName); - module.OnUpdate(); - TProfiler.EndSample(); - } - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/DataCenter/DataCenterSys.cs.meta b/Assets/GameScripts/HotFix/GameLogic/DataCenter/DataCenterSys.cs.meta deleted file mode 100644 index cefc9d01..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/DataCenter/DataCenterSys.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 11af3015e673484a89ea388dbb2dc2cb -timeCreated: 1689248848 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/DataCenter/GameClient.cs b/Assets/GameScripts/HotFix/GameLogic/DataCenter/GameClient.cs deleted file mode 100644 index 07d9d393..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/DataCenter/GameClient.cs +++ /dev/null @@ -1,156 +0,0 @@ -using System; -using System.IO; -using GameBase; -using TEngine; -using TEngine.Core.Network; - -namespace GameLogic -{ - /// - /// 网络客户端状态。 - /// - public enum GameClientStatus - { - /// - /// 初始化。 - /// - StatusInit, - /// - /// 连接成功服务器。 - /// - StatusConnected, - /// - /// 重新连接。 - /// - StatusReconnect, - /// - /// 断开连接。 - /// - StatusClose, - /// - /// 登录中。 - /// - StatusLogin, - /// - /// AccountLogin成功,进入服务器了。 - /// - StatusEnter, - } - - /// - /// 网络客户端。 - /// - public class GameClient:Singleton - { - public readonly NetworkProtocolType ProtocolType = NetworkProtocolType.KCP; - public GameClientStatus Status { get; set; } = GameClientStatus.StatusInit; - public Scene Scene { private set; get; } - - private string _lastAddress = String.Empty; - - public GameClient() - { - Scene = GameApp.Instance.Scene; - } - - public void Connect(string address, bool reconnect = false) - { - if (Status == GameClientStatus.StatusConnected || Status == GameClientStatus.StatusLogin || Status == GameClientStatus.StatusEnter) - { - return; - } - if (!reconnect) - { - // SetWatchReconnect(false); - } - - if (reconnect) - { - // GameEvent.Get().ShowWaitUITip(WaitUISeq.LOGINWORLD_SEQID, G.R(TextDefine.ID_TIPS_RECONNECTING)); - } - else - { - // GameEvent.Get().ShowWaitUI(WaitUISeq.LOGINWORLD_SEQID); - } - - _lastAddress = address; - - Status = reconnect ? GameClientStatus.StatusReconnect : GameClientStatus.StatusInit; - - if (Scene.Session == null || Scene.Session.IsDisposed) - { - Scene.CreateSession(address, ProtocolType, OnConnectComplete, OnConnectFail, OnConnectDisconnect); - } - } - - private void OnConnectComplete() - { - Status = GameClientStatus.StatusConnected; - Log.Info("Connect to server success"); - } - - private void OnConnectFail() - { - Status = GameClientStatus.StatusClose; - Log.Warning("Could not connect to server"); - } - - private void OnConnectDisconnect() - { - Status = GameClientStatus.StatusClose; - Log.Warning("OnConnectDisconnect server"); - } - - public virtual void Send(object message, uint rpcId = 0, long routeId = 0) - { - if (Scene.Session == null) - { - Log.Error("Send Message Failed Because Session Is Null"); - return; - } - Scene.Session.Send(message,rpcId,routeId); - } - - public virtual void Send(IRouteMessage routeMessage, uint rpcId = 0, long routeId = 0) - { - if (Scene.Session == null) - { - Log.Error("Send Message Failed Because Session Is Null"); - return; - } - Scene.Session.Send(routeMessage,rpcId,routeId); - } - - public virtual void Send(MemoryStream memoryStream, uint rpcId = 0, long routeTypeOpCode = 0, long routeId = 0) - { - if (Scene.Session == null) - { - Log.Error("Send Message Failed Because Session Is Null"); - return; - } - Scene.Session.Send(memoryStream,rpcId,routeTypeOpCode,routeId); - } - - public virtual async FTask Call(IRequest request, long routeId = 0) - { - if (Scene == null || Scene.Session == null || Scene.Session.IsDisposed) - { - return null; - } - - var requestCallback = await Scene.Session.Call(request,routeId); - - return requestCallback; - } - - public void RegisterMsgHandler(uint protocolCode,Action ctx) - { - MessageDispatcherSystem.Instance.RegisterMsgHandler(protocolCode,ctx); - } - - public void UnRegisterMsgHandler(uint protocolCode,Action ctx) - { - MessageDispatcherSystem.Instance.UnRegisterMsgHandler(protocolCode,ctx); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/DataCenter/GameClient.cs.meta b/Assets/GameScripts/HotFix/GameLogic/DataCenter/GameClient.cs.meta deleted file mode 100644 index d6e0fd74..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/DataCenter/GameClient.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 346da02ec1b54ce7938cabd8511d4404 -timeCreated: 1689250782 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/DataCenter/NetworkUtils.cs b/Assets/GameScripts/HotFix/GameLogic/DataCenter/NetworkUtils.cs deleted file mode 100644 index 32837e75..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/DataCenter/NetworkUtils.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections.Generic; -using TEngine; -using TEngine.Core.Network; -using TEngine.Logic; - -namespace GameLogic -{ - public class NetworkUtils - { - /// - /// 网络消息校验错误码。 - /// - /// 网络回复消息包。 - /// 是否存在错误。 - public static bool CheckError(IResponse response) - { - bool hasError = false; - if (response == null) - { - // TODO 根据错误码Tips提示。 - // var networkError = "NetWork Response Error"; - hasError = true; - } - else - { - hasError = response.ErrorCode != 0; - if (ErrCodeTextMap.TryGetValue(response.ErrorCode,out var ret)) - { - Log.Error(ret); - } - } - - return hasError; - } - - //Remark 这里图方便注册错误码文本,正常应该走文本配置表。 - public static Dictionary ErrCodeTextMap = new Dictionary - { - { - ErrorCode.ERR_AccountAlreadyRegisted, "账户已经被注册了" - }, - { - ErrorCode.ERR_AccountOrPasswordError, "账户或者密码错误" - }, - { - ErrorCode.ERR_UserNotOnline, "用户当前不在线" - }, - }; - } -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/DataCenter/NetworkUtils.cs.meta b/Assets/GameScripts/HotFix/GameLogic/DataCenter/NetworkUtils.cs.meta deleted file mode 100644 index 343e949f..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/DataCenter/NetworkUtils.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4c373208f2ca4f28b35a28434a3b1103 -timeCreated: 1689262967 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/GameApp_RegisterSystem.cs b/Assets/GameScripts/HotFix/GameLogic/GameApp_RegisterSystem.cs deleted file mode 100644 index c9b51da3..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/GameApp_RegisterSystem.cs +++ /dev/null @@ -1,73 +0,0 @@ -using System.Collections.Generic; -using GameLogic; -using TEngine; -using TEngine.Core; - -public partial class GameApp -{ - private List _listLogicMgr; - - private void Init() - { - _listLogicMgr = new List(); - RegisterAllSystem(); - InitSystemSetting(); - } - - /// - /// 设置一些通用的系统属性。 - /// - private void InitSystemSetting() - { - - } - - /// - /// Entity框架根节点。 - /// - public Scene Scene { private set; get; } - - /// - /// 注册所有逻辑系统 - /// - private void RegisterAllSystem() - { - Scene = GameSystem.Init(); - if (_hotfixAssembly != null) - { - AssemblyManager.Load(AssemblyName.GameBase, _hotfixAssembly.Find(t=>t.FullName.Contains("GameBase"))); - AssemblyManager.Load(AssemblyName.GameProto, _hotfixAssembly.Find(t=>t.FullName.Contains("GameProto"))); - AssemblyManager.Load(AssemblyName.GameLogic, GetType().Assembly); - } - - //带生命周期的单例系统。 - AddLogicSys(BehaviourSingleSystem.Instance); - AddLogicSys(DataCenterSys.Instance); - AddLogicSys(ConfigSystem.Instance); - GMBehaviourSystem.Instance.Active(); - } - - /// - /// 注册逻辑系统。 - /// - /// ILogicSys - /// - protected bool AddLogicSys(ILogicSys logicSys) - { - if (_listLogicMgr.Contains(logicSys)) - { - Log.Fatal("Repeat add logic system: {0}", logicSys.GetType().Name); - return false; - } - - if (!logicSys.OnInit()) - { - Log.Fatal("{0} Init failed", logicSys.GetType().Name); - return false; - } - - _listLogicMgr.Add(logicSys); - - return true; - } -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/GameApp_RegisterSystem.cs.meta b/Assets/GameScripts/HotFix/GameLogic/GameApp_RegisterSystem.cs.meta deleted file mode 100644 index cdd54db0..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/GameApp_RegisterSystem.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4703541a565f5ec4bb35edd81c28958c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/GameLogic/GameLogic.asmdef b/Assets/GameScripts/HotFix/GameLogic/GameLogic.asmdef deleted file mode 100644 index b1c0e3aa..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/GameLogic.asmdef +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "GameLogic", - "rootNamespace": "GameLogic", - "references": [ - "GUID:08c3762f54316454ca6b6fbcb22b40e5", - "GUID:a90b2d3377c5e4a4db95cc44fb82045e", - "GUID:aa06d4cc755c979489c256c1bcca1dfb", - "GUID:641632c4f8079b94f963b5284d859a12", - "GUID:6055be8ebefd69e48b49212b09b47b2f", - "GUID:15fc0a57446b3144c949da3e2b9737a9", - "GUID:ecba4a58c7f7a4842b72ce2c77aecf9b" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": true, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [ - { - "name": "com.unity.render-pipelines.universal", - "expression": "", - "define": "ENABLE_URP" - } - ], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo.meta b/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo.meta deleted file mode 100644 index 23f2f84b..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: fd38f6cec6fb1864596745f8fc7067d8 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/Examples.meta b/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/Examples.meta deleted file mode 100644 index 82e78b81..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/Examples.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 1eb758ad0d305e74887aa3105613ee86 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/Examples/Network.meta b/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/Examples/Network.meta deleted file mode 100644 index 73a8a048..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/Examples/Network.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: a1635fbfe42afd046bb9c80f635f5edd -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/Examples/Network/UIEntry.cs b/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/Examples/Network/UIEntry.cs deleted file mode 100644 index 9877305c..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/Examples/Network/UIEntry.cs +++ /dev/null @@ -1,273 +0,0 @@ -using System; -using System.Collections; -using TEngine.Core.Network; -using TEngine.Core; -using TEngine.Logic; -using UnityEngine; -using UnityEngine.UI; - -#pragma warning disable CS0436 - -namespace TEngine.Demo -{ - public class UIEntry : MonoBehaviour - { - public Scene Scene; - public bool IsConnect; - public bool IsLoginAddress; - - public Text Message; - public Button SendButton; - public Button SendRPCButton; - public Button ReceiveButton; - public Button SendAddressButton; - public Button SendAddressRPCButton; - public Button ReceiveAddressButton; - public Button ConnentServerButton; - public Button LoginAddressButton; - - IEnumerator Start() - { - yield return new WaitForSeconds(2f); - // 框架初始化 - // Scene = GameSystem.Init(); - // 把当前工程的程序集装载到框架中、这样框架才会正常的操作 - // demo里是把unity自带的程序集加载到框架中了 - // 如果你有多个工程、可以多次调用AssemblyManager.Load把其他工程装载下 - // 可以通过ab包来加载工程dll、也可以通过引用方式来拿到程序集加载 - // 装载后例如网络协议等一些框架提供的功能就可以使用了、如果不装载就没办法使用 - // AssemblyManager.Load(233, this.GetType().Assembly); - // 给Scene挂在一个组件、用来记录下操作提示UI的组件、方便后面使用 - Scene = GameApp.Instance.Scene; - var networkEntryComponent = Scene.AddComponent(); - networkEntryComponent.Action = LogDebug; - // 到这里为止框架就配置完成了 - // 下面是给每个按钮增加事件、不属于框架的部分了 - SendButton.onClick.AddListener(OnSendButtonClick); - SendRPCButton.onClick.AddListener(() => OnSendRPCButtonClick().Coroutine()); - ReceiveButton.onClick.AddListener(OnReceiveButtonClick); - SendAddressButton.onClick.AddListener(OnSendAddressButtonClick); - SendAddressRPCButton.onClick.AddListener(() => OnSendAddressRPCButtonClick().Coroutine()); - ReceiveAddressButton.onClick.AddListener(OnReceiveAddressButtonClick); - LoginAddressButton.onClick.AddListener(() => OnLoginAddressButtonClick().Coroutine()); - ConnentServerButton.onClick.AddListener(OnConnectServerButtonClick); - } - - private void OnConnectServerButtonClick() - { - // Demo对应服务器的Network解决方案 - // 创建网络连接 - // CreateSession有五个参数: - // remoteAddress:连接的服务器地址 地址在Demo下Config/Excel/Server里四个文件配置出的 - // networkProtocolType:网络协议类型、目前只有TCP和UDP(KCP)这两种 - // onConnectComplete:当跟服务器建立连接后的回调 - // onConnectFail:当网络无法连接或出错时的回调 - // connectTimeout:连接超时时间、默认是5000毫秒 - Scene.CreateSession("127.0.0.1:20000", NetworkProtocolType.KCP, OnConnectComplete, OnConnectFail, OnConnectDisconnect); - // 注意:框架使用的ProtoBuf协议、文件定义的位置在Demo下Config/ProtoBuf/里 - // 生成协议是在服务器工程生成 - // ProtoBuf有三个文件: - // OuterMessage:用于客户端和服务器之间通讯的所有协议都定义到这里 - // InnerMessage:用于服务器之间通讯的协议都定义到这里 - // InnerBsonMessage:用于服务器之间通讯的、但不是使用的ProtoBuf协议、而是用的Bosn格式压缩的 - } - - private void OnConnectComplete() - { - IsConnect = true; - Scene.Session.AddComponent().Start(15000); - LogDebug("已连接到服务器"); - } - - private void OnConnectFail() - { - IsConnect = false; - LogError("无法连接到服务器"); - } - - private void OnConnectDisconnect() - { - IsConnect = false; - LogError("服务器主动断开了连接"); - } - - private void OnSendButtonClick() - { - if (!IsConnect) - { - LogError("没有连接到服务器、请先点击连接到服务器按钮在进行此操作"); - return; - } - - Scene.Session.Send(new H_C2G_Message() - { - Message = "Hello TEngine" - }); - } - - private async FTask OnSendRPCButtonClick() - { - if (!IsConnect) - { - LogError("没有连接到服务器、请先点击连接到服务器按钮在进行此操作"); - return; - } - - var response = (H_G2C_MessageResponse)await Scene.Session.Call(new H_C2G_MessageRequest() - { - Message = "Hello TEngine" - }); - - LogDebug(response.ErrorCode == 0 - ? $"接收到服务器返回的消息:{response.Message}" - : $"发生错误 ErrorCode:{response.ErrorCode}"); - } - - private void OnReceiveButtonClick() - { - if (!IsConnect) - { - LogError("没有连接到服务器、请先点击连接到服务器按钮在进行此操作"); - return; - } - - // 一般服务器推送给客户端消息都是服务器主动的 - // 但demo中服务器没有这样的逻辑 - // 所以发送一个消息告诉服务器、然后服务器在主动推送一个消息给客户端就可以了 - // 虽然这样看起来跟RPC消息很像、但原理是不一样的 - // 客户端怎么接收服务器发送的协议、您可以看下H_G2C_ReceiveMessageToServer这个类 - - Scene.Session.Send(new H_C2G_PushMessageToClient() - { - Message = "请推送一个消息给我" - }); - - LogDebug("请推送一个消息给我"); - } - - private async FTask OnLoginAddressButtonClick() - { - if (!IsConnect) - { - LogError("没有连接到服务器、请先点击连接到服务器按钮在进行此操作"); - return; - } - - var response = (H_G2C_LoginAddressResponse)await Scene.Session.Call(new H_C2G_LoginAddressRequest() - { - Message = "注册Address" - }); - - if (response.ErrorCode == 0) - { - IsLoginAddress = true; - LogDebug("Address 注册完成"); - return; - } - - IsLoginAddress = false; - LogError($"Address 注册失败 ErrorCode:{response.ErrorCode}"); - } - - private void OnSendAddressButtonClick() - { - if (!IsLoginAddress) - { - LogError("没有注册到Address、请先点击注册Address按钮在进行此操作"); - return; - } - - Scene.Session.Send(new H_C2M_Message() - { - Message = "Hello TEngine Address" - }); - - LogDebug("发送成功"); - } - - private async FTask OnSendAddressRPCButtonClick() - { - if (!IsLoginAddress) - { - LogError("没有注册到Address、请先点击注册Address按钮在进行此操作"); - return; - } - - var response = (H_M2C_MessageResponse)await Scene.Session.Call(new H_C2M_MessageRequest() - { - Message = "这里是客户端发送给MAP的一个AddressRPC消息" - }); - - if (response.ErrorCode == 0) - { - LogDebug(response.Message); - return; - } - - LogError($"发送消息失败 ErrorCode:{response.ErrorCode}"); - } - - private void OnReceiveAddressButtonClick() - { - if (!IsLoginAddress) - { - LogError("没有注册到Address、请先点击注册Address按钮在进行此操作"); - return; - } - - Scene.Session.Send(new H_C2M_PushAddressMessageToClient() - { - Message = "请推送一个消息给我" - }); - - LogDebug("请推送一个消息给我"); - } - - private void LogError(string text) - { - Message.text = text; - Log.Error(text); - } - - private void LogDebug(string text) - { - Message.text = text; - Log.Debug(text); - } - } - - /// - /// 这个组件是方便接收服务器推送消息显示在UI上使用 - /// 我这里是方便使用这样定义的、不一定非要这样做 - /// - public class NetworkEntryComponent : Entity - { - public Action Action; - } - - /// - /// 这个是客户端接收服务器的处理程序 - /// - public class H_G2C_ReceiveMessageToServerHandler : Message - { - protected override async FTask Run(Session session, H_G2C_ReceiveMessageToServer message) - { - var networkEntryComponent = session.Scene.GetComponent(); - networkEntryComponent.Action($"收到服务器推送的消息 message:{message.Message}"); - await FTask.CompletedTask; - } - } - - /// - /// 这个是客户端接收服务器的Address消息 - /// - public class H_M2C_ReceiveAddressMessageToServerHandler : Message - { - protected override async FTask Run(Session session, H_M2C_ReceiveAddressMessageToServer message) - { - var networkEntryComponent = session.Scene.GetComponent(); - networkEntryComponent.Action($"收到服务器推送的Address消息 message:{message.Message}"); - await FTask.CompletedTask; - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/Examples/Network/UIEntry.cs.meta b/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/Examples/Network/UIEntry.cs.meta deleted file mode 100644 index 2a968e35..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/Examples/Network/UIEntry.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6a5f5a004bbd54b518b22040219d91e1 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/GM.meta b/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/GM.meta deleted file mode 100644 index 6f2f949e..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/GM.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 71cf7aa692c445beb79177390f6930f4 -timeCreated: 1689594413 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/GM/ClientGm.cs b/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/GM/ClientGm.cs deleted file mode 100644 index 6c070841..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/GM/ClientGm.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System; -using System.Collections.Generic; -using GameBase; -using TEngine; -using UnityEngine; - -namespace GameLogic -{ - public delegate void HandleGM(List @params); - - [Update] - [LateUpdate] - public class GMBehaviourSystem : BehaviourSingleton - { - public override void Active() - { - ClientGm.Instance.Init(); - base.Active(); - } - - public override void Start() - { - base.Start(); - } - - public override void Update() - { - if (Input.GetKeyDown(KeyCode.F1)) - { - GameModule.UI.ShowUIAsync(); - } - } - - public override void LateUpdate() - { - base.LateUpdate(); - } - } - - class ClientGm : Singleton - { - private readonly Dictionary _dictCmd = new Dictionary(); - - //缓存已输入过的命令 - private readonly List _commendList = new List(); - - private GmCmdHandle _cmdHandle; - - public bool debugLowFps = false; - public bool debugNotchScreen = false; - - public void Init() - { - _cmdHandle = new GmCmdHandle(); - _cmdHandle.Init(); - } - - public void HandleClientGm(string gmText) - { - gmText = gmText.Trim(); - - Log.Debug("type: {0}", gmText.GetType().FullName); - - string[] list = gmText.Split(new[] { " " }, Int32.MaxValue, StringSplitOptions.RemoveEmptyEntries); - - Log.Debug("split list count: {0}", list.Length); - - List gmParams = new List(); - - string cmd = list[0]; - for (int i = 1; i < list.Length; i++) - { - string param1 = list[i].Trim(); - if (string.IsNullOrEmpty(param1)) - { - continue; - } - - gmParams.Add(param1); - } - - Log.Warning("ClientGM:{0} param count: {1}", gmText, gmParams.Count); - if (_dictCmd.TryGetValue(cmd, out var value)) - { - value(gmParams); - } - } - - public void RegGmCmd(string cmd, HandleGM handle) - { - if (_dictCmd.ContainsKey(cmd)) - { - Log.Error("repeat cmd: {0}", cmd); - return; - } - - _dictCmd.Add(cmd, handle); - } - - public bool GetCommendByIndex(int index, out string commend) - { - var inRange = false; - commend = string.Empty; - - if (index >= 0 && index < _commendList.Count) - { - inRange = true; - commend = _commendList[index]; - } - - if (index >= _commendList.Count && _commendList.Count > 0) - { - commend = _commendList[0]; - inRange = false; - } - - return inRange; - } - - public void AddCommend(string commend) - { - _commendList.Insert(0, commend); - } - } -} \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/GM/ClientGm.cs.meta b/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/GM/ClientGm.cs.meta deleted file mode 100644 index ba15cad6..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/GM/ClientGm.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 34c3d12352d5407980e7783bb36a29c3 -timeCreated: 1689595424 \ No newline at end of file diff --git a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/GM/GMPanel.cs b/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/GM/GMPanel.cs deleted file mode 100644 index 5ea14600..00000000 --- a/Assets/GameScripts/HotFix/GameLogic/NetWorkDemo/GM/GMPanel.cs +++ /dev/null @@ -1,403 +0,0 @@ -using System; -using System.Collections.Generic; -using GameLogic; -using TEngine; -using TEngine.Core.Network; -using UnityEngine; -using UnityEngine.UI; - -class QuickGmButton -{ - public string m_name; - public Action m_action; - public string m_gmText; - - public QuickGmButton(string name, string gmText, Action action) - { - m_name = name; - m_gmText = gmText; - m_action = action; - } - - public void Action() - { - m_action(m_gmText); - } -} - -[Window(UILayer.Top)] -public class GMPanel : UIWindow -{ - private InputField m_input; - private InputField m_labelResult; // 结果文本 - private Button m_closeBtn; - - #region 常用的命令布局 - - private Transform m_leftBtnGroupRoot; - - ///左侧快捷按钮 - private Transform m_rightBtnGroupRoot; - - ///右侧快捷按钮 - private GameObject m_goTemplateRmdItem; // 推荐图标模板 - - private Text m_openLogLabel; - - #endregion - - #region 常用GM - - private int m_gmCommendindex = 0; - - /// - /// 推荐的GM - /// key => gm名 - /// val => 处理方法 - /// - private List m_listRmdGmLeft = new List(); - - private List m_listRmdGmRight = new List(); - - /// - /// 推荐gm别名 - /// key => gm名 - /// val => 别名 - /// - private Dictionary m_dicGmAlias = new Dictionary(); - - private List ListRmdGmLeft - { - get - { - if (m_listRmdGmLeft.Count < 1) - { - m_listRmdGmLeft.Add(new QuickGmButton("货币大全", "addAllMoney", RmdGmAction_AddAllMoney)); - m_listRmdGmLeft.Add(new QuickGmButton("清理背包", "clearbag", ExcuteGM)); - m_listRmdGmLeft.Add(new QuickGmButton("道具大全", "addItem", RmdGmAction_AddItem)); - m_listRmdGmLeft.Add(new QuickGmButton("装备大全", "", ShowEquipUI)); - m_listRmdGmLeft.Add(new QuickGmButton("清场", "$killall", ExcuteGM)); - } - - return m_listRmdGmLeft; - } - } - - private List ListRmdGmRight - { - get - { - if (m_listRmdGmRight.Count < 1) - { - m_listRmdGmRight.Add(new QuickGmButton("清理面板日志", "", ClearPanel)); - m_listRmdGmRight.Add(new QuickGmButton("查看当前时间", "seetime", ExcuteGM)); - m_listRmdGmRight.Add(new QuickGmButton("还原服务器时间", "settime", ExcuteGM)); - m_listRmdGmRight.Add(new QuickGmButton("服务器时间加24H", "settimeNextDay", SetTimeNextDay)); - m_listRmdGmRight.Add(new QuickGmButton("快一小时", "nexthour", ExcuteGM)); - m_listRmdGmRight.Add(new QuickGmButton("查看属性", "$selfattr", ExcuteGM)); - m_listRmdGmRight.Add(new QuickGmButton("目标属性", "$targetattr", ExcuteGM)); - } - - return m_listRmdGmRight; - } - } - - #endregion - - public override void BindMemberProperty() - { - m_input = FindChildComponent("center/InputText"); - m_labelResult = FindChildComponent("center/Panel/Scroll View/Viewport/Content/InputField"); - m_closeBtn = FindChildComponent