Skip to content

Commit

Permalink
LostArtefacts#314 Enemy Meshes
Browse files Browse the repository at this point in the history
Adds a UI option for swapping enemy appearances.
  • Loading branch information
lahm86 committed Apr 25, 2022
1 parent b8e5ac9 commit 40b609a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
3 changes: 3 additions & 0 deletions TRRandomizerCore/Editors/RandomizerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class RandomizerSettings
public bool ShowExclusionWarnings { get; set; }
public List<short> 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; }
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion TRRandomizerCore/Randomizers/TR2/TR2EnemyRandomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
6 changes: 6 additions & 0 deletions TRRandomizerCore/TRRandomizerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,12 @@ public List<short> IncludedEnemies
get => LevelRandomizer.IncludedEnemies;
}

public bool SwapEnemyAppearance
{
get => LevelRandomizer.SwapEnemyAppearance;
set => LevelRandomizer.SwapEnemyAppearance = value;
}

public bool RandomizeOutfits
{
get => LevelRandomizer.RandomizeOutfits;
Expand Down
24 changes: 21 additions & 3 deletions TRRandomizerView/Model/ControllerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1007,6 +1007,16 @@ public BoolItemControlClass MaximiseDragonAppearance
}
}

public BoolItemControlClass SwapEnemyAppearance
{
get => _swapEnemyAppearance;
set
{
_swapEnemyAppearance = value;
FirePropertyChanged();
}
}

public RandoDifficulty RandoEnemyDifficulty
{
get => _randoEnemyDifficulty;
Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -1459,7 +1475,7 @@ public ControllerOptions()
};
EnemyBoolItemControls = new List<BoolItemControlClass>()
{
_crossLevelEnemies, _docileWillard, _protectMonks, _maximiseDragonAppearance
_crossLevelEnemies, _docileWillard, _protectMonks, _maximiseDragonAppearance, _swapEnemyAppearance
};
TextureBoolItemControls = new List<BoolItemControlClass>()
{
Expand Down Expand Up @@ -1498,7 +1514,7 @@ private void AdjustAvailableOptions()

_useRewardRoomCameras.IsAvailable = IsRewardRoomsTypeSupported;

_maximiseDragonAppearance.IsAvailable = IsOutfitDaggerSupported;
_maximiseDragonAppearance.IsAvailable = _swapEnemyAppearance.IsAvailable = IsOutfitDaggerSupported;

_docileWillard.IsAvailable = !IsBirdMonsterBehaviourTypeSupported;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 40b609a

Please sign in to comment.