public bool IsVisibleFor(global::Empire empire) { IGameService service = Services.GetService <IGameService>(); if (service != null) { IVisibilityService service2 = service.Game.Services.GetService <IVisibilityService>(); if (service != null) { if (this.isVisibleInFogOfWar) { return(service2.IsWorldPositionExploredFor(this.WorldPosition, empire) || service2.IsWorldPositionVisibleFor(this.WorldPosition, empire)); } return(service2.IsWorldPositionVisibleFor(this.WorldPosition, empire)); } } return(false); }
private bool Accept(WorldPosition worldPosition) { worldPosition = base.GlobalPositionningService.FromRelativeToConstrainedWorldPosition(worldPosition); if (!worldPosition.IsValid) { return(false); } if (base.WorldPositionningService != null) { int regionIndex = (int)base.WorldPositionningService.GetRegionIndex(worldPosition); if (regionIndex != this.City.Region.Index) { return(false); } IVisibilityService service = base.GameService.Game.Services.GetService <IVisibilityService>(); if (!service.IsWorldPositionExploredFor(worldPosition, this.City.Empire)) { return(false); } } return(true); }
public override bool CanApply(IDiplomaticContract diplomaticContract, params string[] flags) { if (!base.CanApply(diplomaticContract, new string[0])) { return(false); } Diagnostics.Assert(base.EmpireWhichProvides != null && base.EmpireWhichReceives != null); DepartmentOfTheInterior agency = base.EmpireWhichProvides.GetAgency <DepartmentOfTheInterior>(); DepartmentOfTheInterior agency2 = base.EmpireWhichReceives.GetAgency <DepartmentOfTheInterior>(); Diagnostics.Assert(agency != null && agency2 != null); City city = agency.Cities.FirstOrDefault((City match) => match.GUID == this.CityGUID); if (city == null) { return(false); } if (city.BesiegingEmpire != null) { return(false); } if (diplomaticContract.EmpireWhichProposes.Index != base.EmpireWhichProvides.Index) { IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); IVisibilityService service2 = service.Game.Services.GetService <IVisibilityService>(); Diagnostics.Assert(service2 != null); District cityCenter = city.GetCityCenter(); if (cityCenter == null || !service2.IsWorldPositionExploredFor(cityCenter.WorldPosition, base.EmpireWhichReceives)) { return(false); } } if (base.Definition.Name == DiplomaticTermCityExchange.MimicsCityDeal) { if (agency.MainCity == city) { return(false); } if (base.EmpireWhichProvides.Faction.Affinity.Name == base.EmpireWhichReceives.Faction.Affinity.Name) { return(false); } if (city.IsInfected) { return(false); } if (base.EmpireWhichReceives.GetAgency <DepartmentOfPlanificationAndDevelopment>().HasIntegratedFaction(base.EmpireWhichProvides.Faction)) { return(false); } if (agency2.InfectedCities.Any((City c) => c.LastNonInfectedOwner != null && (c.LastNonInfectedOwner == base.EmpireWhichProvides || c.LastNonInfectedOwner.Faction == base.EmpireWhichProvides.Faction))) { return(false); } } int num = agency.Cities.Count; int num2 = agency2.Cities.Count; for (int i = 0; i < diplomaticContract.Terms.Count; i++) { DiplomaticTermCityExchange diplomaticTermCityExchange = diplomaticContract.Terms[i] as DiplomaticTermCityExchange; if (diplomaticTermCityExchange != null && !(diplomaticTermCityExchange.CityGUID == this.CityGUID)) { if (base.Definition.Name == DiplomaticTermCityExchange.MimicsCityDeal) { return(false); } if (diplomaticTermCityExchange.EmpireWhichProvides.Index == base.EmpireWhichProvides.Index) { num--; num2++; } else if (diplomaticTermCityExchange.EmpireWhichProvides.Index == base.EmpireWhichReceives.Index) { num2--; num++; } else { Diagnostics.LogError("Can't identify the empire which provides the term {0}.", new object[] { diplomaticTermCityExchange }); } } } num--; num2++; return(num >= 1 && num2 >= 1); }