fixed #2198 - crates are collected when landing on top of a unit
This commit is contained in:
@@ -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 )
|
||||||
|
|||||||
@@ -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();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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(); }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user