Esempio n. 1
0
        public QuakeMap(Stream stream, DefinitionDictionary definitions) : base(stream, definitions)
        {
            var sb = new StringBuilder();

            using (var sr = new StreamReader(stream))
            {
                while (!sr.EndOfStream)
                {
                    string line = sr.ReadLine();

                    int commentStart = line.IndexOf("//", StringComparison.OrdinalIgnoreCase);
                    switch (commentStart)
                    {
                    case -1:
                        sb.Append(line);
                        break;

                    case 0:
                        continue;

                    default:
                        sb.Append(line.Remove(commentStart));
                        break;
                    }
                }
            }

            Raw = sb.ToString();
        }
            public void Clear()
            {
                m_cubeSizes       = new float[typeof(MyCubeSize).GetEnumValues().Length];
                m_basePrefabNames = new string[m_cubeSizes.Length * 4]; // Index computed 4 * enumInt + 2*static + creative.

                m_definitionsById = new DefinitionDictionary <MyDefinitionBase>(100);

                m_voxelMaterialsByName   = new Dictionary <string, MyVoxelMaterialDefinition>(10);
                m_voxelMaterialsByIndex  = new Dictionary <byte, MyVoxelMaterialDefinition>(10);
                m_voxelMaterialRareCount = 0;

                m_physicalItemDefinitions = new List <MyPhysicalItemDefinition>(10);

                m_weaponDefinitionsById = new DefinitionDictionary <MyWeaponDefinition>(10);
                m_ammoDefinitionsById   = new DefinitionDictionary <MyAmmoDefinition>(10);

                m_blockPositions         = new Dictionary <string, Vector2I>(10);
                m_uniqueCubeBlocksBySize = new DefinitionDictionary <MyCubeBlockDefinition> [m_cubeSizes.Length];
                for (int i = 0; i < m_cubeSizes.Length; ++i)
                {
                    m_uniqueCubeBlocksBySize[i] = new DefinitionDictionary <MyCubeBlockDefinition>(10);
                }

                m_blueprintsById = new DefinitionDictionary <MyBlueprintDefinitionBase>(10);

                m_spawnGroupDefinitions = new List <MySpawnGroupDefinition>(10);

                m_containerTypeDefinitions = new DefinitionDictionary <MyContainerTypeDefinition>(10);

                m_handItemsById             = new DefinitionDictionary <MyHandItemDefinition>(10);
                m_physicalItemsByHandItemId = new DefinitionDictionary <MyPhysicalItemDefinition>(m_handItemsById.Count);
                m_handItemsByPhysicalItemId = new DefinitionDictionary <MyHandItemDefinition>(m_handItemsById.Count);

                m_scenarioDefinitions      = new List <MyScenarioDefinition>(10);
                m_characters               = new Dictionary <string, MyCharacterDefinition>();
                m_animationsBySkeletonType = new Dictionary <string, Dictionary <string, MyAnimationDefinition> >();

                m_blueprintClasses      = new DefinitionDictionary <MyBlueprintClassDefinition>(10);
                m_blueprintClassEntries = new HashSet <BlueprintClassEntry>();
                m_blueprintsByResultId  = new DefinitionDictionary <MyBlueprintDefinitionBase>(10);

                m_environmentItemsEntries = new HashSet <EnvironmentItemsEntry>();

                m_categoryClasses = new List <MyGuiBlockCategoryDefinition>(25);
                m_categories      = new Dictionary <string, MyGuiBlockCategoryDefinition>(25);

                m_prefabs      = new Dictionary <string, MyPrefabDefinition>();
                m_respawnShips = new Dictionary <string, MyRespawnShipDefinition>();

                m_sounds              = new DefinitionDictionary <MyAudioDefinition>(10);
                m_environmentDef      = new MyEnvironmentDefinition();
                m_behaviorDefinitions = new DefinitionDictionary <MyBehaviorDefinition>(10);
                m_voxelMapStorages    = new Dictionary <string, MyVoxelMapStorageDefinition>(64);
                m_characterNames      = new List <MyCharacterName>(32);

                m_battleDefinition = new MyBattleDefinition();
            }
Esempio n. 3
0
 public void Merge(DefinitionDictionary <V> other)
 {
     foreach (var definition in other)
     {
         if (definition.Value.Enabled)
         {
             this[definition.Key] = definition.Value;
         }
         else
         {
             Remove(definition.Key);
         }
     }
 }
Esempio n. 4
0
            public void SetUp()
            {
                var fgdStream = new MemoryStream();
                var fgdWriter = new StreamWriter(fgdStream);

                foreach (var line in RawFgd)
                {
                    fgdWriter.WriteLine(line);
                }
                fgdWriter.Flush();
                fgdStream.Position = 0;

                Fgd = new QuakeFgd(fgdStream);
            }
Esempio n. 5
0
        public QuakeBlock(List <string> rawList, int openBraceIndex, DefinitionDictionary definitions)
        {
            Definitions.Clear();
            foreach (KeyValuePair <string, Definition> pair in definitions)
            {
                Definitions.Add(pair.Key, pair.Value);
            }

            RawStartIndex = openBraceIndex;
            RawLength     = (FindCloseBraceIndex(rawList, openBraceIndex) + 1) - RawStartIndex;

            Solids = new List <Solid>();

            List <string> rawBlock = rawList.GetRange(RawStartIndex, RawLength);

            Parse(rawBlock);
        }
Esempio n. 6
0
            public void Clear(bool unload = false)
            {
                base.Clear();

                m_cubeSizes         = new float[typeof(MyCubeSize).GetEnumValues().Length];
                m_cubeSizesOriginal = new float[typeof(MyCubeSize).GetEnumValues().Length];
                m_basePrefabNames   = new string[m_cubeSizes.Length * 4]; // Index computed 4 * enumInt + 2*static + creative.

                m_definitionsById = new DefinitionDictionary <MyDefinitionBase>(100);

                m_voxelMaterialsByName   = new Dictionary <string, MyVoxelMaterialDefinition>(10);
                m_voxelMaterialsByIndex  = new Dictionary <byte, MyVoxelMaterialDefinition>(10);
                m_voxelMaterialRareCount = 0;

                m_physicalItemDefinitions = new List <MyPhysicalItemDefinition>(10);

                m_weaponDefinitionsById = new DefinitionDictionary <MyWeaponDefinition>(10);
                m_ammoDefinitionsById   = new DefinitionDictionary <MyAmmoDefinition>(10);

                m_blockPositions         = new Dictionary <string, Vector2I>(10);
                m_uniqueCubeBlocksBySize = new DefinitionDictionary <MyCubeBlockDefinition> [m_cubeSizes.Length];
                for (int i = 0; i < m_cubeSizes.Length; ++i)
                {
                    m_uniqueCubeBlocksBySize[i] = new DefinitionDictionary <MyCubeBlockDefinition>(10);
                }

                m_blueprintsById = new DefinitionDictionary <MyBlueprintDefinitionBase>(10);

                m_spawnGroupDefinitions = new List <MySpawnGroupDefinition>(10);

                m_containerTypeDefinitions = new DefinitionDictionary <MyContainerTypeDefinition>(10);

                m_handItemsById             = new DefinitionDictionary <MyHandItemDefinition>(10);
                m_physicalItemsByHandItemId = new DefinitionDictionary <MyPhysicalItemDefinition>(m_handItemsById.Count);
                m_handItemsByPhysicalItemId = new DefinitionDictionary <MyHandItemDefinition>(m_handItemsById.Count);

                m_scenarioDefinitions      = new List <MyScenarioDefinition>(10);
                m_characters               = new Dictionary <string, MyCharacterDefinition>();
                m_animationsBySkeletonType = new Dictionary <string, Dictionary <string, MyAnimationDefinition> >();

                m_blueprintClasses      = new DefinitionDictionary <MyBlueprintClassDefinition>(10);
                m_blueprintClassEntries = new HashSet <BlueprintClassEntry>();
                m_blueprintsByResultId  = new DefinitionDictionary <MyBlueprintDefinitionBase>(10);

                m_environmentItemsEntries = new HashSet <EnvironmentItemsEntry>();
                m_componentBlockEntries   = new HashSet <MyComponentBlockEntry>();

                m_componentBlocks    = new HashSet <MyDefinitionId>(MyDefinitionId.Comparer);
                m_componentIdToBlock = new Dictionary <MyDefinitionId, MyCubeBlockDefinition>(MyDefinitionId.Comparer);

                m_categoryClasses = new List <MyGuiBlockCategoryDefinition>(25);
                m_categories      = new Dictionary <string, MyGuiBlockCategoryDefinition>(25);

                m_prefabs      = new Dictionary <string, MyPrefabDefinition>();
                m_respawnShips = new Dictionary <string, MyRespawnShipDefinition>();

                m_sounds = new DefinitionDictionary <MyAudioDefinition>(10);

                m_shipSounds       = new DefinitionDictionary <MyShipSoundsDefinition>(10);                m_behaviorDefinitions = new DefinitionDictionary <MyBehaviorDefinition>(10);
                m_voxelMapStorages = new Dictionary <string, MyVoxelMapStorageDefinition>(64);
                m_characterNames   = new List <MyCharacterName>(32);

                m_battleDefinition = new MyBattleDefinition();

                m_planetGeneratorDefinitions = new DefinitionDictionary <MyPlanetGeneratorDefinition>(5);

                m_componentGroups       = new DefinitionDictionary <MyComponentGroupDefinition>(4);
                m_componentGroupMembers = new Dictionary <MyDefinitionId, MyTuple <int, MyComponentGroupDefinition> >();

                m_planetPrefabDefinitions = new DefinitionDictionary <MyPlanetPrefabDefinition>(5);

                m_groupedIds = new Dictionary <string, Dictionary <string, MyGroupedIds> >();

                m_scriptedGroupDefinitions = new DefinitionDictionary <MyScriptedGroupDefinition>(10);
                m_pirateAntennaDefinitions = new DefinitionDictionary <MyPirateAntennaDefinition>(4);

                m_componentSubstitutions = new Dictionary <MyDefinitionId, MyComponentSubstitutionDefinition>();

                m_destructionDefinition = new MyDestructionDefinition();

                m_mapMultiBlockDefToCubeBlockDef = new Dictionary <string, MyCubeBlockDefinition>();
                m_factionDefinitionsByTag.Clear();

                m_idToRope = new Dictionary <MyDefinitionId, MyRopeDefinition>(MyDefinitionId.Comparer);

                m_gridCreateDefinitions = new DefinitionDictionary <MyGridCreateToolDefinition>(3);

                m_entityComponentDefinitions = new DefinitionDictionary <MyComponentDefinitionBase>(10);
                m_entityContainers           = new DefinitionDictionary <MyContainerDefinition>(10);
                if (unload)
                {
                    m_physicalMaterialsByName = new Dictionary <string, MyPhysicalMaterialDefinition>();
                }

                m_lootBagDefinition = null;
            }