├── .gitignore
├── GameFramework.sln
├── GameFramework
├── Base
│ ├── DataProvider
│ │ ├── DataProvider.cs
│ │ ├── DataProviderCreator.cs
│ │ ├── IDataProvider.cs
│ │ ├── IDataProviderHelper.cs
│ │ ├── ReadDataDependencyAssetEventArgs.cs
│ │ ├── ReadDataFailureEventArgs.cs
│ │ ├── ReadDataSuccessEventArgs.cs
│ │ └── ReadDataUpdateEventArgs.cs
│ ├── DataStruct
│ │ └── TypeNamePair.cs
│ ├── EventPool
│ │ ├── BaseEventArgs.cs
│ │ ├── EventPool.Event.cs
│ │ ├── EventPool.cs
│ │ └── EventPoolMode.cs
│ ├── GameFrameworkAction.cs
│ ├── GameFrameworkEntry.cs
│ ├── GameFrameworkEventArgs.cs
│ ├── GameFrameworkException.cs
│ ├── GameFrameworkFunc.cs
│ ├── GameFrameworkLinkedList.cs
│ ├── GameFrameworkLinkedListRange.cs
│ ├── GameFrameworkModule.cs
│ ├── GameFrameworkMultiDictionary.cs
│ ├── GameFrameworkSerializer.cs
│ ├── Log
│ │ ├── GameFrameworkLog.ILogHelper.cs
│ │ ├── GameFrameworkLog.cs
│ │ └── GameFrameworkLogLevel.cs
│ ├── ReferencePool
│ │ ├── IReference.cs
│ │ ├── ReferencePool.ReferenceCollection.cs
│ │ ├── ReferencePool.cs
│ │ └── ReferencePoolInfo.cs
│ ├── TaskPool
│ │ ├── ITaskAgent.cs
│ │ ├── StartTaskStatus.cs
│ │ ├── TaskBase.cs
│ │ ├── TaskInfo.cs
│ │ ├── TaskPool.cs
│ │ └── TaskStatus.cs
│ ├── Variable
│ │ ├── GenericVariable.cs
│ │ └── Variable.cs
│ └── Version
│ │ ├── Version.IVersionHelper.cs
│ │ └── Version.cs
├── Config
│ ├── ConfigManager.ConfigData.cs
│ ├── ConfigManager.cs
│ ├── IConfigHelper.cs
│ └── IConfigManager.cs
├── DataNode
│ ├── DataNodeManager.DataNode.cs
│ ├── DataNodeManager.cs
│ ├── IDataNode.cs
│ └── IDataNodeManager.cs
├── DataTable
│ ├── DataTableBase.cs
│ ├── DataTableManager.DataTable.cs
│ ├── DataTableManager.cs
│ ├── IDataRow.cs
│ ├── IDataTable.cs
│ ├── IDataTableHelper.cs
│ └── IDataTableManager.cs
├── Debugger
│ ├── DebuggerManager.DebuggerWindowGroup.cs
│ ├── DebuggerManager.cs
│ ├── IDebuggerManager.cs
│ ├── IDebuggerWindow.cs
│ └── IDebuggerWindowGroup.cs
├── Download
│ ├── Constant.cs
│ ├── DownloadAgentHelperCompleteEventArgs.cs
│ ├── DownloadAgentHelperErrorEventArgs.cs
│ ├── DownloadAgentHelperUpdateBytesEventArgs.cs
│ ├── DownloadAgentHelperUpdateLengthEventArgs.cs
│ ├── DownloadFailureEventArgs.cs
│ ├── DownloadManager.DownloadAgent.cs
│ ├── DownloadManager.DownloadCounter.DownloadCounterNode.cs
│ ├── DownloadManager.DownloadCounter.cs
│ ├── DownloadManager.DownloadTask.cs
│ ├── DownloadManager.DownloadTaskStatus.cs
│ ├── DownloadManager.cs
│ ├── DownloadStartEventArgs.cs
│ ├── DownloadSuccessEventArgs.cs
│ ├── DownloadUpdateEventArgs.cs
│ ├── IDownloadAgentHelper.cs
│ └── IDownloadManager.cs
├── Entity
│ ├── EntityManager.EntityGroup.cs
│ ├── EntityManager.EntityInfo.cs
│ ├── EntityManager.EntityInstanceObject.cs
│ ├── EntityManager.EntityStatus.cs
│ ├── EntityManager.ShowEntityInfo.cs
│ ├── EntityManager.cs
│ ├── HideEntityCompleteEventArgs.cs
│ ├── IEntity.cs
│ ├── IEntityGroup.cs
│ ├── IEntityGroupHelper.cs
│ ├── IEntityHelper.cs
│ ├── IEntityManager.cs
│ ├── ShowEntityDependencyAssetEventArgs.cs
│ ├── ShowEntityFailureEventArgs.cs
│ ├── ShowEntitySuccessEventArgs.cs
│ └── ShowEntityUpdateEventArgs.cs
├── Event
│ ├── EventManager.cs
│ ├── GameEventArgs.cs
│ └── IEventManager.cs
├── FileSystem
│ ├── CommonFileSystemStream.cs
│ ├── FileInfo.cs
│ ├── FileSystem.BlockData.cs
│ ├── FileSystem.HeaderData.cs
│ ├── FileSystem.StringData.cs
│ ├── FileSystem.cs
│ ├── FileSystemAccess.cs
│ ├── FileSystemManager.cs
│ ├── FileSystemStream.cs
│ ├── IFileSystem.cs
│ ├── IFileSystemHelper.cs
│ └── IFileSystemManager.cs
├── Fsm
│ ├── Fsm.cs
│ ├── FsmBase.cs
│ ├── FsmManager.cs
│ ├── FsmState.cs
│ ├── IFsm.cs
│ └── IFsmManager.cs
├── GameFramework.csproj
├── Localization
│ ├── ILocalizationHelper.cs
│ ├── ILocalizationManager.cs
│ ├── Language.cs
│ └── LocalizationManager.cs
├── Network
│ ├── AddressFamily.cs
│ ├── INetworkChannel.cs
│ ├── INetworkChannelHelper.cs
│ ├── INetworkManager.cs
│ ├── IPacketHandler.cs
│ ├── IPacketHeader.cs
│ ├── NetworkClosedEventArgs.cs
│ ├── NetworkConnectedEventArgs.cs
│ ├── NetworkCustomErrorEventArgs.cs
│ ├── NetworkErrorCode.cs
│ ├── NetworkErrorEventArgs.cs
│ ├── NetworkManager.ConnectState.cs
│ ├── NetworkManager.HeartBeatState.cs
│ ├── NetworkManager.NetworkChannelBase.cs
│ ├── NetworkManager.ReceiveState.cs
│ ├── NetworkManager.SendState.cs
│ ├── NetworkManager.TcpNetworkChannel.cs
│ ├── NetworkManager.TcpWithSyncReceiveNetworkChannel.cs
│ ├── NetworkManager.cs
│ ├── NetworkMissHeartBeatEventArgs.cs
│ ├── Packet.cs
│ └── ServiceType.cs
├── ObjectPool
│ ├── IObjectPool.cs
│ ├── IObjectPoolManager.cs
│ ├── ObjectBase.cs
│ ├── ObjectInfo.cs
│ ├── ObjectPoolBase.cs
│ ├── ObjectPoolManager.Object.cs
│ ├── ObjectPoolManager.ObjectPool.cs
│ ├── ObjectPoolManager.cs
│ └── ReleaseObjectFilterCallback.cs
├── Procedure
│ ├── IProcedureManager.cs
│ ├── ProcedureBase.cs
│ └── ProcedureManager.cs
├── Properties
│ └── AssemblyInfo.cs
├── Resource
│ ├── ApplyResourcesCompleteCallback.cs
│ ├── CheckResourcesCompleteCallback.cs
│ ├── CheckVersionListResult.cs
│ ├── Constant.cs
│ ├── DecryptResourceCallback.cs
│ ├── HasAssetResult.cs
│ ├── ILoadResourceAgentHelper.cs
│ ├── IResourceGroup.cs
│ ├── IResourceGroupCollection.cs
│ ├── IResourceHelper.cs
│ ├── IResourceManager.cs
│ ├── InitResourcesCompleteCallback.cs
│ ├── LoadAssetCallbacks.cs
│ ├── LoadAssetDependencyAssetCallback.cs
│ ├── LoadAssetFailureCallback.cs
│ ├── LoadAssetSuccessCallback.cs
│ ├── LoadAssetUpdateCallback.cs
│ ├── LoadBinaryCallbacks.cs
│ ├── LoadBinaryFailureCallback.cs
│ ├── LoadBinarySuccessCallback.cs
│ ├── LoadBytesCallbacks.cs
│ ├── LoadBytesFailureCallback.cs
│ ├── LoadBytesSuccessCallback.cs
│ ├── LoadResourceAgentHelperErrorEventArgs.cs
│ ├── LoadResourceAgentHelperLoadCompleteEventArgs.cs
│ ├── LoadResourceAgentHelperParseBytesCompleteEventArgs.cs
│ ├── LoadResourceAgentHelperReadBytesCompleteEventArgs.cs
│ ├── LoadResourceAgentHelperReadFileCompleteEventArgs.cs
│ ├── LoadResourceAgentHelperUpdateEventArgs.cs
│ ├── LoadResourceProgress.cs
│ ├── LoadResourceStatus.cs
│ ├── LoadSceneCallbacks.cs
│ ├── LoadSceneDependencyAssetCallback.cs
│ ├── LoadSceneFailureCallback.cs
│ ├── LoadSceneSuccessCallback.cs
│ ├── LoadSceneUpdateCallback.cs
│ ├── LocalVersionList.FileSystem.cs
│ ├── LocalVersionList.Resource.cs
│ ├── LocalVersionList.cs
│ ├── PackageVersionList.Asset.cs
│ ├── PackageVersionList.FileSystem.cs
│ ├── PackageVersionList.Resource.cs
│ ├── PackageVersionList.ResourceGroup.cs
│ ├── PackageVersionList.cs
│ ├── PackageVersionListSerializer.cs
│ ├── ReadOnlyVersionListSerializer.cs
│ ├── ReadWriteVersionListSerializer.cs
│ ├── ResourceApplyFailureEventArgs.cs
│ ├── ResourceApplyStartEventArgs.cs
│ ├── ResourceApplySuccessEventArgs.cs
│ ├── ResourceManager.AssetInfo.cs
│ ├── ResourceManager.LoadType.cs
│ ├── ResourceManager.ReadWriteResourceInfo.cs
│ ├── ResourceManager.ResourceChecker.CheckInfo.CheckStatus.cs
│ ├── ResourceManager.ResourceChecker.CheckInfo.LocalVersionInfo.cs
│ ├── ResourceManager.ResourceChecker.CheckInfo.RemoteVersionInfo.cs
│ ├── ResourceManager.ResourceChecker.CheckInfo.cs
│ ├── ResourceManager.ResourceChecker.cs
│ ├── ResourceManager.ResourceGroup.cs
│ ├── ResourceManager.ResourceGroupCollection.cs
│ ├── ResourceManager.ResourceInfo.cs
│ ├── ResourceManager.ResourceIniter.cs
│ ├── ResourceManager.ResourceLoader.AssetObject.cs
│ ├── ResourceManager.ResourceLoader.LoadAssetTask.cs
│ ├── ResourceManager.ResourceLoader.LoadBinaryInfo.cs
│ ├── ResourceManager.ResourceLoader.LoadDependencyAssetTask.cs
│ ├── ResourceManager.ResourceLoader.LoadResourceAgent.cs
│ ├── ResourceManager.ResourceLoader.LoadResourceTaskBase.cs
│ ├── ResourceManager.ResourceLoader.LoadSceneTask.cs
│ ├── ResourceManager.ResourceLoader.ResourceObject.cs
│ ├── ResourceManager.ResourceLoader.cs
│ ├── ResourceManager.ResourceName.cs
│ ├── ResourceManager.ResourceNameComparer.cs
│ ├── ResourceManager.ResourceUpdater.ApplyInfo.cs
│ ├── ResourceManager.ResourceUpdater.UpdateInfo.cs
│ ├── ResourceManager.ResourceUpdater.cs
│ ├── ResourceManager.ResourceVerifier.VerifyInfo.cs
│ ├── ResourceManager.ResourceVerifier.cs
│ ├── ResourceManager.VersionListProcessor.cs
│ ├── ResourceManager.cs
│ ├── ResourceMode.cs
│ ├── ResourcePackVersionList.Resource.cs
│ ├── ResourcePackVersionList.cs
│ ├── ResourcePackVersionListSerializer.cs
│ ├── ResourceUpdateAllCompleteEventArgs.cs
│ ├── ResourceUpdateChangedEventArgs.cs
│ ├── ResourceUpdateFailureEventArgs.cs
│ ├── ResourceUpdateStartEventArgs.cs
│ ├── ResourceUpdateSuccessEventArgs.cs
│ ├── ResourceVerifyFailureEventArgs.cs
│ ├── ResourceVerifyStartEventArgs.cs
│ ├── ResourceVerifySuccessEventArgs.cs
│ ├── UnloadSceneCallbacks.cs
│ ├── UnloadSceneFailureCallback.cs
│ ├── UnloadSceneSuccessCallback.cs
│ ├── UpdatableVersionList.Asset.cs
│ ├── UpdatableVersionList.FileSystem.cs
│ ├── UpdatableVersionList.Resource.cs
│ ├── UpdatableVersionList.ResourceGroup.cs
│ ├── UpdatableVersionList.cs
│ ├── UpdatableVersionListSerializer.cs
│ ├── UpdateResourcesCompleteCallback.cs
│ ├── UpdateVersionListCallbacks.cs
│ ├── UpdateVersionListFailureCallback.cs
│ ├── UpdateVersionListSuccessCallback.cs
│ └── VerifyResourcesCompleteCallback.cs
├── Scene
│ ├── ISceneManager.cs
│ ├── LoadSceneDependencyAssetEventArgs.cs
│ ├── LoadSceneFailureEventArgs.cs
│ ├── LoadSceneSuccessEventArgs.cs
│ ├── LoadSceneUpdateEventArgs.cs
│ ├── SceneManager.cs
│ ├── UnloadSceneFailureEventArgs.cs
│ └── UnloadSceneSuccessEventArgs.cs
├── Setting
│ ├── ISettingHelper.cs
│ ├── ISettingManager.cs
│ └── SettingManager.cs
├── Sound
│ ├── Constant.cs
│ ├── ISoundAgent.cs
│ ├── ISoundAgentHelper.cs
│ ├── ISoundGroup.cs
│ ├── ISoundGroupHelper.cs
│ ├── ISoundHelper.cs
│ ├── ISoundManager.cs
│ ├── PlaySoundDependencyAssetEventArgs.cs
│ ├── PlaySoundErrorCode.cs
│ ├── PlaySoundFailureEventArgs.cs
│ ├── PlaySoundParams.cs
│ ├── PlaySoundSuccessEventArgs.cs
│ ├── PlaySoundUpdateEventArgs.cs
│ ├── ResetSoundAgentEventArgs.cs
│ ├── SoundManager.PlaySoundInfo.cs
│ ├── SoundManager.SoundAgent.cs
│ ├── SoundManager.SoundGroup.cs
│ └── SoundManager.cs
├── UI
│ ├── CloseUIFormCompleteEventArgs.cs
│ ├── IUIForm.cs
│ ├── IUIFormHelper.cs
│ ├── IUIGroup.cs
│ ├── IUIGroupHelper.cs
│ ├── IUIManager.cs
│ ├── OpenUIFormDependencyAssetEventArgs.cs
│ ├── OpenUIFormFailureEventArgs.cs
│ ├── OpenUIFormSuccessEventArgs.cs
│ ├── OpenUIFormUpdateEventArgs.cs
│ ├── UIManager.OpenUIFormInfo.cs
│ ├── UIManager.UIFormInstanceObject.cs
│ ├── UIManager.UIGroup.UIFormInfo.cs
│ ├── UIManager.UIGroup.cs
│ └── UIManager.cs
├── Utility
│ ├── Utility.Assembly.cs
│ ├── Utility.Compression.ICompressionHelper.cs
│ ├── Utility.Compression.cs
│ ├── Utility.Converter.cs
│ ├── Utility.Encryption.cs
│ ├── Utility.Json.IJsonHelper.cs
│ ├── Utility.Json.cs
│ ├── Utility.Marshal.cs
│ ├── Utility.Path.cs
│ ├── Utility.Random.cs
│ ├── Utility.Text.ITextHelper.cs
│ ├── Utility.Text.cs
│ ├── Utility.Verifier.Crc32.cs
│ ├── Utility.Verifier.cs
│ └── Utility.cs
└── WebRequest
│ ├── Constant.cs
│ ├── IWebRequestAgentHelper.cs
│ ├── IWebRequestManager.cs
│ ├── WebRequestAgentHelperCompleteEventArgs.cs
│ ├── WebRequestAgentHelperErrorEventArgs.cs
│ ├── WebRequestFailureEventArgs.cs
│ ├── WebRequestManager.WebRequestAgent.cs
│ ├── WebRequestManager.WebRequestTask.cs
│ ├── WebRequestManager.WebRequestTaskStatus.cs
│ ├── WebRequestManager.cs
│ ├── WebRequestStartEventArgs.cs
│ └── WebRequestSuccessEventArgs.cs
├── LICENSE.md
└── README.md
/GameFramework.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.28803.202
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GameFramework", "GameFramework\GameFramework.csproj", "{109D7F39-79AB-4862-9F73-0B8C638930C6}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {109D7F39-79AB-4862-9F73-0B8C638930C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {109D7F39-79AB-4862-9F73-0B8C638930C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {109D7F39-79AB-4862-9F73-0B8C638930C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {109D7F39-79AB-4862-9F73-0B8C638930C6}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {C9FE37CC-C19B-4C35-A093-03578C567222}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/GameFramework/Base/DataProvider/ReadDataFailureEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | ///
11 | /// 读取数据失败事件。
12 | ///
13 | public sealed class ReadDataFailureEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化读取数据失败事件的新实例。
17 | ///
18 | public ReadDataFailureEventArgs()
19 | {
20 | DataAssetName = null;
21 | ErrorMessage = null;
22 | UserData = null;
23 | }
24 |
25 | ///
26 | /// 获取内容资源名称。
27 | ///
28 | public string DataAssetName
29 | {
30 | get;
31 | private set;
32 | }
33 |
34 | ///
35 | /// 获取错误信息。
36 | ///
37 | public string ErrorMessage
38 | {
39 | get;
40 | private set;
41 | }
42 |
43 | ///
44 | /// 获取用户自定义数据。
45 | ///
46 | public object UserData
47 | {
48 | get;
49 | private set;
50 | }
51 |
52 | ///
53 | /// 创建读取数据失败事件。
54 | ///
55 | /// 内容资源名称。
56 | /// 错误信息。
57 | /// 用户自定义数据。
58 | /// 创建的读取数据失败事件。
59 | public static ReadDataFailureEventArgs Create(string dataAssetName, string errorMessage, object userData)
60 | {
61 | ReadDataFailureEventArgs loadDataFailureEventArgs = ReferencePool.Acquire();
62 | loadDataFailureEventArgs.DataAssetName = dataAssetName;
63 | loadDataFailureEventArgs.ErrorMessage = errorMessage;
64 | loadDataFailureEventArgs.UserData = userData;
65 | return loadDataFailureEventArgs;
66 | }
67 |
68 | ///
69 | /// 清理读取数据失败事件。
70 | ///
71 | public override void Clear()
72 | {
73 | DataAssetName = null;
74 | ErrorMessage = null;
75 | UserData = null;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/GameFramework/Base/DataProvider/ReadDataSuccessEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | ///
11 | /// 读取数据成功事件。
12 | ///
13 | public sealed class ReadDataSuccessEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化读取数据成功事件的新实例。
17 | ///
18 | public ReadDataSuccessEventArgs()
19 | {
20 | DataAssetName = null;
21 | Duration = 0f;
22 | UserData = null;
23 | }
24 |
25 | ///
26 | /// 获取内容资源名称。
27 | ///
28 | public string DataAssetName
29 | {
30 | get;
31 | private set;
32 | }
33 |
34 | ///
35 | /// 获取加载持续时间。
36 | ///
37 | public float Duration
38 | {
39 | get;
40 | private set;
41 | }
42 |
43 | ///
44 | /// 获取用户自定义数据。
45 | ///
46 | public object UserData
47 | {
48 | get;
49 | private set;
50 | }
51 |
52 | ///
53 | /// 创建读取数据成功事件。
54 | ///
55 | /// 内容资源名称。
56 | /// 加载持续时间。
57 | /// 用户自定义数据。
58 | /// 创建的读取数据成功事件。
59 | public static ReadDataSuccessEventArgs Create(string dataAssetName, float duration, object userData)
60 | {
61 | ReadDataSuccessEventArgs loadDataSuccessEventArgs = ReferencePool.Acquire();
62 | loadDataSuccessEventArgs.DataAssetName = dataAssetName;
63 | loadDataSuccessEventArgs.Duration = duration;
64 | loadDataSuccessEventArgs.UserData = userData;
65 | return loadDataSuccessEventArgs;
66 | }
67 |
68 | ///
69 | /// 清理读取数据成功事件。
70 | ///
71 | public override void Clear()
72 | {
73 | DataAssetName = null;
74 | Duration = 0f;
75 | UserData = null;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/GameFramework/Base/DataProvider/ReadDataUpdateEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | ///
11 | /// 读取数据更新事件。
12 | ///
13 | public sealed class ReadDataUpdateEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化读取数据更新事件的新实例。
17 | ///
18 | public ReadDataUpdateEventArgs()
19 | {
20 | DataAssetName = null;
21 | Progress = 0f;
22 | UserData = null;
23 | }
24 |
25 | ///
26 | /// 获取内容资源名称。
27 | ///
28 | public string DataAssetName
29 | {
30 | get;
31 | private set;
32 | }
33 |
34 | ///
35 | /// 获取读取数据进度。
36 | ///
37 | public float Progress
38 | {
39 | get;
40 | private set;
41 | }
42 |
43 | ///
44 | /// 获取用户自定义数据。
45 | ///
46 | public object UserData
47 | {
48 | get;
49 | private set;
50 | }
51 |
52 | ///
53 | /// 创建读取数据更新事件。
54 | ///
55 | /// 内容资源名称。
56 | /// 读取数据进度。
57 | /// 用户自定义数据。
58 | /// 创建的读取数据更新事件。
59 | public static ReadDataUpdateEventArgs Create(string dataAssetName, float progress, object userData)
60 | {
61 | ReadDataUpdateEventArgs loadDataUpdateEventArgs = ReferencePool.Acquire();
62 | loadDataUpdateEventArgs.DataAssetName = dataAssetName;
63 | loadDataUpdateEventArgs.Progress = progress;
64 | loadDataUpdateEventArgs.UserData = userData;
65 | return loadDataUpdateEventArgs;
66 | }
67 |
68 | ///
69 | /// 清理读取数据更新事件。
70 | ///
71 | public override void Clear()
72 | {
73 | DataAssetName = null;
74 | Progress = 0f;
75 | UserData = null;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/GameFramework/Base/EventPool/BaseEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | ///
11 | /// 事件基类。
12 | ///
13 | public abstract class BaseEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 获取类型编号。
17 | ///
18 | public abstract int Id
19 | {
20 | get;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/GameFramework/Base/EventPool/EventPool.Event.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | internal sealed partial class EventPool where T : BaseEventArgs
11 | {
12 | ///
13 | /// 事件结点。
14 | ///
15 | private sealed class Event : IReference
16 | {
17 | private object m_Sender;
18 | private T m_EventArgs;
19 |
20 | public Event()
21 | {
22 | m_Sender = null;
23 | m_EventArgs = null;
24 | }
25 |
26 | public object Sender
27 | {
28 | get
29 | {
30 | return m_Sender;
31 | }
32 | }
33 |
34 | public T EventArgs
35 | {
36 | get
37 | {
38 | return m_EventArgs;
39 | }
40 | }
41 |
42 | public static Event Create(object sender, T e)
43 | {
44 | Event eventNode = ReferencePool.Acquire();
45 | eventNode.m_Sender = sender;
46 | eventNode.m_EventArgs = e;
47 | return eventNode;
48 | }
49 |
50 | public void Clear()
51 | {
52 | m_Sender = null;
53 | m_EventArgs = null;
54 | }
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/GameFramework/Base/EventPool/EventPoolMode.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System;
9 |
10 | namespace GameFramework
11 | {
12 | ///
13 | /// 事件池模式。
14 | ///
15 | [Flags]
16 | internal enum EventPoolMode : byte
17 | {
18 | ///
19 | /// 默认事件池模式,即必须存在有且只有一个事件处理函数。
20 | ///
21 | Default = 0,
22 |
23 | ///
24 | /// 允许不存在事件处理函数。
25 | ///
26 | AllowNoHandler = 1,
27 |
28 | ///
29 | /// 允许存在多个事件处理函数。
30 | ///
31 | AllowMultiHandler = 2,
32 |
33 | ///
34 | /// 允许存在重复的事件处理函数。
35 | ///
36 | AllowDuplicateHandler = 4
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/GameFramework/Base/GameFrameworkEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System;
9 |
10 | namespace GameFramework
11 | {
12 | ///
13 | /// 游戏框架中包含事件数据的类的基类。
14 | ///
15 | public abstract class GameFrameworkEventArgs : EventArgs, IReference
16 | {
17 | ///
18 | /// 初始化游戏框架中包含事件数据的类的新实例。
19 | ///
20 | public GameFrameworkEventArgs()
21 | {
22 | }
23 |
24 | ///
25 | /// 清理引用。
26 | ///
27 | public abstract void Clear();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/GameFramework/Base/GameFrameworkException.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System;
9 | using System.Runtime.Serialization;
10 |
11 | namespace GameFramework
12 | {
13 | ///
14 | /// 游戏框架异常类。
15 | ///
16 | [Serializable]
17 | public class GameFrameworkException : Exception
18 | {
19 | ///
20 | /// 初始化游戏框架异常类的新实例。
21 | ///
22 | public GameFrameworkException()
23 | : base()
24 | {
25 | }
26 |
27 | ///
28 | /// 使用指定错误消息初始化游戏框架异常类的新实例。
29 | ///
30 | /// 描述错误的消息。
31 | public GameFrameworkException(string message)
32 | : base(message)
33 | {
34 | }
35 |
36 | ///
37 | /// 使用指定错误消息和对作为此异常原因的内部异常的引用来初始化游戏框架异常类的新实例。
38 | ///
39 | /// 解释异常原因的错误消息。
40 | /// 导致当前异常的异常。如果 innerException 参数不为空引用,则在处理内部异常的 catch 块中引发当前异常。
41 | public GameFrameworkException(string message, Exception innerException)
42 | : base(message, innerException)
43 | {
44 | }
45 |
46 | ///
47 | /// 用序列化数据初始化游戏框架异常类的新实例。
48 | ///
49 | /// 存有有关所引发异常的序列化的对象数据。
50 | /// 包含有关源或目标的上下文信息。
51 | protected GameFrameworkException(SerializationInfo info, StreamingContext context)
52 | : base(info, context)
53 | {
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/GameFramework/Base/GameFrameworkModule.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | ///
11 | /// 游戏框架模块抽象类。
12 | ///
13 | internal abstract class GameFrameworkModule
14 | {
15 | ///
16 | /// 获取游戏框架模块优先级。
17 | ///
18 | /// 优先级较高的模块会优先轮询,并且关闭操作会后进行。
19 | internal virtual int Priority
20 | {
21 | get
22 | {
23 | return 0;
24 | }
25 | }
26 |
27 | ///
28 | /// 游戏框架模块轮询。
29 | ///
30 | /// 逻辑流逝时间,以秒为单位。
31 | /// 真实流逝时间,以秒为单位。
32 | internal abstract void Update(float elapseSeconds, float realElapseSeconds);
33 |
34 | ///
35 | /// 关闭并清理游戏框架模块。
36 | ///
37 | internal abstract void Shutdown();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/GameFramework/Base/Log/GameFrameworkLog.ILogHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | public static partial class GameFrameworkLog
11 | {
12 | ///
13 | /// 游戏框架日志辅助器接口。
14 | ///
15 | public interface ILogHelper
16 | {
17 | ///
18 | /// 记录日志。
19 | ///
20 | /// 游戏框架日志等级。
21 | /// 日志内容。
22 | void Log(GameFrameworkLogLevel level, object message);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/GameFramework/Base/Log/GameFrameworkLogLevel.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | ///
11 | /// 游戏框架日志等级。
12 | ///
13 | public enum GameFrameworkLogLevel : byte
14 | {
15 | ///
16 | /// 调试。
17 | ///
18 | Debug = 0,
19 |
20 | ///
21 | /// 信息。
22 | ///
23 | Info,
24 |
25 | ///
26 | /// 警告。
27 | ///
28 | Warning,
29 |
30 | ///
31 | /// 错误。
32 | ///
33 | Error,
34 |
35 | ///
36 | /// 严重错误。
37 | ///
38 | Fatal
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/GameFramework/Base/ReferencePool/IReference.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | ///
11 | /// 引用接口。
12 | ///
13 | public interface IReference
14 | {
15 | ///
16 | /// 清理引用。
17 | ///
18 | void Clear();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/GameFramework/Base/TaskPool/ITaskAgent.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | ///
11 | /// 任务代理接口。
12 | ///
13 | /// 任务类型。
14 | internal interface ITaskAgent where T : TaskBase
15 | {
16 | ///
17 | /// 获取任务。
18 | ///
19 | T Task
20 | {
21 | get;
22 | }
23 |
24 | ///
25 | /// 初始化任务代理。
26 | ///
27 | void Initialize();
28 |
29 | ///
30 | /// 任务代理轮询。
31 | ///
32 | /// 逻辑流逝时间,以秒为单位。
33 | /// 真实流逝时间,以秒为单位。
34 | void Update(float elapseSeconds, float realElapseSeconds);
35 |
36 | ///
37 | /// 关闭并清理任务代理。
38 | ///
39 | void Shutdown();
40 |
41 | ///
42 | /// 开始处理任务。
43 | ///
44 | /// 要处理的任务。
45 | /// 开始处理任务的状态。
46 | StartTaskStatus Start(T task);
47 |
48 | ///
49 | /// 停止正在处理的任务并重置任务代理。
50 | ///
51 | void Reset();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/GameFramework/Base/TaskPool/StartTaskStatus.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | ///
11 | /// 开始处理任务的状态。
12 | ///
13 | public enum StartTaskStatus : byte
14 | {
15 | ///
16 | /// 可以立刻处理完成此任务。
17 | ///
18 | Done = 0,
19 |
20 | ///
21 | /// 可以继续处理此任务。
22 | ///
23 | CanResume,
24 |
25 | ///
26 | /// 不能继续处理此任务,需等待其它任务执行完成。
27 | ///
28 | HasToWait,
29 |
30 | ///
31 | /// 不能继续处理此任务,出现未知错误。
32 | ///
33 | UnknownError
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/GameFramework/Base/TaskPool/TaskStatus.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | ///
11 | /// 任务状态。
12 | ///
13 | public enum TaskStatus : byte
14 | {
15 | ///
16 | /// 未开始。
17 | ///
18 | Todo = 0,
19 |
20 | ///
21 | /// 执行中。
22 | ///
23 | Doing,
24 |
25 | ///
26 | /// 完成。
27 | ///
28 | Done
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/GameFramework/Base/Variable/GenericVariable.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System;
9 |
10 | namespace GameFramework
11 | {
12 | ///
13 | /// 变量。
14 | ///
15 | /// 变量类型。
16 | public abstract class Variable : Variable
17 | {
18 | private T m_Value;
19 |
20 | ///
21 | /// 初始化变量的新实例。
22 | ///
23 | public Variable()
24 | {
25 | m_Value = default(T);
26 | }
27 |
28 | ///
29 | /// 获取变量类型。
30 | ///
31 | public override Type Type
32 | {
33 | get
34 | {
35 | return typeof(T);
36 | }
37 | }
38 |
39 | ///
40 | /// 获取或设置变量值。
41 | ///
42 | public T Value
43 | {
44 | get
45 | {
46 | return m_Value;
47 | }
48 | set
49 | {
50 | m_Value = value;
51 | }
52 | }
53 |
54 | ///
55 | /// 获取变量值。
56 | ///
57 | /// 变量值。
58 | public override object GetValue()
59 | {
60 | return m_Value;
61 | }
62 |
63 | ///
64 | /// 设置变量值。
65 | ///
66 | /// 变量值。
67 | public override void SetValue(object value)
68 | {
69 | m_Value = (T)value;
70 | }
71 |
72 | ///
73 | /// 清理变量值。
74 | ///
75 | public override void Clear()
76 | {
77 | m_Value = default(T);
78 | }
79 |
80 | ///
81 | /// 获取变量字符串。
82 | ///
83 | /// 变量字符串。
84 | public override string ToString()
85 | {
86 | return (m_Value != null) ? m_Value.ToString() : "";
87 | }
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/GameFramework/Base/Variable/Variable.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System;
9 |
10 | namespace GameFramework
11 | {
12 | ///
13 | /// 变量。
14 | ///
15 | public abstract class Variable : IReference
16 | {
17 | ///
18 | /// 初始化变量的新实例。
19 | ///
20 | public Variable()
21 | {
22 | }
23 |
24 | ///
25 | /// 获取变量类型。
26 | ///
27 | public abstract Type Type
28 | {
29 | get;
30 | }
31 |
32 | ///
33 | /// 获取变量值。
34 | ///
35 | /// 变量值。
36 | public abstract object GetValue();
37 |
38 | ///
39 | /// 设置变量值。
40 | ///
41 | /// 变量值。
42 | public abstract void SetValue(object value);
43 |
44 | ///
45 | /// 清理变量值。
46 | ///
47 | public abstract void Clear();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/GameFramework/Base/Version/Version.IVersionHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | public static partial class Version
11 | {
12 | ///
13 | /// 版本号辅助器接口。
14 | ///
15 | public interface IVersionHelper
16 | {
17 | ///
18 | /// 获取游戏版本号。
19 | ///
20 | string GameVersion
21 | {
22 | get;
23 | }
24 |
25 | ///
26 | /// 获取内部游戏版本号。
27 | ///
28 | int InternalGameVersion
29 | {
30 | get;
31 | }
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/GameFramework/Base/Version/Version.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | ///
11 | /// 版本号类。
12 | ///
13 | public static partial class Version
14 | {
15 | private const string GameFrameworkVersionString = "2021.05.31";
16 |
17 | private static IVersionHelper s_VersionHelper = null;
18 |
19 | ///
20 | /// 获取游戏框架版本号。
21 | ///
22 | public static string GameFrameworkVersion
23 | {
24 | get
25 | {
26 | return GameFrameworkVersionString;
27 | }
28 | }
29 |
30 | ///
31 | /// 获取游戏版本号。
32 | ///
33 | public static string GameVersion
34 | {
35 | get
36 | {
37 | if (s_VersionHelper == null)
38 | {
39 | return string.Empty;
40 | }
41 |
42 | return s_VersionHelper.GameVersion;
43 | }
44 | }
45 |
46 | ///
47 | /// 获取内部游戏版本号。
48 | ///
49 | public static int InternalGameVersion
50 | {
51 | get
52 | {
53 | if (s_VersionHelper == null)
54 | {
55 | return 0;
56 | }
57 |
58 | return s_VersionHelper.InternalGameVersion;
59 | }
60 | }
61 |
62 | ///
63 | /// 设置版本号辅助器。
64 | ///
65 | /// 要设置的版本号辅助器。
66 | public static void SetVersionHelper(IVersionHelper versionHelper)
67 | {
68 | s_VersionHelper = versionHelper;
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/GameFramework/Config/ConfigManager.ConfigData.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.Runtime.InteropServices;
9 |
10 | namespace GameFramework.Config
11 | {
12 | internal sealed partial class ConfigManager : GameFrameworkModule, IConfigManager
13 | {
14 | [StructLayout(LayoutKind.Auto)]
15 | private struct ConfigData
16 | {
17 | private readonly bool m_BoolValue;
18 | private readonly int m_IntValue;
19 | private readonly float m_FloatValue;
20 | private readonly string m_StringValue;
21 |
22 | public ConfigData(bool boolValue, int intValue, float floatValue, string stringValue)
23 | {
24 | m_BoolValue = boolValue;
25 | m_IntValue = intValue;
26 | m_FloatValue = floatValue;
27 | m_StringValue = stringValue;
28 | }
29 |
30 | public bool BoolValue
31 | {
32 | get
33 | {
34 | return m_BoolValue;
35 | }
36 | }
37 |
38 | public int IntValue
39 | {
40 | get
41 | {
42 | return m_IntValue;
43 | }
44 | }
45 |
46 | public float FloatValue
47 | {
48 | get
49 | {
50 | return m_FloatValue;
51 | }
52 | }
53 |
54 | public string StringValue
55 | {
56 | get
57 | {
58 | return m_StringValue;
59 | }
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/GameFramework/Config/IConfigHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Config
9 | {
10 | ///
11 | /// 全局配置辅助器接口。
12 | ///
13 | public interface IConfigHelper
14 | {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/GameFramework/DataTable/IDataRow.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.DataTable
9 | {
10 | ///
11 | /// 数据表行接口。
12 | ///
13 | public interface IDataRow
14 | {
15 | ///
16 | /// 获取数据表行的编号。
17 | ///
18 | int Id
19 | {
20 | get;
21 | }
22 |
23 | ///
24 | /// 解析数据表行。
25 | ///
26 | /// 要解析的数据表行字符串。
27 | /// 用户自定义数据。
28 | /// 是否解析数据表行成功。
29 | bool ParseDataRow(string dataRowString, object userData);
30 |
31 | ///
32 | /// 解析数据表行。
33 | ///
34 | /// 要解析的数据表行二进制流。
35 | /// 数据表行二进制流的起始位置。
36 | /// 数据表行二进制流的长度。
37 | /// 用户自定义数据。
38 | /// 是否解析数据表行成功。
39 | bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/GameFramework/DataTable/IDataTableHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.DataTable
9 | {
10 | ///
11 | /// 数据表辅助器接口。
12 | ///
13 | public interface IDataTableHelper
14 | {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/GameFramework/Debugger/IDebuggerManager.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Debugger
9 | {
10 | ///
11 | /// 调试器管理器接口。
12 | ///
13 | public interface IDebuggerManager
14 | {
15 | ///
16 | /// 获取或设置调试器窗口是否激活。
17 | ///
18 | bool ActiveWindow
19 | {
20 | get;
21 | set;
22 | }
23 |
24 | ///
25 | /// 调试器窗口根结点。
26 | ///
27 | IDebuggerWindowGroup DebuggerWindowRoot
28 | {
29 | get;
30 | }
31 |
32 | ///
33 | /// 注册调试器窗口。
34 | ///
35 | /// 调试器窗口路径。
36 | /// 要注册的调试器窗口。
37 | /// 初始化调试器窗口参数。
38 | void RegisterDebuggerWindow(string path, IDebuggerWindow debuggerWindow, params object[] args);
39 |
40 | ///
41 | /// 解除注册调试器窗口。
42 | ///
43 | /// 调试器窗口路径。
44 | /// 是否解除注册调试器窗口成功。
45 | bool UnregisterDebuggerWindow(string path);
46 |
47 | ///
48 | /// 获取调试器窗口。
49 | ///
50 | /// 调试器窗口路径。
51 | /// 要获取的调试器窗口。
52 | IDebuggerWindow GetDebuggerWindow(string path);
53 |
54 | ///
55 | /// 选中调试器窗口。
56 | ///
57 | /// 调试器窗口路径。
58 | /// 是否成功选中调试器窗口。
59 | bool SelectDebuggerWindow(string path);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/GameFramework/Debugger/IDebuggerWindow.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Debugger
9 | {
10 | ///
11 | /// 调试器窗口接口。
12 | ///
13 | public interface IDebuggerWindow
14 | {
15 | ///
16 | /// 初始化调试器窗口。
17 | ///
18 | /// 初始化调试器窗口参数。
19 | void Initialize(params object[] args);
20 |
21 | ///
22 | /// 关闭调试器窗口。
23 | ///
24 | void Shutdown();
25 |
26 | ///
27 | /// 进入调试器窗口。
28 | ///
29 | void OnEnter();
30 |
31 | ///
32 | /// 离开调试器窗口。
33 | ///
34 | void OnLeave();
35 |
36 | ///
37 | /// 调试器窗口轮询。
38 | ///
39 | /// 逻辑流逝时间,以秒为单位。
40 | /// 真实流逝时间,以秒为单位。
41 | void OnUpdate(float elapseSeconds, float realElapseSeconds);
42 |
43 | ///
44 | /// 调试器窗口绘制。
45 | ///
46 | void OnDraw();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/GameFramework/Debugger/IDebuggerWindowGroup.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Debugger
9 | {
10 | ///
11 | /// 调试器窗口组接口。
12 | ///
13 | public interface IDebuggerWindowGroup : IDebuggerWindow
14 | {
15 | ///
16 | /// 获取调试器窗口数量。
17 | ///
18 | int DebuggerWindowCount
19 | {
20 | get;
21 | }
22 |
23 | ///
24 | /// 获取或设置当前选中的调试器窗口索引。
25 | ///
26 | int SelectedIndex
27 | {
28 | get;
29 | set;
30 | }
31 |
32 | ///
33 | /// 获取当前选中的调试器窗口。
34 | ///
35 | IDebuggerWindow SelectedWindow
36 | {
37 | get;
38 | }
39 |
40 | ///
41 | /// 获取调试组的调试器窗口名称集合。
42 | ///
43 | string[] GetDebuggerWindowNames();
44 |
45 | ///
46 | /// 获取调试器窗口。
47 | ///
48 | /// 调试器窗口路径。
49 | /// 要获取的调试器窗口。
50 | IDebuggerWindow GetDebuggerWindow(string path);
51 |
52 | ///
53 | /// 注册调试器窗口。
54 | ///
55 | /// 调试器窗口路径。
56 | /// 要注册的调试器窗口。
57 | void RegisterDebuggerWindow(string path, IDebuggerWindow debuggerWindow);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/GameFramework/Download/Constant.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Download
9 | {
10 | ///
11 | /// 下载相关常量。
12 | ///
13 | internal static class Constant
14 | {
15 | ///
16 | /// 默认下载任务优先级。
17 | ///
18 | internal const int DefaultPriority = 0;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/GameFramework/Download/DownloadAgentHelperCompleteEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Download
9 | {
10 | ///
11 | /// 下载代理辅助器完成事件。
12 | ///
13 | public sealed class DownloadAgentHelperCompleteEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化下载代理辅助器完成事件的新实例。
17 | ///
18 | public DownloadAgentHelperCompleteEventArgs()
19 | {
20 | Length = 0L;
21 | }
22 |
23 | ///
24 | /// 获取下载的数据大小。
25 | ///
26 | public long Length
27 | {
28 | get;
29 | private set;
30 | }
31 |
32 | ///
33 | /// 创建下载代理辅助器完成事件。
34 | ///
35 | /// 下载的数据大小。
36 | /// 创建的下载代理辅助器完成事件。
37 | public static DownloadAgentHelperCompleteEventArgs Create(long length)
38 | {
39 | if (length < 0L)
40 | {
41 | throw new GameFrameworkException("Length is invalid.");
42 | }
43 |
44 | DownloadAgentHelperCompleteEventArgs downloadAgentHelperCompleteEventArgs = ReferencePool.Acquire();
45 | downloadAgentHelperCompleteEventArgs.Length = length;
46 | return downloadAgentHelperCompleteEventArgs;
47 | }
48 |
49 | ///
50 | /// 清理下载代理辅助器完成事件。
51 | ///
52 | public override void Clear()
53 | {
54 | Length = 0L;
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/GameFramework/Download/DownloadAgentHelperErrorEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Download
9 | {
10 | ///
11 | /// 下载代理辅助器错误事件。
12 | ///
13 | public sealed class DownloadAgentHelperErrorEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化下载代理辅助器错误事件的新实例。
17 | ///
18 | public DownloadAgentHelperErrorEventArgs()
19 | {
20 | DeleteDownloading = false;
21 | ErrorMessage = null;
22 | }
23 |
24 | ///
25 | /// 获取是否需要删除正在下载的文件。
26 | ///
27 | public bool DeleteDownloading
28 | {
29 | get;
30 | private set;
31 | }
32 |
33 | ///
34 | /// 获取错误信息。
35 | ///
36 | public string ErrorMessage
37 | {
38 | get;
39 | private set;
40 | }
41 |
42 | ///
43 | /// 创建下载代理辅助器错误事件。
44 | ///
45 | /// 是否需要删除正在下载的文件。
46 | /// 错误信息。
47 | /// 创建的下载代理辅助器错误事件。
48 | public static DownloadAgentHelperErrorEventArgs Create(bool deleteDownloading, string errorMessage)
49 | {
50 | DownloadAgentHelperErrorEventArgs downloadAgentHelperErrorEventArgs = ReferencePool.Acquire();
51 | downloadAgentHelperErrorEventArgs.DeleteDownloading = deleteDownloading;
52 | downloadAgentHelperErrorEventArgs.ErrorMessage = errorMessage;
53 | return downloadAgentHelperErrorEventArgs;
54 | }
55 |
56 | ///
57 | /// 清理下载代理辅助器错误事件。
58 | ///
59 | public override void Clear()
60 | {
61 | DeleteDownloading = false;
62 | ErrorMessage = null;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/GameFramework/Download/DownloadAgentHelperUpdateLengthEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Download
9 | {
10 | ///
11 | /// 下载代理辅助器更新数据大小事件。
12 | ///
13 | public sealed class DownloadAgentHelperUpdateLengthEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化下载代理辅助器更新数据大小事件的新实例。
17 | ///
18 | public DownloadAgentHelperUpdateLengthEventArgs()
19 | {
20 | DeltaLength = 0;
21 | }
22 |
23 | ///
24 | /// 获取下载的增量数据大小。
25 | ///
26 | public int DeltaLength
27 | {
28 | get;
29 | private set;
30 | }
31 |
32 | ///
33 | /// 创建下载代理辅助器更新数据大小事件。
34 | ///
35 | /// 下载的增量数据大小。
36 | /// 创建的下载代理辅助器更新数据大小事件。
37 | public static DownloadAgentHelperUpdateLengthEventArgs Create(int deltaLength)
38 | {
39 | if (deltaLength <= 0)
40 | {
41 | throw new GameFrameworkException("Delta length is invalid.");
42 | }
43 |
44 | DownloadAgentHelperUpdateLengthEventArgs downloadAgentHelperUpdateLengthEventArgs = ReferencePool.Acquire();
45 | downloadAgentHelperUpdateLengthEventArgs.DeltaLength = deltaLength;
46 | return downloadAgentHelperUpdateLengthEventArgs;
47 | }
48 |
49 | ///
50 | /// 清理下载代理辅助器更新数据大小事件。
51 | ///
52 | public override void Clear()
53 | {
54 | DeltaLength = 0;
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/GameFramework/Download/DownloadManager.DownloadCounter.DownloadCounterNode.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Download
9 | {
10 | internal sealed partial class DownloadManager : GameFrameworkModule, IDownloadManager
11 | {
12 | private sealed partial class DownloadCounter
13 | {
14 | private sealed class DownloadCounterNode : IReference
15 | {
16 | private long m_DeltaLength;
17 | private float m_ElapseSeconds;
18 |
19 | public DownloadCounterNode()
20 | {
21 | m_DeltaLength = 0L;
22 | m_ElapseSeconds = 0f;
23 | }
24 |
25 | public long DeltaLength
26 | {
27 | get
28 | {
29 | return m_DeltaLength;
30 | }
31 | }
32 |
33 | public float ElapseSeconds
34 | {
35 | get
36 | {
37 | return m_ElapseSeconds;
38 | }
39 | }
40 |
41 | public static DownloadCounterNode Create()
42 | {
43 | return ReferencePool.Acquire();
44 | }
45 |
46 | public void Update(float elapseSeconds, float realElapseSeconds)
47 | {
48 | m_ElapseSeconds += realElapseSeconds;
49 | }
50 |
51 | public void AddDeltaLength(int deltaLength)
52 | {
53 | m_DeltaLength += deltaLength;
54 | }
55 |
56 | public void Clear()
57 | {
58 | m_DeltaLength = 0L;
59 | m_ElapseSeconds = 0f;
60 | }
61 | }
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/GameFramework/Download/DownloadManager.DownloadTaskStatus.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Download
9 | {
10 | internal sealed partial class DownloadManager : GameFrameworkModule, IDownloadManager
11 | {
12 | ///
13 | /// 下载任务的状态。
14 | ///
15 | private enum DownloadTaskStatus : byte
16 | {
17 | ///
18 | /// 准备下载。
19 | ///
20 | Todo = 0,
21 |
22 | ///
23 | /// 下载中。
24 | ///
25 | Doing,
26 |
27 | ///
28 | /// 下载完成。
29 | ///
30 | Done,
31 |
32 | ///
33 | /// 下载错误。
34 | ///
35 | Error
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/GameFramework/Download/IDownloadAgentHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System;
9 |
10 | namespace GameFramework.Download
11 | {
12 | ///
13 | /// 下载代理辅助器接口。
14 | ///
15 | public interface IDownloadAgentHelper
16 | {
17 | ///
18 | /// 下载代理辅助器更新数据流事件。
19 | ///
20 | event EventHandler DownloadAgentHelperUpdateBytes;
21 |
22 | ///
23 | /// 下载代理辅助器更新数据大小事件。
24 | ///
25 | event EventHandler DownloadAgentHelperUpdateLength;
26 |
27 | ///
28 | /// 下载代理辅助器完成事件。
29 | ///
30 | event EventHandler DownloadAgentHelperComplete;
31 |
32 | ///
33 | /// 下载代理辅助器错误事件。
34 | ///
35 | event EventHandler DownloadAgentHelperError;
36 |
37 | ///
38 | /// 通过下载代理辅助器下载指定地址的数据。
39 | ///
40 | /// 下载地址。
41 | /// 用户自定义数据。
42 | void Download(string downloadUri, object userData);
43 |
44 | ///
45 | /// 通过下载代理辅助器下载指定地址的数据。
46 | ///
47 | /// 下载地址。
48 | /// 下载数据起始位置。
49 | /// 用户自定义数据。
50 | void Download(string downloadUri, long fromPosition, object userData);
51 |
52 | ///
53 | /// 通过下载代理辅助器下载指定地址的数据。
54 | ///
55 | /// 下载地址。
56 | /// 下载数据起始位置。
57 | /// 下载数据结束位置。
58 | /// 用户自定义数据。
59 | void Download(string downloadUri, long fromPosition, long toPosition, object userData);
60 |
61 | ///
62 | /// 重置下载代理辅助器。
63 | ///
64 | void Reset();
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/GameFramework/Entity/EntityManager.EntityInstanceObject.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using GameFramework.ObjectPool;
9 |
10 | namespace GameFramework.Entity
11 | {
12 | internal sealed partial class EntityManager : GameFrameworkModule, IEntityManager
13 | {
14 | ///
15 | /// 实体实例对象。
16 | ///
17 | private sealed class EntityInstanceObject : ObjectBase
18 | {
19 | private object m_EntityAsset;
20 | private IEntityHelper m_EntityHelper;
21 |
22 | public EntityInstanceObject()
23 | {
24 | m_EntityAsset = null;
25 | m_EntityHelper = null;
26 | }
27 |
28 | public static EntityInstanceObject Create(string name, object entityAsset, object entityInstance, IEntityHelper entityHelper)
29 | {
30 | if (entityAsset == null)
31 | {
32 | throw new GameFrameworkException("Entity asset is invalid.");
33 | }
34 |
35 | if (entityHelper == null)
36 | {
37 | throw new GameFrameworkException("Entity helper is invalid.");
38 | }
39 |
40 | EntityInstanceObject entityInstanceObject = ReferencePool.Acquire();
41 | entityInstanceObject.Initialize(name, entityInstance);
42 | entityInstanceObject.m_EntityAsset = entityAsset;
43 | entityInstanceObject.m_EntityHelper = entityHelper;
44 | return entityInstanceObject;
45 | }
46 |
47 | public override void Clear()
48 | {
49 | base.Clear();
50 | m_EntityAsset = null;
51 | m_EntityHelper = null;
52 | }
53 |
54 | protected internal override void Release(bool isShutdown)
55 | {
56 | m_EntityHelper.ReleaseEntity(m_EntityAsset, Target);
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/GameFramework/Entity/EntityManager.EntityStatus.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Entity
9 | {
10 | internal sealed partial class EntityManager : GameFrameworkModule, IEntityManager
11 | {
12 | ///
13 | /// 实体状态。
14 | ///
15 | private enum EntityStatus : byte
16 | {
17 | Unknown = 0,
18 | WillInit,
19 | Inited,
20 | WillShow,
21 | Showed,
22 | WillHide,
23 | Hidden,
24 | WillRecycle,
25 | Recycled
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/GameFramework/Entity/IEntityGroupHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Entity
9 | {
10 | ///
11 | /// 实体组辅助器接口。
12 | ///
13 | public interface IEntityGroupHelper
14 | {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/GameFramework/Entity/IEntityHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Entity
9 | {
10 | ///
11 | /// 实体辅助器接口。
12 | ///
13 | public interface IEntityHelper
14 | {
15 | ///
16 | /// 实例化实体。
17 | ///
18 | /// 要实例化的实体资源。
19 | /// 实例化后的实体。
20 | object InstantiateEntity(object entityAsset);
21 |
22 | ///
23 | /// 创建实体。
24 | ///
25 | /// 实体实例。
26 | /// 实体所属的实体组。
27 | /// 用户自定义数据。
28 | /// 实体。
29 | IEntity CreateEntity(object entityInstance, IEntityGroup entityGroup, object userData);
30 |
31 | ///
32 | /// 释放实体。
33 | ///
34 | /// 要释放的实体资源。
35 | /// 要释放的实体实例。
36 | void ReleaseEntity(object entityAsset, object entityInstance);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/GameFramework/Entity/ShowEntitySuccessEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Entity
9 | {
10 | ///
11 | /// 显示实体成功事件。
12 | ///
13 | public sealed class ShowEntitySuccessEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化显示实体成功事件的新实例。
17 | ///
18 | public ShowEntitySuccessEventArgs()
19 | {
20 | Entity = null;
21 | Duration = 0f;
22 | UserData = null;
23 | }
24 |
25 | ///
26 | /// 获取显示成功的实体。
27 | ///
28 | public IEntity Entity
29 | {
30 | get;
31 | private set;
32 | }
33 |
34 | ///
35 | /// 获取加载持续时间。
36 | ///
37 | public float Duration
38 | {
39 | get;
40 | private set;
41 | }
42 |
43 | ///
44 | /// 获取用户自定义数据。
45 | ///
46 | public object UserData
47 | {
48 | get;
49 | private set;
50 | }
51 |
52 | ///
53 | /// 创建显示实体成功事件。
54 | ///
55 | /// 加载成功的实体。
56 | /// 加载持续时间。
57 | /// 用户自定义数据。
58 | /// 创建的显示实体成功事件。
59 | public static ShowEntitySuccessEventArgs Create(IEntity entity, float duration, object userData)
60 | {
61 | ShowEntitySuccessEventArgs showEntitySuccessEventArgs = ReferencePool.Acquire();
62 | showEntitySuccessEventArgs.Entity = entity;
63 | showEntitySuccessEventArgs.Duration = duration;
64 | showEntitySuccessEventArgs.UserData = userData;
65 | return showEntitySuccessEventArgs;
66 | }
67 |
68 | ///
69 | /// 清理显示实体成功事件。
70 | ///
71 | public override void Clear()
72 | {
73 | Entity = null;
74 | Duration = 0f;
75 | UserData = null;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/GameFramework/Event/GameEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Event
9 | {
10 | ///
11 | /// 游戏逻辑事件基类。
12 | ///
13 | public abstract class GameEventArgs : BaseEventArgs
14 | {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/GameFramework/FileSystem/FileSystem.BlockData.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.Runtime.InteropServices;
9 |
10 | namespace GameFramework.FileSystem
11 | {
12 | internal sealed partial class FileSystem : IFileSystem
13 | {
14 | ///
15 | /// 块数据。
16 | ///
17 | [StructLayout(LayoutKind.Sequential)]
18 | private struct BlockData
19 | {
20 | public static readonly BlockData Empty = new BlockData(0, 0);
21 |
22 | private readonly int m_StringIndex;
23 | private readonly int m_ClusterIndex;
24 | private readonly int m_Length;
25 |
26 | public BlockData(int clusterIndex, int length)
27 | : this(-1, clusterIndex, length)
28 | {
29 | }
30 |
31 | public BlockData(int stringIndex, int clusterIndex, int length)
32 | {
33 | m_StringIndex = stringIndex;
34 | m_ClusterIndex = clusterIndex;
35 | m_Length = length;
36 | }
37 |
38 | public bool Using
39 | {
40 | get
41 | {
42 | return m_StringIndex >= 0;
43 | }
44 | }
45 |
46 | public int StringIndex
47 | {
48 | get
49 | {
50 | return m_StringIndex;
51 | }
52 | }
53 |
54 | public int ClusterIndex
55 | {
56 | get
57 | {
58 | return m_ClusterIndex;
59 | }
60 | }
61 |
62 | public int Length
63 | {
64 | get
65 | {
66 | return m_Length;
67 | }
68 | }
69 |
70 | public BlockData Free()
71 | {
72 | return new BlockData(m_ClusterIndex, (int)GetUpBoundClusterOffset(m_Length));
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/GameFramework/FileSystem/FileSystemAccess.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System;
9 |
10 | namespace GameFramework.FileSystem
11 | {
12 | ///
13 | /// 文件系统访问方式。
14 | ///
15 | [Flags]
16 | public enum FileSystemAccess : byte
17 | {
18 | ///
19 | /// 未指定。
20 | ///
21 | Unspecified = 0,
22 |
23 | ///
24 | /// 只可读。
25 | ///
26 | Read = 1,
27 |
28 | ///
29 | /// 只可写。
30 | ///
31 | Write = 2,
32 |
33 | ///
34 | /// 可读写。
35 | ///
36 | ReadWrite = 3
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/GameFramework/FileSystem/IFileSystemHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.FileSystem
9 | {
10 | ///
11 | /// 文件系统辅助器接口。
12 | ///
13 | public interface IFileSystemHelper
14 | {
15 | ///
16 | /// 创建文件系统流。
17 | ///
18 | /// 要加载的文件系统的完整路径。
19 | /// 要加载的文件系统的访问方式。
20 | /// 是否创建新的文件系统流。
21 | /// 创建的文件系统流。
22 | FileSystemStream CreateFileSystemStream(string fullPath, FileSystemAccess access, bool createNew);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/GameFramework/Localization/ILocalizationHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Localization
9 | {
10 | ///
11 | /// 本地化辅助器接口。
12 | ///
13 | public interface ILocalizationHelper
14 | {
15 | ///
16 | /// 获取系统语言。
17 | ///
18 | Language SystemLanguage
19 | {
20 | get;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/GameFramework/Network/AddressFamily.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Network
9 | {
10 | ///
11 | /// 网络地址类型。
12 | ///
13 | public enum AddressFamily : byte
14 | {
15 | ///
16 | /// 未知。
17 | ///
18 | Unknown = 0,
19 |
20 | ///
21 | /// IP 版本 4。
22 | ///
23 | IPv4,
24 |
25 | ///
26 | /// IP 版本 6。
27 | ///
28 | IPv6
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/GameFramework/Network/INetworkChannelHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.IO;
9 |
10 | namespace GameFramework.Network
11 | {
12 | ///
13 | /// 网络频道辅助器接口。
14 | ///
15 | public interface INetworkChannelHelper
16 | {
17 | ///
18 | /// 获取消息包头长度。
19 | ///
20 | int PacketHeaderLength
21 | {
22 | get;
23 | }
24 |
25 | ///
26 | /// 初始化网络频道辅助器。
27 | ///
28 | /// 网络频道。
29 | void Initialize(INetworkChannel networkChannel);
30 |
31 | ///
32 | /// 关闭并清理网络频道辅助器。
33 | ///
34 | void Shutdown();
35 |
36 | ///
37 | /// 准备进行连接。
38 | ///
39 | void PrepareForConnecting();
40 |
41 | ///
42 | /// 发送心跳消息包。
43 | ///
44 | /// 是否发送心跳消息包成功。
45 | bool SendHeartBeat();
46 |
47 | ///
48 | /// 序列化消息包。
49 | ///
50 | /// 消息包类型。
51 | /// 要序列化的消息包。
52 | /// 要序列化的目标流。
53 | /// 是否序列化成功。
54 | bool Serialize(T packet, Stream destination) where T : Packet;
55 |
56 | ///
57 | /// 反序列化消息包头。
58 | ///
59 | /// 要反序列化的来源流。
60 | /// 用户自定义错误数据。
61 | /// 反序列化后的消息包头。
62 | IPacketHeader DeserializePacketHeader(Stream source, out object customErrorData);
63 |
64 | ///
65 | /// 反序列化消息包。
66 | ///
67 | /// 消息包头。
68 | /// 要反序列化的来源流。
69 | /// 用户自定义错误数据。
70 | /// 反序列化后的消息包。
71 | Packet DeserializePacket(IPacketHeader packetHeader, Stream source, out object customErrorData);
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/GameFramework/Network/IPacketHandler.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Network
9 | {
10 | ///
11 | /// 网络消息包处理器接口。
12 | ///
13 | public interface IPacketHandler
14 | {
15 | ///
16 | /// 获取网络消息包协议编号。
17 | ///
18 | int Id
19 | {
20 | get;
21 | }
22 |
23 | ///
24 | /// 网络消息包处理函数。
25 | ///
26 | /// 网络消息包源。
27 | /// 网络消息包内容。
28 | void Handle(object sender, Packet packet);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/GameFramework/Network/IPacketHeader.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Network
9 | {
10 | ///
11 | /// 网络消息包头接口。
12 | ///
13 | public interface IPacketHeader
14 | {
15 | ///
16 | /// 获取网络消息包长度。
17 | ///
18 | int PacketLength
19 | {
20 | get;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/GameFramework/Network/NetworkClosedEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Network
9 | {
10 | ///
11 | /// 网络连接关闭事件。
12 | ///
13 | public sealed class NetworkClosedEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化网络连接关闭事件的新实例。
17 | ///
18 | public NetworkClosedEventArgs()
19 | {
20 | NetworkChannel = null;
21 | }
22 |
23 | ///
24 | /// 获取网络频道。
25 | ///
26 | public INetworkChannel NetworkChannel
27 | {
28 | get;
29 | private set;
30 | }
31 |
32 | ///
33 | /// 创建网络连接关闭事件。
34 | ///
35 | /// 网络频道。
36 | /// 创建的网络连接关闭事件。
37 | public static NetworkClosedEventArgs Create(INetworkChannel networkChannel)
38 | {
39 | NetworkClosedEventArgs networkClosedEventArgs = ReferencePool.Acquire();
40 | networkClosedEventArgs.NetworkChannel = networkChannel;
41 | return networkClosedEventArgs;
42 | }
43 |
44 | ///
45 | /// 清理网络连接关闭事件。
46 | ///
47 | public override void Clear()
48 | {
49 | NetworkChannel = null;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/GameFramework/Network/NetworkConnectedEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Network
9 | {
10 | ///
11 | /// 网络连接成功事件。
12 | ///
13 | public sealed class NetworkConnectedEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化网络连接成功事件的新实例。
17 | ///
18 | public NetworkConnectedEventArgs()
19 | {
20 | NetworkChannel = null;
21 | UserData = null;
22 | }
23 |
24 | ///
25 | /// 获取网络频道。
26 | ///
27 | public INetworkChannel NetworkChannel
28 | {
29 | get;
30 | private set;
31 | }
32 |
33 | ///
34 | /// 获取用户自定义数据。
35 | ///
36 | public object UserData
37 | {
38 | get;
39 | private set;
40 | }
41 |
42 | ///
43 | /// 创建网络连接成功事件。
44 | ///
45 | /// 网络频道。
46 | /// 用户自定义数据。
47 | /// 创建的网络连接成功事件。
48 | public static NetworkConnectedEventArgs Create(INetworkChannel networkChannel, object userData)
49 | {
50 | NetworkConnectedEventArgs networkConnectedEventArgs = ReferencePool.Acquire();
51 | networkConnectedEventArgs.NetworkChannel = networkChannel;
52 | networkConnectedEventArgs.UserData = userData;
53 | return networkConnectedEventArgs;
54 | }
55 |
56 | ///
57 | /// 清理网络连接成功事件。
58 | ///
59 | public override void Clear()
60 | {
61 | NetworkChannel = null;
62 | UserData = null;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/GameFramework/Network/NetworkCustomErrorEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Network
9 | {
10 | ///
11 | /// 用户自定义网络错误事件。
12 | ///
13 | public sealed class NetworkCustomErrorEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化用户自定义网络错误事件的新实例。
17 | ///
18 | public NetworkCustomErrorEventArgs()
19 | {
20 | NetworkChannel = null;
21 | CustomErrorData = null;
22 | }
23 |
24 | ///
25 | /// 获取网络频道。
26 | ///
27 | public INetworkChannel NetworkChannel
28 | {
29 | get;
30 | private set;
31 | }
32 |
33 | ///
34 | /// 获取用户自定义错误数据。
35 | ///
36 | public object CustomErrorData
37 | {
38 | get;
39 | private set;
40 | }
41 |
42 | ///
43 | /// 创建用户自定义网络错误事件。
44 | ///
45 | /// 网络频道。
46 | /// 用户自定义错误数据。
47 | /// 创建的用户自定义网络错误事件。
48 | public static NetworkCustomErrorEventArgs Create(INetworkChannel networkChannel, object customErrorData)
49 | {
50 | NetworkCustomErrorEventArgs networkCustomErrorEventArgs = ReferencePool.Acquire();
51 | networkCustomErrorEventArgs.NetworkChannel = networkChannel;
52 | networkCustomErrorEventArgs.CustomErrorData = customErrorData;
53 | return networkCustomErrorEventArgs;
54 | }
55 |
56 | ///
57 | /// 清理用户自定义网络错误事件。
58 | ///
59 | public override void Clear()
60 | {
61 | NetworkChannel = null;
62 | CustomErrorData = null;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/GameFramework/Network/NetworkErrorCode.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Network
9 | {
10 | ///
11 | /// 网络错误码。
12 | ///
13 | public enum NetworkErrorCode : byte
14 | {
15 | ///
16 | /// 未知错误。
17 | ///
18 | Unknown = 0,
19 |
20 | ///
21 | /// 地址族错误。
22 | ///
23 | AddressFamilyError,
24 |
25 | ///
26 | /// Socket 错误。
27 | ///
28 | SocketError,
29 |
30 | ///
31 | /// 连接错误。
32 | ///
33 | ConnectError,
34 |
35 | ///
36 | /// 发送错误。
37 | ///
38 | SendError,
39 |
40 | ///
41 | /// 接收错误。
42 | ///
43 | ReceiveError,
44 |
45 | ///
46 | /// 序列化错误。
47 | ///
48 | SerializeError,
49 |
50 | ///
51 | /// 反序列化消息包头错误。
52 | ///
53 | DeserializePacketHeaderError,
54 |
55 | ///
56 | /// 反序列化消息包错误。
57 | ///
58 | DeserializePacketError
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/GameFramework/Network/NetworkManager.ConnectState.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.Net.Sockets;
9 |
10 | namespace GameFramework.Network
11 | {
12 | internal sealed partial class NetworkManager : GameFrameworkModule, INetworkManager
13 | {
14 | private sealed class ConnectState
15 | {
16 | private readonly Socket m_Socket;
17 | private readonly object m_UserData;
18 |
19 | public ConnectState(Socket socket, object userData)
20 | {
21 | m_Socket = socket;
22 | m_UserData = userData;
23 | }
24 |
25 | public Socket Socket
26 | {
27 | get
28 | {
29 | return m_Socket;
30 | }
31 | }
32 |
33 | public object UserData
34 | {
35 | get
36 | {
37 | return m_UserData;
38 | }
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/GameFramework/Network/NetworkManager.HeartBeatState.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Network
9 | {
10 | internal sealed partial class NetworkManager : GameFrameworkModule, INetworkManager
11 | {
12 | private sealed class HeartBeatState
13 | {
14 | private float m_HeartBeatElapseSeconds;
15 | private int m_MissHeartBeatCount;
16 |
17 | public HeartBeatState()
18 | {
19 | m_HeartBeatElapseSeconds = 0f;
20 | m_MissHeartBeatCount = 0;
21 | }
22 |
23 | public float HeartBeatElapseSeconds
24 | {
25 | get
26 | {
27 | return m_HeartBeatElapseSeconds;
28 | }
29 | set
30 | {
31 | m_HeartBeatElapseSeconds = value;
32 | }
33 | }
34 |
35 | public int MissHeartBeatCount
36 | {
37 | get
38 | {
39 | return m_MissHeartBeatCount;
40 | }
41 | set
42 | {
43 | m_MissHeartBeatCount = value;
44 | }
45 | }
46 |
47 | public void Reset(bool resetHeartBeatElapseSeconds)
48 | {
49 | if (resetHeartBeatElapseSeconds)
50 | {
51 | m_HeartBeatElapseSeconds = 0f;
52 | }
53 |
54 | m_MissHeartBeatCount = 0;
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/GameFramework/Network/NetworkManager.SendState.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System;
9 | using System.IO;
10 |
11 | namespace GameFramework.Network
12 | {
13 | internal sealed partial class NetworkManager : GameFrameworkModule, INetworkManager
14 | {
15 | private sealed class SendState : IDisposable
16 | {
17 | private const int DefaultBufferLength = 1024 * 64;
18 | private MemoryStream m_Stream;
19 | private bool m_Disposed;
20 |
21 | public SendState()
22 | {
23 | m_Stream = new MemoryStream(DefaultBufferLength);
24 | m_Disposed = false;
25 | }
26 |
27 | public MemoryStream Stream
28 | {
29 | get
30 | {
31 | return m_Stream;
32 | }
33 | }
34 |
35 | public void Reset()
36 | {
37 | m_Stream.Position = 0L;
38 | m_Stream.SetLength(0L);
39 | }
40 |
41 | public void Dispose()
42 | {
43 | Dispose(true);
44 | GC.SuppressFinalize(this);
45 | }
46 |
47 | private void Dispose(bool disposing)
48 | {
49 | if (m_Disposed)
50 | {
51 | return;
52 | }
53 |
54 | if (disposing)
55 | {
56 | if (m_Stream != null)
57 | {
58 | m_Stream.Dispose();
59 | m_Stream = null;
60 | }
61 | }
62 |
63 | m_Disposed = true;
64 | }
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/GameFramework/Network/NetworkMissHeartBeatEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Network
9 | {
10 | ///
11 | /// 网络心跳包丢失事件。
12 | ///
13 | public sealed class NetworkMissHeartBeatEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化网络心跳包丢失事件的新实例。
17 | ///
18 | public NetworkMissHeartBeatEventArgs()
19 | {
20 | NetworkChannel = null;
21 | MissCount = 0;
22 | }
23 |
24 | ///
25 | /// 获取网络频道。
26 | ///
27 | public INetworkChannel NetworkChannel
28 | {
29 | get;
30 | private set;
31 | }
32 |
33 | ///
34 | /// 获取心跳包已丢失次数。
35 | ///
36 | public int MissCount
37 | {
38 | get;
39 | private set;
40 | }
41 |
42 | ///
43 | /// 创建网络心跳包丢失事件。
44 | ///
45 | /// 网络频道。
46 | /// 心跳包已丢失次数。
47 | /// 创建的网络心跳包丢失事件。
48 | public static NetworkMissHeartBeatEventArgs Create(INetworkChannel networkChannel, int missCount)
49 | {
50 | NetworkMissHeartBeatEventArgs networkMissHeartBeatEventArgs = ReferencePool.Acquire();
51 | networkMissHeartBeatEventArgs.NetworkChannel = networkChannel;
52 | networkMissHeartBeatEventArgs.MissCount = missCount;
53 | return networkMissHeartBeatEventArgs;
54 | }
55 |
56 | ///
57 | /// 清理网络心跳包丢失事件。
58 | ///
59 | public override void Clear()
60 | {
61 | NetworkChannel = null;
62 | MissCount = 0;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/GameFramework/Network/Packet.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Network
9 | {
10 | ///
11 | /// 网络消息包基类。
12 | ///
13 | public abstract class Packet : BaseEventArgs
14 | {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/GameFramework/Network/ServiceType.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Network
9 | {
10 | ///
11 | /// 网络服务类型。
12 | ///
13 | public enum ServiceType : byte
14 | {
15 | ///
16 | /// TCP 网络服务。
17 | ///
18 | Tcp = 0,
19 |
20 | ///
21 | /// 使用同步接收的 TCP 网络服务。
22 | ///
23 | TcpWithSyncReceive
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/GameFramework/ObjectPool/ReleaseObjectFilterCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System;
9 | using System.Collections.Generic;
10 |
11 | namespace GameFramework.ObjectPool
12 | {
13 | ///
14 | /// 释放对象筛选函数。
15 | ///
16 | /// 对象类型。
17 | /// 要筛选的对象集合。
18 | /// 需要释放的对象数量。
19 | /// 对象过期参考时间。
20 | /// 经筛选需要释放的对象集合。
21 | public delegate List ReleaseObjectFilterCallback(List candidateObjects, int toReleaseCount, DateTime expireTime) where T : ObjectBase;
22 | }
23 |
--------------------------------------------------------------------------------
/GameFramework/Procedure/ProcedureBase.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using GameFramework.Fsm;
9 | using ProcedureOwner = GameFramework.Fsm.IFsm;
10 |
11 | namespace GameFramework.Procedure
12 | {
13 | ///
14 | /// 流程基类。
15 | ///
16 | public abstract class ProcedureBase : FsmState
17 | {
18 | ///
19 | /// 状态初始化时调用。
20 | ///
21 | /// 流程持有者。
22 | protected internal override void OnInit(ProcedureOwner procedureOwner)
23 | {
24 | base.OnInit(procedureOwner);
25 | }
26 |
27 | ///
28 | /// 进入状态时调用。
29 | ///
30 | /// 流程持有者。
31 | protected internal override void OnEnter(ProcedureOwner procedureOwner)
32 | {
33 | base.OnEnter(procedureOwner);
34 | }
35 |
36 | ///
37 | /// 状态轮询时调用。
38 | ///
39 | /// 流程持有者。
40 | /// 逻辑流逝时间,以秒为单位。
41 | /// 真实流逝时间,以秒为单位。
42 | protected internal override void OnUpdate(ProcedureOwner procedureOwner, float elapseSeconds, float realElapseSeconds)
43 | {
44 | base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);
45 | }
46 |
47 | ///
48 | /// 离开状态时调用。
49 | ///
50 | /// 流程持有者。
51 | /// 是否是关闭状态机时触发。
52 | protected internal override void OnLeave(ProcedureOwner procedureOwner, bool isShutdown)
53 | {
54 | base.OnLeave(procedureOwner, isShutdown);
55 | }
56 |
57 | ///
58 | /// 状态销毁时调用。
59 | ///
60 | /// 流程持有者。
61 | protected internal override void OnDestroy(ProcedureOwner procedureOwner)
62 | {
63 | base.OnDestroy(procedureOwner);
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/GameFramework/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.Reflection;
9 | using System.Runtime.InteropServices;
10 |
11 | // 有关程序集的一般信息由以下控制。更改这些特性值可修改与程序集关联的信息。
12 | [assembly: AssemblyTitle("Game Framework")]
13 | [assembly: AssemblyDescription("Game Framework")]
14 | [assembly: AssemblyConfiguration("")]
15 | [assembly: AssemblyCompany("Jiang Yin")]
16 | [assembly: AssemblyProduct("Game Framework")]
17 | [assembly: AssemblyCopyright("Copyright © 2013-2021 Jiang Yin")]
18 | [assembly: AssemblyTrademark("Copyright © 2013-2021 Jiang Yin")]
19 | [assembly: AssemblyCulture("")]
20 |
21 | // 将 ComVisible 设置为 false 将使此程序集中的类型对 COM 组件不可见。
22 | // 如果需要从 COM 访问此程序集中的类型,请将此类型的 ComVisible 特性设置为 true。
23 | [assembly: ComVisible(false)]
24 |
25 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID。
26 | [assembly: Guid("109d7f39-79ab-4862-9f73-0b8c638930c6")]
27 |
28 | // 程序集的版本信息由下列四个值组成:
29 | //
30 | // 主版本
31 | // 次版本
32 | // 生成号
33 | // 修订号
34 | //
35 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,方法是按如下所示使用“*”:
36 | // [assembly: AssemblyVersion("1.0.*")]
37 | [assembly: AssemblyVersion("0.0.0.0")]
38 | [assembly: AssemblyFileVersion("0.0.0.0")]
39 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ApplyResourcesCompleteCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 使用可更新模式并应用资源包资源完成时的回调函数。
12 | ///
13 | /// 应用的资源包路径。
14 | /// 应用资源包资源结果,全部成功为 true,否则为 false。
15 | public delegate void ApplyResourcesCompleteCallback(string resourcePackPath, bool result);
16 | }
17 |
--------------------------------------------------------------------------------
/GameFramework/Resource/CheckResourcesCompleteCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 使用可更新模式并检查资源完成时的回调函数。
12 | ///
13 | /// 已移动的资源数量。
14 | /// 已移除的资源数量。
15 | /// 可更新的资源数量。
16 | /// 可更新的资源总大小。
17 | /// 可更新的压缩后总大小。
18 | public delegate void CheckResourcesCompleteCallback(int movedCount, int removedCount, int updateCount, long updateTotalLength, long updateTotalCompressedLength);
19 | }
20 |
--------------------------------------------------------------------------------
/GameFramework/Resource/CheckVersionListResult.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 检查版本资源列表结果。
12 | ///
13 | public enum CheckVersionListResult : byte
14 | {
15 | ///
16 | /// 已经是最新的。
17 | ///
18 | Updated = 0,
19 |
20 | ///
21 | /// 需要更新。
22 | ///
23 | NeedUpdate
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/GameFramework/Resource/Constant.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 资源相关常量。
12 | ///
13 | internal static class Constant
14 | {
15 | ///
16 | /// 默认资源加载优先级。
17 | ///
18 | internal const int DefaultPriority = 0;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/GameFramework/Resource/DecryptResourceCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 解密资源回调函数。
12 | ///
13 | /// 要解密的资源二进制流。
14 | /// 解密二进制流的起始位置。
15 | /// 解密二进制流的长度。
16 | /// 资源名称。
17 | /// 变体名称。
18 | /// 扩展名称。
19 | /// 资源是否在只读区。
20 | /// 文件系统名称。
21 | /// 资源加载方式。
22 | /// 资源大小。
23 | /// 资源哈希值。
24 | public delegate void DecryptResourceCallback(byte[] bytes, int startIndex, int count, string name, string variant, string extension, bool storageInReadOnly, string fileSystem, byte loadType, int length, int hashCode);
25 | }
26 |
--------------------------------------------------------------------------------
/GameFramework/Resource/HasAssetResult.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 检查资源是否存在的结果。
12 | ///
13 | public enum HasAssetResult : byte
14 | {
15 | ///
16 | /// 资源不存在。
17 | ///
18 | NotExist = 0,
19 |
20 | ///
21 | /// 资源尚未准备完毕。
22 | ///
23 | NotReady,
24 |
25 | ///
26 | /// 存在资源且存储在磁盘上。
27 | ///
28 | AssetOnDisk,
29 |
30 | ///
31 | /// 存在资源且存储在文件系统里。
32 | ///
33 | AssetOnFileSystem,
34 |
35 | ///
36 | /// 存在二进制资源且存储在磁盘上。
37 | ///
38 | BinaryOnDisk,
39 |
40 | ///
41 | /// 存在二进制资源且存储在文件系统里。
42 | ///
43 | BinaryOnFileSystem
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/GameFramework/Resource/IResourceHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 资源辅助器接口。
12 | ///
13 | public interface IResourceHelper
14 | {
15 | ///
16 | /// 直接从指定文件路径加载数据流。
17 | ///
18 | /// 文件路径。
19 | /// 加载数据流回调函数集。
20 | /// 用户自定义数据。
21 | void LoadBytes(string fileUri, LoadBytesCallbacks loadBytesCallbacks, object userData);
22 |
23 | ///
24 | /// 卸载场景。
25 | ///
26 | /// 场景资源名称。
27 | /// 卸载场景回调函数集。
28 | /// 用户自定义数据。
29 | void UnloadScene(string sceneAssetName, UnloadSceneCallbacks unloadSceneCallbacks, object userData);
30 |
31 | ///
32 | /// 释放资源。
33 | ///
34 | /// 要释放的资源。
35 | void Release(object objectToRelease);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/GameFramework/Resource/InitResourcesCompleteCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 使用单机模式并初始化资源完成时的回调函数。
12 | ///
13 | public delegate void InitResourcesCompleteCallback();
14 | }
15 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadAssetDependencyAssetCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载资源时加载依赖资源回调函数。
12 | ///
13 | /// 要加载的资源名称。
14 | /// 被加载的依赖资源名称。
15 | /// 当前已加载依赖资源数量。
16 | /// 总共加载依赖资源数量。
17 | /// 用户自定义数据。
18 | public delegate void LoadAssetDependencyAssetCallback(string assetName, string dependencyAssetName, int loadedCount, int totalCount, object userData);
19 | }
20 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadAssetFailureCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载资源失败回调函数。
12 | ///
13 | /// 要加载的资源名称。
14 | /// 加载资源状态。
15 | /// 错误信息。
16 | /// 用户自定义数据。
17 | public delegate void LoadAssetFailureCallback(string assetName, LoadResourceStatus status, string errorMessage, object userData);
18 | }
19 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadAssetSuccessCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载资源成功回调函数。
12 | ///
13 | /// 要加载的资源名称。
14 | /// 已加载的资源。
15 | /// 加载持续时间。
16 | /// 用户自定义数据。
17 | public delegate void LoadAssetSuccessCallback(string assetName, object asset, float duration, object userData);
18 | }
19 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadAssetUpdateCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载资源更新回调函数。
12 | ///
13 | /// 要加载的资源名称。
14 | /// 加载资源进度。
15 | /// 用户自定义数据。
16 | public delegate void LoadAssetUpdateCallback(string assetName, float progress, object userData);
17 | }
18 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadBinaryCallbacks.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载二进制资源回调函数集。
12 | ///
13 | public sealed class LoadBinaryCallbacks
14 | {
15 | private readonly LoadBinarySuccessCallback m_LoadBinarySuccessCallback;
16 | private readonly LoadBinaryFailureCallback m_LoadBinaryFailureCallback;
17 |
18 | ///
19 | /// 初始化加载二进制资源回调函数集的新实例。
20 | ///
21 | /// 加载二进制资源成功回调函数。
22 | public LoadBinaryCallbacks(LoadBinarySuccessCallback loadBinarySuccessCallback)
23 | : this(loadBinarySuccessCallback, null)
24 | {
25 | }
26 |
27 | ///
28 | /// 初始化加载二进制资源回调函数集的新实例。
29 | ///
30 | /// 加载二进制资源成功回调函数。
31 | /// 加载二进制资源失败回调函数。
32 | public LoadBinaryCallbacks(LoadBinarySuccessCallback loadBinarySuccessCallback, LoadBinaryFailureCallback loadBinaryFailureCallback)
33 | {
34 | if (loadBinarySuccessCallback == null)
35 | {
36 | throw new GameFrameworkException("Load binary success callback is invalid.");
37 | }
38 |
39 | m_LoadBinarySuccessCallback = loadBinarySuccessCallback;
40 | m_LoadBinaryFailureCallback = loadBinaryFailureCallback;
41 | }
42 |
43 | ///
44 | /// 获取加载二进制资源成功回调函数。
45 | ///
46 | public LoadBinarySuccessCallback LoadBinarySuccessCallback
47 | {
48 | get
49 | {
50 | return m_LoadBinarySuccessCallback;
51 | }
52 | }
53 |
54 | ///
55 | /// 获取加载二进制资源失败回调函数。
56 | ///
57 | public LoadBinaryFailureCallback LoadBinaryFailureCallback
58 | {
59 | get
60 | {
61 | return m_LoadBinaryFailureCallback;
62 | }
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadBinaryFailureCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载二进制资源失败回调函数。
12 | ///
13 | /// 要加载的二进制资源名称。
14 | /// 加载二进制资源状态。
15 | /// 错误信息。
16 | /// 用户自定义数据。
17 | public delegate void LoadBinaryFailureCallback(string binaryAssetName, LoadResourceStatus status, string errorMessage, object userData);
18 | }
19 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadBinarySuccessCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载二进制资源成功回调函数。
12 | ///
13 | /// 要加载的二进制资源名称。
14 | /// 已加载的二进制资源。
15 | /// 加载持续时间。
16 | /// 用户自定义数据。
17 | public delegate void LoadBinarySuccessCallback(string binaryAssetName, byte[] binaryBytes, float duration, object userData);
18 | }
19 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadBytesCallbacks.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载数据流回调函数集。
12 | ///
13 | public sealed class LoadBytesCallbacks
14 | {
15 | private readonly LoadBytesSuccessCallback m_LoadBytesSuccessCallback;
16 | private readonly LoadBytesFailureCallback m_LoadBytesFailureCallback;
17 |
18 | ///
19 | /// 初始化加载数据流回调函数集的新实例。
20 | ///
21 | /// 加载数据流成功回调函数。
22 | public LoadBytesCallbacks(LoadBytesSuccessCallback loadBinarySuccessCallback)
23 | : this(loadBinarySuccessCallback, null)
24 | {
25 | }
26 |
27 | ///
28 | /// 初始化加载数据流回调函数集的新实例。
29 | ///
30 | /// 加载数据流成功回调函数。
31 | /// 加载数据流失败回调函数。
32 | public LoadBytesCallbacks(LoadBytesSuccessCallback loadBytesSuccessCallback, LoadBytesFailureCallback loadBytesFailureCallback)
33 | {
34 | if (loadBytesSuccessCallback == null)
35 | {
36 | throw new GameFrameworkException("Load bytes success callback is invalid.");
37 | }
38 |
39 | m_LoadBytesSuccessCallback = loadBytesSuccessCallback;
40 | m_LoadBytesFailureCallback = loadBytesFailureCallback;
41 | }
42 |
43 | ///
44 | /// 获取加载数据流成功回调函数。
45 | ///
46 | public LoadBytesSuccessCallback LoadBytesSuccessCallback
47 | {
48 | get
49 | {
50 | return m_LoadBytesSuccessCallback;
51 | }
52 | }
53 |
54 | ///
55 | /// 获取加载数据流失败回调函数。
56 | ///
57 | public LoadBytesFailureCallback LoadBytesFailureCallback
58 | {
59 | get
60 | {
61 | return m_LoadBytesFailureCallback;
62 | }
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadBytesFailureCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载数据流失败回调函数。
12 | ///
13 | /// 文件路径。
14 | /// 错误信息。
15 | /// 用户自定义数据。
16 | public delegate void LoadBytesFailureCallback(string fileUri, string errorMessage, object userData);
17 | }
18 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadBytesSuccessCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载数据流成功回调函数。
12 | ///
13 | /// 文件路径。
14 | /// 数据流。
15 | /// 加载持续时间。
16 | /// 用户自定义数据。
17 | public delegate void LoadBytesSuccessCallback(string fileUri, byte[] bytes, float duration, object userData);
18 | }
19 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadResourceAgentHelperErrorEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载资源代理辅助器错误事件。
12 | ///
13 | public sealed class LoadResourceAgentHelperErrorEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化加载资源代理辅助器错误事件的新实例。
17 | ///
18 | public LoadResourceAgentHelperErrorEventArgs()
19 | {
20 | Status = LoadResourceStatus.Success;
21 | ErrorMessage = null;
22 | }
23 |
24 | ///
25 | /// 获取加载资源状态。
26 | ///
27 | public LoadResourceStatus Status
28 | {
29 | get;
30 | private set;
31 | }
32 |
33 | ///
34 | /// 获取错误信息。
35 | ///
36 | public string ErrorMessage
37 | {
38 | get;
39 | private set;
40 | }
41 |
42 | ///
43 | /// 创建加载资源代理辅助器错误事件。
44 | ///
45 | /// 加载资源状态。
46 | /// 错误信息。
47 | /// 创建的加载资源代理辅助器错误事件。
48 | public static LoadResourceAgentHelperErrorEventArgs Create(LoadResourceStatus status, string errorMessage)
49 | {
50 | LoadResourceAgentHelperErrorEventArgs loadResourceAgentHelperErrorEventArgs = ReferencePool.Acquire();
51 | loadResourceAgentHelperErrorEventArgs.Status = status;
52 | loadResourceAgentHelperErrorEventArgs.ErrorMessage = errorMessage;
53 | return loadResourceAgentHelperErrorEventArgs;
54 | }
55 |
56 | ///
57 | /// 清理加载资源代理辅助器错误事件。
58 | ///
59 | public override void Clear()
60 | {
61 | Status = LoadResourceStatus.Success;
62 | ErrorMessage = null;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadResourceAgentHelperLoadCompleteEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载资源代理辅助器异步加载资源完成事件。
12 | ///
13 | public sealed class LoadResourceAgentHelperLoadCompleteEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化加载资源代理辅助器异步加载资源完成事件的新实例。
17 | ///
18 | public LoadResourceAgentHelperLoadCompleteEventArgs()
19 | {
20 | Asset = null;
21 | }
22 |
23 | ///
24 | /// 获取加载的资源。
25 | ///
26 | public object Asset
27 | {
28 | get;
29 | private set;
30 | }
31 |
32 | ///
33 | /// 创建加载资源代理辅助器异步加载资源完成事件。
34 | ///
35 | /// 加载的资源。
36 | /// 创建的加载资源代理辅助器异步加载资源完成事件。
37 | public static LoadResourceAgentHelperLoadCompleteEventArgs Create(object asset)
38 | {
39 | LoadResourceAgentHelperLoadCompleteEventArgs loadResourceAgentHelperLoadCompleteEventArgs = ReferencePool.Acquire();
40 | loadResourceAgentHelperLoadCompleteEventArgs.Asset = asset;
41 | return loadResourceAgentHelperLoadCompleteEventArgs;
42 | }
43 |
44 | ///
45 | /// 清理加载资源代理辅助器异步加载资源完成事件。
46 | ///
47 | public override void Clear()
48 | {
49 | Asset = null;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadResourceAgentHelperParseBytesCompleteEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载资源代理辅助器异步将资源二进制流转换为加载对象完成事件。
12 | ///
13 | public sealed class LoadResourceAgentHelperParseBytesCompleteEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化加载资源代理辅助器异步将资源二进制流转换为加载对象完成事件的新实例。
17 | ///
18 | public LoadResourceAgentHelperParseBytesCompleteEventArgs()
19 | {
20 | Resource = null;
21 | }
22 |
23 | ///
24 | /// 获取加载对象。
25 | ///
26 | public object Resource
27 | {
28 | get;
29 | private set;
30 | }
31 |
32 | ///
33 | /// 创建加载资源代理辅助器异步将资源二进制流转换为加载对象完成事件。
34 | ///
35 | /// 资源对象。
36 | /// 创建的加载资源代理辅助器异步将资源二进制流转换为加载对象完成事件。
37 | public static LoadResourceAgentHelperParseBytesCompleteEventArgs Create(object resource)
38 | {
39 | LoadResourceAgentHelperParseBytesCompleteEventArgs loadResourceAgentHelperParseBytesCompleteEventArgs = ReferencePool.Acquire();
40 | loadResourceAgentHelperParseBytesCompleteEventArgs.Resource = resource;
41 | return loadResourceAgentHelperParseBytesCompleteEventArgs;
42 | }
43 |
44 | ///
45 | /// 清理加载资源代理辅助器异步将资源二进制流转换为加载对象完成事件。
46 | ///
47 | public override void Clear()
48 | {
49 | Resource = null;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadResourceAgentHelperReadBytesCompleteEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载资源代理辅助器异步读取资源二进制流完成事件。
12 | ///
13 | public sealed class LoadResourceAgentHelperReadBytesCompleteEventArgs : GameFrameworkEventArgs
14 | {
15 | private byte[] m_Bytes;
16 |
17 | ///
18 | /// 初始化加载资源代理辅助器异步读取资源二进制流完成事件的新实例。
19 | ///
20 | public LoadResourceAgentHelperReadBytesCompleteEventArgs()
21 | {
22 | m_Bytes = null;
23 | }
24 |
25 | ///
26 | /// 创建加载资源代理辅助器异步读取资源二进制流完成事件。
27 | ///
28 | /// 资源的二进制流。
29 | /// 创建的加载资源代理辅助器异步读取资源二进制流完成事件。
30 | public static LoadResourceAgentHelperReadBytesCompleteEventArgs Create(byte[] bytes)
31 | {
32 | LoadResourceAgentHelperReadBytesCompleteEventArgs loadResourceAgentHelperReadBytesCompleteEventArgs = ReferencePool.Acquire();
33 | loadResourceAgentHelperReadBytesCompleteEventArgs.m_Bytes = bytes;
34 | return loadResourceAgentHelperReadBytesCompleteEventArgs;
35 | }
36 |
37 | ///
38 | /// 清理加载资源代理辅助器异步读取资源二进制流完成事件。
39 | ///
40 | public override void Clear()
41 | {
42 | m_Bytes = null;
43 | }
44 |
45 | ///
46 | /// 获取资源的二进制流。
47 | ///
48 | /// 资源的二进制流。
49 | public byte[] GetBytes()
50 | {
51 | return m_Bytes;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadResourceAgentHelperReadFileCompleteEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载资源代理辅助器异步将资源文件转换为加载对象完成事件。
12 | ///
13 | public sealed class LoadResourceAgentHelperReadFileCompleteEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化加载资源代理辅助器异步将资源文件转换为加载对象完成事件的新实例。
17 | ///
18 | public LoadResourceAgentHelperReadFileCompleteEventArgs()
19 | {
20 | Resource = null;
21 | }
22 |
23 | ///
24 | /// 获取加载对象。
25 | ///
26 | public object Resource
27 | {
28 | get;
29 | private set;
30 | }
31 |
32 | ///
33 | /// 创建加载资源代理辅助器异步将资源文件转换为加载对象完成事件。
34 | ///
35 | /// 资源对象。
36 | /// 创建的加载资源代理辅助器异步将资源文件转换为加载对象完成事件。
37 | public static LoadResourceAgentHelperReadFileCompleteEventArgs Create(object resource)
38 | {
39 | LoadResourceAgentHelperReadFileCompleteEventArgs loadResourceAgentHelperReadFileCompleteEventArgs = ReferencePool.Acquire();
40 | loadResourceAgentHelperReadFileCompleteEventArgs.Resource = resource;
41 | return loadResourceAgentHelperReadFileCompleteEventArgs;
42 | }
43 |
44 | ///
45 | /// 清理加载资源代理辅助器异步将资源文件转换为加载对象完成事件。
46 | ///
47 | public override void Clear()
48 | {
49 | Resource = null;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadResourceAgentHelperUpdateEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载资源代理辅助器更新事件。
12 | ///
13 | public sealed class LoadResourceAgentHelperUpdateEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化加载资源代理辅助器更新事件的新实例。
17 | ///
18 | public LoadResourceAgentHelperUpdateEventArgs()
19 | {
20 | Type = LoadResourceProgress.Unknown;
21 | Progress = 0f;
22 | }
23 |
24 | ///
25 | /// 获取进度类型。
26 | ///
27 | public LoadResourceProgress Type
28 | {
29 | get;
30 | private set;
31 | }
32 |
33 | ///
34 | /// 获取进度。
35 | ///
36 | public float Progress
37 | {
38 | get;
39 | private set;
40 | }
41 |
42 | ///
43 | /// 创建加载资源代理辅助器更新事件。
44 | ///
45 | /// 进度类型。
46 | /// 进度。
47 | /// 创建的加载资源代理辅助器更新事件。
48 | public static LoadResourceAgentHelperUpdateEventArgs Create(LoadResourceProgress type, float progress)
49 | {
50 | LoadResourceAgentHelperUpdateEventArgs loadResourceAgentHelperUpdateEventArgs = ReferencePool.Acquire();
51 | loadResourceAgentHelperUpdateEventArgs.Type = type;
52 | loadResourceAgentHelperUpdateEventArgs.Progress = progress;
53 | return loadResourceAgentHelperUpdateEventArgs;
54 | }
55 |
56 | ///
57 | /// 清理加载资源代理辅助器更新事件。
58 | ///
59 | public override void Clear()
60 | {
61 | Type = LoadResourceProgress.Unknown;
62 | Progress = 0f;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadResourceProgress.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载资源进度类型。
12 | ///
13 | public enum LoadResourceProgress : byte
14 | {
15 | ///
16 | /// 未知类型。
17 | ///
18 | Unknown = 0,
19 |
20 | ///
21 | /// 读取资源包。
22 | ///
23 | ReadResource,
24 |
25 | ///
26 | /// 加载资源包。
27 | ///
28 | LoadResource,
29 |
30 | ///
31 | /// 加载资源。
32 | ///
33 | LoadAsset,
34 |
35 | ///
36 | /// 加载场景。
37 | ///
38 | LoadScene
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadResourceStatus.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载资源状态。
12 | ///
13 | public enum LoadResourceStatus : byte
14 | {
15 | ///
16 | /// 加载资源完成。
17 | ///
18 | Success = 0,
19 |
20 | ///
21 | /// 资源不存在。
22 | ///
23 | NotExist,
24 |
25 | ///
26 | /// 资源尚未准备完毕。
27 | ///
28 | NotReady,
29 |
30 | ///
31 | /// 依赖资源错误。
32 | ///
33 | DependencyError,
34 |
35 | ///
36 | /// 资源类型错误。
37 | ///
38 | TypeError,
39 |
40 | ///
41 | /// 加载资源错误。
42 | ///
43 | AssetError
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadSceneDependencyAssetCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载场景时加载依赖资源回调函数。
12 | ///
13 | /// 要加载的场景资源名称。
14 | /// 被加载的依赖资源名称。
15 | /// 当前已加载依赖资源数量。
16 | /// 总共加载依赖资源数量。
17 | /// 用户自定义数据。
18 | public delegate void LoadSceneDependencyAssetCallback(string sceneAssetName, string dependencyAssetName, int loadedCount, int totalCount, object userData);
19 | }
20 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadSceneFailureCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载场景失败回调函数。
12 | ///
13 | /// 要加载的场景资源名称。
14 | /// 加载场景状态。
15 | /// 错误信息。
16 | /// 用户自定义数据。
17 | public delegate void LoadSceneFailureCallback(string sceneAssetName, LoadResourceStatus status, string errorMessage, object userData);
18 | }
19 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadSceneSuccessCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载场景成功回调函数。
12 | ///
13 | /// 要加载的场景资源名称。
14 | /// 加载持续时间。
15 | /// 用户自定义数据。
16 | public delegate void LoadSceneSuccessCallback(string sceneAssetName, float duration, object userData);
17 | }
18 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LoadSceneUpdateCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 加载场景更新回调函数。
12 | ///
13 | /// 要加载的场景资源名称。
14 | /// 加载场景进度。
15 | /// 用户自定义数据。
16 | public delegate void LoadSceneUpdateCallback(string sceneAssetName, float progress, object userData);
17 | }
18 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LocalVersionList.FileSystem.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.Runtime.InteropServices;
9 |
10 | namespace GameFramework.Resource
11 | {
12 | public partial struct LocalVersionList
13 | {
14 | ///
15 | /// 文件系统。
16 | ///
17 | [StructLayout(LayoutKind.Auto)]
18 | public struct FileSystem
19 | {
20 | private static readonly int[] EmptyIntArray = new int[] { };
21 |
22 | private readonly string m_Name;
23 | private readonly int[] m_ResourceIndexes;
24 |
25 | ///
26 | /// 初始化文件系统的新实例。
27 | ///
28 | /// 文件系统名称。
29 | /// 文件系统包含的资源索引集合。
30 | public FileSystem(string name, int[] resourceIndexes)
31 | {
32 | if (name == null)
33 | {
34 | throw new GameFrameworkException("Name is invalid.");
35 | }
36 |
37 | m_Name = name;
38 | m_ResourceIndexes = resourceIndexes ?? EmptyIntArray;
39 | }
40 |
41 | ///
42 | /// 获取文件系统名称。
43 | ///
44 | public string Name
45 | {
46 | get
47 | {
48 | return m_Name;
49 | }
50 | }
51 |
52 | ///
53 | /// 获取文件系统包含的资源索引集合。
54 | ///
55 | /// 文件系统包含的资源索引集合。
56 | public int[] GetResourceIndexes()
57 | {
58 | return m_ResourceIndexes;
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/GameFramework/Resource/LocalVersionList.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.Runtime.InteropServices;
9 |
10 | namespace GameFramework.Resource
11 | {
12 | ///
13 | /// 本地版本资源列表。
14 | ///
15 | [StructLayout(LayoutKind.Auto)]
16 | public partial struct LocalVersionList
17 | {
18 | private static readonly Resource[] EmptyResourceArray = new Resource[] { };
19 | private static readonly FileSystem[] EmptyFileSystemArray = new FileSystem[] { };
20 |
21 | private readonly bool m_IsValid;
22 | private readonly Resource[] m_Resources;
23 | private readonly FileSystem[] m_FileSystems;
24 |
25 | ///
26 | /// 初始化本地版本资源列表的新实例。
27 | ///
28 | /// 包含的资源集合。
29 | /// 包含的文件系统集合。
30 | public LocalVersionList(Resource[] resources, FileSystem[] fileSystems)
31 | {
32 | m_IsValid = true;
33 | m_Resources = resources ?? EmptyResourceArray;
34 | m_FileSystems = fileSystems ?? EmptyFileSystemArray;
35 | }
36 |
37 | ///
38 | /// 获取本地版本资源列表是否有效。
39 | ///
40 | public bool IsValid
41 | {
42 | get
43 | {
44 | return m_IsValid;
45 | }
46 | }
47 |
48 | ///
49 | /// 获取包含的资源集合。
50 | ///
51 | /// 包含的资源集合。
52 | public Resource[] GetResources()
53 | {
54 | if (!m_IsValid)
55 | {
56 | throw new GameFrameworkException("Data is invalid.");
57 | }
58 |
59 | return m_Resources;
60 | }
61 |
62 | ///
63 | /// 获取包含的文件系统集合。
64 | ///
65 | /// 包含的文件系统集合。
66 | public FileSystem[] GetFileSystems()
67 | {
68 | if (!m_IsValid)
69 | {
70 | throw new GameFrameworkException("Data is invalid.");
71 | }
72 |
73 | return m_FileSystems;
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/GameFramework/Resource/PackageVersionList.Asset.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.Runtime.InteropServices;
9 |
10 | namespace GameFramework.Resource
11 | {
12 | public partial struct PackageVersionList
13 | {
14 | ///
15 | /// 资源。
16 | ///
17 | [StructLayout(LayoutKind.Auto)]
18 | public struct Asset
19 | {
20 | private static readonly int[] EmptyIntArray = new int[] { };
21 |
22 | private readonly string m_Name;
23 | private readonly int[] m_DependencyAssetIndexes;
24 |
25 | ///
26 | /// 初始化资源的新实例。
27 | ///
28 | /// 资源名称。
29 | /// 资源包含的依赖资源索引集合。
30 | public Asset(string name, int[] dependencyAssetIndexes)
31 | {
32 | if (string.IsNullOrEmpty(name))
33 | {
34 | throw new GameFrameworkException("Name is invalid.");
35 | }
36 |
37 | m_Name = name;
38 | m_DependencyAssetIndexes = dependencyAssetIndexes ?? EmptyIntArray;
39 | }
40 |
41 | ///
42 | /// 获取资源名称。
43 | ///
44 | public string Name
45 | {
46 | get
47 | {
48 | return m_Name;
49 | }
50 | }
51 |
52 | ///
53 | /// 获取资源包含的依赖资源索引集合。
54 | ///
55 | /// 资源包含的依赖资源索引集合。
56 | public int[] GetDependencyAssetIndexes()
57 | {
58 | return m_DependencyAssetIndexes;
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/GameFramework/Resource/PackageVersionList.FileSystem.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.Runtime.InteropServices;
9 |
10 | namespace GameFramework.Resource
11 | {
12 | public partial struct PackageVersionList
13 | {
14 | ///
15 | /// 文件系统。
16 | ///
17 | [StructLayout(LayoutKind.Auto)]
18 | public struct FileSystem
19 | {
20 | private static readonly int[] EmptyIntArray = new int[] { };
21 |
22 | private readonly string m_Name;
23 | private readonly int[] m_ResourceIndexes;
24 |
25 | ///
26 | /// 初始化文件系统的新实例。
27 | ///
28 | /// 文件系统名称。
29 | /// 文件系统包含的资源索引集合。
30 | public FileSystem(string name, int[] resourceIndexes)
31 | {
32 | if (name == null)
33 | {
34 | throw new GameFrameworkException("Name is invalid.");
35 | }
36 |
37 | m_Name = name;
38 | m_ResourceIndexes = resourceIndexes ?? EmptyIntArray;
39 | }
40 |
41 | ///
42 | /// 获取文件系统名称。
43 | ///
44 | public string Name
45 | {
46 | get
47 | {
48 | return m_Name;
49 | }
50 | }
51 |
52 | ///
53 | /// 获取文件系统包含的资源索引集合。
54 | ///
55 | /// 文件系统包含的资源索引集合。
56 | public int[] GetResourceIndexes()
57 | {
58 | return m_ResourceIndexes;
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/GameFramework/Resource/PackageVersionList.ResourceGroup.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.Runtime.InteropServices;
9 |
10 | namespace GameFramework.Resource
11 | {
12 | public partial struct PackageVersionList
13 | {
14 | ///
15 | /// 资源组。
16 | ///
17 | [StructLayout(LayoutKind.Auto)]
18 | public struct ResourceGroup
19 | {
20 | private static readonly int[] EmptyIntArray = new int[] { };
21 |
22 | private readonly string m_Name;
23 | private readonly int[] m_ResourceIndexes;
24 |
25 | ///
26 | /// 初始化资源组的新实例。
27 | ///
28 | /// 资源组名称。
29 | /// 资源组包含的资源索引集合。
30 | public ResourceGroup(string name, int[] resourceIndexes)
31 | {
32 | if (name == null)
33 | {
34 | throw new GameFrameworkException("Name is invalid.");
35 | }
36 |
37 | m_Name = name;
38 | m_ResourceIndexes = resourceIndexes ?? EmptyIntArray;
39 | }
40 |
41 | ///
42 | /// 获取资源组名称。
43 | ///
44 | public string Name
45 | {
46 | get
47 | {
48 | return m_Name;
49 | }
50 | }
51 |
52 | ///
53 | /// 获取资源组包含的资源索引集合。
54 | ///
55 | /// 资源组包含的资源索引集合。
56 | public int[] GetResourceIndexes()
57 | {
58 | return m_ResourceIndexes;
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/GameFramework/Resource/PackageVersionListSerializer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 单机模式版本资源列表序列化器。
12 | ///
13 | public sealed class PackageVersionListSerializer : GameFrameworkSerializer
14 | {
15 | private static readonly byte[] Header = new byte[] { (byte)'G', (byte)'F', (byte)'P' };
16 |
17 | ///
18 | /// 初始化单机模式版本资源列表序列化器的新实例。
19 | ///
20 | public PackageVersionListSerializer()
21 | {
22 | }
23 |
24 | ///
25 | /// 获取单机模式版本资源列表头标识。
26 | ///
27 | /// 单机模式版本资源列表头标识。
28 | protected override byte[] GetHeader()
29 | {
30 | return Header;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ReadOnlyVersionListSerializer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 本地只读区版本资源列表序列化器。
12 | ///
13 | public sealed class ReadOnlyVersionListSerializer : GameFrameworkSerializer
14 | {
15 | private static readonly byte[] Header = new byte[] { (byte)'G', (byte)'F', (byte)'R' };
16 |
17 | ///
18 | /// 初始化本地只读区版本资源列表序列化器的新实例。
19 | ///
20 | public ReadOnlyVersionListSerializer()
21 | {
22 | }
23 |
24 | ///
25 | /// 获取本地只读区版本资源列表头标识。
26 | ///
27 | /// 本地只读区版本资源列表头标识。
28 | protected override byte[] GetHeader()
29 | {
30 | return Header;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ReadWriteVersionListSerializer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 本地读写区版本资源列表序列化器。
12 | ///
13 | public sealed class ReadWriteVersionListSerializer : GameFrameworkSerializer
14 | {
15 | private static readonly byte[] Header = new byte[] { (byte)'G', (byte)'F', (byte)'W' };
16 |
17 | ///
18 | /// 初始化本地读写区版本资源列表序列化器的新实例。
19 | ///
20 | public ReadWriteVersionListSerializer()
21 | {
22 | }
23 |
24 | ///
25 | /// 获取本地读写区版本资源列表头标识。
26 | ///
27 | /// 本地读写区版本资源列表头标识。
28 | protected override byte[] GetHeader()
29 | {
30 | return Header;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ResourceApplyStartEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 资源应用开始事件。
12 | ///
13 | public sealed class ResourceApplyStartEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化资源应用开始事件的新实例。
17 | ///
18 | public ResourceApplyStartEventArgs()
19 | {
20 | ResourcePackPath = null;
21 | Count = 0;
22 | TotalLength = 0L;
23 | }
24 |
25 | ///
26 | /// 获取资源包路径。
27 | ///
28 | public string ResourcePackPath
29 | {
30 | get;
31 | private set;
32 | }
33 |
34 | ///
35 | /// 获取要应用资源的数量。
36 | ///
37 | public int Count
38 | {
39 | get;
40 | private set;
41 | }
42 |
43 | ///
44 | /// 获取要应用资源的总大小。
45 | ///
46 | public long TotalLength
47 | {
48 | get;
49 | private set;
50 | }
51 |
52 | ///
53 | /// 创建资源应用开始事件。
54 | ///
55 | /// 资源包路径。
56 | /// 要应用资源的数量。
57 | /// 要应用资源的总大小。
58 | /// 创建的资源应用开始事件。
59 | public static ResourceApplyStartEventArgs Create(string resourcePackPath, int count, long totalLength)
60 | {
61 | ResourceApplyStartEventArgs resourceApplyStartEventArgs = ReferencePool.Acquire();
62 | resourceApplyStartEventArgs.ResourcePackPath = resourcePackPath;
63 | resourceApplyStartEventArgs.Count = count;
64 | resourceApplyStartEventArgs.TotalLength = totalLength;
65 | return resourceApplyStartEventArgs;
66 | }
67 |
68 | ///
69 | /// 清理资源应用开始事件。
70 | ///
71 | public override void Clear()
72 | {
73 | ResourcePackPath = null;
74 | Count = 0;
75 | TotalLength = 0L;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ResourceManager.AssetInfo.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | internal sealed partial class ResourceManager : GameFrameworkModule, IResourceManager
11 | {
12 | ///
13 | /// 资源信息。
14 | ///
15 | private sealed class AssetInfo
16 | {
17 | private readonly string m_AssetName;
18 | private readonly ResourceName m_ResourceName;
19 | private readonly string[] m_DependencyAssetNames;
20 |
21 | ///
22 | /// 初始化资源信息的新实例。
23 | ///
24 | /// 资源名称。
25 | /// 所在资源名称。
26 | /// 依赖资源名称。
27 | public AssetInfo(string assetName, ResourceName resourceName, string[] dependencyAssetNames)
28 | {
29 | m_AssetName = assetName;
30 | m_ResourceName = resourceName;
31 | m_DependencyAssetNames = dependencyAssetNames;
32 | }
33 |
34 | ///
35 | /// 获取资源名称。
36 | ///
37 | public string AssetName
38 | {
39 | get
40 | {
41 | return m_AssetName;
42 | }
43 | }
44 |
45 | ///
46 | /// 获取所在资源名称。
47 | ///
48 | public ResourceName ResourceName
49 | {
50 | get
51 | {
52 | return m_ResourceName;
53 | }
54 | }
55 |
56 | ///
57 | /// 获取依赖资源名称。
58 | ///
59 | /// 依赖资源名称。
60 | public string[] GetDependencyAssetNames()
61 | {
62 | return m_DependencyAssetNames;
63 | }
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ResourceManager.LoadType.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | internal sealed partial class ResourceManager : GameFrameworkModule, IResourceManager
11 | {
12 | ///
13 | /// 资源加载方式类型。
14 | ///
15 | private enum LoadType : byte
16 | {
17 | ///
18 | /// 使用文件方式加载。
19 | ///
20 | LoadFromFile = 0,
21 |
22 | ///
23 | /// 使用内存方式加载。
24 | ///
25 | LoadFromMemory,
26 |
27 | ///
28 | /// 使用内存快速解密方式加载。
29 | ///
30 | LoadFromMemoryAndQuickDecrypt,
31 |
32 | ///
33 | /// 使用内存解密方式加载。
34 | ///
35 | LoadFromMemoryAndDecrypt,
36 |
37 | ///
38 | /// 使用二进制方式加载。
39 | ///
40 | LoadFromBinary,
41 |
42 | ///
43 | /// 使用二进制快速解密方式加载。
44 | ///
45 | LoadFromBinaryAndQuickDecrypt,
46 |
47 | ///
48 | /// 使用二进制解密方式加载。
49 | ///
50 | LoadFromBinaryAndDecrypt
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ResourceManager.ReadWriteResourceInfo.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.Runtime.InteropServices;
9 |
10 | namespace GameFramework.Resource
11 | {
12 | internal sealed partial class ResourceManager : GameFrameworkModule, IResourceManager
13 | {
14 | [StructLayout(LayoutKind.Auto)]
15 | private struct ReadWriteResourceInfo
16 | {
17 | private readonly string m_FileSystemName;
18 | private readonly LoadType m_LoadType;
19 | private readonly int m_Length;
20 | private readonly int m_HashCode;
21 |
22 | public ReadWriteResourceInfo(string fileSystemName, LoadType loadType, int length, int hashCode)
23 | {
24 | m_FileSystemName = fileSystemName;
25 | m_LoadType = loadType;
26 | m_Length = length;
27 | m_HashCode = hashCode;
28 | }
29 |
30 | public bool UseFileSystem
31 | {
32 | get
33 | {
34 | return !string.IsNullOrEmpty(m_FileSystemName);
35 | }
36 | }
37 |
38 | public string FileSystemName
39 | {
40 | get
41 | {
42 | return m_FileSystemName;
43 | }
44 | }
45 |
46 | public LoadType LoadType
47 | {
48 | get
49 | {
50 | return m_LoadType;
51 | }
52 | }
53 |
54 | public int Length
55 | {
56 | get
57 | {
58 | return m_Length;
59 | }
60 | }
61 |
62 | public int HashCode
63 | {
64 | get
65 | {
66 | return m_HashCode;
67 | }
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ResourceManager.ResourceChecker.CheckInfo.CheckStatus.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | internal sealed partial class ResourceManager : GameFrameworkModule, IResourceManager
11 | {
12 | private sealed partial class ResourceChecker
13 | {
14 | private sealed partial class CheckInfo
15 | {
16 | ///
17 | /// 资源检查状态。
18 | ///
19 | public enum CheckStatus : byte
20 | {
21 | ///
22 | /// 资源状态未知。
23 | ///
24 | Unknown = 0,
25 |
26 | ///
27 | /// 资源存在且已存放于只读区中。
28 | ///
29 | StorageInReadOnly,
30 |
31 | ///
32 | /// 资源存在且已存放于读写区中。
33 | ///
34 | StorageInReadWrite,
35 |
36 | ///
37 | /// 资源不适用于当前变体。
38 | ///
39 | Unavailable,
40 |
41 | ///
42 | /// 资源需要更新。
43 | ///
44 | Update,
45 |
46 | ///
47 | /// 资源已废弃。
48 | ///
49 | Disuse
50 | }
51 | }
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ResourceManager.ResourceNameComparer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.Collections.Generic;
9 |
10 | namespace GameFramework.Resource
11 | {
12 | internal sealed partial class ResourceManager : GameFrameworkModule, IResourceManager
13 | {
14 | ///
15 | /// 资源名称比较器。
16 | ///
17 | private sealed class ResourceNameComparer : IComparer, IEqualityComparer
18 | {
19 | public int Compare(ResourceName x, ResourceName y)
20 | {
21 | return x.CompareTo(y);
22 | }
23 |
24 | public bool Equals(ResourceName x, ResourceName y)
25 | {
26 | return x.Equals(y);
27 | }
28 |
29 | public int GetHashCode(ResourceName obj)
30 | {
31 | return obj.GetHashCode();
32 | }
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ResourceMode.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 资源模式。
12 | ///
13 | public enum ResourceMode : byte
14 | {
15 | ///
16 | /// 未指定。
17 | ///
18 | Unspecified = 0,
19 |
20 | ///
21 | /// 单机模式。
22 | ///
23 | Package,
24 |
25 | ///
26 | /// 预下载的可更新模式。
27 | ///
28 | Updatable,
29 |
30 | ///
31 | /// 使用时下载的可更新模式。
32 | ///
33 | UpdatableWhilePlaying
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ResourcePackVersionListSerializer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 资源包版本资源列表序列化器。
12 | ///
13 | public sealed class ResourcePackVersionListSerializer : GameFrameworkSerializer
14 | {
15 | private static readonly byte[] Header = new byte[] { (byte)'G', (byte)'F', (byte)'K' };
16 |
17 | ///
18 | /// 初始化资源包版本资源列表序列化器的新实例。
19 | ///
20 | public ResourcePackVersionListSerializer()
21 | {
22 | }
23 |
24 | ///
25 | /// 获取资源包版本资源列表头标识。
26 | ///
27 | /// 资源包版本资源列表头标识。
28 | protected override byte[] GetHeader()
29 | {
30 | return Header;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ResourceUpdateAllCompleteEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 资源更新全部完成事件。
12 | ///
13 | public sealed class ResourceUpdateAllCompleteEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化资源更新全部完成事件的新实例。
17 | ///
18 | public ResourceUpdateAllCompleteEventArgs()
19 | {
20 | }
21 |
22 | ///
23 | /// 创建资源更新全部完成事件。
24 | ///
25 | /// 创建的资源更新全部完成事件。
26 | public static ResourceUpdateAllCompleteEventArgs Create()
27 | {
28 | return ReferencePool.Acquire();
29 | }
30 |
31 | ///
32 | /// 清理资源更新全部完成事件。
33 | ///
34 | public override void Clear()
35 | {
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ResourceVerifyFailureEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 资源校验失败事件。
12 | ///
13 | public sealed class ResourceVerifyFailureEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化资源校验失败事件的新实例。
17 | ///
18 | public ResourceVerifyFailureEventArgs()
19 | {
20 | Name = null;
21 | }
22 |
23 | ///
24 | /// 获取资源名称。
25 | ///
26 | public string Name
27 | {
28 | get;
29 | private set;
30 | }
31 |
32 | ///
33 | /// 创建资源校验失败事件。
34 | ///
35 | /// 资源名称。
36 | /// 创建的资源校验失败事件。
37 | public static ResourceVerifyFailureEventArgs Create(string name)
38 | {
39 | ResourceVerifyFailureEventArgs resourceVerifyFailureEventArgs = ReferencePool.Acquire();
40 | resourceVerifyFailureEventArgs.Name = name;
41 | return resourceVerifyFailureEventArgs;
42 | }
43 |
44 | ///
45 | /// 清理资源校验失败事件。
46 | ///
47 | public override void Clear()
48 | {
49 | Name = null;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ResourceVerifyStartEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 资源校验开始事件。
12 | ///
13 | public sealed class ResourceVerifyStartEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化资源校验开始事件的新实例。
17 | ///
18 | public ResourceVerifyStartEventArgs()
19 | {
20 | Count = 0;
21 | TotalLength = 0L;
22 | }
23 |
24 | ///
25 | /// 获取要校验资源的数量。
26 | ///
27 | public int Count
28 | {
29 | get;
30 | private set;
31 | }
32 |
33 | ///
34 | /// 获取要校验资源的总大小。
35 | ///
36 | public long TotalLength
37 | {
38 | get;
39 | private set;
40 | }
41 |
42 | ///
43 | /// 创建资源校验开始事件。
44 | ///
45 | /// 要校验资源的数量。
46 | /// 要校验资源的总大小。
47 | /// 创建的资源校验开始事件。
48 | public static ResourceVerifyStartEventArgs Create(int count, long totalLength)
49 | {
50 | ResourceVerifyStartEventArgs resourceVerifyStartEventArgs = ReferencePool.Acquire();
51 | resourceVerifyStartEventArgs.Count = count;
52 | resourceVerifyStartEventArgs.TotalLength = totalLength;
53 | return resourceVerifyStartEventArgs;
54 | }
55 |
56 | ///
57 | /// 清理资源校验开始事件。
58 | ///
59 | public override void Clear()
60 | {
61 | Count = 0;
62 | TotalLength = 0L;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/GameFramework/Resource/ResourceVerifySuccessEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 资源校验成功事件。
12 | ///
13 | public sealed class ResourceVerifySuccessEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化资源校验成功事件的新实例。
17 | ///
18 | public ResourceVerifySuccessEventArgs()
19 | {
20 | Name = null;
21 | Length = 0;
22 | }
23 |
24 | ///
25 | /// 获取资源名称。
26 | ///
27 | public string Name
28 | {
29 | get;
30 | private set;
31 | }
32 |
33 | ///
34 | /// 获取资源大小。
35 | ///
36 | public int Length
37 | {
38 | get;
39 | private set;
40 | }
41 |
42 | ///
43 | /// 创建资源校验成功事件。
44 | ///
45 | /// 资源名称。
46 | /// 资源大小。
47 | /// 创建的资源校验成功事件。
48 | public static ResourceVerifySuccessEventArgs Create(string name, int length)
49 | {
50 | ResourceVerifySuccessEventArgs resourceVerifySuccessEventArgs = ReferencePool.Acquire();
51 | resourceVerifySuccessEventArgs.Name = name;
52 | resourceVerifySuccessEventArgs.Length = length;
53 | return resourceVerifySuccessEventArgs;
54 | }
55 |
56 | ///
57 | /// 清理资源校验成功事件。
58 | ///
59 | public override void Clear()
60 | {
61 | Name = null;
62 | Length = 0;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/GameFramework/Resource/UnloadSceneCallbacks.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 卸载场景回调函数集。
12 | ///
13 | public sealed class UnloadSceneCallbacks
14 | {
15 | private readonly UnloadSceneSuccessCallback m_UnloadSceneSuccessCallback;
16 | private readonly UnloadSceneFailureCallback m_UnloadSceneFailureCallback;
17 |
18 | ///
19 | /// 初始化卸载场景回调函数集的新实例。
20 | ///
21 | /// 卸载场景成功回调函数。
22 | public UnloadSceneCallbacks(UnloadSceneSuccessCallback unloadSceneSuccessCallback)
23 | : this(unloadSceneSuccessCallback, null)
24 | {
25 | }
26 |
27 | ///
28 | /// 初始化卸载场景回调函数集的新实例。
29 | ///
30 | /// 卸载场景成功回调函数。
31 | /// 卸载场景失败回调函数。
32 | public UnloadSceneCallbacks(UnloadSceneSuccessCallback unloadSceneSuccessCallback, UnloadSceneFailureCallback unloadSceneFailureCallback)
33 | {
34 | if (unloadSceneSuccessCallback == null)
35 | {
36 | throw new GameFrameworkException("Unload scene success callback is invalid.");
37 | }
38 |
39 | m_UnloadSceneSuccessCallback = unloadSceneSuccessCallback;
40 | m_UnloadSceneFailureCallback = unloadSceneFailureCallback;
41 | }
42 |
43 | ///
44 | /// 获取卸载场景成功回调函数。
45 | ///
46 | public UnloadSceneSuccessCallback UnloadSceneSuccessCallback
47 | {
48 | get
49 | {
50 | return m_UnloadSceneSuccessCallback;
51 | }
52 | }
53 |
54 | ///
55 | /// 获取卸载场景失败回调函数。
56 | ///
57 | public UnloadSceneFailureCallback UnloadSceneFailureCallback
58 | {
59 | get
60 | {
61 | return m_UnloadSceneFailureCallback;
62 | }
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/GameFramework/Resource/UnloadSceneFailureCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 卸载场景失败回调函数。
12 | ///
13 | /// 要卸载的场景资源名称。
14 | /// 用户自定义数据。
15 | public delegate void UnloadSceneFailureCallback(string sceneAssetName, object userData);
16 | }
17 |
--------------------------------------------------------------------------------
/GameFramework/Resource/UnloadSceneSuccessCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 卸载场景成功回调函数。
12 | ///
13 | /// 要卸载的场景资源名称。
14 | /// 用户自定义数据。
15 | public delegate void UnloadSceneSuccessCallback(string sceneAssetName, object userData);
16 | }
17 |
--------------------------------------------------------------------------------
/GameFramework/Resource/UpdatableVersionList.Asset.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.Runtime.InteropServices;
9 |
10 | namespace GameFramework.Resource
11 | {
12 | public partial struct UpdatableVersionList
13 | {
14 | ///
15 | /// 资源。
16 | ///
17 | [StructLayout(LayoutKind.Auto)]
18 | public struct Asset
19 | {
20 | private static readonly int[] EmptyIntArray = new int[] { };
21 |
22 | private readonly string m_Name;
23 | private readonly int[] m_DependencyAssetIndexes;
24 |
25 | ///
26 | /// 初始化资源的新实例。
27 | ///
28 | /// 资源名称。
29 | /// 资源包含的依赖资源索引集合。
30 | public Asset(string name, int[] dependencyAssetIndexes)
31 | {
32 | if (string.IsNullOrEmpty(name))
33 | {
34 | throw new GameFrameworkException("Name is invalid.");
35 | }
36 |
37 | m_Name = name;
38 | m_DependencyAssetIndexes = dependencyAssetIndexes ?? EmptyIntArray;
39 | }
40 |
41 | ///
42 | /// 获取资源名称。
43 | ///
44 | public string Name
45 | {
46 | get
47 | {
48 | return m_Name;
49 | }
50 | }
51 |
52 | ///
53 | /// 获取资源包含的依赖资源索引集合。
54 | ///
55 | /// 资源包含的依赖资源索引集合。
56 | public int[] GetDependencyAssetIndexes()
57 | {
58 | return m_DependencyAssetIndexes;
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/GameFramework/Resource/UpdatableVersionList.FileSystem.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.Runtime.InteropServices;
9 |
10 | namespace GameFramework.Resource
11 | {
12 | public partial struct UpdatableVersionList
13 | {
14 | ///
15 | /// 文件系统。
16 | ///
17 | [StructLayout(LayoutKind.Auto)]
18 | public struct FileSystem
19 | {
20 | private static readonly int[] EmptyIntArray = new int[] { };
21 |
22 | private readonly string m_Name;
23 | private readonly int[] m_ResourceIndexes;
24 |
25 | ///
26 | /// 初始化文件系统的新实例。
27 | ///
28 | /// 文件系统名称。
29 | /// 文件系统包含的资源索引集合。
30 | public FileSystem(string name, int[] resourceIndexes)
31 | {
32 | if (name == null)
33 | {
34 | throw new GameFrameworkException("Name is invalid.");
35 | }
36 |
37 | m_Name = name;
38 | m_ResourceIndexes = resourceIndexes ?? EmptyIntArray;
39 | }
40 |
41 | ///
42 | /// 获取文件系统名称。
43 | ///
44 | public string Name
45 | {
46 | get
47 | {
48 | return m_Name;
49 | }
50 | }
51 |
52 | ///
53 | /// 获取文件系统包含的资源索引集合。
54 | ///
55 | /// 文件系统包含的资源索引集合。
56 | public int[] GetResourceIndexes()
57 | {
58 | return m_ResourceIndexes;
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/GameFramework/Resource/UpdatableVersionList.ResourceGroup.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System.Runtime.InteropServices;
9 |
10 | namespace GameFramework.Resource
11 | {
12 | public partial struct UpdatableVersionList
13 | {
14 | ///
15 | /// 资源组。
16 | ///
17 | [StructLayout(LayoutKind.Auto)]
18 | public struct ResourceGroup
19 | {
20 | private static readonly int[] EmptyIntArray = new int[] { };
21 |
22 | private readonly string m_Name;
23 | private readonly int[] m_ResourceIndexes;
24 |
25 | ///
26 | /// 初始化资源组的新实例。
27 | ///
28 | /// 资源组名称。
29 | /// 资源组包含的资源索引集合。
30 | public ResourceGroup(string name, int[] resourceIndexes)
31 | {
32 | if (name == null)
33 | {
34 | throw new GameFrameworkException("Name is invalid.");
35 | }
36 |
37 | m_Name = name;
38 | m_ResourceIndexes = resourceIndexes ?? EmptyIntArray;
39 | }
40 |
41 | ///
42 | /// 获取资源组名称。
43 | ///
44 | public string Name
45 | {
46 | get
47 | {
48 | return m_Name;
49 | }
50 | }
51 |
52 | ///
53 | /// 获取资源组包含的资源索引集合。
54 | ///
55 | /// 资源组包含的资源索引集合。
56 | public int[] GetResourceIndexes()
57 | {
58 | return m_ResourceIndexes;
59 | }
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/GameFramework/Resource/UpdatableVersionListSerializer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 可更新模式版本资源列表序列化器。
12 | ///
13 | public sealed class UpdatableVersionListSerializer : GameFrameworkSerializer
14 | {
15 | private static readonly byte[] Header = new byte[] { (byte)'G', (byte)'F', (byte)'U' };
16 |
17 | ///
18 | /// 初始化可更新模式版本资源列表序列化器的新实例。
19 | ///
20 | public UpdatableVersionListSerializer()
21 | {
22 | }
23 |
24 | ///
25 | /// 获取可更新模式版本资源列表头标识。
26 | ///
27 | /// 可更新模式版本资源列表头标识。
28 | protected override byte[] GetHeader()
29 | {
30 | return Header;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/GameFramework/Resource/UpdateResourcesCompleteCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 使用可更新模式并更新指定资源组完成时的回调函数。
12 | ///
13 | /// 更新的资源组。
14 | /// 更新资源结果,全部成功为 true,否则为 false。
15 | public delegate void UpdateResourcesCompleteCallback(IResourceGroup resourceGroup, bool result);
16 | }
17 |
--------------------------------------------------------------------------------
/GameFramework/Resource/UpdateVersionListFailureCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 版本资源列表更新失败回调函数。
12 | ///
13 | /// 版本资源列表更新地址。
14 | /// 错误信息。
15 | public delegate void UpdateVersionListFailureCallback(string downloadUri, string errorMessage);
16 | }
17 |
--------------------------------------------------------------------------------
/GameFramework/Resource/UpdateVersionListSuccessCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 版本资源列表更新成功回调函数。
12 | ///
13 | /// 版本资源列表更新后存放路径。
14 | /// 版本资源列表更新地址。
15 | public delegate void UpdateVersionListSuccessCallback(string downloadPath, string downloadUri);
16 | }
17 |
--------------------------------------------------------------------------------
/GameFramework/Resource/VerifyResourcesCompleteCallback.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Resource
9 | {
10 | ///
11 | /// 使用可更新模式并校验资源完成时的回调函数。
12 | ///
13 | /// 校验资源结果,全部成功为 true,否则为 false。
14 | public delegate void VerifyResourcesCompleteCallback(bool result);
15 | }
16 |
--------------------------------------------------------------------------------
/GameFramework/Scene/LoadSceneFailureEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Scene
9 | {
10 | ///
11 | /// 加载场景失败事件。
12 | ///
13 | public sealed class LoadSceneFailureEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化加载场景失败事件的新实例。
17 | ///
18 | public LoadSceneFailureEventArgs()
19 | {
20 | SceneAssetName = null;
21 | ErrorMessage = null;
22 | UserData = null;
23 | }
24 |
25 | ///
26 | /// 获取场景资源名称。
27 | ///
28 | public string SceneAssetName
29 | {
30 | get;
31 | private set;
32 | }
33 |
34 | ///
35 | /// 获取错误信息。
36 | ///
37 | public string ErrorMessage
38 | {
39 | get;
40 | private set;
41 | }
42 |
43 | ///
44 | /// 获取用户自定义数据。
45 | ///
46 | public object UserData
47 | {
48 | get;
49 | private set;
50 | }
51 |
52 | ///
53 | /// 创建加载场景失败事件。
54 | ///
55 | /// 场景资源名称。
56 | /// 错误信息。
57 | /// 用户自定义数据。
58 | /// 创建的加载场景失败事件。
59 | public static LoadSceneFailureEventArgs Create(string sceneAssetName, string errorMessage, object userData)
60 | {
61 | LoadSceneFailureEventArgs loadSceneFailureEventArgs = ReferencePool.Acquire();
62 | loadSceneFailureEventArgs.SceneAssetName = sceneAssetName;
63 | loadSceneFailureEventArgs.ErrorMessage = errorMessage;
64 | loadSceneFailureEventArgs.UserData = userData;
65 | return loadSceneFailureEventArgs;
66 | }
67 |
68 | ///
69 | /// 清理加载场景失败事件。
70 | ///
71 | public override void Clear()
72 | {
73 | SceneAssetName = null;
74 | ErrorMessage = null;
75 | UserData = null;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/GameFramework/Scene/LoadSceneSuccessEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Scene
9 | {
10 | ///
11 | /// 加载场景成功事件。
12 | ///
13 | public sealed class LoadSceneSuccessEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化加载场景成功事件的新实例。
17 | ///
18 | public LoadSceneSuccessEventArgs()
19 | {
20 | SceneAssetName = null;
21 | Duration = 0f;
22 | UserData = null;
23 | }
24 |
25 | ///
26 | /// 获取场景资源名称。
27 | ///
28 | public string SceneAssetName
29 | {
30 | get;
31 | private set;
32 | }
33 |
34 | ///
35 | /// 获取加载持续时间。
36 | ///
37 | public float Duration
38 | {
39 | get;
40 | private set;
41 | }
42 |
43 | ///
44 | /// 获取用户自定义数据。
45 | ///
46 | public object UserData
47 | {
48 | get;
49 | private set;
50 | }
51 |
52 | ///
53 | /// 创建加载场景成功事件。
54 | ///
55 | /// 场景资源名称。
56 | /// 加载持续时间。
57 | /// 用户自定义数据。
58 | /// 创建的加载场景成功事件。
59 | public static LoadSceneSuccessEventArgs Create(string sceneAssetName, float duration, object userData)
60 | {
61 | LoadSceneSuccessEventArgs loadSceneSuccessEventArgs = ReferencePool.Acquire();
62 | loadSceneSuccessEventArgs.SceneAssetName = sceneAssetName;
63 | loadSceneSuccessEventArgs.Duration = duration;
64 | loadSceneSuccessEventArgs.UserData = userData;
65 | return loadSceneSuccessEventArgs;
66 | }
67 |
68 | ///
69 | /// 清理加载场景成功事件。
70 | ///
71 | public override void Clear()
72 | {
73 | SceneAssetName = null;
74 | Duration = 0f;
75 | UserData = null;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/GameFramework/Scene/LoadSceneUpdateEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Scene
9 | {
10 | ///
11 | /// 加载场景更新事件。
12 | ///
13 | public sealed class LoadSceneUpdateEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化加载场景更新事件的新实例。
17 | ///
18 | public LoadSceneUpdateEventArgs()
19 | {
20 | SceneAssetName = null;
21 | Progress = 0f;
22 | UserData = null;
23 | }
24 |
25 | ///
26 | /// 获取场景资源名称。
27 | ///
28 | public string SceneAssetName
29 | {
30 | get;
31 | private set;
32 | }
33 |
34 | ///
35 | /// 获取加载场景进度。
36 | ///
37 | public float Progress
38 | {
39 | get;
40 | private set;
41 | }
42 |
43 | ///
44 | /// 获取用户自定义数据。
45 | ///
46 | public object UserData
47 | {
48 | get;
49 | private set;
50 | }
51 |
52 | ///
53 | /// 创建加载场景更新事件。
54 | ///
55 | /// 场景资源名称。
56 | /// 加载场景进度。
57 | /// 用户自定义数据。
58 | /// 创建的加载场景更新事件。
59 | public static LoadSceneUpdateEventArgs Create(string sceneAssetName, float progress, object userData)
60 | {
61 | LoadSceneUpdateEventArgs loadSceneUpdateEventArgs = ReferencePool.Acquire();
62 | loadSceneUpdateEventArgs.SceneAssetName = sceneAssetName;
63 | loadSceneUpdateEventArgs.Progress = progress;
64 | loadSceneUpdateEventArgs.UserData = userData;
65 | return loadSceneUpdateEventArgs;
66 | }
67 |
68 | ///
69 | /// 清理加载场景更新事件。
70 | ///
71 | public override void Clear()
72 | {
73 | SceneAssetName = null;
74 | Progress = 0f;
75 | UserData = null;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/GameFramework/Scene/UnloadSceneFailureEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Scene
9 | {
10 | ///
11 | /// 卸载场景失败事件。
12 | ///
13 | public sealed class UnloadSceneFailureEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化卸载场景失败事件的新实例。
17 | ///
18 | public UnloadSceneFailureEventArgs()
19 | {
20 | SceneAssetName = null;
21 | UserData = null;
22 | }
23 |
24 | ///
25 | /// 获取场景资源名称。
26 | ///
27 | public string SceneAssetName
28 | {
29 | get;
30 | private set;
31 | }
32 |
33 | ///
34 | /// 获取用户自定义数据。
35 | ///
36 | public object UserData
37 | {
38 | get;
39 | private set;
40 | }
41 |
42 | ///
43 | /// 创建卸载场景失败事件。
44 | ///
45 | /// 场景资源名称。
46 | /// 用户自定义数据。
47 | /// 创建的卸载场景失败事件。
48 | public static UnloadSceneFailureEventArgs Create(string sceneAssetName, object userData)
49 | {
50 | UnloadSceneFailureEventArgs unloadSceneFailureEventArgs = ReferencePool.Acquire();
51 | unloadSceneFailureEventArgs.SceneAssetName = sceneAssetName;
52 | unloadSceneFailureEventArgs.UserData = userData;
53 | return unloadSceneFailureEventArgs;
54 | }
55 |
56 | ///
57 | /// 清理卸载场景失败事件。
58 | ///
59 | public override void Clear()
60 | {
61 | SceneAssetName = null;
62 | UserData = null;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/GameFramework/Scene/UnloadSceneSuccessEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Scene
9 | {
10 | ///
11 | /// 卸载场景成功事件。
12 | ///
13 | public sealed class UnloadSceneSuccessEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化卸载场景成功事件的新实例。
17 | ///
18 | public UnloadSceneSuccessEventArgs()
19 | {
20 | SceneAssetName = null;
21 | UserData = null;
22 | }
23 |
24 | ///
25 | /// 获取场景资源名称。
26 | ///
27 | public string SceneAssetName
28 | {
29 | get;
30 | private set;
31 | }
32 |
33 | ///
34 | /// 获取用户自定义数据。
35 | ///
36 | public object UserData
37 | {
38 | get;
39 | private set;
40 | }
41 |
42 | ///
43 | /// 创建卸载场景成功事件。
44 | ///
45 | /// 场景资源名称。
46 | /// 用户自定义数据。
47 | /// 创建的卸载场景成功事件。
48 | public static UnloadSceneSuccessEventArgs Create(string sceneAssetName, object userData)
49 | {
50 | UnloadSceneSuccessEventArgs unloadSceneSuccessEventArgs = ReferencePool.Acquire();
51 | unloadSceneSuccessEventArgs.SceneAssetName = sceneAssetName;
52 | unloadSceneSuccessEventArgs.UserData = userData;
53 | return unloadSceneSuccessEventArgs;
54 | }
55 |
56 | ///
57 | /// 清理卸载场景成功事件。
58 | ///
59 | public override void Clear()
60 | {
61 | SceneAssetName = null;
62 | UserData = null;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/GameFramework/Sound/Constant.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Sound
9 | {
10 | ///
11 | /// 声音相关常量。
12 | ///
13 | internal static class Constant
14 | {
15 | internal const float DefaultTime = 0f;
16 | internal const bool DefaultMute = false;
17 | internal const bool DefaultLoop = false;
18 | internal const int DefaultPriority = 0;
19 | internal const float DefaultVolume = 1f;
20 | internal const float DefaultFadeInSeconds = 0f;
21 | internal const float DefaultFadeOutSeconds = 0f;
22 | internal const float DefaultPitch = 1f;
23 | internal const float DefaultPanStereo = 0f;
24 | internal const float DefaultSpatialBlend = 0f;
25 | internal const float DefaultMaxDistance = 100f;
26 | internal const float DefaultDopplerLevel = 1f;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/GameFramework/Sound/ISoundGroup.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Sound
9 | {
10 | ///
11 | /// 声音组接口。
12 | ///
13 | public interface ISoundGroup
14 | {
15 | ///
16 | /// 获取声音组名称。
17 | ///
18 | string Name
19 | {
20 | get;
21 | }
22 |
23 | ///
24 | /// 获取声音代理数。
25 | ///
26 | int SoundAgentCount
27 | {
28 | get;
29 | }
30 |
31 | ///
32 | /// 获取或设置声音组中的声音是否避免被同优先级声音替换。
33 | ///
34 | bool AvoidBeingReplacedBySamePriority
35 | {
36 | get;
37 | set;
38 | }
39 |
40 | ///
41 | /// 获取或设置声音组静音。
42 | ///
43 | bool Mute
44 | {
45 | get;
46 | set;
47 | }
48 |
49 | ///
50 | /// 获取或设置声音组音量。
51 | ///
52 | float Volume
53 | {
54 | get;
55 | set;
56 | }
57 |
58 | ///
59 | /// 获取声音组辅助器。
60 | ///
61 | ISoundGroupHelper Helper
62 | {
63 | get;
64 | }
65 |
66 | ///
67 | /// 停止所有已加载的声音。
68 | ///
69 | void StopAllLoadedSounds();
70 |
71 | ///
72 | /// 停止所有已加载的声音。
73 | ///
74 | /// 声音淡出时间,以秒为单位。
75 | void StopAllLoadedSounds(float fadeOutSeconds);
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/GameFramework/Sound/ISoundGroupHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Sound
9 | {
10 | ///
11 | /// 声音组辅助器接口。
12 | ///
13 | public interface ISoundGroupHelper
14 | {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/GameFramework/Sound/ISoundHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Sound
9 | {
10 | ///
11 | /// 声音辅助器接口。
12 | ///
13 | public interface ISoundHelper
14 | {
15 | ///
16 | /// 释放声音资源。
17 | ///
18 | /// 要释放的声音资源。
19 | void ReleaseSoundAsset(object soundAsset);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/GameFramework/Sound/PlaySoundErrorCode.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Sound
9 | {
10 | ///
11 | /// 播放声音错误码。
12 | ///
13 | public enum PlaySoundErrorCode : byte
14 | {
15 | ///
16 | /// 未知错误。
17 | ///
18 | Unknown = 0,
19 |
20 | ///
21 | /// 声音组不存在。
22 | ///
23 | SoundGroupNotExist,
24 |
25 | ///
26 | /// 声音组没有声音代理。
27 | ///
28 | SoundGroupHasNoAgent,
29 |
30 | ///
31 | /// 加载资源失败。
32 | ///
33 | LoadAssetFailure,
34 |
35 | ///
36 | /// 播放声音因优先级低被忽略。
37 | ///
38 | IgnoredDueToLowPriority,
39 |
40 | ///
41 | /// 设置声音资源失败。
42 | ///
43 | SetSoundAssetFailure
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/GameFramework/Sound/ResetSoundAgentEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.Sound
9 | {
10 | ///
11 | /// 重置声音代理事件。
12 | ///
13 | public sealed class ResetSoundAgentEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化重置声音代理事件的新实例。
17 | ///
18 | public ResetSoundAgentEventArgs()
19 | {
20 | }
21 |
22 | ///
23 | /// 创建重置声音代理事件。
24 | ///
25 | /// 创建的重置声音代理事件。
26 | public static ResetSoundAgentEventArgs Create()
27 | {
28 | ResetSoundAgentEventArgs resetSoundAgentEventArgs = ReferencePool.Acquire();
29 | return resetSoundAgentEventArgs;
30 | }
31 |
32 | ///
33 | /// 清理重置声音代理事件。
34 | ///
35 | public override void Clear()
36 | {
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/GameFramework/UI/IUIFormHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.UI
9 | {
10 | ///
11 | /// 界面辅助器接口。
12 | ///
13 | public interface IUIFormHelper
14 | {
15 | ///
16 | /// 实例化界面。
17 | ///
18 | /// 要实例化的界面资源。
19 | /// 实例化后的界面。
20 | object InstantiateUIForm(object uiFormAsset);
21 |
22 | ///
23 | /// 创建界面。
24 | ///
25 | /// 界面实例。
26 | /// 界面所属的界面组。
27 | /// 用户自定义数据。
28 | /// 界面。
29 | IUIForm CreateUIForm(object uiFormInstance, IUIGroup uiGroup, object userData);
30 |
31 | ///
32 | /// 释放界面。
33 | ///
34 | /// 要释放的界面资源。
35 | /// 要释放的界面实例。
36 | void ReleaseUIForm(object uiFormAsset, object uiFormInstance);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/GameFramework/UI/IUIGroupHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.UI
9 | {
10 | ///
11 | /// 界面组辅助器接口。
12 | ///
13 | public interface IUIGroupHelper
14 | {
15 | ///
16 | /// 设置界面组深度。
17 | ///
18 | /// 界面组深度。
19 | void SetDepth(int depth);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/GameFramework/UI/OpenUIFormSuccessEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.UI
9 | {
10 | ///
11 | /// 打开界面成功事件。
12 | ///
13 | public sealed class OpenUIFormSuccessEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化打开界面成功事件的新实例。
17 | ///
18 | public OpenUIFormSuccessEventArgs()
19 | {
20 | UIForm = null;
21 | Duration = 0f;
22 | UserData = null;
23 | }
24 |
25 | ///
26 | /// 获取打开成功的界面。
27 | ///
28 | public IUIForm UIForm
29 | {
30 | get;
31 | private set;
32 | }
33 |
34 | ///
35 | /// 获取加载持续时间。
36 | ///
37 | public float Duration
38 | {
39 | get;
40 | private set;
41 | }
42 |
43 | ///
44 | /// 获取用户自定义数据。
45 | ///
46 | public object UserData
47 | {
48 | get;
49 | private set;
50 | }
51 |
52 | ///
53 | /// 创建打开界面成功事件。
54 | ///
55 | /// 加载成功的界面。
56 | /// 加载持续时间。
57 | /// 用户自定义数据。
58 | /// 创建的打开界面成功事件。
59 | public static OpenUIFormSuccessEventArgs Create(IUIForm uiForm, float duration, object userData)
60 | {
61 | OpenUIFormSuccessEventArgs openUIFormSuccessEventArgs = ReferencePool.Acquire();
62 | openUIFormSuccessEventArgs.UIForm = uiForm;
63 | openUIFormSuccessEventArgs.Duration = duration;
64 | openUIFormSuccessEventArgs.UserData = userData;
65 | return openUIFormSuccessEventArgs;
66 | }
67 |
68 | ///
69 | /// 清理打开界面成功事件。
70 | ///
71 | public override void Clear()
72 | {
73 | UIForm = null;
74 | Duration = 0f;
75 | UserData = null;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/GameFramework/UI/UIManager.UIFormInstanceObject.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using GameFramework.ObjectPool;
9 |
10 | namespace GameFramework.UI
11 | {
12 | internal sealed partial class UIManager : GameFrameworkModule, IUIManager
13 | {
14 | ///
15 | /// 界面实例对象。
16 | ///
17 | private sealed class UIFormInstanceObject : ObjectBase
18 | {
19 | private object m_UIFormAsset;
20 | private IUIFormHelper m_UIFormHelper;
21 |
22 | public UIFormInstanceObject()
23 | {
24 | m_UIFormAsset = null;
25 | m_UIFormHelper = null;
26 | }
27 |
28 | public static UIFormInstanceObject Create(string name, object uiFormAsset, object uiFormInstance, IUIFormHelper uiFormHelper)
29 | {
30 | if (uiFormAsset == null)
31 | {
32 | throw new GameFrameworkException("UI form asset is invalid.");
33 | }
34 |
35 | if (uiFormHelper == null)
36 | {
37 | throw new GameFrameworkException("UI form helper is invalid.");
38 | }
39 |
40 | UIFormInstanceObject uiFormInstanceObject = ReferencePool.Acquire();
41 | uiFormInstanceObject.Initialize(name, uiFormInstance);
42 | uiFormInstanceObject.m_UIFormAsset = uiFormAsset;
43 | uiFormInstanceObject.m_UIFormHelper = uiFormHelper;
44 | return uiFormInstanceObject;
45 | }
46 |
47 | public override void Clear()
48 | {
49 | base.Clear();
50 | m_UIFormAsset = null;
51 | m_UIFormHelper = null;
52 | }
53 |
54 | protected internal override void Release(bool isShutdown)
55 | {
56 | m_UIFormHelper.ReleaseUIForm(m_UIFormAsset, Target);
57 | }
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/GameFramework/Utility/Utility.Json.IJsonHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System;
9 |
10 | namespace GameFramework
11 | {
12 | public static partial class Utility
13 | {
14 | public static partial class Json
15 | {
16 | ///
17 | /// JSON 辅助器接口。
18 | ///
19 | public interface IJsonHelper
20 | {
21 | ///
22 | /// 将对象序列化为 JSON 字符串。
23 | ///
24 | /// 要序列化的对象。
25 | /// 序列化后的 JSON 字符串。
26 | string ToJson(object obj);
27 |
28 | ///
29 | /// 将 JSON 字符串反序列化为对象。
30 | ///
31 | /// 对象类型。
32 | /// 要反序列化的 JSON 字符串。
33 | /// 反序列化后的对象。
34 | T ToObject(string json);
35 |
36 | ///
37 | /// 将 JSON 字符串反序列化为对象。
38 | ///
39 | /// 对象类型。
40 | /// 要反序列化的 JSON 字符串。
41 | /// 反序列化后的对象。
42 | object ToObject(Type objectType, string json);
43 | }
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/GameFramework/Utility/Utility.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework
9 | {
10 | ///
11 | /// 实用函数集。
12 | ///
13 | public static partial class Utility
14 | {
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/GameFramework/WebRequest/Constant.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.WebRequest
9 | {
10 | ///
11 | /// Web 请求相关常量。
12 | ///
13 | internal static class Constant
14 | {
15 | ///
16 | /// 默认 Web 请求任务优先级。
17 | ///
18 | internal const int DefaultPriority = 0;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/GameFramework/WebRequest/IWebRequestAgentHelper.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | using System;
9 |
10 | namespace GameFramework.WebRequest
11 | {
12 | ///
13 | /// Web 请求代理辅助器接口。
14 | ///
15 | public interface IWebRequestAgentHelper
16 | {
17 | ///
18 | /// Web 请求代理辅助器完成事件。
19 | ///
20 | event EventHandler WebRequestAgentHelperComplete;
21 |
22 | ///
23 | /// Web 请求代理辅助器错误事件。
24 | ///
25 | event EventHandler WebRequestAgentHelperError;
26 |
27 | ///
28 | /// 通过 Web 请求代理辅助器发送 Web 请求。
29 | ///
30 | /// Web 请求地址。
31 | /// 用户自定义数据。
32 | void Request(string webRequestUri, object userData);
33 |
34 | ///
35 | /// 通过 Web 请求代理辅助器发送 Web 请求。
36 | ///
37 | /// Web 请求地址。
38 | /// 要发送的数据流。
39 | /// 用户自定义数据。
40 | void Request(string webRequestUri, byte[] postData, object userData);
41 |
42 | ///
43 | /// 重置 Web 请求代理辅助器。
44 | ///
45 | void Reset();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/GameFramework/WebRequest/WebRequestAgentHelperCompleteEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.WebRequest
9 | {
10 | ///
11 | /// Web 请求代理辅助器完成事件。
12 | ///
13 | public sealed class WebRequestAgentHelperCompleteEventArgs : GameFrameworkEventArgs
14 | {
15 | private byte[] m_WebResponseBytes;
16 |
17 | ///
18 | /// 初始化 Web 请求代理辅助器完成事件的新实例。
19 | ///
20 | public WebRequestAgentHelperCompleteEventArgs()
21 | {
22 | m_WebResponseBytes = null;
23 | }
24 |
25 | ///
26 | /// 创建 Web 请求代理辅助器完成事件。
27 | ///
28 | /// Web 响应的数据流。
29 | /// 创建的 Web 请求代理辅助器完成事件。
30 | public static WebRequestAgentHelperCompleteEventArgs Create(byte[] webResponseBytes)
31 | {
32 | WebRequestAgentHelperCompleteEventArgs webRequestAgentHelperCompleteEventArgs = ReferencePool.Acquire();
33 | webRequestAgentHelperCompleteEventArgs.m_WebResponseBytes = webResponseBytes;
34 | return webRequestAgentHelperCompleteEventArgs;
35 | }
36 |
37 | ///
38 | /// 清理 Web 请求代理辅助器完成事件。
39 | ///
40 | public override void Clear()
41 | {
42 | m_WebResponseBytes = null;
43 | }
44 |
45 | ///
46 | /// 获取 Web 响应的数据流。
47 | ///
48 | /// Web 响应的数据流。
49 | public byte[] GetWebResponseBytes()
50 | {
51 | return m_WebResponseBytes;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/GameFramework/WebRequest/WebRequestAgentHelperErrorEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.WebRequest
9 | {
10 | ///
11 | /// Web 请求代理辅助器错误事件。
12 | ///
13 | public sealed class WebRequestAgentHelperErrorEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化 Web 请求代理辅助器错误事件的新实例。
17 | ///
18 | public WebRequestAgentHelperErrorEventArgs()
19 | {
20 | ErrorMessage = null;
21 | }
22 |
23 | ///
24 | /// 获取错误信息。
25 | ///
26 | public string ErrorMessage
27 | {
28 | get;
29 | private set;
30 | }
31 |
32 | ///
33 | /// 创建 Web 请求代理辅助器错误事件。
34 | ///
35 | /// 错误信息。
36 | /// 创建的 Web 请求代理辅助器错误事件。
37 | public static WebRequestAgentHelperErrorEventArgs Create(string errorMessage)
38 | {
39 | WebRequestAgentHelperErrorEventArgs webRequestAgentHelperErrorEventArgs = ReferencePool.Acquire();
40 | webRequestAgentHelperErrorEventArgs.ErrorMessage = errorMessage;
41 | return webRequestAgentHelperErrorEventArgs;
42 | }
43 |
44 | ///
45 | /// 清理 Web 请求代理辅助器错误事件。
46 | ///
47 | public override void Clear()
48 | {
49 | ErrorMessage = null;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/GameFramework/WebRequest/WebRequestManager.WebRequestTaskStatus.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.WebRequest
9 | {
10 | internal sealed partial class WebRequestManager : GameFrameworkModule, IWebRequestManager
11 | {
12 | ///
13 | /// Web 请求任务的状态。
14 | ///
15 | private enum WebRequestTaskStatus : byte
16 | {
17 | ///
18 | /// 准备请求。
19 | ///
20 | Todo = 0,
21 |
22 | ///
23 | /// 请求中。
24 | ///
25 | Doing,
26 |
27 | ///
28 | /// 请求完成。
29 | ///
30 | Done,
31 |
32 | ///
33 | /// 请求错误。
34 | ///
35 | Error
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/GameFramework/WebRequest/WebRequestStartEventArgs.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------
2 | // Game Framework
3 | // Copyright © 2013-2021 Jiang Yin. All rights reserved.
4 | // Homepage: https://gameframework.cn/
5 | // Feedback: mailto:ellan@gameframework.cn
6 | //------------------------------------------------------------
7 |
8 | namespace GameFramework.WebRequest
9 | {
10 | ///
11 | /// Web 请求开始事件。
12 | ///
13 | public sealed class WebRequestStartEventArgs : GameFrameworkEventArgs
14 | {
15 | ///
16 | /// 初始化 Web 请求开始事件的新实例。
17 | ///
18 | public WebRequestStartEventArgs()
19 | {
20 | SerialId = 0;
21 | WebRequestUri = null;
22 | UserData = null;
23 | }
24 |
25 | ///
26 | /// 获取 Web 请求任务的序列编号。
27 | ///
28 | public int SerialId
29 | {
30 | get;
31 | private set;
32 | }
33 |
34 | ///
35 | /// 获取 Web 请求地址。
36 | ///
37 | public string WebRequestUri
38 | {
39 | get;
40 | private set;
41 | }
42 |
43 | ///
44 | /// 获取用户自定义数据。
45 | ///
46 | public object UserData
47 | {
48 | get;
49 | private set;
50 | }
51 |
52 | ///
53 | /// 创建 Web 请求开始事件。
54 | ///
55 | /// Web 请求任务的序列编号。
56 | /// Web 请求地址。
57 | /// 用户自定义数据。
58 | /// 创建的 Web 请求开始事件。
59 | public static WebRequestStartEventArgs Create(int serialId, string webRequestUri, object userData)
60 | {
61 | WebRequestStartEventArgs webRequestStartEventArgs = ReferencePool.Acquire();
62 | webRequestStartEventArgs.SerialId = serialId;
63 | webRequestStartEventArgs.WebRequestUri = webRequestUri;
64 | webRequestStartEventArgs.UserData = userData;
65 | return webRequestStartEventArgs;
66 | }
67 |
68 | ///
69 | /// 清理 Web 请求开始事件。
70 | ///
71 | public override void Clear()
72 | {
73 | SerialId = 0;
74 | WebRequestUri = null;
75 | UserData = null;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2013-2021 Jiang Yin
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------