add mechanism to exclude particular actor types from picking up any crate

This commit is contained in:
Chris Forbes
2010-10-06 18:13:29 +13:00
parent 915e123956
commit 10de282daa
2 changed files with 11 additions and 1 deletions

View File

@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA
public void OnCrush(Actor crusher) public void OnCrush(Actor crusher)
{ {
var shares = self.TraitsImplementing<CrateAction>().Select( var shares = self.TraitsImplementing<CrateAction>().Select(
a => Pair.New(a, a.GetSelectionShares(crusher))); a => Pair.New(a, a.GetSelectionSharesOuter(crusher)));
var totalShares = shares.Sum(a => a.Second); var totalShares = shares.Sum(a => a.Second);
var n = self.World.SharedRandom.Next(totalShares); var n = self.World.SharedRandom.Next(totalShares);

View File

@@ -8,6 +8,7 @@
*/ */
#endregion #endregion
using System.Linq;
using OpenRA.Mods.RA.Effects; using OpenRA.Mods.RA.Effects;
using OpenRA.Traits; using OpenRA.Traits;
@@ -18,6 +19,7 @@ namespace OpenRA.Mods.RA
public int SelectionShares = 10; public int SelectionShares = 10;
public string Effect = null; public string Effect = null;
public string Notification = null; public string Notification = null;
public string[] ExcludedActorTypes = { };
public virtual object Create(ActorInitializer init) { return new CrateAction(init.self, this); } public virtual object Create(ActorInitializer init) { return new CrateAction(init.self, this); }
} }
@@ -32,6 +34,14 @@ namespace OpenRA.Mods.RA
this.self = self; this.self = self;
this.info = info; this.info = info;
} }
public int GetSelectionSharesOuter(Actor collector)
{
if (info.ExcludedActorTypes.Contains(collector.Info.Name))
return 0;
return GetSelectionShares(collector);
}
public virtual int GetSelectionShares(Actor collector) public virtual int GetSelectionShares(Actor collector)
{ {