From 2dda2d768978bfa9f02e36b65fab9d3f89b83776 Mon Sep 17 00:00:00 2001 From: Curtis Shmyr Date: Tue, 30 Jun 2020 18:57:50 -0600 Subject: [PATCH] Added lua IsCloaked actor property --- .../Scripting/Properties/CloakProperties.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 OpenRA.Mods.Common/Scripting/Properties/CloakProperties.cs diff --git a/OpenRA.Mods.Common/Scripting/Properties/CloakProperties.cs b/OpenRA.Mods.Common/Scripting/Properties/CloakProperties.cs new file mode 100644 index 0000000000..521f845815 --- /dev/null +++ b/OpenRA.Mods.Common/Scripting/Properties/CloakProperties.cs @@ -0,0 +1,39 @@ +#region Copyright & License Information +/* + * Copyright 2007-2020 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using System.Linq; +using OpenRA.Mods.Common.Traits; +using OpenRA.Scripting; +using OpenRA.Traits; + +namespace OpenRA.Mods.Common.Scripting +{ + [ScriptPropertyGroup("Cloak")] + public class CloakProperties : ScriptActorProperties, Requires + { + readonly Cloak[] cloaks; + + public CloakProperties(ScriptContext context, Actor self) + : base(context, self) + { + cloaks = self.TraitsImplementing().ToArray(); + } + + [Desc("Returns true if the actor is cloaked.")] + public bool IsCloaked + { + get + { + return cloaks.Any(c => c.Cloaked); + } + } + } +}