Begin iron curtain impl
This commit is contained in:
@@ -305,6 +305,21 @@ namespace OpenRa.Game
|
||||
AddButton(chronoshiftRect, isLmb => HandleChronosphereButton());
|
||||
}
|
||||
buildPaletteRenderer.DrawSprite(repairButton.Image, chronoshiftDrawPos, PaletteType.Chrome);
|
||||
|
||||
// Iron Curtain
|
||||
Rectangle curtainRect = new Rectangle(6, 14+50, repairButton.Image.bounds.Width, repairButton.Image.bounds.Height);
|
||||
var curtainDrawPos = Game.viewport.Location + new float2(curtainRect.Location);
|
||||
|
||||
var hasCurtain = Game.world.Actors.Any(a => a.Owner == Game.LocalPlayer && a.traits.Contains<IronCurtain>());
|
||||
|
||||
if (!hasCurtain)
|
||||
repairButton.ReplaceAnim("disabled");
|
||||
else
|
||||
{
|
||||
//repairButton.ReplaceAnim(Game.controller.orderGenerator is RepairOrderGenerator ? "pressed" : "normal");
|
||||
AddButton(curtainRect, isLmb => Game.controller.ToggleInputMode<IronCurtainOrderGenerator>());
|
||||
}
|
||||
buildPaletteRenderer.DrawSprite(repairButton.Image, curtainDrawPos, PaletteType.Chrome);
|
||||
|
||||
|
||||
// Repair
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace OpenRa.Game
|
||||
public static Cursor DeployBlocked { get { return new Cursor("deploy-blocked"); } }
|
||||
public static Cursor Chronoshift { get { return new Cursor("chrono-target"); } }
|
||||
public static Cursor ChronoshiftSelect { get { return new Cursor("chrono-select"); } }
|
||||
public static Cursor Ability { get { return new Cursor("ability"); } }
|
||||
public static Cursor C4 { get { return new Cursor("c4"); } }
|
||||
public static Cursor Capture { get { return new Cursor("capture"); } }
|
||||
public static Cursor Heal { get { return new Cursor("heal"); } }
|
||||
|
||||
@@ -100,6 +100,7 @@
|
||||
<Compile Include="Orders\ChronoshiftSelfDestinationOrderGenerator.cs" />
|
||||
<Compile Include="Orders\ChronosphereSelectOrderGenerator.cs" />
|
||||
<Compile Include="Orders\IOrderSource.cs" />
|
||||
<Compile Include="Orders\IronCurtainOrderGenerator.cs" />
|
||||
<Compile Include="Orders\LocalOrderSource.cs" />
|
||||
<Compile Include="Effects\Missile.cs" />
|
||||
<Compile Include="Orders\NetworkOrderSource.cs" />
|
||||
@@ -217,6 +218,8 @@
|
||||
<Compile Include="Traits\Helicopter.cs" />
|
||||
<Compile Include="Traits\InvisibleToOthers.cs" />
|
||||
<Compile Include="Traits\ConstructionYard.cs" />
|
||||
<Compile Include="Traits\IronCurtain.cs" />
|
||||
<Compile Include="Traits\IronCurtainable.cs" />
|
||||
<Compile Include="Traits\MineImmune.cs" />
|
||||
<Compile Include="Traits\Minelayer.cs" />
|
||||
<Compile Include="Traits\LimitedAmmo.cs" />
|
||||
|
||||
57
OpenRa.Game/Orders/IronCurtainOrderGenerator.cs
Normal file
57
OpenRa.Game/Orders/IronCurtainOrderGenerator.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.GameRules;
|
||||
using OpenRa.Game.Traits;
|
||||
|
||||
namespace OpenRa.Game.Orders
|
||||
{
|
||||
class IronCurtainOrderGenerator : IOrderGenerator
|
||||
{
|
||||
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
return OrderInner(xy, mi);
|
||||
}
|
||||
|
||||
IEnumerable<Order> OrderInner(int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
{
|
||||
var loc = mi.Location + Game.viewport.Location;
|
||||
var underCursor = Game.FindUnits(loc, loc)
|
||||
.Where(a => a.Owner == Game.LocalPlayer
|
||||
&& a.traits.Contains<IronCurtainable>()
|
||||
&& a.Info.Selectable).FirstOrDefault();
|
||||
|
||||
var unit = underCursor != null ? underCursor.Info as UnitInfo : null;
|
||||
|
||||
if (unit != null)
|
||||
{
|
||||
yield return new Order("IronCurtain", underCursor, null, int2.Zero, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
var hasStructure = Game.world.Actors
|
||||
.Any(a => a.Owner == Game.LocalPlayer && a.traits.Contains<IronCurtain>());
|
||||
|
||||
if (!hasStructure)
|
||||
Game.controller.CancelInputMode();
|
||||
}
|
||||
|
||||
public void Render() { }
|
||||
|
||||
public Cursor GetCursor(int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(xy, mi).Any()
|
||||
? Cursor.Ability : Cursor.MoveBlocked;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
OpenRa.Game/Traits/IronCurtain.cs
Normal file
12
OpenRa.Game/Traits/IronCurtain.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class IronCurtain
|
||||
{
|
||||
public IronCurtain(Actor self) {}
|
||||
}
|
||||
}
|
||||
57
OpenRa.Game/Traits/IronCurtainable.cs
Normal file
57
OpenRa.Game/Traits/IronCurtainable.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using OpenRa.Game.Traits;
|
||||
using OpenRa.Game.Orders;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Drawing;
|
||||
using OpenRa.Game.Effects;
|
||||
using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game.Traits
|
||||
{
|
||||
class IronCurtainable: IOrder, IDamageModifier, ITick, IRenderModifier
|
||||
{
|
||||
int RemainingTicks = 0;
|
||||
|
||||
public IronCurtainable(Actor self) { }
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (RemainingTicks > 0)
|
||||
RemainingTicks--;
|
||||
}
|
||||
public float GetDamageModifier()
|
||||
{
|
||||
return (RemainingTicks > 0) ? 0.0f : 1.0f;
|
||||
}
|
||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||
{
|
||||
return null; // Chronoshift order is issued through Chrome.
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
{
|
||||
if (order.OrderString == "IronCurtain")
|
||||
{
|
||||
RemainingTicks = (int)(Rules.General.IronCurtain * 60 * 25);
|
||||
// Play active anim
|
||||
var ironCurtain = Game.world.Actors.Where(a => a.Owner == order.Subject.Owner && a.traits.Contains<IronCurtain>()).FirstOrDefault();
|
||||
Sound.Play("ironcur9.aud");
|
||||
if (ironCurtain != null)
|
||||
ironCurtain.traits.Get<RenderBuilding>().PlayCustomAnim(ironCurtain, "active");
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> rs)
|
||||
{
|
||||
if (RemainingTicks <= 0)
|
||||
return rs;
|
||||
|
||||
List<Renderable> nrs = new List<Renderable>(rs);
|
||||
foreach(var r in rs)
|
||||
{
|
||||
nrs.Add(r.WithPalette(PaletteType.Shadow));
|
||||
}
|
||||
return nrs;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user