Add a lua function for beacons
This commit is contained in:
@@ -12,10 +12,11 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Scripting;
|
||||
|
||||
namespace OpenRA.Mods.Common.Effects
|
||||
{
|
||||
public class Beacon : IEffect
|
||||
public class Beacon : IEffect, IScriptBindable
|
||||
{
|
||||
static readonly int MaxArrowHeight = 512;
|
||||
|
||||
|
||||
@@ -213,6 +213,7 @@
|
||||
<Compile Include="Scripting\Media.cs" />
|
||||
<Compile Include="Scripting\ScriptTriggers.cs" />
|
||||
<Compile Include="Scripting\Global\ActorGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\BeaconGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\CameraGlobal.cs" />
|
||||
<Compile Include="Scripting\Global\CoordinateGlobals.cs" />
|
||||
<Compile Include="Scripting\Global\DateTimeGlobal.cs" />
|
||||
|
||||
47
OpenRA.Mods.Common/Scripting/Global/BeaconGlobal.cs
Normal file
47
OpenRA.Mods.Common/Scripting/Global/BeaconGlobal.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 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. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Effects;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Scripting;
|
||||
|
||||
namespace OpenRA.Mods.Common.Scripting
|
||||
{
|
||||
[ScriptGlobal("Beacon")]
|
||||
public class BeaconGlobal : ScriptGlobal
|
||||
{
|
||||
readonly RadarPings radarPings;
|
||||
|
||||
public BeaconGlobal(ScriptContext context) : base(context)
|
||||
{
|
||||
radarPings = context.World.WorldActor.TraitOrDefault<RadarPings>();
|
||||
}
|
||||
|
||||
[Desc("Creates a new beacon that stays for the specified time at the specified WPos." +
|
||||
"Does not remove player set beacons, nor gets removed by placing them.")]
|
||||
public Beacon New(Player owner, WPos position, int duration = 30 * 25, bool showRadarPings = true, string palettePrefix = "player")
|
||||
{
|
||||
var playerBeacon = new Beacon(owner, position, duration, palettePrefix);
|
||||
owner.PlayerActor.World.AddFrameEndTask(w => w.Add(playerBeacon));
|
||||
|
||||
if (showRadarPings && radarPings != null)
|
||||
{
|
||||
radarPings.Add(
|
||||
() => owner.IsAlliedWith(owner.World.RenderPlayer),
|
||||
position,
|
||||
owner.Color.RGB,
|
||||
duration);
|
||||
}
|
||||
|
||||
return playerBeacon;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user