Skip to content

Commit

Permalink
Merge pull request #21 from BigBang1112/production
Browse files Browse the repository at this point in the history
Nations Converter 1.3.4
  • Loading branch information
BigBang1112 authored May 6, 2021
2 parents 40b26e2 + e67100b commit 61bf5eb
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 51 deletions.
3 changes: 2 additions & 1 deletion NationsConverter/NationsConverter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
<PlatformTarget>x86</PlatformTarget>
<Version>1.3.3</Version>
<Version>1.3.4</Version>
<Authors>BigBang1112</Authors>
<Product>Nations Converter</Product>
<Company>BigBang1112</Company>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<ApplicationIcon>favicon.ico</ApplicationIcon>
<Platforms>x86</Platforms>
Expand Down
93 changes: 62 additions & 31 deletions NationsConverter/Sheets/Custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,150 +165,181 @@ Blocks:
- Item:
Name: NationsConverter\z_terrain\v_dirt\DirtGround.Item.Gbx
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, 8, 0]
OffsetPos: [0, 8, 0]
OffsetPos2: [0, -8, 0]
StadiumDirtBorder:
- Item:
Name: NationsConverter\z_terrain\y_dirtTransition\DirtTransitionCurveInWall.Item.Gbx
OffsetRot: [90, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, 8, 0]
OffsetPos: [0, 8, 0]
OffsetPos2: [0, -8, 0]
- Item:
Name: NationsConverter\z_terrain\y_dirtTransition\DirtTransitionStraightT.Item.Gbx
OffsetRot: [0, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, 8, 0]
OffsetPos: [0, 8, 0]
OffsetPos2: [0, -8, 0]
- Item:
Name: NationsConverter\z_terrain\y_dirtTransition\DirtTransitionDiagWall.Item.Gbx
OffsetRot: [90, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, 8, 0]
OffsetPos: [0, 8, 0]
OffsetPos2: [0, -8, 0]
- Item:
Name: NationsConverter\z_terrain\y_dirtTransition\DirtTransitionStraightY.Item.Gbx
OffsetRot: [90, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, 8, 0]
OffsetPos: [0, 8, 0]
OffsetPos2: [0, -8, 0]
- ~
- Item: # Straight wall
Name: NationsConverter\z_terrain\y_dirtTransition\DirtTtransitionStraightWall.Item.Gbx
OffsetRot: [90, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, 8, 0]
OffsetPos: [0, 8, 0]
OffsetPos2: [0, -8, 0]
- Item:
Name: NationsConverter\z_terrain\y_dirtTransition\DirtTransitonStraightL.Item.Gbx
OffsetRot: [90, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, 8, 0]
OffsetPos: [0, 8, 0]
OffsetPos2: [0, -8, 0]
- Item:
Name: NationsConverter\z_terrain\y_dirtTransition\DirtTransitionStraightJ.Item.Gbx
OffsetRot: [90, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, 8, 0]
OffsetPos: [0, 8, 0]
OffsetPos2: [0, -8, 0]
- Item:
Name: NationsConverter\z_terrain\y_dirtTransition\DirtTransitionStraightK.Item.Gbx
OffsetRot: [90, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, 8, 0]
OffsetPos: [0, 8, 0]
OffsetPos2: [0, -8, 0]
- Item: # Curve wall
Name: NationsConverter\z_terrain\y_dirtTransition\DirtTransitionCurveWall.Item.Gbx
OffsetRot: [180, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, 8, 0]
OffsetPos: [0, 8, 0]
OffsetPos2: [0, -8, 0]
- Item:
Name: NationsConverter\z_terrain\y_dirtTransition\DirtTransitionCurve.Item.Gbx
OffsetRot: [180, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, 8, 0]
OffsetPos: [0, 8, 0]
OffsetPos2: [0, -8, 0]
- Item:
Name: NationsConverter\z_terrain\y_dirtTransition\DirtTransitionStraight.Item.Gbx
OffsetRot: [90, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, 8, 0]
OffsetPos: [0, 8, 0]
OffsetPos2: [0, -8, 0]
- Item:
Name: NationsConverter\z_terrain\y_dirtTransition\DirtTransitionEnd.Item.Gbx
OffsetRot: [-90, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, 8, 0]
OffsetPos: [0, 8, 0]
OffsetPos2: [0, -8, 0]
- Item:
Name: NationsConverter\z_terrain\y_dirtTransition\DirtTransitionSingle.Item.Gbx
OffsetRot: [0, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, 8, 0]
OffsetPos: [0, 8, 0]
OffsetPos2: [0, -8, 0]

StadiumDirtHill:
- Item:
Name: NationsConverter\z_terrain\x_dirtHill\DirtHillCornerInside.Item.Gbx
OffsetRot: [90, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Item:
Name: NationsConverter\z_terrain\x_dirtHill\DirtHillStraightKSmall.Item.Gbx
OffsetPivot: [16, 0, 16]
OffsetRot: [90, 0, 0]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Item:
Name: NationsConverter\z_terrain\x_dirtHill\DirtHillCornerBothSmall.Item.Gbx
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Item:
Name: NationsConverter\z_terrain\x_dirtHill\DirtHillStraightYSmall.Item.Gbx
OffsetPivot: [16, 0, 16]
OffsetRot: [180, 0, 0]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- ~
- Item:
Name: NationsConverter\z_terrain\x_dirtHill\DirtHillStraight.Item.Gbx
OffsetRot: [180, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Item:
Name: NationsConverter\z_terrain\x_dirtHill\DirtHillStraightLSmall.Item.Gbx
OffsetRot: [180, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Item:
Name: NationsConverter\z_terrain\x_dirtHill\DirtHillStraightJSmall.Item.Gbx
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Item:
Name: NationsConverter\z_terrain\x_dirtHill\DirtHillStraightTSmall.Item.Gbx
OffsetPivot: [16, 0, 16]
OffsetRot: [180, 0, 0]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Items:
- Name: NationsConverter\z_terrain\x_dirtHill\DirtHillCornerOutside.Item.Gbx
OffsetRot: [-90, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Name: NationsConverter\z_terrain\v_dirt\DirtGround.Item.Gbx
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Items:
- Name: NationsConverter\z_terrain\x_dirtHill\DirtHillCornerSmall.Item.Gbx
OffsetRot: [-90, 0, 0]
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Name: NationsConverter\z_terrain\v_dirt\DirtGround.Item.Gbx
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Item:
Name: NationsConverter\z_terrain\x_dirtHill\DirtHillStraightSmall.Item.Gbx
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Items:
- Name: NationsConverter\z_terrain\x_dirtHill\DirtHillEndSmall.Item.Gbx
OffsetPivot: [16, 0, 16]
OffsetRot: [180, 0, 0]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Name: NationsConverter\z_terrain\v_dirt\DirtGround.Item.Gbx
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Items:
- Name: NationsConverter\z_terrain\x_dirtHill\DirtHillSmall.Item.Gbx
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]
- Name: NationsConverter\z_terrain\v_dirt\DirtGround.Item.Gbx
OffsetPivot: [16, 0, 16]
OffsetPos2: [0, -8, 0]
OffsetPos: [0, -8, 0]
OffsetPos2: [0, 8, 0]

# RoadMain

Expand Down
44 changes: 31 additions & 13 deletions NationsConverter/Stages/BlockConverter.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using GBX.NET;
using GBX.NET.BlockInfo;
using GBX.NET.Engines.Game;
using GBX.NET.Engines.GameData;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -84,8 +85,8 @@ void ProcessConversion(CGameCtnBlock referenceBlock, Conversion conversion)
if (conversion.OffsetCoordByBlockModel)
{
var allCoords = conversion.Blocks.Select(x => new Int3(x.OffsetCoord[0], x.OffsetCoord[1], x.OffsetCoord[2])).ToArray();
var min = new Int3(allCoords.Select(x => x.X).Min(), allCoords.Select(x => x.Y).Min(), allCoords.Select(x => x.Z).Min());
var max = new Int3(allCoords.Select(x => x.X).Max(), allCoords.Select(x => x.Y).Max(), allCoords.Select(x => x.Z).Max());
var min = new Int3(allCoords.Min(x => x.X), allCoords.Min(x => x.Y), allCoords.Min(x => x.Z));
var max = new Int3(allCoords.Max(x => x.X), allCoords.Max(x => x.Y), allCoords.Max(x => x.Z));
var size = max - min + (1, 1, 1);

center = (min + max) * .5f;
Expand All @@ -100,9 +101,9 @@ void ProcessConversion(CGameCtnBlock referenceBlock, Conversion conversion)

if (center != default)
{
var newMin = new Vec3(newCoords.Select(x => x.X).Min(), newCoords.Select(x => x.Y).Min(), newCoords.Select(x => x.Z).Min());
newCoords = newCoords.Select(x => x - newMin).ToList();
}
var newMin = new Vec3(newCoords.Min(x => x.X), newCoords.Min(x => x.Y), newCoords.Min(x => x.Z));
newCoords = newCoords.Select(x => x - newMin).ToList();
}

for (var i = 0; i < conversion.Blocks.Length; i++)
{
Expand Down Expand Up @@ -157,15 +158,22 @@ void ProcessConversion(CGameCtnBlock referenceBlock, Conversion conversion)
// Previous skins should be removed
foreach (var b in placedBlocks)
{
if (b.Skin != null)
if (b.Skin == null) // If the official sign set doesn't include the skin variant, create a new skin
{
// Set the skin texture of the sign to black for cleanness
b.Skin.PackDesc = new FileRef(3, FileRef.DefaultChecksum, "Skins\\Any\\Advertisement2x1\\Off.tga", "");
b.Skin.SecondaryPackDesc = new FileRef();
var skin = new CGameCtnBlockSkin { Text = "!4" };
skin.CreateChunk<CGameCtnBlockSkin.Chunk03059002>();
skin.CreateChunk<CGameCtnBlockSkin.Chunk03059003>();

skinsWithLocator.Remove(b.Skin);
// Remove the skin from locators if there is one for some reason, to avoid null exception
b.Skin = skin;
b.Author = "Nadeo";
}

// Set the skin texture of the sign to black for cleanness
b.Skin.PackDesc = new FileRef(3, FileRef.DefaultChecksum, "Skins\\Any\\Advertisement2x1\\Off.tga", "");
b.Skin.SecondaryPackDesc = new FileRef();

skinsWithLocator.Remove(b.Skin);
// Remove the skin from locators if there is one for some reason, to avoid null exception
}

foreach (var item in variant.Items)
Expand Down Expand Up @@ -250,8 +258,8 @@ void PlaceObject(string convName, Vec3 convOffsetPos, Vec3 convOffsetPos2, Vec3
else if(BlockInfoManager.BlockModels[referenceBlock.Name].Air != null)
allCoords = BlockInfoManager.BlockModels[referenceBlock.Name].Air.Select(x => (Int3)x.Coord);

var min = new Int3(allCoords.Select(x => x.X).Min(), allCoords.Select(x => x.Y).Min(), allCoords.Select(x => x.Z).Min());
var max = new Int3(allCoords.Select(x => x.X).Max(), allCoords.Select(x => x.Y).Max(), allCoords.Select(x => x.Z).Max());
var min = new Int3(allCoords.Min(x => x.X), allCoords.Min(x => x.Y), allCoords.Min(x => x.Z));
var max = new Int3(allCoords.Max(x => x.X), allCoords.Max(x => x.Y), allCoords.Max(x => x.Z));
var box = max - min;

var directions = new Int3[]
Expand Down Expand Up @@ -456,6 +464,16 @@ CGameCtnBlock ConvertBlock(CGameCtnBlock referenceBlock, Conversion conversion,
if (referenceBlock.WaypointSpecialProperty != null)
block.WaypointSpecialProperty = referenceBlock.WaypointSpecialProperty;

if (version <= GameVersion.TMUF)
{
if (referenceBlock.Name.Contains("Checkpoint"))
{
var waypoint = new CGameWaypointSpecialProperty();
waypoint.CreateChunk<CGameWaypointSpecialProperty.Chunk2E009000>();
block.WaypointSpecialProperty = waypoint;
}
}

block.IsGround = false;

if (conversionBlock.Flags.HasValue)
Expand Down
8 changes: 3 additions & 5 deletions NationsConverter/Stages/GroundPlacer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void Process(CGameCtnChallenge map, int version, ConverterParameters para
x.Coord += (8, 0, 8); // Shift the block by 8x0x8 positions to center the blocks for the new Stadium

if (version >= GameVersion.TM2)
x.Coord -= (0, 8, 0);
x.Coord -= (0, map.DecoBaseHeightOffset, 0);
});

map.ImportFileToEmbed($"{Converter.LocalDirectory}/UserData/Materials/GrassTexGreenPhy.Mat.Gbx", "Materials", true); // False crashes GBX.NET
Expand Down Expand Up @@ -81,12 +81,10 @@ public void Process(CGameCtnChallenge map, int version, ConverterParameters para
var dirtBlockExists = false;

Int3 coord = (x, 0, z);
if (version <= GameVersion.TMUF)
coord -= (1, 0, 1);

foreach (var groundBlock in map.Blocks.Where(o => o.Coord == (x, 0, z)
|| (version <= GameVersion.TMUF &&
(o.Coord == coord + (0, 1, 0) // TMNF hill
(o.Coord == coord + (0, 2, 0) // TMNF hill
|| o.Coord == coord + (0, -1, 0))) // TMNF base

|| (version >= GameVersion.TM2 && (o.Name == "StadiumPool2" || o.Name == "StadiumWater2") && o.Coord == (x, -1, z))))
Expand All @@ -98,7 +96,7 @@ public void Process(CGameCtnChallenge map, int version, ConverterParameters para
}
}

var fabricExists = map.Blocks.Where(o => o.Coord.XZ == coord && o.Name == "StadiumFabricCross1x1").Count() > 0;
var fabricExists = map.Blocks.Count(o => o.Coord.XZ == coord && o.Name == "StadiumFabricCross1x1") > 0;

if (!dirtBlockExists)
{
Expand Down
3 changes: 2 additions & 1 deletion NationsConverterGUI/NationsConverterGUI.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<Company>BigBang1112</Company>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net5.0-windows;net452</TargetFrameworks>
<UseWPF>true</UseWPF>
<Platforms>x86</Platforms>
<PlatformTarget>x86</PlatformTarget>
<ApplicationIcon>favicon.ico</ApplicationIcon>
<Version>1.3.3</Version>
<Version>1.3.4</Version>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 61bf5eb

Please sign in to comment.