From 82eddfdf981805d2f1fb4dc16b94a08a7c3e9fde Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 9 Aug 2012 10:25:45 +1200 Subject: [PATCH] #2354 fixed - multiple collection of crates --- OpenRA.Mods.RA/Crate.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OpenRA.Mods.RA/Crate.cs b/OpenRA.Mods.RA/Crate.cs index 6ccbc9f274..d806990f59 100644 --- a/OpenRA.Mods.RA/Crate.cs +++ b/OpenRA.Mods.RA/Crate.cs @@ -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().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) {