diff --git a/UdpHosts/GameServer/StaticDB/Records/vcs/ComponentType.cs b/UdpHosts/GameServer/StaticDB/Records/vcs/ComponentType.cs new file mode 100644 index 00000000..340ad701 --- /dev/null +++ b/UdpHosts/GameServer/StaticDB/Records/vcs/ComponentType.cs @@ -0,0 +1,38 @@ +namespace GameServer.Data.SDB.Records.vcs; + +// There are 30 distinct sdb_guid values in vcs::BaseComponentDef +// Each sdb_guid appears in only one of ComponentDef tables +public enum ComponentType : uint +{ + Scoping = 3866376917, + Driver = 1562371278, + Passenger = 2202208390, + Ability = 3048110324, + Damage = 3737859927, + StatusEffect = 3322729247, + Turret = 533726263, + Deployable = 3213454533, + SpawnPoint = 1715213540, + + HullSegment = 555024461, + Warpaint = 1238758490, + WheelBase = 2550758801, + Transmission = 3101116909, + Suspension = 2505221195, + Engine = 868401361, + Steering = 4196128104, + Braking = 3431260985, + Aerodynamics = 1921341588, + HeadLight = 2674988324, + Exhaust = 2154345371, + FlightPath = 2075941479, + Visual = 2131841188, + Light = 1648495344, + LightSensor = 1780124415, + GroundEffects = 3716493569, + Camera = 4175714783, + GroundPath = 1292643894, + SimpleShieldGenerator = 22217899, + DropPod = 1851570801, + Cloak = 3678315516, +} \ No newline at end of file diff --git a/UdpHosts/GameServer/StaticDB/SDBUtils.cs b/UdpHosts/GameServer/StaticDB/SDBUtils.cs index 9f9e9959..c99d2e1f 100644 --- a/UdpHosts/GameServer/StaticDB/SDBUtils.cs +++ b/UdpHosts/GameServer/StaticDB/SDBUtils.cs @@ -225,72 +225,70 @@ public static VehicleInfoResult GetDetailedVehicleInfo(ushort vehicleId) Turrets = new List(), Deployables = new List(), }; + foreach (var baseComponent in baseComponents.Values) { - // We don't know how to identify the type, so we look each one up in every table of interest. - // Not sure if the sdb_guid somehow hints at where to find it var componentId = baseComponent.Id; - var scopingComponent = SDBInterface.GetScopingComponentDef(componentId); - var driverComponent = SDBInterface.GetDriverComponentDef(componentId); - var passengerComponent = SDBInterface.GetPassengerComponentDef(componentId); - var abilityComponent = SDBInterface.GetAbilityComponentDef(componentId); - var damageComponent = SDBInterface.GetDamageComponentDef(componentId); - var statusEffectComponent = SDBInterface.GetStatusEffectComponentDef(componentId); - var turretComponent = SDBInterface.GetTurretComponentDef(componentId); - var deployableComponent = SDBInterface.GetDeployableComponentDef(componentId); - var spawnPointComponent = SDBInterface.GetSpawnPointComponentDef(componentId); - - if (scopingComponent != null) - { - result.ScopeRange = scopingComponent.ScopeRange; - result.SpawnHeight = scopingComponent.SpawnHeight; - result.SpawnAbility = scopingComponent.SpawnAbility; - result.DespawnAbility = scopingComponent.DespawnAbility; - } - - if (driverComponent != null) - { - result.HasDriverSeat = true; - result.DriverPosture = driverComponent.Posture; - } - - if (passengerComponent != null) - { - result.MaxPassengers = passengerComponent.MaxPassengers; - result.PassengerPosture = passengerComponent.Posture; - result.HasActivePassenger = passengerComponent.ActivePassenger == 1; - } - - if (abilityComponent != null) - { - result.Abilities.Add(abilityComponent); - } - - if (damageComponent != null) - { - result.DeathAbility = damageComponent.DeathAbility; - result.MaxHitPoints = damageComponent.MaxHitPoints; - result.DamageResponse = damageComponent.DamageResponse; - } - - if (statusEffectComponent != null) - { - result.StatusFxId = statusEffectComponent.StatusFxId; - } - - if (turretComponent != null) - { - result.Turrets.Add(turretComponent); - } - - if (deployableComponent != null) - { - result.Deployables.Add(deployableComponent); - } - if (spawnPointComponent != null) + var componentType = (ComponentType)baseComponent.SdbGuid; + switch (componentType) { - // TODO: Probably for allowing spawning into the vehicle + case ComponentType.Scoping: + var scopingComponent = SDBInterface.GetScopingComponentDef(componentId); + result.ScopeRange = scopingComponent.ScopeRange; + result.SpawnHeight = scopingComponent.SpawnHeight; + result.SpawnAbility = scopingComponent.SpawnAbility; + result.DespawnAbility = scopingComponent.DespawnAbility; + break; + + case ComponentType.Driver: + var driverComponent = SDBInterface.GetDriverComponentDef(componentId); + result.HasDriverSeat = true; + result.DriverPosture = driverComponent.Posture; + break; + + case ComponentType.Passenger: + var passengerComponent = SDBInterface.GetPassengerComponentDef(componentId); + result.MaxPassengers = passengerComponent.MaxPassengers; + result.PassengerPosture = passengerComponent.Posture; + result.HasActivePassenger = passengerComponent.ActivePassenger == 1; + break; + + case ComponentType.Ability: + var abilityComponent = SDBInterface.GetAbilityComponentDef(componentId); + result.Abilities.Add(abilityComponent); + break; + + case ComponentType.Damage: + var damageComponent = SDBInterface.GetDamageComponentDef(componentId); + result.DeathAbility = damageComponent.DeathAbility; + result.MaxHitPoints = damageComponent.MaxHitPoints; + result.DamageResponse = damageComponent.DamageResponse; + break; + + case ComponentType.StatusEffect: + var statusEffectComponent = SDBInterface.GetStatusEffectComponentDef(componentId); + result.StatusFxId = statusEffectComponent.StatusFxId; + break; + + case ComponentType.Turret: + var turretComponent = SDBInterface.GetTurretComponentDef(componentId); + result.Turrets.Add(turretComponent); + break; + + case ComponentType.Deployable: + var deployableComponent = SDBInterface.GetDeployableComponentDef(componentId); + result.Deployables.Add(deployableComponent); + break; + + case ComponentType.SpawnPoint: + // TODO: Probably for allowing spawning into the vehicle + // var spawnPointComponent = SDBInterface.GetSpawnPointComponentDef(componentId); + break; + + default: + // Console.WriteLine($"Unhandled vehicle component, id: {componentId}, type: {componentType}"); + break; } }