Skip to content

Commit

Permalink
Pass PortableChrono instead of PortableChronoInfo to PortableChronoOr…
Browse files Browse the repository at this point in the history
…derGenerator.
  • Loading branch information
MustaphaTR authored and abcdefg30 committed Apr 17, 2022
1 parent 648c56b commit 9de8d88
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions OpenRA.Mods.Cnc/Traits/PortableChrono.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public Order IssueOrder(Actor self, IOrderTargeter order, in Target target, bool
{
// HACK: Switch the global order generator instead of actually issuing an order
if (CanTeleport)
self.World.OrderGenerator = new PortableChronoOrderGenerator(self, Info);
self.World.OrderGenerator = new PortableChronoOrderGenerator(self, this);

// HACK: We need to issue a fake order to stop the game complaining about the bodge above
return new Order(order.OrderID, self, Target.Invalid, queued);
Expand Down Expand Up @@ -202,12 +202,14 @@ public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifier
class PortableChronoOrderGenerator : OrderGenerator
{
readonly Actor self;
readonly PortableChrono portableChrono;
readonly PortableChronoInfo info;

public PortableChronoOrderGenerator(Actor self, PortableChronoInfo info)
public PortableChronoOrderGenerator(Actor self, PortableChrono portableChrono)
{
this.self = self;
this.info = info;
this.portableChrono = portableChrono;
info = portableChrono.Info;
}

protected override IEnumerable<Order> OrderInner(World world, CPos cell, int2 worldPixel, MouseInput mi)
Expand Down Expand Up @@ -241,12 +243,12 @@ protected override IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr,
if (!self.IsInWorld || self.Owner != self.World.LocalPlayer)
yield break;

if (!self.Trait<PortableChrono>().Info.HasDistanceLimit)
if (!info.HasDistanceLimit)
yield break;

yield return new RangeCircleAnnotationRenderable(
self.CenterPosition,
WDist.FromCells(self.Trait<PortableChrono>().Info.MaxDistance),
WDist.FromCells(info.MaxDistance),
0,
info.CircleColor,
info.CircleWidth,
Expand All @@ -257,7 +259,7 @@ protected override IEnumerable<IRenderable> RenderAnnotations(WorldRenderer wr,
protected override string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
if (self.IsInWorld && self.Location != cell
&& self.Trait<PortableChrono>().CanTeleport && self.Owner.Shroud.IsExplored(cell))
&& portableChrono.CanTeleport && self.Owner.Shroud.IsExplored(cell))
return info.TargetCursor;
else
return info.TargetBlockedCursor;
Expand Down

0 comments on commit 9de8d88

Please sign in to comment.