/// <summary> /// Adds the housing territory default fences as exterior fixtures with an id. /// The game does not actually recognize these as fixtures, they are part of the map. /// However, currently there is no way to know which transforms within the map sgbs belongs to /// which house size. So we have to work around it. Thanks SE! /// </summary> /// <param name="realm"></param> /// <param name="fixtures"></param> private static void AddDefaultFences(ARealmReversed realm, ref Dictionary <int, HousingExteriorFixture> fixtures) { List <TerritoryType> teris = GetHousingTerritoryTypes(realm); //Obtain all housing TerritoryTypes IXivSheet <PlaceName> placeNames = realm.GameData.GetSheet <PlaceName>(); PlaceName[] pNames = placeNames.ToArray(); string[] fncPaths = { "bg/ffxiv/{0}/hou/dyna/c_fnc/0000/asset/{1}_f_fnc0000a.sgb", "bg/ffxiv/{0}/hou/dyna/c_fnc/0000/asset/{1}_f_fnc0000b.sgb", "bg/ffxiv/{0}/hou/dyna/c_fnc/0000/asset/{1}_f_fnc0000c.sgb", "bg/ffxiv/{0}/hou/dyna/c_fnc/0000/asset/{1}_f_fnc0000d.sgb", }; foreach (TerritoryType t in teris) { //Get usable strings string bgFolder = t.Bg.ToString().Split('/')[1]; string namePrefix = t.Name.ToString(); namePrefix = namePrefix.Substring(0, namePrefix.Length - 1) + '0'; //bgFolder is now 'sea_s1', 'est_e1', etc //namePrefix is now 's1h0', 'e1h0', etc int intUse = pNames.Where(_ => _.Name == t.RegionPlaceName.Name) .Select(_ => _.Key) .Min(_ => _); HousingExteriorFixture thisFence = new HousingExteriorFixture(); thisFence.itemId = 0; thisFence.fixtureId = int.Parse("102" + intUse); thisFence.fixtureModelKey = 0; //Not in the sheet, no key ¯\_(ツ)_/¯ thisFence.fixtureType = FixtureType.fnc; thisFence.fixtureIntendedUse = intUse; thisFence.size = Size.x; thisFence.name = $"Default {t.PlaceName.NameWithoutArticle} Fence"; List <string> sgbPaths = new List <string>(); foreach (string fnc in fncPaths) { sgbPaths.Add(string.Format(fnc, bgFolder, namePrefix)); } //I forgot this method existed. Thanks! thisFence.variants = ReadSgbForVariantInfo(realm, sgbPaths.ToArray()); fixtures.Add(thisFence.fixtureId, thisFence); } }
public static List <TerritoryType> GetHousingTerritoryTypes(ARealmReversed realm) { //Obtain all housing TerritoryTypes IXivSheet <TerritoryType> allTerr = realm.GameData.GetSheet <TerritoryType>(); TerritoryType[] tTypes = allTerr.ToArray(); List <TerritoryType> housingTeriTypes = new List <TerritoryType>(); foreach (TerritoryType t in tTypes) { if (!String.IsNullOrEmpty(t.PlaceName.ToString())) { byte intendedUse = (byte)t.GetRaw("TerritoryIntendedUse"); //Housing territory intended use is 13 if (intendedUse == 13) { housingTeriTypes.Add(t); } } } return(housingTeriTypes); }