BITKit/Readme.md

141 lines
3.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# BITKit——easy useful的.net框架(支持网络)
> 所有项目都需要一个FrameworkBITKit为你提供所有支持
无论是小型,大型还是商业项目,你都可以用BITKit完成所有的需求
特别是Unity和asp和正在支持中的Godot
## Getting Started 使用指南
该框架由于目前还没有用户,所以使用指南将包括在部分文件中
### Prerequisites 项目使用条件
你需要一些小小的nuget程序包或者一些小小的Unity Packages
### UniTask
提供异步支持
```csharp
//切换到线程池
await UniTask.SwichToThreadPool();
//在Unity中切换到主线程
await UniTask.SwitchToMainThread();
//在异步中等待,直到某个条件达成或取消
await UniTask.WaitUtil(()=>completed);
```
***
### Newtonsoft.json
提供json的序列化与反序列化
```csharp
//序列化数据
var json = JsonConvert.SerializeObject(value);
//反序列化json为数据
var value = JsonConvert.DeserializeObject<MyValue>(json);
```
***
### Unity.Mathematics
提供数学结构
```csharp
//float3 通常用于坐标和向量
float3 position=new(0,1,0);
//quaternion 四元数,通常用于旋转
quaternion rotation=new(1,1,1,1);
```
***
### (可选)GameDesigner
提供主要的网络服务(未来可能会用内置KCP)
``` csharp
//注册Rpc处理服务
ClientBase.Instance.AddRpcHandle(this);
//向服务器发送Rpc
ClientBase.Instance.SendRT("RpcName",intValue,floatValue,stirngValue);
```
在Unity中,你还需要以下Plugins:
```
Sirenix.Odin 为Unity提供基本的数据序列化(准备移除)
```
```
Demigiant.DOTween 为Unity提供补间动画支持
```
```
RotaryHeart.SerializableDictionaryLite为Unity提供序列化字典(已下架)
```
```
Unity.Addressables 为Unity添加可寻址资源的资源管理方案
```
### Installation 安装
1.从Git Clone此项目
[该项目Git链接](http://server.bitfall.icu:3000/root/BITKit.git) 右键复制
#### Unity:
```
在 PackagesManager 运行 "Add Package From Git Url"
```
#### Net Core:
```
从Git Clone该项目后支持在解决方案中"添加现有项目"即可完成安装
```
### Usage example 使用示例
```csharp
//打包数据
BITAssets.Build(myFile);
//二进制和反二进制化数据
BITBinary.Write(value);
BITBinary.Read<T>(buffer);
//注册远程指令
INetProvider.AddCommandListener<MyCommand>(callback);
//向服务器发送指令
INetProvider.ServerCommand<MyCommand>();
//向客户端发送指令
INetProvider.ClientCommand<MyCommand>(64);
```
还有一种基于`ECS`依赖注入
```csharp
public class InjectExample
{
[Inject]
private IMyService myService;
void Execute()
{
myService.DoSomething();
}
}
```
## Deployment 部署方法
#### Unity:
直接Build项目
#### Net Core:
直接发布项目
## Contributing 贡献指南
从Readme文件下方找到作者的联系方式并直接联系作者
## Release History 版本历史
* 0.2.1
* 更新 `README.md`
* 0.2.0
* 添加 `README.md`
* 0.1.0
* 创建Git 仓库
## Authors 关于作者
* **军火商小火柴** - *Initial work* - [军火商小火柴](https://bitfall.icu)
## License 授权协议
这个项目 MIT 协议, 请点击 [LICENSE.md](LICENSE.md) 了解更多细节。