protected override bool Initialize(QuestBehaviour questBehaviour) { if (this.gameEntityRepositoryService == null) { IGameService service = Services.GetService <IGameService>(); if (service == null || service.Game == null) { Diagnostics.LogError("Failed to retrieve the game service."); return(false); } global::Game game = service.Game as global::Game; if (game == null) { Diagnostics.LogError("Failed to cast gameService.Game to Game."); return(false); } this.gameEntityRepositoryService = game.Services.GetService <IGameEntityRepositoryService>(); if (this.gameEntityRepositoryService == null) { Diagnostics.LogError("Failed to retrieve the game entity repository service."); return(false); } } IGarrison garrison; if (this.StoredDestination != 0UL && !string.IsNullOrEmpty(this.Output_DestinationGUID) && this.gameEntityRepositoryService.TryGetValue <IGarrison>(this.StoredDestination, out garrison)) { base.UpdateQuestVariable(questBehaviour, this.Output_DestinationGUID, garrison.GUID); } return(base.Initialize(questBehaviour)); }
protected override bool Initialize(QuestBehaviour questBehaviour) { Diagnostics.Log("UpdateVariable.Initialize"); global::Game game = Services.GetService <IGameService>().Game as global::Game; if (game == null) { Diagnostics.LogError("Cannot retrieve game service, Action_uptateVariable"); } if (this.EmpireIndex != -1) { QuestVariable questVariable = questBehaviour.QuestVariables.FirstOrDefault((QuestVariable match) => match.Name == this.EmpireVarName); if (questVariable == null) { questVariable = new QuestVariable(this.EmpireVarName); questBehaviour.QuestVariables.Add(questVariable); } questVariable.Object = game.Empires[this.EmpireIndex]; } MajorEmpire majorEmpire; if (this.EmpireIndex == -1 && this.EmpireVarName != string.Empty && questBehaviour.TryGetQuestVariableValueByName <MajorEmpire>(this.EmpireVarName, out majorEmpire)) { this.EmpireIndex = majorEmpire.Index; } return(true); }
protected override bool Initialize(QuestBehaviour questBehaviour) { IGameService service = Services.GetService <IGameService>(); if (service == null || service.Game == null) { Diagnostics.LogError("Failed to retrieve the game service."); return(false); } this.Game = (service.Game as global::Game); if (this.Game == null) { Diagnostics.LogError("Failed to cast gameService.Game to Game."); return(false); } if (this.ArmyGUID == 0UL) { ulong armyGUID; if (!string.IsNullOrEmpty(this.ArmyGUIDVarName) && questBehaviour.TryGetQuestVariableValueByName <ulong>(this.ArmyGUIDVarName, out armyGUID)) { this.ArmyGUID = armyGUID; } } else { QuestVariable questVariable = questBehaviour.QuestVariables.FirstOrDefault((QuestVariable match) => match.Name == this.ArmyGUIDVarName); if (questVariable == null) { questVariable = new QuestVariable(this.ArmyGUIDVarName); questBehaviour.QuestVariables.Add(questVariable); } questVariable.Object = this.ArmyGUID; } return(base.Initialize(questBehaviour)); }
public override IEnumerator Load(global::Game game) { yield return(base.Load(game)); this.UpdateRegionData(); yield break; }
protected override IEnumerator OnLoadGame(Amplitude.Unity.Game.Game game) { yield return(base.OnLoadGame(game)); for (int i = 0; i < this.villages.Count; i++) { Village village = this.villages[i]; this.GameEntityRepositoryService.Register(village); foreach (Unit instance in village.Units) { this.GameEntityRepositoryService.Register(instance); } if (village.HasBeenConvertedByIndex >= 0 && village.HasBeenConvertedBy == null) { global::Game game2 = game as global::Game; Diagnostics.Assert(game2 != null); Diagnostics.Assert(game2.Empires != null); Diagnostics.Assert(village.HasBeenConvertedByIndex < game2.Empires.Length); village.HasBeenConvertedBy = (game2.Empires[village.HasBeenConvertedByIndex] as MajorEmpire); Diagnostics.Assert(village.Converter != null); Diagnostics.Assert(village.Converter.Index == village.HasBeenConvertedByIndex); } } yield break; }
private City[] GetKnownCities(bool includeOwnCities = true) { List <City> list = new List <City>(); global::Game game = this.gameService.Game as global::Game; if (game != null) { for (int i = 0; i < game.Empires.Length; i++) { if (game.Empires[i] is MajorEmpire) { if (includeOwnCities || game.Empires[i].Index != base.AIEntity.Empire.Index) { DepartmentOfTheInterior agency = game.Empires[i].GetAgency <DepartmentOfTheInterior>(); if (agency != null && agency.Cities != null) { for (int j = 0; j < agency.Cities.Count; j++) { if (this.visibilityService.IsWorldPositionExploredFor(agency.Cities[j].WorldPosition, base.AIEntity.Empire)) { list.Add(agency.Cities[j]); } } } } } } } return(list.ToArray()); }
private void RefreshOtherEmpiresDropList() { global::Game game = base.Game as global::Game; Diagnostics.Assert(game != null); List <DiplomaticRelation> list = (from relation in this.DepartmentOfForeignAffairs.DiplomaticRelations where relation.OwnerEmpireIndex == this.Empire.Index select relation).ToList <DiplomaticRelation>(); list.RemoveAll((DiplomaticRelation diplomaticRelation) => diplomaticRelation.State == null || diplomaticRelation.State.Name == DiplomaticRelationState.Names.Unknown || diplomaticRelation.State.Name == DiplomaticRelationState.Names.Dead); this.otherEmpires = (from relation in list select game.Empires[relation.OtherEmpireIndex]).ToArray <global::Empire>(); List <string> list2 = new List <string>(); List <string> list3 = new List <string>(); for (int i = 0; i < this.otherEmpires.Length; i++) { string text; AgeUtils.ColorToHexaKey(this.otherEmpires[i].Color, out text); string text2 = string.Concat(new string[] { text, this.otherEmpires[i].LocalizedName, " - ", this.otherEmpires[i].Faction.LocalizedName, "#REVERT#" }); list2.Add(text2); list3.Add((!this.otherEmpires[i].IsControlledByAI) ? (text2 + "\n" + AgeLocalizer.Instance.LocalizeString("%CompetitorEmpireTypeHumanDescription")) : (text2 + "\n" + AgeLocalizer.Instance.LocalizeString("%CompetitorEmpireTypeComputerDescription"))); } this.TheirEmpireNameDropList.ItemTable = list2.ToArray(); this.TheirEmpireNameDropList.TooltipTable = list3.ToArray(); }
public static float GetUnitPrice(TradableCategoryDefinition tradableCategoryDefinition, float value = 0f) { float num = 0f; float num2 = 0f; float num3 = 0f; IGameService service = Services.GetService <IGameService>(); if (service != null) { global::Game game = service.Game as global::Game; num3 = (float)game.Turn * Tradable.InflationMultiplier; ITradeManagementService service2 = game.Services.GetService <ITradeManagementService>(); TradableCategoryTendency tendency; TradableCategoryStockFactor stockFactor; if (service2 != null && service2.TryGetTradableCategoryState(tradableCategoryDefinition.Name, out tendency, out stockFactor)) { num = tendency; num2 = stockFactor; } } num3 *= tradableCategoryDefinition.SensitivityToInflation; num *= tradableCategoryDefinition.SensitivityToTendency; num2 *= tradableCategoryDefinition.SensitivityToStockFactor; value *= tradableCategoryDefinition.ValueModifier; float num4 = tradableCategoryDefinition.ReferencePrice * (1f + num3) + value * (1f + num3); float val = num4 * (1f + num + num2); float val2 = num4 * Tradable.MinimumPriceMultiplier; float val3 = num4 * Tradable.MaximumPriceMultiplier; return(Math.Max(val2, Math.Min(val3, val))); }
protected override State Execute(QuestBehaviour questBehaviour, EventTerraformDeviceEntityCreated e, params object[] parameters) { global::Game game = Services.GetService <IGameService>().Game as global::Game; if (this.DevicePositionVarName == string.Empty) { return(State.Success); } IEnumerable <WorldPosition> source; if (this.DevicePositionVarName != null && questBehaviour.TryGetQuestVariableValueByName <WorldPosition>(this.DevicePositionVarName, out source)) { this.DevicePositions = source.ToArray <WorldPosition>(); } if (this.DevicePositions != null && this.DevicePositions[0] == e.TerraformDevice.WorldPosition) { IQuestManagementService service = game.Services.GetService <IQuestManagementService>(); if (service != null) { this.EntityGUID = e.TerraformDevice.GUID; QuestVariable questVariable = new QuestVariable(this.Output_EntityVarName, e.TerraformDevice); service.State.AddGlobalVariable(questBehaviour.Initiator.Index, questVariable); } return(State.Success); } return(State.Running); }
private void InitializeAIParameter(IServiceContainer serviceContainer, global::Game game) { this.WorldPositionningService = game.Services.GetService <IWorldPositionningService>(); this.SimulationDescriptorDatabase = Databases.GetDatabase <SimulationDescriptor>(false); int num = 0; for (int i = 0; i < game.Empires.Length; i++) { if (game.Empires[i] is MinorEmpire) { break; } num++; } this.scoreByWorldPositionByEmpires = new GridMap <WorldPositionScore> [num]; this.cityProxyByEmpires = new SimulationObject[num]; this.districtProxyByEmpires = new SimulationObject[num]; SimulationDescriptor value = this.SimulationDescriptorDatabase.GetValue("ClassCity"); for (int j = 0; j < num; j++) { this.scoreByWorldPositionByEmpires[j] = new GridMap <WorldPositionScore>("PositionScore", (int)this.WorldPositionningService.World.WorldParameters.Columns, (int)this.WorldPositionningService.World.WorldParameters.Rows, null); this.cityProxyByEmpires[j] = new SimulationObject("WorldPositionEvaluation.CityProxy#" + j); this.cityProxyByEmpires[j].ModifierForward = ModifierForwardType.ChildrenOnly; this.cityProxyByEmpires[j].AddDescriptor(value); this.districtProxyByEmpires[j] = new SimulationObject("WorldPositionEvaluation.DistrictProxy#" + j); this.districtProxyByEmpires[j].ModifierForward = ModifierForwardType.ChildrenOnly; this.cityProxyByEmpires[j].AddChild_ModifierForwardType_ChildrenOnly(this.districtProxyByEmpires[j]); game.Empires[j].SimulationObject.AddChild_ModifierForwardType_ChildrenOnly(this.cityProxyByEmpires[j]); } }
protected void UpdateGameModifiers(global::Game game) { Diagnostics.Assert(game != null); PlayerType playerType = (!this.IsControlledByAI) ? PlayerType.Human : PlayerType.AI; this.Refresh(true); this.ApplyGameModifier(GameModifierDefinition.GetGameDifficultyReference(game.GameDifficulty), playerType); this.Refresh(true); this.ApplyGameModifier(GameModifierDefinition.GetGameSpeedReference(game.GameSpeed), playerType); this.Refresh(true); this.ApplyGameModifier(GameModifierDefinition.GetMinorFactionDifficultyReference(game.MinorFactionDifficulty), playerType); this.Refresh(true); this.ApplyGameModifier("ELCPEmpireProperties", playerType); this.Refresh(true); ISessionService service = Services.GetService <ISessionService>(); if (service != null && service.Session != null) { string x = string.Format("Handicap{0}", base.Index); string lobbyData = service.Session.GetLobbyData <string>(x, "5"); if (lobbyData != "5") { this.ApplyGameModifier("Handicap" + lobbyData, playerType); this.Refresh(true); } } DepartmentOfHealth agency = base.GetAgency <DepartmentOfHealth>(); if (agency != null) { agency.RefreshApprovalStatus(); } }
public void BindPlayer(Player player) { Diagnostics.Assert(player != null); switch (player.Type) { case PlayerType.Unset: throw new GameException("Player type is unset."); case PlayerType.AI: base.IsControlledByAI = true; break; case PlayerType.Human: base.IsControlledByAI = false; break; default: throw new ArgumentOutOfRangeException(); } IGameService service = Services.GetService<IGameService>(); Diagnostics.Assert(service != null); global::Game game = service.Game as global::Game; Diagnostics.Assert(game != null); base.UpdateGameModifiers(game); this.players.Add(player); IPlayerRepositoryService service2 = game.GetService<IPlayerRepositoryService>(); Diagnostics.Assert(service2 != null); service2.Register(player); if (this.OnPlayerBond != null) { this.OnPlayerBond(this, player); } }
private void CreateAmbassadorInteractionPanels() { if (this.ambassadorInteractionPanels != null) { this.DestroyAmbassadorInteractionPanels(); } global::Game game = base.Game as global::Game; int num = (from empire in game.Empires where empire is MajorEmpire select empire).Count <global::Empire>(); this.ambassadorInteractionPanels = new AmbassadorInteractionPanel[num]; for (int i = 0; i < num; i++) { Transform transform = UnityEngine.Object.Instantiate <Transform>(this.AmbassadorInteractionPanelPrefab); if (transform != null) { transform.parent = base.transform; AmbassadorInteractionPanel component = transform.GetComponent <AmbassadorInteractionPanel>(); component.Bind(this.LookingEmpire, game.Empires[i], base.Empire, this); component.Load(); component.RefreshContent(); component.Hide(true); this.ambassadorInteractionPanels[i] = component; } } }
public IEnumerator LoadGame(global::Game game) { this.UpdateGameModifiers(game); yield return(this.OnLoadGame(game)); yield break; }
private void ComputeTameCosts(global::Game game) { System.Random random = new System.Random(World.Seed); IDatabase <ArmyAction> database = Databases.GetDatabase <ArmyAction>(false); Diagnostics.Assert(database != null); Dictionary <string, List <PointOfInterestTemplate> > dictionary = KaijuTechsManager.ComputeLuxuryAbundance(game); for (int i = 0; i < database.Count <ArmyAction>(); i++) { ArmyAction armyAction = database.ElementAt(i); if (armyAction is IArmyActionWithKaijuTameCost) { KaijuTameCost tameCost = (armyAction as IArmyActionWithKaijuTameCost).TameCost; for (int j = 0; j < tameCost.CostDefinitions.Length; j++) { KaijuTameCost.CostDefinition costDefinition = tameCost.CostDefinitions[j]; List <PointOfInterestTemplate> list = new List <PointOfInterestTemplate>(); list.AddRange(dictionary[costDefinition.LuxuryTier]); PointOfInterestTemplate pointOfInterestTemplate = list[random.Next(list.Count)]; string empty = string.Empty; if (pointOfInterestTemplate.Properties.TryGetValue("ResourceName", out empty)) { costDefinition.SetResourceName(empty); } } } } }
private static void StaticInitialize() { IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null, "Failed to retrieve game service"); global::Game game = service.Game as global::Game; Diagnostics.Assert(game != null, "Failed to retrieve game reference"); KaijuCouncil.attractivenessMap = null; KaijuCouncil.majorEmpires = null; KaijuCouncil.attractivenessDatabase = Databases.GetDatabase <KaijuAttractivenessRule>(false); Diagnostics.Assert(KaijuCouncil.attractivenessDatabase != null, "Failed to retrieve attractiveness database"); KaijuCouncil.world = game.World; Diagnostics.Assert(KaijuCouncil.world != null, "Failed to retrieve game world"); KaijuCouncil.worldPositionService = game.Services.GetService <IWorldPositionningService>(); Diagnostics.Assert(KaijuCouncil.worldPositionService != null, "Failed to retrieve world positioning service"); if (game.Empires != null) { KaijuCouncil.majorEmpires = Array.ConvertAll <global::Empire, MajorEmpire>(Array.FindAll <global::Empire>(game.Empires, (global::Empire match) => match is MajorEmpire), (global::Empire empire) => empire as MajorEmpire); if (KaijuCouncil.majorEmpires.Length == 0) { Diagnostics.LogError("No MajorEmpires were retrieved"); } } KaijuCouncil.random = new System.Random(World.Seed); }
private void OnSeasonChange(object sender, SeasonChangeEventArgs e) { if (e.NewSeason.SeasonDefinition.SeasonType != Season.ReadOnlyHeatWave) { return; } global::Game game = this.GameService.Game as global::Game; if (game == null) { return; } List <int> empireIndexesOfFaction = game.GetEmpireIndexesOfFaction("FactionDrakkens"); for (int i = 0; i < empireIndexesOfFaction.Count; i++) { for (int j = 0; j < this.villages.Count; j++) { if (this.villages[j].PointOfInterest != null) { this.villages[j].PointOfInterest.Interaction.RemoveInteractionLock(i, "ArmyActionReceiveDiplomacy"); } } } }
protected override bool Initialize(QuestBehaviour questBehaviour) { IGameService service = Services.GetService <IGameService>(); if (service == null || service.Game == null) { Diagnostics.LogError("Failed to retrieve the game service."); return(false); } global::Game game = service.Game as global::Game; if (game == null) { Diagnostics.LogError("Failed to cast gameService.Game to Game."); return(false); } this.gameEntityRepositoryService = game.Services.GetService <IGameEntityRepositoryService>(); if (this.gameEntityRepositoryService == null) { Diagnostics.LogError("Failed to retrieve the game entity repository service."); return(false); } City value; if (this.StoredCity != 0UL && !string.IsNullOrEmpty(this.Output_CityVarName) && this.gameEntityRepositoryService.TryGetValue <City>(this.StoredCity, out value)) { this.UpdateQuestVariable(questBehaviour, this.Output_CityVarName, value); } return(base.Initialize(questBehaviour)); }
private void FilterPointOfInterests(Army army, ref bool available) { IGameService service = Services.GetService <IGameService>(); if (service == null) { return; } global::Game x = service.Game as global::Game; if (x == null) { return; } IQuestManagementService service2 = service.Game.Services.GetService <IQuestManagementService>(); Diagnostics.Assert(service2 != null); IQuestRepositoryService service3 = service.Game.Services.GetService <IQuestRepositoryService>(); Diagnostics.Assert(service2 != null); available = false; for (int i = base.PointsOfInterest.Count - 1; i >= 0; i--) { if (!this.CanSearch(army, base.PointsOfInterest[i], service2, service3, ref available)) { base.PointsOfInterest.RemoveAt(i); } } }
public override void ReadXml(XmlReader reader) { IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); Diagnostics.Assert(service.Game != null); global::Game game = service.Game as global::Game; Diagnostics.Assert(game != null); reader.ReadVersionAttribute(); this.GUID = reader.GetAttribute <ulong>("GUID"); base.ReadXml(reader); string x = reader.ReadElementString("NodeDefinitionName"); IDatabase <CreepingNodeImprovementDefinition> database = Databases.GetDatabase <CreepingNodeImprovementDefinition>(true); CreepingNodeImprovementDefinition nodeDefinition = null; if (database.TryGetValue(x, out nodeDefinition)) { this.NodeDefinition = nodeDefinition; } int num = reader.ReadElementString <int>("IndexOfPointOfInterest"); int num2 = reader.ReadElementString <int>("IndexOfRegion"); this.PointOfInterest = game.World.Regions[num2].PointOfInterests[num]; this.LastTurnChecked = reader.ReadElementString <int>("LastTurnChecked"); this.IsUpgradeReady = reader.ReadElementString <bool>("IsUpgradeReady"); this.UpgradeReachedTurn = reader.ReadElementString <int>("UpgradeReachedTurn"); this.TurnsCounter = reader.ReadElementString <float>("TurnsCounter"); this.dismantlingArmyGUID = reader.ReadElementString <ulong>("DismantlingArmyGUID"); this.Life = reader.ReadElementString <float>("Life"); this.MaxLife = reader.ReadElementString <float>("MaxLife"); this.LastTurnWhenDismantleBegun = reader.ReadElementString <int>("LastTurnWhenDismantleBegun"); this.ReadDictionnary(reader, "StoredConstructionCost", this.StoredConstructionCost); }
private void ListNearbyCreepingNodesFiltered(Army army) { if (army == null) { throw new ArgumentNullException("army"); } this.creepingNodes.Clear(); IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); global::Game game = service.Game as global::Game; Diagnostics.Assert(game != null); IWorldPositionningService service2 = service.Game.Services.GetService <IWorldPositionningService>(); Diagnostics.Assert(service2 != null); IGameEntityRepositoryService service3 = service.Game.Services.GetService <IGameEntityRepositoryService>(); Diagnostics.Assert(service3 != null); List <StaticString> list = new List <StaticString>(); List <WorldPosition> neighbours = army.WorldPosition.GetNeighbours(game.World.WorldParameters); for (int i = 0; i < neighbours.Count; i++) { PointOfInterest pointOfInterest = service2.GetPointOfInterest(neighbours[i]); if (pointOfInterest != null && pointOfInterest.CreepingNodeGUID != GameEntityGUID.Zero) { CreepingNode creepingNode = null; if (service3.TryGetValue <CreepingNode>(pointOfInterest.CreepingNodeGUID, out creepingNode) && this.CanToggleOverCreepingNode(army, creepingNode, ref list) && !this.creepingNodes.Contains(creepingNode)) { this.creepingNodes.Add(creepingNode); } } } }
private IEnumerator GameServerState_Turn_Begin_Interact(string context, string pass) { IGameService gameService = Services.GetService<IGameService>(); Diagnostics.Assert(gameService != null); Diagnostics.Assert(gameService.Game != null); global::Game game = gameService.Game as global::Game; if (game != null && game.Turn > this.TurnWhenLastBegun) { this.TurnWhenLastBegun = game.Turn; OrderInteractWith order = new OrderInteractWith(base.Index, GameEntityGUID.Zero, "BeginTurn"); order.WorldPosition = WorldPosition.Invalid; order.Tags.AddTag("BeginTurn"); if (global::GameManager.Preferences.QuestVerboseMode) { Diagnostics.Log("[Quest] Trying to trigger quests with event BeginTurn for empire {0}", new object[] { order.EmpireIndex }); } IPlayerControllerRepositoryControl playerControllerRepositoryService = gameService.Game.Services.GetService<IPlayerControllerRepositoryService>() as IPlayerControllerRepositoryControl; playerControllerRepositoryService.GetPlayerControllerById("server").PostOrder(order); } yield return null; yield break; }
private void ComputeGlobalPriority() { base.GlobalPriority.Reset(); if (this.departmentOfTheInterior.Cities.Count == 0) { base.GlobalPriority.Add(1f, "No more city!", new object[0]); } else { AILayer_Strategy layer = base.AIEntity.GetLayer <AILayer_Strategy>(); base.GlobalPriority.Add(layer.StrategicNetwork.GetAgentValue("Expansion"), "Expansion strategic network score", new object[0]); if (this.aiLayerStrategy.IsAtWar() && this.CurrentSettlerCount < 2) { base.GlobalPriority.Boost(-0.5f, "At war", new object[0]); } else if (this.aiLayerStrategy.WantWarWithSomeone() && this.CurrentSettlerCount < 2) { base.GlobalPriority.Boost(-0.2f, "Want war but not at war", new object[0]); } else if (this.departmentOfTheInterior.Cities.Count == 1) { base.GlobalPriority.Boost(0.2f, "I am sure you want more than one city...", new object[0]); } } global::Game game = Services.GetService <IGameService>().Game as global::Game; if (!this.aiLayerStrategy.IsAtWar() && this.departmentOfTheInterior.Cities.Count < 5 && this.departmentOfTheInterior.Cities.Count * 20 < game.Turn && base.AIEntity.Empire.GetPropertyValue(SimulationProperties.NetEmpireApproval) > 70f) { float operand = Mathf.Min(1f, 0.04f * (float)(game.Turn - this.departmentOfTheInterior.Cities.Count * 20)); base.GlobalPriority.Boost(operand, "low city count boost", new object[0]); } }
public override void ReadXml(XmlReader reader) { IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); Diagnostics.Assert(service.Game != null); global::Game game = service.Game as global::Game; Diagnostics.Assert(game != null); this.HasBeenPacified = reader.GetAttribute <bool>("HasBeenPacified"); int num = reader.ReadVersionAttribute(); if (num >= 2) { this.HasBeenConvertedByIndex = reader.GetAttribute <int>("HasBeenConvertedByIndex"); this.ConvertedUnitSpawnTurn = reader.GetAttribute <int>("ConvertedUnitSpawnTurn"); this.HasBeenConvertedBy = null; } base.ReadXml(reader); int num2 = reader.ReadElementString <int>("IndexOfPointOfInterest"); if (num >= 3) { int num3 = reader.ReadElementString <int>("IndexOfRegion"); this.PointOfInterest = game.World.Regions[num3].PointOfInterests[num2]; } else { MinorEmpire minorEmpire = this.Empire as MinorEmpire; Diagnostics.Assert(minorEmpire != null); this.PointOfInterest = minorEmpire.Region.PointOfInterests[num2]; } }
private void ListNearbyDevicesFiltered(Army army) { if (army == null) { throw new ArgumentNullException("army"); } this.devices.Clear(); IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); global::Game game = service.Game as global::Game; Diagnostics.Assert(game != null); ITerraformDeviceService service2 = game.Services.GetService <ITerraformDeviceService>(); Diagnostics.Assert(service2 != null); List <WorldPosition> neighbours = army.WorldPosition.GetNeighbours(game.World.WorldParameters); for (int i = 0; i < neighbours.Count; i++) { TerraformDevice deviceAtPosition = service2.GetDeviceAtPosition(neighbours[i]); List <StaticString> list = new List <StaticString>(); if (this.CanToggleOverDevice(army, deviceAtPosition, ref list) && !this.devices.Contains(deviceAtPosition)) { this.devices.Add(deviceAtPosition); } } }
public override void ReadXml(XmlReader reader) { int attribute = reader.GetAttribute <int>("RegionTargetIndex"); this.region = null; if (attribute > -1) { IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); global::Game game = service.Game as global::Game; World world = game.World; this.region = world.Regions[attribute]; Diagnostics.Assert(this.region != null); } ulong attribute2 = reader.GetAttribute <ulong>("RequestGarrisonMessageID"); this.requestGarrison = null; if (attribute2 != 0UL) { Diagnostics.Assert(base.Commander != null); Diagnostics.Assert(base.Commander.AIPlayer != null); Diagnostics.Assert(base.Commander.AIPlayer.Blackboard != null); this.requestGarrison = (base.Commander.AIPlayer.Blackboard.GetMessage(attribute2) as RequestGarrisonMessage); } base.ReadXml(reader); }
public void RefreshDiplomaticAbilities() { IGameService service = Services.GetService <IGameService>(); global::Game game = service.Game as global::Game; Diagnostics.Assert(game != null); int count = this.diplomaticAbilities.Count; for (int i = 0; i < count; i++) { DiplomaticAbilityDefinition definition = this.diplomaticAbilities[i].Definition; if (definition != null) { bool flag = definition.CheckDiplomaticAbilityPrerequisites(game.Empires[this.OwnerEmpireIndex], game.Empires[this.OtherEmpireIndex]) && definition.CheckPrerequisites(game.Empires[this.OwnerEmpireIndex]); if (flag != this.diplomaticAbilities[i].IsActive) { if (this.diplomaticAbilities[i].IsActive) { this.diplomaticAbilities[i].IsActive = false; this.UpdateEmpireDiplomaticAbilityDescriptor(definition, game.Empires[this.OwnerEmpireIndex], false); } else { this.diplomaticAbilities[i].IsActive = true; this.UpdateEmpireDiplomaticAbilityDescriptor(definition, game.Empires[this.OwnerEmpireIndex], true); } } } } }
public static void main() { global::Game newGame = new global::Game(); string line = ((global::haxe.io.Input)(new global::cs.io.NativeInput(((global::System.IO.Stream)(global::System.Console.OpenStandardInput()))))).readLine(); global::Move playerMove = ((global::Move)(global::Type.createEnum <object>(((global::System.Type)(typeof(global::Move))), ((string)(line)), default(global::Array)))); newGame.start(playerMove); }
public override bool Check(IDiplomaticContract diplomaticContract, global::Empire empireWhichProvides, global::Empire empireWhichReceives) { global::Game game = Services.GetService <IGameService>().Game as global::Game; IDiplomaticContractRepositoryService service = game.Services.GetService <IDiplomaticContractRepositoryService>(); Predicate <DiplomaticContract> match = (DiplomaticContract contract) => (contract.EmpireWhichProposes == empireWhichProvides && contract.EmpireWhichReceives == empireWhichReceives) || (contract.EmpireWhichProposes == empireWhichReceives && contract.EmpireWhichReceives == empireWhichProvides); int num = -100; bool flag = false; foreach (DiplomaticContract diplomaticContract2 in service.FindAll(match)) { if (diplomaticContract2.State == DiplomaticContractState.Signed) { string[] diplomaticTermNames = this.DiplomaticTermNames; for (int i = 0; i < diplomaticTermNames.Length; i++) { string termname = diplomaticTermNames[i]; if (termname.Contains("ToWar")) { flag = true; } if (!this.OnlyWhenProposer) { if (diplomaticContract2.Terms.Any((DiplomaticTerm term) => term.Definition.Name.ToString() == termname)) { num = Mathf.Max(num, diplomaticContract2.TurnAtTheBeginningOfTheState); } } else if (diplomaticContract2.Terms.Any((DiplomaticTerm term) => term.Definition.Name.ToString() == termname && term.EmpireWhichProvides == empireWhichProvides)) { num = Mathf.Max(num, diplomaticContract2.TurnAtTheBeginningOfTheState); } } } } if (flag) { match = ((DiplomaticContract contract) => contract.EmpireWhichProposes == empireWhichProvides || contract.EmpireWhichReceives == empireWhichProvides); Func <DiplomaticTerm, bool> < > 9__4; foreach (DiplomaticContract diplomaticContract3 in service.FindAll(match)) { if (diplomaticContract3.State == DiplomaticContractState.Signed) { IEnumerable <DiplomaticTerm> terms = diplomaticContract3.Terms; Func <DiplomaticTerm, bool> predicate; if ((predicate = < > 9__4) == null) { predicate = (< > 9__4 = ((DiplomaticTerm term) => term is DiplomaticTermProposal && term.EmpireWhichProvides == empireWhichProvides && (term as DiplomaticTermProposal).ChosenEmpire == empireWhichReceives && term.Definition.Name == "AskToDeclareWar")); } if (terms.Any(predicate)) { num = Mathf.Max(num, diplomaticContract3.TurnAtTheBeginningOfTheState); } } } } return(base.Inverted ^ game.Turn - num >= this.Cooldown); }
public override State CheckCondition(QuestBehaviour questBehaviour, GameEvent gameEvent, params object[] parameters) { if (this.RegionIndex != -1) { IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); global::Game game = service.Game as global::Game; if (game == null) { return(State.Failure); } IWorldPositionningService service2 = service.Game.Services.GetService <IWorldPositionningService>(); global::Empire empire; if (gameEvent != null) { empire = (gameEvent.Empire as global::Empire); } else { empire = questBehaviour.Initiator; } DepartmentOfForeignAffairs agency = empire.GetAgency <DepartmentOfForeignAffairs>(); Diagnostics.Assert(agency != null); for (int i = 0; i < game.Empires.Length; i++) { if (i != empire.Index && (this.IgnoredEmpiresIndex == null || !this.IgnoredEmpiresIndex.Contains(i))) { global::Empire empire2 = game.Empires[i]; bool flag; if (empire2 is MajorEmpire) { DiplomaticRelation diplomaticRelation = agency.GetDiplomaticRelation(empire2); Diagnostics.Assert(diplomaticRelation != null); Diagnostics.Assert(diplomaticRelation.State != null); flag = (diplomaticRelation.State.Name == DiplomaticRelationState.Names.ColdWar || diplomaticRelation.State.Name == DiplomaticRelationState.Names.War || diplomaticRelation.State.Name == DiplomaticRelationState.Names.Unknown); } else { flag = true; } if (flag) { DepartmentOfDefense agency2 = empire2.GetAgency <DepartmentOfDefense>(); for (int j = 0; j < agency2.Armies.Count; j++) { if ((this.IncludeNaval || !agency2.Armies[j].IsNaval) && (int)service2.GetRegionIndex(agency2.Armies[j].WorldPosition) == this.RegionIndex) { return(State.Success); } } } } } } return(State.Failure); }