Esempio n. 1
0
    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();
        }
    }
Esempio n. 2
0
 protected virtual AICommanderMission GenerateMission(AICommanderMissionDefinition missionDefinition, params object[] parameters)
 {
     if (!string.IsNullOrEmpty(missionDefinition.Type.ToString()))
     {
         Type type = Type.GetType(missionDefinition.Type.ToString());
         AICommanderMission aicommanderMission = (AICommanderMission)Activator.CreateInstance(type);
         aicommanderMission.Initialize(this);
         aicommanderMission.SetParameters(missionDefinition, parameters);
         aicommanderMission.Load();
         return(aicommanderMission);
     }
     return(null);
 }