Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to send a radar ping with lua #15359

Merged
merged 1 commit into from Jul 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
Expand Up @@ -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" />
Expand Down
41 changes: 41 additions & 0 deletions 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<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);
}
}
}
}