Skip to content

Commit

Permalink
feat: more shit
Browse files Browse the repository at this point in the history
  • Loading branch information
tresabhi committed Feb 2, 2025
1 parent 920ef6e commit 8b0f95c
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 171 deletions.
5 changes: 2 additions & 3 deletions packages/core/src/protos/tank.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ message Tank {
required ModuleHealth fuel_tank_health = 12;
repeated CrewHealth crew_health = 13;
required float max_health = 14;
required float health_burn_per_second = 15;
required float health_burn_per_sec = 15;
required float fire_starting_chance = 16;

required float concealment_stationary = 17;
required float concealment_moving = 18;
required float concealment_factor_on_shot = 19;
required float concealment_factor_at_shot = 19;

required float turret_turn_rate = 20;
required float circular_vision_radius = 21;
Expand All @@ -46,7 +46,6 @@ message Tank {
required float rotation_speed = 33;
required float terrain_resistance_hard = 34;
required float brake_force = 35;
required bool b_rotation_is_around_center = 36;
}

enum CrewType {
Expand Down
60 changes: 19 additions & 41 deletions packages/core/src/protos/tank.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

112 changes: 26 additions & 86 deletions src/BlitzKit.CLI/Functions/Mangler.cs
Original file line number Diff line number Diff line change
@@ -1,112 +1,52 @@
using Blitzkit;

Check failure on line 1 in src/BlitzKit.CLI/Functions/Mangler.cs

View workflow job for this annotation

GitHub Actions / Download client

The type or namespace name 'Blitzkit' could not be found (are you missing a using directive or an assembly reference?)
using BlitzKit.CLI.Models;
using BlitzKit.CLI.Utils;
using CUE4Parse.FileProvider.Objects;
using Google.Protobuf.Collections;
using Newtonsoft.Json.Linq;

namespace BlitzKit.CLI.Functions
{
public static class Mangler
public class Mangler
{
public static void Mangle()
readonly Tanks tanks = new();

Check failure on line 10 in src/BlitzKit.CLI/Functions/Mangler.cs

View workflow job for this annotation

GitHub Actions / Download client

The type or namespace name 'Tanks' could not be found (are you missing a using directive or an assembly reference?)
readonly BlitzProvider provider = new();

public void Mangle()
{
Tanks tanks = new();
BlitzProvider provider = new();
var nationDirs = provider.RootDirectory.GetDirectory("Blitz/Content/Tanks").Directories;

foreach (
var nationDir in provider.RootDirectory.GetDirectory("Blitz/Content/Tanks").Directories
)
foreach (var nationDir in nationDirs)
{
if (nationDir.Key == "TankStub")
continue;

foreach (var tankDir in nationDir.Value.Directories)
{
var id = tankDir.Key;

if (id != "R90_IS_4")
continue;

var attributeFileName = $"DA_{id}_Attributes.uasset";
var hasAttributesFile = tankDir.Value.HasFile(attributeFileName);
GameFile? attributesFile = null;

if (hasAttributesFile)
{
attributesFile = tankDir.Value.GetFile(attributeFileName);
}
else
{
PrettyLog.Warn(
$"No attributes file found for {nationDir.Key}/{id}, it may be misspelled; finding any attributes file..."
);

foreach (var file in tankDir.Value.Files)
{
if (file.Key.EndsWith("_Attributes.uasset"))
{
attributesFile = file.Value;
break;
}
}

if (attributesFile == null)
{
PrettyLog.Error(
$"No suffixed attributes file found for {nationDir.Key}/{id}; skipping..."
);
continue;
}
}

var exports = provider.LoadAllObjects(attributesFile.Path);

var tankAttributesDataAsset =
exports.First((export) => export.ExportType == "TankAttributesDataAsset")
?? throw new Exception("TankAttributesDataAsset not found");
var attr = JObject.FromObject(tankAttributesDataAsset);

if (attr["Properties"] is not JObject props || props["MaxHealth"] == null)
{
PrettyLog.Warn($"{nationDir.Key}/{id} has not migrated to Reforged; skipping...");
continue;
}
MangleNation(nationDir.Value);
}
}

var tank = MangleTank(id, props);
void MangleNation(VfsDirectory nation)
{
foreach (var tankDir in nation.Directories)
{
if (tankDir.Value.Name != "R90_IS_4")
continue;

tanks.Tanks_.Add(tank.Id);
var tank = MangleTank(tankDir.Value);

Console.WriteLine($"Mangled {nationDir.Key}/{id}");
}
tanks.Tanks_.Add(tank.Id);
}
}

public static Tank MangleTank(string id, JObject props)
Tank MangleTank(VfsDirectory tankDir)

Check failure on line 39 in src/BlitzKit.CLI/Functions/Mangler.cs

View workflow job for this annotation

GitHub Actions / Download client

The type or namespace name 'Tank' could not be found (are you missing a using directive or an assembly reference?)
{
Tank tank = new()
{
Id = id,
// TODO: Name
// TODO: Set
// TODO: Class
// TODO: Faction

TurretRotatorHealth = MangleModuleHealth((props["TurretRotatorHealth"] as JObject)!),
SurveyingDeviceHealth = MangleModuleHealth((props["SurveyingDeviceHealth"] as JObject)!),
GunHealth = MangleModuleHealth((props["GunHealth"] as JObject)!),
ChassisHealth = MangleModuleHealth((props["ChassisHealth"] as JObject)!),
AmmoBayHealth = MangleModuleHealth((props["AmmoBayHealth"] as JObject)!),
EngineHealth = MangleModuleHealth((props["EngineHealth"] as JObject)!),
FuelTankHealth = MangleModuleHealth((props["FuelTankHealth"] as JObject)!),
};
var pdaName = $"PDA_{tankDir.Name}";
var pda = tankDir.GetUasset($"{pdaName}.uasset").Get(pdaName);

MangleCrewHealth(tank.CrewHealth, (props["CrewHealth"] as JArray)!);
Console.WriteLine(pda);

return tank;
return new();
}

public static Dictionary<string, CrewType> CrewTypes = new()
Dictionary<string, CrewType> CrewTypes = new()

Check failure on line 49 in src/BlitzKit.CLI/Functions/Mangler.cs

View workflow job for this annotation

GitHub Actions / Download client

The type or namespace name 'CrewType' could not be found (are you missing a using directive or an assembly reference?)
{
{ "EModuleOrTankmen::Commander", CrewType.Commander },
{ "EModuleOrTankmen::Driver", CrewType.Driver },
Expand All @@ -116,7 +56,7 @@ public static Tank MangleTank(string id, JObject props)
{ "EModuleOrTankmen::Loader2", CrewType.Loader2 },
};

public static void MangleCrewHealth(RepeatedField<CrewHealth> map, JArray array)
void MangleCrewHealth(RepeatedField<CrewHealth> map, JArray array)

Check failure on line 59 in src/BlitzKit.CLI/Functions/Mangler.cs

View workflow job for this annotation

GitHub Actions / Download client

The type or namespace name 'CrewHealth' could not be found (are you missing a using directive or an assembly reference?)
{
foreach (var member in array.Cast<JObject>())
{
Expand All @@ -138,7 +78,7 @@ public static void MangleCrewHealth(RepeatedField<CrewHealth> map, JArray array)
}
}

public static ModuleHealth MangleModuleHealth(JObject obj)
ModuleHealth MangleModuleHealth(JObject obj)

Check failure on line 81 in src/BlitzKit.CLI/Functions/Mangler.cs

View workflow job for this annotation

GitHub Actions / Download client

The type or namespace name 'ModuleHealth' could not be found (are you missing a using directive or an assembly reference?)
{
ModuleHealth moduleHealth = new()
{
Expand Down
Loading

0 comments on commit 8b0f95c

Please sign in to comment.