Пример #1
0
        public static void AddBattleMaps(List <Tuple <string, MyWorldInfo> > availableMaps, List <MyBattleMapInfo> outBattleMaps, string officialBattlesPath, string workshopBattlesPath)
        {
            for (int i = 0; i < availableMaps.Count; ++i)
            {
                var   save = availableMaps[i];
                ulong dummySizeInBytes;
                var   checkpoint = MyLocalCache.LoadCheckpoint(save.Item1, out dummySizeInBytes);
                if (checkpoint == null)
                {
                    continue;
                }

                foreach (var component in checkpoint.SessionComponents)
                {
                    var battleComponent = component as MyObjectBuilder_BattleSystemComponent;
                    if (battleComponent != null && battleComponent.IsCastleSiegeMap)
                    {
                        MyBattleMapInfo battleMapInfo = new MyBattleMapInfo();
                        battleMapInfo.WorldInfo    = save.Item2;
                        battleMapInfo.SessionPath  = save.Item1;
                        battleMapInfo.BattlePoints = battleComponent.Points;
                        battleMapInfo.MapType      = MyBattleMapType.SAVE;

                        if (battleMapInfo.SessionPath.StartsWith(officialBattlesPath))
                        {
                            battleMapInfo.MapType = MyBattleMapType.OFFICIAL;
                        }
                        else if (workshopBattlesPath != null && battleMapInfo.SessionPath.StartsWith(workshopBattlesPath))
                        {
                            battleMapInfo.MapType = MyBattleMapType.SUBSCRIBED;
                        }

                        outBattleMaps.Add(battleMapInfo);
                        break;
                    }
                }
            }
        }
        public static void AddBattleMaps(List<Tuple<string, MyWorldInfo>> availableMaps, List<MyBattleMapInfo> outBattleMaps, string officialBattlesPath, string workshopBattlesPath)
        {
            for (int i = 0; i < availableMaps.Count; ++i)
            {
                var save = availableMaps[i];
                ulong dummySizeInBytes;
                var checkpoint = MyLocalCache.LoadCheckpoint(save.Item1, out dummySizeInBytes);
                if (checkpoint == null)
                    continue;

                foreach (var component in checkpoint.SessionComponents)
                {
                    var battleComponent = component as MyObjectBuilder_BattleSystemComponent;
                    if (battleComponent != null && battleComponent.IsCastleSiegeMap)
                    {
                        MyBattleMapInfo battleMapInfo = new MyBattleMapInfo();
                        battleMapInfo.WorldInfo = save.Item2;
                        battleMapInfo.SessionPath = save.Item1;
                        battleMapInfo.BattlePoints = battleComponent.Points;
                        battleMapInfo.MapType = MyBattleMapType.SAVE;

                        if (battleMapInfo.SessionPath.StartsWith(officialBattlesPath))
                            battleMapInfo.MapType = MyBattleMapType.OFFICIAL;
                        else if (workshopBattlesPath != null && battleMapInfo.SessionPath.StartsWith(workshopBattlesPath))
                            battleMapInfo.MapType = MyBattleMapType.SUBSCRIBED;

                        outBattleMaps.Add(battleMapInfo);
                        break;
                    }
                }
            }
        }