Implement reveal-on-fire.
This commit is contained in:
@@ -789,6 +789,7 @@
|
||||
<Compile Include="UtilityCommands\Utilities.cs" />
|
||||
<Compile Include="UtilityCommands\OutputResolvedSequencesCommand.cs" />
|
||||
<Compile Include="UtilityCommands\OutputResolvedWeaponsCommand.cs" />
|
||||
<Compile Include="Traits\RevealOnFire.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="AfterBuild">
|
||||
|
||||
79
OpenRA.Mods.Common/Traits/RevealOnFire.cs
Normal file
79
OpenRA.Mods.Common/Traits/RevealOnFire.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2017 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.Mods.Common.Effects;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Reveal this actor to the target's owner when attacking.")]
|
||||
public class RevealOnFireInfo : ConditionalTraitInfo
|
||||
{
|
||||
[Desc("The armament types which trigger revealing.")]
|
||||
public readonly string[] ArmamentNames = { "primary", "secondary" };
|
||||
|
||||
[Desc("Stances relative to the target player this actor will be revealed to during firing.")]
|
||||
public readonly Stance RevealForStancesRelativeToTarget = Stance.Ally;
|
||||
|
||||
[Desc("Duration of the reveal.")]
|
||||
public readonly int Duration = 25;
|
||||
|
||||
[Desc("Radius of the reveal around this actor.")]
|
||||
public readonly WDist Radius = new WDist(1536);
|
||||
|
||||
[Desc("Can this actor be revealed through shroud generated by the GeneratesShroud trait?")]
|
||||
public readonly bool RevealGeneratedShroud = true;
|
||||
|
||||
public override object Create(ActorInitializer init) { return new RevealOnFire(init.Self, this); }
|
||||
}
|
||||
|
||||
public class RevealOnFire : ConditionalTrait<RevealOnFireInfo>, INotifyAttack
|
||||
{
|
||||
readonly RevealOnFireInfo info;
|
||||
|
||||
public RevealOnFire(Actor self, RevealOnFireInfo info)
|
||||
: base(info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
void INotifyAttack.Attacking(Actor self, Target target, Armament a, Barrel barrel)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return;
|
||||
|
||||
if (!info.ArmamentNames.Contains(a.Info.Name))
|
||||
return;
|
||||
|
||||
var targetPlayer = GetTargetPlayer(target);
|
||||
|
||||
if (targetPlayer != null && targetPlayer.WinState == WinState.Undefined)
|
||||
{
|
||||
self.World.AddFrameEndTask(w => w.Add(new RevealShroudEffect(self.CenterPosition, info.Radius,
|
||||
info.RevealGeneratedShroud ? Shroud.SourceType.Visibility : Shroud.SourceType.PassiveVisibility,
|
||||
targetPlayer, info.RevealForStancesRelativeToTarget, duration: info.Duration)));
|
||||
}
|
||||
}
|
||||
|
||||
Player GetTargetPlayer(Target target)
|
||||
{
|
||||
if (target.Type == TargetType.Actor)
|
||||
return target.Actor.Owner;
|
||||
else if (target.Type == TargetType.FrozenActor && !target.FrozenActor.Actor.IsDead)
|
||||
return target.FrozenActor.Actor.Owner;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
void INotifyAttack.PreparingAttack(Actor self, OpenRA.Traits.Target target, Armament a, Barrel barrel) { }
|
||||
}
|
||||
}
|
||||
@@ -341,6 +341,7 @@
|
||||
Palette: pips
|
||||
ReferencePoint: Bottom, Right
|
||||
RequiresCondition: hospitalheal
|
||||
RevealOnFire:
|
||||
|
||||
^RegularInfantryDeath:
|
||||
WithDeathAnimation@normal:
|
||||
@@ -520,6 +521,7 @@
|
||||
RequiresCondition: criticalspeed
|
||||
Modifier: 60
|
||||
Carryable:
|
||||
RevealOnFire:
|
||||
|
||||
^Tank:
|
||||
Inherits: ^Vehicle
|
||||
@@ -592,6 +594,7 @@
|
||||
MustBeDestroyed:
|
||||
RenderVoxels:
|
||||
WithVoxelBody:
|
||||
RevealOnFire:
|
||||
|
||||
^Helicopter:
|
||||
Inherits: ^Aircraft
|
||||
@@ -662,6 +665,7 @@
|
||||
HiddenUnderFog:
|
||||
Guardable:
|
||||
WithSpriteBody:
|
||||
RevealOnFire:
|
||||
|
||||
^BlossomTree:
|
||||
Inherits@1: ^SpriteActor
|
||||
@@ -747,6 +751,7 @@
|
||||
Range: 6c0
|
||||
DetectCloaked:
|
||||
Range: 5c0
|
||||
RevealOnFire:
|
||||
|
||||
^Train:
|
||||
Inherits@1: ^EmpDisable
|
||||
|
||||
@@ -218,6 +218,7 @@ GAARTY:
|
||||
NoTransformSounds:
|
||||
Voice: Move
|
||||
WithMuzzleOverlay:
|
||||
RevealOnFire:
|
||||
|
||||
NAMISL:
|
||||
Inherits: ^Building
|
||||
|
||||
@@ -165,6 +165,8 @@ TTNK:
|
||||
AutoTarget:
|
||||
Carryable:
|
||||
RequiresCondition: undeployed
|
||||
RevealOnFire:
|
||||
ArmamentNames: primary, deployed
|
||||
|
||||
ART2:
|
||||
Inherits: ^Tank
|
||||
|
||||
Reference in New Issue
Block a user