Produce D2k carryalls at the edge of the map
This commit is contained in:
@@ -73,6 +73,7 @@
|
|||||||
<Compile Include="SpriteLoaders\R8Loader.cs" />
|
<Compile Include="SpriteLoaders\R8Loader.cs" />
|
||||||
<Compile Include="Traits\AttackSwallow.cs" />
|
<Compile Include="Traits\AttackSwallow.cs" />
|
||||||
<Compile Include="Traits\AutoCarryall.cs" />
|
<Compile Include="Traits\AutoCarryall.cs" />
|
||||||
|
<Compile Include="Traits\Buildings\ProductionFromMapEdge.cs" />
|
||||||
<Compile Include="Traits\Buildings\DamagedWithoutFoundation.cs" />
|
<Compile Include="Traits\Buildings\DamagedWithoutFoundation.cs" />
|
||||||
<Compile Include="Traits\Buildings\LaysTerrain.cs" />
|
<Compile Include="Traits\Buildings\LaysTerrain.cs" />
|
||||||
<Compile Include="Traits\Carryable.cs" />
|
<Compile Include="Traits\Carryable.cs" />
|
||||||
|
|||||||
82
OpenRA.Mods.D2k/Traits/Buildings/ProductionFromMapEdge.cs
Normal file
82
OpenRA.Mods.D2k/Traits/Buildings/ProductionFromMapEdge.cs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
#region Copyright & License Information
|
||||||
|
/*
|
||||||
|
* Copyright 2007-2015 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 COPYING.
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Drawing;
|
||||||
|
using OpenRA.Activities;
|
||||||
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Primitives;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
|
namespace OpenRA.Mods.D2k.Traits
|
||||||
|
{
|
||||||
|
[Desc("Produce a unit on the closest map edge cell and move into the world.")]
|
||||||
|
class ProductionFromMapEdgeInfo : ProductionInfo
|
||||||
|
{
|
||||||
|
public override object Create(ActorInitializer init) { return new ProductionFromMapEdge(init, this); }
|
||||||
|
}
|
||||||
|
|
||||||
|
class ProductionFromMapEdge : Production
|
||||||
|
{
|
||||||
|
public ProductionFromMapEdge(ActorInitializer init, ProductionInfo info)
|
||||||
|
: base(init, info) { }
|
||||||
|
|
||||||
|
public override bool Produce(Actor self, ActorInfo producee, string raceVariant)
|
||||||
|
{
|
||||||
|
var location = self.World.Map.ChooseClosestEdgeCell(self.Location);
|
||||||
|
var pos = self.World.Map.CenterOfCell(location);
|
||||||
|
|
||||||
|
// If aircraft, spawn at cruise altitude
|
||||||
|
var aircraftInfo = producee.Traits.GetOrDefault<AircraftInfo>();
|
||||||
|
if (aircraftInfo != null)
|
||||||
|
pos += new WVec(0, 0, aircraftInfo.CruiseAltitude.Range);
|
||||||
|
|
||||||
|
var initialFacing = self.World.Map.FacingBetween(location, self.Location, 0);
|
||||||
|
|
||||||
|
self.World.AddFrameEndTask(w =>
|
||||||
|
{
|
||||||
|
var td = new TypeDictionary
|
||||||
|
{
|
||||||
|
new OwnerInit(self.Owner),
|
||||||
|
new LocationInit(location),
|
||||||
|
new CenterPositionInit(pos),
|
||||||
|
new FacingInit(initialFacing)
|
||||||
|
};
|
||||||
|
|
||||||
|
if (raceVariant != null)
|
||||||
|
td.Add(new RaceInit(raceVariant));
|
||||||
|
|
||||||
|
var newUnit = self.World.CreateActor(producee.Name, td);
|
||||||
|
|
||||||
|
var move = newUnit.TraitOrDefault<IMove>();
|
||||||
|
if (move != null)
|
||||||
|
newUnit.QueueActivity(move.MoveIntoWorld(newUnit, self.Location));
|
||||||
|
|
||||||
|
newUnit.SetTargetLine(Target.FromCell(self.World, self.Location), Color.Green, false);
|
||||||
|
|
||||||
|
if (!self.IsDead)
|
||||||
|
foreach (var t in self.TraitsImplementing<INotifyProduction>())
|
||||||
|
t.UnitProduced(self, newUnit, self.Location);
|
||||||
|
|
||||||
|
var notifyOthers = self.World.ActorsWithTrait<INotifyOtherProduction>();
|
||||||
|
foreach (var notify in notifyOthers)
|
||||||
|
notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit);
|
||||||
|
|
||||||
|
var bi = newUnit.Info.Traits.GetOrDefault<BuildableInfo>();
|
||||||
|
if (bi != null && bi.InitialActivity != null)
|
||||||
|
newUnit.QueueActivity(Game.CreateObject<Activity>(bi.InitialActivity));
|
||||||
|
|
||||||
|
foreach (var t in newUnit.TraitsImplementing<INotifyBuildComplete>())
|
||||||
|
t.BuildingComplete(newUnit);
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -668,7 +668,7 @@ hightech:
|
|||||||
Tooltip:
|
Tooltip:
|
||||||
Name: High Tech Facility
|
Name: High Tech Facility
|
||||||
Description: Unlocks advanced technology
|
Description: Unlocks advanced technology
|
||||||
Production:
|
ProductionFromMapEdge:
|
||||||
Produces: Aircraft
|
Produces: Aircraft
|
||||||
Exit:
|
Exit:
|
||||||
SpawnOffset: 0,0,728
|
SpawnOffset: 0,0,728
|
||||||
|
|||||||
Reference in New Issue
Block a user