breakpoint
This commit is contained in:
@@ -8,8 +8,7 @@
|
||||
"GUID:eaaac13fa1ccdfb4ca5d246fb1d9c561",
|
||||
"GUID:be17a8778dbfe454890ed8279279e153",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:9400d40641bab5b4a9702f65bf5c6eb5",
|
||||
"GUID:53336df3122d0cb41a64b6109d19b016"
|
||||
"GUID:1bb4187526a9431478feccaef064696a"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"name": "BITFALL.PlayerService.Core",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:f263169dea78d2249ba035c363b9cb8e",
|
||||
"GUID:9400d40641bab5b4a9702f65bf5c6eb5"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": true
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Net.Server;
|
||||
using System.Data.SqlTypes;
|
||||
using System.IO;
|
||||
using Net.Serialize;
|
||||
using BITKit;
|
||||
using Net.Share;
|
||||
using Unity.Plastic.Antlr3.Runtime.Misc;
|
||||
|
||||
namespace BITFALL.Services
|
||||
{
|
||||
[System.Serializable]
|
||||
public record PlayerModel
|
||||
{
|
||||
public int Id;
|
||||
public string Name;
|
||||
public string PlayerId;
|
||||
}
|
||||
|
||||
public class PlayerModelBinary : NetMessageReader<PlayerModel>
|
||||
{
|
||||
public override PlayerModel ReadBinary(BinaryReader reader)
|
||||
{
|
||||
return new PlayerModel
|
||||
{
|
||||
Id = reader.ReadInt32(),
|
||||
Name = reader.ReadString(),
|
||||
PlayerId = reader.ReadString()
|
||||
};
|
||||
}
|
||||
public override void WriteBinary(BinaryWriter writer, PlayerModel value)
|
||||
{
|
||||
writer.Write(value.Id);
|
||||
writer.Write(value.Name);
|
||||
writer.Write(value.PlayerId);
|
||||
}
|
||||
}
|
||||
public interface IPlayerService
|
||||
{
|
||||
}
|
||||
|
||||
public struct PlayerReadyCommand
|
||||
{
|
||||
public int PlayerId;
|
||||
}
|
||||
}
|
@@ -4,29 +4,57 @@ using System.Collections.Generic;
|
||||
using BITFALL.Services;
|
||||
using BITKit;
|
||||
using BITKit.HttpNet;
|
||||
using BITKit.Steamwork;
|
||||
using BITKit.SubSystems;
|
||||
using Net.Client;
|
||||
using Net.Server;
|
||||
using Net.Share;
|
||||
using UnityEngine;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using INetClient = BITKit.INetClient;
|
||||
|
||||
namespace BITFALL
|
||||
{
|
||||
public class UnityPlayerService : MonoBehaviour, IPlayerService
|
||||
{
|
||||
public event Action<int> OnPlayerReady;
|
||||
//申明服务
|
||||
[SerializeField, SerializeReference, SubclassSelector]
|
||||
private INetProvider netProvider;
|
||||
|
||||
[SerializeField, SerializeReference, SubclassSelector]
|
||||
private INetClient netClient;
|
||||
[SerializeField, SerializeReference, SubclassSelector]
|
||||
private ISteamService steamService;
|
||||
//接口实现
|
||||
public event Action<PlayerModel> OnVerifyPlayer;
|
||||
public event Action<PlayerModel> OnPlayerVerified;
|
||||
private void Start()
|
||||
{
|
||||
netProvider.AddRpcHandle(this);
|
||||
BITNet.OnConnected += OnConnect;
|
||||
netClient.OnConnected += OnConnect;
|
||||
|
||||
netProvider.AddCommandListener<PlayerVerifiedCommand>(OnPlayerVerifiedCallback);
|
||||
}
|
||||
private void OnConnect()
|
||||
{
|
||||
OnPlayerReady?.Invoke(0);
|
||||
var command = new PlayerVerifiedCommand()
|
||||
{
|
||||
PlayerModel = new PlayerModel
|
||||
{
|
||||
Id =netClient.Id,
|
||||
SteamId =steamService.SteamId,
|
||||
Name = steamService.Name,
|
||||
}
|
||||
};
|
||||
BIT4Log.Log<UnityPlayerService>("正在发送玩家验证清单");
|
||||
|
||||
OnVerifyPlayer?.Invoke(command.PlayerModel);
|
||||
|
||||
netProvider.ServerCommand(command);
|
||||
}
|
||||
private void OnPlayerVerifiedCallback(PlayerVerifiedCommand command)
|
||||
{
|
||||
BIT4Log.Log<UnityPlayerService>($"玩家\t{command.PlayerModel.Name}\t已验证");
|
||||
OnPlayerVerified?.Invoke(command.PlayerModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user