[+] 接入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 Unity.Mathematics;
namespace ET.Server
{
[FriendOf(typeof(MoveComponent))]
[FriendOf(typeof(NumericComponent))]
public static partial class UnitHelper
{
public static UnitInfo CreateUnitInfo(Unit unit)
{
UnitInfo unitInfo = new();
NumericComponent nc = unit.GetComponent<NumericComponent>();
unitInfo.UnitId = unit.Id;
unitInfo.ConfigId = unit.ConfigId;
unitInfo.Type = (int)unit.Type;
unitInfo.Position = unit.Position;
unitInfo.Forward = unit.Forward;
MoveComponent moveComponent = unit.GetComponent<MoveComponent>();
if (moveComponent != null)
{
if (!moveComponent.IsArrived())
{
unitInfo.MoveInfo = new MoveInfo();
unitInfo.MoveInfo.Points.Add(unit.Position);
for (int i = moveComponent.N; i < moveComponent.Targets.Count; ++i)
{
float3 pos = moveComponent.Targets[i];
unitInfo.MoveInfo.Points.Add(pos);
}
}
}
foreach ((int key, long value) in nc.NumericDic)
{
unitInfo.KV.Add(key, value);
}
return unitInfo;
}
// 获取看见unit的玩家主要用于广播
public static Dictionary<long, AOIEntity> GetBeSeePlayers(this Unit self)
{
return self.GetComponent<AOIEntity>().GetBeSeePlayers();
}
}
}