using System; using UnityEngine; namespace ET.Client { [FriendOf(typeof(LSUnitViewComponent))] public static class LSUnitViewComponentSystem { public class AwakeSystem: AwakeSystem { protected override void Awake(LSUnitViewComponent self) { self.MyId = self.Parent.GetParent().GetComponent().MyId; } } public class UpdateSystem: UpdateSystem { protected override void Update(LSUnitViewComponent self) { Room room = self.GetParent(); LSWorld lsWorld = room.LSWorld; foreach (long playerId in room.PlayerIds) { LSUnit unit = lsWorld.LSUnitComponent.GetChild(playerId); LSUnitView child = self.GetChild(playerId); Vector3 pos = child.Transform.position; Vector3 to = unit.Position.ToVector(); float distance = (to - pos).magnitude; if (distance < 0.5) { continue; } float t = distance / 9f; child.Transform.position = Vector3.Lerp(pos, unit.Position.ToVector(), Time.deltaTime / t); } } } public static LSUnitView GetMyLsUnitView(this LSUnitViewComponent self) { return self.GetChild(self.MyId); } } }