Made SelectDirectionalTarget a opted in feature and added fields for palettes
This commit is contained in:
@@ -36,12 +36,21 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Amount of time to keep the camera alive after the aircraft have finished attacking")]
|
||||
public readonly int CameraRemoveDelay = 25;
|
||||
|
||||
[Desc("Enables the player directional targeting")]
|
||||
public readonly bool UseDirectionalTarget = false;
|
||||
|
||||
[Desc("Placeholder cursor animation for the target cursor when the real cursor is invisible.")]
|
||||
public readonly string TargetPlaceholderCursorAnimation = null;
|
||||
|
||||
[Desc("Palette for placeholder cursor animation.")]
|
||||
public readonly string TargetPlaceholderCursorPalette = "chrome";
|
||||
|
||||
[Desc("Animation used to render the direction arrows.")]
|
||||
public readonly string DirectionArrowAnimation = null;
|
||||
|
||||
[Desc("Palette for direction cursor animation.")]
|
||||
public readonly string DirectionArrowPalette = "chrome";
|
||||
|
||||
[Desc("Weapon range offset to apply during the beacon clock calculation")]
|
||||
public readonly WDist BeaconDistanceOffset = WDist.FromCells(6);
|
||||
|
||||
@@ -59,18 +68,24 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
public override void SelectTarget(Actor self, string order, SupportPowerManager manager)
|
||||
{
|
||||
if (info.UseDirectionalTarget)
|
||||
{
|
||||
Game.Sound.PlayToPlayer(SoundType.UI, manager.Self.Owner, Info.SelectTargetSound);
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
|
||||
Info.SelectTargetSpeechNotification, self.Owner.Faction.InternalName);
|
||||
|
||||
self.World.OrderGenerator = new SelectDirectionalTarget(self.World, order, manager, Info.Cursor, info.TargetPlaceholderCursorAnimation, info.DirectionArrowAnimation);
|
||||
self.World.OrderGenerator = new SelectDirectionalTarget(self.World, order, manager, Info.Cursor,
|
||||
info.TargetPlaceholderCursorAnimation, info.DirectionArrowAnimation, info.TargetPlaceholderCursorPalette, info.DirectionArrowPalette);
|
||||
}
|
||||
else
|
||||
base.SelectTarget(self, order, manager);
|
||||
}
|
||||
|
||||
public override void Activate(Actor self, Order order, SupportPowerManager manager)
|
||||
{
|
||||
base.Activate(self, order, manager);
|
||||
SendAirstrike(self, order.Target.CenterPosition, order.ExtraData == uint.MaxValue, (int)order.ExtraData);
|
||||
SendAirstrike(self, order.Target.CenterPosition, !info.UseDirectionalTarget || order.ExtraData == uint.MaxValue, (int)order.ExtraData);
|
||||
}
|
||||
|
||||
public void SendAirstrike(Actor self, WPos target, bool randomize = true, int attackFacing = 0)
|
||||
|
||||
@@ -50,12 +50,21 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Amount of time (in ticks) to keep the camera alive while the passengers drop.")]
|
||||
public readonly int CameraRemoveDelay = 85;
|
||||
|
||||
[Desc("Enables the player directional targeting")]
|
||||
public readonly bool UseDirectionalTarget = false;
|
||||
|
||||
[Desc("Placeholder cursor animation for the target cursor when the real cursor is invisible.")]
|
||||
public readonly string TargetPlaceholderCursorAnimation = null;
|
||||
|
||||
[Desc("Palette for placeholder cursor animation.")]
|
||||
public readonly string TargetPlaceholderCursorPalette = "chrome";
|
||||
|
||||
[Desc("Animation used to render the direction arrows.")]
|
||||
public readonly string DirectionArrowAnimation = null;
|
||||
|
||||
[Desc("Palette for direction cursor animation.")]
|
||||
public readonly string DirectionArrowPalette = "chrome";
|
||||
|
||||
[Desc("Weapon range offset to apply during the beacon clock calculation.")]
|
||||
public readonly WDist BeaconDistanceOffset = WDist.FromCells(4);
|
||||
|
||||
@@ -73,19 +82,25 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
public override void SelectTarget(Actor self, string order, SupportPowerManager manager)
|
||||
{
|
||||
if (info.UseDirectionalTarget)
|
||||
{
|
||||
Game.Sound.PlayToPlayer(SoundType.UI, manager.Self.Owner, Info.SelectTargetSound);
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
|
||||
Info.SelectTargetSpeechNotification, self.Owner.Faction.InternalName);
|
||||
|
||||
self.World.OrderGenerator = new SelectDirectionalTarget(self.World, order, manager, Info.Cursor, info.TargetPlaceholderCursorAnimation, info.DirectionArrowAnimation);
|
||||
self.World.OrderGenerator = new SelectDirectionalTarget(self.World, order, manager, Info.Cursor,
|
||||
info.TargetPlaceholderCursorAnimation, info.DirectionArrowAnimation, info.TargetPlaceholderCursorPalette, info.DirectionArrowPalette);
|
||||
}
|
||||
else
|
||||
base.SelectTarget(self, order, manager);
|
||||
}
|
||||
|
||||
public override void Activate(Actor self, Order order, SupportPowerManager manager)
|
||||
{
|
||||
base.Activate(self, order, manager);
|
||||
|
||||
SendParatroopers(self, order.Target.CenterPosition, order.ExtraData == uint.MaxValue, (int)order.ExtraData);
|
||||
SendParatroopers(self, order.Target.CenterPosition, !info.UseDirectionalTarget || order.ExtraData == uint.MaxValue, (int)order.ExtraData);
|
||||
}
|
||||
|
||||
public Actor[] SendParatroopers(Actor self, WPos target, bool randomize = true, int dropFacing = 0)
|
||||
|
||||
@@ -22,6 +22,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly string order;
|
||||
readonly SupportPowerManager manager;
|
||||
readonly string cursor;
|
||||
readonly string targetPlaceholderCursorPalette;
|
||||
readonly string directionArrowPalette;
|
||||
readonly Animation targetCursor;
|
||||
|
||||
readonly string[] arrows = { "arrow-t", "arrow-tl", "arrow-l", "arrow-bl", "arrow-b", "arrow-br", "arrow-r", "arrow-tr" };
|
||||
@@ -35,11 +37,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Arrow currentArrow;
|
||||
|
||||
public SelectDirectionalTarget(World world, string order, SupportPowerManager manager, string cursor, string targetPlaceholderCursorAnimation,
|
||||
string directionArrowAnimation)
|
||||
string directionArrowAnimation, string targetPlaceholderCursorPalette, string directionArrowPalette)
|
||||
{
|
||||
this.order = order;
|
||||
this.manager = manager;
|
||||
this.cursor = cursor;
|
||||
this.targetPlaceholderCursorPalette = targetPlaceholderCursorPalette;
|
||||
this.directionArrowPalette = directionArrowPalette;
|
||||
|
||||
targetCursor = new Animation(world, targetPlaceholderCursorAnimation);
|
||||
targetCursor.PlayRepeating("cursor");
|
||||
@@ -116,13 +120,16 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!beginDrag)
|
||||
return Enumerable.Empty<IRenderable>();
|
||||
|
||||
var palette = wr.Palette("chrome");
|
||||
var targetPalette = wr.Palette(targetPlaceholderCursorPalette);
|
||||
var worldPx = wr.Viewport.ViewToWorldPx(location);
|
||||
var worldPos = wr.ProjectedPosition(worldPx);
|
||||
var renderables = new List<IRenderable>(targetCursor.Render(worldPos, WVec.Zero, -511, palette, 1 / wr.Viewport.Zoom));
|
||||
var renderables = new List<IRenderable>(targetCursor.Render(worldPos, WVec.Zero, -511, targetPalette, 1 / wr.Viewport.Zoom));
|
||||
|
||||
if (IsOutsideDragZone)
|
||||
renderables.Add(new SpriteRenderable(currentArrow.Sprite, worldPos, WVec.Zero, -511, palette, 1 / wr.Viewport.Zoom, true));
|
||||
{
|
||||
var directionPalette = wr.Palette(directionArrowPalette);
|
||||
renderables.Add(new SpriteRenderable(currentArrow.Sprite, worldPos, WVec.Zero, -511, directionPalette, 1 / wr.Viewport.Zoom, true));
|
||||
}
|
||||
|
||||
return renderables;
|
||||
}
|
||||
|
||||
@@ -628,6 +628,7 @@ HQ:
|
||||
ArrowSequence: arrow
|
||||
ClockSequence: clock
|
||||
CircleSequence: circles
|
||||
UseDirectionalTarget: True
|
||||
TargetPlaceholderCursorAnimation: airstriketarget
|
||||
DirectionArrowAnimation: airstrikedirection
|
||||
SupportPowerChargeBar:
|
||||
|
||||
@@ -1461,6 +1461,7 @@ AFLD:
|
||||
ArrowSequence: arrow
|
||||
ClockSequence: clock
|
||||
CircleSequence: circles
|
||||
UseDirectionalTarget: True
|
||||
TargetPlaceholderCursorAnimation: paratarget
|
||||
DirectionArrowAnimation: paradirection
|
||||
ParatroopersPower@paratroopers:
|
||||
@@ -1481,6 +1482,7 @@ AFLD:
|
||||
ArrowSequence: arrow
|
||||
ClockSequence: clock
|
||||
CircleSequence: circles
|
||||
UseDirectionalTarget: True
|
||||
TargetPlaceholderCursorAnimation: paratarget
|
||||
DirectionArrowAnimation: paradirection
|
||||
AirstrikePower@parabombs:
|
||||
@@ -1502,6 +1504,7 @@ AFLD:
|
||||
ArrowSequence: arrow
|
||||
ClockSequence: clock
|
||||
CircleSequence: circles
|
||||
UseDirectionalTarget: True
|
||||
TargetPlaceholderCursorAnimation: paratarget
|
||||
DirectionArrowAnimation: paradirection
|
||||
ProductionBar:
|
||||
|
||||
Reference in New Issue
Block a user