Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions JortPob/BigTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,18 @@ namespace JortPob
{
/* BigTile is a 2x2 grid of Tiles. Sort of like an LOD type thing. */
[DebuggerDisplay("Big m{map}_{coordinate.x}_{coordinate.y}_{block} :: [{cells.Count}] Cells")]
public class BigTile : BaseTile
public class BigTile(int m, int x, int y, int b) : BaseTile(m, x, y, b)
{
public HugeTile huge;
public List<Tile> tiles;

public BigTile(int m, int x, int y, int b) : base(m, x, y, b)
{
tiles = new();
}
public List<Tile> tiles = [];

/* Checks ABSOLUTE POSITION! This is the position of an object from the ESM accounting for the layout offset! */
public bool PositionInside(Vector3 position)
{
Vector3 pos = position + Const.LAYOUT_COORDINATE_OFFSET;

float x1 = (coordinate.x * 2f * Const.TILE_SIZE) - (Const.TILE_SIZE * 0.5f);
float y1 = (coordinate.y * 2f * Const.TILE_SIZE) - (Const.TILE_SIZE * 0.5f);
float x1 = (Coordinates.x * 2f * Const.TILE_SIZE) - (Const.TILE_SIZE * 0.5f);
float y1 = (Coordinates.y * 2f * Const.TILE_SIZE) - (Const.TILE_SIZE * 0.5f);
float x2 = x1 + (Const.TILE_SIZE * 2f);
float y2 = y1 + (Const.TILE_SIZE * 2f);

Expand All @@ -37,7 +32,7 @@ public bool PositionInside(Vector3 position)

public override void AddCell(ScriptManager scriptManager, Cell cell)
{
cells.Add(cell);
Cells.Add(cell);
Tile tile = GetTile(cell.center);
if (tile == null) { Lort.Log($" ## WARNING ## Cell fell outside of reality [{cell.coordinate.x}, {cell.coordinate.y}] -- {cell.name} :: B00", Lort.Type.Debug); return; }
tile.AddCell(scriptManager, cell);
Expand All @@ -51,12 +46,12 @@ public override void AddContent(Cache cache, Cell cell, Content content, bool fo
case AssetContent a:
ModelInfo modelInfo = cache.GetModel(a.mesh);
if (modelInfo.size * (content.scale*0.01f) > Const.CONTENT_SIZE_BIG) {
float x = (coordinate.x * 2f * Const.TILE_SIZE) + (Const.TILE_SIZE * 0.5f);
float y = (coordinate.y * 2f * Const.TILE_SIZE) + (Const.TILE_SIZE * 0.5f);
float x = (Coordinates.x * 2f * Const.TILE_SIZE) + (Const.TILE_SIZE * 0.5f);
float y = (Coordinates.y * 2f * Const.TILE_SIZE) + (Const.TILE_SIZE * 0.5f);
content.relative = (content.position + Const.LAYOUT_COORDINATE_OFFSET) - new Vector3(x, 0, y);
Tile t = GetTile(cell.center);
if (t == null) { break; } // Content fell outside of the bounds of any valid msbs. BAD!
content.load = t.coordinate;
content.load = t.Coordinates;
base.AddContent(cache, cell, content);
t.AddNav(cache, cell, content);
break;
Expand Down
38 changes: 38 additions & 0 deletions JortPob/Common/MakePart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,27 @@ public static MSBE.Region.EnvironmentMapPoint EnvPoint()
return envPoint;
}

/* Create generic MapPoint */
public static MSBE.Region.MapPoint MapPoint()
{
MSBE.Region.MapPoint mapPoint = new()
{
Rotation = Vector3.Zero,
MapStudioLayer = 4294967295,
MapID = -1,
UnkE08 = 255,
UnkS04 = 0,
UnkS0C = -1,
UnkT04 = -1,
UnkT08 = -1,
UnkT0C = -1,
UnkT10 = -1,
UnkT14 = -1,
UnkT18 = -1
};
return mapPoint;
}

public static MSBE.Event.Treasure Treasure()
{
MSBE.Event.Treasure treasure = new();
Expand Down Expand Up @@ -733,6 +754,23 @@ public static MSBE.Part.Enemy Bed()
return enemy;
}

/* Creates a patrol route */
public static MSBE.Region.PatrolRoute PatrolRoute()
{
MSBE.Region.PatrolRoute patrolRoute = new()
{
Rotation = Vector3.Zero,
MapStudioLayer = 4294967295,
MapID = -1,
UnkE08 = 255,
UnkS04 = 0,
UnkS0C = -1,
UnkT00 = -1,
Unk40 = 0,
};
return patrolRoute;
}

/* Deprecated, not used */
public static MSBE.Event.PatrolInfo PatrolRandom(List<Layout.PathGridPoint> points)
{
Expand Down
16 changes: 8 additions & 8 deletions JortPob/EnvManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void CreateEnvMaps(HugeTile tile, int envId)
string region = tile.GetRegion();
WeatherData weatherData = GetWeatherData(region);

string mid = $"{tile.map:D2}_{tile.coordinate.x:D2}_{tile.coordinate.y:D2}_{tile.block:D2}"; // msb full name
string mid = $"{tile.Map:D2}_{tile.Coordinates.x:D2}_{tile.Coordinates.y:D2}_{tile.Block:D2}"; // msb full name

Dictionary<string, int> levels = new();
levels.Add("high", 64);
Expand All @@ -69,7 +69,7 @@ public static void CreateEnvMaps(HugeTile tile, int envId)
bnd.Compression = Compression.KRAK();
bnd.Version = "07D7R6";

List<Tuple<string, byte[]>> textures = GenerateIrradianceTextures(tile.map, tile.coordinate.x, tile.coordinate.y, tile.block, envId, timeId, size, weatherData.rem);
List<Tuple<string, byte[]>> textures = GenerateIrradianceTextures(tile.Map, tile.Coordinates.x, tile.Coordinates.y, tile.Block, envId, timeId, size, weatherData.rem);

int bndId = 0;
foreach (Tuple<string, byte[]> texture in textures)
Expand Down Expand Up @@ -98,7 +98,7 @@ public static void CreateEnvMaps(HugeTile tile, int envId)
bnd.Files.Add(file);
}

bnd.Write(Path.Combine(Const.OUTPUT_PATH, $@"map\m{tile.map:D2}\m{mid}\m{mid}_envmap_{timeId:D2}_{level}_00.tpfbnd.dcx"));
bnd.Write(Path.Combine(Const.OUTPUT_PATH, $@"map\m{tile.Map:D2}\m{mid}\m{mid}_envmap_{timeId:D2}_{level}_00.tpfbnd.dcx"));
}
}

Expand All @@ -121,15 +121,15 @@ public static void CreateEnvMaps(HugeTile tile, int envId)
ivBnd.Files.Add(ivFile);
}

ivBnd.Write(Path.Combine(Const.OUTPUT_PATH, $@"map\m{tile.map:D2}\m{mid}\\m{mid}_{level}.ivinfobnd.dcx"));
ivBnd.Write(Path.Combine(Const.OUTPUT_PATH, $@"map\m{tile.Map:D2}\m{mid}\\m{mid}_{level}.ivinfobnd.dcx"));
}
}

public static void CreateEnvMaps(InteriorGroup group, int envId)
{
WeatherData weatherData = group.GetWeather();

string mid = $"{group.map:D2}_{group.area:D2}_{group.unk:D2}_{group.block:D2}"; // msb full name
string mid = $"{group.Map:D2}_{group.Area:D2}_{group.Unk:D2}_{group.Block:D2}"; // msb full name

Dictionary<string, int> levels = new();
levels.Add("high", 64);
Expand All @@ -145,7 +145,7 @@ public static void CreateEnvMaps(InteriorGroup group, int envId)
bnd.Compression = Compression.KRAK();
bnd.Version = "07D7R6";

List<Tuple<string, byte[]>> textures = GenerateIrradianceTextures(group.map, group.area, group.unk, group.block, envId, 0, size, weatherData.rem);
List<Tuple<string, byte[]>> textures = GenerateIrradianceTextures(group.Map, group.Area, group.Unk, group.Block, envId, 0, size, weatherData.rem);

int bndId = 0;
foreach (Tuple<string, byte[]> texture in textures)
Expand Down Expand Up @@ -174,7 +174,7 @@ public static void CreateEnvMaps(InteriorGroup group, int envId)
bnd.Files.Add(file);
}

bnd.Write(Path.Combine(Const.OUTPUT_PATH, $@"map\m{group.map:D2}\m{mid}\m{mid}_envmap_{0:D2}_{level}_00.tpfbnd.dcx"));
bnd.Write(Path.Combine(Const.OUTPUT_PATH, $@"map\m{group.Map:D2}\m{mid}\m{mid}_envmap_{0:D2}_{level}_00.tpfbnd.dcx"));
}


Expand All @@ -194,7 +194,7 @@ public static void CreateEnvMaps(InteriorGroup group, int envId)
ivFile.Name = $"N:\\GR\\data\\INTERROOT_win64\\map\\m{mid}\\tex\\Envmap\\{level}\\IvInfo\\m{mid}_GIIV{envId}_{0:D2}.ivInfo";
ivBnd.Files.Add(ivFile);

ivBnd.Write(Path.Combine(Const.OUTPUT_PATH, $@"map\m{group.map:D2}\m{mid}\m{mid}_{level}.ivinfobnd.dcx"));
ivBnd.Write(Path.Combine(Const.OUTPUT_PATH, $@"map\m{group.Map:D2}\m{mid}\m{mid}_{level}.ivinfobnd.dcx"));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions JortPob/FxrManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ public static void Write(Layout layout)
];
foreach(InteriorGroup group in layout.Interiors)
{
if (group.IsEmpty()) { continue; }
if (maps.Contains(group.map)) { continue; }
maps.Add(group.map);
if (group.IsEmpty) { continue; }
if (maps.Contains(group.Map)) { continue; }
maps.Add(group.Map);
}

Lort.Log($"Writing {maps.Count} FFX Binder files... ", Lort.Type.Main);
Expand Down
37 changes: 15 additions & 22 deletions JortPob/HugeTile.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using IronPython.Compiler.Ast;
using JortPob.Common;
using JortPob.Common;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
Expand All @@ -10,24 +9,18 @@ namespace JortPob
{
/* HugeTile is a 4x4 grid of Tiles. Sort of like an LOD type thing. HugeTile contains 4 big tiles & 16 regular tiles. */
[DebuggerDisplay("Huge m{map}_{coordinate.x}_{coordinate.y}_{block} :: [{cells.Count}] Cells")]
public class HugeTile : BaseTile
public class HugeTile(int m, int x, int y, int b) : BaseTile(m, x, y, b)
{
public List<BigTile> bigs;
public List<Tile> tiles;

public HugeTile(int m, int x, int y, int b) : base(m, x, y, b)
{
bigs = new();
tiles = new();
}
public List<BigTile> bigs = [];
public List<Tile> tiles = [];

/* Checks ABSOLUTE POSITION! This is the position of an object from the ESM accounting for the layout offset! */
public bool PositionInside(Vector3 position)
{
Vector3 pos = position + Const.LAYOUT_COORDINATE_OFFSET;

float x1 = (coordinate.x * 4f * Const.TILE_SIZE) - (Const.TILE_SIZE * 0.5f);
float y1 = (coordinate.y * 4f * Const.TILE_SIZE) - (Const.TILE_SIZE * 0.5f);
float x1 = (Coordinates.x * 4f * Const.TILE_SIZE) - (Const.TILE_SIZE * 0.5f);
float y1 = (Coordinates.y * 4f * Const.TILE_SIZE) - (Const.TILE_SIZE * 0.5f);
float x2 = x1 + (Const.TILE_SIZE * 4f);
float y2 = y1 + (Const.TILE_SIZE * 4f);

Expand All @@ -41,7 +34,7 @@ public bool PositionInside(Vector3 position)

public override void AddCell(ScriptManager scriptManager, Cell cell)
{
cells.Add(cell);
Cells.Add(cell);
BigTile big = GetBigTile(cell.center);
if(big == null) { Lort.Log($" ## WARNING ## Cell fell outside of reality [{cell.coordinate.x}, {cell.coordinate.y}] -- {cell.name} :: B01", Lort.Type.Debug); return; }
big.AddCell(scriptManager, cell);
Expand Down Expand Up @@ -72,12 +65,12 @@ public override void AddContent(Cache cache, Cell cell, Content content, bool fo
ModelInfo modelInfo = cache.GetModel(a.mesh);
if (modelInfo.size * (content.scale * 0.01f) > Const.CONTENT_SIZE_HUGE)
{
float x = (coordinate.x * 4f * Const.TILE_SIZE) + (Const.TILE_SIZE * 1.5f);
float y = (coordinate.y * 4f * Const.TILE_SIZE) + (Const.TILE_SIZE * 1.5f);
float x = (Coordinates.x * 4f * Const.TILE_SIZE) + (Const.TILE_SIZE * 1.5f);
float y = (Coordinates.y * 4f * Const.TILE_SIZE) + (Const.TILE_SIZE * 1.5f);
content.relative = (content.position + Const.LAYOUT_COORDINATE_OFFSET) - new Vector3(x, 0, y);
Tile tile = GetTile(cell.center);
if(tile == null) { break; } // Content fell outside of the bounds of any valid msbs. BAD!
content.load = tile.coordinate;
content.load = tile.Coordinates;
base.AddContent(cache, cell, content);
tile.AddNav(cache, cell, content);
break;
Expand All @@ -86,11 +79,11 @@ public override void AddContent(Cache cache, Cell cell, Content content, bool fo
case CharacterContent c:
if(c.follower)
{
float x = (coordinate.x * 4f * Const.TILE_SIZE) + (Const.TILE_SIZE * 1.5f);
float y = (coordinate.y * 4f * Const.TILE_SIZE) + (Const.TILE_SIZE * 1.5f);
float x = (Coordinates.x * 4f * Const.TILE_SIZE) + (Const.TILE_SIZE * 1.5f);
float y = (Coordinates.y * 4f * Const.TILE_SIZE) + (Const.TILE_SIZE * 1.5f);
content.relative = (content.position + Const.LAYOUT_COORDINATE_OFFSET) - new Vector3(x, 0, y);
Tile tile = GetTile(c.position);
content.load = tile.coordinate;
content.load = tile.Coordinates;
base.AddContent(cache, cell, content);
break;
}
Expand Down Expand Up @@ -160,15 +153,15 @@ public void AddTile(Tile tile)
public string GetRegion()
{
Dictionary<string, int> regions = new();
foreach (Cell cell in cells)
foreach (Cell cell in Cells)
{
if (cell.region == null) { continue; }
string r = cell.region.Trim().ToLower();
if (regions.ContainsKey(r)) { regions[r]++; }
else { regions.Add(r, 1); }
}

if (regions.Count() <= 0) { return "Default Region"; } // no regions set so guh
if (regions.Count <= 0) { return "Default Region"; } // no regions set so guh

string most = regions.Keys.First();
foreach (KeyValuePair<string, int> kvp in regions)
Expand Down
Loading