-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Generate Luz and Lvl files from xml. * Filter out cdclient for zone entries.
- Loading branch information
Showing
14 changed files
with
401 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\InfectedRose.Database\InfectedRose.Database.csproj" /> | ||
<ProjectReference Include="..\InfectedRose.World\InfectedRose.World.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System; | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
using System.Xml.Serialization; | ||
using InfectedRose.Database; | ||
using InfectedRose.Database.Concepts.Tables; | ||
using InfectedRose.World; | ||
|
||
namespace InfectedRose.Interface | ||
{ | ||
internal static class Program | ||
{ | ||
private static async Task Main(string[] args) | ||
{ | ||
if (args.Length != 2) | ||
{ | ||
Console.WriteLine($"Usage: {Path.GetFileName(Assembly.GetEntryAssembly()?.Location)} <xml-file> <fdb>"); | ||
|
||
Environment.Exit(1); | ||
|
||
return; | ||
} | ||
|
||
var serializer = new XmlSerializer(typeof(Zone)); | ||
|
||
var zone = new Zone(); | ||
|
||
if (File.Exists(args[0])) | ||
{ | ||
await using var stream = File.OpenRead(args[0]); | ||
|
||
zone = (Zone) serializer.Deserialize(stream); | ||
} | ||
else | ||
{ | ||
await using var stream = File.Create(args[0]); | ||
|
||
serializer.Serialize(stream, zone); | ||
|
||
Console.WriteLine("Created xml file"); | ||
|
||
Environment.Exit(1); | ||
|
||
return; | ||
} | ||
|
||
await zone.SaveAsync(Path.GetDirectoryName(args[0])); | ||
|
||
var database = await AccessDatabase.OpenAsync(args[1]); | ||
|
||
var zones = database["ZoneTable"]; | ||
|
||
foreach (var row in zones) | ||
{ | ||
if (Enum.IsDefined(typeof(ZoneId), (ushort) row.Key)) continue; | ||
|
||
zones.Remove(row); | ||
} | ||
|
||
var entry = new ZoneTableTable(zones.Create(zone.Id)); | ||
|
||
entry.zoneName = zone.Name; | ||
entry.zoneID = (int) zone.Id; | ||
entry.ghostdistance = zone.GhostDistance; | ||
entry.scriptID = -1; | ||
entry.locStatus = 0; | ||
entry.DisplayDescription = zone.Description; | ||
|
||
foreach (var table in database) | ||
{ | ||
table.Recalculate(); | ||
} | ||
|
||
var pad = 0; | ||
|
||
await database.SaveAsync(args[1], i => | ||
{ | ||
if (++pad != 10000) return; | ||
|
||
Console.WriteLine(i); | ||
|
||
pad = 0; | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
namespace InfectedRose.Interface | ||
{ | ||
public enum ZoneId : ushort | ||
{ | ||
VentureExplorerCinematic, | ||
VentureExplorer = 1000, | ||
ReturnToVentureExplorer, | ||
AvantGardens = 1100, | ||
AvantGardensSurvival, | ||
SpiderQueenBattle, | ||
BlockYard = 1150, | ||
AvantGrove, | ||
NimbusStation = 1200, | ||
PetCove, | ||
VertigoLoopRacetrack = 1203, | ||
BattleOfNimbusStation, | ||
NimbusRock = 1250, | ||
NimbusIsle, | ||
FrostBurgh = 1260, | ||
GnarledForest = 1300, | ||
CanyonCove = 1302, | ||
KeelhaulCanyon, | ||
ChanteyShantey = 1350, | ||
ForbiddenValley = 1400, | ||
ForbiddenValleyDragon = 1402, | ||
DragonmawChasm, | ||
RavenBluff = 1450, | ||
Starbase3001 = 1600, | ||
DeepFreeze, | ||
RobotCity, | ||
MoonBase, | ||
Portabello = 1604, | ||
LegoClub = 1700, | ||
CruxPrime = 1800, | ||
NexusTower = 1900, | ||
Ninjago = 2000, | ||
FrakjawBattle, | ||
NimbusStationWinterRacetrack = 1261 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
using System; | ||
using System.Numerics; | ||
using InfectedRose.Core; | ||
using RakDotNet.IO; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\InfectedRose.Luz\InfectedRose.Luz.csproj" /> | ||
<ProjectReference Include="..\InfectedRose.Lvl\InfectedRose.Lvl.csproj" /> | ||
<ProjectReference Include="..\InfectedRose.Terrain\InfectedRose.Terrain.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Xml.Serialization; | ||
using InfectedRose.Luz; | ||
using InfectedRose.Lvl; | ||
using RakDotNet.IO; | ||
|
||
namespace InfectedRose.World | ||
{ | ||
[XmlRoot] | ||
public class Scene | ||
{ | ||
[XmlAttribute] public string Name { get; set; } | ||
|
||
[XmlAttribute] public uint Id { get; set; } | ||
|
||
[XmlAttribute] public uint Layer { get; set; } | ||
|
||
[XmlAttribute] public uint Revision { get; set; } | ||
|
||
[XmlElement] public string SkyBox { get; set; } | ||
|
||
[XmlElement("Object")] public List<WorldObject> Objects { get; set; } | ||
|
||
public LuzScene LuzScene => new LuzScene | ||
{ | ||
FileName = $"{Name.Replace(" ", "_")}.lvl", | ||
SceneName = Name, | ||
SceneId = Id, | ||
LayerId = Layer | ||
}; | ||
|
||
public async Task SaveAsync(string path) | ||
{ | ||
var scene = LuzScene; | ||
|
||
var file = new LvlFile | ||
{ | ||
LvlVersion = 0x26 | ||
}; | ||
|
||
if (Objects?.Count > 0) | ||
{ | ||
file.LevelObjects = new LevelObjects(file.LvlVersion) | ||
{ | ||
Templates = Objects.Select(o => o.Template).ToArray() | ||
}; | ||
} | ||
|
||
if (!string.IsNullOrWhiteSpace(SkyBox)) | ||
{ | ||
var skyConfig = new LevelSkyConfig | ||
{ | ||
Skybox = {[0] = SkyBox} | ||
}; | ||
|
||
file.LevelSkyConfig = skyConfig; | ||
} | ||
|
||
file.LevelInfo = new LevelInfo | ||
{ | ||
RevisionNumber = Revision | ||
}; | ||
|
||
await using var stream = File.Create(Path.Combine(path, scene.FileName)); | ||
|
||
using var writer = new BitWriter(stream); | ||
|
||
file.Serialize(writer); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System.Xml.Serialization; | ||
|
||
namespace InfectedRose.World | ||
{ | ||
[XmlRoot] | ||
public class Terrain | ||
{ | ||
[XmlElement] public string FileName { get; set; } = "terrain.raw"; | ||
|
||
[XmlElement] public string Name { get; set; } = "terrain"; | ||
|
||
[XmlElement] public string Description { get; set; } = "terrain file"; | ||
} | ||
} |
Oops, something went wrong.