Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map vehicle component types to sdb_guids #39

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions UdpHosts/GameServer/StaticDB/Records/vcs/ComponentType.cs
Original file line number Diff line number Diff line change
@@ -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 <Type>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,
}
120 changes: 59 additions & 61 deletions UdpHosts/GameServer/StaticDB/SDBUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,72 +225,70 @@ public static VehicleInfoResult GetDetailedVehicleInfo(ushort vehicleId)
Turrets = new List<TurretComponentDef>(),
Deployables = new List<DeployableComponentDef>(),
};

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;
}
}

Expand Down
Loading