take lock while capture in progress
This commit is contained in:
@@ -40,7 +40,8 @@ namespace OpenRA.Mods.RA.Activities
|
||||
if (sellable != null && sellable.Selling)
|
||||
return NextActivity;
|
||||
|
||||
target.Trait<Capturable>().BeginCapture(target, self);
|
||||
if (!target.Trait<Capturable>().BeginCapture(target, self))
|
||||
return NextActivity;
|
||||
|
||||
var capturesInfo = self.Info.Traits.Get<CapturesInfo>();
|
||||
if (capturesInfo != null && capturesInfo.WastedAfterwards)
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
using System.Linq;
|
||||
using OpenRA.Effects;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
@@ -37,14 +38,19 @@ namespace OpenRA.Mods.RA
|
||||
this.Info = info;
|
||||
}
|
||||
|
||||
public void BeginCapture(Actor self, Actor captor)
|
||||
public bool BeginCapture(Actor self, Actor captor)
|
||||
{
|
||||
if (!self.Trait<Building>().Lock())
|
||||
return false;
|
||||
|
||||
CaptureProgressTime = 0;
|
||||
|
||||
this.Captor = captor;
|
||||
|
||||
if (self.Owner != self.World.WorldActor.Owner)
|
||||
self.ChangeOwner(self.World.WorldActor.Owner);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
@@ -67,6 +73,7 @@ namespace OpenRA.Mods.RA
|
||||
t.Trait.OnActorCaptured(t.Actor, self, Captor, self.Owner, Captor.Owner);
|
||||
|
||||
Captor = null;
|
||||
self.Trait<Building>().Unlock();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user