From ad1af792e6cb167c224d6df0d0c54d8d75c2354d Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 15 Oct 2010 17:56:28 +1300 Subject: [PATCH] add CashTrickler trait, to support oil derricks, etc --- OpenRA.Mods.RA/CashTrickler.cs | 36 ++++++++++++++++++++++++++++ OpenRA.Mods.RA/OpenRA.Mods.RA.csproj | 6 ++--- 2 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 OpenRA.Mods.RA/CashTrickler.cs diff --git a/OpenRA.Mods.RA/CashTrickler.cs b/OpenRA.Mods.RA/CashTrickler.cs new file mode 100644 index 0000000000..f5192426c7 --- /dev/null +++ b/OpenRA.Mods.RA/CashTrickler.cs @@ -0,0 +1,36 @@ +#region Copyright & License Information +/* + * Copyright 2007-2010 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see LICENSE. + */ +#endregion + +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + class CashTricklerInfo : TraitInfo + { + public readonly int Period = 10; + public readonly int Amount = 3; + } + + class CashTrickler : ITick + { + [Sync] + int ticks; + + public void Tick(Actor self) + { + if (--ticks < 0) + { + var info = self.Info.Traits.Get(); + self.Owner.PlayerActor.Trait().GiveCash(info.Amount); + ticks = info.Period; + } + } + } +} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index ea6f8ec205..64bb95340e 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -1,4 +1,4 @@ - + Debug @@ -93,6 +93,7 @@ + @@ -290,7 +291,4 @@ copy "$(TargetPath)" "$(SolutionDir)mods/ra/" cd "$(SolutionDir)" - - - \ No newline at end of file