123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using CommonLang.Geometry;
- using ET.Client;
- using ET.EventType;
- using System;
- namespace ET
- {
-
- public partial class BattleMgr
- {
- public void doUpdate()
- {
- SyncUnitPos();
- }
- private Vector3 VecTmp = new Vector3();
- private void SyncUnitPos()
- {
- if(UnitMgr.Instance != null)
- {
- foreach (var obj in UnitMgr.Instance.AllUnits)
- {
- if (obj is BattleUnit unit)
- {
- var zu = unit.ZUnit;
- VecTmp.Set(zu.X, zu.Y, zu.Z);
- if (!VecTmp.Equal(unit.LastPos, 0.01f) || MathF.Abs(unit.LastRotation - zu.Direction) > 0.01f)
- {
- EventSystem.Instance.Publish<SyncUnitPosEvent>(SyncUnitPosEvent.Static.Clone(unit.Id, VecTmp, zu.Direction));
- unit.LastPos.Set(VecTmp);
- unit.LastRotation = zu.Direction;
- }
- }
- else if (obj is BattleSpell spell)
- {
-
- }
- }
- }
- }
- }
- }
|