Keep selection on mcv deploy/undeploy. Bonus: build tab opens on mcv deploy
This commit is contained in:
@@ -18,7 +18,17 @@ namespace OpenRA
|
|||||||
public class Selection
|
public class Selection
|
||||||
{
|
{
|
||||||
List<Actor> actors = new List<Actor>();
|
List<Actor> actors = new List<Actor>();
|
||||||
|
public void Add(World w, Actor a)
|
||||||
|
{
|
||||||
|
actors.Add(a);
|
||||||
|
foreach (var ns in w.WorldActor.traits.WithInterface<INotifySelection>())
|
||||||
|
ns.SelectionChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Contains(Actor a)
|
||||||
|
{
|
||||||
|
return actors.AsEnumerable().Contains(a);
|
||||||
|
}
|
||||||
public void Combine(World world, IEnumerable<Actor> newSelection, bool isCombine, bool isClick)
|
public void Combine(World world, IEnumerable<Actor> newSelection, bool isCombine, bool isClick)
|
||||||
{
|
{
|
||||||
var oldSelection = actors.AsEnumerable();
|
var oldSelection = actors.AsEnumerable();
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA.Activities
|
namespace OpenRA.Mods.RA.Activities
|
||||||
@@ -36,14 +38,19 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
{
|
{
|
||||||
if (isCanceled) return NextActivity;
|
if (isCanceled) return NextActivity;
|
||||||
|
|
||||||
self.World.AddFrameEndTask(_ =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
|
var selected = Game.controller.selection.Contains(self);
|
||||||
|
|
||||||
self.World.Remove(self);
|
self.World.Remove(self);
|
||||||
foreach (var s in sounds)
|
foreach (var s in sounds)
|
||||||
Sound.PlayToPlayer(self.Owner, s, self.CenterLocation);
|
Sound.PlayToPlayer(self.Owner, s, self.CenterLocation);
|
||||||
|
|
||||||
var a = self.World.CreateActor(actor, self.Location + offset, self.Owner);
|
var a = self.World.CreateActor(actor, self.Location + offset, self.Owner);
|
||||||
a.Health = GetHealthToTransfer(self, a, transferPercentage);
|
a.Health = GetHealthToTransfer(self, a, transferPercentage);
|
||||||
|
|
||||||
|
if (selected)
|
||||||
|
Game.controller.selection.Add(w, a);
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,17 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
public IActivity NextActivity { get; set; }
|
public IActivity NextActivity { get; set; }
|
||||||
bool started;
|
bool started;
|
||||||
|
|
||||||
void DoUndeploy(World w,Actor self)
|
void DoUndeploy(World w, Actor self)
|
||||||
{
|
{
|
||||||
|
var selected = Game.controller.selection.Contains(self);
|
||||||
w.Remove(self);
|
w.Remove(self);
|
||||||
|
|
||||||
var mcv = w.CreateActor("mcv", self.Location + new int2(1, 1), self.Owner);
|
var mcv = w.CreateActor("mcv", self.Location + new int2(1, 1), self.Owner);
|
||||||
mcv.Health = TransformIntoActor.GetHealthToTransfer(self, mcv, true);
|
mcv.Health = TransformIntoActor.GetHealthToTransfer(self, mcv, true);
|
||||||
mcv.traits.Get<Unit>().Facing = 96;
|
mcv.traits.Get<Unit>().Facing = 96;
|
||||||
|
|
||||||
|
if (selected)
|
||||||
|
Game.controller.selection.Add(w, mcv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActivity Tick(Actor self)
|
public IActivity Tick(Actor self)
|
||||||
|
|||||||
Reference in New Issue
Block a user