invuln moved to mod
This commit is contained in:
31
OpenRa.Mods.RA/Effects/InvulnEffect.cs
Normal file
31
OpenRa.Mods.RA/Effects/InvulnEffect.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using OpenRa.Graphics;
|
||||
using OpenRa.Traits;
|
||||
using OpenRa.Effects;
|
||||
|
||||
namespace OpenRa.Mods.RA.Effects
|
||||
{
|
||||
class InvulnEffect : IEffect
|
||||
{
|
||||
Actor a;
|
||||
IronCurtainable b;
|
||||
|
||||
public InvulnEffect(Actor a)
|
||||
{
|
||||
this.a = a;
|
||||
this.b = a.traits.Get<IronCurtainable>();
|
||||
}
|
||||
|
||||
public void Tick( World world )
|
||||
{
|
||||
if (a.IsDead || b.GetDamageModifier() > 0)
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
foreach (var r in a.Render())
|
||||
yield return r.WithPalette(PaletteType.Invuln);
|
||||
}
|
||||
}
|
||||
}
|
||||
97
OpenRa.Mods.RA/IronCurtainPower.cs
Normal file
97
OpenRa.Mods.RA/IronCurtainPower.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRa.Traits;
|
||||
|
||||
namespace OpenRa.Mods.RA
|
||||
{
|
||||
class IronCurtainPowerInfo : SupportPowerInfo
|
||||
{
|
||||
public readonly float Duration = 0f;
|
||||
public override object Create(Actor self) { return new IronCurtainPower(self, this); }
|
||||
}
|
||||
|
||||
class IronCurtainPower : SupportPower, IResolveOrder
|
||||
{
|
||||
public IronCurtainPower(Actor self, IronCurtainPowerInfo info) : base(self, info) { }
|
||||
|
||||
protected override void OnBeginCharging() { Sound.PlayToPlayer(Owner, "ironchg1.aud"); }
|
||||
protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "ironrdy1.aud"); }
|
||||
protected override void OnActivate()
|
||||
{
|
||||
Game.controller.orderGenerator = new SelectTarget();
|
||||
Sound.Play("slcttgt1.aud");
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "IronCurtain")
|
||||
{
|
||||
if (self.Owner == self.World.LocalPlayer)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
var curtain = self.World.Actors.Where(a => a.Owner != null
|
||||
&& a.traits.Contains<IronCurtain>()).FirstOrDefault();
|
||||
if (curtain != null)
|
||||
curtain.traits.Get<RenderBuilding>().PlayCustomAnim(curtain, "active");
|
||||
|
||||
Sound.Play("ironcur9.aud");
|
||||
|
||||
order.TargetActor.traits.Get<IronCurtainable>().Activate(order.TargetActor,
|
||||
(int)((Info as IronCurtainPowerInfo).Duration * 25 * 60));
|
||||
|
||||
FinishActivate();
|
||||
}
|
||||
}
|
||||
|
||||
class SelectTarget : IOrderGenerator
|
||||
{
|
||||
public SelectTarget() { }
|
||||
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
return OrderInner(world, xy, mi);
|
||||
}
|
||||
|
||||
IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
{
|
||||
var underCursor = world.FindUnitsAtMouse(mi.Location)
|
||||
.Where(a => a.Owner != null
|
||||
&& a.traits.Contains<IronCurtainable>()
|
||||
&& a.traits.Contains<Selectable>()).FirstOrDefault();
|
||||
|
||||
if (underCursor != null)
|
||||
yield return new Order("IronCurtain", underCursor.Owner.PlayerActor, underCursor);
|
||||
}
|
||||
|
||||
yield break;
|
||||
}
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
var hasStructure = world.Actors
|
||||
.Any(a => a.Owner == world.LocalPlayer && a.traits.Contains<IronCurtain>());
|
||||
|
||||
if (!hasStructure)
|
||||
Game.controller.CancelInputMode();
|
||||
}
|
||||
|
||||
public void Render(World world) { }
|
||||
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? Cursor.Ability : Cursor.MoveBlocked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// tag trait for the building
|
||||
class IronCurtainInfo : StatelessTraitInfo<IronCurtain> { }
|
||||
class IronCurtain { }
|
||||
}
|
||||
35
OpenRa.Mods.RA/IronCurtainable.cs
Normal file
35
OpenRa.Mods.RA/IronCurtainable.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Linq;
|
||||
using OpenRa.Effects;
|
||||
using OpenRa.Traits;
|
||||
using OpenRa.Mods.RA.Effects;
|
||||
|
||||
namespace OpenRa.Mods.RA
|
||||
{
|
||||
class IronCurtainableInfo : ITraitInfo
|
||||
{
|
||||
public object Create(Actor self) { return new IronCurtainable(); }
|
||||
}
|
||||
|
||||
class IronCurtainable : IDamageModifier, ITick
|
||||
{
|
||||
[Sync]
|
||||
int RemainingTicks = 0;
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (RemainingTicks > 0)
|
||||
RemainingTicks--;
|
||||
}
|
||||
|
||||
public float GetDamageModifier()
|
||||
{
|
||||
return (RemainingTicks > 0) ? 0.0f : 1.0f;
|
||||
}
|
||||
|
||||
public void Activate(Actor self, int duration)
|
||||
{
|
||||
self.World.AddFrameEndTask(w => w.Add(new InvulnEffect(self)));
|
||||
RemainingTicks = duration;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,9 +53,12 @@
|
||||
<Compile Include="Activities\Steal.cs" />
|
||||
<Compile Include="C4Demolition.cs" />
|
||||
<Compile Include="Effects\CrateEffect.cs" />
|
||||
<Compile Include="Effects\InvulnEffect.cs" />
|
||||
<Compile Include="Effects\Parachute.cs" />
|
||||
<Compile Include="EngineerCapture.cs" />
|
||||
<Compile Include="InfiltrateForSonarPulse.cs" />
|
||||
<Compile Include="IronCurtainable.cs" />
|
||||
<Compile Include="IronCurtainPower.cs" />
|
||||
<Compile Include="ParaDrop.cs" />
|
||||
<Compile Include="ParatroopersPower.cs" />
|
||||
<Compile Include="RequiresPower.cs" />
|
||||
|
||||
Reference in New Issue
Block a user