#region Copyright & License Information /* * Copyright 2007-2010 The OpenRA Developers (see AUTHORS) * This file is part of OpenRA, which is free software. It is made * available to you under the terms of the GNU General Public License * as published by the Free Software Foundation. For more information, * see LICENSE. */ #endregion using System.Linq; using OpenRA.GameRules; using OpenRA.Traits; namespace OpenRA.Mods.RA { public class ProducesHelicoptersInfo : ProductionInfo { public override object Create(ActorInitializer init) { return new ProducesHelicopters(); } } class ProducesHelicopters : Production { // Hack around visibility bullshit in Production public override bool Produce( Actor self, ActorInfo producee ) { var location = CreationLocation( self, producee ); if( location == null || self.World.WorldActor.traits.Get().GetUnitsAt( location.Value ).Any() ) return false; var newUnit = self.World.CreateActor( producee.Name, location.Value, self.Owner ); newUnit.traits.Get().Facing = CreationFacing( self, newUnit ); ; var pi = self.Info.Traits.Get(); var rp = self.traits.GetOrDefault(); if( rp != null || pi.ExitOffset != null) { if( newUnit.traits.Contains() ) { if (pi.ExitOffset != null) newUnit.QueueActivity(new Activities.HeliFly(Util.CenterOfCell(ExitLocation( self, producee ).Value))); if (rp != null) newUnit.QueueActivity( new Activities.HeliFly( Util.CenterOfCell(rp.rallyPoint)) ); } } if (pi != null && pi.SpawnOffset != null) newUnit.CenterLocation = self.CenterLocation + new float2(pi.SpawnOffset[0], pi.SpawnOffset[1]); foreach (var t in self.traits.WithInterface()) t.UnitProduced(self, newUnit); Log.Write("debug", "{0} #{1} produced by {2} #{3}", newUnit.Info.Name, newUnit.ActorID, self.Info.Name, self.ActorID); return true; } } }