Permalink
Browse files

Implement RevealOnFire in the AS namespace for now.

  • Loading branch information...
1 parent e7f574e commit ce85dc8cbe1cc6135e7c8c261a799ebcb05a0062 @GraionDilach committed Jan 8, 2017
Showing with 77 additions and 0 deletions.
  1. +1 −0 OpenRA.Mods.AS.csproj
  2. +76 −0 Traits/RevealOnFire.cs
@@ -85,6 +85,7 @@
<Compile Include="Traits\ExplodeWeapon.cs" />
<Compile Include="Traits\PeriodicProducer.cs" />
<Compile Include="Traits\Player\PlayerSilo.cs" />
+ <Compile Include="Traits\RevealOnFire.cs" />
<Compile Include="Traits\SupportPowers\AirstrikePowerAS.cs" />
<Compile Include="Traits\Multipliers\HealthPercentageFirepowerMultiplier.cs" />
<Compile Include="Traits\SupportPowers\DetonateWeaponPower.cs" />
@@ -0,0 +1,76 @@
+#region Copyright & License Information
+/*
+ * Copyright 2015- OpenRA.Mods.AS Developers (see AUTHORS)
+ * This file is a part of a third-party plugin for 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.Traits;
+
+namespace OpenRA.Mods.AS.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("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 RevealedThroughGeneratedShroud = 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.RevealedThroughGeneratedShroud ? Shroud.SourceType.Visibility : Shroud.SourceType.PassiveVisibility,
+ targetPlayer, Stance.Ally, 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) { }
+ }
+}

0 comments on commit ce85dc8

Please sign in to comment.