-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
89 changed files
with
1,212 additions
and
949 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,6 @@ | ||
namespace Grille.BeamNgLib.Collections; | ||
|
||
public interface IKeyed | ||
{ | ||
public string? Key { get; } | ||
} |
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,29 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<LangVersion>12</LangVersion> | ||
<Nullable>enable</Nullable> | ||
<PackageId>Grille.BeamNgLib</PackageId> | ||
<Title>Grille.BeamNgLib</Title> | ||
<Owners>Grille</Owners> | ||
<RepositoryUrl>https://github.com/Grille/BeamNG_LevelTemplateCreator</RepositoryUrl> | ||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> | ||
<Copyright>Copyright (c) 2024 Paul Hirch</Copyright> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
<PackageLicenseFile>LICENSE</PackageLicenseFile> | ||
<PackageIcon>Grille.BeamNG.png</PackageIcon> | ||
<Authors>Grille</Authors> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\Assets\Grille.BeamNG.png" Pack="true" PackagePath="\" Visible="false" /> | ||
<None Include="..\README.md" Pack="true" PackagePath="\" Visible="false" /> | ||
<None Include="..\LICENSE" Pack="true" PackagePath="\" Visible="false" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="GGL.BinaryView" Version="2.4.2" /> | ||
</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,39 @@ | ||
namespace Grille.BeamNgLib.IO.Binary; | ||
|
||
public class TerrainBinary | ||
{ | ||
public struct TerrainData | ||
{ | ||
public ushort Height; | ||
public byte Material; | ||
|
||
public bool IsHole => Material == byte.MaxValue; | ||
|
||
public void SetHeight(float value, float maxHeight) => Height = TerrainV9Serializer.GetU16Height(value, maxHeight); | ||
public float GetHeight(float maxHeight) => TerrainV9Serializer.GetSingleHeight(Height, maxHeight); | ||
} | ||
|
||
public int Size { get; } | ||
|
||
public TerrainData[] Data { get; } | ||
|
||
public string[] MaterialNames { get; set; } | ||
|
||
public int TotalSize => Size * Size; | ||
|
||
public TerrainBinary(int size) : this(size, Array.Empty<string>()) { } | ||
|
||
public TerrainBinary(int size, string[] materialNames) : this(size, materialNames, new TerrainData[size * size]) { } | ||
|
||
public TerrainBinary(int size, string[] materialNames, TerrainData[] data) | ||
{ | ||
Size = size; | ||
Data = data; | ||
MaterialNames = materialNames; | ||
|
||
if (data.Length != TotalSize) | ||
{ | ||
throw new ArgumentException($"data.Length must be {TotalSize}", nameof(data)); | ||
} | ||
} | ||
} |
12 changes: 3 additions & 9 deletions
12
...lTemplateCreator/IO/JsonDictSerializer.cs → Grille.BeamNGLib/IO/JsonDictSerializer.cs
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
11 changes: 2 additions & 9 deletions
11
...TemplateCreator/IO/LevelInfoSerializer.cs → Grille.BeamNGLib/IO/LevelInfoSerializer.cs
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,16 @@ | ||
namespace Grille.BeamNgLib.IO.Resources; | ||
|
||
public class FileResource : Resource | ||
{ | ||
public string Path { get; } | ||
|
||
public FileResource(string name, string path, bool isGameResource) : base(name, isGameResource) | ||
{ | ||
Path = path; | ||
} | ||
|
||
public override Stream Open() | ||
{ | ||
return new FileStream(Path, FileMode.Open); | ||
} | ||
} |
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 @@ | ||
namespace Grille.BeamNgLib.IO.Resources; | ||
|
||
internal class GroupResource : Resource | ||
{ | ||
public GroupResource(string name, bool isGameResource, Resource[] resources) : base(name, isGameResource) | ||
{ | ||
|
||
} | ||
|
||
public override Stream Open() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
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,38 @@ | ||
namespace Grille.BeamNgLib.IO.Resources; | ||
|
||
public static class PathEvaluator | ||
{ | ||
static public Resource Get(string entry, string gamePath) | ||
{ | ||
return Get(entry, gamePath, string.Empty); | ||
} | ||
|
||
static public Resource Get(string entry, string gamePath, string userPath) | ||
{ | ||
entry = entry.Replace("\\", "/"); | ||
|
||
string path = entry.StartsWith('/') ? entry.Substring(1) : entry; | ||
return ParseAbsolute(path, gamePath, userPath); | ||
} | ||
|
||
static Resource ParseAbsolute(string entry, string gamePath, string userPath) | ||
{ | ||
var split = entry.ToLower().Split([Path.PathSeparator, Path.AltDirectorySeparatorChar]); | ||
|
||
if (split[0] == "levels") | ||
{ | ||
var level = split[1]; | ||
var filename = split[split.Length - 1]; | ||
var key = $"beamng.{level}.{filename}"; | ||
var zippath = $"{gamePath}/content/levels/{level}.zip"; | ||
if (File.Exists(zippath)) | ||
{ | ||
return new ZipFileResource(key, zippath, entry, true); | ||
} | ||
} | ||
|
||
throw new NotImplementedException(); | ||
} | ||
|
||
|
||
} |
28 changes: 12 additions & 16 deletions
28
...lTemplateCreator/IO/Resources/Resource.cs → Grille.BeamNGLib/IO/Resources/Resource.cs
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,21 @@ | ||
using Grille.BeamNgLib.Collections; | ||
|
||
namespace Grille.BeamNgLib.IO.Resources; | ||
|
||
public class ResourceCollection : KeyedCollection<Resource> | ||
{ | ||
public ResourceCollection() { } | ||
|
||
public ResourceCollection(bool ignoreFalseDuplicates) | ||
{ | ||
IgnoreFalseDuplicates = ignoreFalseDuplicates; | ||
} | ||
|
||
public void Save(string path) | ||
{ | ||
foreach (var resource in this) | ||
{ | ||
resource.SaveToDirectory(path); | ||
} | ||
} | ||
} |
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,4 @@ | ||
namespace Grille.BeamNgLib.IO.Resources; | ||
internal class StaticPath | ||
{ | ||
} |
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
Oops, something went wrong.