Fix and polish all ra production structures; remove some obsoleted Production subclasses

This commit is contained in:
Paul Chote
2010-08-03 18:29:32 +12:00
parent 8e82f6fa1a
commit 40b16e33ba
11 changed files with 62 additions and 142 deletions

View File

@@ -10,6 +10,8 @@
using OpenRA.Traits;
using System.Linq;
using OpenRA.FileFormats;
namespace OpenRA.Mods.RA
{
@@ -29,7 +31,35 @@ namespace OpenRA.Mods.RA
if (Reservable.IsReserved(self))
return false;
return base.Produce(self, producee);
// Pick a spawn/exit point
// Todo: Reorder in a synced random way
foreach (var s in Spawns)
{
var exit = self.Location + s.Second;
var spawn = self.CenterLocation + s.First;
if (!self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt( exit ).Any())
{
var newUnit = self.World.CreateActor( producee.Name, new TypeDictionary
{
new LocationInit( exit ),
new OwnerInit( self.Owner ),
});
newUnit.CenterLocation = spawn;
var rp = self.traits.GetOrDefault<RallyPoint>();
if( rp != null )
{
newUnit.QueueActivity( new Activities.HeliFly( Util.CenterOfCell(rp.rallyPoint)) );
}
foreach (var t in self.traits.WithInterface<INotifyProduction>())
t.UnitProduced(self, newUnit, exit);
Log.Write("debug", "{0} #{1} produced by {2} #{3}", newUnit.Info.Name, newUnit.ActorID, self.Info.Name, self.ActorID);
return true;
}
}
return false;
}
}
}