public IEnumerable <Threat> GetAllThreats() { List <Threat> threatList = new List <Threat>(); this._potentialTargetUsableMachines.RemoveAll((Predicate <ITargetable>)(ptum => { if (!(ptum is UsableMachine)) { return(false); } return((ptum as UsableMachine).IsDestroyed || (NativeObject)(ptum as UsableMachine).GameEntity == (NativeObject)null); })); threatList.AddRange(this._potentialTargetUsableMachines.Select <ITargetable, Threat>((Func <ITargetable, Threat>)(um => new Threat() { WeaponEntity = um, ThreatValue = this.Weapon.ProcessTargetValue(um.GetTargetValue(this.WeaponPositions), um.GetTargetFlags()) }))); foreach (Formation unemployedEnemyFormation in this.GetUnemployedEnemyFormations()) { threatList.Add(new Threat() { Formation = unemployedEnemyFormation, ThreatValue = this.Weapon.ProcessTargetValue(ThreatSeeker.GetTargetValueOfFormation(unemployedEnemyFormation, (IEnumerable <ICastleKeyPosition>) this._referencePositions), ThreatSeeker.GetTargetFlagsOfFormation()) }); } return((IEnumerable <Threat>)threatList); }
public RangedSiegeWeaponAi(RangedSiegeWeapon rangedSiegeWeapon) : base((UsableMachine)rangedSiegeWeapon) { this.threatSeeker = new ThreatSeeker(rangedSiegeWeapon); (this.UsableMachine as RangedSiegeWeapon).OnReloadDone += new RangedSiegeWeapon.OnSiegeWeaponReloadDone(this.FindNextTarget); this._delayTimer = this._delayDuration; this._targetEvaluationTimer = new Timer(MBCommon.GetTime(MBCommon.TimeType.Mission), 0.5f); }
private static float GetPositionMultiplierOfFormation( Formation formation, IEnumerable <ICastleKeyPosition> referencePositions) { ICastleKeyPosition closestCastlePosition; float betweenPositions = ThreatSeeker.GetMinimumDistanceBetweenPositions(formation.GetMedianAgent(false, false, formation.GetAveragePositionOfUnits(false, false)).Position, referencePositions, out closestCastlePosition); bool flag = closestCastlePosition.AttackerSiegeWeapon != null && closestCastlePosition.AttackerSiegeWeapon.HasCompletedAction(); return(formation.IsRanged() ? (float)(((double)betweenPositions >= 20.0 ? ((double)betweenPositions >= 35.0 ? 0.600000023841858 : 0.800000011920929) : 1.0) + (flag ? 0.200000002980232 : 0.0)) : (float)(((double)betweenPositions >= 15.0 ? ((double)betweenPositions >= 40.0 ? 0.119999997317791 : 0.150000005960464) : 0.200000002980232) * (flag ? 7.5 : 1.0))); }
private static float GetTargetValueOfFormation( Formation formation, IEnumerable <ICastleKeyPosition> referencePositions) { float num = (float)formation.CountOfUnits * 3f; if (TeamAISiegeComponent.IsFormationInsideCastle(formation, true)) { num *= 3f; } return(num * ThreatSeeker.GetPositionMultiplierOfFormation(formation, referencePositions) * (MBMath.ClampFloat(formation.QuerySystem.LocalAllyPower / (formation.QuerySystem.LocalEnemyPower + 0.01f), 0.0f, 5f) / 5f)); }