Make buildings grant prerequisites explicitly

This commit is contained in:
penev92
2015-03-30 21:08:43 +03:00
parent a310411bcc
commit 50fb6f1d25
3 changed files with 12 additions and 14 deletions

View File

@@ -17,13 +17,13 @@ namespace OpenRA.Mods.Common.Traits
{
public class ProvidesCustomPrerequisiteInfo : ITraitInfo
{
[Desc("The prerequisite type that this provides")]
[Desc("The prerequisite type that this provides. If left empty it defaults to the actor's name.")]
public readonly string Prerequisite = null;
[Desc("Only grant this prerequisite when you have these prerequisites")]
[Desc("Only grant this prerequisite when you have these prerequisites.")]
public readonly string[] RequiresPrerequisites = { };
[Desc("Only grant this prerequisite for certain factions")]
[Desc("Only grant this prerequisite for certain factions.")]
public readonly string[] Race = { };
[Desc("Should it recheck everything when it is captured?")]
@@ -34,12 +34,17 @@ namespace OpenRA.Mods.Common.Traits
public class ProvidesCustomPrerequisite : ITechTreePrerequisite, INotifyOwnerChanged
{
readonly ProvidesCustomPrerequisiteInfo info;
readonly string prerequisite;
bool enabled = true;
public ProvidesCustomPrerequisite(ActorInitializer init, ProvidesCustomPrerequisiteInfo info)
{
this.info = info;
prerequisite = info.Prerequisite;
if (string.IsNullOrEmpty(prerequisite))
prerequisite = init.Self.Info.Name;
var race = init.Contains<RaceInit>() ? init.Get<RaceInit, string>() : init.Self.Owner.Country.Race;
@@ -53,7 +58,7 @@ namespace OpenRA.Mods.Common.Traits
if (!enabled)
yield break;
yield return info.Prerequisite;
yield return prerequisite;
}
}