From 9c61217bc6aedd986f1b6f5875981f0d3689aeb9 Mon Sep 17 00:00:00 2001 From: Mustafa Alperen Seki Date: Wed, 18 Jul 2018 12:41:39 +0300 Subject: [PATCH] Add ability to send a radar ping with lua. --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 + .../Scripting/Global/RadarGlobal.cs | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 OpenRA.Mods.Common/Scripting/Global/RadarGlobal.cs diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 8ae62cf90b..c98d6dd53f 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -238,6 +238,7 @@ + diff --git a/OpenRA.Mods.Common/Scripting/Global/RadarGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/RadarGlobal.cs new file mode 100644 index 0000000000..018bd95cc1 --- /dev/null +++ b/OpenRA.Mods.Common/Scripting/Global/RadarGlobal.cs @@ -0,0 +1,41 @@ +#region Copyright & License Information +/* + * Copyright 2007-2018 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.Graphics; +using OpenRA.Mods.Common.Traits; +using OpenRA.Scripting; + +namespace OpenRA.Mods.Common.Scripting +{ + [ScriptGlobal("Radar")] + public class RadarGlobal : ScriptGlobal + { + readonly RadarPings radarPings; + + public RadarGlobal(ScriptContext context) : base(context) + { + radarPings = context.World.WorldActor.TraitOrDefault(); + } + + [Desc("Creates a new radar ping that stays for the specified time at the specified WPos.")] + public void Ping(Player player, WPos position, HSLColor color, int duration = 30 * 25) + { + if (radarPings != null) + { + radarPings.Add( + () => player.World.RenderPlayer == player, + position, + color.RGB, + duration); + } + } + } +}