Example #1
0
 private void Init(STUGameMode gamemode, ulong key = default)
 {
     GUID = (teResourceGUID)key;
     Name = GetString(gamemode.m_displayName);
     GameRulesetSchemas = Helper.JSON.FixArray(gamemode.m_gameRulesetSchemas);
     VoiceSet           = gamemode.m_7F5B54B2;
     Type = gamemode.m_gameModeType;
 }
Example #2
0
        public GameMode(ulong key)
        {
            STUGameMode stu = GetInstance <STUGameMode>(key);

            if (stu == null)
            {
                return;
            }
            Init(stu, key);
        }
Example #3
0
        public List <GameMode> GetGameModes()
        {
            List <GameMode> gameModes = new List <GameMode>();

            foreach (var guid in TrackedFiles[0xC5])
            {
                STUGameMode gameMode = GetInstance <STUGameMode>(guid);
                if (gameMode == null)
                {
                    continue;
                }

                gameModes.Add(new GameMode(gameMode));
            }

            return(gameModes);
        }
Example #4
0
        public GameMode(STUGameMode gameMode)
        {
            DisplayName = GetString(gameMode.m_displayName);

            if (gameMode.m_gameRulesetSchemas != null)
            {
                GameRulesetSchemas = new teResourceGUID[gameMode.m_gameRulesetSchemas.Length];

                for (int i = 0; i < GameRulesetSchemas.Length; i++)
                {
                    GameRulesetSchemas[i] = gameMode.m_gameRulesetSchemas[i];
                }
            }

            VoiceSet = gameMode.m_7F5B54B2;
            Type     = gameMode.m_gameModeType;
        }
Example #5
0
File: Map.cs Project: ipud2/OWLib
        public static void Save(ICLIFlags flags, STUMapHeader mapHeader, ulong key, string basePath)
        {
            string name = GetString(mapHeader.m_displayName) ?? "Title Screen";
            //string name = map.m_506FA8D8;
            var variantName = GetString(mapHeader.m_1C706502);

            if (variantName != null)
            {
                name = variantName;
            }

            LoudLog($"Extracting map {name}\\{teResourceGUID.Index(key):X}");
            name = GetValidFilename(name);

            // TODO: MAP11 HAS CHANGED
            // TODO: MAP10 TOO?

            string mapPath = Path.Combine(basePath, "Maps", name, teResourceGUID.Index(key).ToString("X")) + Path.DirectorySeparatorChar;

            CreateDirectoryFromFile(mapPath);

            FindLogic.Combo.ComboInfo info = new FindLogic.Combo.ComboInfo();
            LoudLog("\tFinding");
            FindLogic.Combo.Find(info, mapHeader.m_map);

            //for (ushort i = 0; i < 255; i++) {
            //    using (Stream mapChunkStream = OpenFile(mapHeader.GetChunkKey((byte)i))) {
            //        if (mapChunkStream == null) continue;
            //        WriteFile(mapChunkStream, Path.Combine(mapPath, $"{(Enums.teMAP_PLACEABLE_TYPE)i}.0BC"));
            //    }
            //}
            //return;

            teMapPlaceableData placeableModelGroups  = GetPlaceableData(mapHeader, Enums.teMAP_PLACEABLE_TYPE.MODEL_GROUP);
            teMapPlaceableData placeableSingleModels = GetPlaceableData(mapHeader, Enums.teMAP_PLACEABLE_TYPE.SINGLE_MODEL);
            teMapPlaceableData placeableModel        = GetPlaceableData(mapHeader, Enums.teMAP_PLACEABLE_TYPE.MODEL);
            teMapPlaceableData placeableLights       = GetPlaceableData(mapHeader, Enums.teMAP_PLACEABLE_TYPE.LIGHT);
            teMapPlaceableData placeableEntities     = GetPlaceableData(mapHeader, Enums.teMAP_PLACEABLE_TYPE.ENTITY);
            teMapPlaceableData placeableSounds       = GetPlaceableData(mapHeader, Enums.teMAP_PLACEABLE_TYPE.SOUND);
            teMapPlaceableData placeableEffects      = GetPlaceableData(mapHeader, Enums.teMAP_PLACEABLE_TYPE.EFFECT);

            OverwatchMap exportMap = new OverwatchMap(name, info, placeableSingleModels, placeableModelGroups, placeableModel, placeableEntities, placeableLights, placeableSounds, placeableEffects);

            using (Stream outputStream = File.OpenWrite(Path.Combine(mapPath, $"{name}.{exportMap.Extension}"))) {
                exportMap.Write(outputStream);
            }

            {
                FindLogic.Combo.Find(info, mapHeader.m_86C1CFAB);
                FindLogic.Combo.Find(info, mapHeader.m_9386E669);
                FindLogic.Combo.Find(info, mapHeader.m_C6599DEB);

                if (mapHeader.m_D608E9F3 != null)
                {
                    foreach (teResourceGUID gamemodeGUID in mapHeader.m_D608E9F3)
                    {
                        STUGameMode gameMode = GetInstance <STUGameMode>(gamemodeGUID);
                        if (gameMode == null)
                        {
                            continue;
                        }

                        FindLogic.Combo.Find(info, gameMode.m_6EB38130);  // 004
                        FindLogic.Combo.Find(info, gameMode.m_CF63B633);  // 01B
                        FindLogic.Combo.Find(info, gameMode.m_7F5B54B2);  // game mode voice set

                        foreach (STUGameModeTeam team in gameMode.m_teams)
                        {
                            FindLogic.Combo.Find(info, team.m_bodyScript);       // 01B
                            FindLogic.Combo.Find(info, team.m_controllerScript); // 01B
                        }
                    }
                }
            }

            FindLogic.Combo.Find(info, mapHeader.m_announcerWelcome);
            info.SetEffectName(mapHeader.m_announcerWelcome, "AnnouncerWelcome");
            FindLogic.Combo.Find(info, mapHeader.m_musicTease);
            info.SetEffectName(mapHeader.m_musicTease, "MusicTease");

            ulong announcerVoiceSet = 0;

            using (Stream stream = OpenFile(mapHeader.m_map)) {
                if (stream != null)
                {
                    using (BinaryReader reader = new BinaryReader(stream)) {
                        teMap map = reader.Read <teMap>();

                        STUVoiceSetComponent voiceSetComponent =
                            GetInstance <STUVoiceSetComponent>(map.EntityDefinition);
                        announcerVoiceSet = voiceSetComponent?.m_voiceDefinition;
                        FindLogic.Combo.Find(info, announcerVoiceSet);

                        info.SetEffectVoiceSet(mapHeader.m_announcerWelcome, announcerVoiceSet);
                    }
                }
            }

            LoudLog("\tSaving");
            Combo.Save(flags, mapPath, info);
            Combo.SaveLooseTextures(flags, Path.Combine(mapPath, "Textures"), info);

            if (mapHeader.m_7F5B54B2 != 0)    // map voice set. not announcer
            {
                FindLogic.Combo.Find(info, mapHeader.m_7F5B54B2);
            }

            if (announcerVoiceSet != 0)    // whole thing in env mode, not here
            {
                info.VoiceSets.Remove(announcerVoiceSet);
            }
            Combo.SaveAllVoiceSets(flags, Path.Combine(mapPath, "VoiceSets"), info);
            Combo.SaveAllSoundFiles(flags, Path.Combine(mapPath, "Sound"), info);

            LoudLog("\tDone");
        }
Example #6
0
 public GameMode(STUGameMode stu)
 {
     Init(stu);
 }
Example #7
0
        protected string GetGamemode(ulong guid)
        {
            STUGameMode gamemode = GetInstance <STUGameMode>(guid);

            return(GetString(gamemode?.m_displayName));
        }
Example #8
0
        public static MapInfo GetMap(ulong key)
        {
            STUMapHeader map = GetInstance <STUMapHeader>(key);

            if (map == null)
            {
                return(null);
            }

            string nameA   = GetString(map.m_displayName);
            string nameB   = GetString(map.m_1C706502);
            string subline = GetString(map.m_EBCFAD22);

            string descA = GetString(map.m_389CB894);
            string descB = GetString(map.m_ACB95597);

            string stateA = GetString(map.m_5AFE2F61);
            string stateB = GetString(map.m_8EBADA44);

            List <GamemodeInfo> gamemodes = null;

            if (map.m_D608E9F3 != null)
            {
                gamemodes = new List <GamemodeInfo>();
                foreach (ulong guid in map.m_D608E9F3)
                {
                    STUGameMode gamemode = GetInstance <STUGameMode>(guid);
                    if (gamemode == null)
                    {
                        continue;
                    }

                    gamemodes.Add(new GamemodeInfo {
                        Name = GetString(gamemode.m_displayName),
                        GUID = guid
                    });
                }
            }

            // if (map.m_celebrationOverrides != null) {
            //
            //
            // }

            if (!string.IsNullOrEmpty(nameA) && !string.IsNullOrEmpty(nameB) && nameB.Equals(nameA))
            {
                nameB = null;
            }

            if (!string.IsNullOrEmpty(descA) && !string.IsNullOrEmpty(descB) && descB.Equals(descA))
            {
                descB = null;
            }

            string uniqueName;

            if (nameA == null)
            {
                uniqueName = $"Title Screen:{teResourceGUID.Index(key):X}";
            }
            else
            {
                uniqueName = nameA + $":{teResourceGUID.Index(key):X}";
            }
            return(new MapInfo(uniqueName, key, nameA, nameB, descA, descB, subline, stateA, stateB,
                               map.m_map, map.m_baseMap, gamemodes));
        }