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
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
using RustToDust.Core;
|
||||
using RustToDust.Ymir;
|
||||
|
||||
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<(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, int> _lastContenderLoadoutVer = new();
|
||||
private readonly List<(float X, float Z, float Expiry)> _recentExplosionPoints = new(16);
|
||||
|
|
@ -292,6 +294,7 @@ public partial class ArenaAudioSystem : Node3D
|
|||
|
||||
_shotDedupeExpiry.Clear();
|
||||
_impactDedupeExpiry.Clear();
|
||||
_ordnanceDedupeExpiry.Clear();
|
||||
_lastContenderChassis.Clear();
|
||||
_lastContenderLoadoutVer.Clear();
|
||||
_recentExplosionPoints.Clear();
|
||||
|
|
@ -489,6 +492,10 @@ public partial class ArenaAudioSystem : Node3D
|
|||
case DropPodEvent dpe:
|
||||
HandleDropPodEvent(dpe, localId, listenerPos);
|
||||
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)
|
||||
{
|
||||
var state = session.ViewState;
|
||||
|
|
@ -1176,6 +1285,12 @@ public partial class ArenaAudioSystem : Node3D
|
|||
private string SelectWeaponClipKey(string? weaponId, WeaponVisualClass weaponClass)
|
||||
{
|
||||
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();
|
||||
return id switch
|
||||
{
|
||||
|
|
@ -1201,6 +1316,10 @@ public partial class ArenaAudioSystem : Node3D
|
|||
WeaponVisualClass.Autocannon => "ac_light_01",
|
||||
WeaponVisualClass.Explosive => "cannon_heavy_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"
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue