Merge ModRuleset and MapRuleset into Ruleset

This commit is contained in:
Pavlos Touboulidis
2014-05-10 10:29:26 +03:00
parent 48d1dde8a7
commit 750fc4e02c
18 changed files with 54 additions and 80 deletions

View File

@@ -111,8 +111,8 @@ namespace OpenRA
[FieldLoader.Ignore] public Lazy<TileReference<byte, byte>[,]> MapResources;
[FieldLoader.Ignore] public string[,] CustomTerrain;
[FieldLoader.Ignore] Lazy<MapRuleset> rules;
public MapRuleset Rules { get { return rules != null ? rules.Value : null; } }
[FieldLoader.Ignore] Lazy<Ruleset> rules;
public Ruleset Rules { get { return rules != null ? rules.Value : null; } }
public SequenceProvider SequenceProvider { get; private set; }
public static Map FromTileset(TileSet tileset)
@@ -249,7 +249,7 @@ namespace OpenRA
SequenceProvider = new SequenceProvider(this);
}
public MapRuleset PreloadRules()
public Ruleset PreloadRules()
{
return rules.Value;
}
@@ -508,7 +508,7 @@ namespace OpenRA
});
}
public void FixOpenAreas(MapRuleset rules)
public void FixOpenAreas(Ruleset rules)
{
var r = new Random();
var tileset = rules.TileSets[Tileset];

View File

@@ -149,7 +149,7 @@ namespace OpenRA
// the next render cycle.
// (d) Any partially written bytes from the next minimap is in an
// unallocated area, and will be committed in the next cycle.
var bitmap = p.CustomPreview ?? Minimap.RenderMapPreview(modData.ModRules.TileSets[p.Map.Tileset], p.Map, true);
var bitmap = p.CustomPreview ?? Minimap.RenderMapPreview(modData.DefaultRules.TileSets[p.Map.Tileset], p.Map, true);
p.Minimap = sheetBuilder.Add(bitmap);
lock (syncRoot)

View File

@@ -15,24 +15,29 @@ using OpenRA.GameRules;
namespace OpenRA
{
public class ModRuleset
public class Ruleset
{
public readonly IReadOnlyDictionary<string, ActorInfo> Actors;
public readonly IReadOnlyDictionary<string, WeaponInfo> Weapons;
public readonly IReadOnlyDictionary<string, SoundInfo> Voices;
public readonly IReadOnlyDictionary<string, SoundInfo> Notifications;
public readonly IReadOnlyDictionary<string, MusicInfo> Music;
public readonly IReadOnlyDictionary<string, string> Movies;
public readonly IReadOnlyDictionary<string, TileSet> TileSets;
public ModRuleset(ModRuleset other)
{
this.Music = other.Music;
this.Movies = other.Movies;
this.TileSets = other.TileSets;
}
public ModRuleset(
public Ruleset(
IDictionary<string, ActorInfo> actors,
IDictionary<string, WeaponInfo> weapons,
IDictionary<string, SoundInfo> voices,
IDictionary<string, SoundInfo> notifications,
IDictionary<string, MusicInfo> music,
IDictionary<string, string> movies,
IDictionary<string, TileSet> tileSets)
{
this.Actors = new ReadOnlyDictionary<string, ActorInfo>(actors);
this.Weapons = new ReadOnlyDictionary<string, WeaponInfo>(weapons);
this.Voices = new ReadOnlyDictionary<string, SoundInfo>(voices);
this.Notifications = new ReadOnlyDictionary<string, SoundInfo>(notifications);
this.Music = new ReadOnlyDictionary<string, MusicInfo>(music);
this.Movies = new ReadOnlyDictionary<string, string>(movies);
this.TileSets = new ReadOnlyDictionary<string, TileSet>(tileSets);
@@ -40,26 +45,4 @@ namespace OpenRA
public IEnumerable<KeyValuePair<string, MusicInfo>> InstalledMusic { get { return Music.Where(m => m.Value.Exists); } }
}
public class MapRuleset : ModRuleset
{
public readonly IReadOnlyDictionary<string, ActorInfo> Actors;
public readonly IReadOnlyDictionary<string, WeaponInfo> Weapons;
public readonly IReadOnlyDictionary<string, SoundInfo> Voices;
public readonly IReadOnlyDictionary<string, SoundInfo> Notifications;
public MapRuleset(
ModRuleset modRuleset,
IDictionary<string, ActorInfo> actors,
IDictionary<string, WeaponInfo> weapons,
IDictionary<string, SoundInfo> voices,
IDictionary<string, SoundInfo> notifications)
: base(modRuleset)
{
this.Actors = new ReadOnlyDictionary<string, ActorInfo>(actors);
this.Weapons = new ReadOnlyDictionary<string, WeaponInfo>(weapons);
this.Voices = new ReadOnlyDictionary<string, SoundInfo>(voices);
this.Notifications = new ReadOnlyDictionary<string, SoundInfo>(notifications);
}
}
}