fixed #2198 - crates are collected when landing on top of a unit

This commit is contained in:
Chris Forbes
2012-07-01 09:04:49 +12:00
parent b9365a149f
commit 9201b1cced
3 changed files with 15 additions and 1 deletions

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
} }
// ITeleportable is required for paradrop // ITeleportable is required for paradrop
class Crate : ITick, IOccupySpace, ITeleportable, ICrushable, ISync class Crate : ITick, IOccupySpace, ITeleportable, ICrushable, ISync, INotifyParachuteLanded
{ {
readonly Actor self; readonly Actor self;
[Sync] int ticks; [Sync] int ticks;
@@ -62,6 +62,15 @@ namespace OpenRA.Mods.RA
n -= s.Second; n -= s.Second;
} }
public void OnLanded()
{
var landedOn = self.World.ActorMap.GetUnitsAt(self.Location)
.FirstOrDefault(a => a != self);
if (landedOn != null)
OnCrush(landedOn);
}
public void Tick(Actor self) public void Tick(Actor self)
{ {
if( ++ticks >= Info.Lifetime * 25 ) if( ++ticks >= Info.Lifetime * 25 )

View File

@@ -67,6 +67,9 @@ namespace OpenRA.Mods.RA.Effects
cargo.CancelActivity(); cargo.CancelActivity();
cargo.Trait<ITeleportable>().SetPosition(cargo, loc); cargo.Trait<ITeleportable>().SetPosition(cargo, loc);
w.Add(cargo); w.Add(cargo);
foreach( var npl in cargo.TraitsImplementing<INotifyParachuteLanded>() )
npl.OnLanded();
}); });
} }

View File

@@ -42,4 +42,6 @@ namespace OpenRA.Mods.RA
{ {
void OnNotifyResourceClaimLost(Actor self, ResourceClaim claim, Actor claimer); void OnNotifyResourceClaimLost(Actor self, ResourceClaim claim, Actor claimer);
} }
public interface INotifyParachuteLanded { void OnLanded(); }
} }