Chronosphere implementation plus supporting tweaks to Order
This commit is contained in:
@@ -122,6 +122,7 @@
|
|||||||
<Compile Include="Smudge.cs" />
|
<Compile Include="Smudge.cs" />
|
||||||
<Compile Include="Sound.cs" />
|
<Compile Include="Sound.cs" />
|
||||||
<Compile Include="SupportPower.cs" />
|
<Compile Include="SupportPower.cs" />
|
||||||
|
<Compile Include="SupportPowers\ChronospherePower.cs" />
|
||||||
<Compile Include="SupportPowers\GpsSatellite.cs" />
|
<Compile Include="SupportPowers\GpsSatellite.cs" />
|
||||||
<Compile Include="SupportPowers\IronCurtainPower.cs" />
|
<Compile Include="SupportPowers\IronCurtainPower.cs" />
|
||||||
<Compile Include="SupportPowers\ISupportPowerImpl.cs" />
|
<Compile Include="SupportPowers\ISupportPowerImpl.cs" />
|
||||||
|
|||||||
@@ -1,19 +1,20 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using OpenRa.Game.Traits;
|
using OpenRa.Game.Traits;
|
||||||
|
using OpenRa.Game.SupportPowers;
|
||||||
|
|
||||||
namespace OpenRa.Game.Orders
|
namespace OpenRa.Game.Orders
|
||||||
{
|
{
|
||||||
class ChronoshiftDestinationOrderGenerator : IOrderGenerator
|
class ChronoshiftDestinationOrderGenerator : IOrderGenerator
|
||||||
{
|
{
|
||||||
public readonly Actor self;
|
public readonly Actor self;
|
||||||
|
ISupportPowerImpl chronospherePower;
|
||||||
public ChronoshiftDestinationOrderGenerator(Actor self)
|
public ChronoshiftDestinationOrderGenerator(Actor self, ISupportPowerImpl chronospherePower)
|
||||||
{
|
{
|
||||||
this.self = self;
|
this.self = self;
|
||||||
|
this.chronospherePower = chronospherePower;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||||
@@ -23,8 +24,7 @@ namespace OpenRa.Game.Orders
|
|||||||
Game.controller.CancelInputMode();
|
Game.controller.CancelInputMode();
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
yield return new Order("Chronoshift", self, null, xy, null, chronospherePower);
|
||||||
yield return new Order("Chronoshift", self, null, xy, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick() {}
|
public void Tick() {}
|
||||||
|
|||||||
@@ -1,14 +1,20 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using OpenRa.Game.GameRules;
|
using OpenRa.Game.GameRules;
|
||||||
using OpenRa.Game.Traits;
|
using OpenRa.Game.Traits;
|
||||||
|
using OpenRa.Game.SupportPowers;
|
||||||
|
|
||||||
namespace OpenRa.Game.Orders
|
namespace OpenRa.Game.Orders
|
||||||
{
|
{
|
||||||
class ChronosphereSelectOrderGenerator : IOrderGenerator
|
class ChronosphereSelectOrderGenerator : IOrderGenerator
|
||||||
{
|
{
|
||||||
|
ISupportPowerImpl chronospherePower;
|
||||||
|
public ChronosphereSelectOrderGenerator(ISupportPowerImpl chronospherePower)
|
||||||
|
{
|
||||||
|
this.chronospherePower = chronospherePower;
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right)
|
if (mi.Button == MouseButton.Right)
|
||||||
@@ -31,7 +37,7 @@ namespace OpenRa.Game.Orders
|
|||||||
|
|
||||||
if (unit != null)
|
if (unit != null)
|
||||||
{
|
{
|
||||||
yield return new Order("ChronosphereSelect", underCursor, null, int2.Zero, null);
|
yield return new Order("ChronosphereSelect", underCursor, null, int2.Zero, null, chronospherePower);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
using OpenRa.Game.GameRules;
|
using OpenRa.Game.GameRules;
|
||||||
using OpenRa.Game.Traits;
|
using OpenRa.Game.Traits;
|
||||||
using OpenRa.Game.SupportPowers;
|
using OpenRa.Game.SupportPowers;
|
||||||
|
|
||||||
namespace OpenRa.Game.Orders
|
namespace OpenRa.Game.Orders
|
||||||
{
|
{
|
||||||
class IronCurtainOrderGenerator : IOrderGenerator
|
class IronCurtainOrderGenerator : IOrderGenerator
|
||||||
{
|
{
|
||||||
ISupportPowerImpl power;
|
ISupportPowerImpl ironCurtainPower;
|
||||||
public IronCurtainOrderGenerator(ISupportPowerImpl power)
|
public IronCurtainOrderGenerator(ISupportPowerImpl ironCurtainPower)
|
||||||
{
|
{
|
||||||
this.power = power;
|
this.ironCurtainPower = ironCurtainPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||||
@@ -37,8 +37,7 @@ namespace OpenRa.Game.Orders
|
|||||||
|
|
||||||
if (unit != null)
|
if (unit != null)
|
||||||
{
|
{
|
||||||
yield return new Order("IronCurtain", underCursor, this.power);
|
yield return new Order("IronCurtain", underCursor, null, int2.Zero, null, ironCurtainPower);
|
||||||
//yield return new Order("IronCurtain", underCursor, null, int2.Zero, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ namespace OpenRa.Game
|
|||||||
public readonly string TargetString;
|
public readonly string TargetString;
|
||||||
public bool IsImmediate;
|
public bool IsImmediate;
|
||||||
|
|
||||||
|
// This is a hack - fix me
|
||||||
|
public readonly ISupportPowerImpl SupportPowerImpl;
|
||||||
|
|
||||||
public Actor Subject { get { return ActorFromUInt(SubjectId); } }
|
public Actor Subject { get { return ActorFromUInt(SubjectId); } }
|
||||||
public Actor TargetActor { get { return ActorFromUInt(TargetActorId); } }
|
public Actor TargetActor { get { return ActorFromUInt(TargetActorId); } }
|
||||||
public Player Player { get { return Subject.Owner; } }
|
public Player Player { get { return Subject.Owner; } }
|
||||||
@@ -21,29 +24,27 @@ namespace OpenRa.Game
|
|||||||
public Order(string orderString, Actor subject,
|
public Order(string orderString, Actor subject,
|
||||||
Actor targetActor, int2 targetLocation, string targetString)
|
Actor targetActor, int2 targetLocation, string targetString)
|
||||||
: this( orderString, UIntFromActor( subject ),
|
: this( orderString, UIntFromActor( subject ),
|
||||||
UIntFromActor( targetActor ), targetLocation, targetString ) {}
|
UIntFromActor( targetActor ), targetLocation, targetString, null ) {}
|
||||||
|
|
||||||
|
public Order(string orderString, Actor subject,
|
||||||
|
Actor targetActor, int2 targetLocation, string targetString, ISupportPowerImpl power)
|
||||||
|
: this(orderString, UIntFromActor(subject),
|
||||||
|
UIntFromActor(targetActor), targetLocation, targetString, power) { }
|
||||||
|
|
||||||
Order(string orderString, uint subjectId,
|
Order(string orderString, uint subjectId,
|
||||||
uint targetActorId, int2 targetLocation, string targetString)
|
uint targetActorId, int2 targetLocation, string targetString)
|
||||||
|
: this(orderString, subjectId,
|
||||||
|
targetActorId, targetLocation, targetString, null) { }
|
||||||
|
|
||||||
|
Order(string orderString, uint subjectId,
|
||||||
|
uint targetActorId, int2 targetLocation, string targetString, ISupportPowerImpl power)
|
||||||
{
|
{
|
||||||
this.OrderString = orderString;
|
this.OrderString = orderString;
|
||||||
this.SubjectId = subjectId;
|
this.SubjectId = subjectId;
|
||||||
this.TargetActorId = targetActorId;
|
this.TargetActorId = targetActorId;
|
||||||
this.TargetLocation = targetLocation;
|
this.TargetLocation = targetLocation;
|
||||||
this.TargetString = targetString;
|
this.TargetString = targetString;
|
||||||
}
|
this.SupportPowerImpl = power;
|
||||||
// This is a hack - fix me
|
|
||||||
public readonly ISupportPowerImpl Power;
|
|
||||||
public Order(string orderString, Actor subject, ISupportPowerImpl power)
|
|
||||||
{
|
|
||||||
this.OrderString = orderString;
|
|
||||||
this.SubjectId = UIntFromActor( subject );
|
|
||||||
|
|
||||||
this.Power = power;
|
|
||||||
|
|
||||||
this.TargetActorId = UIntFromActor(null);
|
|
||||||
this.TargetLocation = int2.Zero;
|
|
||||||
this.TargetString = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Validate()
|
public bool Validate()
|
||||||
|
|||||||
39
OpenRa.Game/SupportPowers/ChronospherePower.cs
Normal file
39
OpenRa.Game/SupportPowers/ChronospherePower.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Drawing;
|
||||||
|
using OpenRa.Game.Orders;
|
||||||
|
using OpenRa.Game.Traits;
|
||||||
|
|
||||||
|
namespace OpenRa.Game.SupportPowers
|
||||||
|
{
|
||||||
|
class ChronospherePower : ISupportPowerImpl
|
||||||
|
{
|
||||||
|
public void IsReadyNotification(SupportPower p) { Sound.Play("chrordy1.aud"); }
|
||||||
|
public void IsChargingNotification(SupportPower p) { Sound.Play("chrochr1.aud"); }
|
||||||
|
|
||||||
|
public void OnFireNotification(Actor target, int2 xy)
|
||||||
|
{
|
||||||
|
p.FinishActivate();
|
||||||
|
Game.controller.CancelInputMode();
|
||||||
|
|
||||||
|
Sound.Play("chrono2.aud");
|
||||||
|
|
||||||
|
foreach (var a in Game.world.Actors.Where(a => a.traits.Contains<ChronoshiftPaletteEffect>()))
|
||||||
|
a.traits.Get<ChronoshiftPaletteEffect>().DoChronoshift();
|
||||||
|
|
||||||
|
// Play chronosphere active anim
|
||||||
|
var chronosphere = Game.world.Actors.Where(a => a.Owner == p.Owner && a.traits.Contains<Chronosphere>()).FirstOrDefault();
|
||||||
|
|
||||||
|
if (chronosphere != null)
|
||||||
|
chronosphere.traits.Get<RenderBuilding>().PlayCustomAnim(chronosphere, "active");
|
||||||
|
}
|
||||||
|
SupportPower p;
|
||||||
|
public void Activate(SupportPower p)
|
||||||
|
{
|
||||||
|
this.p = p;
|
||||||
|
Game.controller.orderGenerator = new ChronosphereSelectOrderGenerator(this);
|
||||||
|
Sound.Play("slcttgt1.aud");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
using OpenRa.Game.Orders;
|
using OpenRa.Game.Orders;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace OpenRa.Game.Traits
|
namespace OpenRa.Game.Traits
|
||||||
{
|
{
|
||||||
@@ -40,7 +39,7 @@ namespace OpenRa.Game.Traits
|
|||||||
{
|
{
|
||||||
if (order.OrderString == "ChronosphereSelect")
|
if (order.OrderString == "ChronosphereSelect")
|
||||||
{
|
{
|
||||||
Game.controller.orderGenerator = new ChronoshiftDestinationOrderGenerator(self);
|
Game.controller.orderGenerator = new ChronoshiftDestinationOrderGenerator(self, order.SupportPowerImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
var movement = self.traits.WithInterface<IMovement>().FirstOrDefault();
|
var movement = self.traits.WithInterface<IMovement>().FirstOrDefault();
|
||||||
@@ -49,37 +48,26 @@ namespace OpenRa.Game.Traits
|
|||||||
// Cannot chronoshift into unexplored location
|
// Cannot chronoshift into unexplored location
|
||||||
if (!Game.LocalPlayer.Shroud.IsExplored(order.TargetLocation))
|
if (!Game.LocalPlayer.Shroud.IsExplored(order.TargetLocation))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set up return-to-sender info
|
// Set up return-to-sender info
|
||||||
chronoshiftOrigin = self.Location;
|
chronoshiftOrigin = self.Location;
|
||||||
chronoshiftReturnTicks = (int)(Rules.General.ChronoDuration * 60 * 25);
|
chronoshiftReturnTicks = (int)(Rules.General.ChronoDuration * 60 * 25);
|
||||||
|
|
||||||
var chronosphere = Game.world.Actors.Where(a => a.Owner == order.Subject.Owner && a.traits.Contains<Chronosphere>()).FirstOrDefault();
|
|
||||||
|
|
||||||
// Kill cargo
|
// Kill cargo
|
||||||
if (Rules.General.ChronoKillCargo && self.traits.Contains<Cargo>())
|
if (Rules.General.ChronoKillCargo && self.traits.Contains<Cargo>())
|
||||||
{
|
{
|
||||||
var cargo = self.traits.Get<Cargo>();
|
var cargo = self.traits.Get<Cargo>();
|
||||||
while (!cargo.IsEmpty(self))
|
while (!cargo.IsEmpty(self))
|
||||||
{
|
{
|
||||||
if (chronosphere != null)
|
order.Player.Kills++;
|
||||||
chronosphere.Owner.Kills++;
|
|
||||||
cargo.Unload(self);
|
cargo.Unload(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the teleport
|
// Set up the teleport
|
||||||
Game.controller.CancelInputMode();
|
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(new Activities.Teleport(order.TargetLocation));
|
self.QueueActivity(new Activities.Teleport(order.TargetLocation));
|
||||||
Sound.Play("chrono2.aud");
|
order.SupportPowerImpl.OnFireNotification(self, self.Location);
|
||||||
|
|
||||||
foreach (var a in Game.world.Actors.Where(a => a.traits.Contains<ChronoshiftPaletteEffect>()))
|
|
||||||
a.traits.Get<ChronoshiftPaletteEffect>().DoChronoshift();
|
|
||||||
|
|
||||||
// Play chronosphere active anim
|
|
||||||
if (chronosphere != null)
|
|
||||||
chronosphere.traits.Get<RenderBuilding>().PlayCustomAnim(chronosphere, "active");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace OpenRa.Game.Traits
|
|||||||
{
|
{
|
||||||
if (order.OrderString == "IronCurtain")
|
if (order.OrderString == "IronCurtain")
|
||||||
{
|
{
|
||||||
order.Power.OnFireNotification(self, self.Location);
|
order.SupportPowerImpl.OnFireNotification(self, self.Location);
|
||||||
Game.world.AddFrameEndTask(w => w.Add(new InvulnEffect(self)));
|
Game.world.AddFrameEndTask(w => w.Add(new InvulnEffect(self)));
|
||||||
RemainingTicks = (int)(Rules.General.IronCurtain * 60 * 25);
|
RemainingTicks = (int)(Rules.General.IronCurtain * 60 * 25);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -861,7 +861,7 @@ LongDesc=Temporarily teleports a vehicle across \nthe map.
|
|||||||
Prerequisite=PDOX
|
Prerequisite=PDOX
|
||||||
Image=warpicon
|
Image=warpicon
|
||||||
TechLevel=12
|
TechLevel=12
|
||||||
Impl=NullPower
|
Impl=ChronospherePower
|
||||||
|
|
||||||
[SpyPlanePower] ; free with first AFLD
|
[SpyPlanePower] ; free with first AFLD
|
||||||
ChargeTime=3
|
ChargeTime=3
|
||||||
|
|||||||
Reference in New Issue
Block a user