From 6130d5622c4ada996623c0b8f1adefc894acf767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 6 Jun 2020 10:46:51 +0200 Subject: [PATCH] Add a panic function to the Lua API. --- .../Properties/ScaredCatProperties.cs | 36 +++++++++++++++++++ .../Traits/Infantry/ScaredyCat.cs | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 OpenRA.Mods.Common/Scripting/Properties/ScaredCatProperties.cs diff --git a/OpenRA.Mods.Common/Scripting/Properties/ScaredCatProperties.cs b/OpenRA.Mods.Common/Scripting/Properties/ScaredCatProperties.cs new file mode 100644 index 0000000000..a29a262db3 --- /dev/null +++ b/OpenRA.Mods.Common/Scripting/Properties/ScaredCatProperties.cs @@ -0,0 +1,36 @@ +#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 OpenRA.Mods.Common.Traits; +using OpenRA.Scripting; +using OpenRA.Traits; + +namespace OpenRA.Mods.Common.Scripting +{ + [ScriptPropertyGroup("Movement")] + public class ScaredCatProperties : ScriptActorProperties, Requires + { + readonly ScaredyCat scaredyCat; + + public ScaredCatProperties(ScriptContext context, Actor self) + : base(context, self) + { + scaredyCat = self.Trait(); + } + + [ScriptActorPropertyActivity] + [Desc("Makes the unit automatically run around and become faster.")] + public void Panic() + { + scaredyCat.Panic(); + } + } +} diff --git a/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs b/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs index 8b406a2ca6..fe54c38460 100644 --- a/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs +++ b/OpenRA.Mods.Common/Traits/Infantry/ScaredyCat.cs @@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Traits mobile = self.Trait(); } - void Panic() + public void Panic() { if (!Panicking) self.CancelActivity();