[+] 接入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.Collections.Generic;
using System.IO;
namespace ET.Server
{
public static partial class MessageHelper
{
public static void NoticeUnitAdd(Unit unit, Unit sendUnit)
{
M2C_CreateUnits createUnits = M2C_CreateUnits.Create();
createUnits.Units.Add(UnitHelper.CreateUnitInfo(sendUnit));
MessageHelper.SendToClient(unit, createUnits);
}
public static void NoticeUnitRemove(Unit unit, Unit sendUnit)
{
M2C_RemoveUnits removeUnits = M2C_RemoveUnits.Create();
removeUnits.Units.Add(sendUnit.Id);
MessageHelper.SendToClient(unit, removeUnits);
}
public static void Broadcast(Unit unit, IActorMessage message)
{
(message as MessageObject).IsFromPool = false;
Dictionary<long, AOIEntity> dict = unit.GetBeSeePlayers();
// 网络底层做了优化,同一个消息不会多次序列化
ActorLocationSenderOneType oneTypeLocationType = unit.Root().GetComponent<ActorLocationSenderComponent>().Get(LocationType.GateSession);
foreach (AOIEntity u in dict.Values)
{
oneTypeLocationType.Send(u.Unit.Id, message);
}
}
public static void SendToClient(Unit unit, IActorMessage message)
{
unit.Root().GetComponent<ActorLocationSenderComponent>().Get(LocationType.GateSession).Send(unit.Id, message);
}
/// <summary>
/// 发送协议给Actor
/// </summary>
public static void SendActor(Scene root, ActorId actorId, IActorMessage message)
{
root.GetComponent<ActorSenderComponent>().Send(actorId, message);
}
}
}