From aecfff905d98e9d2ef9bcf432dec626f7f3365a9 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Thu, 11 May 2017 14:06:25 +0200 Subject: [PATCH] Throw a more detailed error message when creating invalid frozen actors --- OpenRA.Mods.Common/Traits/Modifiers/FrozenUnderFog.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Modifiers/FrozenUnderFog.cs b/OpenRA.Mods.Common/Traits/Modifiers/FrozenUnderFog.cs index 512c36c73d..a4a58ab5c9 100644 --- a/OpenRA.Mods.Common/Traits/Modifiers/FrozenUnderFog.cs +++ b/OpenRA.Mods.Common/Traits/Modifiers/FrozenUnderFog.cs @@ -18,11 +18,17 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { [Desc("This actor will remain visible (but not updated visually) under fog, once discovered.")] - public class FrozenUnderFogInfo : ITraitInfo, Requires, IDefaultVisibilityInfo + public class FrozenUnderFogInfo : ITraitInfo, Requires, IDefaultVisibilityInfo, IRulesetLoaded { [Desc("Players with these stances can always see the actor.")] public readonly Stance AlwaysVisibleStances = Stance.Ally; + void IRulesetLoaded.RulesetLoaded(Ruleset rules, ActorInfo info) + { + if (!info.HasTraitInfo() && !info.HasTraitInfo()) + throw new YamlException("Cannot create a frozen actor for actor type '{0}' with empty bounds (no selection size given).".F(info.Name)); + } + public object Create(ActorInitializer init) { return new FrozenUnderFog(init, this); } } @@ -61,7 +67,7 @@ namespace OpenRA.Mods.Common.Traits footprint = footprintCells.SelectMany(c => map.ProjectedCellsCovering(c.ToMPos(map))).ToArray(); } - public void Created(Actor self) + void INotifyCreated.Created(Actor self) { frozenStates = new PlayerDictionary(self.World, (player, playerIndex) => {