Add IRulesetLoaded for late binding in trait info getting all rules

This commit is contained in:
atlimit8
2015-09-20 10:23:41 -05:00
parent a8106a9999
commit 65c1d2f5c1
2 changed files with 7 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ using System.Collections.Generic;
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA
{
@@ -41,6 +42,10 @@ namespace OpenRA
Music = new ReadOnlyDictionary<string, MusicInfo>(music);
TileSets = new ReadOnlyDictionary<string, TileSet>(tileSets);
Sequences = new ReadOnlyDictionary<string, SequenceProvider>(sequences);
foreach (var a in Actors.Values)
foreach (var t in a.TraitInfos<IRulesetLoaded>())
t.RulesetLoaded(this, a);
}
public IEnumerable<KeyValuePair<string, MusicInfo>> InstalledMusic { get { return Music.Where(m => m.Value.Exists); } }

View File

@@ -368,4 +368,6 @@ namespace OpenRA.Traits
{
bool RemoveActor(Actor self, Player owner);
}
public interface IRulesetLoaded : ITraitInfo { void RulesetLoaded(Ruleset rules, ActorInfo ai); }
}