Simplify cloak crate behavior.
This removes the runtime trait addition which prevented Cloak from being cached. The CloakCrateAction in D2K was never used, so has also been removed.
This commit is contained in:
@@ -22,6 +22,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly int InitialDelay = 10; // Ticks
|
public readonly int InitialDelay = 10; // Ticks
|
||||||
public readonly int CloakDelay = 30; // Ticks
|
public readonly int CloakDelay = 30; // Ticks
|
||||||
public readonly bool UncloakOnMove = false;
|
public readonly bool UncloakOnMove = false;
|
||||||
|
public readonly bool RequiresCrate = false;
|
||||||
|
|
||||||
public readonly string CloakSound = "subshow1.aud";
|
public readonly string CloakSound = "subshow1.aud";
|
||||||
public readonly string UncloakSound = "subshow1.aud";
|
public readonly string UncloakSound = "subshow1.aud";
|
||||||
@@ -33,7 +34,8 @@ namespace OpenRA.Mods.RA
|
|||||||
public class Cloak : IRenderModifier, INotifyDamageStateChanged, INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, ISync
|
public class Cloak : IRenderModifier, INotifyDamageStateChanged, INotifyAttack, ITick, IVisibilityModifier, IRadarColorModifier, ISync
|
||||||
{
|
{
|
||||||
[Sync] int remainingTime;
|
[Sync] int remainingTime;
|
||||||
[Sync] bool canCloak = true;
|
[Sync] bool damageDisabled;
|
||||||
|
[Sync] bool crateDisabled;
|
||||||
|
|
||||||
Actor self;
|
Actor self;
|
||||||
CloakInfo info;
|
CloakInfo info;
|
||||||
@@ -45,6 +47,7 @@ namespace OpenRA.Mods.RA
|
|||||||
this.self = self;
|
this.self = self;
|
||||||
|
|
||||||
remainingTime = info.InitialDelay;
|
remainingTime = info.InitialDelay;
|
||||||
|
crateDisabled = info.RequiresCrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Uncloak() { Uncloak(info.CloakDelay); }
|
public void Uncloak() { Uncloak(info.CloakDelay); }
|
||||||
@@ -63,8 +66,8 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void DamageStateChanged(Actor self, AttackInfo e)
|
public void DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
canCloak = e.DamageState < DamageState.Critical;
|
damageDisabled = e.DamageState >= DamageState.Critical;
|
||||||
if (!canCloak)
|
if (damageDisabled)
|
||||||
Uncloak();
|
Uncloak();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +87,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (remainingTime > 0 && canCloak && --remainingTime <= 0)
|
if (remainingTime > 0 && !crateDisabled && !damageDisabled && --remainingTime <= 0)
|
||||||
{
|
{
|
||||||
self.Generation++;
|
self.Generation++;
|
||||||
Sound.Play(info.CloakSound, self.CenterPosition);
|
Sound.Play(info.CloakSound, self.CenterPosition);
|
||||||
@@ -118,5 +121,12 @@ namespace OpenRA.Mods.RA
|
|||||||
c = Color.FromArgb(128, c);
|
c = Color.FromArgb(128, c);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool AcceptsCloakCrate { get { return info.RequiresCrate && crateDisabled; } }
|
||||||
|
|
||||||
|
public void ReceivedCloakCrate(Actor self)
|
||||||
|
{
|
||||||
|
crateDisabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,52 +16,27 @@ namespace OpenRA.Mods.RA.Crates
|
|||||||
{
|
{
|
||||||
public class CloakCrateActionInfo : CrateActionInfo
|
public class CloakCrateActionInfo : CrateActionInfo
|
||||||
{
|
{
|
||||||
public readonly int InitialDelay = 10;
|
|
||||||
public readonly int CloakDelay = 30;
|
|
||||||
public readonly string CloakSound = "subshow1.aud";
|
|
||||||
public readonly string UncloakSound = "subshow1.aud";
|
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new CloakCrateAction(init.self, this); }
|
public override object Create(ActorInitializer init) { return new CloakCrateAction(init.self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CloakCrateAction : CrateAction
|
public class CloakCrateAction : CrateAction
|
||||||
{
|
{
|
||||||
CloakCrateActionInfo Info;
|
|
||||||
public CloakCrateAction(Actor self, CloakCrateActionInfo info)
|
public CloakCrateAction(Actor self, CloakCrateActionInfo info)
|
||||||
: base(self, info) { Info = info; }
|
: base(self, info) { }
|
||||||
|
|
||||||
public override int GetSelectionShares(Actor collector)
|
public override int GetSelectionShares(Actor collector)
|
||||||
{
|
{
|
||||||
return collector.HasTrait<AcceptsCloakCrate>() && !collector.HasTrait<Cloak>()
|
var cloak = collector.TraitOrDefault<Cloak>();
|
||||||
? base.GetSelectionShares(collector) : 0;
|
if (cloak == null || !cloak.AcceptsCloakCrate)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return base.GetSelectionShares(collector);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Activate(Actor collector)
|
public override void Activate(Actor collector)
|
||||||
{
|
{
|
||||||
var cloakInfo = new CloakInfo()
|
collector.Trait<Cloak>().ReceivedCloakCrate(collector);
|
||||||
{
|
|
||||||
InitialDelay = Info.InitialDelay,
|
|
||||||
CloakDelay = Info.CloakDelay,
|
|
||||||
CloakSound = Info.CloakSound,
|
|
||||||
UncloakSound = Info.UncloakSound
|
|
||||||
};
|
|
||||||
var cloak = new Cloak(collector, cloakInfo);
|
|
||||||
|
|
||||||
collector.World.AddFrameEndTask(w =>
|
|
||||||
{
|
|
||||||
w.Remove(collector);
|
|
||||||
|
|
||||||
collector.AddTrait(cloak);
|
|
||||||
var t = collector.TraitOrDefault<TargetableUnit>();
|
|
||||||
if (t != null) t.ReceivedCloak(collector);
|
|
||||||
|
|
||||||
w.Add(collector);
|
|
||||||
});
|
|
||||||
|
|
||||||
base.Activate(collector);
|
base.Activate(collector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AcceptsCloakCrateInfo : TraitInfo<AcceptsCloakCrate> {}
|
|
||||||
public class AcceptsCloakCrate {}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
Lazy<HiddenUnderFog> huf;
|
Lazy<HiddenUnderFog> huf;
|
||||||
Lazy<FrozenUnderFog> fuf;
|
Lazy<FrozenUnderFog> fuf;
|
||||||
Lazy<Spy> spy;
|
Lazy<Spy> spy;
|
||||||
|
Lazy<Cloak> cloak;
|
||||||
Cache<Player, GpsWatcher> watcher;
|
Cache<Player, GpsWatcher> watcher;
|
||||||
Cache<Player, FrozenActorLayer> frozen;
|
Cache<Player, FrozenActorLayer> frozen;
|
||||||
|
|
||||||
@@ -53,15 +54,15 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
huf = Lazy.New(() => self.TraitOrDefault<HiddenUnderFog>());
|
huf = Lazy.New(() => self.TraitOrDefault<HiddenUnderFog>());
|
||||||
fuf = Lazy.New(() => self.TraitOrDefault<FrozenUnderFog>());
|
fuf = Lazy.New(() => self.TraitOrDefault<FrozenUnderFog>());
|
||||||
spy = Lazy.New(() => self.TraitOrDefault<Spy>());
|
spy = Lazy.New(() => self.TraitOrDefault<Spy>());
|
||||||
|
cloak = Lazy.New(() => self.TraitOrDefault<Cloak>());
|
||||||
|
|
||||||
watcher = new Cache<Player, GpsWatcher>(p => p.PlayerActor.Trait<GpsWatcher>());
|
watcher = new Cache<Player, GpsWatcher>(p => p.PlayerActor.Trait<GpsWatcher>());
|
||||||
frozen = new Cache<Player, FrozenActorLayer>(p => p.PlayerActor.Trait<FrozenActorLayer>());
|
frozen = new Cache<Player, FrozenActorLayer>(p => p.PlayerActor.Trait<FrozenActorLayer>());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShouldShowIndicator()
|
bool ShouldShowIndicator()
|
||||||
{
|
{
|
||||||
// Can be granted at runtime via a crate, so can't cache
|
if (cloak.Value != null && cloak.Value.Cloaked)
|
||||||
var cloak = self.TraitOrDefault<Cloak>();
|
|
||||||
if (cloak != null && cloak.Cloaked)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (spy.Value != null && spy.Value.Disguised)
|
if (spy.Value != null && spy.Value.Disguised)
|
||||||
|
|||||||
@@ -30,12 +30,6 @@ namespace OpenRA.Mods.RA
|
|||||||
public TargetableUnit(Actor self, TargetableUnitInfo info)
|
public TargetableUnit(Actor self, TargetableUnitInfo info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
ReceivedCloak(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Arbitrary units can receive cloak via a crate during gameplay
|
|
||||||
public void ReceivedCloak(Actor self)
|
|
||||||
{
|
|
||||||
cloak = self.TraitOrDefault<Cloak>();
|
cloak = self.TraitOrDefault<Cloak>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,13 +28,18 @@
|
|||||||
DrawLineToTarget:
|
DrawLineToTarget:
|
||||||
ActorLostNotification:
|
ActorLostNotification:
|
||||||
AttackMove:
|
AttackMove:
|
||||||
AcceptsCloakCrate:
|
|
||||||
WithSmoke:
|
WithSmoke:
|
||||||
DebugMuzzlePositions:
|
DebugMuzzlePositions:
|
||||||
Guard:
|
Guard:
|
||||||
Guardable:
|
Guardable:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
|
Cloak:
|
||||||
|
RequiresCrate: true
|
||||||
|
InitialDelay: 15
|
||||||
|
CloakDelay: 90
|
||||||
|
CloakSound: trans1.aud
|
||||||
|
UncloakSound: trans1.aud
|
||||||
|
|
||||||
^Tank:
|
^Tank:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
@@ -66,7 +71,6 @@
|
|||||||
DrawLineToTarget:
|
DrawLineToTarget:
|
||||||
ActorLostNotification:
|
ActorLostNotification:
|
||||||
AttackMove:
|
AttackMove:
|
||||||
AcceptsCloakCrate:
|
|
||||||
WithSmoke:
|
WithSmoke:
|
||||||
Explodes:
|
Explodes:
|
||||||
Weapon: UnitExplodeSmall
|
Weapon: UnitExplodeSmall
|
||||||
@@ -76,6 +80,12 @@
|
|||||||
Guardable:
|
Guardable:
|
||||||
BodyOrientation:
|
BodyOrientation:
|
||||||
UpdatesPlayerStatistics:
|
UpdatesPlayerStatistics:
|
||||||
|
Cloak:
|
||||||
|
RequiresCrate: true
|
||||||
|
InitialDelay: 15
|
||||||
|
CloakDelay: 90
|
||||||
|
CloakSound: trans1.aud
|
||||||
|
UncloakSound: trans1.aud
|
||||||
|
|
||||||
^Helicopter:
|
^Helicopter:
|
||||||
AppearsOnRadar:
|
AppearsOnRadar:
|
||||||
|
|||||||
@@ -393,10 +393,6 @@ CRATE:
|
|||||||
SelectionShares: 5
|
SelectionShares: 5
|
||||||
CloakCrateAction:
|
CloakCrateAction:
|
||||||
SelectionShares: 5
|
SelectionShares: 5
|
||||||
InitialDelay: 15
|
|
||||||
CloakDelay: 90
|
|
||||||
CloakSound: trans1.aud
|
|
||||||
UncloakSound: trans1.aud
|
|
||||||
Effect: cloak
|
Effect: cloak
|
||||||
GiveMcvCrateAction:
|
GiveMcvCrateAction:
|
||||||
SelectionShares: 0
|
SelectionShares: 0
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ MCV:
|
|||||||
LeavesHusk:
|
LeavesHusk:
|
||||||
HuskActor: MCV.Husk
|
HuskActor: MCV.Husk
|
||||||
-GainsExperience:
|
-GainsExperience:
|
||||||
-AcceptsCloakCrate:
|
-Cloak:
|
||||||
Explodes:
|
Explodes:
|
||||||
Weapon: UnitExplodeSmall
|
Weapon: UnitExplodeSmall
|
||||||
EmptyWeapon: UnitExplodeSmall
|
EmptyWeapon: UnitExplodeSmall
|
||||||
@@ -519,6 +519,7 @@ STNK:
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 7
|
Range: 7
|
||||||
Cloak:
|
Cloak:
|
||||||
|
RequiresCrate: false
|
||||||
InitialDelay: 90
|
InitialDelay: 90
|
||||||
CloakDelay: 90
|
CloakDelay: 90
|
||||||
CloakSound: trans1.aud
|
CloakSound: trans1.aud
|
||||||
|
|||||||
@@ -554,13 +554,6 @@ CRATE:
|
|||||||
SelectionShares: 0
|
SelectionShares: 0
|
||||||
NoBaseSelectionShares: 9001
|
NoBaseSelectionShares: 9001
|
||||||
Unit: mcvo
|
Unit: mcvo
|
||||||
CloakCrateAction:
|
|
||||||
SelectionShares: 15
|
|
||||||
InitialDelay: 15
|
|
||||||
CloakDelay: 90
|
|
||||||
CloakSound: STEALTH1.WAV
|
|
||||||
UncloakSound: STEALTH2.WAV
|
|
||||||
Effect: cloak
|
|
||||||
RenderSimple:
|
RenderSimple:
|
||||||
ProximityCaptor:
|
ProximityCaptor:
|
||||||
Types:Crate
|
Types:Crate
|
||||||
|
|||||||
Reference in New Issue
Block a user