Example #1
0
        static void Main(string[] args)
        {
            var lumina = new global::Lumina.Lumina(GameDirectory);

            LgbFile lgb = lumina.GetFile <LgbFile>(lgbPath);

            var text = JsonConvert.SerializeObject(lgb.Layers, Formatting.Indented);

            // Console.WriteLine(text);
            File.WriteAllText(@"C:\Users\Liam\Desktop\test.txt", text);
        }
Example #2
0
        private bool ContainsCurrents(TerritoryType t)
        {
            const string pathFormat = "bg/{0}/planevent.lgb";

            string initPath = t.Bg;

            initPath = initPath.Substring(0, initPath.LastIndexOf('/'));

            string path = string.Format(pathFormat, initPath);

            if (!realm.GameData.PackCollection.TryGetFile(path, out var file))
            {
                return(false);
            }

            LgbFile planEvent = new LgbFile(file);

            List <Point> theseCurrents = new List <Point>();

            foreach (LgbGroup group in planEvent.Groups)
            {
                foreach (LgbEventObjectEntry entry in group.Entries.Where(_ => _?.Type == LgbEntryType.EventObject))
                {
                    if (currentIds.Contains(entry.Header.EventObjectId))
                    {
                        theseCurrents.Add(new Point((int)entry.Header.Translation.X, (int)entry.Header.Translation.Z));
                    }
                }
            }

            if (theseCurrents.Count > 0)
            {
                currentsMap.Add(t, theseCurrents);
                return(true);
            }
            return(false);
        }
Example #3
0
        /// <summary>
        /// Occurs second in the ward data output flow and reads all housing territories for their appropriate
        /// plot placeholders and calculates plot locations from them.<br />
        ///
        /// This <i>would</i> be read from HousingMapMarkerInfo but the height values are incorrect there,
        /// and would mess up camera movement. X coordinates are negated due to the map reflection in Unity.<br />
        ///
        /// This method takes a very long time due to Territory instantiation.
        /// </summary>
        private static void ReadTerritoryPlots(ARealmReversed realm, ref List <Plot> plots)
        {
            List <TerritoryType> housingTeriTypes = GetHousingTerritoryTypes(realm);

            WardSetting[] settings = JsonConvert.DeserializeObject <WardSetting[]>(File.ReadAllText(FFXIVHSPaths.GetWardSettingsJson()));

            foreach (TerritoryType tType in housingTeriTypes)
            {
                SaintCoinach.Graphics.Territory t = new SaintCoinach.Graphics.Territory(tType);
                LgbFile bg = null;

                //Get the ward's information from the wardsettings.json
                string groupName = "", plotName = "", subdivisionName = "";

                foreach (WardSetting ws in settings)
                {
                    if (ws.Territory.ToString() == t.Name.ToUpper())
                    {
                        plotName        = ws.plotName;
                        groupName       = ws.group;
                        subdivisionName = ws.subdivisionSuffix + groupName;
                    }
                }

                //We only care about bg.lgb for this territory
                foreach (LgbFile lgbFile in t.LgbFiles)
                {
                    if (lgbFile.File.Path.EndsWith("bg.lgb"))
                    {
                        bg = lgbFile;
                    }
                }

                if (bg != null)
                {
                    //Define main and subdiv groups
                    var mainGroup = bg.Groups
                                    .Where(_ => _.Name == groupName)
                                    .Select(_ => _);

                    var subDivGroup = bg.Groups
                                      .Where(_ => _.Name == subdivisionName)
                                      .Select(_ => _);

                    //Get main and subdiv plot lists and sort by index
                    var mainPlotList = plots.Where(_ => _.ward.ToString() == t.Name.ToUpper())
                                       .Where(_ => _.subdiv == false)
                                       .Select(_ => _).ToList();

                    var subdivPlotList = plots.Where(_ => _.ward.ToString() == t.Name.ToUpper())
                                         .Where(_ => _.subdiv == true)
                                         .Select(_ => _).ToList();

                    mainPlotList.Sort((p1, p2) => p1.index.CompareTo(p2.index));
                    subdivPlotList.Sort((p1, p2) => p1.index.CompareTo(p2.index));

                    int plotIndex = 0;
                    foreach (var lgbGroup in mainGroup.ToArray())
                    {
                        foreach (var lgbGimmickEntry in lgbGroup.Entries.OfType <LgbGimmickEntry>())
                        {
                            foreach (var sgbGroup in lgbGimmickEntry.Gimmick.Data.OfType <SgbGroup>())
                            {
                                foreach (var modelEntry in sgbGroup.Entries.OfType <SgbModelEntry>())
                                {
                                    if (modelEntry.Model.Model.File.Path.Contains(plotName))
                                    {
                                        //Position is in gimmick header, not transformedmodel
                                        SaintCoinach.Graphics.Vector3 position = lgbGimmickEntry.Header.Translation;
                                        SaintCoinach.Graphics.Vector3 rotation = lgbGimmickEntry.Header.Rotation;
                                        Vector3    pos = new Vector3(position.X * -1, position.Y, position.Z);
                                        Quaternion rot = new Vector3(rotation.X, rotation.Y, rotation.Z).ToQuaternion();

                                        mainPlotList[plotIndex].position = pos;
                                        mainPlotList[plotIndex].rotation = rot;
                                        plotIndex++;
                                    }
                                }
                            }
                        }
                    }

                    plotIndex = 0;
                    foreach (var lgbGroup in subDivGroup.ToArray())
                    {
                        foreach (var lgbGimmickEntry in lgbGroup.Entries.OfType <LgbGimmickEntry>())
                        {
                            foreach (var sgbGroup in lgbGimmickEntry.Gimmick.Data.OfType <SgbGroup>())
                            {
                                foreach (var modelEntry in sgbGroup.Entries.OfType <SgbModelEntry>())
                                {
                                    if (modelEntry.Model.Model.File.Path.Contains(plotName))
                                    {
                                        //Position is in gimmick header, not transformedmodel
                                        SaintCoinach.Graphics.Vector3 position = lgbGimmickEntry.Header.Translation;
                                        SaintCoinach.Graphics.Vector3 rotation = lgbGimmickEntry.Header.Rotation;
                                        Vector3    pos = new Vector3(position.X * -1, position.Y, position.Z);
                                        Quaternion rot = new Vector3(rotation.X, rotation.Y, rotation.Z).ToQuaternion();

                                        subdivPlotList[plotIndex].position = pos;
                                        subdivPlotList[plotIndex].rotation = rot;
                                        plotIndex++;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }