From 310b63150f7c772e32e86933667e89fb45cb5e84 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Fri, 9 Nov 2018 22:28:44 +0100 Subject: [PATCH] Check for player trait prereqs in ProximityCapturable --- OpenRA.Mods.Common/Traits/ProximityCapturable.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/ProximityCapturable.cs b/OpenRA.Mods.Common/Traits/ProximityCapturable.cs index b5d7011aba..1dfeb82720 100644 --- a/OpenRA.Mods.Common/Traits/ProximityCapturable.cs +++ b/OpenRA.Mods.Common/Traits/ProximityCapturable.cs @@ -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 CaptorTypes = new BitSet("Vehicle", "Tank", "Infantry"); + public readonly BitSet CaptorTypes = new BitSet("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(); + 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); } }