public virtual void ReadXml(XmlReader reader) { int num = reader.ReadVersionAttribute(); if (num >= 5) { this.InternalGUID = reader.GetAttribute <ulong>("InternalGUID"); } if (this.InternalGUID == GameEntityGUID.Zero) { this.InternalGUID = AIScheduler.Services.GetService <IAIEntityGUIDAIHelper>().GenerateAIEntityGUID(); } this.ForceArmyGUID = reader.GetAttribute <ulong>("ForceArmyGUID", 0UL); reader.ReadStartElement(); try { if (reader.IsStartElement("MissionList") && reader.IsEmptyElement()) { reader.Skip(); } else { reader.ReadStartElement("MissionList"); while (reader.IsStartElement()) { string attribute = reader.GetAttribute("AssemblyQualifiedName"); if (!string.IsNullOrEmpty(attribute)) { Type type = Type.GetType(attribute); AICommanderMission aicommanderMission = (AICommanderMission)Activator.CreateInstance(type); aicommanderMission.Initialize(this); reader.ReadElementSerializable <AICommanderMission>(ref aicommanderMission); this.Missions.Add(aicommanderMission); Diagnostics.Assert(AIScheduler.Services != null); ITickableRepositoryAIHelper service = AIScheduler.Services.GetService <ITickableRepositoryAIHelper>(); Diagnostics.Assert(service != null); service.Register(aicommanderMission); } else { reader.Skip(); } } reader.ReadEndElement("MissionList"); } } catch (Exception ex) { Diagnostics.LogError("Fail to load the mission: {0}", new object[] { ex.ToString() }); reader.Skip(); } }
public override IEnumerator Initialize(AIEntity aiEntity) { yield return(base.Initialize(aiEntity)); IGameService service = Services.GetService <IGameService>(); Diagnostics.Assert(service != null); this.worldPositionningService = service.Game.Services.GetService <IWorldPositionningService>(); Diagnostics.Assert(this.worldPositionningService != null); this.departmentOfTheInterior = base.AIEntity.Empire.GetAgency <DepartmentOfTheInterior>(); this.aiDataRepositoryHelper = AIScheduler.Services.GetService <IAIDataRepositoryAIHelper>(); base.AIEntity.RegisterPass(AIEntity.Passes.RefreshObjectives.ToString(), "AILayer_SiegeBreaker_RefreshObjectives", new AIEntity.AIAction(this.RefreshObjectives), this, new StaticString[0]); ITickableRepositoryAIHelper service2 = AIScheduler.Services.GetService <ITickableRepositoryAIHelper>(); Diagnostics.Assert(service2 != null); service2.Register(this); yield break; }