Implement modular settings backend.

This commit is contained in:
Paul Chote
2025-12-22 09:12:55 +00:00
committed by Gustas Kažukauskas
parent 962e7e911d
commit 575f6624a2
5 changed files with 255 additions and 167 deletions

View File

@@ -34,6 +34,7 @@ namespace OpenRA
readonly List<IEffect> effects = [];
readonly List<IEffect> unpartitionedEffects = [];
readonly List<ISync> syncedEffects = [];
readonly ModData modData;
readonly GameSettings gameSettings;
readonly Queue<Action<World>> frameEndActions = [];
@@ -178,6 +179,7 @@ namespace OpenRA
{
Type = type;
OrderManager = orderManager;
this.modData = modData;
Map = map;
if (string.IsNullOrEmpty(modData.Manifest.DefaultOrderGenerator))
@@ -229,7 +231,7 @@ namespace OpenRA
gameInfo.MapData = preview.ToBase64String();
RulesContainTemporaryBlocker = Map.Rules.Actors.Any(a => a.Value.HasTraitInfo<ITemporaryBlockerInfo>());
gameSettings = Game.Settings.Game;
gameSettings = GetSettings<GameSettings>();
}
public void AddToMaps(Actor self, IOccupySpace ios)
@@ -622,6 +624,11 @@ namespace OpenRA
// In the event the replay goes out of sync, it becomes no longer usable. For polish we permanently pause the world.
ReplayTimestep = 0;
}
public T GetSettings<T>() where T : SettingsModule
{
return modData.GetSettings<T>();
}
}
public readonly struct TraitPair<T>(Actor actor, T trait) : IEquatable<TraitPair<T>>