diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
index ac265e91b1..56c70f87b6 100644
--- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
+++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
@@ -114,7 +114,6 @@
-
diff --git a/OpenRA.Mods.RA/Traits/Disguise.cs b/OpenRA.Mods.RA/Traits/Disguise.cs
index 3fe169f14a..3618dbbb46 100644
--- a/OpenRA.Mods.RA/Traits/Disguise.cs
+++ b/OpenRA.Mods.RA/Traits/Disguise.cs
@@ -8,6 +8,7 @@
*/
#endregion
+using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
@@ -61,18 +62,15 @@ namespace OpenRA.Mods.RA.Traits
{
[VoiceReference] public readonly string Voice = "Action";
+ [UpgradeGrantedReference]
+ [Desc("Upgrades to grant when disguised.")]
+ public readonly string[] Upgrades = { "disguise" };
+
public object Create(ActorInitializer init) { return new Disguise(init.Self, this); }
}
class Disguise : IEffectiveOwner, IIssueOrder, IResolveOrder, IOrderVoice, IRadarColorModifier, INotifyAttack
{
- readonly DisguiseInfo info;
-
- public Disguise(Actor self, DisguiseInfo info)
- {
- this.info = info;
- }
-
public Player AsPlayer { get; private set; }
public string AsSprite { get; private set; }
public ITooltipInfo AsTooltipInfo { get; private set; }
@@ -80,6 +78,18 @@ namespace OpenRA.Mods.RA.Traits
public bool Disguised { get { return AsPlayer != null; } }
public Player Owner { get { return AsPlayer; } }
+ readonly Actor self;
+ readonly DisguiseInfo info;
+ readonly Lazy um;
+
+ public Disguise(Actor self, DisguiseInfo info)
+ {
+ this.self = self;
+ this.info = info;
+
+ um = Exts.Lazy(() => self.TraitOrDefault());
+ }
+
public IEnumerable Orders
{
get
@@ -101,7 +111,7 @@ namespace OpenRA.Mods.RA.Traits
if (order.OrderString == "Disguise")
{
var target = order.TargetActor != self && order.TargetActor.IsInWorld ? order.TargetActor : null;
- DisguiseAs(self, target);
+ DisguiseAs(target);
}
}
@@ -118,8 +128,9 @@ namespace OpenRA.Mods.RA.Traits
return AsPlayer.Color.RGB;
}
- void DisguiseAs(Actor self, Actor target)
+ void DisguiseAs(Actor target)
{
+ var oldDisguiseSetting = Disguised;
var oldEffectiveOwner = AsPlayer;
if (target != null)
@@ -150,8 +161,22 @@ namespace OpenRA.Mods.RA.Traits
foreach (var t in self.TraitsImplementing())
t.OnEffectiveOwnerChanged(self, oldEffectiveOwner, AsPlayer);
+
+ if (Disguised != oldDisguiseSetting && um.Value != null)
+ {
+ foreach (var u in info.Upgrades)
+ {
+ if (!um.Value.AcceptsUpgrade(self, u))
+ continue;
+
+ if (Disguised)
+ um.Value.GrantUpgrade(self, u, this);
+ else
+ um.Value.RevokeUpgrade(self, u, this);
+ }
+ }
}
- public void Attacking(Actor self, Target target, Armament a, Barrel barrel) { DisguiseAs(self, null); }
+ public void Attacking(Actor self, Target target, Armament a, Barrel barrel) { DisguiseAs(null); }
}
}
\ No newline at end of file
diff --git a/OpenRA.Mods.RA/Traits/Render/WithDecorationDisguised.cs b/OpenRA.Mods.RA/Traits/Render/WithDecorationDisguised.cs
deleted file mode 100644
index b08d6697dd..0000000000
--- a/OpenRA.Mods.RA/Traits/Render/WithDecorationDisguised.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-#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;
-using OpenRA.Mods.Common.Traits;
-using OpenRA.Traits;
-
-namespace OpenRA.Mods.RA.Traits
-{
- public class WithDecorationDisguisedInfo : WithDecorationInfo, Requires
- {
- [Desc("Require an active disguise to render this decoration?")]
- public readonly bool RequireDisguise = true;
-
- public override object Create(ActorInitializer init) { return new WithDecorationDisguised(init.Self, this); }
- }
-
- public class WithDecorationDisguised : WithDecoration
- {
- readonly WithDecorationDisguisedInfo info;
- readonly Disguise disguise;
-
- public WithDecorationDisguised(Actor self, WithDecorationDisguisedInfo info)
- : base(self, info)
- {
- this.info = info;
- disguise = self.Trait();
- }
-
- public override bool ShouldRender(Actor self)
- {
- return !info.RequireDisguise || disguise.Disguised;
- }
- }
-}
\ No newline at end of file
diff --git a/mods/ra/bits/pip-disguise.shp b/mods/ra/bits/pip-disguise.shp
new file mode 100644
index 0000000000..95ecd66f9e
Binary files /dev/null and b/mods/ra/bits/pip-disguise.shp differ
diff --git a/mods/ra/rules/infantry.yaml b/mods/ra/rules/infantry.yaml
index 3fc6b8faf4..ef9ff4b653 100644
--- a/mods/ra/rules/infantry.yaml
+++ b/mods/ra/rules/infantry.yaml
@@ -235,6 +235,15 @@ SPY:
AttackSequence: shoot
IdleSequences: idle1,idle2
StandSequences: stand,stand2
+ WithDecoration@disguise:
+ Image: pips
+ Sequence: pip-disguise
+ Palette: effect
+ ReferencePoint: Top, Right
+ Offset: 4, -2
+ ZOffset: 256
+ UpgradeTypes: disguise
+ UpgradeMinEnabledLevel: 1
Armament:
Weapon: SilencedPPK
AttackFrontal:
diff --git a/mods/ra/sequences/misc.yaml b/mods/ra/sequences/misc.yaml
index 81d364686e..9b7795b908 100644
--- a/mods/ra/sequences/misc.yaml
+++ b/mods/ra/sequences/misc.yaml
@@ -84,6 +84,9 @@ pips:
Start: 4
pip-blue: pips2
Start: 5
+ pip-disguise: pip-disguise
+ Length: *
+ Tick: 300
v2:
idle:
diff --git a/mods/ts/bits/pip-disguise.shp b/mods/ts/bits/pip-disguise.shp
new file mode 100644
index 0000000000..95ecd66f9e
Binary files /dev/null and b/mods/ts/bits/pip-disguise.shp differ
diff --git a/mods/ts/rules/civilian-infantry.yaml b/mods/ts/rules/civilian-infantry.yaml
index e3f51f9ea3..354b4fd794 100644
--- a/mods/ts/rules/civilian-infantry.yaml
+++ b/mods/ts/rules/civilian-infantry.yaml
@@ -58,6 +58,15 @@ CHAMSPY:
Range: 9c0
Passenger:
Disguise:
+ WithDecoration@disguise:
+ Image: pips
+ Sequence: pip-disguise
+ Palette: pips
+ ReferencePoint: Top, Right
+ Offset: 4, -2
+ ZOffset: 256
+ UpgradeTypes: disguise
+ UpgradeMinEnabledLevel: 1
Infiltrates:
Types: SpyInfiltrate
-AutoTarget:
diff --git a/mods/ts/sequences/misc.yaml b/mods/ts/sequences/misc.yaml
index 6805414045..91ed65b881 100644
--- a/mods/ts/sequences/misc.yaml
+++ b/mods/ts/sequences/misc.yaml
@@ -94,6 +94,9 @@ pips:
pip-ammo: ammopips
pip-ammoempty: ammopips
Start: 1
+ pip-disguise: pip-disguise
+ Length: *
+ Tick: 300
# TODO:
pip-empty-building:
pip-green-building: