-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change intro otis model to otis, remap body and head keyvalues
malortie/custom-hl-viewmodels#21
- Loading branch information
1 parent
797c366
commit dc8a54f
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
src/HalfLife.UnifiedSdk.MapUpgrader.Upgrades/ConvertOtisModelUpgrade.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using HalfLife.UnifiedSdk.Utilities.Entities; | ||
using HalfLife.UnifiedSdk.Utilities.Games; | ||
using HalfLife.UnifiedSdk.Utilities.Tools.UpgradeTool; | ||
|
||
namespace HalfLife.UnifiedSdk.MapUpgrader.Upgrades | ||
{ | ||
/// <summary> | ||
/// Converts the <c>monster_otis</c> model and body value to the appropriate keyvalues. | ||
/// </summary> | ||
internal sealed class ConvertOtisModelUpgrade : IMapUpgradeAction | ||
{ | ||
private const string OtisModelName = "models/otis.mdl"; | ||
private const string IntroOtisModelName = "models/intro_otis.mdl"; | ||
|
||
private enum OtisSleeves | ||
{ | ||
Random = -1, | ||
Long = 0, | ||
Short | ||
} | ||
|
||
private enum OtisSkin | ||
{ | ||
Random = -1, | ||
HeadWithHair = 0, | ||
Bald, | ||
BlackHeadWithHair | ||
} | ||
|
||
public void Apply(MapUpgradeContext context) | ||
{ | ||
foreach (var otis in context.Map.Entities.OfClass("monster_otis")) | ||
{ | ||
var head = otis.GetInteger("head"); | ||
|
||
otis.Remove("head"); | ||
//Remove this because it will just screw up the submodel state otherwise. | ||
otis.Remove("body"); | ||
//Previously unused, but now exist. | ||
otis.Remove("sleeves"); | ||
otis.Remove("item"); | ||
|
||
otis.SetInteger("skin", head); | ||
|
||
var sleeves = OtisSleeves.Long; | ||
|
||
if (head == (int)OtisSkin.Bald) | ||
{ | ||
sleeves = OtisSleeves.Short; | ||
} | ||
|
||
otis.SetInteger("sleeves", (int)sleeves); | ||
} | ||
|
||
//Only Blue Shift uses Otis models separately from Opposing Force so this section only applies to that game. | ||
if (ValveGames.BlueShift.IsMap(context.Map.BaseName)) | ||
{ | ||
foreach (var entity in context.Map.Entities.WhereString("model", OtisModelName)) | ||
{ | ||
var body = entity.GetInteger("body"); | ||
|
||
//Remap old submodels to new ones. Hardcoded to the body values used in Blue Shift to keep things simple. | ||
body = body switch | ||
{ | ||
2 => 15, | ||
_ => 3, | ||
}; | ||
|
||
entity.SetInteger("body", body); | ||
entity.SetInteger("skin", (int)OtisSkin.Bald); | ||
} | ||
|
||
foreach (var entity in context.Map.Entities.WhereString("model", IntroOtisModelName)) | ||
{ | ||
//Use the main Otis model for these. | ||
entity.SetModel(OtisModelName); | ||
|
||
entity.SetInteger("body", 9); | ||
entity.SetInteger("skin", (int)OtisSkin.Bald); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters