RA special infantry all in mod dll now
This commit is contained in:
47
OpenRa.Mods.RA/Activities/CaptureBuilding.cs
Normal file
47
OpenRa.Mods.RA/Activities/CaptureBuilding.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Traits.Activities;
|
||||
using OpenRa.Traits;
|
||||
|
||||
namespace OpenRa.Mods.RA.Activities
|
||||
{
|
||||
class CaptureBuilding : IActivity
|
||||
{
|
||||
Actor target;
|
||||
|
||||
public CaptureBuilding(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)
|
||||
{
|
||||
if (target.Health == target.Info.Traits.Get<OwnedActorInfo>().HP)
|
||||
return NextActivity;
|
||||
target.InflictDamage(self, -EngineerCapture.EngineerDamage, Rules.WarheadInfo["Super"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (target.Health - EngineerCapture.EngineerDamage <= 0)
|
||||
{
|
||||
target.Owner = self.Owner;
|
||||
target.InflictDamage(self, target.Health - EngineerCapture.EngineerDamage, Rules.WarheadInfo["Super"]);
|
||||
}
|
||||
else
|
||||
target.InflictDamage(self, EngineerCapture.EngineerDamage, Rules.WarheadInfo["Super"]);
|
||||
}
|
||||
|
||||
// the engineer is sacrificed.
|
||||
Game.world.AddFrameEndTask(w => w.Remove(self));
|
||||
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self) { target = null; NextActivity = null; }
|
||||
}
|
||||
}
|
||||
26
OpenRa.Mods.RA/Activities/Demolish.cs
Normal file
26
OpenRa.Mods.RA/Activities/Demolish.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using OpenRa.Effects;
|
||||
using OpenRa.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Mods.RA.Activities
|
||||
{
|
||||
class Demolish : IActivity
|
||||
{
|
||||
Actor target;
|
||||
public IActivity NextActivity { get; set; }
|
||||
|
||||
public Demolish( Actor target )
|
||||
{
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public IActivity Tick(Actor self)
|
||||
{
|
||||
if (target == null || target.IsDead) return NextActivity;
|
||||
Game.world.AddFrameEndTask(w => w.Add(new DelayedAction(25*2,
|
||||
() => target.InflictDamage(self, target.Health, Rules.WarheadInfo["DemolishWarhead"]))));
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self) { target = null; NextActivity = null; }
|
||||
}
|
||||
}
|
||||
27
OpenRa.Mods.RA/Activities/Infiltrate.cs
Normal file
27
OpenRa.Mods.RA/Activities/Infiltrate.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using OpenRa.Traits.Activities;
|
||||
using OpenRa.Traits;
|
||||
|
||||
namespace OpenRa.Mods.RA.Activities
|
||||
{
|
||||
class Infiltrate : IActivity
|
||||
{
|
||||
Actor target;
|
||||
public Infiltrate(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<IAcceptSpy>())
|
||||
t.OnInfiltrate(target, self);
|
||||
|
||||
Game.world.AddFrameEndTask(w => w.Remove(self));
|
||||
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self) { target = null; NextActivity = null; }
|
||||
}
|
||||
}
|
||||
33
OpenRa.Mods.RA/Activities/Steal.cs
Normal file
33
OpenRa.Mods.RA/Activities/Steal.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Traits.Activities;
|
||||
using OpenRa.Traits;
|
||||
|
||||
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);
|
||||
|
||||
Game.world.AddFrameEndTask(w => w.Remove(self));
|
||||
|
||||
return NextActivity;
|
||||
}
|
||||
|
||||
public void Cancel(Actor self) { target = null; NextActivity = null; }
|
||||
}
|
||||
}
|
||||
32
OpenRa.Mods.RA/C4Demolition.cs
Normal file
32
OpenRa.Mods.RA/C4Demolition.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using OpenRa.Mods.RA.Activities;
|
||||
using OpenRa.Traits;
|
||||
using OpenRa.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Mods.RA
|
||||
{
|
||||
class C4DemolitionInfo : StatelessTraitInfo<C4Demolition> { }
|
||||
|
||||
class C4Demolition : 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 (underCursor.Owner == self.Owner && !mi.Modifiers.HasModifier(Modifiers.Ctrl)) return null;
|
||||
if (!underCursor.traits.Contains<Building>()) return null;
|
||||
|
||||
return new Order("C4", self, underCursor, int2.Zero, null);
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "C4")
|
||||
{
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Move(order.TargetActor, 2));
|
||||
self.QueueActivity(new Demolish(order.TargetActor));
|
||||
self.QueueActivity(new Move(self.Location, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
35
OpenRa.Mods.RA/EngineerCapture.cs
Normal file
35
OpenRa.Mods.RA/EngineerCapture.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using OpenRa.Traits.Activities;
|
||||
using OpenRa.Traits;
|
||||
using OpenRa.Mods.RA.Activities;
|
||||
|
||||
namespace OpenRa.Mods.RA
|
||||
{
|
||||
class EngineerCaptureInfo : StatelessTraitInfo<EngineerCapture> { }
|
||||
|
||||
class EngineerCapture : IIssueOrder, IResolveOrder
|
||||
{
|
||||
public const int EngineerDamage = 300; // todo: push into rules, as a weapon
|
||||
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
if (mi.Button != MouseButton.Right) return null;
|
||||
if (underCursor == null) return null;
|
||||
if (!underCursor.traits.Contains<Building>()) return null;
|
||||
|
||||
// todo: other bits
|
||||
|
||||
return new Order(underCursor.Health <= EngineerDamage ? "Capture" : "Infiltrate",
|
||||
self, underCursor, int2.Zero, null);
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "Infiltrate" || order.OrderString == "Capture")
|
||||
{
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Move(order.TargetActor, 1));
|
||||
self.QueueActivity(new CaptureBuilding(order.TargetActor));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,10 +46,19 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Activities\CaptureBuilding.cs" />
|
||||
<Compile Include="Activities\Demolish.cs" />
|
||||
<Compile Include="Activities\Infiltrate.cs" />
|
||||
<Compile Include="Activities\Steal.cs" />
|
||||
<Compile Include="C4Demolition.cs" />
|
||||
<Compile Include="EngineerCapture.cs" />
|
||||
<Compile Include="Mine.cs" />
|
||||
<Compile Include="MineImmune.cs" />
|
||||
<Compile Include="Minelayer.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RenderSpy.cs" />
|
||||
<Compile Include="Spy.cs" />
|
||||
<Compile Include="Thief.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRa.FileFormats\OpenRa.FileFormats.csproj">
|
||||
|
||||
36
OpenRa.Mods.RA/RenderSpy.cs
Normal file
36
OpenRa.Mods.RA/RenderSpy.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Graphics;
|
||||
using OpenRa.Traits;
|
||||
|
||||
namespace OpenRa.Mods.RA
|
||||
{
|
||||
class RenderSpyInfo : RenderInfantryInfo
|
||||
{
|
||||
public override object Create(Actor self) { return new RenderSpy(self); }
|
||||
}
|
||||
|
||||
class RenderSpy : RenderInfantry, IRenderModifier
|
||||
{
|
||||
public RenderSpy(Actor self)
|
||||
: base(self)
|
||||
{
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)
|
||||
{
|
||||
if (self.Owner == Game.LocalPlayer)
|
||||
return r;
|
||||
|
||||
return r.Select(a => a.WithPalette(Game.LocalPlayer.Palette));
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
anim.ChangeImage(self.Owner == Game.LocalPlayer ? GetImage(self) : "e1");
|
||||
base.Tick(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
35
OpenRa.Mods.RA/Spy.cs
Normal file
35
OpenRa.Mods.RA/Spy.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Traits.Activities;
|
||||
using OpenRa.Traits;
|
||||
using OpenRa.Mods.RA.Activities;
|
||||
|
||||
namespace OpenRa.Mods.RA
|
||||
{
|
||||
class SpyInfo : StatelessTraitInfo<Spy> { }
|
||||
|
||||
class Spy : 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 (underCursor.Owner == self.Owner) return null;
|
||||
if (!underCursor.traits.Contains<IAcceptSpy>()) return null;
|
||||
|
||||
return new Order("Infiltrate", self, underCursor, int2.Zero, null);
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "Infiltrate")
|
||||
{
|
||||
self.CancelActivity();
|
||||
self.QueueActivity(new Move(order.TargetActor, 1));
|
||||
self.QueueActivity(new Infiltrate(order.TargetActor));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
30
OpenRa.Mods.RA/Thief.cs
Normal file
30
OpenRa.Mods.RA/Thief.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using OpenRa.Mods.RA.Activities;
|
||||
using OpenRa.Traits;
|
||||
using OpenRa.Traits.Activities;
|
||||
|
||||
namespace OpenRa.Mods.RA
|
||||
{
|
||||
class ThiefInfo : StatelessTraitInfo<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 (!underCursor.traits.Contains<IAcceptThief>()) return null;
|
||||
|
||||
return new Order("Steal", self, underCursor, int2.Zero, null);
|
||||
}
|
||||
|
||||
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