| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using System;
- using UnityEngine;
- namespace ET.Client
- {
- [FriendOf(typeof(LSUnitViewComponent))]
- public static class LSUnitViewComponentSystem
- {
- public class AwakeSystem: AwakeSystem<LSUnitViewComponent>
- {
- protected override void Awake(LSUnitViewComponent self)
- {
- self.MyId = self.Parent.GetParent<Scene>().GetComponent<PlayerComponent>().MyId;
- }
- }
-
- //public class RollbackSystem: RollbackSystem<LSUnitViewComponent>
- //{
- // protected override void Rollback(LSUnitViewComponent self)
- // {
- // LSWorld lsWorld = self.GetParent<Room>().LSWorld;
- // foreach (LSUnitView child in self.Children.Values)
- // {
- // LSUnit unit = lsWorld.Get(child.Id) as LSUnit;
- //
- // Vector3 pos = child.Transform.position;
- // Vector3 to = unit.Position.ToVector();
- // float t = (to - pos).magnitude / 9f;
- //
- // child.Transform.position = pos;
- // }
- // }
- //}
-
- public class UpdateSystem: UpdateSystem<LSUnitViewComponent>
- {
- protected override void Update(LSUnitViewComponent self)
- {
- LSWorld lsWorld = self.GetParent<Room>().LSWorld;
- foreach (LSUnitView child in self.Children.Values)
- {
- LSUnit unit = lsWorld.Get(child.Id) as LSUnit;
- 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<LSUnitView>(self.MyId);
- }
- }
- }
|