From 5094a706062a155959fc2757f85716d000f4fffc Mon Sep 17 00:00:00 2001 From: Sam V Date: Thu, 19 May 2022 13:12:08 +0200 Subject: [PATCH] Add upgrade to convert item_suit to use w_pcv.mdl for Opposing Force maps malortie/custom-hl-viewmodels#47 --- .../ConvertSuitToPCVUpgrade.cs | 25 +++++++++++++++++++ .../MapUpgradeBuilderExtensions.cs | 1 + 2 files changed, 26 insertions(+) create mode 100644 src/HalfLife.UnifiedSdk.MapUpgrader.Upgrades/ConvertSuitToPCVUpgrade.cs diff --git a/src/HalfLife.UnifiedSdk.MapUpgrader.Upgrades/ConvertSuitToPCVUpgrade.cs b/src/HalfLife.UnifiedSdk.MapUpgrader.Upgrades/ConvertSuitToPCVUpgrade.cs new file mode 100644 index 0000000..278b95a --- /dev/null +++ b/src/HalfLife.UnifiedSdk.MapUpgrader.Upgrades/ConvertSuitToPCVUpgrade.cs @@ -0,0 +1,25 @@ +using HalfLife.UnifiedSdk.Utilities.Entities; +using HalfLife.UnifiedSdk.Utilities.Games; +using HalfLife.UnifiedSdk.Utilities.Tools.UpgradeTool; + +namespace HalfLife.UnifiedSdk.MapUpgrader.Upgrades +{ + /// + /// Converts item_suit's model to use w_pcv.mdl in Opposing Force maps. + /// + internal sealed class ConvertSuitToPCVUpgrade : IMapUpgradeAction + { + public void Apply(MapUpgradeContext context) + { + if (!ValveGames.OpposingForce.IsMap(context.Map.BaseName)) + { + return; + } + + foreach (var entity in context.Map.Entities.OfClass("item_suit")) + { + entity.SetModel("models/w_pcv.mdl"); + } + } + } +} diff --git a/src/HalfLife.UnifiedSdk.MapUpgrader.Upgrades/MapUpgradeBuilderExtensions.cs b/src/HalfLife.UnifiedSdk.MapUpgrader.Upgrades/MapUpgradeBuilderExtensions.cs index 936ebd2..64d8c55 100644 --- a/src/HalfLife.UnifiedSdk.MapUpgrader.Upgrades/MapUpgradeBuilderExtensions.cs +++ b/src/HalfLife.UnifiedSdk.MapUpgrader.Upgrades/MapUpgradeBuilderExtensions.cs @@ -20,6 +20,7 @@ public static MapUpgradeBuilder AddHalfLifeUpgrades(this MapUpgradeBuilder build public static MapUpgradeBuilder AddOpposingForceUpgrades(this MapUpgradeBuilder builder) { + builder.AddAction(new ConvertSuitToPCVUpgrade()); builder.AddAction(new MonsterTentacleSpawnFlagUpgrade()); builder.AddAction(new Of4a4BridgeUpgrade()); return builder;