protected override float GetAiWeight() { if (!this.formation.AI.IsMainFormation) { foreach (Formation formation1 in this.formation.Team.FormationsIncludingSpecialAndEmpty) { if (this.formation != formation1 && formation1.CountOfUnits > 0) { using (IEnumerator <Team> enumerator = Mission.Current.Teams.GetEnumerator()) { while (enumerator.MoveNext()) { Team current = enumerator.Current; if (current.IsEnemyOf(this.formation.Team)) { foreach (Formation formation2 in current.FormationsIncludingSpecialAndEmpty) { if (formation2.CountOfUnits > 0) { return(0.04f); } } } } break; } } } } return(0.0f); }
protected override void CalculateCurrentOrder() { WorldPosition position = this.formation.QuerySystem.MedianPosition; if (this.formation.QuerySystem.ClosestSignificantlyLargeEnemyFormation == null) { position.SetVec2(this.formation.QuerySystem.AveragePosition); } else { int num1 = (double)(this.formation.QuerySystem.AverageAllyPosition - this.formation.Team.QuerySystem.AverageEnemyPosition).LengthSquared <= 3600.0 ? 1 : 0; bool engaging = this._engaging; this._engaging = num1 != 0 || (this._engaging ? (double)this.formation.QuerySystem.UnderRangedAttackRatio <= (double)this.formation.QuerySystem.MakingRangedAttackRatio && (!this.formation.QuerySystem.FastestSignificantlyLargeEnemyFormation.IsCavalryFormation && !this.formation.QuerySystem.FastestSignificantlyLargeEnemyFormation.IsRangedCavalryFormation || (double)(this.formation.QuerySystem.AveragePosition - this.formation.QuerySystem.FastestSignificantlyLargeEnemyFormation.MedianPosition.AsVec2).LengthSquared / ((double)this.formation.QuerySystem.FastestSignificantlyLargeEnemyFormation.MovementSpeed * (double)this.formation.QuerySystem.FastestSignificantlyLargeEnemyFormation.MovementSpeed) >= 16.0) : (double)(this.formation.QuerySystem.AveragePosition - this.formation.QuerySystem.AverageAllyPosition).LengthSquared <= 3600.0); if (this._engaging) { Vec2 vec2_1 = this.formation.QuerySystem.AveragePosition - this.formation.QuerySystem.ClosestSignificantlyLargeEnemyFormation.AveragePosition; vec2_1 = vec2_1.Normalized(); Vec2 vec2_2 = vec2_1.LeftVec(); FormationQuerySystem largeEnemyFormation = this.formation.QuerySystem.ClosestSignificantlyLargeEnemyFormation; float num2 = (float)(50.0 + ((double)this.formation.QuerySystem.ClosestSignificantlyLargeEnemyFormation.Formation.Width + (double)this.formation.Depth) * 0.5); float num3 = 0.0f; Formation formation1 = this.formation.QuerySystem.ClosestSignificantlyLargeEnemyFormation.Formation; for (int index1 = 0; index1 < Mission.Current.Teams.Count; ++index1) { Team team = Mission.Current.Teams[index1]; if (team.IsEnemyOf(this.formation.Team)) { for (int index2 = 0; index2 < team.FormationsIncludingSpecialAndEmpty.Count; ++index2) { Formation formation2 = team.FormationsIncludingSpecialAndEmpty[index2]; if (formation2.CountOfUnits > 0 && formation2.QuerySystem != largeEnemyFormation) { Vec2 v = formation2.QuerySystem.AveragePosition - largeEnemyFormation.AveragePosition; float num4 = v.Normalize(); if ((double)vec2_2.DotProduct(v) > 0.800000011920929 && (double)num4 < (double)num2 && (double)num4 > (double)num3) { num3 = num4; formation1 = formation2; } } } } } if (((double)this.formation.QuerySystem.RangedCavalryUnitRatio <= 0.949999988079071 ? 0 : (this.formation.QuerySystem.ClosestSignificantlyLargeEnemyFormation.Formation == formation1 ? 1 : 0)) == 0) { bool flag = formation1.QuerySystem.IsCavalryFormation || formation1.QuerySystem.IsRangedCavalryFormation; float radius = Math.Min((flag ? 35f : 20f) + (float)(((double)formation1.Depth + (double)this.formation.Width) * 0.5), this.formation.QuerySystem.MissileRange - this.formation.Width * 0.5f); BehaviorMountedSkirmish.Ellipse ellipse = new BehaviorMountedSkirmish.Ellipse(formation1.QuerySystem.MedianPosition.AsVec2, radius, (float)((double)formation1.Width * 0.5 * (flag ? 1.5 : 1.0)), formation1.Direction); position.SetVec2(ellipse.GetTargetPos(this.formation.QuerySystem.AveragePosition, 20f)); } else { this.CurrentOrder = MovementOrder.MovementOrderCharge; return; } } else { position = new WorldPosition(Mission.Current.Scene, new Vec3(this.formation.QuerySystem.AverageAllyPosition, this.formation.Team.QuerySystem.MedianPosition.GetNavMeshZ() + 100f)); } } this.CurrentOrder = MovementOrder.MovementOrderMove(position); }