forked from OpenRA/OpenRA
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds TRUK to both sides - donates cash to others
- Loading branch information
1 parent
b4fe481
commit 88d63d0
Showing
8 changed files
with
171 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ The OpenRA developers are: | |
* Joakim Lindberg | ||
* Andrew Riedi | ||
* Tim Mylemans | ||
* Curtis Shmyr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#region Copyright & License Information | ||
/* | ||
* Copyright 2007-2011 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 COPYING. | ||
*/ | ||
#endregion | ||
|
||
using OpenRA.Traits; | ||
|
||
namespace OpenRA.Mods.RA | ||
{ | ||
class AcceptsSuppliesInfo : TraitInfo<AcceptsSupplies> {} | ||
|
||
class AcceptsSupplies {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#region Copyright & License Information | ||
/* | ||
* Copyright 2007-2011 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 COPYING. | ||
*/ | ||
#endregion | ||
|
||
using System.Linq; | ||
using OpenRA.Traits; | ||
using OpenRA.Traits.Activities; | ||
using OpenRA.Mods.RA.Effects; | ||
|
||
namespace OpenRA.Mods.RA.Activities | ||
{ | ||
class DonateSupplies : CancelableActivity | ||
{ | ||
Actor target; | ||
int payload; | ||
|
||
public DonateSupplies(Actor target, int payload) | ||
{ | ||
this.target = target; | ||
this.payload = payload; | ||
} | ||
|
||
public override IActivity Tick(Actor self) | ||
{ | ||
if (IsCanceled) return NextActivity; | ||
if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity; | ||
if (!target.Trait<IOccupySpace>().OccupiedCells().Any(x => x.First == self.Location)) | ||
return NextActivity; | ||
|
||
target.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(payload); | ||
self.Destroy(); | ||
self.World.AddFrameEndTask(w => w.Add(new CashTick(payload, 30, 2, target.CenterLocation, target.Owner.ColorRamp.GetColor(0)))); | ||
|
||
return this; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#region Copyright & License Information | ||
/* | ||
* Copyright 2007-2011 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 COPYING. | ||
*/ | ||
#endregion | ||
|
||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using OpenRA.Mods.RA.Activities; | ||
using OpenRA.Mods.RA.Buildings; | ||
using OpenRA.Mods.RA.Orders; | ||
using OpenRA.Traits; | ||
|
||
namespace OpenRA.Mods.RA | ||
{ | ||
class SupplyTruckInfo : ITraitInfo | ||
{ | ||
public readonly int Payload = 500; | ||
public object Create(ActorInitializer init) { return new SupplyTruck(this); } | ||
} | ||
|
||
class SupplyTruck : IIssueOrder, IResolveOrder, IOrderVoice | ||
{ | ||
int payload; | ||
SupplyTruckInfo Info; | ||
public SupplyTruck(SupplyTruckInfo info) | ||
{ | ||
payload = info.Payload; | ||
Info = info; | ||
} | ||
|
||
public IEnumerable<IOrderTargeter> Orders | ||
{ | ||
get { yield return new SupplyTruckOrderTargeter(); } | ||
} | ||
|
||
public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) | ||
{ | ||
if (order.OrderID == "SupplyTruck") | ||
return new Order(order.OrderID, self, queued) { TargetActor = target.Actor }; | ||
|
||
return null; | ||
} | ||
|
||
public string VoicePhraseForOrder(Actor self, Order order) | ||
{ | ||
return "Move"; | ||
} | ||
|
||
public void ResolveOrder(Actor self, Order order) | ||
{ | ||
if (order.OrderString == "SupplyTruck") | ||
{ | ||
self.SetTargetLine(Target.FromOrder(order), Color.Yellow); | ||
self.CancelActivity(); | ||
self.QueueActivity(new Enter(order.TargetActor)); | ||
self.QueueActivity(new DonateSupplies(order.TargetActor, payload)); | ||
} | ||
} | ||
|
||
class SupplyTruckOrderTargeter : UnitTraitOrderTargeter<Building> | ||
{ | ||
public SupplyTruckOrderTargeter() | ||
: base("SupplyTruck", 5, "enter", false, true) | ||
{ | ||
} | ||
|
||
public override bool CanTargetActor(Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) | ||
{ | ||
if (!base.CanTargetActor(self, target, forceAttack, forceMove, forceQueued, ref cursor)) return false; | ||
if (target.AppearsHostileTo(self)) return false; | ||
if (!target.HasTrait<AcceptsSupplies>()) return false; | ||
|
||
IsQueued = forceQueued; | ||
return true; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters