Add Type Support for InfiltrateFor* traits

This commit is contained in:
Mustafa Alperen Seki
2017-11-07 10:32:11 +03:00
committed by Paul Chote
parent f7de5d46be
commit fc07391c8c
10 changed files with 65 additions and 11 deletions

View File

@@ -20,18 +20,27 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Reveals a decoration sprite to the indicated players when infiltrated.")]
class InfiltrateForDecorationInfo : WithDecorationInfo
{
public readonly HashSet<string> Types = new HashSet<string>();
public override object Create(ActorInitializer init) { return new InfiltrateForDecoration(init.Self, this); }
}
class InfiltrateForDecoration : WithDecoration, INotifyInfiltrated
{
readonly HashSet<Player> infiltrators = new HashSet<Player>();
readonly InfiltrateForDecorationInfo info;
public InfiltrateForDecoration(Actor self, InfiltrateForDecorationInfo info)
: base(self, info) { }
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator)
: base(self, info)
{
this.info = info;
}
void INotifyInfiltrated.Infiltrated(Actor self, Actor infiltrator, HashSet<string> types)
{
if (!info.Types.Overlaps(types))
return;
infiltrators.Add(infiltrator.Owner);
}