Rebased. (+1 squashed commits)

Squashed commits:

[43010a0] Fixes. (+1 squashed commits)

Squashed commits:

[94ee90e] Fixes. (+1 squashed commits)

Squashed commits:

[ef827c7] Style cop updates. Updates to LevelUp, Cloak, and UnitUpgrade to allow multiple units within range, plus maximum extra unit limit. (+1 squashed commits)

Squashed commits:

[2103b01] Dupe crate action updates and fixes. (+2 squashed commit)

Squashed commit:

[0f4df4a] Added DuplicateUnitCrateAction.

[2787fa1] Clarity update. (+1 squashed commits)

Squashed commits:

[93ddc3b] Crate updates.
+Multiple units per crate allowed.
+Allow time delay on crate actions.
This commit is contained in:
UberWaffe
2014-07-10 20:55:02 +02:00
parent 582c1016e9
commit 94b1f53ebf
16 changed files with 374 additions and 63 deletions

View File

@@ -8,17 +8,31 @@
*/
#endregion
using System.Linq;
namespace OpenRA.Mods.RA.Crates
{
[Desc("Grants the collector the ability to cloak.")]
public class CloakCrateActionInfo : CrateActionInfo
{
[Desc("The range to search for extra collectors in.", "Extra collectors will also be granted the crate action.")]
public readonly WRange Range = new WRange(3);
[Desc("The maximum number of extra collectors to grant the crate action to.")]
public readonly int MaxExtraCollectors = 4;
public override object Create(ActorInitializer init) { return new CloakCrateAction(init.self, this); }
}
public class CloakCrateAction : CrateAction
{
CloakCrateActionInfo Info;
public CloakCrateAction(Actor self, CloakCrateActionInfo info)
: base(self, info) { }
: base(self, info)
{
Info = info;
}
public override int GetSelectionShares(Actor collector)
{
@@ -32,6 +46,25 @@ namespace OpenRA.Mods.RA.Crates
public override void Activate(Actor collector)
{
collector.Trait<Cloak>().ReceivedCloakCrate(collector);
var inRange = self.World.FindActorsInCircle(self.CenterPosition, Info.Range);
inRange = inRange.Where(a =>
(a.Owner == collector.Owner) &&
(a != collector) &&
(a.TraitOrDefault<Cloak>() != null) &&
(a.TraitOrDefault<Cloak>().AcceptsCloakCrate));
if (inRange.Any())
{
if (Info.MaxExtraCollectors > -1)
inRange = inRange.Take(Info.MaxExtraCollectors);
if (inRange.Any())
foreach (Actor actor in inRange)
{
actor.Trait<Cloak>().ReceivedCloakCrate(actor);
}
}
base.Activate(collector);
}
}