|
| 1 | +using DataTool.Flag; |
| 2 | +using DataTool.Helper; |
| 3 | +using TankLib.Helpers; |
| 4 | +using TankLib.STU.Types; |
| 5 | +using TankLib.STU.Types.Enums; |
| 6 | + |
| 7 | +namespace DataTool.SaveLogic.Unlock { |
| 8 | + public static class HighlightIntro { |
| 9 | + public static void Save(ICLIFlags flags, string directory, DataModels.Unlock unlock, STUHero hero) { |
| 10 | + if (unlock.GetSTU() is STUUnlock_POTGAnimation { m_type: POTGType.Default }) { |
| 11 | + SaveHeroicIntro(flags, directory, hero); |
| 12 | + return; |
| 13 | + } |
| 14 | + |
| 15 | + AnimationItem.Save(flags, directory, unlock); |
| 16 | + } |
| 17 | + |
| 18 | + private static void SaveHeroicIntro(ICLIFlags flags, string directory, STUHero hero) { |
| 19 | + if (hero == null) { |
| 20 | + // sanity |
| 21 | + Logger.Error(nameof(HighlightIntro), "No hero associated to highlight intro"); |
| 22 | + return; |
| 23 | + } |
| 24 | + |
| 25 | + // heroic highlight intros do not use the animation field |
| 26 | + // instead it uses the hero select entity which has a blend tree |
| 27 | + |
| 28 | + var heroSelectEntity = STUHelper.GetInstance<STUModelComponent>(hero.m_322C521A); |
| 29 | + if (heroSelectEntity == null) { |
| 30 | + Logger.Error(nameof(HighlightIntro), "Unable to load heroic animation entity"); |
| 31 | + return; |
| 32 | + } |
| 33 | + |
| 34 | + // we don't really want to extract the whole hero |
| 35 | + // so select only the blend tree |
| 36 | + var comboInfo = new FindLogic.Combo.ComboInfo(); |
| 37 | + FindLogic.Combo.Find(comboInfo, heroSelectEntity.m_animBlendTreeSet); |
| 38 | + |
| 39 | + var saveContext = new Combo.SaveContext(comboInfo) { |
| 40 | + m_saveAnimationEffects = false // not supported in loose mode |
| 41 | + }; |
| 42 | + Combo.Save(flags, directory, saveContext); |
| 43 | + Combo.SaveAllAnimations(flags, directory, saveContext); |
| 44 | + } |
| 45 | + } |
| 46 | +} |
0 commit comments