Files
TEngine/Assets/GameScripts/DotNet/Hotfix/Server/LockStep/Match/MatchComponentSystem.cs
ALEXTANG 336d4b2eb9 [+] 接入ET8服务端
[+] 接入ET8服务端
2023-07-13 12:23:48 +08:00

49 lines
1.8 KiB
C#
Raw 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.

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);
// 等待进入房间的确认消息,如果超时要通知所有玩家退出房间,重新匹配
}
}
}
}