take lock while capture in progress

This commit is contained in:
Chris Forbes
2012-09-13 06:52:27 +12:00
parent 952e277d35
commit c253e59c57
2 changed files with 10 additions and 2 deletions

View File

@@ -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)

View File

@@ -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();
});
}
}