Cut 7b: 16 modular Brokkr weapon parts, mfg paint bands 10..14, ClientOrdnanceMirror, audio & tooltips
This commit is contained in:
parent
6f6bfe3c46
commit
6447155efb
27 changed files with 2420 additions and 74 deletions
BIN
assets/gear/parts/brl_autocannon.glb
Normal file
BIN
assets/gear/parts/brl_autocannon.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/brl_missile_tube.glb
Normal file
BIN
assets/gear/parts/brl_missile_tube.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/brl_prism_lance.glb
Normal file
BIN
assets/gear/parts/brl_prism_lance.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/brl_sabot_rail.glb
Normal file
BIN
assets/gear/parts/brl_sabot_rail.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/fd_belt_drum.glb
Normal file
BIN
assets/gear/parts/fd_belt_drum.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/fd_capacitor_bank.glb
Normal file
BIN
assets/gear/parts/fd_capacitor_bank.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/fd_rotary_loader.glb
Normal file
BIN
assets/gear/parts/fd_rotary_loader.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/fd_swarm_magazine.glb
Normal file
BIN
assets/gear/parts/fd_swarm_magazine.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/mz_loiter_aero_fin.glb
Normal file
BIN
assets/gear/parts/mz_loiter_aero_fin.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/mz_mirv_warhead.glb
Normal file
BIN
assets/gear/parts/mz_mirv_warhead.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/mz_plasma_diffuser.glb
Normal file
BIN
assets/gear/parts/mz_plasma_diffuser.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/mz_slotted_brake.glb
Normal file
BIN
assets/gear/parts/mz_slotted_brake.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/rx_auralian_prism.glb
Normal file
BIN
assets/gear/parts/rx_auralian_prism.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/rx_korrathi_cradle.glb
Normal file
BIN
assets/gear/parts/rx_korrathi_cradle.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/rx_salvage_frame.glb
Normal file
BIN
assets/gear/parts/rx_salvage_frame.glb
Normal file
Binary file not shown.
BIN
assets/gear/parts/rx_vex_pod_rack.glb
Normal file
BIN
assets/gear/parts/rx_vex_pod_rack.glb
Normal file
Binary file not shown.
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Godot;
|
using Godot;
|
||||||
using RustToDust.Core;
|
using RustToDust.Core;
|
||||||
|
using RustToDust.Ymir;
|
||||||
|
|
||||||
namespace RustToDust.Client;
|
namespace RustToDust.Client;
|
||||||
|
|
||||||
|
|
@ -102,6 +103,7 @@ public partial class ArenaAudioSystem : Node3D
|
||||||
|
|
||||||
private readonly Dictionary<(bool IsSpectator, int ShooterId, string WeaponId), float> _shotDedupeExpiry = new();
|
private readonly Dictionary<(bool IsSpectator, int ShooterId, string WeaponId), float> _shotDedupeExpiry = new();
|
||||||
private readonly Dictionary<(byte TargetKind, int TargetId), float> _impactDedupeExpiry = new();
|
private readonly Dictionary<(byte TargetKind, int TargetId), float> _impactDedupeExpiry = new();
|
||||||
|
private readonly Dictionary<(byte Kind, int ShooterId, byte NodeIdx), float> _ordnanceDedupeExpiry = new();
|
||||||
private readonly Dictionary<int, string> _lastContenderChassis = new();
|
private readonly Dictionary<int, string> _lastContenderChassis = new();
|
||||||
private readonly Dictionary<int, int> _lastContenderLoadoutVer = new();
|
private readonly Dictionary<int, int> _lastContenderLoadoutVer = new();
|
||||||
private readonly List<(float X, float Z, float Expiry)> _recentExplosionPoints = new(16);
|
private readonly List<(float X, float Z, float Expiry)> _recentExplosionPoints = new(16);
|
||||||
|
|
@ -292,6 +294,7 @@ public partial class ArenaAudioSystem : Node3D
|
||||||
|
|
||||||
_shotDedupeExpiry.Clear();
|
_shotDedupeExpiry.Clear();
|
||||||
_impactDedupeExpiry.Clear();
|
_impactDedupeExpiry.Clear();
|
||||||
|
_ordnanceDedupeExpiry.Clear();
|
||||||
_lastContenderChassis.Clear();
|
_lastContenderChassis.Clear();
|
||||||
_lastContenderLoadoutVer.Clear();
|
_lastContenderLoadoutVer.Clear();
|
||||||
_recentExplosionPoints.Clear();
|
_recentExplosionPoints.Clear();
|
||||||
|
|
@ -489,6 +492,10 @@ public partial class ArenaAudioSystem : Node3D
|
||||||
case DropPodEvent dpe:
|
case DropPodEvent dpe:
|
||||||
HandleDropPodEvent(dpe, localId, listenerPos);
|
HandleDropPodEvent(dpe, localId, listenerPos);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OrdnanceNodeEvent ord:
|
||||||
|
HandleOrdnanceNodeEvent(ord, localId, listenerPos);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -771,6 +778,108 @@ public partial class ArenaAudioSystem : Node3D
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void HandleOrdnanceNodeEvent(OrdnanceNodeEvent ord, int localId, Vector3 listenerPos)
|
||||||
|
{
|
||||||
|
var dedupeKey = (ord.Kind, ord.ShooterId, ord.NodeDefIndex);
|
||||||
|
if (_ordnanceDedupeExpiry.TryGetValue(dedupeKey, out float expiry) && _audioTime < expiry)
|
||||||
|
{
|
||||||
|
DedupedCount++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_ordnanceDedupeExpiry[dedupeKey] = _audioTime + 0.065f;
|
||||||
|
PruneExpiredMap(_ordnanceDedupeExpiry);
|
||||||
|
|
||||||
|
OrdnanceNodeDef? def = null;
|
||||||
|
if (ord.WeaponKey is { } wk)
|
||||||
|
{
|
||||||
|
var spec = ProceduralWeaponGenerator.Generate(wk);
|
||||||
|
def = ord.NodeDefIndex < spec.FlattenedNodes.Length ? spec.FlattenedNodes[ord.NodeDefIndex] : spec.RootNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
var kind = (OrdnanceEventKind)ord.Kind;
|
||||||
|
bool isLocal = !ord.IsSpectatorShooter && ord.ShooterId == localId;
|
||||||
|
Vector3 pos = new(ord.PosX, ord.PosY, ord.PosZ);
|
||||||
|
float distSq = pos.DistanceSquaredTo(listenerPos);
|
||||||
|
int priority = isLocal
|
||||||
|
? PriorityLocalAction
|
||||||
|
: (distSq <= 90f * 90f ? PriorityNearCombat : PriorityDistantCombat);
|
||||||
|
|
||||||
|
string? clipKey = null;
|
||||||
|
float volDb = isLocal ? -2.0f : -4.2f;
|
||||||
|
float pitch = NextPitchJitter(0.94f, 1.06f);
|
||||||
|
uint v = _variantCounter++;
|
||||||
|
|
||||||
|
switch (kind)
|
||||||
|
{
|
||||||
|
case OrdnanceEventKind.Spawned:
|
||||||
|
if (ord.ParentOrdnanceId != 0)
|
||||||
|
{
|
||||||
|
return; // Split event already provides audio cue
|
||||||
|
}
|
||||||
|
clipKey = SelectAudioClassClip(def?.AudioClass ?? OrdnanceAudioClass.RocketSalvo, v);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OrdnanceEventKind.StageTransition:
|
||||||
|
if (def?.Motion is OrdnanceMotion.RocketBoosted or OrdnanceMotion.HomingMissile)
|
||||||
|
{
|
||||||
|
clipKey = (v & 1) == 0 ? "rocket_salvo_01" : "rocket_salvo_02";
|
||||||
|
volDb = isLocal ? -1.5f : -3.5f;
|
||||||
|
}
|
||||||
|
else if (def?.Motion == OrdnanceMotion.LoiterOrbit)
|
||||||
|
{
|
||||||
|
clipKey = "pd_laser";
|
||||||
|
pitch = NextPitchJitter(1.12f, 1.24f);
|
||||||
|
volDb = -5.5f;
|
||||||
|
}
|
||||||
|
else if (def?.Motion == OrdnanceMotion.StationaryMine)
|
||||||
|
{
|
||||||
|
clipKey = "mech_quick_bolt";
|
||||||
|
pitch = NextPitchJitter(1.25f, 1.38f);
|
||||||
|
volDb = -6.5f;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OrdnanceEventKind.Split:
|
||||||
|
clipKey = (v & 1) == 0 ? "flak_blast_01" : "pod_petal_pop";
|
||||||
|
volDb = isLocal ? -2.5f : -4.5f;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OrdnanceEventKind.Detonated:
|
||||||
|
if (def?.AudioClass == OrdnanceAudioClass.PlasmaPpc)
|
||||||
|
{
|
||||||
|
clipKey = "plasma_ppc_02";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
clipKey = "impact_explosion";
|
||||||
|
RecordExplosionPoint(pos.X, pos.Z);
|
||||||
|
}
|
||||||
|
volDb = isLocal ? -2.0f : -3.8f;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OrdnanceEventKind.Intercepted:
|
||||||
|
clipKey = "mech_eject";
|
||||||
|
volDb = -5.5f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(clipKey))
|
||||||
|
{
|
||||||
|
PlayOneShot3D(clipKey, pos, listenerPos, priority, volDb, pitch, isLocal, ord.ShooterId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string SelectAudioClassClip(OrdnanceAudioClass audioClass, uint variant) => audioClass switch
|
||||||
|
{
|
||||||
|
OrdnanceAudioClass.CannonLight => (variant & 1) == 0 ? "ac_light_01" : "ac_light_02",
|
||||||
|
OrdnanceAudioClass.CannonHeavy => (variant & 1) == 0 ? "cannon_heavy_01" : "cannon_heavy_02",
|
||||||
|
OrdnanceAudioClass.RocketSalvo => (variant & 1) == 0 ? "rocket_salvo_01" : "rocket_salvo_02",
|
||||||
|
OrdnanceAudioClass.LaserHeavy => "laser_heavy_01",
|
||||||
|
OrdnanceAudioClass.GaussRail => "gauss_rail_01",
|
||||||
|
OrdnanceAudioClass.PlasmaPpc => (variant & 1) == 0 ? "plasma_ppc_01" : "plasma_ppc_02",
|
||||||
|
_ => "rocket_salvo_01"
|
||||||
|
};
|
||||||
|
|
||||||
private void UpdateLoopSlots(IClientArenaSession session, Vector3 listenerPos, float alpha)
|
private void UpdateLoopSlots(IClientArenaSession session, Vector3 listenerPos, float alpha)
|
||||||
{
|
{
|
||||||
var state = session.ViewState;
|
var state = session.ViewState;
|
||||||
|
|
@ -1176,6 +1285,12 @@ public partial class ArenaAudioSystem : Node3D
|
||||||
private string SelectWeaponClipKey(string? weaponId, WeaponVisualClass weaponClass)
|
private string SelectWeaponClipKey(string? weaponId, WeaponVisualClass weaponClass)
|
||||||
{
|
{
|
||||||
uint v = _variantCounter++;
|
uint v = _variantCounter++;
|
||||||
|
if (ProceduralWeaponGenerator.TryParseId(weaponId, out ProceduralWeaponKey pKey))
|
||||||
|
{
|
||||||
|
var spec = ProceduralWeaponGenerator.Generate(pKey);
|
||||||
|
return SelectAudioClassClip(spec.AudioClass, v);
|
||||||
|
}
|
||||||
|
|
||||||
string id = (weaponId ?? string.Empty).ToLowerInvariant();
|
string id = (weaponId ?? string.Empty).ToLowerInvariant();
|
||||||
return id switch
|
return id switch
|
||||||
{
|
{
|
||||||
|
|
@ -1201,6 +1316,10 @@ public partial class ArenaAudioSystem : Node3D
|
||||||
WeaponVisualClass.Autocannon => "ac_light_01",
|
WeaponVisualClass.Autocannon => "ac_light_01",
|
||||||
WeaponVisualClass.Explosive => "cannon_heavy_01",
|
WeaponVisualClass.Explosive => "cannon_heavy_01",
|
||||||
WeaponVisualClass.ThermalBeam => "lance_beam_01",
|
WeaponVisualClass.ThermalBeam => "lance_beam_01",
|
||||||
|
WeaponVisualClass.GaussRail => "gauss_rail_01",
|
||||||
|
WeaponVisualClass.PlasmaPpc => (v & 1) == 0 ? "plasma_ppc_01" : "plasma_ppc_02",
|
||||||
|
WeaponVisualClass.RocketSalvo => (v & 1) == 0 ? "rocket_salvo_01" : "rocket_salvo_02",
|
||||||
|
WeaponVisualClass.SwarmSmart => "pd_laser",
|
||||||
_ => "mg_shot_01"
|
_ => "mg_shot_01"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,9 @@ public partial class ArenaRenderer : Node3D
|
||||||
{
|
{
|
||||||
public VehicleVisualInstance? ChassisVisual;
|
public VehicleVisualInstance? ChassisVisual;
|
||||||
public ArrayMesh? GearMesh;
|
public ArrayMesh? GearMesh;
|
||||||
|
public VehicleVisualInstance.ModularWeaponPartBinding[]? ModularParts;
|
||||||
|
public float ManufacturerRoleIndex;
|
||||||
|
public Color DropBeaconColor;
|
||||||
public Vector3 GearScale;
|
public Vector3 GearScale;
|
||||||
public float GearYOffset;
|
public float GearYOffset;
|
||||||
public bool IsModule;
|
public bool IsModule;
|
||||||
|
|
@ -95,6 +98,9 @@ public partial class ArenaRenderer : Node3D
|
||||||
private MultiMesh _vfxRingMm = null!;
|
private MultiMesh _vfxRingMm = null!;
|
||||||
private MultiMeshInstance3D _vfxRingMmi = null!;
|
private MultiMeshInstance3D _vfxRingMmi = null!;
|
||||||
private readonly List<TransientVfx> _transientVfx = new(128);
|
private readonly List<TransientVfx> _transientVfx = new(128);
|
||||||
|
private readonly ClientOrdnanceMirror _ordnanceMirror = new();
|
||||||
|
private readonly List<(Transform3D Xf, Color Col)> _mirrorSpheres = new(64);
|
||||||
|
private readonly List<(Transform3D Xf, Color Col)> _mirrorRings = new(128);
|
||||||
private int _activeBeamCount;
|
private int _activeBeamCount;
|
||||||
|
|
||||||
// Continuous emitter rate limiters (keyed by (IsContender, EntityId))
|
// Continuous emitter rate limiters (keyed by (IsContender, EntityId))
|
||||||
|
|
@ -122,6 +128,7 @@ public partial class ArenaRenderer : Node3D
|
||||||
public ParticlePool Particles => _particles;
|
public ParticlePool Particles => _particles;
|
||||||
internal MultiMeshPartPool PartPool => _partPool;
|
internal MultiMeshPartPool PartPool => _partPool;
|
||||||
internal PomDecalPool PomDecals => _pomDecals;
|
internal PomDecalPool PomDecals => _pomDecals;
|
||||||
|
internal ClientOrdnanceMirror OrdnanceMirror => _ordnanceMirror;
|
||||||
|
|
||||||
public VehicleVisualInstance? GetContenderVisual(int contenderId) =>
|
public VehicleVisualInstance? GetContenderVisual(int contenderId) =>
|
||||||
_contenderVisuals.TryGetValue(contenderId, out var vis) ? vis.Visual : null;
|
_contenderVisuals.TryGetValue(contenderId, out var vis) ? vis.Visual : null;
|
||||||
|
|
@ -348,6 +355,19 @@ public partial class ArenaRenderer : Node3D
|
||||||
SyncSpectators(session, elapsedSeconds, dt, alpha, hasCam, camPos);
|
SyncSpectators(session, elapsedSeconds, dt, alpha, hasCam, camPos);
|
||||||
SyncGroundDrops(state, elapsedSeconds, hasCam, camPos);
|
SyncGroundDrops(state, elapsedSeconds, hasCam, camPos);
|
||||||
SyncOrbitalPods(session, alpha, hasCam, camPos);
|
SyncOrbitalPods(session, alpha, hasCam, camPos);
|
||||||
|
_mirrorSpheres.Clear();
|
||||||
|
_mirrorRings.Clear();
|
||||||
|
_ordnanceMirror.StepAndSubmit(
|
||||||
|
dt,
|
||||||
|
session,
|
||||||
|
_assetCache,
|
||||||
|
_partPool,
|
||||||
|
_particles,
|
||||||
|
state.Terrain,
|
||||||
|
hasCam,
|
||||||
|
camPos,
|
||||||
|
(xf, col) => _mirrorRings.Add((xf, col)),
|
||||||
|
(xf, col) => _mirrorSpheres.Add((xf, col)));
|
||||||
_debris.Step(dt, state.Terrain);
|
_debris.Step(dt, state.Terrain);
|
||||||
_debris.SubmitToPool(_partPool);
|
_debris.SubmitToPool(_partPool);
|
||||||
_partPool.EndFrame();
|
_partPool.EndFrame();
|
||||||
|
|
@ -372,6 +392,26 @@ public partial class ArenaRenderer : Node3D
|
||||||
var state = session.ViewState;
|
var state = session.ViewState;
|
||||||
_pomDecals.ConsumeEvents(session, events, stepDt, ResolveEntityVisual);
|
_pomDecals.ConsumeEvents(session, events, stepDt, ResolveEntityVisual);
|
||||||
_particles.ConsumeEvents(session, events, camPos, hasCam, sampleGroundTint);
|
_particles.ConsumeEvents(session, events, camPos, hasCam, sampleGroundTint);
|
||||||
|
_ordnanceMirror.ConsumeEvents(
|
||||||
|
events,
|
||||||
|
_assetCache,
|
||||||
|
_debris,
|
||||||
|
_particles,
|
||||||
|
hasCam,
|
||||||
|
camPos,
|
||||||
|
spec => AddTransient(new TransientVfx
|
||||||
|
{
|
||||||
|
Shape = spec.IsSphere ? VfxShape.Sphere : VfxShape.Ring,
|
||||||
|
Position = spec.Position,
|
||||||
|
Velocity = spec.Velocity,
|
||||||
|
BaseRotation = spec.Rotation,
|
||||||
|
StartScale = spec.StartScale,
|
||||||
|
EndScale = spec.EndScale,
|
||||||
|
ColorStart = spec.ColorStart,
|
||||||
|
ColorEnd = spec.ColorEnd,
|
||||||
|
Age = 0f,
|
||||||
|
Lifetime = spec.Lifetime
|
||||||
|
}));
|
||||||
|
|
||||||
for (int i = 0; i < footsteps.Count; i++)
|
for (int i = 0; i < footsteps.Count; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -474,6 +514,9 @@ public partial class ArenaRenderer : Node3D
|
||||||
_debris.ClearAll();
|
_debris.ClearAll();
|
||||||
_particles.ClearAll();
|
_particles.ClearAll();
|
||||||
_transientVfx.Clear();
|
_transientVfx.Clear();
|
||||||
|
_ordnanceMirror.Clear();
|
||||||
|
_mirrorSpheres.Clear();
|
||||||
|
_mirrorRings.Clear();
|
||||||
_tireDustNextTime.Clear();
|
_tireDustNextTime.Clear();
|
||||||
_thermalVentNextTime.Clear();
|
_thermalVentNextTime.Clear();
|
||||||
_damageSmokeNextTime.Clear();
|
_damageSmokeNextTime.Clear();
|
||||||
|
|
@ -901,19 +944,48 @@ public partial class ArenaRenderer : Node3D
|
||||||
float baseY = state.Terrain.SampleHeight(d.X, d.Z);
|
float baseY = state.Terrain.SampleHeight(d.X, d.Z);
|
||||||
if (d.Module is { } mod)
|
if (d.Module is { } mod)
|
||||||
{
|
{
|
||||||
VehicleVisualInstance.ResolveDropGearVisual(_assetCache, mod, out ArrayMesh gMesh, out Vector3 gScale, out float gYOff);
|
if (mod.Procedural is { } proc)
|
||||||
entry = new DropVisualEntry
|
|
||||||
{
|
{
|
||||||
IsModule = true,
|
VehicleVisualInstance.BuildModularWeaponAssembly(
|
||||||
IsImperial = mod.IsImperial,
|
_assetCache,
|
||||||
GearMesh = gMesh,
|
proc.Assembly,
|
||||||
GearScale = gScale * 1.45f,
|
out var modParts,
|
||||||
GearYOffset = gYOff * 1.45f + 0.35f,
|
out _,
|
||||||
BaseY = baseY,
|
out _,
|
||||||
TileX = tx,
|
out float minY);
|
||||||
TileZ = tz,
|
float sc = proc.Assembly.VisualScale * 1.45f;
|
||||||
TileVersion = state.Terrain.TileVersions[tx, tz]
|
entry = new DropVisualEntry
|
||||||
};
|
{
|
||||||
|
IsModule = true,
|
||||||
|
IsImperial = mod.IsImperial,
|
||||||
|
ModularParts = modParts,
|
||||||
|
ManufacturerRoleIndex = 10f + (float)proc.Manufacturer,
|
||||||
|
DropBeaconColor = ResolveManufacturerBeaconColor(proc.Manufacturer),
|
||||||
|
GearScale = Vector3.One * sc,
|
||||||
|
GearYOffset = -minY * sc + 0.35f,
|
||||||
|
BaseY = baseY,
|
||||||
|
TileX = tx,
|
||||||
|
TileZ = tz,
|
||||||
|
TileVersion = state.Terrain.TileVersions[tx, tz]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VehicleVisualInstance.ResolveDropGearVisual(_assetCache, mod, out ArrayMesh gMesh, out Vector3 gScale, out float gYOff);
|
||||||
|
entry = new DropVisualEntry
|
||||||
|
{
|
||||||
|
IsModule = true,
|
||||||
|
IsImperial = mod.IsImperial,
|
||||||
|
GearMesh = gMesh,
|
||||||
|
DropBeaconColor = mod.IsImperial ? TouristGold * 2.2f : OlivePaint * 1.5f,
|
||||||
|
GearScale = gScale * 1.45f,
|
||||||
|
GearYOffset = gYOff * 1.45f + 0.35f,
|
||||||
|
BaseY = baseY,
|
||||||
|
TileX = tx,
|
||||||
|
TileZ = tz,
|
||||||
|
TileVersion = state.Terrain.TileVersions[tx, tz]
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -962,20 +1034,27 @@ public partial class ArenaRenderer : Node3D
|
||||||
float bob = MathF.Sin(elapsedSeconds * 2.5f + d.Id) * 0.12f;
|
float bob = MathF.Sin(elapsedSeconds * 2.5f + d.Id) * 0.12f;
|
||||||
float yaw = elapsedSeconds * 0.9f + d.Id;
|
float yaw = elapsedSeconds * 0.9f + d.Id;
|
||||||
|
|
||||||
if (entry.GearMesh is not null)
|
var gearXf = new Transform3D(
|
||||||
|
new Basis(Vector3.Up, yaw) * Basis.FromScale(entry.GearScale),
|
||||||
|
new Vector3(d.X, entry.BaseY + bob + entry.GearYOffset, d.Z));
|
||||||
|
if (entry.ModularParts is { } modParts)
|
||||||
|
{
|
||||||
|
Color custom = new(0f, 0f, entry.ManufacturerRoleIndex, 1f);
|
||||||
|
for (int p = 0; p < modParts.Length; p++)
|
||||||
|
{
|
||||||
|
Transform3D partXf = gearXf * modParts[p].LocalToGearPivot;
|
||||||
|
_partPool.Submit(modParts[p].Mesh, in partXf, in custom, wantsShadow: false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (entry.GearMesh is not null)
|
||||||
{
|
{
|
||||||
var gearXf = new Transform3D(
|
|
||||||
new Basis(Vector3.Up, yaw) * Basis.FromScale(entry.GearScale),
|
|
||||||
new Vector3(d.X, entry.BaseY + bob + entry.GearYOffset, d.Z));
|
|
||||||
_partPool.Submit(entry.GearMesh, in gearXf, new Color(0f, 0f, 5f, 1f), wantsShadow: false);
|
_partPool.Submit(entry.GearMesh, in gearXf, new Color(0f, 0f, 5f, 1f), wantsShadow: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (discCount < _dropDiscMm.InstanceCount)
|
if (discCount < _dropDiscMm.InstanceCount)
|
||||||
{
|
{
|
||||||
_dropDiscMm.SetInstanceTransform(discCount, new Transform3D(Basis.Identity, new Vector3(d.X, entry.BaseY + bob + 0.08f, d.Z)));
|
_dropDiscMm.SetInstanceTransform(discCount, new Transform3D(Basis.Identity, new Vector3(d.X, entry.BaseY + bob + 0.08f, d.Z)));
|
||||||
Color dCol = entry.IsImperial
|
Color dCol = entry.DropBeaconColor with { A = entry.IsImperial ? 0.82f : 0.72f };
|
||||||
? new Color(TouristGold.R * 2.2f, TouristGold.G * 2.2f, TouristGold.B * 2.2f, 0.82f)
|
|
||||||
: new Color(OlivePaint.R * 1.5f, OlivePaint.G * 1.5f, OlivePaint.B * 1.5f, 0.72f);
|
|
||||||
_dropDiscMm.SetInstanceCustomData(discCount, dCol);
|
_dropDiscMm.SetInstanceCustomData(discCount, dCol);
|
||||||
discCount++;
|
discCount++;
|
||||||
}
|
}
|
||||||
|
|
@ -1271,6 +1350,33 @@ public partial class ArenaRenderer : Node3D
|
||||||
EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(coreW, coreW, dist), coreCol);
|
EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(coreW, coreW, dist), coreCol);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WeaponVisualClass.GaussRail:
|
||||||
|
{
|
||||||
|
EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(0.30f, 0.30f, dist), new Color(0.25f, 1.85f, 3.4f, 0.68f));
|
||||||
|
EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(0.10f, 0.10f, dist), new Color(2.2f, 3.6f, 4.0f, 0.98f));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WeaponVisualClass.PlasmaPpc:
|
||||||
|
{
|
||||||
|
EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(0.36f, 0.36f, dist), new Color(0.18f, 2.25f, 2.65f, 0.65f));
|
||||||
|
EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(0.14f, 0.14f, dist), new Color(1.2f, 3.5f, 3.8f, 0.98f));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WeaponVisualClass.RocketSalvo:
|
||||||
|
{
|
||||||
|
EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(0.22f, 0.22f, dist), new Color(3.2f, 1.45f, 0.30f, 0.92f));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WeaponVisualClass.SwarmSmart:
|
||||||
|
{
|
||||||
|
EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(0.16f, 0.16f, dist), new Color(1.4f, 2.8f, 0.45f, 0.85f));
|
||||||
|
EmitBeam(ref beamIdx, lookBasis, mid, new Vector3(0.07f, 0.07f, dist), new Color(2.0f, 0.95f, 3.2f, 0.96f));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1300,7 +1406,8 @@ public partial class ArenaRenderer : Node3D
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((WeaponVisualClass)ev.WeaponClass != WeaponVisualClass.Explosive || ev.IsAirburst)
|
var wClass = (WeaponVisualClass)ev.WeaponClass;
|
||||||
|
if (ev.IsAirburst || wClass is not (WeaponVisualClass.Explosive or WeaponVisualClass.RocketSalvo or WeaponVisualClass.PlasmaPpc or WeaponVisualClass.SwarmSmart))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -1311,8 +1418,20 @@ public partial class ArenaRenderer : Node3D
|
||||||
normal = normal.Normalized();
|
normal = normal.Normalized();
|
||||||
|
|
||||||
bool isRecoilless = string.Equals(ev.WeaponId, "recoilless", StringComparison.Ordinal);
|
bool isRecoilless = string.Equals(ev.WeaponId, "recoilless", StringComparison.Ordinal);
|
||||||
float detSize = isRecoilless ? 3.2f : 1.7f;
|
float detSize = isRecoilless || wClass == WeaponVisualClass.RocketSalvo ? 3.2f : 1.9f;
|
||||||
float ringSize = isRecoilless ? 6.2f : 2.9f;
|
float ringSize = isRecoilless || wClass == WeaponVisualClass.RocketSalvo ? 6.2f : 3.4f;
|
||||||
|
Color coreStart = wClass switch
|
||||||
|
{
|
||||||
|
WeaponVisualClass.PlasmaPpc => new Color(0.35f, 3.2f, 3.6f, 0.92f),
|
||||||
|
WeaponVisualClass.SwarmSmart => new Color(1.9f, 3.2f, 0.6f, 0.90f),
|
||||||
|
_ => new Color(3.6f, 2.0f, 0.55f, 0.92f)
|
||||||
|
};
|
||||||
|
Color coreEnd = wClass switch
|
||||||
|
{
|
||||||
|
WeaponVisualClass.PlasmaPpc => new Color(0.10f, 0.55f, 0.85f, 0f),
|
||||||
|
WeaponVisualClass.SwarmSmart => new Color(0.55f, 0.25f, 0.85f, 0f),
|
||||||
|
_ => new Color(0.85f, 0.28f, 0.08f, 0f)
|
||||||
|
};
|
||||||
AddTransient(new TransientVfx
|
AddTransient(new TransientVfx
|
||||||
{
|
{
|
||||||
Shape = VfxShape.Sphere,
|
Shape = VfxShape.Sphere,
|
||||||
|
|
@ -1321,10 +1440,10 @@ public partial class ArenaRenderer : Node3D
|
||||||
BaseRotation = Basis.Identity,
|
BaseRotation = Basis.Identity,
|
||||||
StartScale = Vector3.One * 0.5f,
|
StartScale = Vector3.One * 0.5f,
|
||||||
EndScale = Vector3.One * detSize,
|
EndScale = Vector3.One * detSize,
|
||||||
ColorStart = new Color(3.6f, 2.0f, 0.55f, 0.92f),
|
ColorStart = coreStart,
|
||||||
ColorEnd = new Color(0.85f, 0.28f, 0.08f, 0.0f),
|
ColorEnd = coreEnd,
|
||||||
Age = 0f,
|
Age = 0f,
|
||||||
Lifetime = isRecoilless ? 0.28f : 0.20f
|
Lifetime = isRecoilless ? 0.28f : 0.22f
|
||||||
});
|
});
|
||||||
|
|
||||||
Vector3 upRef = MathF.Abs(normal.Y) > 0.92f ? Vector3.Forward : Vector3.Up;
|
Vector3 upRef = MathF.Abs(normal.Y) > 0.92f ? Vector3.Forward : Vector3.Up;
|
||||||
|
|
@ -1339,15 +1458,28 @@ public partial class ArenaRenderer : Node3D
|
||||||
BaseRotation = ringBasis,
|
BaseRotation = ringBasis,
|
||||||
StartScale = new Vector3(0.7f, 1.0f, 0.7f),
|
StartScale = new Vector3(0.7f, 1.0f, 0.7f),
|
||||||
EndScale = new Vector3(ringSize, 0.4f, ringSize),
|
EndScale = new Vector3(ringSize, 0.4f, ringSize),
|
||||||
ColorStart = new Color(3.2f, 1.65f, 0.45f, 0.92f),
|
ColorStart = coreStart,
|
||||||
ColorEnd = new Color(1.4f, 0.55f, 0.20f, 0.0f),
|
ColorEnd = coreEnd,
|
||||||
Age = 0f,
|
Age = 0f,
|
||||||
Lifetime = isRecoilless ? 0.32f : 0.22f
|
Lifetime = isRecoilless ? 0.32f : 0.24f
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
int sphereIdx = 0;
|
int sphereIdx = 0;
|
||||||
int ringIdx = 0;
|
int ringIdx = 0;
|
||||||
|
for (int i = 0; i < _mirrorSpheres.Count && sphereIdx < MaxVfxSpheres; i++)
|
||||||
|
{
|
||||||
|
_vfxSphereMm.SetInstanceTransform(sphereIdx, _mirrorSpheres[i].Xf);
|
||||||
|
_vfxSphereMm.SetInstanceCustomData(sphereIdx, _mirrorSpheres[i].Col);
|
||||||
|
sphereIdx++;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < _mirrorRings.Count && ringIdx < MaxVfxRings; i++)
|
||||||
|
{
|
||||||
|
_vfxRingMm.SetInstanceTransform(ringIdx, _mirrorRings[i].Xf);
|
||||||
|
_vfxRingMm.SetInstanceCustomData(ringIdx, _mirrorRings[i].Col);
|
||||||
|
ringIdx++;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < _transientVfx.Count; i++)
|
for (int i = 0; i < _transientVfx.Count; i++)
|
||||||
{
|
{
|
||||||
TransientVfx v = _transientVfx[i];
|
TransientVfx v = _transientVfx[i];
|
||||||
|
|
@ -1574,6 +1706,16 @@ public partial class ArenaRenderer : Node3D
|
||||||
_transientVfx.Add(vfx);
|
_transientVfx.Add(vfx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Color ResolveManufacturerBeaconColor(ManufacturerId mfg) => mfg switch
|
||||||
|
{
|
||||||
|
ManufacturerId.ScrapFrontier => new Color(2.1f, 1.35f, 0.40f, 0.82f),
|
||||||
|
ManufacturerId.KorrathiIronworks => new Color(2.6f, 1.15f, 0.22f, 0.86f),
|
||||||
|
ManufacturerId.AuralianOptics => new Color(0.55f, 2.25f, 2.65f, 0.86f),
|
||||||
|
ManufacturerId.VexNineCollective => new Color(1.45f, 2.55f, 0.45f, 0.86f),
|
||||||
|
ManufacturerId.ThalassanForge => new Color(0.35f, 1.95f, 2.85f, 0.86f),
|
||||||
|
_ => TouristGold * 2.2f
|
||||||
|
};
|
||||||
|
|
||||||
private static void ClearChildren(Node parent)
|
private static void ClearChildren(Node parent)
|
||||||
{
|
{
|
||||||
for (int i = parent.GetChildCount() - 1; i >= 0; i--)
|
for (int i = parent.GetChildCount() - 1; i >= 0; i--)
|
||||||
|
|
|
||||||
627
client/ClientOrdnanceMirror.cs
Normal file
627
client/ClientOrdnanceMirror.cs
Normal file
|
|
@ -0,0 +1,627 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Godot;
|
||||||
|
using RustToDust.Core;
|
||||||
|
using RustToDust.Ymir;
|
||||||
|
|
||||||
|
namespace RustToDust.Client;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Client-side kinematic mirror of active <see cref="OrdnanceRuntime"/> projectiles, loitering drones,
|
||||||
|
/// proximity mines, and thermal pools driven strictly by <c>[Union(13)]</c> <see cref="OrdnanceNodeEvent"/>
|
||||||
|
/// (identical behavior in Solo and RemoteClient multiplayer, zero per-projectile <see cref="Node3D"/>s,
|
||||||
|
/// zero material clones).
|
||||||
|
/// </summary>
|
||||||
|
public sealed class ClientOrdnanceMirror
|
||||||
|
{
|
||||||
|
public const int PoolCapacity = OrdnanceRuntime.PoolCapacity;
|
||||||
|
|
||||||
|
public readonly record struct TransientVfxSpec(
|
||||||
|
bool IsSphere,
|
||||||
|
Vector3 Position,
|
||||||
|
Vector3 Velocity,
|
||||||
|
Basis Rotation,
|
||||||
|
Vector3 StartScale,
|
||||||
|
Vector3 EndScale,
|
||||||
|
Color ColorStart,
|
||||||
|
Color ColorEnd,
|
||||||
|
float Lifetime);
|
||||||
|
|
||||||
|
private struct MirroredSlot
|
||||||
|
{
|
||||||
|
public bool Active;
|
||||||
|
public int OrdnanceId;
|
||||||
|
public int ParentOrdnanceId;
|
||||||
|
public ProceduralWeaponKey? WeaponKey;
|
||||||
|
public byte NodeDefIndex;
|
||||||
|
public OrdnanceNodeDef? Def;
|
||||||
|
public OrdnanceVisualShape VisualShape;
|
||||||
|
public Color Color;
|
||||||
|
public float ManufacturerRoleIndex;
|
||||||
|
public Vector3 Pos;
|
||||||
|
public Vector3 Vel;
|
||||||
|
public Vector3 AnchorPos;
|
||||||
|
public int TargetEntityId;
|
||||||
|
public bool TargetIsSpectator;
|
||||||
|
public float Age;
|
||||||
|
public float StageAge;
|
||||||
|
public float OrbitAngle;
|
||||||
|
public float TrailTimer;
|
||||||
|
public float EmberTimer;
|
||||||
|
public bool Armed;
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly MirroredSlot[] _slots = new MirroredSlot[PoolCapacity];
|
||||||
|
private readonly Dictionary<int, int> _slotById = new(PoolCapacity);
|
||||||
|
private int _activeCount;
|
||||||
|
|
||||||
|
public int ActiveCount => _activeCount;
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
Array.Clear(_slots, 0, _slots.Length);
|
||||||
|
_slotById.Clear();
|
||||||
|
_activeCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryGetMirroredPose(int ordnanceId, out Vector3 pos, out OrdnanceVisualShape shape)
|
||||||
|
{
|
||||||
|
if (_slotById.TryGetValue(ordnanceId, out int idx) && _slots[idx].Active)
|
||||||
|
{
|
||||||
|
pos = _slots[idx].Pos;
|
||||||
|
shape = _slots[idx].VisualShape;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
pos = Vector3.Zero;
|
||||||
|
shape = OrdnanceVisualShape.None;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConsumeEvents(
|
||||||
|
IReadOnlyList<ISimEvent> events,
|
||||||
|
VehicleAssetCache cache,
|
||||||
|
DebrisSystem debris,
|
||||||
|
ParticlePool particles,
|
||||||
|
bool hasCam,
|
||||||
|
Vector3 camPos,
|
||||||
|
Action<TransientVfxSpec> emitTransient)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < events.Count; i++)
|
||||||
|
{
|
||||||
|
if (events[i] is MatchResetEvent)
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (events[i] is not OrdnanceNodeEvent ev)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var kind = (OrdnanceEventKind)ev.Kind;
|
||||||
|
Vector3 pos = new(ev.PosX, ev.PosY, ev.PosZ);
|
||||||
|
Vector3 vel = new(ev.VelX, ev.VelY, ev.VelZ);
|
||||||
|
Color col = DecodeColorRgba(ev.ColorRgba);
|
||||||
|
OrdnanceNodeDef? def = ResolveNodeDef(ev.WeaponKey, ev.NodeDefIndex);
|
||||||
|
var shape = (OrdnanceVisualShape)ev.VisualShape;
|
||||||
|
if (shape == OrdnanceVisualShape.None && def is not null)
|
||||||
|
{
|
||||||
|
shape = def.VisualShape;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (kind)
|
||||||
|
{
|
||||||
|
case OrdnanceEventKind.Spawned:
|
||||||
|
UpsertSlot(ev, pos, vel, col, def, shape);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OrdnanceEventKind.StageTransition:
|
||||||
|
{
|
||||||
|
bool wasSabot = false;
|
||||||
|
if (ev.ParentOrdnanceId != 0 && _slotById.TryGetValue(ev.ParentOrdnanceId, out int parentIdx) && _slots[parentIdx].Active)
|
||||||
|
{
|
||||||
|
wasSabot = _slots[parentIdx].VisualShape == OrdnanceVisualShape.SabotCarrier;
|
||||||
|
RemoveAtSlot(parentIdx);
|
||||||
|
}
|
||||||
|
UpsertSlot(ev, pos, vel, col, def, shape);
|
||||||
|
|
||||||
|
if (wasSabot)
|
||||||
|
{
|
||||||
|
float roleIdx = ev.WeaponKey is { } wk ? 10f + Math.Clamp((int)wk.Manufacturer, 0, 4) : 11f;
|
||||||
|
var petalTpl = cache.GetOrLoadWeaponPart("mz_slotted_brake");
|
||||||
|
Vector3 dir = vel.LengthSquared() > 1e-3f ? vel.Normalized() : Vector3.Forward;
|
||||||
|
Vector3 right = dir.Cross(Vector3.Up);
|
||||||
|
if (right.LengthSquared() < 1e-4f) right = Vector3.Right;
|
||||||
|
right = right.Normalized();
|
||||||
|
|
||||||
|
for (int side = -1; side <= 1; side += 2)
|
||||||
|
{
|
||||||
|
Vector3 pPos = pos + right * (side * 0.28f);
|
||||||
|
Transform3D petalXf = new(Basis.FromScale(Vector3.One * 0.65f), pPos);
|
||||||
|
debris.SpawnDetachedPart(
|
||||||
|
petalTpl.SingleSurfaceMesh,
|
||||||
|
petalXf,
|
||||||
|
pos - right * (side * 0.45f),
|
||||||
|
vel * 0.35f,
|
||||||
|
roleIdx,
|
||||||
|
impulseScale: 0.75f,
|
||||||
|
applyScorch: true,
|
||||||
|
lifetime: 2.2f);
|
||||||
|
}
|
||||||
|
particles.EmitOrdnanceBurst(pos, col, sparkCount: 4, radiusScale: 0.65f, camPos, hasCam);
|
||||||
|
}
|
||||||
|
else if (def?.Motion == OrdnanceMotion.LoiterOrbit)
|
||||||
|
{
|
||||||
|
emitTransient(new TransientVfxSpec(
|
||||||
|
IsSphere: false,
|
||||||
|
Position: pos,
|
||||||
|
Velocity: Vector3.Zero,
|
||||||
|
Rotation: Basis.Identity,
|
||||||
|
StartScale: new Vector3(0.6f, 1.0f, 0.6f),
|
||||||
|
EndScale: new Vector3(3.6f, 0.5f, 3.6f),
|
||||||
|
ColorStart: (col * 2.4f) with { A = 0.85f },
|
||||||
|
ColorEnd: col with { A = 0f },
|
||||||
|
Lifetime: 0.30f));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case OrdnanceEventKind.Split:
|
||||||
|
RemoveById(ev.OrdnanceId);
|
||||||
|
particles.EmitOrdnanceBurst(pos, col, sparkCount: 6, radiusScale: 1.05f, camPos, hasCam);
|
||||||
|
emitTransient(new TransientVfxSpec(
|
||||||
|
IsSphere: false,
|
||||||
|
Position: pos,
|
||||||
|
Velocity: Vector3.Zero,
|
||||||
|
Rotation: Basis.Identity,
|
||||||
|
StartScale: new Vector3(0.7f, 1.0f, 0.7f),
|
||||||
|
EndScale: new Vector3(5.2f, 0.5f, 5.2f),
|
||||||
|
ColorStart: (col * 2.8f) with { A = 0.92f },
|
||||||
|
ColorEnd: col with { A = 0f },
|
||||||
|
Lifetime: 0.28f));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OrdnanceEventKind.Detonated:
|
||||||
|
{
|
||||||
|
RemoveById(ev.OrdnanceId);
|
||||||
|
float splashR = def is not null && def.SplashRadius > 0.5f ? def.SplashRadius : 4.2f;
|
||||||
|
particles.EmitOrdnanceBurst(pos, col, sparkCount: 6, radiusScale: Math.Clamp(splashR / 4.5f, 0.7f, 1.6f), camPos, hasCam);
|
||||||
|
emitTransient(new TransientVfxSpec(
|
||||||
|
IsSphere: true,
|
||||||
|
Position: pos + Vector3.Up * 0.2f,
|
||||||
|
Velocity: Vector3.Up * 1.2f,
|
||||||
|
Rotation: Basis.Identity,
|
||||||
|
StartScale: Vector3.One * 0.55f,
|
||||||
|
EndScale: Vector3.One * Math.Clamp(splashR * 0.75f, 1.8f, 4.8f),
|
||||||
|
ColorStart: new Color(col.R * 3.2f, col.G * 3.2f, col.B * 3.2f, 0.92f),
|
||||||
|
ColorEnd: new Color(col.R * 0.8f, col.G * 0.3f, col.B * 0.2f, 0f),
|
||||||
|
Lifetime: 0.26f));
|
||||||
|
emitTransient(new TransientVfxSpec(
|
||||||
|
IsSphere: false,
|
||||||
|
Position: pos + Vector3.Up * 0.16f,
|
||||||
|
Velocity: Vector3.Zero,
|
||||||
|
Rotation: Basis.Identity,
|
||||||
|
StartScale: new Vector3(0.7f, 1f, 0.7f),
|
||||||
|
EndScale: new Vector3(Math.Clamp(splashR * 1.35f, 2.8f, 8.5f), 0.4f, Math.Clamp(splashR * 1.35f, 2.8f, 8.5f)),
|
||||||
|
ColorStart: new Color(col.R * 2.9f, col.G * 2.9f, col.B * 2.9f, 0.90f),
|
||||||
|
ColorEnd: col with { A = 0f },
|
||||||
|
Lifetime: 0.30f));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case OrdnanceEventKind.Intercepted:
|
||||||
|
RemoveById(ev.OrdnanceId);
|
||||||
|
particles.EmitOrdnanceBurst(pos, new Color(1.0f, 0.75f, 0.28f), sparkCount: 5, radiusScale: 0.7f, camPos, hasCam);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OrdnanceEventKind.Expired:
|
||||||
|
RemoveById(ev.OrdnanceId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StepAndSubmit(
|
||||||
|
float dt,
|
||||||
|
IClientArenaSession session,
|
||||||
|
VehicleAssetCache cache,
|
||||||
|
MultiMeshPartPool partPool,
|
||||||
|
ParticlePool particles,
|
||||||
|
TerrainField terrain,
|
||||||
|
bool hasCam,
|
||||||
|
Vector3 camPos,
|
||||||
|
Action<Transform3D, Color> submitActiveRing,
|
||||||
|
Action<Transform3D, Color> submitActiveSphere)
|
||||||
|
{
|
||||||
|
if (_activeCount == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float stepDt = float.IsFinite(dt) && dt > 0f ? Math.Clamp(dt, 0f, 0.05f) : 0f;
|
||||||
|
var state = session.ViewState;
|
||||||
|
|
||||||
|
var sabotMesh = cache.GetOrLoadWeaponPart("brl_sabot_rail").SingleSurfaceMesh;
|
||||||
|
var rocketMesh = cache.GetOrLoadWeaponPart("mz_mirv_warhead").SingleSurfaceMesh;
|
||||||
|
var droneMesh = cache.GetOrLoadWeaponPart("mz_loiter_aero_fin").SingleSurfaceMesh;
|
||||||
|
var brakeMesh = cache.GetOrLoadWeaponPart("mz_slotted_brake").SingleSurfaceMesh;
|
||||||
|
|
||||||
|
for (int i = 0; i < PoolCapacity; i++)
|
||||||
|
{
|
||||||
|
if (!_slots[i].Active)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ref MirroredSlot s = ref _slots[i];
|
||||||
|
var def = s.Def;
|
||||||
|
float maxLife = def is not null && def.MaxLifetime > 0f ? def.MaxLifetime : 30f;
|
||||||
|
|
||||||
|
if (stepDt > 0f)
|
||||||
|
{
|
||||||
|
s.Age += stepDt;
|
||||||
|
s.StageAge += stepDt;
|
||||||
|
if (s.Age > maxLife + 2.5f)
|
||||||
|
{
|
||||||
|
RemoveAtSlot(i);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (def is not null && !s.Armed && s.StageAge >= def.ArmDelay)
|
||||||
|
{
|
||||||
|
s.Armed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
AdvanceSlotKinematics(ref s, def, state, terrain, stepDt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasCam && s.Pos.DistanceSquaredTo(camPos) > 340f * 340f)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isThermalPool = (def?.IsThermalPool == true) || s.VisualShape == OrdnanceVisualShape.Pool;
|
||||||
|
if (isThermalPool)
|
||||||
|
{
|
||||||
|
float radius = def is not null && def.WhileAlive is { RadialRadius: > 0.5f }
|
||||||
|
? def.WhileAlive.RadialRadius
|
||||||
|
: (def is not null && def.SplashRadius > 0.5f ? def.SplashRadius : 5.5f);
|
||||||
|
float pulse = 0.88f + 0.14f * MathF.Sin(s.StageAge * 7.5f + s.OrdnanceId);
|
||||||
|
float groundY = terrain.SampleHeight(s.Pos.X, s.Pos.Z);
|
||||||
|
Vector3 poolPos = new(s.Pos.X, MathF.Max(s.Pos.Y, groundY + 0.14f), s.Pos.Z);
|
||||||
|
|
||||||
|
Transform3D ringXf = new(Basis.FromScale(new Vector3(radius * 2f * pulse, 0.35f, radius * 2f * pulse)), poolPos);
|
||||||
|
submitActiveRing(ringXf, new Color(s.Color.R * 2.6f, s.Color.G * 2.6f, s.Color.B * 2.6f, 0.78f));
|
||||||
|
|
||||||
|
Transform3D discXf = new(Basis.FromScale(new Vector3(radius * 1.4f * pulse, 0.14f, radius * 1.4f * pulse)), poolPos - new Vector3(0f, 0.04f, 0f));
|
||||||
|
submitActiveSphere(discXf, new Color(s.Color.R * 2.1f, s.Color.G * 2.1f, s.Color.B * 2.1f, 0.42f));
|
||||||
|
|
||||||
|
if (stepDt > 0f)
|
||||||
|
{
|
||||||
|
s.EmberTimer += stepDt;
|
||||||
|
if (s.EmberTimer >= 0.11f)
|
||||||
|
{
|
||||||
|
s.EmberTimer = 0f;
|
||||||
|
particles.EmitThermalPoolEmber(poolPos, radius, s.Color, camPos, hasCam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s.VisualShape == OrdnanceVisualShape.Mine || def?.Motion == OrdnanceMotion.StationaryMine)
|
||||||
|
{
|
||||||
|
float groundY = terrain.SampleHeight(s.Pos.X, s.Pos.Z);
|
||||||
|
Vector3 minePos = new(s.Pos.X, MathF.Max(s.Pos.Y, groundY + 0.10f), s.Pos.Z);
|
||||||
|
Basis upright = new Basis(Vector3.Right, -MathF.PI * 0.5f) * Basis.FromScale(Vector3.One * 1.05f);
|
||||||
|
Transform3D mineXf = new(upright, minePos);
|
||||||
|
float blink = s.Armed ? (0.45f + 0.55f * MathF.Max(0f, MathF.Sin(s.StageAge * 9.5f + s.OrdnanceId))) : 0f;
|
||||||
|
partPool.Submit(rocketMesh, in mineXf, new Color(0f, blink * 0.6f, s.ManufacturerRoleIndex, 1f), wantsShadow: false);
|
||||||
|
|
||||||
|
if (s.Armed)
|
||||||
|
{
|
||||||
|
float proxR = def is not null && def.ProximityRadius > 0.5f ? def.ProximityRadius : 6.0f;
|
||||||
|
float ringPulse = 0.92f + 0.08f * MathF.Sin(s.StageAge * 6f);
|
||||||
|
Transform3D warnXf = new(Basis.FromScale(new Vector3(proxR * 0.55f * ringPulse, 0.18f, proxR * 0.55f * ringPulse)), minePos + new Vector3(0f, 0.08f, 0f));
|
||||||
|
submitActiveRing(warnXf, new Color(s.Color.R * 2.2f, s.Color.G * 2.2f, s.Color.B * 2.2f, 0.25f + 0.35f * blink));
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s.VisualShape == OrdnanceVisualShape.Drone || def?.Motion == OrdnanceMotion.LoiterOrbit)
|
||||||
|
{
|
||||||
|
Vector3 dir = s.Vel.LengthSquared() > 1e-3f ? s.Vel.Normalized() : Vector3.Forward;
|
||||||
|
Vector3 up = MathF.Abs(dir.Dot(Vector3.Up)) > 0.95f ? Vector3.Right : Vector3.Up;
|
||||||
|
Basis orient = Basis.LookingAt(-dir, up);
|
||||||
|
if (def?.Motion == OrdnanceMotion.LoiterOrbit)
|
||||||
|
{
|
||||||
|
orient *= new Basis(Vector3.Forward, 0.32f);
|
||||||
|
}
|
||||||
|
Transform3D droneXf = new(orient * Basis.FromScale(Vector3.One * 2.4f), s.Pos);
|
||||||
|
partPool.Submit(droneMesh, in droneXf, new Color(0f, 0.35f, s.ManufacturerRoleIndex, 1f), wantsShadow: false);
|
||||||
|
|
||||||
|
if (def?.Motion == OrdnanceMotion.LoiterOrbit)
|
||||||
|
{
|
||||||
|
float scanPulse = 0.85f + 0.15f * MathF.Sin(s.StageAge * 8f);
|
||||||
|
Transform3D haloXf = new(Basis.FromScale(new Vector3(2.4f * scanPulse, 0.25f, 2.4f * scanPulse)), s.Pos - new Vector3(0f, 0.45f, 0f));
|
||||||
|
submitActiveRing(haloXf, new Color(s.Color.R * 2.5f, s.Color.G * 2.5f, s.Color.B * 2.5f, 0.58f));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stepDt > 0f)
|
||||||
|
{
|
||||||
|
s.TrailTimer += stepDt;
|
||||||
|
if (s.TrailTimer >= 0.055f)
|
||||||
|
{
|
||||||
|
s.TrailTimer = 0f;
|
||||||
|
particles.EmitOrdnanceTrail(s.Pos, s.Vel, s.Color, isRocket: def?.Motion != OrdnanceMotion.LoiterOrbit, camPos, hasCam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rocket, SabotCarrier, or Bolt projectile in flight
|
||||||
|
{
|
||||||
|
Vector3 dir = s.Vel.LengthSquared() > 1e-3f ? s.Vel.Normalized() : Vector3.Forward;
|
||||||
|
Vector3 up = MathF.Abs(dir.Dot(Vector3.Up)) > 0.95f ? Vector3.Right : Vector3.Up;
|
||||||
|
Basis orient = Basis.LookingAt(-dir, up);
|
||||||
|
|
||||||
|
ArrayMesh projMesh = s.VisualShape switch
|
||||||
|
{
|
||||||
|
OrdnanceVisualShape.SabotCarrier => sabotMesh,
|
||||||
|
OrdnanceVisualShape.Rocket => rocketMesh,
|
||||||
|
_ => brakeMesh
|
||||||
|
};
|
||||||
|
float projScale = s.VisualShape switch
|
||||||
|
{
|
||||||
|
OrdnanceVisualShape.SabotCarrier => 1.15f,
|
||||||
|
OrdnanceVisualShape.Rocket => 1.55f,
|
||||||
|
_ => 1.0f
|
||||||
|
};
|
||||||
|
|
||||||
|
Transform3D projXf = new(orient * Basis.FromScale(Vector3.One * projScale), s.Pos);
|
||||||
|
bool isRocket = s.VisualShape == OrdnanceVisualShape.Rocket ||
|
||||||
|
def?.Motion is OrdnanceMotion.RocketBoosted or OrdnanceMotion.HomingMissile;
|
||||||
|
partPool.Submit(projMesh, in projXf, new Color(0f, isRocket ? 0.65f : 0.25f, s.ManufacturerRoleIndex, 1f), wantsShadow: false);
|
||||||
|
|
||||||
|
if (isRocket)
|
||||||
|
{
|
||||||
|
Transform3D thrusterXf = new(Basis.FromScale(Vector3.One * 0.42f), s.Pos - dir * 0.22f);
|
||||||
|
submitActiveSphere(thrusterXf, new Color(s.Color.R * 3.2f, s.Color.G * 3.2f, s.Color.B * 3.2f, 0.90f));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stepDt > 0f)
|
||||||
|
{
|
||||||
|
s.TrailTimer += stepDt;
|
||||||
|
if (s.TrailTimer >= (isRocket ? 0.035f : 0.055f))
|
||||||
|
{
|
||||||
|
s.TrailTimer = 0f;
|
||||||
|
particles.EmitOrdnanceTrail(s.Pos - dir * 0.18f, s.Vel, s.Color, isRocket, camPos, hasCam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void AdvanceSlotKinematics(
|
||||||
|
ref MirroredSlot s,
|
||||||
|
OrdnanceNodeDef? def,
|
||||||
|
MatchState state,
|
||||||
|
TerrainField terrain,
|
||||||
|
float dt)
|
||||||
|
{
|
||||||
|
OrdnanceMotion motion = def?.Motion ?? OrdnanceMotion.Ballistic;
|
||||||
|
switch (motion)
|
||||||
|
{
|
||||||
|
case OrdnanceMotion.Ballistic:
|
||||||
|
s.Vel.Y -= 19.6f * (def?.GravityScale ?? 1f) * dt;
|
||||||
|
s.Pos += s.Vel * dt;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OrdnanceMotion.RocketBoosted:
|
||||||
|
{
|
||||||
|
float burnTime = def?.BurnTime ?? 1.4f;
|
||||||
|
if (s.StageAge <= burnTime && (def?.ThrustAccel ?? 0f) > 0f)
|
||||||
|
{
|
||||||
|
Vector3 dir = s.Vel.LengthSquared() > 1e-4f ? s.Vel.Normalized() : Vector3.Forward;
|
||||||
|
float speed = s.Vel.Length();
|
||||||
|
float maxSpd = def!.MaxSpeed > 0f ? def.MaxSpeed : 360f;
|
||||||
|
float nextSpd = MathF.Min(maxSpd, speed + def.ThrustAccel * dt);
|
||||||
|
s.Vel = dir * nextSpd;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s.Vel.Y -= 19.6f * (def?.GravityScale ?? 0.25f) * dt;
|
||||||
|
}
|
||||||
|
s.Pos += s.Vel * dt;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case OrdnanceMotion.HomingMissile:
|
||||||
|
{
|
||||||
|
if (s.TargetEntityId >= 0)
|
||||||
|
{
|
||||||
|
Vector3 targetPt = Vector3.Zero;
|
||||||
|
bool hasTarget = false;
|
||||||
|
if (!s.TargetIsSpectator && s.TargetEntityId < state.Contenders.Count)
|
||||||
|
{
|
||||||
|
var tc = state.Contenders[s.TargetEntityId];
|
||||||
|
if (tc.IsGroundedActive)
|
||||||
|
{
|
||||||
|
targetPt = new Vector3(tc.X, tc.Y + tc.Grid.Spec.HalfHeight * 0.35f, tc.Z);
|
||||||
|
hasTarget = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (s.TargetIsSpectator)
|
||||||
|
{
|
||||||
|
for (int k = 0; k < state.Spectators.Spectators.Count; k++)
|
||||||
|
{
|
||||||
|
var sp = state.Spectators.Spectators[k];
|
||||||
|
if (sp.Id == s.TargetEntityId && sp.Alive)
|
||||||
|
{
|
||||||
|
targetPt = new Vector3(sp.X, sp.Y + sp.Grid.Spec.HalfHeight * 0.35f, sp.Z);
|
||||||
|
hasTarget = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasTarget && (targetPt - s.Pos).LengthSquared() > 1e-3f)
|
||||||
|
{
|
||||||
|
Vector3 desiredDir = (targetPt - s.Pos).Normalized();
|
||||||
|
Vector3 curDir = s.Vel.LengthSquared() > 1e-4f ? s.Vel.Normalized() : desiredDir;
|
||||||
|
float maxTurn = (def?.TurnRateRad ?? 4.5f) * dt;
|
||||||
|
float dot = Math.Clamp(curDir.Dot(desiredDir), -1f, 1f);
|
||||||
|
float angle = MathF.Acos(dot);
|
||||||
|
Vector3 newDir = angle <= maxTurn || angle < 1e-4f
|
||||||
|
? desiredDir
|
||||||
|
: curDir.Lerp(desiredDir, maxTurn / angle).Normalized();
|
||||||
|
float spd = s.Vel.Length();
|
||||||
|
float maxSpd = def is not null && def.MaxSpeed > 0f ? def.MaxSpeed : MathF.Max(spd, 115f);
|
||||||
|
spd = MathF.Min(maxSpd, spd + (def?.ThrustAccel ?? 90f) * dt);
|
||||||
|
s.Vel = newDir * spd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.Pos += s.Vel * dt;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case OrdnanceMotion.LoiterOrbit:
|
||||||
|
{
|
||||||
|
float orbitSpeed = def?.LoiterOrbitSpeedRad ?? 1.45f;
|
||||||
|
float radius = def?.LoiterOrbitRadius ?? 15f;
|
||||||
|
float agl = def?.LoiterAltitudeAgl ?? 35f;
|
||||||
|
s.OrbitAngle += orbitSpeed * dt;
|
||||||
|
float ox = s.AnchorPos.X + MathF.Cos(s.OrbitAngle) * radius;
|
||||||
|
float oz = s.AnchorPos.Z + MathF.Sin(s.OrbitAngle) * radius;
|
||||||
|
float oy = terrain.SampleHeight(ox, oz) + agl;
|
||||||
|
Vector3 nextPos = new(ox, oy, oz);
|
||||||
|
s.Vel = (nextPos - s.Pos) / MathF.Max(1e-4f, dt);
|
||||||
|
s.Pos = nextPos;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case OrdnanceMotion.StationaryMine:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpsertSlot(
|
||||||
|
OrdnanceNodeEvent ev,
|
||||||
|
Vector3 pos,
|
||||||
|
Vector3 vel,
|
||||||
|
Color col,
|
||||||
|
OrdnanceNodeDef? def,
|
||||||
|
OrdnanceVisualShape shape)
|
||||||
|
{
|
||||||
|
if (_slotById.TryGetValue(ev.OrdnanceId, out int existing))
|
||||||
|
{
|
||||||
|
ref var slot = ref _slots[existing];
|
||||||
|
slot.Pos = pos;
|
||||||
|
slot.Vel = vel;
|
||||||
|
slot.AnchorPos = pos;
|
||||||
|
slot.TargetEntityId = ev.TargetEntityId;
|
||||||
|
slot.TargetIsSpectator = ev.TargetIsSpectator;
|
||||||
|
slot.Def = def;
|
||||||
|
slot.VisualShape = shape;
|
||||||
|
slot.Color = col;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int freeIdx = -1;
|
||||||
|
for (int i = 0; i < PoolCapacity; i++)
|
||||||
|
{
|
||||||
|
if (!_slots[i].Active)
|
||||||
|
{
|
||||||
|
freeIdx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (freeIdx < 0)
|
||||||
|
{
|
||||||
|
// Evict oldest slot to stay strictly bounded under PoolCapacity
|
||||||
|
float maxAge = -1f;
|
||||||
|
int oldest = 0;
|
||||||
|
for (int i = 0; i < PoolCapacity; i++)
|
||||||
|
{
|
||||||
|
if (_slots[i].Age > maxAge)
|
||||||
|
{
|
||||||
|
maxAge = _slots[i].Age;
|
||||||
|
oldest = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RemoveAtSlot(oldest);
|
||||||
|
freeIdx = oldest;
|
||||||
|
}
|
||||||
|
|
||||||
|
float mfgRole = ev.WeaponKey is { } wk ? 10f + Math.Clamp((int)wk.Manufacturer, 0, 4) : 5f;
|
||||||
|
_slots[freeIdx] = new MirroredSlot
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
OrdnanceId = ev.OrdnanceId,
|
||||||
|
ParentOrdnanceId = ev.ParentOrdnanceId,
|
||||||
|
WeaponKey = ev.WeaponKey,
|
||||||
|
NodeDefIndex = ev.NodeDefIndex,
|
||||||
|
Def = def,
|
||||||
|
VisualShape = shape,
|
||||||
|
Color = col,
|
||||||
|
ManufacturerRoleIndex = mfgRole,
|
||||||
|
Pos = pos,
|
||||||
|
Vel = vel,
|
||||||
|
AnchorPos = pos,
|
||||||
|
TargetEntityId = ev.TargetEntityId,
|
||||||
|
TargetIsSpectator = ev.TargetIsSpectator,
|
||||||
|
Age = 0f,
|
||||||
|
StageAge = 0f,
|
||||||
|
OrbitAngle = 0f,
|
||||||
|
TrailTimer = 0f,
|
||||||
|
EmberTimer = 0f,
|
||||||
|
Armed = def is null || def.ArmDelay <= 0f
|
||||||
|
};
|
||||||
|
_slotById[ev.OrdnanceId] = freeIdx;
|
||||||
|
_activeCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveById(int ordnanceId)
|
||||||
|
{
|
||||||
|
if (_slotById.TryGetValue(ordnanceId, out int idx))
|
||||||
|
{
|
||||||
|
RemoveAtSlot(idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveAtSlot(int idx)
|
||||||
|
{
|
||||||
|
if (!_slots[idx].Active)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_slotById.Remove(_slots[idx].OrdnanceId);
|
||||||
|
_slots[idx] = default;
|
||||||
|
_activeCount = Math.Max(0, _activeCount - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static OrdnanceNodeDef? ResolveNodeDef(ProceduralWeaponKey? key, byte nodeDefIndex)
|
||||||
|
{
|
||||||
|
if (!key.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var spec = ProceduralWeaponGenerator.Generate(key.Value);
|
||||||
|
if (nodeDefIndex < spec.FlattenedNodes.Length)
|
||||||
|
{
|
||||||
|
return spec.FlattenedNodes[nodeDefIndex];
|
||||||
|
}
|
||||||
|
return spec.RootNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Color DecodeColorRgba(uint rgba)
|
||||||
|
{
|
||||||
|
if (rgba == 0)
|
||||||
|
{
|
||||||
|
return new Color(1.0f, 0.72f, 0.28f, 1.0f);
|
||||||
|
}
|
||||||
|
float r = ((rgba >> 24) & 0xFF) / 255f;
|
||||||
|
float g = ((rgba >> 16) & 0xFF) / 255f;
|
||||||
|
float b = ((rgba >> 8) & 0xFF) / 255f;
|
||||||
|
return new Color(r, g, b, 1.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
125
client/Hud.cs
125
client/Hud.cs
|
|
@ -87,6 +87,7 @@ public partial class Hud : CanvasLayer
|
||||||
private int _selectedCargoIndex = -1;
|
private int _selectedCargoIndex = -1;
|
||||||
private int _lastCargoHash = -1;
|
private int _lastCargoHash = -1;
|
||||||
private bool _garageExpanded;
|
private bool _garageExpanded;
|
||||||
|
private Vector2I? _lastHoveredCell;
|
||||||
|
|
||||||
public event Action<string, string>? JoinRequested;
|
public event Action<string, string>? JoinRequested;
|
||||||
public event Action<int, string>? HostRequested;
|
public event Action<int, string>? HostRequested;
|
||||||
|
|
@ -125,6 +126,10 @@ public partial class Hud : CanvasLayer
|
||||||
}
|
}
|
||||||
internal Rect2 BottomLeftPanelRect => _bottomLeftPanel.GetGlobalRect();
|
internal Rect2 BottomLeftPanelRect => _bottomLeftPanel.GetGlobalRect();
|
||||||
internal Rect2 ChyronPanelRect => _chyronPanel.GetGlobalRect();
|
internal Rect2 ChyronPanelRect => _chyronPanel.GetGlobalRect();
|
||||||
|
internal string HoverLabelText => _hoverLabel.Text;
|
||||||
|
internal string PromptLabelText => _promptLabel.Text;
|
||||||
|
internal string GarageDetailsText => _garageDetails.Text;
|
||||||
|
internal void SimulateCellHover(Vector2I? cell, HardpointSpec? hp) => OnSchematicHoverChanged(cell, hp);
|
||||||
|
|
||||||
public IEnumerable<ShaderMaterial> GetChromeMaterials()
|
public IEnumerable<ShaderMaterial> GetChromeMaterials()
|
||||||
{
|
{
|
||||||
|
|
@ -217,8 +222,11 @@ public partial class Hud : CanvasLayer
|
||||||
case HitImpactEvent hit:
|
case HitImpactEvent hit:
|
||||||
if (hit.TargetKind == (byte)HitTargetKind.Contender && hit.TargetId == localContenderId)
|
if (hit.TargetKind == (byte)HitTargetKind.Contender && hit.TargetId == localContenderId)
|
||||||
{
|
{
|
||||||
_crosshair?.PushTestHitArc(hit.SourceX, hit.SourceZ, (WeaponVisualClass)hit.WeaponClass);
|
var wc = (WeaponVisualClass)hit.WeaponClass;
|
||||||
float pulse = (WeaponVisualClass)hit.WeaponClass == WeaponVisualClass.Explosive ? 0.95f : 0.62f;
|
_crosshair?.PushTestHitArc(hit.SourceX, hit.SourceZ, wc);
|
||||||
|
float pulse = wc is WeaponVisualClass.Explosive or WeaponVisualClass.RocketSalvo or WeaponVisualClass.GaussRail
|
||||||
|
? 0.95f
|
||||||
|
: 0.62f;
|
||||||
_damagePulse = MathF.Max(_damagePulse, pulse);
|
_damagePulse = MathF.Max(_damagePulse, pulse);
|
||||||
}
|
}
|
||||||
bool targetIsVehicle = hit.TargetKind == (byte)HitTargetKind.Contender
|
bool targetIsVehicle = hit.TargetKind == (byte)HitTargetKind.Contender
|
||||||
|
|
@ -472,9 +480,14 @@ public partial class Hud : CanvasLayer
|
||||||
_schematic.SetGrid(player.Grid, _selectedCargoIndex);
|
_schematic.SetGrid(player.Grid, _selectedCargoIndex);
|
||||||
SyncCargoButtons(player.Grid);
|
SyncCargoButtons(player.Grid);
|
||||||
|
|
||||||
|
if (_lastHoveredCell is null)
|
||||||
|
{
|
||||||
|
UpdateCargoSelectionTooltip(player.Grid);
|
||||||
|
}
|
||||||
|
|
||||||
if (_garageExpanded)
|
if (_garageExpanded)
|
||||||
{
|
{
|
||||||
_garageDetails.Text = BuildGarageDetails(player.Grid);
|
_garageDetails.Text = BuildGarageDetails(player.Grid, _selectedCargoIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Broadcast Chyron
|
// Broadcast Chyron
|
||||||
|
|
@ -609,9 +622,15 @@ public partial class Hud : CanvasLayer
|
||||||
_netStatusLabel.AddThemeFontSizeOverride("font_size", 12);
|
_netStatusLabel.AddThemeFontSizeOverride("font_size", 12);
|
||||||
vbox.AddChild(_netStatusLabel);
|
vbox.AddChild(_netStatusLabel);
|
||||||
|
|
||||||
_promptLabel = new Label { Text = "", Visible = false };
|
_promptLabel = new Label
|
||||||
|
{
|
||||||
|
Text = "",
|
||||||
|
Visible = false,
|
||||||
|
AutowrapMode = TextServer.AutowrapMode.Word,
|
||||||
|
CustomMinimumSize = new Vector2(336f, 0f)
|
||||||
|
};
|
||||||
_promptLabel.AddThemeColorOverride("font_color", CyanCol);
|
_promptLabel.AddThemeColorOverride("font_color", CyanCol);
|
||||||
_promptLabel.AddThemeFontSizeOverride("font_size", 14);
|
_promptLabel.AddThemeFontSizeOverride("font_size", 13);
|
||||||
vbox.AddChild(_promptLabel);
|
vbox.AddChild(_promptLabel);
|
||||||
|
|
||||||
_controlsHint = new Label { Text = "WASD Drive | Mouse Aim | LMB Fire | E Loot/Swap | Tab Garage | Wheel Zoom" };
|
_controlsHint = new Label { Text = "WASD Drive | Mouse Aim | LMB Fire | E Loot/Swap | Tab Garage | Wheel Zoom" };
|
||||||
|
|
@ -697,8 +716,8 @@ public partial class Hud : CanvasLayer
|
||||||
_hoverLabel = new Label
|
_hoverLabel = new Label
|
||||||
{
|
{
|
||||||
Text = "HOVER CELL FOR TELEMETRY",
|
Text = "HOVER CELL FOR TELEMETRY",
|
||||||
ClipText = true,
|
AutowrapMode = TextServer.AutowrapMode.Word,
|
||||||
CustomMinimumSize = new Vector2(180f, 15f)
|
CustomMinimumSize = new Vector2(180f, 28f)
|
||||||
};
|
};
|
||||||
_hoverLabel.AddThemeColorOverride("font_color", TextMuted);
|
_hoverLabel.AddThemeColorOverride("font_color", TextMuted);
|
||||||
_hoverLabel.AddThemeFontSizeOverride("font_size", 10);
|
_hoverLabel.AddThemeFontSizeOverride("font_size", 10);
|
||||||
|
|
@ -984,11 +1003,15 @@ public partial class Hud : CanvasLayer
|
||||||
|
|
||||||
private void OnSchematicHoverChanged(Vector2I? cell, HardpointSpec? hp)
|
private void OnSchematicHoverChanged(Vector2I? cell, HardpointSpec? hp)
|
||||||
{
|
{
|
||||||
|
_lastHoveredCell = cell;
|
||||||
var grid = _schematic.Grid;
|
var grid = _schematic.Grid;
|
||||||
if (cell is null || grid is null)
|
if (cell is null || grid is null)
|
||||||
{
|
{
|
||||||
_hoverLabel.Text = "HOVER CELL FOR TELEMETRY";
|
if (!UpdateCargoSelectionTooltip(grid))
|
||||||
_hoverLabel.AddThemeColorOverride("font_color", TextMuted);
|
{
|
||||||
|
_hoverLabel.Text = "HOVER CELL FOR TELEMETRY";
|
||||||
|
_hoverLabel.AddThemeColorOverride("font_color", TextMuted);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1001,10 +1024,19 @@ public partial class Hud : CanvasLayer
|
||||||
var mounted = grid.GetMountedOn(hp.Id);
|
var mounted = grid.GetMountedOn(hp.Id);
|
||||||
bool strippedHp = !grid.IsHardpointOperational(hp);
|
bool strippedHp = !grid.IsHardpointOperational(hp);
|
||||||
string hpStatus = strippedHp ? " [STRIPPED]" : "";
|
string hpStatus = strippedHp ? " [STRIPPED]" : "";
|
||||||
_hoverLabel.Text = mounted is not null
|
if (mounted is not null && mounted.Spec.Procedural is { } proc)
|
||||||
? $"{hp.Kind.ToString().ToUpperInvariant()}: {mounted.Spec.Name} {mounted.CurrentTemp:F0}°C ({mounted.CurrentPerformance * 100f:F0}%){hpStatus}"
|
{
|
||||||
: $"{hp.Kind.ToString().ToUpperInvariant()} SLOT [{hp.Width}x{hp.Height}] EMPTY{hpStatus}";
|
_hoverLabel.Text = $"[{proc.ManufacturerLabel}] {proc.SummaryLine1}{hpStatus}\n{proc.SummaryLine2}";
|
||||||
_hoverLabel.AddThemeColorOverride("font_color", (arm <= 0.01f || strippedHp) ? RedCol : TextLight);
|
_hoverLabel.AddThemeColorOverride("font_color",
|
||||||
|
(arm <= 0.01f || strippedHp) ? RedCol : ResolveManufacturerHudColor(proc.Manufacturer));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_hoverLabel.Text = mounted is not null
|
||||||
|
? $"{hp.Kind.ToString().ToUpperInvariant()}: {mounted.Spec.Name} {mounted.CurrentTemp:F0}°C ({mounted.CurrentPerformance * 100f:F0}%){hpStatus}"
|
||||||
|
: $"{hp.Kind.ToString().ToUpperInvariant()} SLOT [{hp.Width}x{hp.Height}] EMPTY{hpStatus}";
|
||||||
|
_hoverLabel.AddThemeColorOverride("font_color", (arm <= 0.01f || strippedHp) ? RedCol : TextLight);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1015,6 +1047,36 @@ public partial class Hud : CanvasLayer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool UpdateCargoSelectionTooltip(ChassisGrid? grid)
|
||||||
|
{
|
||||||
|
if (grid is null || _selectedCargoIndex < 0 || _selectedCargoIndex >= grid.Cargo.Count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var mod = grid.Cargo[_selectedCargoIndex];
|
||||||
|
if (mod.Procedural is { } proc)
|
||||||
|
{
|
||||||
|
_hoverLabel.Text = $"[{proc.ManufacturerLabel}] {proc.SummaryLine1}\n{proc.SummaryLine2}";
|
||||||
|
_hoverLabel.AddThemeColorOverride("font_color", ResolveManufacturerHudColor(proc.Manufacturer));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_hoverLabel.Text = $"CARGO: {mod.Name} [{mod.Width}x{mod.Height}]";
|
||||||
|
_hoverLabel.AddThemeColorOverride("font_color", mod.IsImperial ? GoldCol : TextLight);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Color ResolveManufacturerHudColor(ManufacturerId mfg) => mfg switch
|
||||||
|
{
|
||||||
|
ManufacturerId.ScrapFrontier => Color.FromHtml("#ffaa33"),
|
||||||
|
ManufacturerId.KorrathiIronworks => Color.FromHtml("#f2c422"),
|
||||||
|
ManufacturerId.AuralianOptics => Color.FromHtml("#38e8ff"),
|
||||||
|
ManufacturerId.VexNineCollective => Color.FromHtml("#7cf230"),
|
||||||
|
ManufacturerId.ThalassanForge => Color.FromHtml("#2cb8ff"),
|
||||||
|
_ => GoldCol
|
||||||
|
};
|
||||||
|
|
||||||
private void SyncCargoButtons(ChassisGrid grid)
|
private void SyncCargoButtons(ChassisGrid grid)
|
||||||
{
|
{
|
||||||
int hash = HashCode.Combine(grid.Cargo.Count, grid.Spec.CargoCapacity, _selectedCargoIndex);
|
int hash = HashCode.Combine(grid.Cargo.Count, grid.Spec.CargoCapacity, _selectedCargoIndex);
|
||||||
|
|
@ -1141,6 +1203,13 @@ public partial class Hud : CanvasLayer
|
||||||
if (nearest.Module is { } mod)
|
if (nearest.Module is { } mod)
|
||||||
{
|
{
|
||||||
var freeHp = player.Grid.FindFirstEmptyCompatibleHardpoint(mod);
|
var freeHp = player.Grid.FindFirstEmptyCompatibleHardpoint(mod);
|
||||||
|
if (mod.Procedural is { } proc)
|
||||||
|
{
|
||||||
|
string action = freeHp is not null
|
||||||
|
? $"[E] Bolt [{proc.ManufacturerLabel}] {mod.Name} -> {freeHp.Id}"
|
||||||
|
: $"[E] Loot [{proc.ManufacturerLabel}] {mod.Name}";
|
||||||
|
return $"{action}\n{proc.SummaryLine1} | {proc.SummaryLine2}";
|
||||||
|
}
|
||||||
return freeHp is not null
|
return freeHp is not null
|
||||||
? $"[E] Bolt {(mod.IsImperial ? "IMPERIAL " : "")}{mod.Name} -> {freeHp.Id}"
|
? $"[E] Bolt {(mod.IsImperial ? "IMPERIAL " : "")}{mod.Name} -> {freeHp.Id}"
|
||||||
: $"[E] Loot {(mod.IsImperial ? "IMPERIAL " : "")}{mod.Name}";
|
: $"[E] Loot {(mod.IsImperial ? "IMPERIAL " : "")}{mod.Name}";
|
||||||
|
|
@ -1152,7 +1221,7 @@ public partial class Hud : CanvasLayer
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string BuildGarageDetails(ChassisGrid grid)
|
private static string BuildGarageDetails(ChassisGrid grid, int selectedCargoIndex = -1)
|
||||||
{
|
{
|
||||||
var lines = new List<string>
|
var lines = new List<string>
|
||||||
{
|
{
|
||||||
|
|
@ -1163,7 +1232,23 @@ public partial class Hud : CanvasLayer
|
||||||
{
|
{
|
||||||
var m = grid.Mounted[i];
|
var m = grid.Mounted[i];
|
||||||
string stateTag = grid.IsHardpointOperational(m.HardpointId) ? "" : " [STRIPPED]";
|
string stateTag = grid.IsHardpointOperational(m.HardpointId) ? "" : " [STRIPPED]";
|
||||||
lines.Add($"• {m.HardpointId}: {m.Spec.Name} {m.CurrentTemp:F0}°C ({(m.CurrentPerformance * 100f):F0}%){stateTag}");
|
if (m.Spec.Procedural is { } proc)
|
||||||
|
{
|
||||||
|
lines.Add($"• [{proc.ManufacturerLabel}] {m.Spec.Name} {m.CurrentTemp:F0}°C{stateTag}");
|
||||||
|
lines.Add($" {proc.SummaryLine1}");
|
||||||
|
lines.Add($" {proc.SummaryLine2}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lines.Add($"• {m.HardpointId}: {m.Spec.Name} {m.CurrentTemp:F0}°C ({(m.CurrentPerformance * 100f):F0}%){stateTag}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (selectedCargoIndex >= 0 && selectedCargoIndex < grid.Cargo.Count &&
|
||||||
|
grid.Cargo[selectedCargoIndex].Procedural is { } cargoProc)
|
||||||
|
{
|
||||||
|
lines.Add($"SEL [{cargoProc.ManufacturerLabel}]:");
|
||||||
|
lines.Add($" {cargoProc.SummaryLine1}");
|
||||||
|
lines.Add($" {cargoProc.SummaryLine2}");
|
||||||
}
|
}
|
||||||
return string.Join("\n", lines);
|
return string.Join("\n", lines);
|
||||||
}
|
}
|
||||||
|
|
@ -1512,14 +1597,18 @@ public partial class Hud : CanvasLayer
|
||||||
Color arcCol = arc.WeaponClass switch
|
Color arcCol = arc.WeaponClass switch
|
||||||
{
|
{
|
||||||
WeaponVisualClass.Explosive => new Color(1.0f, 0.36f, 0.12f, alpha * 0.96f),
|
WeaponVisualClass.Explosive => new Color(1.0f, 0.36f, 0.12f, alpha * 0.96f),
|
||||||
|
WeaponVisualClass.RocketSalvo => new Color(1.0f, 0.56f, 0.14f, alpha * 0.96f),
|
||||||
WeaponVisualClass.ThermalBeam => new Color(0.30f, 0.90f, 1.0f, alpha * 0.96f),
|
WeaponVisualClass.ThermalBeam => new Color(0.30f, 0.90f, 1.0f, alpha * 0.96f),
|
||||||
|
WeaponVisualClass.GaussRail => new Color(0.24f, 0.78f, 1.0f, alpha * 0.98f),
|
||||||
|
WeaponVisualClass.PlasmaPpc => new Color(0.18f, 0.92f, 0.96f, alpha * 0.96f),
|
||||||
|
WeaponVisualClass.SwarmSmart => new Color(0.56f, 0.96f, 0.28f, alpha * 0.96f),
|
||||||
_ => new Color(0.96f, 0.72f, 0.22f, alpha * 0.94f)
|
_ => new Color(0.96f, 0.72f, 0.22f, alpha * 0.94f)
|
||||||
};
|
};
|
||||||
|
|
||||||
const float hitR = 39f;
|
const float hitR = 39f;
|
||||||
const float halfSpan = 0.34f;
|
const float halfSpan = 0.34f;
|
||||||
DrawArc(center, hitR, angle - halfSpan, angle + halfSpan, 14, arcCol, 4.2f);
|
DrawArc(center, hitR, angle - halfSpan, angle + halfSpan, 14, arcCol, 4.2f);
|
||||||
if (arc.WeaponClass == WeaponVisualClass.ThermalBeam)
|
if (arc.WeaponClass is WeaponVisualClass.ThermalBeam or WeaponVisualClass.GaussRail or WeaponVisualClass.PlasmaPpc)
|
||||||
{
|
{
|
||||||
DrawArc(center, hitR - 3.5f, angle - halfSpan * 0.75f, angle + halfSpan * 0.75f, 10,
|
DrawArc(center, hitR - 3.5f, angle - halfSpan * 0.75f, angle + halfSpan * 0.75f, 10,
|
||||||
new Color(GoldCol.R, GoldCol.G, GoldCol.B, alpha * 0.90f), 2.0f);
|
new Color(GoldCol.R, GoldCol.G, GoldCol.B, alpha * 0.90f), 2.0f);
|
||||||
|
|
@ -1539,7 +1628,11 @@ public partial class Hud : CanvasLayer
|
||||||
{
|
{
|
||||||
WeaponVisualClass.Autocannon => ("20MM IMPACT", new Color(0.98f, 0.70f, 0.20f, tagAlpha)),
|
WeaponVisualClass.Autocannon => ("20MM IMPACT", new Color(0.98f, 0.70f, 0.20f, tagAlpha)),
|
||||||
WeaponVisualClass.Explosive => ("BLAST IMPACT", new Color(1.0f, 0.38f, 0.14f, tagAlpha)),
|
WeaponVisualClass.Explosive => ("BLAST IMPACT", new Color(1.0f, 0.38f, 0.14f, tagAlpha)),
|
||||||
|
WeaponVisualClass.RocketSalvo => ("ROCKET HIT", new Color(1.0f, 0.58f, 0.18f, tagAlpha)),
|
||||||
WeaponVisualClass.ThermalBeam => ("THERMAL HIT", new Color(0.36f, 0.92f, 1.0f, tagAlpha)),
|
WeaponVisualClass.ThermalBeam => ("THERMAL HIT", new Color(0.36f, 0.92f, 1.0f, tagAlpha)),
|
||||||
|
WeaponVisualClass.GaussRail => ("GAUSS RAIL", new Color(0.28f, 0.84f, 1.0f, tagAlpha)),
|
||||||
|
WeaponVisualClass.PlasmaPpc => ("PLASMA BURN", new Color(0.24f, 0.94f, 0.98f, tagAlpha)),
|
||||||
|
WeaponVisualClass.SwarmSmart => ("SWARM HIT", new Color(0.58f, 0.96f, 0.30f, tagAlpha)),
|
||||||
_ => ("KINETIC HIT", new Color(0.96f, 0.78f, 0.28f, tagAlpha))
|
_ => ("KINETIC HIT", new Color(0.96f, 0.78f, 0.28f, tagAlpha))
|
||||||
};
|
};
|
||||||
DrawString(
|
DrawString(
|
||||||
|
|
|
||||||
|
|
@ -746,6 +746,116 @@ public partial class ParticlePool : Node3D
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case WeaponVisualClass.GaussRail:
|
||||||
|
{
|
||||||
|
Color gaussCol = new(0.22f, 0.78f, 1.0f, 0.98f);
|
||||||
|
SpawnParticle(new ParticleSlot
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Mode = ModeMuzzleStarburst,
|
||||||
|
Position = start,
|
||||||
|
Velocity = Vector3.Zero,
|
||||||
|
StartSize = 1.45f,
|
||||||
|
EndSize = 0.50f,
|
||||||
|
AspectY = 1f,
|
||||||
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
|
Emissive = 3.8f,
|
||||||
|
ColorStart = new Color(0.75f, 0.96f, 1.0f, 1.0f),
|
||||||
|
ColorEnd = gaussCol with { A = 0f },
|
||||||
|
Lifetime = 0.095f
|
||||||
|
});
|
||||||
|
SpawnSparkBurst(start, (end - start).Normalized(), 4, gaussCol, 14f);
|
||||||
|
if (!hasCam || start.DistanceSquaredTo(camPos) <= 65f * 65f)
|
||||||
|
{
|
||||||
|
SpawnFlashLight(start, gaussCol with { A = 1f }, 4.2f, 14f, 0.11f, priority: 5);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WeaponVisualClass.PlasmaPpc:
|
||||||
|
{
|
||||||
|
Color plasmaCol = new(0.16f, 0.88f, 0.95f, 0.96f);
|
||||||
|
SpawnParticle(new ParticleSlot
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Mode = ModeSteamFire,
|
||||||
|
Position = start,
|
||||||
|
Velocity = (end - start).Normalized() * 3.5f,
|
||||||
|
StartSize = 0.85f,
|
||||||
|
EndSize = 2.0f,
|
||||||
|
AspectY = 1f,
|
||||||
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
|
Emissive = 3.2f,
|
||||||
|
ColorStart = plasmaCol,
|
||||||
|
ColorEnd = new Color(0.08f, 0.45f, 0.65f, 0f),
|
||||||
|
Lifetime = 0.24f
|
||||||
|
});
|
||||||
|
if (!hasCam || start.DistanceSquaredTo(camPos) <= 55f * 55f)
|
||||||
|
{
|
||||||
|
SpawnFlashLight(start, plasmaCol with { A = 1f }, 3.4f, 12f, 0.12f, priority: 4);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WeaponVisualClass.RocketSalvo:
|
||||||
|
{
|
||||||
|
SpawnParticle(new ParticleSlot
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Mode = ModeMuzzleStarburst,
|
||||||
|
Position = start,
|
||||||
|
Velocity = Vector3.Zero,
|
||||||
|
StartSize = 1.15f,
|
||||||
|
EndSize = 0.55f,
|
||||||
|
AspectY = 1f,
|
||||||
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
|
Emissive = 3.0f,
|
||||||
|
ColorStart = new Color(1.0f, 0.72f, 0.24f, 0.96f),
|
||||||
|
ColorEnd = new Color(0.95f, 0.35f, 0.08f, 0f),
|
||||||
|
Lifetime = 0.10f
|
||||||
|
});
|
||||||
|
SpawnParticle(new ParticleSlot
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Mode = ModeDustSmoke,
|
||||||
|
Position = start,
|
||||||
|
Velocity = new Vector3(NextSigned() * 1.2f, 1.4f, NextSigned() * 1.2f),
|
||||||
|
Gravity = -0.15f,
|
||||||
|
Drag = 1.8f,
|
||||||
|
StartSize = 0.55f,
|
||||||
|
EndSize = 1.85f,
|
||||||
|
AspectY = 1f,
|
||||||
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
|
AngularVel = NextSigned() * 1.3f,
|
||||||
|
Emissive = 0f,
|
||||||
|
ColorStart = new Color(0.62f, 0.58f, 0.52f, 0.55f),
|
||||||
|
ColorEnd = new Color(0.45f, 0.42f, 0.38f, 0f),
|
||||||
|
Lifetime = 0.42f
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WeaponVisualClass.SwarmSmart:
|
||||||
|
{
|
||||||
|
Color swarmCol = new(0.56f, 0.96f, 0.28f, 0.96f);
|
||||||
|
SpawnParticle(new ParticleSlot
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Mode = ModeMuzzleStarburst,
|
||||||
|
Position = start,
|
||||||
|
Velocity = Vector3.Zero,
|
||||||
|
StartSize = 0.78f,
|
||||||
|
EndSize = 0.36f,
|
||||||
|
AspectY = 1f,
|
||||||
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
|
Emissive = 2.6f,
|
||||||
|
ColorStart = swarmCol,
|
||||||
|
ColorEnd = new Color(0.55f, 0.28f, 0.88f, 0f),
|
||||||
|
Lifetime = 0.085f
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -873,9 +983,187 @@ public partial class ParticlePool : Node3D
|
||||||
});
|
});
|
||||||
SpawnSparkBurst(pos, normal, 4, new Color(0.55f, 0.92f, 1.0f, 0.98f), 12f);
|
SpawnSparkBurst(pos, normal, 4, new Color(0.55f, 0.92f, 1.0f, 0.98f), 12f);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WeaponVisualClass.GaussRail:
|
||||||
|
EmitImpactDustPlume(pos, normal, groundTint, count: 3, size: 1.65f);
|
||||||
|
SpawnSparkBurst(pos, normal, 6, new Color(0.30f, 0.84f, 1.0f, 0.98f), 17f);
|
||||||
|
if (!hasCam || pos.DistanceSquaredTo(camPos) <= 65f * 65f)
|
||||||
|
{
|
||||||
|
SpawnFlashLight(pos + normal * 0.35f, new Color(0.28f, 0.82f, 1.0f), 4.0f, 13f, 0.12f, priority: 6);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WeaponVisualClass.PlasmaPpc:
|
||||||
|
SpawnParticle(new ParticleSlot
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Mode = ModeSteamFire,
|
||||||
|
Position = pos + normal * 0.2f,
|
||||||
|
Velocity = normal * 1.6f,
|
||||||
|
StartSize = 0.90f,
|
||||||
|
EndSize = 2.6f,
|
||||||
|
AspectY = 1f,
|
||||||
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
|
Emissive = 3.2f,
|
||||||
|
ColorStart = new Color(0.20f, 0.88f, 1.0f, 0.95f),
|
||||||
|
ColorEnd = new Color(0.12f, 0.38f, 0.52f, 0f),
|
||||||
|
Lifetime = 0.42f
|
||||||
|
});
|
||||||
|
SpawnSparkBurst(pos, normal, 5, new Color(0.32f, 0.94f, 1.0f, 0.98f), 12.5f);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WeaponVisualClass.RocketSalvo:
|
||||||
|
EmitImpactDustPlume(pos, normal, groundTint, count: 4, size: 1.75f);
|
||||||
|
SpawnParticle(new ParticleSlot
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Mode = ModeSteamFire,
|
||||||
|
Position = pos + normal * 0.25f,
|
||||||
|
Velocity = normal * 2.2f,
|
||||||
|
Gravity = -0.25f,
|
||||||
|
Drag = 1.6f,
|
||||||
|
StartSize = 0.95f,
|
||||||
|
EndSize = 2.95f,
|
||||||
|
AspectY = 1f,
|
||||||
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
|
Emissive = 2.8f,
|
||||||
|
ColorStart = new Color(1.0f, 0.62f, 0.18f, 0.96f),
|
||||||
|
ColorEnd = new Color(0.28f, 0.16f, 0.12f, 0f),
|
||||||
|
Lifetime = 0.38f
|
||||||
|
});
|
||||||
|
SpawnSparkBurst(pos, normal, 5, new Color(1.0f, 0.68f, 0.22f, 0.98f), 14.5f);
|
||||||
|
if (!hasCam || pos.DistanceSquaredTo(camPos) <= 75f * 75f)
|
||||||
|
{
|
||||||
|
SpawnFlashLight(pos + normal * 0.45f, new Color(1.0f, 0.56f, 0.16f), 4.5f, 14f, 0.14f, priority: 7);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WeaponVisualClass.SwarmSmart:
|
||||||
|
EmitImpactDustPlume(pos, normal, groundTint, count: 2, size: 1.25f);
|
||||||
|
SpawnSparkBurst(pos, normal, 4, new Color(0.56f, 0.96f, 0.32f, 0.98f), 12f);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void EmitOrdnanceTrail(Vector3 pos, Vector3 vel, Color accentCol, bool isRocket, Vector3 camPos, bool hasCam)
|
||||||
|
{
|
||||||
|
EnsureInitialized();
|
||||||
|
if (hasCam && pos.DistanceSquaredTo(camPos) > 220f * 220f)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 backVel = vel.LengthSquared() > 1f ? -vel.Normalized() * 4.5f : Vector3.Up * 1.2f;
|
||||||
|
if (isRocket)
|
||||||
|
{
|
||||||
|
SpawnParticle(new ParticleSlot
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Mode = ModeMuzzleStarburst,
|
||||||
|
Position = pos,
|
||||||
|
Velocity = backVel * 0.4f,
|
||||||
|
StartSize = 0.58f,
|
||||||
|
EndSize = 0.20f,
|
||||||
|
AspectY = 1f,
|
||||||
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
|
Emissive = 2.8f,
|
||||||
|
ColorStart = new Color(1.0f, 0.72f, 0.24f, 0.92f),
|
||||||
|
ColorEnd = accentCol with { A = 0f },
|
||||||
|
Lifetime = 0.12f
|
||||||
|
});
|
||||||
|
SpawnParticle(new ParticleSlot
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Mode = ModeDustSmoke,
|
||||||
|
Position = pos,
|
||||||
|
Velocity = backVel * 0.25f + new Vector3(NextSigned() * 0.6f, 0.7f, NextSigned() * 0.6f),
|
||||||
|
Gravity = -0.15f,
|
||||||
|
Drag = 1.8f,
|
||||||
|
StartSize = 0.32f,
|
||||||
|
EndSize = 1.25f,
|
||||||
|
AspectY = 1f,
|
||||||
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
|
AngularVel = NextSigned() * 1.4f,
|
||||||
|
Emissive = 0f,
|
||||||
|
ColorStart = new Color(0.58f, 0.54f, 0.48f, 0.46f),
|
||||||
|
ColorEnd = new Color(0.40f, 0.38f, 0.36f, 0f),
|
||||||
|
Lifetime = 0.42f
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SpawnParticle(new ParticleSlot
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Mode = ModeSparkStreak,
|
||||||
|
Position = pos,
|
||||||
|
Velocity = backVel * 0.25f,
|
||||||
|
StartSize = 0.24f,
|
||||||
|
EndSize = 0.08f,
|
||||||
|
AspectY = 1.4f,
|
||||||
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
|
Emissive = 2.4f,
|
||||||
|
ColorStart = accentCol with { A = 0.90f },
|
||||||
|
ColorEnd = accentCol with { A = 0f },
|
||||||
|
Lifetime = 0.16f
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EmitOrdnanceBurst(Vector3 pos, Color accentCol, int sparkCount, float radiusScale, Vector3 camPos, bool hasCam)
|
||||||
|
{
|
||||||
|
EnsureInitialized();
|
||||||
|
if (hasCam && pos.DistanceSquaredTo(camPos) > 220f * 220f)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SpawnParticle(new ParticleSlot
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Mode = ModeSteamFire,
|
||||||
|
Position = pos,
|
||||||
|
Velocity = Vector3.Up * 1.5f,
|
||||||
|
StartSize = 0.65f * radiusScale,
|
||||||
|
EndSize = 2.2f * radiusScale,
|
||||||
|
AspectY = 1f,
|
||||||
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
|
Emissive = 2.8f,
|
||||||
|
ColorStart = accentCol with { A = 0.94f },
|
||||||
|
ColorEnd = new Color(0.24f, 0.16f, 0.14f, 0f),
|
||||||
|
Lifetime = 0.34f
|
||||||
|
});
|
||||||
|
SpawnSparkBurst(pos, Vector3.Up, Math.Clamp(sparkCount, 1, 8), accentCol with { A = 0.98f }, 12f * radiusScale);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EmitThermalPoolEmber(Vector3 pos, float radius, Color accentCol, Vector3 camPos, bool hasCam)
|
||||||
|
{
|
||||||
|
EnsureInitialized();
|
||||||
|
if (hasCam && pos.DistanceSquaredTo(camPos) > 150f * 150f)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
float ang = NextFloat() * MathF.Tau;
|
||||||
|
float r = MathF.Sqrt(NextFloat()) * MathF.Max(0.5f, radius * 0.85f);
|
||||||
|
Vector3 p = pos + new Vector3(MathF.Cos(ang) * r, 0.18f, MathF.Sin(ang) * r);
|
||||||
|
SpawnParticle(new ParticleSlot
|
||||||
|
{
|
||||||
|
Active = true,
|
||||||
|
Mode = ModeSteamFire,
|
||||||
|
Position = p,
|
||||||
|
Velocity = new Vector3(NextSigned() * 0.5f, 1.8f + NextFloat() * 1.4f, NextSigned() * 0.5f),
|
||||||
|
Gravity = -0.3f,
|
||||||
|
Drag = 1.2f,
|
||||||
|
StartSize = 0.36f,
|
||||||
|
EndSize = 0.92f,
|
||||||
|
AspectY = 1.25f,
|
||||||
|
Rotation = NextFloat() * MathF.Tau,
|
||||||
|
Emissive = 2.9f,
|
||||||
|
ColorStart = accentCol with { A = 0.88f },
|
||||||
|
ColorEnd = accentCol with { A = 0f },
|
||||||
|
Lifetime = 0.45f
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void EmitChassisExplosion(
|
private void EmitChassisExplosion(
|
||||||
Vector3 pos,
|
Vector3 pos,
|
||||||
float massKg,
|
float massKg,
|
||||||
|
|
|
||||||
|
|
@ -95,17 +95,39 @@ public sealed class VehicleAssetCache : IDisposable
|
||||||
public required float MaxY { get; init; }
|
public required float MaxY { get; init; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public sealed class WeaponPartTemplate
|
||||||
|
{
|
||||||
|
public required string Id { get; init; }
|
||||||
|
public required string Slot { get; init; }
|
||||||
|
public required string GlbPath { get; init; }
|
||||||
|
public required Node3D SceneTemplate { get; init; }
|
||||||
|
public required ArrayMesh SingleSurfaceMesh { get; init; }
|
||||||
|
public required Vector3 Size { get; init; }
|
||||||
|
public required float MinY { get; init; }
|
||||||
|
public required IReadOnlyDictionary<string, Transform3D> SocketsLocal { get; init; }
|
||||||
|
}
|
||||||
|
|
||||||
public static readonly string[] ExpectedGearIds =
|
public static readonly string[] ExpectedGearIds =
|
||||||
{
|
{
|
||||||
"mg_762", "autocannon", "recoilless", "copper_rad", "gilded_lance", "gold_radiator"
|
"mg_762", "autocannon", "recoilless", "copper_rad", "gilded_lance", "gold_radiator"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public static readonly string[] ExpectedWeaponPartIds =
|
||||||
|
{
|
||||||
|
"rx_salvage_frame", "rx_korrathi_cradle", "rx_auralian_prism", "rx_vex_pod_rack",
|
||||||
|
"brl_autocannon", "brl_sabot_rail", "brl_prism_lance", "brl_missile_tube",
|
||||||
|
"fd_belt_drum", "fd_rotary_loader", "fd_capacitor_bank", "fd_swarm_magazine",
|
||||||
|
"mz_slotted_brake", "mz_mirv_warhead", "mz_loiter_aero_fin", "mz_plasma_diffuser"
|
||||||
|
};
|
||||||
|
|
||||||
private readonly Dictionary<string, VehicleTemplate> _vehicles = new(StringComparer.OrdinalIgnoreCase);
|
private readonly Dictionary<string, VehicleTemplate> _vehicles = new(StringComparer.OrdinalIgnoreCase);
|
||||||
private readonly Dictionary<string, GearTemplate> _gear = new(StringComparer.OrdinalIgnoreCase);
|
private readonly Dictionary<string, GearTemplate> _gear = new(StringComparer.OrdinalIgnoreCase);
|
||||||
|
private readonly Dictionary<string, WeaponPartTemplate> _weaponParts = new(StringComparer.OrdinalIgnoreCase);
|
||||||
private readonly Dictionary<string, ArrayMesh> _gearVariantMeshes = new(StringComparer.OrdinalIgnoreCase);
|
private readonly Dictionary<string, ArrayMesh> _gearVariantMeshes = new(StringComparer.OrdinalIgnoreCase);
|
||||||
private DropPodTemplate? _dropPod;
|
private DropPodTemplate? _dropPod;
|
||||||
private readonly string _vehiclesDir;
|
private readonly string _vehiclesDir;
|
||||||
private readonly string _gearDir;
|
private readonly string _gearDir;
|
||||||
|
private readonly string _weaponPartsDir;
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
public VehicleAssetCache()
|
public VehicleAssetCache()
|
||||||
|
|
@ -118,10 +140,12 @@ public sealed class VehicleAssetCache : IDisposable
|
||||||
{
|
{
|
||||||
throw new DirectoryNotFoundException($"Could not locate gear directory '{_gearDir}'.");
|
throw new DirectoryNotFoundException($"Could not locate gear directory '{_gearDir}'.");
|
||||||
}
|
}
|
||||||
|
_weaponPartsDir = Path.Combine(_gearDir, "parts");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IReadOnlyDictionary<string, VehicleTemplate> Vehicles => _vehicles;
|
public IReadOnlyDictionary<string, VehicleTemplate> Vehicles => _vehicles;
|
||||||
public IReadOnlyDictionary<string, GearTemplate> Gear => _gear;
|
public IReadOnlyDictionary<string, GearTemplate> Gear => _gear;
|
||||||
|
public IReadOnlyDictionary<string, WeaponPartTemplate> WeaponParts => _weaponParts;
|
||||||
|
|
||||||
public void PreloadAll()
|
public void PreloadAll()
|
||||||
{
|
{
|
||||||
|
|
@ -133,9 +157,32 @@ public sealed class VehicleAssetCache : IDisposable
|
||||||
{
|
{
|
||||||
GetOrLoadGear(gearId);
|
GetOrLoadGear(gearId);
|
||||||
}
|
}
|
||||||
|
foreach (string partId in ExpectedWeaponPartIds)
|
||||||
|
{
|
||||||
|
GetOrLoadWeaponPart(partId);
|
||||||
|
}
|
||||||
GetOrLoadDropPod();
|
GetOrLoadDropPod();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WeaponPartTemplate GetOrLoadWeaponPart(string partId)
|
||||||
|
{
|
||||||
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
|
if (_weaponParts.TryGetValue(partId, out var cached))
|
||||||
|
{
|
||||||
|
return cached;
|
||||||
|
}
|
||||||
|
|
||||||
|
string glbPath = Path.Combine(_weaponPartsDir, $"{partId}.glb");
|
||||||
|
if (!File.Exists(glbPath))
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException($"Missing modular weapon part GLB '{partId}': {glbPath}", glbPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
var template = LoadWeaponPartTemplate(partId, glbPath);
|
||||||
|
_weaponParts[partId] = template;
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
public DropPodTemplate GetOrLoadDropPod()
|
public DropPodTemplate GetOrLoadDropPod()
|
||||||
{
|
{
|
||||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||||
|
|
@ -597,6 +644,89 @@ public sealed class VehicleAssetCache : IDisposable
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static WeaponPartTemplate LoadWeaponPartTemplate(string partId, string glbPath)
|
||||||
|
{
|
||||||
|
var doc = new GltfDocument();
|
||||||
|
var state = new GltfState();
|
||||||
|
Error err = doc.AppendFromFile(glbPath, state, flags: 0, basePath: Path.GetDirectoryName(glbPath) ?? string.Empty);
|
||||||
|
if (err != Error.Ok)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"GltfDocument.AppendFromFile failed for weapon part '{glbPath}': {err}");
|
||||||
|
}
|
||||||
|
|
||||||
|
Node? generated = doc.GenerateScene(state);
|
||||||
|
if (generated is not Node3D sceneRoot)
|
||||||
|
{
|
||||||
|
generated?.QueueFree();
|
||||||
|
throw new InvalidOperationException($"GltfDocument.GenerateScene did not return a Node3D for weapon part '{glbPath}'.");
|
||||||
|
}
|
||||||
|
ClearOwnerRecursive(sceneRoot);
|
||||||
|
|
||||||
|
var modelTransforms = new Dictionary<Node, Transform3D>();
|
||||||
|
CollectModelTransforms(sceneRoot, Transform3D.Identity, modelTransforms);
|
||||||
|
|
||||||
|
string partSlot = "unknown";
|
||||||
|
var sockets = new Dictionary<string, Transform3D>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
byte[] jsonBytes = ReadGlbJsonChunk(glbPath);
|
||||||
|
using (var jsonDoc = JsonDocument.Parse(jsonBytes))
|
||||||
|
{
|
||||||
|
if (jsonDoc.RootElement.TryGetProperty("nodes", out JsonElement jsonNodes) &&
|
||||||
|
jsonNodes.ValueKind == JsonValueKind.Array)
|
||||||
|
{
|
||||||
|
var gltfNodes = state.Nodes;
|
||||||
|
int nodeCount = Math.Min(gltfNodes.Count, jsonNodes.GetArrayLength());
|
||||||
|
for (int i = 0; i < nodeCount; i++)
|
||||||
|
{
|
||||||
|
JsonElement jn = jsonNodes[i];
|
||||||
|
if (!jn.TryGetProperty("extras", out JsonElement extras) || extras.ValueKind != JsonValueKind.Object)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
GltfNode gn = gltfNodes[i];
|
||||||
|
string origName = !string.IsNullOrEmpty(gn.OriginalName)
|
||||||
|
? gn.OriginalName
|
||||||
|
: (jn.TryGetProperty("name", out var nm) ? nm.GetString() ?? $"node_{i}" : $"node_{i}");
|
||||||
|
Node? resolved = ResolveSceneNode(sceneRoot, gn.GetSceneNodePath(state), origName);
|
||||||
|
if (resolved is not Node3D n3d)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extras.TryGetProperty("rtd.part_slot", out var slotEl) && slotEl.ValueKind == JsonValueKind.String)
|
||||||
|
{
|
||||||
|
partSlot = slotEl.GetString() ?? partSlot;
|
||||||
|
}
|
||||||
|
if (extras.TryGetProperty("rtd.socket", out var sockEl) && sockEl.ValueKind == JsonValueKind.String)
|
||||||
|
{
|
||||||
|
string? sockName = sockEl.GetString();
|
||||||
|
if (!string.IsNullOrWhiteSpace(sockName) && modelTransforms.TryGetValue(n3d, out Transform3D sockXf))
|
||||||
|
{
|
||||||
|
sockets[sockName] = sockXf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ComputeSceneMeshBounds(sceneRoot, out Vector3 bMin, out Vector3 bMax);
|
||||||
|
ArrayMesh bakedMesh = BuildBakedStaticMesh(sceneRoot, coarseMaterials: false);
|
||||||
|
ArrayMesh singleSurfaceMesh = CollapseToSingleSurfaceMechPaintMesh(bakedMesh);
|
||||||
|
|
||||||
|
return new WeaponPartTemplate
|
||||||
|
{
|
||||||
|
Id = partId,
|
||||||
|
Slot = partSlot,
|
||||||
|
GlbPath = glbPath,
|
||||||
|
SceneTemplate = sceneRoot,
|
||||||
|
SingleSurfaceMesh = singleSurfaceMesh,
|
||||||
|
Size = bMax - bMin,
|
||||||
|
MinY = bMin.Y,
|
||||||
|
SocketsLocal = sockets
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private static DropPodTemplate LoadDropPodTemplate(string glbPath)
|
private static DropPodTemplate LoadDropPodTemplate(string glbPath)
|
||||||
{
|
{
|
||||||
var doc = new GltfDocument();
|
var doc = new GltfDocument();
|
||||||
|
|
@ -1453,6 +1583,33 @@ public sealed class VehicleAssetCache : IDisposable
|
||||||
string mName = (sm.ResourceName ?? string.Empty).ToLowerInvariant();
|
string mName = (sm.ResourceName ?? string.Empty).ToLowerInvariant();
|
||||||
roughness = Math.Clamp(sm.Roughness, 0.08f, 0.90f);
|
roughness = Math.Clamp(sm.Roughness, 0.08f, 0.90f);
|
||||||
|
|
||||||
|
if (mName.Contains("mfg_primary"))
|
||||||
|
{
|
||||||
|
Color b = sm.AlbedoColor.SrgbToLinear();
|
||||||
|
linearColor = new Vector3(b.R, b.G, b.B);
|
||||||
|
band = 3;
|
||||||
|
roughness = 0.50f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mName.Contains("mfg_accent"))
|
||||||
|
{
|
||||||
|
Color b = sm.AlbedoColor.SrgbToLinear();
|
||||||
|
linearColor = new Vector3(b.R, b.G, b.B);
|
||||||
|
band = 4;
|
||||||
|
roughness = 0.38f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mName.Contains("mfg_glow"))
|
||||||
|
{
|
||||||
|
Color eCol = (sm.EmissionEnabled ? sm.Emission : sm.AlbedoColor).SrgbToLinear();
|
||||||
|
linearColor = new Vector3(eCol.R, eCol.G, eCol.B);
|
||||||
|
band = 5;
|
||||||
|
roughness = 0.22f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mName.Contains("lamp") || mName.Contains("glow") || mName.Contains("cyan") ||
|
if (mName.Contains("lamp") || mName.Contains("glow") || mName.Contains("cyan") ||
|
||||||
mName.Contains("amber") || mName.Contains("optic_red"))
|
mName.Contains("amber") || mName.Contains("optic_red"))
|
||||||
{
|
{
|
||||||
|
|
@ -2229,8 +2386,16 @@ public sealed class VehicleAssetCache : IDisposable
|
||||||
g.SceneTemplate.QueueFree();
|
g.SceneTemplate.QueueFree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach (var wp in _weaponParts.Values)
|
||||||
|
{
|
||||||
|
if (GodotObject.IsInstanceValid(wp.SceneTemplate))
|
||||||
|
{
|
||||||
|
wp.SceneTemplate.QueueFree();
|
||||||
|
}
|
||||||
|
}
|
||||||
_vehicles.Clear();
|
_vehicles.Clear();
|
||||||
_gear.Clear();
|
_gear.Clear();
|
||||||
|
_weaponParts.Clear();
|
||||||
if (_dropPod is not null && GodotObject.IsInstanceValid(_dropPod.SceneTemplate))
|
if (_dropPod is not null && GodotObject.IsInstanceValid(_dropPod.SceneTemplate))
|
||||||
{
|
{
|
||||||
_dropPod.SceneTemplate.QueueFree();
|
_dropPod.SceneTemplate.QueueFree();
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,11 @@ public sealed class VehicleVisualInstance
|
||||||
public required ArrayMesh Mesh;
|
public required ArrayMesh Mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public readonly record struct ModularWeaponPartBinding(
|
||||||
|
ArrayMesh Mesh,
|
||||||
|
Transform3D LocalToGearPivot,
|
||||||
|
string Slot);
|
||||||
|
|
||||||
private sealed class BoundHardpoint
|
private sealed class BoundHardpoint
|
||||||
{
|
{
|
||||||
public required HardpointSpec Spec;
|
public required HardpointSpec Spec;
|
||||||
|
|
@ -47,6 +52,10 @@ public sealed class VehicleVisualInstance
|
||||||
public Node3D? GearNode;
|
public Node3D? GearNode;
|
||||||
public ArrayMesh? GearMesh;
|
public ArrayMesh? GearMesh;
|
||||||
public VehicleAssetCache.GearTemplate? GearTemplate;
|
public VehicleAssetCache.GearTemplate? GearTemplate;
|
||||||
|
public ModularWeaponPartBinding[]? ModularParts;
|
||||||
|
public float ManufacturerRoleIndex;
|
||||||
|
public Vector3 ModularMuzzleTipLocal;
|
||||||
|
public Vector3 ModularReceiverCenterLocal;
|
||||||
public float HeatGlow;
|
public float HeatGlow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -384,8 +393,20 @@ public sealed class VehicleVisualInstance
|
||||||
rearInModel = Vector3.Zero;
|
rearInModel = Vector3.Zero;
|
||||||
if (!_hardpoints.TryGetValue(hardpointId, out var bh) ||
|
if (!_hardpoints.TryGetValue(hardpointId, out var bh) ||
|
||||||
bh.GearNode is null ||
|
bh.GearNode is null ||
|
||||||
!GodotObject.IsInstanceValid(bh.GearNode) ||
|
!GodotObject.IsInstanceValid(bh.GearNode))
|
||||||
bh.GearTemplate is null)
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Transform3D gearToModel = ComputeRelativeTransform(bh.GearNode, ModelRoot);
|
||||||
|
if (bh.ModularParts is not null)
|
||||||
|
{
|
||||||
|
frontInModel = gearToModel * bh.ModularMuzzleTipLocal;
|
||||||
|
rearInModel = gearToModel * bh.ModularReceiverCenterLocal;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bh.GearTemplate is null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -395,12 +416,52 @@ public sealed class VehicleVisualInstance
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform3D gearToModel = ComputeRelativeTransform(bh.GearNode, ModelRoot);
|
|
||||||
frontInModel = gearToModel * fLocal;
|
frontInModel = gearToModel * fLocal;
|
||||||
rearInModel = gearToModel * rLocal;
|
rearInModel = gearToModel * rLocal;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void BuildModularWeaponAssembly(
|
||||||
|
VehicleAssetCache cache,
|
||||||
|
ModularWeaponAssembly assembly,
|
||||||
|
out ModularWeaponPartBinding[] parts,
|
||||||
|
out Vector3 muzzleTipLocal,
|
||||||
|
out Vector3 receiverCenterLocal,
|
||||||
|
out float minY)
|
||||||
|
{
|
||||||
|
var rxTpl = cache.GetOrLoadWeaponPart(assembly.ReceiverPartName);
|
||||||
|
var brlTpl = cache.GetOrLoadWeaponPart(assembly.BarrelPartName);
|
||||||
|
var fdTpl = cache.GetOrLoadWeaponPart(assembly.FeedPartName);
|
||||||
|
var mzTpl = cache.GetOrLoadWeaponPart(assembly.MuzzlePartName);
|
||||||
|
|
||||||
|
Transform3D rxXf = Transform3D.Identity;
|
||||||
|
Transform3D brlXf = rxTpl.SocketsLocal.TryGetValue("barrel", out var bx)
|
||||||
|
? bx
|
||||||
|
: new Transform3D(Basis.Identity, new Vector3(0f, 0.20f, 0.24f));
|
||||||
|
Transform3D fdXf = rxTpl.SocketsLocal.TryGetValue("feed", out var fx)
|
||||||
|
? fx
|
||||||
|
: new Transform3D(Basis.Identity, new Vector3(0.14f, 0.20f, 0f));
|
||||||
|
Transform3D brlMuzzle = brlTpl.SocketsLocal.TryGetValue("muzzle", out var mx)
|
||||||
|
? mx
|
||||||
|
: new Transform3D(Basis.Identity, new Vector3(0f, 0f, 0.55f));
|
||||||
|
Transform3D mzXf = brlXf * brlMuzzle;
|
||||||
|
Transform3D mzTip = mzTpl.SocketsLocal.TryGetValue("muzzle_tip", out var tx)
|
||||||
|
? tx
|
||||||
|
: new Transform3D(Basis.Identity, new Vector3(0f, 0f, 0.22f));
|
||||||
|
|
||||||
|
muzzleTipLocal = (mzXf * mzTip).Origin;
|
||||||
|
receiverCenterLocal = new Vector3(0f, rxTpl.Size.Y * 0.5f, 0f);
|
||||||
|
minY = rxTpl.MinY;
|
||||||
|
|
||||||
|
parts = new[]
|
||||||
|
{
|
||||||
|
new ModularWeaponPartBinding(rxTpl.SingleSurfaceMesh, rxXf, "receiver"),
|
||||||
|
new ModularWeaponPartBinding(brlTpl.SingleSurfaceMesh, brlXf, "barrel"),
|
||||||
|
new ModularWeaponPartBinding(fdTpl.SingleSurfaceMesh, fdXf, "feed"),
|
||||||
|
new ModularWeaponPartBinding(mzTpl.SingleSurfaceMesh, mzXf, "muzzle")
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public static void ResolveDropGearVisual(
|
public static void ResolveDropGearVisual(
|
||||||
VehicleAssetCache cache,
|
VehicleAssetCache cache,
|
||||||
ModuleSpec mod,
|
ModuleSpec mod,
|
||||||
|
|
@ -443,6 +504,8 @@ public sealed class VehicleVisualInstance
|
||||||
bh.GearNode = null;
|
bh.GearNode = null;
|
||||||
bh.GearMesh = null;
|
bh.GearMesh = null;
|
||||||
bh.GearTemplate = null;
|
bh.GearTemplate = null;
|
||||||
|
bh.ModularParts = null;
|
||||||
|
bh.ManufacturerRoleIndex = 0f;
|
||||||
bh.HeatGlow = 0f;
|
bh.HeatGlow = 0f;
|
||||||
bh.MountedModuleId = desiredId;
|
bh.MountedModuleId = desiredId;
|
||||||
|
|
||||||
|
|
@ -451,16 +514,46 @@ public sealed class VehicleVisualInstance
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node3D gearNode = CreateGearPivotForHardpoint(
|
if (mounted.Spec.Procedural is { } proc)
|
||||||
mounted.Spec,
|
{
|
||||||
bh.Spec,
|
BuildModularWeaponAssembly(
|
||||||
bh.AnchorInfo,
|
_cache,
|
||||||
out ArrayMesh gearMesh,
|
proc.Assembly,
|
||||||
out VehicleAssetCache.GearTemplate gearTemplate);
|
out var modParts,
|
||||||
bh.AnchorNode.AddChild(gearNode);
|
out Vector3 muzzleTipLocal,
|
||||||
bh.GearNode = gearNode;
|
out Vector3 receiverCenterLocal,
|
||||||
bh.GearMesh = gearMesh;
|
out float minY);
|
||||||
bh.GearTemplate = gearTemplate;
|
Transform3D mountXf = ComputeHardpointMountTransform(
|
||||||
|
bh.Spec,
|
||||||
|
bh.AnchorInfo,
|
||||||
|
Vector3.One * proc.Assembly.VisualScale,
|
||||||
|
localModelForwardZ: 1f,
|
||||||
|
minY);
|
||||||
|
var gearNode = new Node3D
|
||||||
|
{
|
||||||
|
Name = $"Mounted_{mounted.Spec.Id}_{bh.Spec.Id}",
|
||||||
|
Transform = mountXf
|
||||||
|
};
|
||||||
|
bh.AnchorNode.AddChild(gearNode);
|
||||||
|
bh.GearNode = gearNode;
|
||||||
|
bh.ModularParts = modParts;
|
||||||
|
bh.ManufacturerRoleIndex = 10f + (float)proc.Manufacturer;
|
||||||
|
bh.ModularMuzzleTipLocal = muzzleTipLocal;
|
||||||
|
bh.ModularReceiverCenterLocal = receiverCenterLocal;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Node3D gearNode = CreateGearPivotForHardpoint(
|
||||||
|
mounted.Spec,
|
||||||
|
bh.Spec,
|
||||||
|
bh.AnchorInfo,
|
||||||
|
out ArrayMesh gearMesh,
|
||||||
|
out VehicleAssetCache.GearTemplate gearTemplate);
|
||||||
|
bh.AnchorNode.AddChild(gearNode);
|
||||||
|
bh.GearNode = gearNode;
|
||||||
|
bh.GearMesh = gearMesh;
|
||||||
|
bh.GearTemplate = gearTemplate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -533,21 +626,43 @@ public sealed class VehicleVisualInstance
|
||||||
{
|
{
|
||||||
_shearedHardpoints.Add(bh.Spec.Id);
|
_shearedHardpoints.Add(bh.Spec.Id);
|
||||||
_hasAnyStrippedCell = true;
|
_hasAnyStrippedCell = true;
|
||||||
if (bh.GearNode is not null && GodotObject.IsInstanceValid(bh.GearNode) && bh.GearMesh is not null)
|
if (bh.GearNode is not null && GodotObject.IsInstanceValid(bh.GearNode))
|
||||||
{
|
{
|
||||||
Transform3D worldXf = bh.GearNode.IsInsideTree()
|
Transform3D worldXf = bh.GearNode.IsInsideTree()
|
||||||
? bh.GearNode.GlobalTransform
|
? bh.GearNode.GlobalTransform
|
||||||
: ComputeWorldTransformFallback(bh.GearNode);
|
: ComputeWorldTransformFallback(bh.GearNode);
|
||||||
ArrayMesh gearMesh = bh.GearMesh;
|
ModularWeaponPartBinding[]? modParts = bh.ModularParts;
|
||||||
|
float mfgRole = bh.ManufacturerRoleIndex;
|
||||||
|
ArrayMesh? gearMesh = bh.GearMesh;
|
||||||
Node3D sheared = bh.GearNode;
|
Node3D sheared = bh.GearNode;
|
||||||
bh.GearNode = null;
|
bh.GearNode = null;
|
||||||
bh.GearMesh = null;
|
bh.GearMesh = null;
|
||||||
bh.GearTemplate = null;
|
bh.GearTemplate = null;
|
||||||
|
bh.ModularParts = null;
|
||||||
|
bh.ManufacturerRoleIndex = 0f;
|
||||||
bh.MountedModuleId = null;
|
bh.MountedModuleId = null;
|
||||||
bh.HeatGlow = 0f;
|
bh.HeatGlow = 0f;
|
||||||
sheared.GetParent()?.RemoveChild(sheared);
|
sheared.GetParent()?.RemoveChild(sheared);
|
||||||
sheared.QueueFree();
|
sheared.QueueFree();
|
||||||
debris.SpawnDetachedPart(gearMesh, worldXf, blastOrigin, vehicleVelocity, _roleIndex, impulseScale: 1.15f, applyScorch: true);
|
|
||||||
|
if (modParts is not null)
|
||||||
|
{
|
||||||
|
for (int p = 0; p < modParts.Length; p++)
|
||||||
|
{
|
||||||
|
debris.SpawnDetachedPart(
|
||||||
|
modParts[p].Mesh,
|
||||||
|
worldXf * modParts[p].LocalToGearPivot,
|
||||||
|
blastOrigin,
|
||||||
|
vehicleVelocity,
|
||||||
|
mfgRole,
|
||||||
|
impulseScale: 1.15f,
|
||||||
|
applyScorch: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (gearMesh is not null)
|
||||||
|
{
|
||||||
|
debris.SpawnDetachedPart(gearMesh, worldXf, blastOrigin, vehicleVelocity, _roleIndex, impulseScale: 1.15f, applyScorch: true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -620,12 +735,24 @@ public sealed class VehicleVisualInstance
|
||||||
for (int i = 0; i < _hardpointList.Count; i++)
|
for (int i = 0; i < _hardpointList.Count; i++)
|
||||||
{
|
{
|
||||||
var bh = _hardpointList[i];
|
var bh = _hardpointList[i];
|
||||||
if (bh.GearNode is null || bh.GearMesh is null || !GodotObject.IsInstanceValid(bh.GearNode))
|
if (bh.GearNode is null || !GodotObject.IsInstanceValid(bh.GearNode))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Transform3D xf = bh.GearNode.IsInsideTree() ? bh.GearNode.GlobalTransform : ComputeWorldTransformFallback(bh.GearNode);
|
Transform3D xf = bh.GearNode.IsInsideTree() ? bh.GearNode.GlobalTransform : ComputeWorldTransformFallback(bh.GearNode);
|
||||||
pool.Submit(bh.GearMesh, in xf, new Color(0f, bh.HeatGlow, _roleIndex, 1f), wantsShadow: false);
|
if (bh.ModularParts is { } modParts)
|
||||||
|
{
|
||||||
|
Color custom = new(0f, bh.HeatGlow, bh.ManufacturerRoleIndex, 1f);
|
||||||
|
for (int p = 0; p < modParts.Length; p++)
|
||||||
|
{
|
||||||
|
Transform3D partXf = xf * modParts[p].LocalToGearPivot;
|
||||||
|
pool.Submit(modParts[p].Mesh, in partXf, in custom, wantsShadow: false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (bh.GearMesh is not null)
|
||||||
|
{
|
||||||
|
pool.Submit(bh.GearMesh, in xf, new Color(0f, bh.HeatGlow, _roleIndex, 1f), wantsShadow: false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -712,8 +839,26 @@ public sealed class VehicleVisualInstance
|
||||||
GearVisualRecipe recipe = ResolveGearRecipe(mod);
|
GearVisualRecipe recipe = ResolveGearRecipe(mod);
|
||||||
gearTemplate = _cache.GetOrLoadGear(recipe.GearGlbId);
|
gearTemplate = _cache.GetOrLoadGear(recipe.GearGlbId);
|
||||||
gearMesh = _cache.GetOrBuildGearVariantMesh(mod.Id, recipe.GearGlbId, recipe.PaintTint, recipe.AccentTint);
|
gearMesh = _cache.GetOrBuildGearVariantMesh(mod.Id, recipe.GearGlbId, recipe.PaintTint, recipe.AccentTint);
|
||||||
var gearNode = new Node3D { Name = $"Mounted_{mod.Id}_{hp.Id}" };
|
Transform3D xf = ComputeHardpointMountTransform(
|
||||||
|
hp,
|
||||||
|
anchorInfo,
|
||||||
|
recipe.VariantScale,
|
||||||
|
gearTemplate.LocalModelForward.Z,
|
||||||
|
gearTemplate.MinY);
|
||||||
|
return new Node3D
|
||||||
|
{
|
||||||
|
Name = $"Mounted_{mod.Id}_{hp.Id}",
|
||||||
|
Transform = xf
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Transform3D ComputeHardpointMountTransform(
|
||||||
|
HardpointSpec hp,
|
||||||
|
VehicleAssetCache.GlbAnchorInfo anchorInfo,
|
||||||
|
Vector3 variantScale,
|
||||||
|
float localModelForwardZ,
|
||||||
|
float minY)
|
||||||
|
{
|
||||||
Basis anchorModelBasis = anchorInfo.ModelSpaceTransform.Basis.Orthonormalized();
|
Basis anchorModelBasis = anchorInfo.ModelSpaceTransform.Basis.Orthonormalized();
|
||||||
Vector3 upOut = anchorModelBasis.Y.Normalized();
|
Vector3 upOut = anchorModelBasis.Y.Normalized();
|
||||||
if (upOut.LengthSquared() < 1e-6f) upOut = Vector3.Up;
|
if (upOut.LengthSquared() < 1e-6f) upOut = Vector3.Up;
|
||||||
|
|
@ -755,7 +900,7 @@ public sealed class VehicleVisualInstance
|
||||||
desiredGearFwd = rightX.Cross(upOut).Normalized();
|
desiredGearFwd = rightX.Cross(upOut).Normalized();
|
||||||
var desiredModelBasis = new Basis(rightX, upOut, desiredGearFwd);
|
var desiredModelBasis = new Basis(rightX, upOut, desiredGearFwd);
|
||||||
|
|
||||||
if (gearTemplate.LocalModelForward.Z < 0f)
|
if (localModelForwardZ < 0f)
|
||||||
{
|
{
|
||||||
desiredModelBasis *= new Basis(Vector3.Up, MathF.PI);
|
desiredModelBasis *= new Basis(Vector3.Up, MathF.PI);
|
||||||
}
|
}
|
||||||
|
|
@ -768,7 +913,7 @@ public sealed class VehicleVisualInstance
|
||||||
if (hp.Kind == HardpointKind.Weapon)
|
if (hp.Kind == HardpointKind.Weapon)
|
||||||
{
|
{
|
||||||
float baseScale = Math.Clamp(MathF.Min(sx, sy) / 0.56f, 0.72f, 1.75f);
|
float baseScale = Math.Clamp(MathF.Min(sx, sy) / 0.56f, 0.72f, 1.75f);
|
||||||
fitScale = recipe.VariantScale * baseScale;
|
fitScale = variantScale * baseScale;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -776,15 +921,15 @@ public sealed class VehicleVisualInstance
|
||||||
float scaleZ = Math.Clamp(sy / 0.45f, 0.72f, 2.15f);
|
float scaleZ = Math.Clamp(sy / 0.45f, 0.72f, 2.15f);
|
||||||
float scaleY = Math.Clamp(0.5f * (scaleX + scaleZ), 0.72f, 1.85f);
|
float scaleY = Math.Clamp(0.5f * (scaleX + scaleZ), 0.72f, 1.85f);
|
||||||
fitScale = new Vector3(
|
fitScale = new Vector3(
|
||||||
recipe.VariantScale.X * scaleX,
|
variantScale.X * scaleX,
|
||||||
recipe.VariantScale.Y * scaleY,
|
variantScale.Y * scaleY,
|
||||||
recipe.VariantScale.Z * scaleZ);
|
variantScale.Z * scaleZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
gearNode.Basis = localBasis * Basis.FromScale(fitScale);
|
Basis finalBasis = localBasis * Basis.FromScale(fitScale);
|
||||||
float ySeat = -gearTemplate.MinY * fitScale.Y;
|
float ySeat = -minY * fitScale.Y;
|
||||||
gearNode.Position = (anchorModelBasis.Inverse() * upOut) * ySeat;
|
Vector3 pos = (anchorModelBasis.Inverse() * upOut) * ySeat;
|
||||||
return gearNode;
|
return new Transform3D(finalBasis, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GearVisualRecipe ResolveGearRecipe(ModuleSpec mod)
|
private static GearVisualRecipe ResolveGearRecipe(ModuleSpec mod)
|
||||||
|
|
@ -886,9 +1031,22 @@ public sealed class VehicleVisualInstance
|
||||||
for (int i = 0; i < _hardpointList.Count; i++)
|
for (int i = 0; i < _hardpointList.Count; i++)
|
||||||
{
|
{
|
||||||
var bh = _hardpointList[i];
|
var bh = _hardpointList[i];
|
||||||
if (bh.GearNode is not null && bh.GearMesh is not null && GodotObject.IsInstanceValid(bh.GearNode))
|
if (bh.GearNode is null || !GodotObject.IsInstanceValid(bh.GearNode))
|
||||||
{
|
{
|
||||||
AccumulateMeshMinMaxY(bh.GearMesh, ComputeRelativeTransform(bh.GearNode, Root), out _, out float gyMax);
|
continue;
|
||||||
|
}
|
||||||
|
Transform3D gearRel = ComputeRelativeTransform(bh.GearNode, Root);
|
||||||
|
if (bh.ModularParts is { } modParts)
|
||||||
|
{
|
||||||
|
for (int p = 0; p < modParts.Length; p++)
|
||||||
|
{
|
||||||
|
AccumulateMeshMinMaxY(modParts[p].Mesh, gearRel * modParts[p].LocalToGearPivot, out _, out float pyMax);
|
||||||
|
if (pyMax > maxY) maxY = pyMax;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (bh.GearMesh is not null)
|
||||||
|
{
|
||||||
|
AccumulateMeshMinMaxY(bh.GearMesh, gearRel, out _, out float gyMax);
|
||||||
if (gyMax > maxY) maxY = gyMax;
|
if (gyMax > maxY) maxY = gyMax;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,16 @@ void resolve_role_armor(int role, out vec3 col, out float met, out float rgh) {
|
||||||
col = vec3(0.011, 0.011, 0.016); met = 0.45; rgh = 0.42; // SpectatorExemplar (#1b1b22)
|
col = vec3(0.011, 0.011, 0.016); met = 0.45; rgh = 0.42; // SpectatorExemplar (#1b1b22)
|
||||||
} else if (role == 5) {
|
} else if (role == 5) {
|
||||||
col = vec3(0.089, 0.105, 0.107); met = 0.55; rgh = 0.48; // SalvageDrop (#545b5c)
|
col = vec3(0.089, 0.105, 0.107); met = 0.55; rgh = 0.48; // SalvageDrop (#545b5c)
|
||||||
|
} else if (role == 10) {
|
||||||
|
col = vec3(0.076, 0.095, 0.051); met = 0.30; rgh = 0.58; // ScrapFrontier (#4e5740)
|
||||||
|
} else if (role == 11) {
|
||||||
|
col = vec3(0.017, 0.019, 0.022); met = 0.72; rgh = 0.40; // KorrathiIronworks (#232629)
|
||||||
|
} else if (role == 12) {
|
||||||
|
col = vec3(0.888, 0.823, 0.687); met = 0.18; rgh = 0.34; // AuralianOptics (#f2ead8)
|
||||||
|
} else if (role == 13) {
|
||||||
|
col = vec3(0.023, 0.028, 0.039); met = 0.50; rgh = 0.38; // VexNineCollective (#2a2f38)
|
||||||
|
} else if (role == 14) {
|
||||||
|
col = vec3(0.013, 0.127, 0.138); met = 0.56; rgh = 0.36; // ThalassanForge (#1e6468)
|
||||||
} else {
|
} else {
|
||||||
col = vec3(0.076, 0.095, 0.051); met = 0.28; rgh = 0.58; // Player (#4e5740)
|
col = vec3(0.076, 0.095, 0.051); met = 0.28; rgh = 0.58; // Player (#4e5740)
|
||||||
}
|
}
|
||||||
|
|
@ -159,11 +169,35 @@ void resolve_role_accent(int role, out vec3 col, out float met, out float rgh, o
|
||||||
col = vec3(0.584, 0.023, 0.023); met = 0.25; rgh = 0.36; emit_e = 0.65; // SpectatorExemplar (#c92a2a)
|
col = vec3(0.584, 0.023, 0.023); met = 0.25; rgh = 0.36; emit_e = 0.65; // SpectatorExemplar (#c92a2a)
|
||||||
} else if (role == 5) {
|
} else if (role == 5) {
|
||||||
col = vec3(0.058, 0.694, 0.807); met = 0.22; rgh = 0.34; emit_e = 0.45; // SalvageDrop (#44d9e8)
|
col = vec3(0.058, 0.694, 0.807); met = 0.22; rgh = 0.34; emit_e = 0.45; // SalvageDrop (#44d9e8)
|
||||||
|
} else if (role == 10) {
|
||||||
|
col = vec3(0.258, 0.068, 0.024); met = 0.34; rgh = 0.52; // ScrapFrontier rust (#8b4a2b)
|
||||||
|
} else if (role == 11) {
|
||||||
|
col = vec3(0.753, 0.048, 0.010); met = 0.22; rgh = 0.42; // KorrathiIronworks hazard-red (#e13e1a)
|
||||||
|
} else if (role == 12) {
|
||||||
|
col = vec3(0.791, 0.479, 0.039); met = 0.88; rgh = 0.26; // AuralianOptics gold (#e6b838)
|
||||||
|
} else if (role == 13) {
|
||||||
|
col = vec3(0.258, 0.061, 0.658); met = 0.32; rgh = 0.36; emit_e = 0.15; // VexNineCollective violet (#8b46d4)
|
||||||
|
} else if (role == 14) {
|
||||||
|
col = vec3(0.578, 0.168, 0.039); met = 0.86; rgh = 0.30; // ThalassanForge copper-brass (#c87238)
|
||||||
} else {
|
} else {
|
||||||
col = vec3(0.694, 0.150, 0.020); met = 0.18; rgh = 0.44; // Player (#d96c27)
|
col = vec3(0.694, 0.150, 0.020); met = 0.18; rgh = 0.44; // Player (#d96c27)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void resolve_role_glow(int role, inout vec3 col) {
|
||||||
|
if (role == 10) {
|
||||||
|
col = vec3(1.000, 0.402, 0.033); // ScrapFrontier amber (#ffaa33)
|
||||||
|
} else if (role == 11) {
|
||||||
|
col = vec3(0.888, 0.552, 0.016); // KorrathiIronworks hazard-yellow (#f2c422)
|
||||||
|
} else if (role == 12) {
|
||||||
|
col = vec3(0.039, 0.807, 1.000); // AuralianOptics cyan (#38e8ff)
|
||||||
|
} else if (role == 13) {
|
||||||
|
col = vec3(0.201, 0.888, 0.030); // VexNineCollective lime-optic (#7cf230)
|
||||||
|
} else if (role == 14) {
|
||||||
|
col = vec3(0.025, 0.479, 1.000); // ThalassanForge electric-blue (#2cb8ff)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void fragment() {
|
void fragment() {
|
||||||
if (v_alpha < 0.99) {
|
if (v_alpha < 0.99) {
|
||||||
float dither = fract(sin(dot(floor(FRAGCOORD.xy), vec2(12.9898, 78.233))) * 43758.5453);
|
float dither = fract(sin(dot(floor(FRAGCOORD.xy), vec2(12.9898, 78.233))) * 43758.5453);
|
||||||
|
|
@ -194,6 +228,9 @@ void fragment() {
|
||||||
} else if (band == 4) {
|
} else if (band == 4) {
|
||||||
resolve_role_accent(role, mat_base_col, mat_metal, mat_rough, mat_static_emit);
|
resolve_role_accent(role, mat_base_col, mat_metal, mat_rough, mat_static_emit);
|
||||||
} else if (band == 5) {
|
} else if (band == 5) {
|
||||||
|
if (role >= 10 && role <= 14) {
|
||||||
|
resolve_role_glow(role, mat_base_col);
|
||||||
|
}
|
||||||
mat_metal = 0.15;
|
mat_metal = 0.15;
|
||||||
mat_static_emit = 1.85;
|
mat_static_emit = 1.85;
|
||||||
mat_wear = 0.0;
|
mat_wear = 0.0;
|
||||||
|
|
|
||||||
|
|
@ -277,6 +277,7 @@ public partial class Smoke : Node
|
||||||
await VerifyMaxLoadPaladinGarageAsync();
|
await VerifyMaxLoadPaladinGarageAsync();
|
||||||
await VerifySionMapAsync();
|
await VerifySionMapAsync();
|
||||||
await VerifyOrbitalDropSequenceAsync();
|
await VerifyOrbitalDropSequenceAsync();
|
||||||
|
await VerifyCut7bModularOrdnanceAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task VerifyHudAndShadersAsync(bool isHeadless)
|
private async Task VerifyHudAndShadersAsync(bool isHeadless)
|
||||||
|
|
@ -2006,6 +2007,275 @@ public partial class Smoke : Node
|
||||||
GD.Print($"SMOKE INFO: Cut 6b OrbitalDrop verified (touchdownTick={touchdownTick}, debris={debrisAtTouchdown}, postDisp={postDisp:F2}m, bucketsDelta={bucketsDuringDrop - bucketsBefore}, matDups={VehicleVisualInstance.PerfMaterialDupCount})");
|
GD.Print($"SMOKE INFO: Cut 6b OrbitalDrop verified (touchdownTick={touchdownTick}, debris={debrisAtTouchdown}, postDisp={postDisp:F2}m, bucketsDelta={bucketsDuringDrop - bucketsBefore}, matDups={VehicleVisualInstance.PerfMaterialDupCount})");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task VerifyCut7bModularOrdnanceAsync()
|
||||||
|
{
|
||||||
|
var cache = _main.Arena.AssetCache;
|
||||||
|
var partPool = _main.Arena.PartPool;
|
||||||
|
|
||||||
|
// 1. All 16 modular weapon sub-parts loaded with single-surface COLOR_0 meshes and required sockets
|
||||||
|
Check(cache.WeaponParts.Count == 16, $"Expected 16 cached modular weapon parts, got {cache.WeaponParts.Count}");
|
||||||
|
foreach (string pid in VehicleAssetCache.ExpectedWeaponPartIds)
|
||||||
|
{
|
||||||
|
var wp = cache.GetOrLoadWeaponPart(pid);
|
||||||
|
Check(wp.SingleSurfaceMesh.GetSurfaceCount() == 1,
|
||||||
|
$"Expected 1 surface on modular part '{pid}', got {wp.SingleSurfaceMesh.GetSurfaceCount()}");
|
||||||
|
var arr = wp.SingleSurfaceMesh.SurfaceGetArrays(0);
|
||||||
|
Check(arr.Count > (int)Mesh.ArrayType.Color && arr[(int)Mesh.ArrayType.Color].VariantType == Variant.Type.PackedColorArray,
|
||||||
|
$"Modular part '{pid}' missing COLOR_0 attribute");
|
||||||
|
if (wp.Slot == "receiver")
|
||||||
|
{
|
||||||
|
Check(wp.SocketsLocal.ContainsKey("barrel") && wp.SocketsLocal.ContainsKey("feed"),
|
||||||
|
$"Receiver '{pid}' missing barrel/feed sockets");
|
||||||
|
}
|
||||||
|
else if (wp.Slot == "barrel")
|
||||||
|
{
|
||||||
|
Check(wp.SocketsLocal.ContainsKey("muzzle"), $"Barrel '{pid}' missing muzzle socket");
|
||||||
|
}
|
||||||
|
else if (wp.Slot == "muzzle")
|
||||||
|
{
|
||||||
|
Check(wp.SocketsLocal.ContainsKey("muzzle_tip"), $"Muzzle '{pid}' missing muzzle_tip socket");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Mount 50 distinct procedural weapons across all 5 manufacturers & 20 archetypes -> <= 16 new PartPool buckets, 0 matDups
|
||||||
|
VehicleVisualInstance.PerfMaterialDupCount = 0;
|
||||||
|
var testVis = VehicleVisualInstance.Create(cache, "anvil", VehicleVisualRole.Player);
|
||||||
|
AddChild(testVis.Root);
|
||||||
|
var testGrid = Catalog.CreateWithDefaultLoadout(Catalog.Anvil);
|
||||||
|
string? weaponHpId = null;
|
||||||
|
for (int i = 0; i < testGrid.Spec.Hardpoints.Length; i++)
|
||||||
|
{
|
||||||
|
if (testGrid.Spec.Hardpoints[i].Kind == HardpointKind.Weapon &&
|
||||||
|
testGrid.Spec.Hardpoints[i].Height >= 2)
|
||||||
|
{
|
||||||
|
weaponHpId = testGrid.Spec.Hardpoints[i].Id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Check(weaponHpId is not null, "Expected Anvil to have a 1x2 weapon hardpoint for modular assembly test");
|
||||||
|
|
||||||
|
// Pre-warm baseline Anvil chassis/cell buckets in PartPool so bucketDelta measures ONLY modular weapon parts
|
||||||
|
if (weaponHpId is not null)
|
||||||
|
{
|
||||||
|
testGrid.Mounted.RemoveAll(m => m.HardpointId == weaponHpId);
|
||||||
|
}
|
||||||
|
testVis.SyncMountedGear(testGrid);
|
||||||
|
partPool.BeginFrame(null);
|
||||||
|
testVis.SubmitToPool(partPool);
|
||||||
|
partPool.EndFrame();
|
||||||
|
int bucketsBefore = partPool.BucketCount;
|
||||||
|
|
||||||
|
partPool.BeginFrame(null);
|
||||||
|
if (weaponHpId is not null)
|
||||||
|
{
|
||||||
|
for (int w = 0; w < 50; w++)
|
||||||
|
{
|
||||||
|
byte mfg = (byte)(w % 5);
|
||||||
|
byte arch = (byte)(mfg * 4 + (w % 4));
|
||||||
|
var pSpec = ProceduralWeaponGenerator.Generate(new ProceduralWeaponKey((ulong)(0xA100 + w), mfg, arch, (byte)(w & 3), 0));
|
||||||
|
testGrid.Mounted.RemoveAll(m => m.HardpointId == weaponHpId);
|
||||||
|
Check(testGrid.TryMount(pSpec.Module, weaponHpId), $"Failed to mount procedural weapon '{pSpec.DisplayName}' on '{weaponHpId}'");
|
||||||
|
testVis.SyncMountedGear(testGrid);
|
||||||
|
testVis.SubmitToPool(partPool);
|
||||||
|
|
||||||
|
if (w < 5)
|
||||||
|
{
|
||||||
|
bool hasAim = testVis.TryGetMountedWeaponCentroidsInModel(weaponHpId, "muzzle", "receiver", out Vector3 frontC, out Vector3 rearC);
|
||||||
|
Check(hasAim && (frontC.Z > rearC.Z + 0.35f),
|
||||||
|
$"Expected modular weapon '{pSpec.DisplayName}' muzzle ({frontC}) forward of receiver ({rearC})");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
partPool.EndFrame();
|
||||||
|
|
||||||
|
int bucketDelta = partPool.BucketCount - bucketsBefore;
|
||||||
|
Check(bucketDelta <= 16, $"Expected 50 procedural weapons to add <= 16 PartPool buckets, added {bucketDelta}");
|
||||||
|
Check(VehicleVisualInstance.PerfMaterialDupCount == 0, $"Expected 0 material duplications, got {VehicleVisualInstance.PerfMaterialDupCount}");
|
||||||
|
Check(CountMeshInstances(testVis.Root) == 0, $"Expected 0 MeshInstance3D children on modular vehicle rig, got {CountMeshInstances(testVis.Root)}");
|
||||||
|
|
||||||
|
// Verify shearing a modular weapon hardpoint spawns all 4 sub-parts into DebrisSystem
|
||||||
|
if (weaponHpId is not null)
|
||||||
|
{
|
||||||
|
var testDebris = new DebrisSystem { Name = "SmokeModularShearDebris" };
|
||||||
|
AddChild(testDebris);
|
||||||
|
var hp = testGrid.FindHardpoint(weaponHpId)!;
|
||||||
|
for (int dy = 0; dy < hp.Height; dy++)
|
||||||
|
{
|
||||||
|
for (int dx = 0; dx < hp.Width; dx++)
|
||||||
|
{
|
||||||
|
testGrid.Armor[hp.X + dx, hp.Y + dy] = 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
testVis.SyncDamageAndHeat(testGrid, testDebris, Vector3.Zero);
|
||||||
|
Check(testDebris.ActiveCount >= 4, $"Expected >= 4 sheared modular sub-parts in DebrisSystem, got {testDebris.ActiveCount}");
|
||||||
|
testDebris.QueueFree();
|
||||||
|
}
|
||||||
|
testVis.Root.QueueFree();
|
||||||
|
|
||||||
|
// 3. Procedural weapon GroundDrops render with modular parts & clean up on pickup
|
||||||
|
_main.Reset(77, ArenaMapKind.Desert, skipInitialDrop: true);
|
||||||
|
_main.SetPhysicsProcess(false);
|
||||||
|
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||||
|
|
||||||
|
var state = _main.Session.ViewState;
|
||||||
|
var player = _main.Session.LocalContender;
|
||||||
|
int dropsBefore = state.GroundDrops.Count;
|
||||||
|
_main.Arena.Sync(_main.Session, 1.0f, 1f / 60f, 1f);
|
||||||
|
int trackedBefore = _main.Arena.ActiveDropVisualCount;
|
||||||
|
|
||||||
|
var procDrops = new List<GroundDrop>(5);
|
||||||
|
for (int m = 0; m < 5; m++)
|
||||||
|
{
|
||||||
|
var pSpec = ProceduralWeaponGenerator.RollForManufacturer((ManufacturerId)m, tier: 2, seed: (ulong)(0x7700 + m));
|
||||||
|
var gd = new GroundDrop(95000 + m, player.X + 4f + m * 6f, player.Z + 8f, null, pSpec.Module);
|
||||||
|
state.GroundDrops.Add(gd);
|
||||||
|
procDrops.Add(gd);
|
||||||
|
}
|
||||||
|
_main.Arena.Sync(_main.Session, 1.1f, 1f / 60f, 1f);
|
||||||
|
Check(_main.Arena.ActiveDropVisualCount == trackedBefore + 5,
|
||||||
|
$"Expected {trackedBefore + 5} tracked drops after adding 5 mfg drops, got {_main.Arena.ActiveDropVisualCount}");
|
||||||
|
|
||||||
|
// 4. HUD 6 chrome panels, 2-line Borderlands tooltips (Garage + Hover + Pickup Prompt), zero overlap at 1280x720
|
||||||
|
var sabotDream = ProceduralWeaponGenerator.CreateDreamSabotSled();
|
||||||
|
var droneDream = ProceduralWeaponGenerator.CreateDreamLoiteringDrone();
|
||||||
|
var mirvDream = ProceduralWeaponGenerator.CreateDreamMirvMineBlanket();
|
||||||
|
|
||||||
|
var pGrid = player.Grid;
|
||||||
|
string? pWeaponHp = null;
|
||||||
|
HardpointSpec? pWeaponHpSpec = null;
|
||||||
|
for (int i = 0; i < pGrid.Spec.Hardpoints.Length; i++)
|
||||||
|
{
|
||||||
|
if (pGrid.Spec.Hardpoints[i].Kind == HardpointKind.Weapon && pGrid.Spec.Hardpoints[i].Height >= 2)
|
||||||
|
{
|
||||||
|
pWeaponHp = pGrid.Spec.Hardpoints[i].Id;
|
||||||
|
pWeaponHpSpec = pGrid.Spec.Hardpoints[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pWeaponHp is not null && pWeaponHpSpec is not null)
|
||||||
|
{
|
||||||
|
pGrid.Mounted.RemoveAll(m => m.HardpointId == pWeaponHp);
|
||||||
|
Check(pGrid.TryMount(sabotDream.Module, pWeaponHp), "Expected Dream Sabot Sled to mount on player");
|
||||||
|
if (!_main.Hud.GarageExpanded) _main.Hud.ToggleGarage();
|
||||||
|
_main.Hud.Sync(_main.Session);
|
||||||
|
_main.Hud.SimulateCellHover(new Vector2I(pWeaponHpSpec.X, pWeaponHpSpec.Y), pWeaponHpSpec);
|
||||||
|
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||||
|
|
||||||
|
int chromeCount = 0;
|
||||||
|
foreach (var _ in _main.Hud.GetChromeMaterials()) chromeCount++;
|
||||||
|
Check(chromeCount == 6, $"Expected 6 HUD chrome panels, got {chromeCount}");
|
||||||
|
Check(_main.Hud.HoverLabelText.Contains(sabotDream.ManufacturerLabel) && _main.Hud.HoverLabelText.Contains('\n'),
|
||||||
|
$"Expected 2-line Borderlands hover tooltip with manufacturer badge, got: {_main.Hud.HoverLabelText}");
|
||||||
|
Check(_main.Hud.GarageDetailsText.Contains(sabotDream.SummaryLine1) && _main.Hud.GarageDetailsText.Contains(sabotDream.SummaryLine2),
|
||||||
|
$"Expected Garage details to contain SummaryLine1 & SummaryLine2, got: {_main.Hud.GarageDetailsText}");
|
||||||
|
|
||||||
|
// Check nearby pickup prompt 2-line display
|
||||||
|
var nearbyDrop = new GroundDrop(95999, player.X + 1.0f, player.Z + 1.0f, null, droneDream.Module);
|
||||||
|
state.GroundDrops.Add(nearbyDrop);
|
||||||
|
_main.Hud.Sync(_main.Session);
|
||||||
|
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||||
|
Check(_main.Hud.PromptLabelText.Contains(droneDream.ManufacturerLabel) && _main.Hud.PromptLabelText.Contains('\n'),
|
||||||
|
$"Expected 2-line pickup prompt with manufacturer & summary, got: {_main.Hud.PromptLabelText}");
|
||||||
|
|
||||||
|
Vector2 vpSize = GetViewport().GetVisibleRect().Size;
|
||||||
|
Check(!_main.Hud.HasPanelOverlapOrClip(vpSize), $"HUD overlapped or clipped with procedural tooltip at {vpSize}");
|
||||||
|
|
||||||
|
nearbyDrop.PickedUp = true;
|
||||||
|
state.GroundDrops.Remove(nearbyDrop);
|
||||||
|
if (_main.Hud.GarageExpanded) _main.Hud.ToggleGarage();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < procDrops.Count; i++) procDrops[i].PickedUp = true;
|
||||||
|
_main.Arena.Sync(_main.Session, 1.2f, 1f / 60f, 1f);
|
||||||
|
state.GroundDrops.RemoveRange(dropsBefore, procDrops.Count);
|
||||||
|
|
||||||
|
// 5. ClientOrdnanceMirror + Haven MWO Audio Hooks across Sabot, Loitering Drone, and MIRV Mines
|
||||||
|
var localSession = (_main.Session as LocalArenaSession)!;
|
||||||
|
var sim = localSession.Inner;
|
||||||
|
for (int cIdx = 1; cIdx < sim.State.Contenders.Count; cIdx++)
|
||||||
|
{
|
||||||
|
sim.SetContenderPose(cIdx, 480f + cIdx * 12f, 480f);
|
||||||
|
}
|
||||||
|
sim.SetContenderPose(0, 0f, 0f, 0f);
|
||||||
|
sim.SetContenderPose(1, 0f, 125f, MathF.PI); // target Anvil/rival 125m ahead
|
||||||
|
|
||||||
|
int audioShotsBefore = _main.Audio.Total3DPlaysRequested;
|
||||||
|
bool sawMirrorRocket = false;
|
||||||
|
bool sawSabotTransition = false;
|
||||||
|
bool sawMirrorDrone = false;
|
||||||
|
bool sawMirrorMines = false;
|
||||||
|
|
||||||
|
// 5a: Sabot Rocket Sled
|
||||||
|
if (pWeaponHp is not null)
|
||||||
|
{
|
||||||
|
pGrid.Mounted.RemoveAll(m => m.HardpointId == pWeaponHp);
|
||||||
|
pGrid.TryMount(sabotDream.Module, pWeaponHp);
|
||||||
|
for (int t = 0; t < 35; t++)
|
||||||
|
{
|
||||||
|
var inp = new PlayerInput(0f, 0f, 0f, 125f, Fire: t == 0, InteractPickup: false, Brake: true);
|
||||||
|
_main.Session.SubmitLocalInput(in inp, isPhysicsTick: true);
|
||||||
|
var evs = new List<ISimEvent>(16);
|
||||||
|
_main.Session.DrainSimEvents(evs);
|
||||||
|
for (int e = 0; e < evs.Count; e++)
|
||||||
|
{
|
||||||
|
if (evs[e] is OrdnanceNodeEvent oe && (OrdnanceEventKind)oe.Kind == OrdnanceEventKind.StageTransition)
|
||||||
|
{
|
||||||
|
sawSabotTransition = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_main.Arena.Sync(_main.Session, 2.0f + t / 60f, 1f / 60f, 1f);
|
||||||
|
_main.Arena.ConsumeEvents(_main.Session, evs, Array.Empty<FootstepPulse>(), 1f / 60f, _main.SampleCurrentMapGroundTint);
|
||||||
|
_main.Audio.UpdateFrame(_main.Session, evs, Array.Empty<FootstepPulse>(), _main.Camera.GlobalPosition, 1f / 60f, 1f);
|
||||||
|
if (_main.Arena.OrdnanceMirror.ActiveCount > 0) sawMirrorRocket = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5b: Loitering Laser Drone
|
||||||
|
pGrid.Mounted.RemoveAll(m => m.HardpointId == pWeaponHp);
|
||||||
|
pGrid.TryMount(droneDream.Module, pWeaponHp);
|
||||||
|
for (int t = 0; t < 95; t++)
|
||||||
|
{
|
||||||
|
var inp = new PlayerInput(0f, 0f, 0f, 125f, Fire: t == 0, InteractPickup: false, Brake: true);
|
||||||
|
_main.Session.SubmitLocalInput(in inp, isPhysicsTick: true);
|
||||||
|
var evs = new List<ISimEvent>(16);
|
||||||
|
_main.Session.DrainSimEvents(evs);
|
||||||
|
_main.Arena.Sync(_main.Session, 3.0f + t / 60f, 1f / 60f, 1f);
|
||||||
|
_main.Arena.ConsumeEvents(_main.Session, evs, Array.Empty<FootstepPulse>(), 1f / 60f, _main.SampleCurrentMapGroundTint);
|
||||||
|
_main.Audio.UpdateFrame(_main.Session, evs, Array.Empty<FootstepPulse>(), _main.Camera.GlobalPosition, 1f / 60f, 1f);
|
||||||
|
if (t > 70 && _main.Arena.OrdnanceMirror.ActiveCount > 0) sawMirrorDrone = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5c: MIRV Minefield Blanket
|
||||||
|
pGrid.Mounted.RemoveAll(m => m.HardpointId == pWeaponHp);
|
||||||
|
pGrid.TryMount(mirvDream.Module, pWeaponHp);
|
||||||
|
for (int t = 0; t < 160; t++)
|
||||||
|
{
|
||||||
|
var inp = new PlayerInput(0f, 0f, 0f, 85f, Fire: t == 0, InteractPickup: false, Brake: true);
|
||||||
|
_main.Session.SubmitLocalInput(in inp, isPhysicsTick: true);
|
||||||
|
var evs = new List<ISimEvent>(32);
|
||||||
|
_main.Session.DrainSimEvents(evs);
|
||||||
|
_main.Arena.Sync(_main.Session, 5.0f + t / 60f, 1f / 60f, 1f);
|
||||||
|
_main.Arena.ConsumeEvents(_main.Session, evs, Array.Empty<FootstepPulse>(), 1f / 60f, _main.SampleCurrentMapGroundTint);
|
||||||
|
_main.Audio.UpdateFrame(_main.Session, evs, Array.Empty<FootstepPulse>(), _main.Camera.GlobalPosition, 1f / 60f, 1f);
|
||||||
|
if (_main.Arena.OrdnanceMirror.ActiveCount >= 6) sawMirrorMines = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Check(sawMirrorRocket && sawSabotTransition,
|
||||||
|
$"Expected ClientOrdnanceMirror to track Sabot rocket & StageTransition (rocket={sawMirrorRocket}, trans={sawSabotTransition})");
|
||||||
|
Check(sawMirrorDrone, "Expected ClientOrdnanceMirror to maintain active Loitering Laser Drone after climb");
|
||||||
|
Check(sawMirrorMines, "Expected ClientOrdnanceMirror to mirror >= 6 MIRV mines after Split");
|
||||||
|
Check(_main.Audio.Total3DPlaysRequested > audioShotsBefore,
|
||||||
|
$"Expected ArenaAudioSystem Haven MWO ordnance cues to trigger (before={audioShotsBefore}, after={_main.Audio.Total3DPlaysRequested})");
|
||||||
|
|
||||||
|
// Verify MatchResetEvent clears ClientOrdnanceMirror cleanly
|
||||||
|
_main.Arena.ConsumeEvents(_main.Session, new ISimEvent[] { new MatchResetEvent() }, Array.Empty<FootstepPulse>(), 1f / 60f, _main.SampleCurrentMapGroundTint);
|
||||||
|
Check(_main.Arena.OrdnanceMirror.ActiveCount == 0,
|
||||||
|
$"Expected MatchResetEvent to clear ClientOrdnanceMirror, got {_main.Arena.OrdnanceMirror.ActiveCount}");
|
||||||
|
|
||||||
|
_main.SetPhysicsProcess(true);
|
||||||
|
GD.Print($"SMOKE INFO: Cut 7b verified (16 parts, bucketDelta={bucketDelta}, matDups={VehicleVisualInstance.PerfMaterialDupCount}, audioPlays={_main.Audio.Total3DPlaysRequested - audioShotsBefore})");
|
||||||
|
}
|
||||||
|
|
||||||
private static int CountPremulViolations(Image img, float tolerance)
|
private static int CountPremulViolations(Image img, float tolerance)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
|
||||||
353
tools/vehicles/build_weapon_parts.py
Normal file
353
tools/vehicles/build_weapon_parts.py
Normal file
|
|
@ -0,0 +1,353 @@
|
||||||
|
"""Build the 16 modular Brokkr procedural weapon sub-parts into assets/gear/parts/*.glb."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import math
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
import bmesh
|
||||||
|
import bpy
|
||||||
|
from mathutils import Matrix
|
||||||
|
|
||||||
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||||
|
import vehicle_common as vc # noqa: E402
|
||||||
|
import bake_vertex_weathering as bvw # noqa: E402
|
||||||
|
|
||||||
|
PARTS_DIR = vc.ASSETS_GEAR_DIR / "parts"
|
||||||
|
|
||||||
|
WEAPON_PART_PALETTE: dict[str, dict[str, Any]] = {
|
||||||
|
"mfg_primary": {"hex": "#4e5740", "metallic": 0.35, "roughness": 0.50},
|
||||||
|
"mfg_accent": {"hex": "#e8621a", "metallic": 0.38, "roughness": 0.40},
|
||||||
|
"mfg_glow": {"hex": "#38e8ff", "metallic": 0.18, "roughness": 0.24, "emission": "#38e8ff", "emission_strength": 1.85},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def ensure_weapon_part_materials() -> None:
|
||||||
|
vc.ensure_materials()
|
||||||
|
for name, spec in WEAPON_PART_PALETTE.items():
|
||||||
|
mat = bpy.data.materials.get(name)
|
||||||
|
if mat is None:
|
||||||
|
mat = bpy.data.materials.new(name=name)
|
||||||
|
mat.use_nodes = True
|
||||||
|
nt = mat.node_tree
|
||||||
|
nt.nodes.clear()
|
||||||
|
out = nt.nodes.new("ShaderNodeOutputMaterial")
|
||||||
|
bsdf = nt.nodes.new("ShaderNodeBsdfPrincipled")
|
||||||
|
nt.links.new(bsdf.outputs["BSDF"], out.inputs["Surface"])
|
||||||
|
bsdf.inputs["Base Color"].default_value = vc.srgb_hex_to_linear(spec["hex"])
|
||||||
|
bsdf.inputs["Metallic"].default_value = float(spec["metallic"])
|
||||||
|
bsdf.inputs["Roughness"].default_value = float(spec["roughness"])
|
||||||
|
if "emission" in spec:
|
||||||
|
bsdf.inputs["Emission Color"].default_value = vc.srgb_hex_to_linear(spec["emission"])
|
||||||
|
bsdf.inputs["Emission Strength"].default_value = float(spec.get("emission_strength", 1.0))
|
||||||
|
|
||||||
|
|
||||||
|
def _make_socket(name: str, socket_tag: str, parent: bpy.types.Object, location: tuple[float, float, float]) -> bpy.types.Object:
|
||||||
|
emp = vc.make_empty(name, parent=parent, location=location, display_size=0.06)
|
||||||
|
emp["rtd.socket"] = socket_tag
|
||||||
|
return emp
|
||||||
|
|
||||||
|
|
||||||
|
def _export_part(name: str, slot: str, root: bpy.types.Object, ground: bool) -> None:
|
||||||
|
root["rtd.part_slot"] = slot
|
||||||
|
glb_path = PARTS_DIR / f"{name}.glb"
|
||||||
|
tris, bounds = vc.export_vehicle_glb(glb_path, root=root if ground else None)
|
||||||
|
stats = bvw.bake_glb(glb_path)
|
||||||
|
print(f"[weapon_part:{slot}:{name}] tris={tris} bounds={bounds} ao_min={stats['ao_min']:.2f} bytes={glb_path.stat().st_size}")
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# 4 RECEIVERS (grounded at minY = 0, forward = -Y_blender = +Z_gltf)
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def build_rx_salvage_frame() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
vc.make_tube_part("pintle_base", 0.16, 0.14, 0.06, segments=12, mat_name="gunmetal", parent=root)
|
||||||
|
vc.make_box("cradle_yoke", (0.20, 0.24, 0.14), "gunmetal", parent=root, location=(0.0, 0.02, 0.12), bevel=0.006)
|
||||||
|
vc.make_box("receiver_hull", (0.18, 0.44, 0.16), "mfg_primary", parent=root, location=(0.0, -0.02, 0.22), bevel=0.008)
|
||||||
|
for side in (-1.0, 1.0):
|
||||||
|
tag = "L" if side > 0 else "R"
|
||||||
|
vc.make_box(f"cheek_plate_{tag}", (0.04, 0.30, 0.11), "mfg_accent", parent=root, location=(side * 0.105, -0.04, 0.23), bevel=0.005)
|
||||||
|
vc.make_tube_part(f"rear_grip_{tag}", 0.013, 0.013, 0.11, segments=8, mat_name="rubber_dark", parent=root, location=(side * 0.065, 0.22, 0.18))
|
||||||
|
vc.make_box("status_lamp", (0.06, 0.08, 0.03), "mfg_glow", parent=root, location=(0.0, 0.06, 0.31), bevel=0.003)
|
||||||
|
_make_socket("socket.barrel", "barrel", root, (0.0, -0.24, 0.22))
|
||||||
|
_make_socket("socket.feed", "feed", root, (0.125, 0.02, 0.22))
|
||||||
|
_export_part("rx_salvage_frame", "receiver", root, ground=True)
|
||||||
|
|
||||||
|
|
||||||
|
def build_rx_korrathi_cradle() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
vc.make_tube_part("turret_collar", 0.24, 0.21, 0.07, segments=8, smooth=False, mat_name="gunmetal", parent=root)
|
||||||
|
vc.make_box("armored_breech", (0.30, 0.48, 0.22), "mfg_primary", parent=root, location=(0.0, 0.0, 0.18), bevel=0.012)
|
||||||
|
vc.make_box("brow_visor", (0.26, 0.34, 0.06), "mfg_accent", parent=root, location=(0.0, -0.06, 0.31), bevel=0.006)
|
||||||
|
for side in (-1.0, 1.0):
|
||||||
|
tag = "L" if side > 0 else "R"
|
||||||
|
vc.make_tube_part(f"recoil_piston_{tag}", 0.028, 0.028, 0.34, segments=10, mat_name="copper_rad", parent=root, location=(side * 0.11, 0.16, 0.22), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
vc.make_box(f"side_rib_{tag}", (0.045, 0.28, 0.12), "gunmetal", parent=root, location=(side * 0.165, -0.02, 0.18), bevel=0.005)
|
||||||
|
vc.make_box("charge_strip", (0.14, 0.18, 0.025), "mfg_glow", parent=root, location=(0.0, -0.10, 0.345), bevel=0.003)
|
||||||
|
_make_socket("socket.barrel", "barrel", root, (0.0, -0.24, 0.20))
|
||||||
|
_make_socket("socket.feed", "feed", root, (0.185, 0.02, 0.19))
|
||||||
|
_export_part("rx_korrathi_cradle", "receiver", root, ground=True)
|
||||||
|
|
||||||
|
|
||||||
|
def build_rx_auralian_prism() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
vc.make_tube_part("gimbal_base", 0.21, 0.17, 0.075, segments=16, mat_name="mfg_accent", parent=root)
|
||||||
|
vc.make_box("condenser_shroud", (0.24, 0.50, 0.20), "mfg_primary", parent=root, location=(0.0, 0.0, 0.175), bevel=0.015)
|
||||||
|
vc.make_box("dorsal_crest", (0.09, 0.40, 0.075), "mfg_accent", parent=root, location=(0.0, 0.02, 0.30), bevel=0.008)
|
||||||
|
vc.make_box("optic_spine", (0.036, 0.32, 0.032), "mfg_glow", parent=root, location=(0.0, 0.0, 0.345), bevel=0.004)
|
||||||
|
for side in (-1.0, 1.0):
|
||||||
|
tag = "L" if side > 0 else "R"
|
||||||
|
vc.make_box(f"side_vent_{tag}", (0.03, 0.26, 0.06), "mfg_glow", parent=root, location=(side * 0.125, -0.02, 0.18), bevel=0.003)
|
||||||
|
_make_socket("socket.barrel", "barrel", root, (0.0, -0.25, 0.19))
|
||||||
|
_make_socket("socket.feed", "feed", root, (0.135, 0.02, 0.18))
|
||||||
|
_export_part("rx_auralian_prism", "receiver", root, ground=True)
|
||||||
|
|
||||||
|
|
||||||
|
def build_rx_vex_pod_rack() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
vc.make_tube_part("hex_pedestal", 0.22, 0.20, 0.065, segments=6, smooth=False, mat_name="gunmetal", parent=root)
|
||||||
|
vc.make_box("turret_core", (0.28, 0.42, 0.20), "mfg_primary", parent=root, location=(0.0, 0.02, 0.165), bevel=0.012)
|
||||||
|
vc.make_box("sensor_cowl", (0.22, 0.24, 0.09), "mfg_accent", parent=root, location=(0.0, -0.06, 0.295), bevel=0.008)
|
||||||
|
for idx, ox in enumerate((-0.065, 0.0, 0.065)):
|
||||||
|
vc.make_tube_part(f"seeker_eye_{idx}", 0.022, 0.022, 0.05, segments=10, mat_name="mfg_glow", parent=root, location=(ox, -0.17, 0.30), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
for side in (-1.0, 1.0):
|
||||||
|
vc.make_box(f"wing_cheek_{'L' if side > 0 else 'R'}", (0.05, 0.32, 0.12), "gunmetal", parent=root, location=(side * 0.16, 0.02, 0.17), rotation_deg=(0.0, 12.0 * side, 0.0), bevel=0.005)
|
||||||
|
_make_socket("socket.barrel", "barrel", root, (0.0, -0.19, 0.18))
|
||||||
|
_make_socket("socket.feed", "feed", root, (0.18, 0.02, 0.17))
|
||||||
|
_export_part("rx_vex_pod_rack", "receiver", root, ground=True)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# 4 BARRELS (origin = rear breech at (0,0,0), forward = -Y_blender = +Z_gltf)
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def build_brl_autocannon() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
vc.make_box("breech_collar", (0.18, 0.12, 0.13), "gunmetal", parent=root, location=(0.0, -0.06, 0.0), bevel=0.006)
|
||||||
|
for side in (-1.0, 1.0):
|
||||||
|
tag = "L" if side > 0 else "R"
|
||||||
|
vc.make_tube_part(f"jacket_{tag}", 0.036, 0.032, 0.38, segments=10, mat_name="mfg_primary", parent=root, location=(side * 0.048, 0.0, 0.0), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
vc.make_tube_part(f"barrel_{tag}", 0.019, 0.019, 0.58, segments=10, mat_name="gunmetal", parent=root, location=(side * 0.048, 0.0, 0.0), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
vc.make_box("clamp_band_a", (0.15, 0.04, 0.09), "mfg_accent", parent=root, location=(0.0, -0.22, 0.0), bevel=0.004)
|
||||||
|
vc.make_box("clamp_band_b", (0.14, 0.04, 0.08), "mfg_accent", parent=root, location=(0.0, -0.44, 0.0), bevel=0.004)
|
||||||
|
_make_socket("socket.muzzle", "muzzle", root, (0.0, -0.58, 0.0))
|
||||||
|
_export_part("brl_autocannon", "barrel", root, ground=False)
|
||||||
|
|
||||||
|
|
||||||
|
def build_brl_sabot_rail() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
vc.make_box("rail_breech", (0.20, 0.14, 0.15), "mfg_primary", parent=root, location=(0.0, -0.07, 0.0), bevel=0.008)
|
||||||
|
for side in (-1.0, 1.0):
|
||||||
|
tag = "L" if side > 0 else "R"
|
||||||
|
vc.make_box(f"rail_bar_{tag}", (0.035, 0.68, 0.075), "gunmetal", parent=root, location=(side * 0.052, -0.34, 0.0), bevel=0.004)
|
||||||
|
vc.make_box(f"rail_glow_{tag}", (0.014, 0.56, 0.025), "mfg_glow", parent=root, location=(side * 0.028, -0.37, 0.0), bevel=0.002)
|
||||||
|
vc.make_box("rail_spine", (0.08, 0.58, 0.035), "mfg_accent", parent=root, location=(0.0, -0.36, 0.055), bevel=0.004)
|
||||||
|
for idx, dy in enumerate((-0.20, -0.38, -0.54)):
|
||||||
|
vc.make_box(f"coil_yoke_{idx}", (0.15, 0.045, 0.11), "copper_rad", parent=root, location=(0.0, dy, 0.0), bevel=0.004)
|
||||||
|
_make_socket("socket.muzzle", "muzzle", root, (0.0, -0.68, 0.0))
|
||||||
|
_export_part("brl_sabot_rail", "barrel", root, ground=False)
|
||||||
|
|
||||||
|
|
||||||
|
def build_brl_prism_lance() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
vc.make_tube_part("emitter_collar", 0.085, 0.070, 0.14, segments=14, mat_name="mfg_accent", parent=root, location=(0.0, 0.0, 0.0), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
vc.make_tube_part("lance_core", 0.048, 0.028, 0.66, segments=12, mat_name="mfg_primary", parent=root, location=(0.0, 0.0, 0.0), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
vc.make_box("focus_vane", (0.028, 0.52, 0.055), "mfg_accent", parent=root, location=(0.0, -0.32, 0.058), bevel=0.004)
|
||||||
|
for idx, dy in enumerate((-0.22, -0.39, -0.56)):
|
||||||
|
r = 0.068 - idx * 0.007
|
||||||
|
vc.make_tube_part(f"condenser_ring_{idx}", r, r, 0.038, segments=14, mat_name="mfg_glow", parent=root, location=(0.0, dy, 0.0), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
_make_socket("socket.muzzle", "muzzle", root, (0.0, -0.66, 0.0))
|
||||||
|
_export_part("brl_prism_lance", "barrel", root, ground=False)
|
||||||
|
|
||||||
|
|
||||||
|
def build_brl_missile_tube() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
vc.make_box("launch_shroud", (0.24, 0.44, 0.22), "mfg_primary", parent=root, location=(0.0, -0.22, 0.0), bevel=0.012)
|
||||||
|
vc.make_box("front_flare_lip", (0.265, 0.06, 0.245), "mfg_accent", parent=root, location=(0.0, -0.45, 0.0), bevel=0.006)
|
||||||
|
for ix in (-0.055, 0.055):
|
||||||
|
for iz in (-0.050, 0.050):
|
||||||
|
vc.make_tube_part(f"cell_{ix:+.2f}_{iz:+.2f}", 0.038, 0.038, 0.49, segments=10, mat_name="gunmetal", parent=root, location=(ix, 0.0, iz), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
vc.make_box("arm_led_bar", (0.16, 0.04, 0.025), "mfg_glow", parent=root, location=(0.0, -0.40, 0.12), bevel=0.003)
|
||||||
|
_make_socket("socket.muzzle", "muzzle", root, (0.0, -0.48, 0.0))
|
||||||
|
_export_part("brl_missile_tube", "barrel", root, ground=False)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# 4 FEEDS (origin = inboard mount flange at (0,0,0), body extends +X)
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def build_fd_belt_drum() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
vc.make_box("mount_bracket", (0.06, 0.14, 0.12), "gunmetal", parent=root, location=(0.03, 0.0, 0.0), bevel=0.004)
|
||||||
|
vc.make_tube_part("ammo_drum", 0.12, 0.12, 0.15, segments=14, mat_name="mfg_primary", parent=root, location=(0.06, 0.0, 0.0), rotation_deg=(0.0, 90.0, 0.0))
|
||||||
|
vc.make_box("feed_chute", (0.10, 0.10, 0.06), "mfg_accent", parent=root, location=(0.07, -0.02, 0.12), bevel=0.004)
|
||||||
|
vc.make_box("belt_latch", (0.04, 0.08, 0.08), "rubber_dark", parent=root, location=(0.21, 0.0, 0.0), bevel=0.003)
|
||||||
|
_export_part("fd_belt_drum", "feed", root, ground=False)
|
||||||
|
|
||||||
|
|
||||||
|
def build_fd_rotary_loader() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
vc.make_box("drive_housing", (0.07, 0.16, 0.16), "gunmetal", parent=root, location=(0.035, 0.0, 0.0), bevel=0.005)
|
||||||
|
for i in range(6):
|
||||||
|
ang = i * (math.tau / 6.0)
|
||||||
|
cy = math.cos(ang) * 0.078
|
||||||
|
cz = math.sin(ang) * 0.078
|
||||||
|
vc.make_tube_part(f"carousel_{i}", 0.034, 0.034, 0.16, segments=8, mat_name="mfg_primary", parent=root, location=(0.06, cy, cz), rotation_deg=(0.0, 90.0, 0.0))
|
||||||
|
vc.make_tube_part("hub_cap", 0.055, 0.045, 0.04, segments=12, mat_name="mfg_accent", parent=root, location=(0.22, 0.0, 0.0), rotation_deg=(0.0, 90.0, 0.0))
|
||||||
|
vc.make_tube_part("spin_ring", 0.062, 0.062, 0.02, segments=12, mat_name="mfg_glow", parent=root, location=(0.21, 0.0, 0.0), rotation_deg=(0.0, 90.0, 0.0))
|
||||||
|
_export_part("fd_rotary_loader", "feed", root, ground=False)
|
||||||
|
|
||||||
|
|
||||||
|
def build_fd_capacitor_bank() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
vc.make_box("cap_rail", (0.06, 0.24, 0.14), "gunmetal", parent=root, location=(0.03, 0.0, 0.0), bevel=0.005)
|
||||||
|
vc.make_kit_part(
|
||||||
|
"cap_fins",
|
||||||
|
"mechanical",
|
||||||
|
"radiator_stack",
|
||||||
|
{"fins": 7, "fin_w": 0.15, "fin_h": 0.16, "fin_t": 0.007, "pitch": 0.026, "segments": 8},
|
||||||
|
mat_name="copper_rad",
|
||||||
|
parent=root,
|
||||||
|
location=(0.135, -0.08, 0.0),
|
||||||
|
rotation_deg=(-90.0, 0.0, 0.0),
|
||||||
|
)
|
||||||
|
vc.make_box("cap_end_plate", (0.04, 0.22, 0.16), "mfg_primary", parent=root, location=(0.22, 0.0, 0.0), bevel=0.005)
|
||||||
|
vc.make_box("busbar_glow", (0.05, 0.20, 0.03), "mfg_glow", parent=root, location=(0.135, 0.0, 0.095), bevel=0.003)
|
||||||
|
vc.make_box("trim_bar", (0.05, 0.20, 0.03), "mfg_accent", parent=root, location=(0.135, 0.0, -0.095), bevel=0.003)
|
||||||
|
_export_part("fd_capacitor_bank", "feed", root, ground=False)
|
||||||
|
|
||||||
|
|
||||||
|
def build_fd_swarm_magazine() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
vc.make_box("swarm_mount", (0.05, 0.18, 0.14), "gunmetal", parent=root, location=(0.025, 0.0, 0.0), bevel=0.004)
|
||||||
|
vc.make_box("honeycomb_box", (0.16, 0.26, 0.18), "mfg_primary", parent=root, location=(0.12, 0.0, 0.0), bevel=0.008)
|
||||||
|
vc.make_box("swarm_latch", (0.12, 0.08, 0.20), "mfg_accent", parent=root, location=(0.12, -0.08, 0.0), bevel=0.004)
|
||||||
|
for row in (-0.042, 0.042):
|
||||||
|
for col in (-0.06, 0.0, 0.06):
|
||||||
|
vc.make_tube_part(f"cell_{row:+.2f}_{col:+.2f}", 0.022, 0.022, 0.04, segments=6, smooth=False, mat_name="gunmetal", parent=root, location=(0.12, -0.14, row) if col == 0 else (0.12 + col * 0.4, -0.14, row), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
vc.make_box("telemetry_bar", (0.03, 0.18, 0.03), "mfg_glow", parent=root, location=(0.205, 0.0, 0.06), bevel=0.002)
|
||||||
|
_export_part("fd_swarm_magazine", "feed", root, ground=False)
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# 4 MUZZLES (origin = rear collar at (0,0,0), forward = -Y_blender = +Z_gltf)
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def build_mz_slotted_brake() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
vc.make_tube_part("brake_collar", 0.062, 0.058, 0.05, segments=12, mat_name="gunmetal", parent=root, location=(0.0, 0.0, 0.0), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
vc.make_box("brake_body", (0.15, 0.16, 0.095), "mfg_primary", parent=root, location=(0.0, -0.11, 0.0), bevel=0.006)
|
||||||
|
for dy in (-0.075, -0.125, -0.17):
|
||||||
|
vc.make_box(f"baffle_{dy:.3f}", (0.175, 0.022, 0.105), "mfg_accent", parent=root, location=(0.0, dy, 0.0), bevel=0.003)
|
||||||
|
vc.make_tube_part("bore_sleeve", 0.034, 0.034, 0.21, segments=10, mat_name="gunmetal", parent=root, location=(0.0, 0.0, 0.0), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
_make_socket("muzzle_tip", "muzzle_tip", root, (0.0, -0.21, 0.0))
|
||||||
|
_export_part("mz_slotted_brake", "muzzle", root, ground=False)
|
||||||
|
|
||||||
|
|
||||||
|
def build_mz_mirv_warhead() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
profile = [
|
||||||
|
[0.068, 0.0],
|
||||||
|
[0.088, 0.05],
|
||||||
|
[0.088, 0.13],
|
||||||
|
[0.054, 0.21],
|
||||||
|
[0.018, 0.25],
|
||||||
|
[0.0, 0.25],
|
||||||
|
]
|
||||||
|
vc.make_lathe_part("warhead_cone", profile, segments=8, loop=False, smooth=False, mat_name="mfg_primary", parent=root, location=(0.0, 0.0, 0.0), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
vc.make_tube_part("arm_ring", 0.091, 0.091, 0.032, segments=12, mat_name="mfg_glow", parent=root, location=(0.0, -0.07, 0.0), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
for i in range(4):
|
||||||
|
ang = i * 90.0 + 45.0
|
||||||
|
vc.make_box(f"strake_{i}", (0.018, 0.12, 0.045), "mfg_accent", parent=root, location=(math.cos(math.radians(ang)) * 0.082, -0.08, math.sin(math.radians(ang)) * 0.082), rotation_deg=(0.0, ang, 0.0), bevel=0.002)
|
||||||
|
_make_socket("muzzle_tip", "muzzle_tip", root, (0.0, -0.25, 0.0))
|
||||||
|
_export_part("mz_mirv_warhead", "muzzle", root, ground=False)
|
||||||
|
|
||||||
|
|
||||||
|
def build_mz_loiter_aero_fin() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
# Sleek deployable drone fuselage + swept delta wings + twin V-tail + glowing sensor eye
|
||||||
|
vc.make_tube_part("drone_fuselage", 0.060, 0.036, 0.26, segments=12, mat_name="mfg_primary", parent=root, location=(0.0, 0.0, 0.0), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
vc.make_box("sensor_nose", (0.072, 0.06, 0.052), "mfg_glow", parent=root, location=(0.0, -0.24, 0.0), bevel=0.005)
|
||||||
|
for side in (-1.0, 1.0):
|
||||||
|
tag = "L" if side > 0 else "R"
|
||||||
|
vc.make_box(f"delta_wing_{tag}", (0.20, 0.13, 0.018), "mfg_accent", parent=root, location=(side * 0.125, -0.10, 0.0), rotation_deg=(0.0, 0.0, -24.0 * side), bevel=0.003)
|
||||||
|
vc.make_box(f"v_tail_{tag}", (0.018, 0.08, 0.085), "mfg_primary", parent=root, location=(side * 0.055, -0.04, 0.052), rotation_deg=(0.0, 28.0 * side, 0.0), bevel=0.002)
|
||||||
|
_make_socket("muzzle_tip", "muzzle_tip", root, (0.0, -0.28, 0.0))
|
||||||
|
_export_part("mz_loiter_aero_fin", "muzzle", root, ground=False)
|
||||||
|
|
||||||
|
|
||||||
|
def build_mz_plasma_diffuser() -> None:
|
||||||
|
vc.reset_scene()
|
||||||
|
ensure_weapon_part_materials()
|
||||||
|
root = vc.make_empty("PartRoot")
|
||||||
|
vc.make_tube_part("choke_collar", 0.068, 0.062, 0.06, segments=6, smooth=False, mat_name="gunmetal", parent=root, location=(0.0, 0.0, 0.0), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
vc.make_tube_part("containment_ring", 0.078, 0.078, 0.04, segments=14, mat_name="mfg_glow", parent=root, location=(0.0, -0.08, 0.0), rotation_deg=(90.0, 0.0, 0.0))
|
||||||
|
for i in range(3):
|
||||||
|
ang = i * 120.0 + 90.0
|
||||||
|
rad = math.radians(ang)
|
||||||
|
px = math.cos(rad) * 0.068
|
||||||
|
pz = math.sin(rad) * 0.068
|
||||||
|
vc.make_box(f"copper_prong_{i}", (0.024, 0.19, 0.036), "copper_rad", parent=root, location=(px, -0.145, pz), rotation_deg=(0.0, ang, 0.0), bevel=0.003)
|
||||||
|
vc.make_box(f"guard_fin_{i}", (0.020, 0.10, 0.046), "mfg_accent", parent=root, location=(px * 1.18, -0.07, pz * 1.18), rotation_deg=(0.0, ang, 0.0), bevel=0.002)
|
||||||
|
_make_socket("muzzle_tip", "muzzle_tip", root, (0.0, -0.24, 0.0))
|
||||||
|
_export_part("mz_plasma_diffuser", "muzzle", root, ground=False)
|
||||||
|
|
||||||
|
|
||||||
|
def build_all_weapon_parts() -> None:
|
||||||
|
PARTS_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
# 4 Receivers
|
||||||
|
build_rx_salvage_frame()
|
||||||
|
build_rx_korrathi_cradle()
|
||||||
|
build_rx_auralian_prism()
|
||||||
|
build_rx_vex_pod_rack()
|
||||||
|
# 4 Barrels
|
||||||
|
build_brl_autocannon()
|
||||||
|
build_brl_sabot_rail()
|
||||||
|
build_brl_prism_lance()
|
||||||
|
build_brl_missile_tube()
|
||||||
|
# 4 Feeds
|
||||||
|
build_fd_belt_drum()
|
||||||
|
build_fd_rotary_loader()
|
||||||
|
build_fd_capacitor_bank()
|
||||||
|
build_fd_swarm_magazine()
|
||||||
|
# 4 Muzzles
|
||||||
|
build_mz_slotted_brake()
|
||||||
|
build_mz_mirv_warhead()
|
||||||
|
build_mz_loiter_aero_fin()
|
||||||
|
build_mz_plasma_diffuser()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
build_all_weapon_parts()
|
||||||
|
|
@ -13,6 +13,7 @@ import numpy as np
|
||||||
REPO_ROOT = Path(__file__).resolve().parents[2]
|
REPO_ROOT = Path(__file__).resolve().parents[2]
|
||||||
VEHICLES_DIR = REPO_ROOT / "assets" / "vehicles"
|
VEHICLES_DIR = REPO_ROOT / "assets" / "vehicles"
|
||||||
GEAR_DIR = REPO_ROOT / "assets" / "gear"
|
GEAR_DIR = REPO_ROOT / "assets" / "gear"
|
||||||
|
WEAPON_PARTS_DIR = GEAR_DIR / "parts"
|
||||||
|
|
||||||
EXPECTED_VEHICLES = (
|
EXPECTED_VEHICLES = (
|
||||||
"jackal", "mule", "ferret", "hornet", "mammoth", "ironclad", "anvil", "condor",
|
"jackal", "mule", "ferret", "hornet", "mammoth", "ironclad", "anvil", "condor",
|
||||||
|
|
@ -20,6 +21,12 @@ EXPECTED_VEHICLES = (
|
||||||
)
|
)
|
||||||
RETROFIT_MECHS = frozenset({"breaker", "paladin", "raptor", "manticore", "bastion", "spectre", "kestrel"})
|
RETROFIT_MECHS = frozenset({"breaker", "paladin", "raptor", "manticore", "bastion", "spectre", "kestrel"})
|
||||||
EXPECTED_GEAR = ("mg_762", "autocannon", "recoilless", "copper_rad", "gilded_lance", "gold_radiator")
|
EXPECTED_GEAR = ("mg_762", "autocannon", "recoilless", "copper_rad", "gilded_lance", "gold_radiator")
|
||||||
|
EXPECTED_WEAPON_PARTS = {
|
||||||
|
"receiver": ("rx_salvage_frame", "rx_korrathi_cradle", "rx_auralian_prism", "rx_vex_pod_rack"),
|
||||||
|
"barrel": ("brl_autocannon", "brl_sabot_rail", "brl_prism_lance", "brl_missile_tube"),
|
||||||
|
"feed": ("fd_belt_drum", "fd_rotary_loader", "fd_capacitor_bank", "fd_swarm_magazine"),
|
||||||
|
"muzzle": ("mz_slotted_brake", "mz_mirv_warhead", "mz_loiter_aero_fin", "mz_plasma_diffuser"),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def parse_glb(glb_path: Path) -> tuple[dict[str, Any], bytes]:
|
def parse_glb(glb_path: Path) -> tuple[dict[str, Any], bytes]:
|
||||||
|
|
@ -523,10 +530,94 @@ def validate_drop_pod() -> dict[str, Any]:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def validate_weapon_part(slot: str, pid: str) -> dict[str, Any]:
|
||||||
|
glb_path = WEAPON_PARTS_DIR / f"{pid}.glb"
|
||||||
|
if not glb_path.is_file():
|
||||||
|
raise AssertionError(f"Missing weapon part GLB: {glb_path}")
|
||||||
|
gltf, bin_blob = parse_glb(glb_path)
|
||||||
|
nodes = gltf.get("nodes", [])
|
||||||
|
meshes = gltf.get("meshes", [])
|
||||||
|
if not meshes:
|
||||||
|
raise AssertionError(f"gear/parts/{pid}: GLB contains no meshes")
|
||||||
|
|
||||||
|
for m_idx, mesh in enumerate(meshes):
|
||||||
|
for p_idx, prim in enumerate(mesh.get("primitives", [])):
|
||||||
|
attrs = prim.get("attributes") or {}
|
||||||
|
if "COLOR_0" not in attrs:
|
||||||
|
raise AssertionError(f"gear/parts/{pid}: mesh[{m_idx}] prim[{p_idx}] missing COLOR_0 weathering")
|
||||||
|
|
||||||
|
tri_total, g_min, g_max = compute_glb_stats(gltf, bin_blob)
|
||||||
|
if tri_total < 24 or tri_total > 4000:
|
||||||
|
raise AssertionError(f"gear/parts/{pid}: unexpected tri count {tri_total}")
|
||||||
|
if not np.all(np.isfinite(g_min)) or not np.all(np.isfinite(g_max)):
|
||||||
|
raise AssertionError(f"gear/parts/{pid}: non-finite bounds")
|
||||||
|
size = g_max - g_min
|
||||||
|
if np.any(size <= 0.01):
|
||||||
|
raise AssertionError(f"gear/parts/{pid}: degenerate bounds size={size.tolist()}")
|
||||||
|
|
||||||
|
# Compute world positions of rtd.socket nodes
|
||||||
|
scenes = gltf.get("scenes", [])
|
||||||
|
root_indices = scenes[gltf.get("scene", 0)]["nodes"] if scenes else list(range(len(nodes)))
|
||||||
|
sockets: dict[str, np.ndarray] = {}
|
||||||
|
found_slot: str | None = None
|
||||||
|
|
||||||
|
def walk_sockets(idx: int, parent_mat: np.ndarray) -> None:
|
||||||
|
nonlocal found_slot
|
||||||
|
node = nodes[idx]
|
||||||
|
world = parent_mat @ _node_local_matrix(node)
|
||||||
|
extras = node.get("extras") or {}
|
||||||
|
if "rtd.part_slot" in extras:
|
||||||
|
found_slot = str(extras["rtd.part_slot"])
|
||||||
|
if "rtd.socket" in extras:
|
||||||
|
sockets[str(extras["rtd.socket"])] = world[:3, 3]
|
||||||
|
for child_idx in node.get("children", []):
|
||||||
|
walk_sockets(child_idx, world)
|
||||||
|
|
||||||
|
ident = np.eye(4, dtype=np.float64)
|
||||||
|
for r_idx in root_indices:
|
||||||
|
walk_sockets(r_idx, ident)
|
||||||
|
|
||||||
|
if found_slot != slot:
|
||||||
|
raise AssertionError(f"gear/parts/{pid}: rtd.part_slot={found_slot!r} != expected {slot!r}")
|
||||||
|
|
||||||
|
if slot == "receiver":
|
||||||
|
if abs(float(g_min[1])) > 0.02:
|
||||||
|
raise AssertionError(f"gear/parts/{pid}: receiver not grounded at minY=0 (got {g_min[1]:.4f})")
|
||||||
|
for req_sock in ("barrel", "feed"):
|
||||||
|
if req_sock not in sockets:
|
||||||
|
raise AssertionError(f"gear/parts/{pid}: missing socket {req_sock!r}")
|
||||||
|
if sockets["barrel"][2] <= 0.05:
|
||||||
|
raise AssertionError(f"gear/parts/{pid}: barrel socket not forward (+Z), got z={sockets['barrel'][2]:.4f}")
|
||||||
|
elif slot == "barrel":
|
||||||
|
if "muzzle" not in sockets:
|
||||||
|
raise AssertionError(f"gear/parts/{pid}: missing socket 'muzzle'")
|
||||||
|
if sockets["muzzle"][2] <= 0.25 or float(g_max[2]) < 0.25:
|
||||||
|
raise AssertionError(f"gear/parts/{pid}: barrel does not extend forward (+Z), maxZ={g_max[2]:.4f}, muzzle={sockets['muzzle'].tolist()}")
|
||||||
|
elif slot == "muzzle":
|
||||||
|
if "muzzle_tip" not in sockets:
|
||||||
|
raise AssertionError(f"gear/parts/{pid}: missing socket 'muzzle_tip'")
|
||||||
|
if sockets["muzzle_tip"][2] <= 0.05 or float(g_max[2]) < 0.08:
|
||||||
|
raise AssertionError(f"gear/parts/{pid}: muzzle does not extend forward (+Z), maxZ={g_max[2]:.4f}, tip={sockets['muzzle_tip'].tolist()}")
|
||||||
|
|
||||||
|
return {
|
||||||
|
"id": pid,
|
||||||
|
"slot": slot,
|
||||||
|
"tris": tri_total,
|
||||||
|
"bytes": glb_path.stat().st_size,
|
||||||
|
"size": [round(float(v), 3) for v in size],
|
||||||
|
"sockets": sorted(sockets.keys()),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
v_reports = [validate_vehicle(v) for v in EXPECTED_VEHICLES]
|
v_reports = [validate_vehicle(v) for v in EXPECTED_VEHICLES]
|
||||||
g_reports = [validate_gear(g) for g in EXPECTED_GEAR]
|
g_reports = [validate_gear(g) for g in EXPECTED_GEAR]
|
||||||
pod_report = validate_drop_pod()
|
pod_report = validate_drop_pod()
|
||||||
|
part_reports = [
|
||||||
|
validate_weapon_part(slot, pid)
|
||||||
|
for slot, pids in EXPECTED_WEAPON_PARTS.items()
|
||||||
|
for pid in pids
|
||||||
|
]
|
||||||
print("=== VEHICLE GLB VALIDATION PASSED ===")
|
print("=== VEHICLE GLB VALIDATION PASSED ===")
|
||||||
for r in v_reports:
|
for r in v_reports:
|
||||||
mech_tag = f" | dofs={r['mechanisms']}" if r["mechanisms"] else ""
|
mech_tag = f" | dofs={r['mechanisms']}" if r["mechanisms"] else ""
|
||||||
|
|
@ -536,6 +627,9 @@ def main() -> int:
|
||||||
print(f" {r['id']:14s} | tris={r['tris']:4d} | size={r['size']} | {r['bytes']/1024:.1f} KiB")
|
print(f" {r['id']:14s} | tris={r['tris']:4d} | size={r['size']} | {r['bytes']/1024:.1f} KiB")
|
||||||
print("=== DROP POD GLB VALIDATION PASSED ===")
|
print("=== DROP POD GLB VALIDATION PASSED ===")
|
||||||
print(f" {pod_report['id']:10s} | tris={pod_report['tris']:5d} | size={pod_report['size']} | minY={pod_report['minY']} | petalPivotOffsets={pod_report['petalOffsets']} | {pod_report['bytes']/1024:.1f} KiB")
|
print(f" {pod_report['id']:10s} | tris={pod_report['tris']:5d} | size={pod_report['size']} | minY={pod_report['minY']} | petalPivotOffsets={pod_report['petalOffsets']} | {pod_report['bytes']/1024:.1f} KiB")
|
||||||
|
print(f"=== MODULAR WEAPON PARTS VALIDATION PASSED ({len(part_reports)} PARTS) ===")
|
||||||
|
for r in part_reports:
|
||||||
|
print(f" {r['slot']:8s} | {r['id']:20s} | tris={r['tris']:4d} | size={r['size']} | sockets={r['sockets']} | {r['bytes']/1024:.1f} KiB")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue