From 40b609a5876046c307ef48694872414544c2b5d0 Mon Sep 17 00:00:00 2001 From: lahm86 <33758420+lahm86@users.noreply.github.com> Date: Mon, 25 Apr 2022 21:05:39 +0100 Subject: [PATCH] #314 Enemy Meshes Adds a UI option for swapping enemy appearances. --- .../Editors/RandomizerSettings.cs | 3 +++ .../Randomizers/TR2/TR2EnemyRandomizer.cs | 5 +++- TRRandomizerCore/TRRandomizerController.cs | 6 +++++ TRRandomizerView/Model/ControllerOptions.cs | 24 ++++++++++++++++--- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/TRRandomizerCore/Editors/RandomizerSettings.cs b/TRRandomizerCore/Editors/RandomizerSettings.cs index 759c5fe38..ffef972cd 100644 --- a/TRRandomizerCore/Editors/RandomizerSettings.cs +++ b/TRRandomizerCore/Editors/RandomizerSettings.cs @@ -63,6 +63,7 @@ public class RandomizerSettings public bool ShowExclusionWarnings { get; set; } public List IncludedEnemies => ExcludableEnemies.Keys.Except(ExcludedEnemies).ToList(); public bool OneEnemyMode => IncludedEnemies.Count == 1; + public bool SwapEnemyAppearance { get; set; } public bool GlitchedSecrets { get; set; } public bool UseRewardRoomCameras { get; set; } public bool PersistOutfits { get; set; } @@ -136,6 +137,7 @@ public void ApplyConfig(Config config) BirdMonsterBehaviour = (BirdMonsterBehaviour)config.GetEnum(nameof(BirdMonsterBehaviour), typeof(BirdMonsterBehaviour), BirdMonsterBehaviour.Default); RandoEnemyDifficulty = (RandoDifficulty)config.GetEnum(nameof(RandoEnemyDifficulty), typeof(RandoDifficulty), RandoDifficulty.Default); MaximiseDragonAppearance = config.GetBool(nameof(MaximiseDragonAppearance)); + SwapEnemyAppearance = config.GetBool(nameof(SwapEnemyAppearance), true); UseEnemyExclusions = config.GetBool(nameof(UseEnemyExclusions)); ShowExclusionWarnings = config.GetBool(nameof(ShowExclusionWarnings)); ExcludedEnemies = config.GetString(nameof(ExcludedEnemies)) @@ -244,6 +246,7 @@ public void StoreConfig(Config config) config[nameof(ExcludedEnemies)] = string.Join(",", ExcludedEnemies); config[nameof(UseEnemyExclusions)] = UseEnemyExclusions; config[nameof(ShowExclusionWarnings)] = ShowExclusionWarnings; + config[nameof(SwapEnemyAppearance)] = SwapEnemyAppearance; config[nameof(RandomizeTextures)] = RandomizeTextures; config[nameof(TextureSeed)] = TextureSeed; diff --git a/TRRandomizerCore/Randomizers/TR2/TR2EnemyRandomizer.cs b/TRRandomizerCore/Randomizers/TR2/TR2EnemyRandomizer.cs index 83427f6a4..887ada01b 100644 --- a/TRRandomizerCore/Randomizers/TR2/TR2EnemyRandomizer.cs +++ b/TRRandomizerCore/Randomizers/TR2/TR2EnemyRandomizer.cs @@ -814,7 +814,10 @@ private void RandomizeEnemies(TR2CombinedLevel level, EnemyRandomizationCollecti LimitSkidooEntities(level); } - RandomizeEnemyMeshes(level, enemies); + if (Settings.SwapEnemyAppearance) + { + RandomizeEnemyMeshes(level, enemies); + } if (Settings.BirdMonsterBehaviour == BirdMonsterBehaviour.Unconditional && !level.Is(TR2LevelNames.CHICKEN)) { diff --git a/TRRandomizerCore/TRRandomizerController.cs b/TRRandomizerCore/TRRandomizerController.cs index 4bf0c174c..61ac678f8 100644 --- a/TRRandomizerCore/TRRandomizerController.cs +++ b/TRRandomizerCore/TRRandomizerController.cs @@ -499,6 +499,12 @@ public List IncludedEnemies get => LevelRandomizer.IncludedEnemies; } + public bool SwapEnemyAppearance + { + get => LevelRandomizer.SwapEnemyAppearance; + set => LevelRandomizer.SwapEnemyAppearance = value; + } + public bool RandomizeOutfits { get => LevelRandomizer.RandomizeOutfits; diff --git a/TRRandomizerView/Model/ControllerOptions.cs b/TRRandomizerView/Model/ControllerOptions.cs index fae859867..e2e095f94 100644 --- a/TRRandomizerView/Model/ControllerOptions.cs +++ b/TRRandomizerView/Model/ControllerOptions.cs @@ -25,7 +25,7 @@ public class ControllerOptions : INotifyPropertyChanged private BoolItemControlClass _isHardSecrets, _allowGlitched, _useRewardRoomCameras; private BoolItemControlClass _includeKeyItems; - private BoolItemControlClass _crossLevelEnemies, _protectMonks, _docileWillard, _maximiseDragonAppearance; + private BoolItemControlClass _crossLevelEnemies, _protectMonks, _docileWillard, _maximiseDragonAppearance, _swapEnemyAppearance; private BoolItemControlClass _persistTextures, _retainKeySpriteTextures, _retainSecretSpriteTextures; private BoolItemControlClass _includeBlankTracks, _changeTriggerTracks, _separateSecretTracks, _changeWeaponSFX, _changeCrashSFX, _changeEnemySFX, _linkCreatureSFX; private BoolItemControlClass _persistOutfits, _removeRobeDagger; @@ -1007,6 +1007,16 @@ public BoolItemControlClass MaximiseDragonAppearance } } + public BoolItemControlClass SwapEnemyAppearance + { + get => _swapEnemyAppearance; + set + { + _swapEnemyAppearance = value; + FirePropertyChanged(); + } + } + public RandoDifficulty RandoEnemyDifficulty { get => _randoEnemyDifficulty; @@ -1321,6 +1331,12 @@ public ControllerOptions() Description = "Make a best effort attempt to have as many dragons as possible in the game." }; BindingOperations.SetBinding(MaximiseDragonAppearance, BoolItemControlClass.IsActiveProperty, randomizeEnemiesBinding); + SwapEnemyAppearance = new BoolItemControlClass + { + Title = "Swap enemy appearances", + Description = "Allow some enemies to take on the appearance of others." + }; + BindingOperations.SetBinding(SwapEnemyAppearance, BoolItemControlClass.IsActiveProperty, randomizeEnemiesBinding); // Textures Binding randomizeTexturesBinding = new Binding(nameof(RandomizeTextures)) { Source = this }; @@ -1459,7 +1475,7 @@ public ControllerOptions() }; EnemyBoolItemControls = new List() { - _crossLevelEnemies, _docileWillard, _protectMonks, _maximiseDragonAppearance + _crossLevelEnemies, _docileWillard, _protectMonks, _maximiseDragonAppearance, _swapEnemyAppearance }; TextureBoolItemControls = new List() { @@ -1498,7 +1514,7 @@ private void AdjustAvailableOptions() _useRewardRoomCameras.IsAvailable = IsRewardRoomsTypeSupported; - _maximiseDragonAppearance.IsAvailable = IsOutfitDaggerSupported; + _maximiseDragonAppearance.IsAvailable = _swapEnemyAppearance.IsAvailable = IsOutfitDaggerSupported; _docileWillard.IsAvailable = !IsBirdMonsterBehaviourTypeSupported; } @@ -1572,6 +1588,7 @@ public void Load(TRRandomizerController controller) DocileWillard.Value = _controller.DocileWillard; BirdMonsterBehaviour = _controller.BirdMonsterBehaviour; MaximiseDragonAppearance.Value = _controller.MaximiseDragonAppearance; + SwapEnemyAppearance.Value = _controller.SwapEnemyAppearance; RandoEnemyDifficulty = _controller.RandoEnemyDifficulty; UseEnemyExclusions = _controller.UseEnemyExclusions; ShowExclusionWarnings = _controller.ShowExclusionWarnings; @@ -1849,6 +1866,7 @@ public void Save() _controller.DocileWillard = DocileWillard.Value; _controller.BirdMonsterBehaviour = BirdMonsterBehaviour; _controller.MaximiseDragonAppearance = MaximiseDragonAppearance.Value; + _controller.SwapEnemyAppearance = SwapEnemyAppearance.Value; _controller.RandoEnemyDifficulty = RandoEnemyDifficulty; _controller.UseEnemyExclusions = UseEnemyExclusions; _controller.ShowExclusionWarnings = ShowExclusionWarnings;