public override void Initialize(AgentDefinition agentDefinition, AgentGroup parentGroup) { base.Initialize(agentDefinition, parentGroup); AIPlayer_MajorEmpire aiplayer_MajorEmpire = base.ContextObject as AIPlayer_MajorEmpire; if (aiplayer_MajorEmpire == null) { Diagnostics.LogError("The agent context object is not an ai player."); return; } this.empire = aiplayer_MajorEmpire.MajorEmpire; if (this.empire == null) { Diagnostics.LogError("Can't retrieve the empire."); return; } Diagnostics.Assert(base.ParentGroup != null); this.netEmpireMoneyAgent = (base.ParentGroup.GetAgent("NetEmpireMoney") as SimulationNormalizedAgent); Diagnostics.Assert(this.netEmpireMoneyAgent != null); this.departmentOfScience = this.empire.GetAgency <DepartmentOfScience>(); IGameService service = Services.GetService <IGameService>(); this.game = (service.Game as global::Game); InfluencedByPersonalityAttribute.LoadFieldAndPropertyValues(this.empire, this); }
public override void Initialize(AgentDefinition agentDefinition, AgentGroup parentGroup) { base.Initialize(agentDefinition, parentGroup); Diagnostics.Assert(base.ParentGroup != null && base.ParentGroup.Parent != null); AIPlayer_MajorEmpire aiplayer_MajorEmpire = base.ParentGroup.Parent.ContextObject as AIPlayer_MajorEmpire; Diagnostics.Assert(aiplayer_MajorEmpire != null); this.Empire = aiplayer_MajorEmpire.MajorEmpire; if (this.Empire == null) { Diagnostics.LogError("The agent's parent context object is not an empire"); return; } this.EmpireWhichReceives = (base.ParentGroup.ContextObject as global::Empire); if (this.EmpireWhichReceives == null) { Diagnostics.LogError("The agent context object is not an empire"); return; } this.aiEntityEmpire = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); if (this.aiEntityEmpire == null) { Diagnostics.LogError("The AIPlayer has no ai entity empire."); return; } InfluencedByPersonalityAttribute.LoadFieldAndPropertyValues(this.aiEntityEmpire.Empire, this); }
public override void Initialize(AgentDefinition agentDefinition, AgentGroup parentGroup) { base.Initialize(agentDefinition, parentGroup); AIPlayer_MajorEmpire aiPlayer = base.ContextObject as AIPlayer_MajorEmpire; if (aiPlayer == null) { Diagnostics.LogError("The agent context object is not an ai player."); return; } this.empire = aiPlayer.MajorEmpire; if (this.empire == null) { Diagnostics.LogError("Can't retrieve the empire."); return; } Diagnostics.Assert(this.empire != null); this.departmentOfTheInterior = this.empire.GetAgency <DepartmentOfTheInterior>(); Diagnostics.Assert(this.departmentOfTheInterior != null); this.departmentOfTheTreasury = this.empire.GetAgency <DepartmentOfTheTreasury>(); Diagnostics.Assert(this.departmentOfTheTreasury != null); DepartmentOfIndustry agency = this.empire.GetAgency <DepartmentOfIndustry>(); Diagnostics.Assert(agency != null); DepartmentOfIndustry.ConstructibleElement[] availableConstructibleElements = ((IConstructibleElementDatabase)agency).GetAvailableConstructibleElements(new StaticString[] { DistrictImprovementDefinition.ReadOnlyCategory }); Diagnostics.Assert(availableConstructibleElements != null); this.districtImprovement = Array.Find <DepartmentOfIndustry.ConstructibleElement>(availableConstructibleElements, (DepartmentOfIndustry.ConstructibleElement element) => element.Name == aiPlayer.AIData_Faction.DistrictImprovement); Diagnostics.Assert(this.districtImprovement != null && this.districtImprovement.Costs != null); InfluencedByPersonalityAttribute.LoadFieldAndPropertyValues(this.empire, this); }
public bool TryGetMajorEmpireAIPlayer(MajorEmpire majorEmpire, out AIPlayer_MajorEmpire aiPlayerMajorEmpire) { if (majorEmpire == null) { throw new ArgumentNullException("majorEmpire"); } aiPlayerMajorEmpire = null; Diagnostics.Assert(this.aiPlayerMajorEmpires != null); for (int i = 0; i < this.aiPlayerMajorEmpires.Count; i++) { AIPlayer_MajorEmpire aiplayer_MajorEmpire = this.aiPlayerMajorEmpires[i]; Diagnostics.Assert(aiplayer_MajorEmpire != null && aiplayer_MajorEmpire.MajorEmpire != null); if (aiplayer_MajorEmpire.MajorEmpire.Index == majorEmpire.Index) { aiPlayerMajorEmpire = aiplayer_MajorEmpire; return(true); } } return(false); }
private IEnumerator InitializeMajorEmpires(Game game) { for (int index = 0; index < game.Empires.Length; index++) { Empire empire = game.Empires[index]; if (empire is MajorEmpire) { AIPlayer_MajorEmpire playerMajorEmpire = new AIPlayer_MajorEmpire(empire as MajorEmpire); playerMajorEmpire.ChangeAIState(AIPlayer.PlayerState.EmpireControlledByAI); this.aiPlayerMajorEmpires.Add(playerMajorEmpire); } } bool isPlayerThreaded = this.IsThreaded; isPlayerThreaded = false; for (int index2 = 0; index2 < this.aiPlayerMajorEmpires.Count; index2++) { yield return(this.aiPlayerMajorEmpires[index2].Initialize(isPlayerThreaded)); } yield break; }
public override void Initialize(AgentDefinition agentDefinition, AgentGroup parentGroup) { base.Initialize(agentDefinition, parentGroup); AIPlayer_MajorEmpire aiplayer_MajorEmpire = base.ContextObject as AIPlayer_MajorEmpire; if (aiplayer_MajorEmpire == null) { Diagnostics.LogError("The agent context object is not an ai player."); return; } this.empire = aiplayer_MajorEmpire.MajorEmpire; if (this.empire == null) { Diagnostics.LogError("Can't retrieve the empire."); return; } this.aiEntityEmpire = aiplayer_MajorEmpire.GetEntity <AIEntity_Empire>(); Diagnostics.Assert(this.aiEntityEmpire != null); Diagnostics.Assert(base.ParentGroup != null); this.netEmpireMoneyAgent = (base.ParentGroup.GetAgent("NetEmpireMoney") as SimulationNormalizedAgent); Diagnostics.Assert(this.netEmpireMoneyAgent != null); InfluencedByPersonalityAttribute.LoadFieldAndPropertyValues(this.aiEntityEmpire.Empire, this); }