Implement reveal-on-fire.
This commit is contained in:
@@ -789,6 +789,7 @@
|
|||||||
<Compile Include="UtilityCommands\Utilities.cs" />
|
<Compile Include="UtilityCommands\Utilities.cs" />
|
||||||
<Compile Include="UtilityCommands\OutputResolvedSequencesCommand.cs" />
|
<Compile Include="UtilityCommands\OutputResolvedSequencesCommand.cs" />
|
||||||
<Compile Include="UtilityCommands\OutputResolvedWeaponsCommand.cs" />
|
<Compile Include="UtilityCommands\OutputResolvedWeaponsCommand.cs" />
|
||||||
|
<Compile Include="Traits\RevealOnFire.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<Target Name="AfterBuild">
|
<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
|
Palette: pips
|
||||||
ReferencePoint: Bottom, Right
|
ReferencePoint: Bottom, Right
|
||||||
RequiresCondition: hospitalheal
|
RequiresCondition: hospitalheal
|
||||||
|
RevealOnFire:
|
||||||
|
|
||||||
^RegularInfantryDeath:
|
^RegularInfantryDeath:
|
||||||
WithDeathAnimation@normal:
|
WithDeathAnimation@normal:
|
||||||
@@ -520,6 +521,7 @@
|
|||||||
RequiresCondition: criticalspeed
|
RequiresCondition: criticalspeed
|
||||||
Modifier: 60
|
Modifier: 60
|
||||||
Carryable:
|
Carryable:
|
||||||
|
RevealOnFire:
|
||||||
|
|
||||||
^Tank:
|
^Tank:
|
||||||
Inherits: ^Vehicle
|
Inherits: ^Vehicle
|
||||||
@@ -592,6 +594,7 @@
|
|||||||
MustBeDestroyed:
|
MustBeDestroyed:
|
||||||
RenderVoxels:
|
RenderVoxels:
|
||||||
WithVoxelBody:
|
WithVoxelBody:
|
||||||
|
RevealOnFire:
|
||||||
|
|
||||||
^Helicopter:
|
^Helicopter:
|
||||||
Inherits: ^Aircraft
|
Inherits: ^Aircraft
|
||||||
@@ -662,6 +665,7 @@
|
|||||||
HiddenUnderFog:
|
HiddenUnderFog:
|
||||||
Guardable:
|
Guardable:
|
||||||
WithSpriteBody:
|
WithSpriteBody:
|
||||||
|
RevealOnFire:
|
||||||
|
|
||||||
^BlossomTree:
|
^BlossomTree:
|
||||||
Inherits@1: ^SpriteActor
|
Inherits@1: ^SpriteActor
|
||||||
@@ -747,6 +751,7 @@
|
|||||||
Range: 6c0
|
Range: 6c0
|
||||||
DetectCloaked:
|
DetectCloaked:
|
||||||
Range: 5c0
|
Range: 5c0
|
||||||
|
RevealOnFire:
|
||||||
|
|
||||||
^Train:
|
^Train:
|
||||||
Inherits@1: ^EmpDisable
|
Inherits@1: ^EmpDisable
|
||||||
|
|||||||
@@ -218,6 +218,7 @@ GAARTY:
|
|||||||
NoTransformSounds:
|
NoTransformSounds:
|
||||||
Voice: Move
|
Voice: Move
|
||||||
WithMuzzleOverlay:
|
WithMuzzleOverlay:
|
||||||
|
RevealOnFire:
|
||||||
|
|
||||||
NAMISL:
|
NAMISL:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
@@ -165,6 +165,8 @@ TTNK:
|
|||||||
AutoTarget:
|
AutoTarget:
|
||||||
Carryable:
|
Carryable:
|
||||||
RequiresCondition: undeployed
|
RequiresCondition: undeployed
|
||||||
|
RevealOnFire:
|
||||||
|
ArmamentNames: primary, deployed
|
||||||
|
|
||||||
ART2:
|
ART2:
|
||||||
Inherits: ^Tank
|
Inherits: ^Tank
|
||||||
|
|||||||
Reference in New Issue
Block a user