private void OnEntityDeath(ModularCar car) { if (IsBombTruck(car) && car.OwnerID != 0) { var playerConfig = GetPlayerData(car.OwnerID.ToString()); var netID = car.net.ID; var truckName = playerConfig.FindTruck(netID)?.Name; if (truckName == null) { PrintWarning("Unable to determine truck name on death."); return; } var truckConfig = GetTruckConfig(truckName); if (truckConfig == null) { PrintError("Unable to detonate '{0}' truck because its configuration is missing.", truckName); return; } playerConfig.RemoveTruck(netID); // Clean up the engine parts foreach (var module in car.AttachedModuleEntities) { var engineStorage = (module as VehicleModuleEngine)?.GetContainer() as EngineStorage; engineStorage?.inventory?.Kill(); } var carPosition = car.CenterPoint(); car.Kill(); DetonateExplosion(truckConfig.ExplosionSpec, carPosition); } }
private void DetonateBombTruck(ModularCar car) { var playerConfig = GetPlayerData(car.OwnerID.ToString()); var netID = car.net.ID; var truckName = playerConfig.FindTruck(netID)?.Name; if (truckName == null) { LogError("Unable to determine truck name."); return; } var truckConfig = GetTruckConfig(truckName); if (truckConfig == null) { LogError("Unable to detonate '{0}' truck because its configuration is missing.", truckName); return; } playerConfig.RemoveTruck(netID); // Remove the engine parts. foreach (var module in car.AttachedModuleEntities) { var engineStorage = GetEngineStorage(module); if (engineStorage != null) { engineStorage.inventory.Kill(); } } var carPosition = car.CenterPoint(); car.Kill(); DetonateExplosion(truckConfig.ExplosionSpec, carPosition); }