diff --git a/OpenRA.Mods.Common/Traits/GivesBounty.cs b/OpenRA.Mods.Common/Traits/GivesBounty.cs index 8663860fb9..41e31962b8 100644 --- a/OpenRA.Mods.Common/Traits/GivesBounty.cs +++ b/OpenRA.Mods.Common/Traits/GivesBounty.cs @@ -38,19 +38,26 @@ namespace OpenRA.Mods.Common.Traits public object Create(ActorInitializer init) { return new GivesBounty(init.Self, this); } } - class GivesBounty : INotifyKilled + class GivesBounty : INotifyKilled, INotifyCreated { readonly GivesBountyInfo info; + GainsExperience gainsExp; + Cargo cargo; public GivesBounty(Actor self, GivesBountyInfo info) { this.info = info; } - int GetMultiplier(Actor self) + void INotifyCreated.Created(Actor self) + { + gainsExp = self.TraitOrDefault(); + cargo = self.TraitOrDefault(); + } + + // Returns 100's as 1, so as to keep accuracy for longer. + int GetMultiplier() { - // returns 100's as 1, so as to keep accuracy for longer. - var gainsExp = self.TraitOrDefault(); if (gainsExp == null) return 100; @@ -61,13 +68,12 @@ namespace OpenRA.Mods.Common.Traits int GetBountyValue(Actor self, int percentage) { // Divide by 10000 because of GetMultiplier and info.Percentage. - return self.GetSellValue() * GetMultiplier(self) * percentage / 10000; + return self.GetSellValue() * GetMultiplier() * percentage / 10000; } int GetDisplayedBountyValue(Actor self) { var bounty = GetBountyValue(self, info.Percentage); - var cargo = self.TraitOrDefault(); if (cargo == null) return bounty;