Add a CanDeploy check to Transform at FrameEndTask

This commit is contained in:
Gustas
2022-12-07 11:56:44 +02:00
committed by Matthias Mailänder
parent 43bb9e4302
commit 8a18c2e4b6

View File

@@ -66,15 +66,15 @@ namespace OpenRA.Mods.Common.Activities
// Wait forever
QueueChild(new WaitFor(() => false));
makeAnimation.Reverse(self, () => DoTransform(self));
makeAnimation.Reverse(self, () => DoTransform(self, transforms, makeAnimation));
return false;
}
DoTransform(self);
DoTransform(self, transforms, null);
return true;
}
void DoTransform(Actor self)
void DoTransform(Actor self, Transforms transforms, WithMakeAnimation makeAnimation)
{
// This activity may be buried as a child within one or more parents
// We need to consider the top-level activities when transferring orders to the new actor!
@@ -85,6 +85,20 @@ namespace OpenRA.Mods.Common.Activities
if (self.IsDead || self.WillDispose)
return;
// Prevent deployment in bogus locations
if (transforms != null && !transforms.CanDeploy())
{
if (!SkipMakeAnims && makeAnimation != null)
makeAnimation.Forward(self, () => { IsInterruptible = true; Cancel(self, true); });
else
{
IsInterruptible = true;
Cancel(self, true);
}
return;
}
foreach (var nt in self.TraitsImplementing<INotifyTransform>())
nt.OnTransform(self);