[+] 接入ET8服务端

[+] 接入ET8服务端
This commit is contained in:
ALEXTANG
2023-07-13 12:23:48 +08:00
parent e0be062006
commit 336d4b2eb9
1316 changed files with 130657 additions and 626 deletions

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
namespace ET.Server
{
[FriendOf(typeof(MatchComponent))]
public static partial class MatchComponentSystem
{
public static async ETTask Match(this MatchComponent self, long playerId)
{
if (self.waitMatchPlayers.Contains(playerId))
{
return;
}
self.waitMatchPlayers.Add(playerId);
if (self.waitMatchPlayers.Count < LSConstValue.MatchCount)
{
return;
}
// 申请一个房间
StartSceneConfig startSceneConfig = RandomGenerator.RandomArray(StartSceneConfigCategory.Instance.Maps);
Match2Map_GetRoom match2MapGetRoom = new();
foreach (long id in self.waitMatchPlayers)
{
match2MapGetRoom.PlayerIds.Add(id);
}
self.waitMatchPlayers.Clear();
Scene root = self.Root();
Map2Match_GetRoom map2MatchGetRoom = await root.GetComponent<ActorSenderComponent>().Call(
startSceneConfig.ActorId, match2MapGetRoom) as Map2Match_GetRoom;
Match2G_NotifyMatchSuccess match2GNotifyMatchSuccess = new() { ActorId = map2MatchGetRoom.ActorId };
ActorLocationSenderComponent actorLocationSenderComponent = root.GetComponent<ActorLocationSenderComponent>();
foreach (long id in match2MapGetRoom.PlayerIds) // 这里发送消息线程不会修改PlayerInfo所以可以直接使用
{
actorLocationSenderComponent.Get(LocationType.Player).Send(id, match2GNotifyMatchSuccess);
// 等待进入房间的确认消息,如果超时要通知所有玩家退出房间,重新匹配
}
}
}
}