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

@@ -9,6 +9,7 @@
*/
#endregion
using System.Collections.Generic;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
@@ -19,6 +20,8 @@ namespace OpenRA.Mods.Cnc.Traits
{
[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); }
}
@@ -31,8 +34,11 @@ namespace OpenRA.Mods.Cnc.Traits
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
{
new OwnerInit(infiltrator.Owner)