Remove thief; transfer ore along with stolen silo/proc.
This commit is contained in:
@@ -146,6 +146,14 @@ namespace OpenRA.Traits
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool TakeOre(int num)
|
||||||
|
{
|
||||||
|
if (Ore < num) return false;
|
||||||
|
Ore -= num;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void GiveCash(int num)
|
public void GiveCash(int num)
|
||||||
{
|
{
|
||||||
Cash += num;
|
Cash += num;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Traits
|
||||||
{
|
{
|
||||||
class StoresOreInfo : TraitInfo<StoresOre>
|
class StoresOreInfo : TraitInfo<StoresOre>
|
||||||
@@ -28,17 +28,20 @@ namespace OpenRA.Traits
|
|||||||
public readonly int Capacity = 0;
|
public readonly int Capacity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
class StoresOre : IPips, IAcceptThief
|
class StoresOre : IPips, INotifyCapture
|
||||||
{
|
{
|
||||||
public void OnSteal(Actor self, Actor thief)
|
public void OnCapture(Actor self, Actor captor)
|
||||||
{
|
{
|
||||||
// Steal half the cash the building holds
|
var ore = Stored(self);
|
||||||
var toSteal = self.Info.Traits.Get<StoresOreInfo>().Capacity / 2;
|
self.Owner.PlayerActor.traits.Get<PlayerResources>().TakeOre(ore);
|
||||||
self.Owner.PlayerActor.traits.Get<PlayerResources>().TakeCash(toSteal);
|
captor.Owner.PlayerActor.traits.Get<PlayerResources>().GiveOre(ore);
|
||||||
thief.Owner.PlayerActor.traits.Get<PlayerResources>().GiveCash(toSteal);
|
}
|
||||||
|
|
||||||
var eva = thief.World.WorldActor.Info.Traits.Get<EvaAlertsInfo>();
|
int Stored(Actor self)
|
||||||
Sound.PlayToPlayer(thief.Owner, eva.CreditsStolen);
|
{
|
||||||
|
var use = self.Owner.PlayerActor.traits.Get<PlayerResources>().GetSiloFullness();
|
||||||
|
var capacity = self.Info.Traits.Get<StoresOreInfo>().Capacity;
|
||||||
|
return (int)use*capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<PipType> GetPips(Actor self)
|
public IEnumerable<PipType> GetPips(Actor self)
|
||||||
@@ -46,7 +49,7 @@ namespace OpenRA.Traits
|
|||||||
var numPips = self.Info.Traits.Get<StoresOreInfo>().Pips;
|
var numPips = self.Info.Traits.Get<StoresOreInfo>().Pips;
|
||||||
|
|
||||||
return Graphics.Util.MakeArray( numPips,
|
return Graphics.Util.MakeArray( numPips,
|
||||||
i => (self.World.LocalPlayer.PlayerActor.traits.Get<PlayerResources>().GetSiloFullness() > i * 1.0f / numPips)
|
i => (self.Owner.PlayerActor.traits.Get<PlayerResources>().GetSiloFullness() > i * 1.0f / numPips)
|
||||||
? PipType.Yellow : PipType.Transparent );
|
? PipType.Yellow : PipType.Transparent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Traits
|
|||||||
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
|
public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
|
||||||
public interface INotifyBuildComplete { void BuildingComplete(Actor self); }
|
public interface INotifyBuildComplete { void BuildingComplete(Actor self); }
|
||||||
public interface INotifyProduction { void UnitProduced(Actor self, Actor other); }
|
public interface INotifyProduction { void UnitProduced(Actor self, Actor other); }
|
||||||
public interface IAcceptThief { void OnSteal(Actor self, Actor thief); }
|
public interface INotifyCapture { void OnCapture(Actor self, Actor captor); }
|
||||||
public interface IAcceptSpy { void OnInfiltrate(Actor self, Actor spy); }
|
public interface IAcceptSpy { void OnInfiltrate(Actor self, Actor spy); }
|
||||||
public interface INotifyEnterCell { void OnEnterCell(Actor self, int2 cell); }
|
public interface INotifyEnterCell { void OnEnterCell(Actor self, int2 cell); }
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -49,6 +49,9 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
w.Remove(target);
|
w.Remove(target);
|
||||||
target.Owner = self.Owner;
|
target.Owner = self.Owner;
|
||||||
w.Add(target);
|
w.Add(target);
|
||||||
|
|
||||||
|
foreach (var t in target.traits.WithInterface<INotifyCapture>())
|
||||||
|
t.OnCapture(target, self);
|
||||||
});
|
});
|
||||||
|
|
||||||
target.InflictDamage(self, target.Health - EngineerCapture.EngineerDamage, null);
|
target.InflictDamage(self, target.Health - EngineerCapture.EngineerDamage, null);
|
||||||
|
|||||||
@@ -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; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -66,7 +66,6 @@
|
|||||||
<Compile Include="Activities\Rearm.cs" />
|
<Compile Include="Activities\Rearm.cs" />
|
||||||
<Compile Include="Activities\Repair.cs" />
|
<Compile Include="Activities\Repair.cs" />
|
||||||
<Compile Include="Activities\ReturnToBase.cs" />
|
<Compile Include="Activities\ReturnToBase.cs" />
|
||||||
<Compile Include="Activities\Steal.cs" />
|
|
||||||
<Compile Include="Activities\Teleport.cs" />
|
<Compile Include="Activities\Teleport.cs" />
|
||||||
<Compile Include="Activities\UnloadCargo.cs" />
|
<Compile Include="Activities\UnloadCargo.cs" />
|
||||||
<Compile Include="Activities\Wait.cs" />
|
<Compile Include="Activities\Wait.cs" />
|
||||||
@@ -168,7 +167,6 @@
|
|||||||
<Compile Include="NukePower.cs" />
|
<Compile Include="NukePower.cs" />
|
||||||
<Compile Include="TakeCover.cs" />
|
<Compile Include="TakeCover.cs" />
|
||||||
<Compile Include="TeslaInstantKills.cs" />
|
<Compile Include="TeslaInstantKills.cs" />
|
||||||
<Compile Include="Thief.cs" />
|
|
||||||
<Compile Include="Crates\ResetRadarCrateAction.cs" />
|
<Compile Include="Crates\ResetRadarCrateAction.cs" />
|
||||||
<Compile Include="ThrowsParticles.cs" />
|
<Compile Include="ThrowsParticles.cs" />
|
||||||
<Compile Include="TraitsInterfaces.cs" />
|
<Compile Include="TraitsInterfaces.cs" />
|
||||||
|
|||||||
@@ -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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user