feat: implement mappeduobject

This commit is contained in:
tresabhi committed 2025-02-01 22:01:06 -06:00
1 parent 09abbbadc9
commit 37b5d1c6e8
2 files changed
+42 -3

No files matched your search

+18 -3
View File
@@ -1,5 +1,6 @@
using Blitzkit;
using BlitzKit.CLI.Models;
using BlitzKit.CLI.Utils;
using Google.Protobuf.Collections;
using Newtonsoft.Json.Linq;
@@ -27,20 +28,34 @@ namespace BlitzKit.CLI.Functions
{
foreach (var tankDir in nation.Directories)
{
if (tankDir.Value.Name != "R90_IS_4")
continue;
// if (tankDir.Value.Name != "R90_IS_4")
// continue;
var tank = MangleTank(tankDir.Value);
if (tank == null)
continue;
tanks.Tanks_.Add(tank.Id);
}
}
Tank MangleTank(VfsDirectory tankDir)
Tank? MangleTank(VfsDirectory tankDir)
{
var pdaName = $"PDA_{tankDir.Name}";
var pda = tankDir.GetUasset($"{pdaName}.uasset").Get(pdaName);
var tankId = pda.GetName("TankId");
var isDev = pda.TryGetBool("bInDevelopment") ?? true;
if (isDev)
{
PrettyLog.Warn($"Skipping dev tank: {tankId}");
return null;
}
else
{
PrettyLog.Success($"Mangling tank: {tankId}");
}
return new() { Id = tankId };
}
+24
View File
@@ -16,6 +16,8 @@ namespace BlitzKit.CLI.Models
readonly Dictionary<string, BoolProperty> Booleans = [];
readonly Dictionary<string, FloatProperty> Floats = [];
readonly Dictionary<string, ArrayProperty> Arrays = [];
readonly Dictionary<string, TextProperty> Texts = [];
readonly Dictionary<string, IntProperty> Ints = [];
public MappedUObject(List<FPropertyTag> properties)
: base(properties)
@@ -66,6 +68,18 @@ namespace BlitzKit.CLI.Models
break;
}
case TextProperty text:
{
Texts.Add(property.Name.Text, text);
break;
}
case IntProperty integer:
{
Ints.Add(property.Name.Text, integer);
break;
}
default:
{
throw new Exception($"Unhandled property type: {property}");
@@ -78,5 +92,15 @@ namespace BlitzKit.CLI.Models
{
return Names[name].Value.Text;
}
public bool GetBool(string name)
{
return Booleans[name].Value;
}
public bool? TryGetBool(string name)
{
return Booleans.TryGetValue(name, out var entry) ? entry.Value : null;
}
}
}