Merge pull request #9987 from pchote/transforms
Check deploy location at the time of transform.
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using OpenRA.Activities;
|
||||||
using OpenRA.Mods.Common.Activities;
|
using OpenRA.Mods.Common.Activities;
|
||||||
using OpenRA.Mods.Common.Orders;
|
using OpenRA.Mods.Common.Orders;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
@@ -95,9 +96,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public void DeployTransform(bool queued)
|
public void DeployTransform(bool queued)
|
||||||
{
|
{
|
||||||
var building = self.TraitOrDefault<Building>();
|
if (!queued && !CanDeploy())
|
||||||
if (!CanDeploy() || (building != null && !building.Lock()))
|
|
||||||
{
|
{
|
||||||
|
// Only play the "Cannot deploy here" audio
|
||||||
|
// for non-queued orders
|
||||||
foreach (var s in info.NoTransformSounds)
|
foreach (var s in info.NoTransformSounds)
|
||||||
Game.Sound.PlayToPlayer(self.Owner, s);
|
Game.Sound.PlayToPlayer(self.Owner, s);
|
||||||
|
|
||||||
@@ -115,23 +117,31 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (self.Info.HasTraitInfo<AircraftInfo>())
|
if (self.Info.HasTraitInfo<AircraftInfo>())
|
||||||
self.QueueActivity(new HeliLand(self, true));
|
self.QueueActivity(new HeliLand(self, true));
|
||||||
|
|
||||||
foreach (var nt in self.TraitsImplementing<INotifyTransform>())
|
self.QueueActivity(new CallFunc(() =>
|
||||||
nt.BeforeTransform(self);
|
|
||||||
|
|
||||||
var transform = new Transform(self, info.IntoActor)
|
|
||||||
{
|
{
|
||||||
Offset = info.Offset,
|
// Prevent deployment in bogus locations
|
||||||
Facing = info.Facing,
|
var building = self.TraitOrDefault<Building>();
|
||||||
Sounds = info.TransformSounds,
|
if (!CanDeploy() || (building != null && !building.Lock()))
|
||||||
Notification = info.TransformNotification,
|
return;
|
||||||
Faction = faction
|
|
||||||
};
|
|
||||||
|
|
||||||
var makeAnimation = self.TraitOrDefault<WithMakeAnimation>();
|
foreach (var nt in self.TraitsImplementing<INotifyTransform>())
|
||||||
if (makeAnimation != null)
|
nt.BeforeTransform(self);
|
||||||
makeAnimation.Reverse(self, transform);
|
|
||||||
else
|
var transform = new Transform(self, info.IntoActor)
|
||||||
self.QueueActivity(transform);
|
{
|
||||||
|
Offset = info.Offset,
|
||||||
|
Facing = info.Facing,
|
||||||
|
Sounds = info.TransformSounds,
|
||||||
|
Notification = info.TransformNotification,
|
||||||
|
Faction = faction
|
||||||
|
};
|
||||||
|
|
||||||
|
var makeAnimation = self.TraitOrDefault<WithMakeAnimation>();
|
||||||
|
if (makeAnimation != null)
|
||||||
|
makeAnimation.Reverse(self, transform);
|
||||||
|
else
|
||||||
|
self.QueueActivity(transform);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResolveOrder(Actor self, Order order)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
|
|||||||
Reference in New Issue
Block a user