Skip to content

Commit c4c1579

Browse files
committed
Merge remote-tracking branch 'darkademic/dev'
2 parents b10c1cf + 2ce35d8 commit c4c1579

491 files changed

Lines changed: 62262 additions & 3154 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#region Copyright & License Information
2+
/*
3+
* Copyright (c) The OpenRA Developers and Contributors
4+
* This file is part of OpenRA, which is free software. It is made
5+
* available to you under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation, either version 3 of
7+
* the License, or (at your option) any later version. For more
8+
* information, see COPYING.
9+
*/
10+
#endregion
11+
12+
using OpenRA.Mods.Common.Activities;
13+
using OpenRA.Mods.Common.Traits;
14+
using OpenRA.Primitives;
15+
using OpenRA.Traits;
16+
17+
namespace OpenRA.Mods.CA.Activities
18+
{
19+
public class MassRideTransport : Enter
20+
{
21+
readonly Passenger passenger;
22+
23+
Actor enterActor;
24+
Cargo enterCargo;
25+
Aircraft enterAircraft;
26+
27+
public MassRideTransport(Actor self, in Target target, Color? targetLineColor)
28+
: base(self, target, targetLineColor)
29+
{
30+
passenger = self.Trait<Passenger>();
31+
}
32+
33+
protected override bool TryStartEnter(Actor self, Actor targetActor)
34+
{
35+
enterActor = targetActor;
36+
enterCargo = targetActor.TraitOrDefault<Cargo>();
37+
enterAircraft = targetActor.TraitOrDefault<Aircraft>();
38+
39+
// Make sure we can still enter the transport
40+
// (but not before, because this may stop the actor in the middle of nowhere)
41+
if (enterCargo == null || !passenger.Reserve(self, enterCargo))
42+
{
43+
Cancel(self, true);
44+
return false;
45+
}
46+
47+
if (enterAircraft != null && !enterAircraft.AtLandAltitude)
48+
return false;
49+
50+
return true;
51+
}
52+
53+
protected override void OnEnterComplete(Actor self, Actor targetActor)
54+
{
55+
self.World.AddFrameEndTask(w =>
56+
{
57+
if (self.IsDead)
58+
return;
59+
60+
// Make sure the target hasn't changed while entering
61+
// OnEnterComplete is only called if targetActor is alive
62+
if (targetActor != enterActor)
63+
return;
64+
65+
if (!enterCargo.CanLoad(self))
66+
return;
67+
68+
foreach (var inl in targetActor.TraitsImplementing<INotifyLoadCargo>())
69+
inl.Loading(self);
70+
71+
enterCargo.Load(enterActor, self);
72+
w.Remove(self);
73+
});
74+
}
75+
76+
protected override void OnLastRun(Actor self)
77+
{
78+
passenger.Unreserve(self);
79+
}
80+
81+
public override void Cancel(Actor self, bool keepQueue = false)
82+
{
83+
passenger.Unreserve(self);
84+
85+
base.Cancel(self, keepQueue);
86+
}
87+
}
88+
}

OpenRA.Mods.CA/Activities/TargetedLeap.cs

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,35 @@ public TargetedLeap(Actor self, CPos targetCell, TargetedLeapAbility ability, Mo
5959

6060
protected override void OnFirstRun(Actor self)
6161
{
62+
if (!ability.CanLeap)
63+
{
64+
canceling = true;
65+
return;
66+
}
67+
6268
originPos = self.CenterPosition;
6369

6470
var cell = ChooseBestDestinationCell(self, targetCell);
6571
if (cell.HasValue)
72+
{
6673
destinationCell = cell.Value;
74+
}
6775
else
76+
{
6877
canceling = true;
78+
return;
79+
}
6980

7081
var subCell = mobile.GetAvailableSubCell(destinationCell);
7182
if (subCell != SubCell.Invalid)
83+
{
7284
destinationSubCell = subCell;
85+
}
86+
else
87+
{
88+
canceling = true;
89+
return;
90+
}
7391

7492
destinationPos = self.World.Map.CenterOfSubCell(destinationCell, destinationSubCell);
7593
length = Math.Max((originPos - destinationPos).Length / speed, 1);
@@ -145,22 +163,28 @@ public override IEnumerable<Target> GetTargets(Actor self)
145163

146164
CPos? ChooseBestDestinationCell(Actor self, CPos destination)
147165
{
148-
var restrictTo = self.World.Map.FindTilesInCircle(self.Location, ability.Info.MaxDistance);
149-
destination = restrictTo.MinBy(x => (x - destination).LengthSquared);
150-
166+
var maxDistance = ability.Info.MaxDistance;
167+
var restrictTo = self.World.Map.FindTilesInCircle(self.Location, maxDistance).ToList();
151168
var pos = self.Trait<IPositionable>();
152-
if (pos.CanEnterCell(destination)
153-
&& self.Owner.Shroud.IsExplored(destination))
154-
return destination;
155169

156-
foreach (var tile in self.World.Map.FindTilesInCircle(destination, ability.Info.MaxDistance))
170+
// Check if the original destination is within MaxDistance and is valid
171+
if ((destination - self.Location).LengthSquared <= maxDistance * maxDistance &&
172+
restrictTo.Contains(destination) &&
173+
pos.CanEnterCell(destination) &&
174+
self.Owner.Shroud.IsExplored(destination))
157175
{
158-
if (self.Owner.Shroud.IsExplored(tile)
159-
&& (restrictTo == null || (restrictTo != null && restrictTo.Contains(tile)))
160-
&& pos.CanEnterCell(tile))
161-
return tile;
176+
return destination;
162177
}
163178

179+
// Find the closest valid cell within MaxDistance
180+
var closestValidCell = restrictTo
181+
.Where(tile => pos.CanEnterCell(tile) && self.Owner.Shroud.IsExplored(tile))
182+
.OrderBy(tile => (tile - destination).LengthSquared)
183+
.FirstOrDefault();
184+
185+
if (closestValidCell != default)
186+
return closestValidCell;
187+
164188
return null;
165189
}
166190
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#region Copyright & License Information
2+
/**
3+
* Copyright (c) The OpenRA Combined Arms Developers (see CREDITS).
4+
* This file is part of OpenRA Combined Arms, which is free software.
5+
* It is made available to you under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation, either version 3 of the License,
7+
* or (at your option) any later version. For more information, see COPYING.
8+
*/
9+
#endregion
10+
11+
using OpenRA.Mods.CA.Traits;
12+
using OpenRA.Mods.Common.Orders;
13+
using OpenRA.Traits;
14+
15+
namespace OpenRA.Mods.CA.Orders
16+
{
17+
class MassEnterCargoOrderTargeter : UnitOrderTargeter
18+
{
19+
public const string Id = "MassEnterCargo";
20+
21+
private string cursor;
22+
23+
public MassEnterCargoOrderTargeter(string cursor)
24+
: base(Id, 6, cursor, false, true)
25+
{
26+
this.cursor = cursor;
27+
}
28+
29+
public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor)
30+
{
31+
cursor = null;
32+
33+
if (!target.Info.HasTraitInfo<UnitConverterInfo>())
34+
return false;
35+
36+
if (target.Trait<UnitConverter>().IsTraitDisabled)
37+
return false;
38+
39+
if (self.Owner != target.Owner)
40+
return false;
41+
42+
cursor = this.cursor;
43+
return true;
44+
}
45+
46+
public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor)
47+
{
48+
return false;
49+
}
50+
}
51+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#region Copyright & License Information
2+
/**
3+
* Copyright (c) The OpenRA Combined Arms Developers (see CREDITS).
4+
* This file is part of OpenRA Combined Arms, which is free software.
5+
* It is made available to you under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation, either version 3 of the License,
7+
* or (at your option) any later version. For more information, see COPYING.
8+
*/
9+
#endregion
10+
11+
using System.Linq;
12+
using OpenRA.Mods.CA.Traits;
13+
using OpenRA.Mods.Common.Traits;
14+
using OpenRA.Scripting;
15+
using OpenRA.Traits;
16+
17+
namespace OpenRA.Mods.CA.Scripting
18+
{
19+
[ScriptPropertyGroup("Support Powers")]
20+
public class AirstrikeCAProperties : ScriptActorProperties, Requires<AirstrikePowerCAInfo>
21+
{
22+
readonly AirstrikePowerCA ap;
23+
24+
public AirstrikeCAProperties(ScriptContext context, Actor self)
25+
: base(context, self)
26+
{
27+
ap = self.TraitsImplementing<AirstrikePowerCA>().First();
28+
}
29+
30+
[Desc("Activate the actor's Airstrike Power. Returns the aircraft that will attack.")]
31+
public Actor[] TargetAirstrike(WPos target, WAngle? facing = null)
32+
{
33+
return ap.SendAirstrike(Self, target, facing);
34+
}
35+
}
36+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#region Copyright & License Information
2+
/**
3+
* Copyright (c) The OpenRA Combined Arms Developers (see CREDITS).
4+
* This file is part of OpenRA Combined Arms, which is free software.
5+
* It is made available to you under the terms of the GNU General Public License
6+
* as published by the Free Software Foundation, either version 3 of the License,
7+
* or (at your option) any later version. For more information, see COPYING.
8+
*/
9+
#endregion
10+
11+
using OpenRA.Mods.CA.Traits;
12+
using OpenRA.Scripting;
13+
using OpenRA.Traits;
14+
15+
namespace OpenRA.Mods.CA.Scripting
16+
{
17+
[ScriptPropertyGroup("PortableChronoCA")]
18+
public class PortableChronoCAProperties : ScriptActorProperties, Requires<PortableChronoCAInfo>
19+
{
20+
readonly PortableChronoCA PortableChrono;
21+
22+
public PortableChronoCAProperties(ScriptContext context, Actor self)
23+
: base(context, self)
24+
{
25+
PortableChrono = self.Trait<PortableChronoCA>();
26+
}
27+
28+
[ScriptActorPropertyActivity]
29+
[Desc("Queue portable chrono teleport.")]
30+
public void PortableChronoTeleport(CPos targetCell, bool queued = false)
31+
{
32+
var target = Target.FromCell(Self.World, targetCell);
33+
PortableChrono.ResolveOrder(Self, new Order("PortableChronoTeleport", Self, target, queued));
34+
}
35+
}
36+
}

OpenRA.Mods.CA/Scripting/UtilsCAGlobal.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,13 @@ public string FormatTimeForGameSpeed(int ticks)
4444
{
4545
return WidgetUtils.FormatTime(ticks, world.Timestep);
4646
}
47+
48+
[Desc("Returns hotkey for a specified hotkey name.")]
49+
public string Hotkey(string hotkeyName)
50+
{
51+
var reference = Game.ModData.Hotkeys[hotkeyName];
52+
var hotkey = reference.GetValue();
53+
return hotkey.DisplayString();
54+
}
4755
}
4856
}

0 commit comments

Comments
 (0)