Merge pull request #2911 from chrisforbes/mcv-crate-bugfix
fix MCV crate not being given if normal SelectionShares was zero
This commit is contained in:
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Crates
|
|||||||
|
|
||||||
public override int GetSelectionShares(Actor collector)
|
public override int GetSelectionShares(Actor collector)
|
||||||
{
|
{
|
||||||
if (base.GetSelectionShares(collector) == 0)
|
if (!CanGiveTo(collector))
|
||||||
return 0; // there's some other really good reason why we shouldn't give this.
|
return 0; // there's some other really good reason why we shouldn't give this.
|
||||||
|
|
||||||
var hasBase = self.World.ActorsWithTrait<BaseBuilding>()
|
var hasBase = self.World.ActorsWithTrait<BaseBuilding>()
|
||||||
|
|||||||
@@ -32,17 +32,23 @@ namespace OpenRA.Mods.RA.Crates
|
|||||||
public GiveUnitCrateAction(Actor self, GiveUnitCrateActionInfo info)
|
public GiveUnitCrateAction(Actor self, GiveUnitCrateActionInfo info)
|
||||||
: base(self, info) { Info = info; }
|
: base(self, info) { Info = info; }
|
||||||
|
|
||||||
public override int GetSelectionShares(Actor collector)
|
public bool CanGiveTo(Actor collector)
|
||||||
{
|
{
|
||||||
var bi = Rules.Info[Info.Unit].Traits.GetOrDefault<BuildableInfo>();
|
var bi = Rules.Info[Info.Unit].Traits.GetOrDefault<BuildableInfo>();
|
||||||
|
|
||||||
// this unit is not buildable by the collector's country, so
|
// this unit is not buildable by the collector's country, so
|
||||||
// don't give them free ones either.
|
// don't give them free ones either.
|
||||||
if (Info.Owner == null && bi != null && !bi.Owner.Contains(collector.Owner.Country.Race)) return 0;
|
if (Info.Owner == null && bi != null && !bi.Owner.Contains(collector.Owner.Country.Race)) return false;
|
||||||
|
|
||||||
// avoid dumping tanks in the sea, and ships on dry land.
|
// avoid dumping tanks in the sea, and ships on dry land.
|
||||||
if (!GetSuitableCells(collector.Location).Any()) return 0;
|
if (!GetSuitableCells(collector.Location).Any()) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetSelectionShares(Actor collector)
|
||||||
|
{
|
||||||
|
if (!CanGiveTo(collector)) return 0;
|
||||||
return base.GetSelectionShares(collector);
|
return base.GetSelectionShares(collector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user