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")]
|
[Desc("Amount of time to keep the camera alive after the aircraft have finished attacking")]
|
||||||
public readonly int CameraRemoveDelay = 25;
|
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.")]
|
[Desc("Placeholder cursor animation for the target cursor when the real cursor is invisible.")]
|
||||||
public readonly string TargetPlaceholderCursorAnimation = null;
|
public readonly string TargetPlaceholderCursorAnimation = null;
|
||||||
|
|
||||||
|
[Desc("Palette for placeholder cursor animation.")]
|
||||||
|
public readonly string TargetPlaceholderCursorPalette = "chrome";
|
||||||
|
|
||||||
[Desc("Animation used to render the direction arrows.")]
|
[Desc("Animation used to render the direction arrows.")]
|
||||||
public readonly string DirectionArrowAnimation = null;
|
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")]
|
[Desc("Weapon range offset to apply during the beacon clock calculation")]
|
||||||
public readonly WDist BeaconDistanceOffset = WDist.FromCells(6);
|
public readonly WDist BeaconDistanceOffset = WDist.FromCells(6);
|
||||||
|
|
||||||
@@ -60,17 +69,23 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public override void SelectTarget(Actor self, string order, SupportPowerManager manager)
|
public override void SelectTarget(Actor self, string order, SupportPowerManager manager)
|
||||||
{
|
{
|
||||||
Game.Sound.PlayToPlayer(SoundType.UI, manager.Self.Owner, Info.SelectTargetSound);
|
if (info.UseDirectionalTarget)
|
||||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
|
{
|
||||||
Info.SelectTargetSpeechNotification, self.Owner.Faction.InternalName);
|
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)
|
public override void Activate(Actor self, Order order, SupportPowerManager manager)
|
||||||
{
|
{
|
||||||
base.Activate(self, order, 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)
|
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.")]
|
[Desc("Amount of time (in ticks) to keep the camera alive while the passengers drop.")]
|
||||||
public readonly int CameraRemoveDelay = 85;
|
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.")]
|
[Desc("Placeholder cursor animation for the target cursor when the real cursor is invisible.")]
|
||||||
public readonly string TargetPlaceholderCursorAnimation = null;
|
public readonly string TargetPlaceholderCursorAnimation = null;
|
||||||
|
|
||||||
|
[Desc("Palette for placeholder cursor animation.")]
|
||||||
|
public readonly string TargetPlaceholderCursorPalette = "chrome";
|
||||||
|
|
||||||
[Desc("Animation used to render the direction arrows.")]
|
[Desc("Animation used to render the direction arrows.")]
|
||||||
public readonly string DirectionArrowAnimation = null;
|
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.")]
|
[Desc("Weapon range offset to apply during the beacon clock calculation.")]
|
||||||
public readonly WDist BeaconDistanceOffset = WDist.FromCells(4);
|
public readonly WDist BeaconDistanceOffset = WDist.FromCells(4);
|
||||||
|
|
||||||
@@ -74,18 +83,24 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public override void SelectTarget(Actor self, string order, SupportPowerManager manager)
|
public override void SelectTarget(Actor self, string order, SupportPowerManager manager)
|
||||||
{
|
{
|
||||||
Game.Sound.PlayToPlayer(SoundType.UI, manager.Self.Owner, Info.SelectTargetSound);
|
if (info.UseDirectionalTarget)
|
||||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
|
{
|
||||||
Info.SelectTargetSpeechNotification, self.Owner.Faction.InternalName);
|
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)
|
public override void Activate(Actor self, Order order, SupportPowerManager manager)
|
||||||
{
|
{
|
||||||
base.Activate(self, order, 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)
|
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 string order;
|
||||||
readonly SupportPowerManager manager;
|
readonly SupportPowerManager manager;
|
||||||
readonly string cursor;
|
readonly string cursor;
|
||||||
|
readonly string targetPlaceholderCursorPalette;
|
||||||
|
readonly string directionArrowPalette;
|
||||||
readonly Animation targetCursor;
|
readonly Animation targetCursor;
|
||||||
|
|
||||||
readonly string[] arrows = { "arrow-t", "arrow-tl", "arrow-l", "arrow-bl", "arrow-b", "arrow-br", "arrow-r", "arrow-tr" };
|
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;
|
Arrow currentArrow;
|
||||||
|
|
||||||
public SelectDirectionalTarget(World world, string order, SupportPowerManager manager, string cursor, string targetPlaceholderCursorAnimation,
|
public SelectDirectionalTarget(World world, string order, SupportPowerManager manager, string cursor, string targetPlaceholderCursorAnimation,
|
||||||
string directionArrowAnimation)
|
string directionArrowAnimation, string targetPlaceholderCursorPalette, string directionArrowPalette)
|
||||||
{
|
{
|
||||||
this.order = order;
|
this.order = order;
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
this.cursor = cursor;
|
this.cursor = cursor;
|
||||||
|
this.targetPlaceholderCursorPalette = targetPlaceholderCursorPalette;
|
||||||
|
this.directionArrowPalette = directionArrowPalette;
|
||||||
|
|
||||||
targetCursor = new Animation(world, targetPlaceholderCursorAnimation);
|
targetCursor = new Animation(world, targetPlaceholderCursorAnimation);
|
||||||
targetCursor.PlayRepeating("cursor");
|
targetCursor.PlayRepeating("cursor");
|
||||||
@@ -116,13 +120,16 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (!beginDrag)
|
if (!beginDrag)
|
||||||
return Enumerable.Empty<IRenderable>();
|
return Enumerable.Empty<IRenderable>();
|
||||||
|
|
||||||
var palette = wr.Palette("chrome");
|
var targetPalette = wr.Palette(targetPlaceholderCursorPalette);
|
||||||
var worldPx = wr.Viewport.ViewToWorldPx(location);
|
var worldPx = wr.Viewport.ViewToWorldPx(location);
|
||||||
var worldPos = wr.ProjectedPosition(worldPx);
|
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)
|
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;
|
return renderables;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -628,6 +628,7 @@ HQ:
|
|||||||
ArrowSequence: arrow
|
ArrowSequence: arrow
|
||||||
ClockSequence: clock
|
ClockSequence: clock
|
||||||
CircleSequence: circles
|
CircleSequence: circles
|
||||||
|
UseDirectionalTarget: True
|
||||||
TargetPlaceholderCursorAnimation: airstriketarget
|
TargetPlaceholderCursorAnimation: airstriketarget
|
||||||
DirectionArrowAnimation: airstrikedirection
|
DirectionArrowAnimation: airstrikedirection
|
||||||
SupportPowerChargeBar:
|
SupportPowerChargeBar:
|
||||||
|
|||||||
@@ -1461,6 +1461,7 @@ AFLD:
|
|||||||
ArrowSequence: arrow
|
ArrowSequence: arrow
|
||||||
ClockSequence: clock
|
ClockSequence: clock
|
||||||
CircleSequence: circles
|
CircleSequence: circles
|
||||||
|
UseDirectionalTarget: True
|
||||||
TargetPlaceholderCursorAnimation: paratarget
|
TargetPlaceholderCursorAnimation: paratarget
|
||||||
DirectionArrowAnimation: paradirection
|
DirectionArrowAnimation: paradirection
|
||||||
ParatroopersPower@paratroopers:
|
ParatroopersPower@paratroopers:
|
||||||
@@ -1481,6 +1482,7 @@ AFLD:
|
|||||||
ArrowSequence: arrow
|
ArrowSequence: arrow
|
||||||
ClockSequence: clock
|
ClockSequence: clock
|
||||||
CircleSequence: circles
|
CircleSequence: circles
|
||||||
|
UseDirectionalTarget: True
|
||||||
TargetPlaceholderCursorAnimation: paratarget
|
TargetPlaceholderCursorAnimation: paratarget
|
||||||
DirectionArrowAnimation: paradirection
|
DirectionArrowAnimation: paradirection
|
||||||
AirstrikePower@parabombs:
|
AirstrikePower@parabombs:
|
||||||
@@ -1502,6 +1504,7 @@ AFLD:
|
|||||||
ArrowSequence: arrow
|
ArrowSequence: arrow
|
||||||
ClockSequence: clock
|
ClockSequence: clock
|
||||||
CircleSequence: circles
|
CircleSequence: circles
|
||||||
|
UseDirectionalTarget: True
|
||||||
TargetPlaceholderCursorAnimation: paratarget
|
TargetPlaceholderCursorAnimation: paratarget
|
||||||
DirectionArrowAnimation: paradirection
|
DirectionArrowAnimation: paradirection
|
||||||
ProductionBar:
|
ProductionBar:
|
||||||
|
|||||||
Reference in New Issue
Block a user