Add Type Support for InfiltrateFor* traits
This commit is contained in:
committed by
Paul Chote
parent
f7de5d46be
commit
fc07391c8c
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Cnc.Activities
|
|||||||
ini.Infiltrating(self);
|
ini.Infiltrating(self);
|
||||||
|
|
||||||
foreach (var t in target.TraitsImplementing<INotifyInfiltrated>())
|
foreach (var t in target.TraitsImplementing<INotifyInfiltrated>())
|
||||||
t.Infiltrated(target, self);
|
t.Infiltrated(target, self, infiltrates.Info.Types);
|
||||||
|
|
||||||
var exp = self.Owner.PlayerActor.TraitOrDefault<PlayerExperience>();
|
var exp = self.Owner.PlayerActor.TraitOrDefault<PlayerExperience>();
|
||||||
if (exp != null)
|
if (exp != null)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using OpenRA.Mods.Common.Effects;
|
using OpenRA.Mods.Common.Effects;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -19,6 +20,8 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
[Desc("This structure can be infiltrated causing funds to be stolen.")]
|
[Desc("This structure can be infiltrated causing funds to be stolen.")]
|
||||||
class InfiltrateForCashInfo : ITraitInfo
|
class InfiltrateForCashInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
|
public readonly HashSet<string> Types = new HashSet<string>();
|
||||||
|
|
||||||
[Desc("Percentage of the victim's resources that will be stolen.")]
|
[Desc("Percentage of the victim's resources that will be stolen.")]
|
||||||
public readonly int Percentage = 100;
|
public readonly int Percentage = 100;
|
||||||
|
|
||||||
@@ -44,8 +47,11 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
public InfiltrateForCash(InfiltrateForCashInfo info) { this.info = info; }
|
public InfiltrateForCash(InfiltrateForCashInfo info) { this.info = info; }
|
||||||
|
|
||||||
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator)
|
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, HashSet<string> types)
|
||||||
{
|
{
|
||||||
|
if (!info.Types.Overlaps(types))
|
||||||
|
return;
|
||||||
|
|
||||||
var targetResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
var targetResources = self.Owner.PlayerActor.Trait<PlayerResources>();
|
||||||
var spyResources = infiltrator.Owner.PlayerActor.Trait<PlayerResources>();
|
var spyResources = infiltrator.Owner.PlayerActor.Trait<PlayerResources>();
|
||||||
var spyValue = infiltrator.Info.TraitInfoOrDefault<ValuedInfo>();
|
var spyValue = infiltrator.Info.TraitInfoOrDefault<ValuedInfo>();
|
||||||
|
|||||||
@@ -20,18 +20,27 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
[Desc("Reveals a decoration sprite to the indicated players when infiltrated.")]
|
[Desc("Reveals a decoration sprite to the indicated players when infiltrated.")]
|
||||||
class InfiltrateForDecorationInfo : WithDecorationInfo
|
class InfiltrateForDecorationInfo : WithDecorationInfo
|
||||||
{
|
{
|
||||||
|
public readonly HashSet<string> Types = new HashSet<string>();
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new InfiltrateForDecoration(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new InfiltrateForDecoration(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
class InfiltrateForDecoration : WithDecoration, INotifyInfiltrated
|
class InfiltrateForDecoration : WithDecoration, INotifyInfiltrated
|
||||||
{
|
{
|
||||||
readonly HashSet<Player> infiltrators = new HashSet<Player>();
|
readonly HashSet<Player> infiltrators = new HashSet<Player>();
|
||||||
|
readonly InfiltrateForDecorationInfo info;
|
||||||
|
|
||||||
public InfiltrateForDecoration(Actor self, InfiltrateForDecorationInfo info)
|
public InfiltrateForDecoration(Actor self, InfiltrateForDecorationInfo info)
|
||||||
: base(self, info) { }
|
: base(self, info)
|
||||||
|
|
||||||
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator)
|
|
||||||
{
|
{
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, HashSet<string> types)
|
||||||
|
{
|
||||||
|
if (!info.Types.Overlaps(types))
|
||||||
|
return;
|
||||||
|
|
||||||
infiltrators.Add(infiltrator.Owner);
|
infiltrators.Add(infiltrator.Owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -16,12 +17,27 @@ using OpenRA.Traits;
|
|||||||
namespace OpenRA.Mods.Cnc.Traits
|
namespace OpenRA.Mods.Cnc.Traits
|
||||||
{
|
{
|
||||||
[Desc("Steal and reset the owner's exploration.")]
|
[Desc("Steal and reset the owner's exploration.")]
|
||||||
class InfiltrateForExplorationInfo : TraitInfo<InfiltrateForExploration> { }
|
class InfiltrateForExplorationInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public readonly HashSet<string> Types = new HashSet<string>();
|
||||||
|
|
||||||
|
public object Create(ActorInitializer init) { return new InfiltrateForExploration(init.Self, this); }
|
||||||
|
}
|
||||||
|
|
||||||
class InfiltrateForExploration : INotifyInfiltrated
|
class InfiltrateForExploration : INotifyInfiltrated
|
||||||
{
|
{
|
||||||
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator)
|
readonly InfiltrateForExplorationInfo info;
|
||||||
|
|
||||||
|
public InfiltrateForExploration(Actor self, InfiltrateForExplorationInfo info)
|
||||||
{
|
{
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
|
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, HashSet<string> types)
|
||||||
|
{
|
||||||
|
if (!info.Types.Overlaps(types))
|
||||||
|
return;
|
||||||
|
|
||||||
infiltrator.Owner.Shroud.Explore(self.Owner.Shroud);
|
infiltrator.Owner.Shroud.Explore(self.Owner.Shroud);
|
||||||
var preventReset = self.Owner.PlayerActor.TraitsImplementing<IPreventsShroudReset>()
|
var preventReset = self.Owner.PlayerActor.TraitsImplementing<IPreventsShroudReset>()
|
||||||
.Any(p => p.PreventShroudReset(self));
|
.Any(p => p.PreventShroudReset(self));
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
@@ -16,6 +17,8 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
{
|
{
|
||||||
class InfiltrateForPowerOutageInfo : ITraitInfo
|
class InfiltrateForPowerOutageInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
|
public readonly HashSet<string> Types = new HashSet<string>();
|
||||||
|
|
||||||
public readonly int Duration = 25 * 20;
|
public readonly int Duration = 25 * 20;
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new InfiltrateForPowerOutage(init.Self, this); }
|
public object Create(ActorInitializer init) { return new InfiltrateForPowerOutage(init.Self, this); }
|
||||||
@@ -32,8 +35,11 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
playerPower = self.Owner.PlayerActor.Trait<PowerManager>();
|
playerPower = self.Owner.PlayerActor.Trait<PowerManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator)
|
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, HashSet<string> types)
|
||||||
{
|
{
|
||||||
|
if (!info.Types.Overlaps(types))
|
||||||
|
return;
|
||||||
|
|
||||||
playerPower.TriggerPowerOutage(info.Duration);
|
playerPower.TriggerPowerOutage(info.Duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Primitives;
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -19,6 +20,8 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
{
|
{
|
||||||
[ActorReference, FieldLoader.Require] public readonly string Proxy = null;
|
[ActorReference, FieldLoader.Require] public readonly string Proxy = null;
|
||||||
|
|
||||||
|
public readonly HashSet<string> Types = new HashSet<string>();
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new InfiltrateForSupportPower(this); }
|
public object Create(ActorInitializer init) { return new InfiltrateForSupportPower(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,8 +34,11 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator)
|
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, HashSet<string> types)
|
||||||
{
|
{
|
||||||
|
if (!info.Types.Overlaps(types))
|
||||||
|
return;
|
||||||
|
|
||||||
infiltrator.World.AddFrameEndTask(w => w.CreateActor(info.Proxy, new TypeDictionary
|
infiltrator.World.AddFrameEndTask(w => w.CreateActor(info.Proxy, new TypeDictionary
|
||||||
{
|
{
|
||||||
new OwnerInit(infiltrator.Owner)
|
new OwnerInit(infiltrator.Owner)
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ namespace OpenRA.Mods.Common.Scripting
|
|||||||
OnCapturedInternal(self);
|
OnCapturedInternal(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator)
|
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, HashSet<string> types)
|
||||||
{
|
{
|
||||||
if (world.Disposing)
|
if (world.Disposing)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public interface ISeedableResource { void Seed(Actor self); }
|
public interface ISeedableResource { void Seed(Actor self); }
|
||||||
|
|
||||||
[RequireExplicitImplementation]
|
[RequireExplicitImplementation]
|
||||||
public interface INotifyInfiltrated { void Infiltrated(Actor self, Actor infiltrator); }
|
public interface INotifyInfiltrated { void Infiltrated(Actor self, Actor infiltrator, HashSet<string> types); }
|
||||||
|
|
||||||
[RequireExplicitImplementation]
|
[RequireExplicitImplementation]
|
||||||
public interface INotifyBlockingMove { void OnNotifyBlockingMove(Actor self, Actor blocking); }
|
public interface INotifyBlockingMove { void OnNotifyBlockingMove(Actor self, Actor blocking); }
|
||||||
|
|||||||
@@ -770,6 +770,7 @@
|
|||||||
Targetable:
|
Targetable:
|
||||||
TargetTypes: Ground, Structure, C4, DetonateAttack, SpyInfiltrate
|
TargetTypes: Ground, Structure, C4, DetonateAttack, SpyInfiltrate
|
||||||
InfiltrateForDecoration:
|
InfiltrateForDecoration:
|
||||||
|
Types: SpyInfiltrate
|
||||||
RequiresSelection: true
|
RequiresSelection: true
|
||||||
Image: pips
|
Image: pips
|
||||||
Sequence: tag-fake
|
Sequence: tag-fake
|
||||||
@@ -1120,5 +1121,6 @@
|
|||||||
AffectedByPowerOutage:
|
AffectedByPowerOutage:
|
||||||
Condition: power-outage
|
Condition: power-outage
|
||||||
InfiltrateForPowerOutage:
|
InfiltrateForPowerOutage:
|
||||||
|
Types: SpyInfiltrate
|
||||||
Power:
|
Power:
|
||||||
RequiresCondition: !disabled
|
RequiresCondition: !disabled
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ SPEN:
|
|||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
InfiltrateForSupportPower:
|
InfiltrateForSupportPower:
|
||||||
Proxy: powerproxy.sonarpulse
|
Proxy: powerproxy.sonarpulse
|
||||||
|
Types: SpyInfiltrate
|
||||||
Valued:
|
Valued:
|
||||||
Cost: 800
|
Cost: 800
|
||||||
Tooltip:
|
Tooltip:
|
||||||
@@ -241,6 +242,7 @@ SYRD:
|
|||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
InfiltrateForSupportPower:
|
InfiltrateForSupportPower:
|
||||||
Proxy: powerproxy.sonarpulse
|
Proxy: powerproxy.sonarpulse
|
||||||
|
Types: SpyInfiltrate
|
||||||
Buildable:
|
Buildable:
|
||||||
Queue: Building
|
Queue: Building
|
||||||
BuildPaletteOrder: 40
|
BuildPaletteOrder: 40
|
||||||
@@ -621,6 +623,7 @@ DOME:
|
|||||||
ProvidesRadar:
|
ProvidesRadar:
|
||||||
RequiresCondition: !jammed && !disabled
|
RequiresCondition: !jammed && !disabled
|
||||||
InfiltrateForExploration:
|
InfiltrateForExploration:
|
||||||
|
Types: SpyInfiltrate
|
||||||
DetectCloaked:
|
DetectCloaked:
|
||||||
Range: 10c0
|
Range: 10c0
|
||||||
RequiresCondition: !disabled
|
RequiresCondition: !disabled
|
||||||
@@ -1016,6 +1019,7 @@ WEAP:
|
|||||||
TargetTypes: Ground, C4, DetonateAttack, Structure, SpyInfiltrate
|
TargetTypes: Ground, C4, DetonateAttack, Structure, SpyInfiltrate
|
||||||
InfiltrateForSupportPower:
|
InfiltrateForSupportPower:
|
||||||
Proxy: vehicles.upgraded
|
Proxy: vehicles.upgraded
|
||||||
|
Types: SpyInfiltrate
|
||||||
WithDecoration@primary:
|
WithDecoration@primary:
|
||||||
RequiresSelection: true
|
RequiresSelection: true
|
||||||
Image: pips
|
Image: pips
|
||||||
@@ -1153,6 +1157,7 @@ PROC:
|
|||||||
Facing: 64
|
Facing: 64
|
||||||
InfiltrateForCash:
|
InfiltrateForCash:
|
||||||
Percentage: 50
|
Percentage: 50
|
||||||
|
Types: SpyInfiltrate
|
||||||
Notification: CreditsStolen
|
Notification: CreditsStolen
|
||||||
WithIdleOverlay@TOP:
|
WithIdleOverlay@TOP:
|
||||||
Sequence: idle-top
|
Sequence: idle-top
|
||||||
@@ -1286,6 +1291,7 @@ HPAD:
|
|||||||
TargetTypes: Ground, C4, DetonateAttack, Structure, SpyInfiltrate
|
TargetTypes: Ground, C4, DetonateAttack, Structure, SpyInfiltrate
|
||||||
InfiltrateForSupportPower:
|
InfiltrateForSupportPower:
|
||||||
Proxy: aircraft.upgraded
|
Proxy: aircraft.upgraded
|
||||||
|
Types: SpyInfiltrate
|
||||||
WithDecoration@primary:
|
WithDecoration@primary:
|
||||||
RequiresSelection: true
|
RequiresSelection: true
|
||||||
Image: pips
|
Image: pips
|
||||||
@@ -1422,6 +1428,7 @@ AFLD:
|
|||||||
TargetTypes: Ground, C4, DetonateAttack, Structure, SpyInfiltrate
|
TargetTypes: Ground, C4, DetonateAttack, Structure, SpyInfiltrate
|
||||||
InfiltrateForSupportPower:
|
InfiltrateForSupportPower:
|
||||||
Proxy: aircraft.upgraded
|
Proxy: aircraft.upgraded
|
||||||
|
Types: SpyInfiltrate
|
||||||
WithDecoration@primary:
|
WithDecoration@primary:
|
||||||
RequiresSelection: true
|
RequiresSelection: true
|
||||||
Image: pips
|
Image: pips
|
||||||
@@ -1626,6 +1633,7 @@ BARR:
|
|||||||
ProvidesPrerequisite@buildingname:
|
ProvidesPrerequisite@buildingname:
|
||||||
InfiltrateForSupportPower:
|
InfiltrateForSupportPower:
|
||||||
Proxy: barracks.upgraded
|
Proxy: barracks.upgraded
|
||||||
|
Types: SpyInfiltrate
|
||||||
Targetable:
|
Targetable:
|
||||||
TargetTypes: Ground, C4, DetonateAttack, Structure, SpyInfiltrate
|
TargetTypes: Ground, C4, DetonateAttack, Structure, SpyInfiltrate
|
||||||
WithDecoration@primary:
|
WithDecoration@primary:
|
||||||
@@ -1763,6 +1771,7 @@ TENT:
|
|||||||
ProvidesPrerequisite@buildingname:
|
ProvidesPrerequisite@buildingname:
|
||||||
InfiltrateForSupportPower:
|
InfiltrateForSupportPower:
|
||||||
Proxy: barracks.upgraded
|
Proxy: barracks.upgraded
|
||||||
|
Types: SpyInfiltrate
|
||||||
Targetable:
|
Targetable:
|
||||||
TargetTypes: Ground, C4, DetonateAttack, Structure, SpyInfiltrate
|
TargetTypes: Ground, C4, DetonateAttack, Structure, SpyInfiltrate
|
||||||
WithDecoration@primary:
|
WithDecoration@primary:
|
||||||
|
|||||||
Reference in New Issue
Block a user