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(); 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(); 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 GetBeSeePlayers(this Unit self) { return self.GetComponent().GetBeSeePlayers(); } } }