Check for player trait prereqs in ProximityCapturable

This commit is contained in:
Oliver Brakmann
2018-11-09 22:28:44 +01:00
committed by Paul Chote
parent c3f4bc484d
commit 310b63150f

View File

@@ -18,13 +18,13 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Actor can be captured by units in a specified proximity.")]
public class ProximityCapturableInfo : ITraitInfo
public class ProximityCapturableInfo : ITraitInfo, IRulesetLoaded
{
[Desc("Maximum range at which a ProximityCaptor actor can initiate the capture.")]
public readonly WDist Range = WDist.FromCells(5);
[Desc("Allowed ProximityCaptor actors to capture this actor.")]
public readonly BitSet<CaptureType> CaptorTypes = new BitSet<CaptureType>("Vehicle", "Tank", "Infantry");
public readonly BitSet<CaptureType> CaptorTypes = new BitSet<CaptureType>("Player", "Vehicle", "Tank", "Infantry");
[Desc("If set, the capturing process stops immediately after another player comes into Range.")]
public readonly bool MustBeClear = false;
@@ -36,6 +36,13 @@ namespace OpenRA.Mods.Common.Traits
"This option implies the `Sticky` behaviour as well.")]
public readonly bool Permanent = false;
public void RulesetLoaded(Ruleset rules, ActorInfo info)
{
var pci = rules.Actors["player"].TraitInfoOrDefault<ProximityCaptorInfo>();
if (pci == null)
throw new YamlException("ProximityCapturable requires the `Player` actor to have the ProximityCaptor trait.");
}
public object Create(ActorInitializer init) { return new ProximityCapturable(init.Self, this); }
}