Add ability to use NukePower via lua.
This commit is contained in:
committed by
Matthias Mailänder
parent
f31e5d17b3
commit
2387e49ee7
@@ -266,6 +266,7 @@
|
|||||||
<Compile Include="Scripting\Properties\ConditionProperties.cs" />
|
<Compile Include="Scripting\Properties\ConditionProperties.cs" />
|
||||||
<Compile Include="Scripting\Properties\ParadropProperties.cs" />
|
<Compile Include="Scripting\Properties\ParadropProperties.cs" />
|
||||||
<Compile Include="Scripting\Properties\ParatroopersProperties.cs" />
|
<Compile Include="Scripting\Properties\ParatroopersProperties.cs" />
|
||||||
|
<Compile Include="Scripting\Properties\NukeProperties.cs" />
|
||||||
<Compile Include="TraitsInterfaces.cs" />
|
<Compile Include="TraitsInterfaces.cs" />
|
||||||
<Compile Include="Traits\AcceptsDeliveredCash.cs" />
|
<Compile Include="Traits\AcceptsDeliveredCash.cs" />
|
||||||
<Compile Include="Traits\AcceptsDeliveredExperience.cs" />
|
<Compile Include="Traits\AcceptsDeliveredExperience.cs" />
|
||||||
|
|||||||
39
OpenRA.Mods.Common/Scripting/Properties/NukeProperties.cs
Normal file
39
OpenRA.Mods.Common/Scripting/Properties/NukeProperties.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
#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 System.Linq;
|
||||||
|
using OpenRA.Effects;
|
||||||
|
using OpenRA.Mods.Common.Activities;
|
||||||
|
using OpenRA.Mods.Common.Effects;
|
||||||
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Scripting;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.Common.Scripting
|
||||||
|
{
|
||||||
|
[ScriptPropertyGroup("Support Powers")]
|
||||||
|
public class NukeProperties : ScriptActorProperties, Requires<NukePowerInfo>
|
||||||
|
{
|
||||||
|
readonly NukePower np;
|
||||||
|
|
||||||
|
public NukeProperties(ScriptContext context, Actor self)
|
||||||
|
: base(context, self)
|
||||||
|
{
|
||||||
|
np = self.TraitsImplementing<NukePower>().First();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Desc("Activate the actor's NukePower.")]
|
||||||
|
public void ActivateNukePower(CPos target)
|
||||||
|
{
|
||||||
|
np.Activate(Self, Self.World.Map.CenterOfCell(target));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -108,10 +108,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
base.Activate(self, order, manager);
|
base.Activate(self, order, manager);
|
||||||
PlayLaunchSounds();
|
PlayLaunchSounds();
|
||||||
|
|
||||||
|
Activate(self, self.World.Map.CenterOfCell(order.TargetLocation));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Activate(Actor self, WPos targetPosition)
|
||||||
|
{
|
||||||
foreach (var launchpad in self.TraitsImplementing<INotifyNuke>())
|
foreach (var launchpad in self.TraitsImplementing<INotifyNuke>())
|
||||||
launchpad.Launching(self);
|
launchpad.Launching(self);
|
||||||
|
|
||||||
var targetPosition = self.World.Map.CenterOfCell(order.TargetLocation);
|
|
||||||
var palette = info.IsPlayerPalette ? info.MissilePalette + self.Owner.InternalName : info.MissilePalette;
|
var palette = info.IsPlayerPalette ? info.MissilePalette + self.Owner.InternalName : info.MissilePalette;
|
||||||
var missile = new NukeLaunch(self.Owner, info.MissileWeapon, info.WeaponInfo, palette, info.MissileUp, info.MissileDown,
|
var missile = new NukeLaunch(self.Owner, info.MissileWeapon, info.WeaponInfo, palette, info.MissileUp, info.MissileDown,
|
||||||
self.CenterPosition + body.LocalToWorld(info.SpawnOffset),
|
self.CenterPosition + body.LocalToWorld(info.SpawnOffset),
|
||||||
@@ -133,7 +137,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (Info.DisplayBeacon)
|
if (Info.DisplayBeacon)
|
||||||
{
|
{
|
||||||
var beacon = new Beacon(
|
var beacon = new Beacon(
|
||||||
order.Player,
|
self.Owner,
|
||||||
targetPosition,
|
targetPosition,
|
||||||
Info.BeaconPaletteIsPlayerPalette,
|
Info.BeaconPaletteIsPlayerPalette,
|
||||||
Info.BeaconPalette,
|
Info.BeaconPalette,
|
||||||
|
|||||||
Reference in New Issue
Block a user