CashTrickler style fixes and Period -> Interval rename

This commit is contained in:
reaperrr
2016-11-06 17:42:48 +01:00
parent bc1e2a7058
commit 7dcda5db30
5 changed files with 24 additions and 12 deletions

View File

@@ -18,12 +18,17 @@ namespace OpenRA.Mods.Common.Traits
class CashTricklerInfo : ConditionalTraitInfo class CashTricklerInfo : ConditionalTraitInfo
{ {
[Desc("Number of ticks to wait between giving money.")] [Desc("Number of ticks to wait between giving money.")]
public readonly int Period = 50; public readonly int Interval = 50;
[Desc("Amount of money to give each time.")] [Desc("Amount of money to give each time.")]
public readonly int Amount = 15; public readonly int Amount = 15;
[Desc("Whether to show the cash tick indicators (+$15 rising from actor).")]
[Desc("Whether to show the cash tick indicators rising from the actor.")]
public readonly bool ShowTicks = true; public readonly bool ShowTicks = true;
[Desc("How long to show the cash tick indicator when enabled.")]
public readonly int DisplayDuration = 30;
public override object Create(ActorInitializer init) { return new CashTrickler(this); } public override object Create(ActorInitializer init) { return new CashTrickler(this); }
} }
@@ -31,29 +36,32 @@ namespace OpenRA.Mods.Common.Traits
{ {
readonly CashTricklerInfo info; readonly CashTricklerInfo info;
[Sync] int ticks; [Sync] int ticks;
public CashTrickler(CashTricklerInfo info) public CashTrickler(CashTricklerInfo info)
: base(info) : base(info)
{ {
this.info = info; this.info = info;
} }
public void Tick(Actor self) void ITick.Tick(Actor self)
{ {
if (IsTraitDisabled) if (IsTraitDisabled)
return; return;
if (--ticks < 0) if (--ticks < 0)
{ {
ticks = info.Period; ticks = info.Interval;
self.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(info.Amount); self.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(info.Amount);
MaybeAddCashTick(self, info.Amount);
if (info.ShowTicks)
AddCashTick(self, info.Amount);
} }
} }
void MaybeAddCashTick(Actor self, int amount) void AddCashTick(Actor self, int amount)
{ {
if (info.ShowTicks) self.World.AddFrameEndTask(w => w.Add(
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color.RGB, FloatingText.FormatCashTick(amount), 30))); new FloatingText(self.CenterPosition, self.Owner.Color.RGB, FloatingText.FormatCashTick(amount), info.DisplayDuration)));
} }
} }
} }

View File

@@ -740,6 +740,10 @@ namespace OpenRA.Mods.Common.UtilityCommands
node.Value.Nodes.Add(gcoc); node.Value.Nodes.Add(gcoc);
RenameNodeKey(capture, "Amount"); RenameNodeKey(capture, "Amount");
} }
var period = trickler.Value.Nodes.FirstOrDefault(n => n.Key == "Period");
if (period != null)
period.Key = "Interval";
} }
} }

View File

@@ -91,7 +91,7 @@ MNLYR:
Offset: 0,0 Offset: 0,0
Facing: 96 Facing: 96
CashTrickler: CashTrickler:
Period: 150 Interval: 150
Amount: 20 Amount: 20
RenderSprites: RenderSprites:
Image: MNLY Image: MNLY
@@ -108,7 +108,7 @@ FTUR:
MustBeDestroyed: MustBeDestroyed:
RequiredForShortGame: true RequiredForShortGame: true
CashTrickler: CashTrickler:
Period: 150 Interval: 150
Amount: 30 Amount: 30
ChronoshiftPower: ChronoshiftPower:
Icon: chrono Icon: chrono

View File

@@ -117,7 +117,7 @@ OILB:
RevealsShroud: RevealsShroud:
Range: 3c0 Range: 3c0
CashTrickler: CashTrickler:
Period: 250 Interval: 250
Amount: 50 Amount: 50
MOBILETENT: MOBILETENT:

View File

@@ -364,7 +364,7 @@ OILB:
ExternalCapturableBar: ExternalCapturableBar:
EngineerRepairable: EngineerRepairable:
CashTrickler: CashTrickler:
Period: 375 Interval: 375
Amount: 100 Amount: 100
Tooltip: Tooltip:
Name: Oil Derrick Name: Oil Derrick