Add ability to send a radar ping with lua.

This commit is contained in:
Mustafa Alperen Seki
2018-07-18 12:41:39 +03:00
committed by Paul Chote
parent b86355cda6
commit 9c61217bc6
2 changed files with 42 additions and 0 deletions

View File

@@ -238,6 +238,7 @@
<Compile Include="Scripting\Global\MapGlobal.cs" />
<Compile Include="Scripting\Global\MediaGlobal.cs" />
<Compile Include="Scripting\Global\PlayerGlobal.cs" />
<Compile Include="Scripting\Global\RadarGlobal.cs" />
<Compile Include="Scripting\Global\ReinforcementsGlobal.cs" />
<Compile Include="Scripting\Global\TriggerGlobal.cs" />
<Compile Include="Scripting\Global\UserInterfaceGlobal.cs" />

View File

@@ -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<RadarPings>();
}
[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);
}
}
}
}