Remove thief; transfer ore along with stolen silo/proc.

This commit is contained in:
Paul Chote
2010-06-14 20:58:40 +12:00
parent 283512f314
commit 24edba34a7
7 changed files with 28 additions and 116 deletions

View File

@@ -1,4 +1,4 @@
#region Copyright & License Information
#region Copyright & License Information
/*
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
* This file is part of OpenRA.
@@ -49,6 +49,9 @@ namespace OpenRA.Mods.RA.Activities
w.Remove(target);
target.Owner = self.Owner;
w.Add(target);
foreach (var t in target.traits.WithInterface<INotifyCapture>())
t.OnCapture(target, self);
});
target.InflictDamage(self, target.Health - EngineerCapture.EngineerDamage, null);

View File

@@ -1,49 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
* This file is part of OpenRA.
*
* OpenRA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenRA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
*/
#endregion
using OpenRA.Traits;
using OpenRA.Traits.Activities;
namespace OpenRA.Mods.RA.Activities
{
class Steal : IActivity
{
Actor target;
public Steal(Actor target) { this.target = target; }
public IActivity NextActivity { get; set; }
public IActivity Tick(Actor self)
{
if (target == null || target.IsDead) return NextActivity;
if (target.Owner == self.Owner) return NextActivity;
foreach (var t in target.traits.WithInterface<IAcceptThief>())
t.OnSteal(target, self);
self.World.AddFrameEndTask(w => w.Remove(self));
return NextActivity;
}
public void Cancel(Actor self) { target = null; NextActivity = null; }
}
}

View File

@@ -66,7 +66,6 @@
<Compile Include="Activities\Rearm.cs" />
<Compile Include="Activities\Repair.cs" />
<Compile Include="Activities\ReturnToBase.cs" />
<Compile Include="Activities\Steal.cs" />
<Compile Include="Activities\Teleport.cs" />
<Compile Include="Activities\UnloadCargo.cs" />
<Compile Include="Activities\Wait.cs" />
@@ -168,7 +167,6 @@
<Compile Include="NukePower.cs" />
<Compile Include="TakeCover.cs" />
<Compile Include="TeslaInstantKills.cs" />
<Compile Include="Thief.cs" />
<Compile Include="Crates\ResetRadarCrateAction.cs" />
<Compile Include="ThrowsParticles.cs" />
<Compile Include="TraitsInterfaces.cs" />

View File

@@ -1,51 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
* This file is part of OpenRA.
*
* OpenRA is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenRA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
*/
#endregion
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits;
using OpenRA.Traits.Activities;
namespace OpenRA.Mods.RA
{
class ThiefInfo : TraitInfo<Thief> { }
class Thief : IIssueOrder, IResolveOrder
{
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
if (mi.Button != MouseButton.Right) return null;
if (underCursor == null) return null;
if (self.Owner.Stances[underCursor.Owner] != Stance.Enemy) return null;
if (!underCursor.traits.Contains<IAcceptThief>()) return null;
return new Order("Steal", self, underCursor);
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Steal")
{
self.CancelActivity();
self.QueueActivity(new Move(order.TargetActor, 1));
self.QueueActivity(new Steal(order.TargetActor));
}
}
}
}