#2354 fixed - multiple collection of crates

This commit is contained in:
Chris Forbes
2012-08-09 10:25:45 +12:00
parent 063191b09e
commit 82eddfdf98

View File

@@ -30,6 +30,7 @@ namespace OpenRA.Mods.RA
[Sync] int ticks;
[Sync] public CPos Location;
CrateInfo Info;
bool collected;
public Crate(ActorInitializer init, CrateInfo info)
{
@@ -46,12 +47,16 @@ namespace OpenRA.Mods.RA
public void OnCrush(Actor crusher)
{
if (collected) return;
var shares = self.TraitsImplementing<CrateAction>().Select(
a => Pair.New(a, a.GetSelectionSharesOuter(crusher)));
var totalShares = shares.Sum(a => a.Second);
var n = self.World.SharedRandom.Next(totalShares);
self.Destroy();
collected = true;
foreach (var s in shares)
if (n < s.Second)
{