private float GetAttitudeValue(StaticString modifierName, AIHeuristicAnalyser.Context debugContext) { float num = 0f; IGameService service = Services.GetService <IGameService>(); global::Game game = service.Game as global::Game; for (int i = 0; i < game.Empires.Length; i++) { MajorEmpire majorEmpire = game.Empires[i] as MajorEmpire; if (majorEmpire != null && majorEmpire.Index != base.AIEntity.Empire.Index) { AILayer_Attitude.Attitude attitude = this.aiLayerAttitude.GetAttitude(majorEmpire); num = Mathf.Max(num, attitude.Score.GetNormalizedScoreByName(modifierName)); } } return(num); }
public override void Reset() { this.DiplomacyLayer = this.aiEntityEmpire.GetLayer <AILayer_Diplomacy>(); this.VictoryLayer = this.aiEntityEmpire.GetLayer <AILayer_Victory>(); AILayer_Attitude layer = this.aiEntityEmpire.GetLayer <AILayer_Attitude>(); Diagnostics.Assert(layer != null); AILayer_Attitude.Attitude attitude = layer.GetAttitude(this.EmpireWhichReceives); if (attitude == null) { Diagnostics.LogError("Can't retrieve attitude between {0} and {1}.", new object[] { this.Empire, this.EmpireWhichReceives }); base.Enable = false; return; } this.AttitudeScore = attitude.Score; if (this.AttitudeScore == null) { base.Enable = false; return; } DepartmentOfForeignAffairs agency = this.aiEntityEmpire.Empire.GetAgency <DepartmentOfForeignAffairs>(); Diagnostics.Assert(agency != null); this.DiplomaticRelation = agency.GetDiplomaticRelation(this.EmpireWhichReceives); if (this.DiplomaticRelation == null) { base.Enable = false; return; } base.Reset(); bool enable = base.Enable; }