// Token: 0x06000BF1 RID: 3057 RVA: 0x00054608 File Offset: 0x00052808
        public static Dictionary <string, PlayerFactionSelection> GetFactionOptions(LevelManager levelManager, DLCManager dlcManager, PlayerType playerType, bool useOwnedDLCOnly)
        {
            Dictionary <string, PlayerFactionSelection> dictionary = new Dictionary <string, PlayerFactionSelection>(6);

            if (levelManager != null)
            {
                CommanderAttributes[] commanderAttributes = levelManager.CommanderAttributes;
                if (commanderAttributes != null)
                {
                    for (int i = 0; i < commanderAttributes.Length; i++)
                    {
                        CommanderAttributes commanderAttributes2 = commanderAttributes[i];
                        string key = string.IsNullOrEmpty(commanderAttributes2.NameLocID) ? commanderAttributes2.Name : commanderAttributes2.NameLocID;
                        PlayerFactionSelection value = new PlayerFactionSelection((CustomizationFactionSetting)i, DLCPackID.kInvalidID, false);
                        dictionary.Add(key, value);
                    }
                }
            }
            if (dlcManager != null)
            {
                IEnumerable <DLCPackDescriptor> enumerable = useOwnedDLCOnly ? dlcManager.OwnedDLCPacks : dlcManager.AllDLCPacks;
                foreach (DLCPackDescriptor dlcpackDescriptor in enumerable)
                {
                    if (dlcpackDescriptor.DLCPackType == DLCType.Faction)
                    {
                        UnitFactionDLCPack unitFactionDLCPack = (UnitFactionDLCPack)dlcManager.GetDLCPackHeader(dlcpackDescriptor.DLCPackID);
                        if (!(unitFactionDLCPack == null))
                        {
                            if (playerType == PlayerType.AI)
                            {
                                CommanderAttributesData commanderAttributesData = unitFactionDLCPack.CommanderAttrs as CommanderAttributesData;
                                if (commanderAttributesData == null || commanderAttributesData.AIArchetypeAssets.IsNullOrEmpty <AIArchetypeAttributesAsset>())
                                {
                                    continue;
                                }
                            }
                            string dlcpackLocID           = dlcpackDescriptor.DLCPackLocID;
                            PlayerFactionSelection value2 = new PlayerFactionSelection(unitFactionDLCPack.CustomizesFaction, dlcpackDescriptor.DLCPackID, false);
                            dictionary.Add(dlcpackLocID, value2);
                        }
                    }
                }
            }
            PlayerFactionSelection value3 = new PlayerFactionSelection(CustomizationFactionSetting.Coalition, DLCPackID.kInvalidID, true);

            // MOD
            if (playerType == PlayerType.AI)
            {
                dictionary.Remove("SPECTATOR");
                dictionary.Remove("FATHERSHIP");
                dictionary.Remove("NONE");
            }
            // MOD
            dictionary.Add("ID_UI_FE_MP_RANDOM_253", value3);
            return(dictionary);
        }
예제 #2
0
 // Token: 0x06000134 RID: 308 RVA: 0x00006C18 File Offset: 0x00004E18
 public static void PopulateAIArchetypesForCommanderAttributes(string assetName, AIArchetypeAttributesAsset[] aiArchetypeAssets, CommanderAttributes commanderAttributes)
 {
     if (!aiArchetypeAssets.IsNullOrEmpty <AIArchetypeAttributesAsset>())
     {
         AIArchetypeAttributes[] arrayOriginal = new AIArchetypeAttributes[aiArchetypeAssets.Length];
         for (int i = 0; i < aiArchetypeAssets.Length; i++)
         {
             AIArchetypeAttributesAsset aiarchetypeAttributesAsset = aiArchetypeAssets[i];
             if (aiarchetypeAttributesAsset == null)
             {
                 Debug.LogWarning(string.Format("{0}: warning: commander {1} is missing AI archetype asset {2}", assetName, commanderAttributes.Name, i));
             }
             else
             {
                 arrayOriginal[i] = (aiarchetypeAttributesAsset.Data as AIArchetypeAttributesData);
             }
         }
         commanderAttributes.AIArchetypes = arrayOriginal;
     }
 }
예제 #3
0
        // Token: 0x06000B87 RID: 2951 RVA: 0x0004090C File Offset: 0x0003EB0C
        private void LoadReplay()
        {
            LevelDefinition levelDefinition = this.mLevelManager.FindLevelFromSceneName(this.mSelectedReplay.SceneName, this.mSelectedReplay.GameSessionSettings.GameMode);

            if (levelDefinition != null)
            {
                // MOD: tell the mod what map is being loaded
                try {
                    byte[] replayX      = System.IO.File.ReadAllBytes(mSelectedReplay.FilePath + "x");
                    int    layoutLength = (replayX[0] << 0) + (replayX[1] << 8) + (replayX[2] << 16) + (replayX[3] << 24);
                    int    patchLength  = (replayX[4] << 0) + (replayX[5] << 8) + (replayX[6] << 16) + (replayX[7] << 24);
                    int    reserved0    = (replayX[8] << 0) + (replayX[9] << 8) + (replayX[10] << 16) + (replayX[11] << 24);
                    int    reserved1    = (replayX[12] << 0) + (replayX[13] << 8) + (replayX[14] << 16) + (replayX[15] << 24);
                    MapModManager.MapXml = Encoding.UTF8.GetString(replayX, 16, layoutLength);
                    Subsystem.AttributeLoader.PatchOverrideData = Encoding.UTF8.GetString(replayX, 16 + layoutLength, patchLength);
                } catch {}
                Dictionary <CommanderID, TeamID> teams = new Dictionary <CommanderID, TeamID>();
                foreach (var tuple in mSelectedReplay.SessionPlayers)
                {
                    teams[new CommanderID(tuple.CID)] = new TeamID(tuple.TeamID);
                }
                MapModManager.SetMap(levelDefinition, mSelectedReplay.GameSessionSettings.GameMode, mSelectedReplay.GameSessionSettings.TeamSetting, teams);
                // MOD

                Dictionary <CommanderID, PlayerSelection> dictionary = new Dictionary <CommanderID, PlayerSelection>(this.mSelectedReplay.SessionPlayers.Length);
                List <NetworkPlayerID> list = new List <NetworkPlayerID>(this.mSelectedReplay.SessionPlayers.Length);
                for (int i = 0; i < this.mSelectedReplay.SessionPlayers.Length; i++)
                {
                    ReplayHelpers.ReplayDataTuple replayDataTuple     = this.mSelectedReplay.SessionPlayers[i];
                    CommanderAttributes           commanderAttributes = null;
                    foreach (DLCAssetBundleBase dlcassetBundleBase in this.mDLCManager.GetAllLoadedHeadersOfType(DLCType.Faction))
                    {
                        UnitFactionDLCPack unitFactionDLCPack = dlcassetBundleBase as UnitFactionDLCPack;
                        if (unitFactionDLCPack != null && unitFactionDLCPack.CommanderAttrs != null && unitFactionDLCPack.CommanderAttrs.Name == replayDataTuple.CommanderAttributesName)
                        {
                            commanderAttributes = unitFactionDLCPack.CommanderAttrs;
                            break;
                        }
                    }
                    int j = 0;
                    if (commanderAttributes == null)
                    {
                        for (j = 0; j < this.mLevelManager.CommanderAttributes.Length; j++)
                        {
                            CommanderAttributes commanderAttributes2 = this.mLevelManager.CommanderAttributes[j];
                            if (commanderAttributes2.Name == replayDataTuple.CommanderAttributesName)
                            {
                                commanderAttributes = commanderAttributes2;
                                break;
                            }
                        }
                    }
                    if (commanderAttributes == null)
                    {
                        Log.Error(Log.Channel.Data, "Couldn't resolve commander attributes from saved replay.  The replay that was saved didn't have commander attributes that match the commander attributes in the level ({0})", new object[]
                        {
                            replayDataTuple.CommanderAttributesName
                        });
                    }
                    else
                    {
                        CommanderDescription commanderDescription = new CommanderDescription(replayDataTuple.PlayerName, new CommanderID(replayDataTuple.CID), replayDataTuple.PlayerID, replayDataTuple.SpawnIndex, j, new TeamID(replayDataTuple.TeamID), replayDataTuple.PlayerType, replayDataTuple.UnitColors, replayDataTuple.AIDifficulty, replayDataTuple.UnitSkinPack, replayDataTuple.RandomFaction);
                        dictionary.Add(commanderDescription.CommanderID, new PlayerSelection(commanderAttributes, commanderDescription));
                        if (replayDataTuple.PlayerID != NetworkPlayerID.kInvalidID)
                        {
                            list.Add(replayDataTuple.PlayerID);
                        }
                    }
                }
                DependencyContainer <GameStartSettings, ReplayHelpers.ReplayableGameSessionHeader, SessionBase> dependencies = new DependencyContainer <GameStartSettings, ReplayHelpers.ReplayableGameSessionHeader, SessionBase>(new GameStartSettings(dictionary, this.mSelectedReplay.GameSessionSettings.VictoryConditions, this.mSelectedReplay.GameSessionSettings.TeamSetting, this.mSelectedReplay.GameSessionSettings.GameModeSettings, this.mSelectedReplay.RandomSeed, false, false, AutomatchSizeType.ThreeVSThree), this.mSelectedReplay, new NullSession(list));
                this.mLevelManager.LoadLevelForSave(levelDefinition, this.mSelectedReplay.GameSessionSettings.GameMode, ReplayMode.ReplayingGame, dependencies);
                return;
            }
            Log.Error(Log.Channel.Data, "The level associated with {0} could not be found", new object[]
            {
                this.mSelectedReplay.SceneName
            });
        }