public void Defend(BaseUnit unit, bool isCustomMoveLegion = true)
        {
            if (unit == null)
            {
                return;
            }
            var castle = unit as TCastle;

            if (castle == null)
            {
                CLog.Error("Defend:castle == null)");
                return;
            }
            if (IsInDefend())
            {
                return;
            }
            if (!SelfUnit.IsSelf(castle))
            {
                return;
            }
            if (castle.CastleStationedMgr.IsHaveDefender())
            {
                return;
            }
            PreDefendCastle = DefendCastle;
            DefendCastle    = castle;
            castle.CastleStationedMgr.OnBeDefend(SelfUnit);
            OnDefend(castle, isCustomMoveLegion);
            Callback_OnDefendChanged?.Invoke(PreDefendCastle, DefendCastle);
        }
        public virtual void OnUnBeDefend(BaseUnit unit)
        {
            var legion = unit as TLegion;

            PreDefendLegion = Defender;
            Defender        = null;
            Callback_OnDefendChanged?.Invoke(PreDefendLegion, Defender, IsHaveDefender());
        }
 public void LeaveDefend(bool isForce = false)
 {
     if (!IsInDefend())
     {
         return;
     }
     PreDefendCastle = DefendCastle;
     DefendCastle    = null;
     PreDefendCastle.CastleStationedMgr.OnUnBeDefend(SelfUnit);
     if (isForce)
     {
         AStarMgr.SetArroundUnit(PreDefendCastle, SelfUnit);
     }
     OnLeaveDefend(isForce);
     Callback_OnDefendChanged?.Invoke(PreDefendCastle, null);
 }