Set the closest production to Primary when force-targeting rallypoints.
This commit is contained in:
@@ -48,6 +48,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
[Desc("The speech notification to play when setting a new rallypoint.")]
|
[Desc("The speech notification to play when setting a new rallypoint.")]
|
||||||
public readonly string Notification = null;
|
public readonly string Notification = null;
|
||||||
|
|
||||||
|
[Desc("Used to group equivalent actors to allow force-setting a rallypoint (e.g. for Primary production).")]
|
||||||
|
public readonly string ForceSetType = null;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new RallyPoint(init.Self, this); }
|
public override object Create(ActorInitializer init) { return new RallyPoint(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +92,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public IEnumerable<IOrderTargeter> Orders
|
public IEnumerable<IOrderTargeter> Orders
|
||||||
{
|
{
|
||||||
get { yield return new RallyPointOrderTargeter(Info.Cursor); }
|
get { yield return new RallyPointOrderTargeter(Info); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool queued)
|
||||||
@@ -126,11 +129,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
class RallyPointOrderTargeter : IOrderTargeter
|
class RallyPointOrderTargeter : IOrderTargeter
|
||||||
{
|
{
|
||||||
readonly string cursor;
|
readonly RallyPointInfo info;
|
||||||
|
|
||||||
public RallyPointOrderTargeter(string cursor)
|
public RallyPointOrderTargeter(RallyPointInfo info)
|
||||||
{
|
{
|
||||||
this.cursor = cursor;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string OrderID => "SetRallyPoint";
|
public string OrderID => "SetRallyPoint";
|
||||||
@@ -149,14 +152,18 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var location = self.World.Map.CellContaining(target.CenterPosition);
|
var location = self.World.Map.CellContaining(target.CenterPosition);
|
||||||
if (self.World.Map.Contains(location))
|
if (self.World.Map.Contains(location))
|
||||||
{
|
{
|
||||||
cursor = this.cursor;
|
cursor = info.Cursor;
|
||||||
|
|
||||||
// Notify force-set 'RallyPoint' order watchers with Ctrl and only if this is the only building of its type selected
|
// Notify force-set 'RallyPoint' order watchers with Ctrl
|
||||||
if (modifiers.HasModifier(TargetModifiers.ForceAttack))
|
if (modifiers.HasModifier(TargetModifiers.ForceAttack) && !string.IsNullOrEmpty(info.ForceSetType))
|
||||||
{
|
{
|
||||||
var selfName = self.Info.Name;
|
var closest = self.World.Selection.Actors
|
||||||
if (!self.World.Selection.Actors.Any(a => a.Info.Name == selfName && a.ActorID != self.ActorID))
|
.Select<Actor, (Actor Actor, RallyPoint RallyPoint)>(a => (a, a.TraitOrDefault<RallyPoint>()))
|
||||||
ForceSet = true;
|
.Where(x => x.RallyPoint != null && x.RallyPoint.Info.ForceSetType == info.ForceSetType)
|
||||||
|
.OrderBy(x => (location - x.Actor.Location).LengthSquared)
|
||||||
|
.FirstOrDefault().Actor;
|
||||||
|
|
||||||
|
ForceSet = closest == self;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ barracks:
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 3c768
|
Range: 3c768
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ForceSetType: Infantry
|
||||||
Exit@1:
|
Exit@1:
|
||||||
SpawnOffset: 352,576,0
|
SpawnOffset: 352,576,0
|
||||||
ExitCell: 0,2
|
ExitCell: 0,2
|
||||||
@@ -392,6 +393,7 @@ light_factory:
|
|||||||
Queues: Vehicle
|
Queues: Vehicle
|
||||||
Sequence: production-welding
|
Sequence: production-welding
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ForceSetType: Vehicle
|
||||||
Exit@1:
|
Exit@1:
|
||||||
SpawnOffset: 544,-224,0
|
SpawnOffset: 544,-224,0
|
||||||
ExitCell: 2,1
|
ExitCell: 2,1
|
||||||
@@ -459,6 +461,7 @@ heavy_factory:
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 4c768
|
Range: 4c768
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ForceSetType: Armor
|
||||||
Exit@1:
|
Exit@1:
|
||||||
SpawnOffset: 256,192,0
|
SpawnOffset: 256,192,0
|
||||||
ExitCell: 0,2
|
ExitCell: 0,2
|
||||||
@@ -595,6 +598,7 @@ starport:
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 3c768
|
Range: 3c768
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ForceSetType: Starport
|
||||||
Exit@1:
|
Exit@1:
|
||||||
SpawnOffset: 0,-480,0
|
SpawnOffset: 0,-480,0
|
||||||
ExitCell: 2,2
|
ExitCell: 2,2
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ SPEN:
|
|||||||
FinishRepairingNotification: UnitRepaired
|
FinishRepairingNotification: UnitRepaired
|
||||||
PlayerExperience: 15
|
PlayerExperience: 15
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ForceSetType: Ship
|
||||||
ProductionBar:
|
ProductionBar:
|
||||||
ProductionType: Ship
|
ProductionType: Ship
|
||||||
Power:
|
Power:
|
||||||
@@ -322,6 +323,7 @@ SYRD:
|
|||||||
FinishRepairingNotification: UnitRepaired
|
FinishRepairingNotification: UnitRepaired
|
||||||
PlayerExperience: 15
|
PlayerExperience: 15
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ForceSetType: Ship
|
||||||
ProductionBar:
|
ProductionBar:
|
||||||
ProductionType: Ship
|
ProductionType: Ship
|
||||||
Power:
|
Power:
|
||||||
@@ -1030,6 +1032,7 @@ WEAP:
|
|||||||
RequiresCondition: !build-incomplete
|
RequiresCondition: !build-incomplete
|
||||||
Sequence: build-top
|
Sequence: build-top
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ForceSetType: Vehicle
|
||||||
Exit@1:
|
Exit@1:
|
||||||
RequiresCondition: !being-captured
|
RequiresCondition: !being-captured
|
||||||
SpawnOffset: 213,-128,0
|
SpawnOffset: 213,-128,0
|
||||||
@@ -1386,6 +1389,7 @@ HPAD:
|
|||||||
ExitCell: 0,0
|
ExitCell: 0,0
|
||||||
Facing: 896
|
Facing: 896
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ForceSetType: Helicopter
|
||||||
Production:
|
Production:
|
||||||
Produces: Aircraft, Helicopter
|
Produces: Aircraft, Helicopter
|
||||||
Reservable:
|
Reservable:
|
||||||
@@ -1467,6 +1471,7 @@ AFLD:
|
|||||||
ExitCell: 1,1
|
ExitCell: 1,1
|
||||||
Facing: 768
|
Facing: 768
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ForceSetType: Plane
|
||||||
Production:
|
Production:
|
||||||
Produces: Aircraft, Plane
|
Produces: Aircraft, Plane
|
||||||
Reservable:
|
Reservable:
|
||||||
@@ -1732,6 +1737,7 @@ BARR:
|
|||||||
Range: 4c0
|
Range: 4c0
|
||||||
WithBuildingBib:
|
WithBuildingBib:
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ForceSetType: Infantry
|
||||||
Exit@1:
|
Exit@1:
|
||||||
RequiresCondition: !being-captured
|
RequiresCondition: !being-captured
|
||||||
SpawnOffset: -170,810,0
|
SpawnOffset: -170,810,0
|
||||||
@@ -1807,6 +1813,7 @@ KENN:
|
|||||||
WithBuildingBib:
|
WithBuildingBib:
|
||||||
HasMinibib: True
|
HasMinibib: True
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ForceSetType: Dog
|
||||||
Exit@0:
|
Exit@0:
|
||||||
RequiresCondition: !being-captured
|
RequiresCondition: !being-captured
|
||||||
SpawnOffset: -280,400,0
|
SpawnOffset: -280,400,0
|
||||||
@@ -1893,6 +1900,7 @@ TENT:
|
|||||||
Range: 4c0
|
Range: 4c0
|
||||||
WithBuildingBib:
|
WithBuildingBib:
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ForceSetType: Infantry
|
||||||
Exit@1:
|
Exit@1:
|
||||||
RequiresCondition: !being-captured
|
RequiresCondition: !being-captured
|
||||||
SpawnOffset: -42,810,0
|
SpawnOffset: -42,810,0
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ GAPILE:
|
|||||||
Palette: mouse
|
Palette: mouse
|
||||||
IsPlayerPalette: false
|
IsPlayerPalette: false
|
||||||
LineWidth: 2
|
LineWidth: 2
|
||||||
|
ForceSetType: Infantry
|
||||||
Exit@1:
|
Exit@1:
|
||||||
SpawnOffset: -512,768,0
|
SpawnOffset: -512,768,0
|
||||||
ExitCell: 1,2
|
ExitCell: 1,2
|
||||||
@@ -226,6 +227,7 @@ GAWEAP:
|
|||||||
Palette: mouse
|
Palette: mouse
|
||||||
IsPlayerPalette: false
|
IsPlayerPalette: false
|
||||||
LineWidth: 2
|
LineWidth: 2
|
||||||
|
ForceSetType: Vehicle
|
||||||
Exit@1:
|
Exit@1:
|
||||||
SpawnOffset: -384,-384,0
|
SpawnOffset: -384,-384,0
|
||||||
ExitCell: 3,1
|
ExitCell: 3,1
|
||||||
@@ -303,6 +305,7 @@ GAHPAD:
|
|||||||
Palette: mouse
|
Palette: mouse
|
||||||
IsPlayerPalette: false
|
IsPlayerPalette: false
|
||||||
LineWidth: 2
|
LineWidth: 2
|
||||||
|
ForceSetType: Air
|
||||||
Production:
|
Production:
|
||||||
Produces: Air
|
Produces: Air
|
||||||
PauseOnCondition: empdisable
|
PauseOnCondition: empdisable
|
||||||
|
|||||||
@@ -159,6 +159,7 @@ NAHAND:
|
|||||||
Palette: mouse
|
Palette: mouse
|
||||||
IsPlayerPalette: false
|
IsPlayerPalette: false
|
||||||
LineWidth: 2
|
LineWidth: 2
|
||||||
|
ForceSetType: Infantry
|
||||||
Production:
|
Production:
|
||||||
Produces: Infantry
|
Produces: Infantry
|
||||||
PauseOnCondition: empdisable
|
PauseOnCondition: empdisable
|
||||||
@@ -205,6 +206,7 @@ NAWEAP:
|
|||||||
Palette: mouse
|
Palette: mouse
|
||||||
IsPlayerPalette: false
|
IsPlayerPalette: false
|
||||||
LineWidth: 2
|
LineWidth: 2
|
||||||
|
ForceSetType: Vehicle
|
||||||
Exit@1:
|
Exit@1:
|
||||||
SpawnOffset: -384,-384,0
|
SpawnOffset: -384,-384,0
|
||||||
ExitCell: 3,1
|
ExitCell: 3,1
|
||||||
@@ -267,6 +269,7 @@ NAHPAD:
|
|||||||
Palette: mouse
|
Palette: mouse
|
||||||
IsPlayerPalette: false
|
IsPlayerPalette: false
|
||||||
LineWidth: 2
|
LineWidth: 2
|
||||||
|
ForceSetType: Air
|
||||||
Production:
|
Production:
|
||||||
Produces: Air
|
Produces: Air
|
||||||
PauseOnCondition: empdisable
|
PauseOnCondition: empdisable
|
||||||
|
|||||||
Reference in New Issue
Block a user