fix actor leak bug

This commit is contained in:
Bob
2010-09-09 01:47:26 +12:00
parent c3fa9f7aa8
commit f70a6aafb1
3 changed files with 39 additions and 43 deletions

View File

@@ -37,8 +37,13 @@ namespace OpenRA.Traits
Info = info;
}
public void DoProduction(Actor self, Actor newUnit, ExitInfo exitinfo)
public void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo)
{
var newUnit = self.World.CreateActor(false, producee.Name, new TypeDictionary
{
new OwnerInit( self.Owner ),
});
var exit = self.Location + exitinfo.ExitCell;
var spawn = self.CenterLocation + exitinfo.SpawnOffset;
@@ -86,21 +91,17 @@ namespace OpenRA.Traits
public virtual bool Produce( Actor self, ActorInfo producee )
{
var newUnit = self.World.CreateActor(false, producee.Name, new TypeDictionary
{
new OwnerInit( self.Owner ),
});
// Todo: remove assumption on Mobile;
// required for 3-arg CanEnterCell
var mobile = newUnit.Trait<Mobile>();
//var mobile = newUnit.Trait<Mobile>();
var mobileInfo = producee.Traits.Get<MobileInfo>();
// Pick a spawn/exit point pair
// Todo: Reorder in a synced random way
foreach (var s in self.Info.Traits.WithInterface<ExitInfo>())
if (mobile.CanEnterCell(self.Location + s.ExitCell,self,true))
if( Mobile.CanEnterCell( mobileInfo, self.World, self.Location + s.ExitCell,self,true ) )
{
DoProduction(self, newUnit, s);
DoProduction(self, producee, s);
return true;
}
return false;