[+] 接入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,23 @@
using System.Net;
namespace ET.Server
{
[Invoke((long)SceneType.Match)]
public class FiberInit_Match: AInvokeHandler<FiberInit, ETTask>
{
public override async ETTask Handle(FiberInit fiberInit)
{
Scene root = fiberInit.Fiber.Root;
root.AddComponent<MailBoxComponent, MailBoxType>(MailBoxType.UnOrderedMessage);
root.AddComponent<TimerComponent>();
root.AddComponent<CoroutineLockComponent>();
root.AddComponent<ActorInnerComponent>();
root.AddComponent<ActorSenderComponent>();
root.AddComponent<MatchComponent>();
root.AddComponent<LocationProxyComponent>();
root.AddComponent<ActorLocationSenderComponent>();
await ETTask.CompletedTask;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a6a6101f02189c643accabb36f52c150
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using System;
namespace ET.Server
{
[ActorMessageHandler(SceneType.Match)]
public class G2Match_MatchHandler : ActorMessageHandler<Scene, G2Match_Match, Match2G_Match>
{
protected override async ETTask Run(Scene scene, G2Match_Match request, Match2G_Match response)
{
MatchComponent matchComponent = scene.GetComponent<MatchComponent>();
matchComponent.Match(request.Id).Coroutine();
await ETTask.CompletedTask;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 643a9fc2cab3148718708aba9c790f7d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

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

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fd80372aeb5d74a3ba66f43bae5613df
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: