Make Prerequisite Lint Check use ITechTreePrerequisiteInfo
This commit is contained in:
committed by
Paul Chote
parent
e33f729682
commit
c14c7653bc
@@ -20,16 +20,7 @@ namespace OpenRA.Mods.Common.Lint
|
|||||||
{
|
{
|
||||||
public void Run(Action<string> emitError, Action<string> emitWarning, Ruleset rules)
|
public void Run(Action<string> emitError, Action<string> emitWarning, Ruleset rules)
|
||||||
{
|
{
|
||||||
// ProvidesPrerequisite allows arbitrary prereq definitions
|
var providedPrereqs = rules.Actors.SelectMany(a => a.Value.TraitInfos<ITechTreePrerequisiteInfo>().SelectMany(p => p.Prerequisites(a.Value)));
|
||||||
var customPrereqs = rules.Actors.SelectMany(a => a.Value.TraitInfos<ProvidesPrerequisiteInfo>()
|
|
||||||
.Select(p => p.Prerequisite ?? a.Value.Name));
|
|
||||||
|
|
||||||
// ProvidesTechPrerequisite allows arbitrary prereq definitions
|
|
||||||
// (but only one group at a time during gameplay)
|
|
||||||
var techPrereqs = rules.Actors.SelectMany(a => a.Value.TraitInfos<ProvidesTechPrerequisiteInfo>())
|
|
||||||
.SelectMany(p => p.Prerequisites);
|
|
||||||
|
|
||||||
var providedPrereqs = customPrereqs.Concat(techPrereqs);
|
|
||||||
|
|
||||||
// TODO: this check is case insensitive while the real check in-game is not
|
// TODO: this check is case insensitive while the real check in-game is not
|
||||||
foreach (var i in rules.Actors)
|
foreach (var i in rules.Actors)
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
[Desc("Should it recheck everything when it is captured?")]
|
[Desc("Should it recheck everything when it is captured?")]
|
||||||
public readonly bool ResetOnOwnerChange = false;
|
public readonly bool ResetOnOwnerChange = false;
|
||||||
|
|
||||||
|
IEnumerable<string> ITechTreePrerequisiteInfo.Prerequisites(ActorInfo info)
|
||||||
|
{
|
||||||
|
return new string[] { Prerequisite ?? info.Name };
|
||||||
|
}
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new ProvidesPrerequisite(init, this); }
|
public override object Create(ActorInitializer init) { return new ProvidesPrerequisite(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Prerequisites to grant when this tech level is active.")]
|
[Desc("Prerequisites to grant when this tech level is active.")]
|
||||||
public readonly string[] Prerequisites = { };
|
public readonly string[] Prerequisites = { };
|
||||||
|
|
||||||
|
IEnumerable<string> ITechTreePrerequisiteInfo.Prerequisites(ActorInfo info) { return Prerequisites; }
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new ProvidesTechPrerequisite(this, init); }
|
public object Create(ActorInitializer init) { return new ProvidesTechPrerequisite(this, init); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ using OpenRA.Traits;
|
|||||||
namespace OpenRA.Mods.Common.Traits
|
namespace OpenRA.Mods.Common.Traits
|
||||||
{
|
{
|
||||||
[Desc("Enables defined prerequisites at game start for all players if the checkbox is enabled.")]
|
[Desc("Enables defined prerequisites at game start for all players if the checkbox is enabled.")]
|
||||||
public class LobbyPrerequisiteCheckboxInfo : ITraitInfo, ILobbyOptions
|
public class LobbyPrerequisiteCheckboxInfo : ITraitInfo, ILobbyOptions, ITechTreePrerequisiteInfo
|
||||||
{
|
{
|
||||||
[FieldLoader.Require]
|
[FieldLoader.Require]
|
||||||
[Desc("Internal id for this checkbox.")]
|
[Desc("Internal id for this checkbox.")]
|
||||||
@@ -45,6 +45,8 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("Prerequisites to grant when this checkbox is enabled.")]
|
[Desc("Prerequisites to grant when this checkbox is enabled.")]
|
||||||
public readonly HashSet<string> Prerequisites = new HashSet<string>();
|
public readonly HashSet<string> Prerequisites = new HashSet<string>();
|
||||||
|
|
||||||
|
IEnumerable<string> ITechTreePrerequisiteInfo.Prerequisites(ActorInfo info) { return Prerequisites; }
|
||||||
|
|
||||||
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
|
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
|
||||||
{
|
{
|
||||||
yield return new LobbyBooleanOption(ID, Label, Description,
|
yield return new LobbyBooleanOption(ID, Label, Description,
|
||||||
|
|||||||
@@ -211,7 +211,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
void Infiltrating(Actor self);
|
void Infiltrating(Actor self);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ITechTreePrerequisiteInfo : ITraitInfo { }
|
public interface ITechTreePrerequisiteInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
IEnumerable<string> Prerequisites(ActorInfo info);
|
||||||
|
}
|
||||||
|
|
||||||
public interface ITechTreePrerequisite
|
public interface ITechTreePrerequisite
|
||||||
{
|
{
|
||||||
IEnumerable<string> ProvidesPrerequisites { get; }
|
IEnumerable<string> ProvidesPrerequisites { get; }
|
||||||
|
|||||||
Reference in New Issue
Block a user