Make DonateSupplies grant player experience
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using OpenRA.Mods.Common.Effects;
|
using OpenRA.Mods.Common.Effects;
|
||||||
|
using OpenRA.Mods.Common.Traits;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Activities
|
namespace OpenRA.Mods.Common.Activities
|
||||||
@@ -18,12 +19,14 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
readonly Actor target;
|
readonly Actor target;
|
||||||
readonly int payload;
|
readonly int payload;
|
||||||
|
readonly int experience;
|
||||||
|
|
||||||
public DonateSupplies(Actor self, Actor target, int payload)
|
public DonateSupplies(Actor self, Actor target, int payload, int playerExperience)
|
||||||
: base(self, target, EnterBehaviour.Dispose)
|
: base(self, target, EnterBehaviour.Dispose)
|
||||||
{
|
{
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.payload = payload;
|
this.payload = payload;
|
||||||
|
this.experience = playerExperience;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnInside(Actor self)
|
protected override void OnInside(Actor self)
|
||||||
@@ -33,6 +36,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
target.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(payload);
|
target.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(payload);
|
||||||
|
|
||||||
|
var exp = self.Owner.PlayerActor.TraitOrDefault<PlayerExperience>();
|
||||||
|
if (exp != null && target.Owner != self.Owner)
|
||||||
|
exp.GiveExperience(experience);
|
||||||
|
|
||||||
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
||||||
self.World.AddFrameEndTask(w => w.Add(new FloatingText(target.CenterPosition, target.Owner.Color.RGB, FloatingText.FormatCashTick(payload), 30)));
|
self.World.AddFrameEndTask(w => w.Add(new FloatingText(target.CenterPosition, target.Owner.Color.RGB, FloatingText.FormatCashTick(payload), 30)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("The amount of cash the owner receives.")]
|
[Desc("The amount of cash the owner receives.")]
|
||||||
public readonly int Payload = 500;
|
public readonly int Payload = 500;
|
||||||
|
|
||||||
|
[Desc("The amount of experience the donating player receives.")]
|
||||||
|
public readonly int PlayerExperience = 0;
|
||||||
|
|
||||||
[VoiceReference] public readonly string Voice = "Action";
|
[VoiceReference] public readonly string Voice = "Action";
|
||||||
|
|
||||||
public object Create(ActorInitializer init) { return new SupplyTruck(this); }
|
public object Create(ActorInitializer init) { return new SupplyTruck(this); }
|
||||||
@@ -71,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
|
|
||||||
self.SetTargetLine(target, Color.Yellow);
|
self.SetTargetLine(target, Color.Yellow);
|
||||||
self.QueueActivity(new DonateSupplies(self, target.Actor, info.Payload));
|
self.QueueActivity(new DonateSupplies(self, target.Actor, info.Payload, info.PlayerExperience));
|
||||||
}
|
}
|
||||||
|
|
||||||
class SupplyTruckOrderTargeter : UnitOrderTargeter
|
class SupplyTruckOrderTargeter : UnitOrderTargeter
|
||||||
|
|||||||
Reference in New Issue
Block a user