Fix and polish all ra production structures; remove some obsoleted Production subclasses
This commit is contained in:
@@ -28,7 +28,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public class Production : IIssueOrder, IResolveOrder, ITags, IOrderCursor
|
public class Production : IIssueOrder, IResolveOrder, ITags, IOrderCursor
|
||||||
{
|
{
|
||||||
public readonly Dictionary<float2, int2> Spawns = new Dictionary<float2, int2>();
|
public readonly List<Pair<float2, int2>> Spawns = new List<Pair<float2, int2>>();
|
||||||
public Production(ProductionInfo info)
|
public Production(ProductionInfo info)
|
||||||
{
|
{
|
||||||
if (info.SpawnOffsets == null || info.ExitCells == null)
|
if (info.SpawnOffsets == null || info.ExitCells == null)
|
||||||
@@ -38,7 +38,7 @@ namespace OpenRA.Traits
|
|||||||
throw new System.InvalidOperationException("SpawnOffset, ExitCells length mismatch");
|
throw new System.InvalidOperationException("SpawnOffset, ExitCells length mismatch");
|
||||||
|
|
||||||
for (int i = 0; i < info.ExitCells.Length; i+=2)
|
for (int i = 0; i < info.ExitCells.Length; i+=2)
|
||||||
Spawns.Add(new float2(info.SpawnOffsets[i],info.SpawnOffsets[i+1]), new int2(info.ExitCells[i], info.ExitCells[i+1]));
|
Spawns.Add(Pair.New(new float2(info.SpawnOffsets[i],info.SpawnOffsets[i+1]), new int2(info.ExitCells[i], info.ExitCells[i+1])));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoProduction(Actor self, Actor newUnit, int2 exit, float2 spawn)
|
public void DoProduction(Actor self, Actor newUnit, int2 exit, float2 spawn)
|
||||||
@@ -100,8 +100,8 @@ namespace OpenRA.Traits
|
|||||||
// Todo: Reorder in a synced random way
|
// Todo: Reorder in a synced random way
|
||||||
foreach (var s in Spawns)
|
foreach (var s in Spawns)
|
||||||
{
|
{
|
||||||
var exit = self.Location + s.Value;
|
var exit = self.Location + s.Second;
|
||||||
var spawn = self.CenterLocation + s.Key;
|
var spawn = self.CenterLocation + s.First;
|
||||||
if (mobile.CanEnterCell(exit,self,true))
|
if (mobile.CanEnterCell(exit,self,true))
|
||||||
{
|
{
|
||||||
DoProduction(self, newUnit, exit, spawn);
|
DoProduction(self, newUnit, exit, spawn);
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ namespace OpenRA.Mods.Cnc
|
|||||||
|
|
||||||
|
|
||||||
// Assume a single exit point for simplicity
|
// Assume a single exit point for simplicity
|
||||||
var spawn = self.CenterLocation + Spawns.First().Key;
|
var spawn = self.CenterLocation + Spawns.First().First;
|
||||||
var exit = self.Location + Spawns.First().Value;
|
var exit = self.Location + Spawns.First().Second;
|
||||||
|
|
||||||
owner.World.AddFrameEndTask(w =>
|
owner.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
self.traits.Get<Helicopter>().reservation = res.Reserve(self);
|
self.traits.Get<Helicopter>().reservation = res.Reserve(self);
|
||||||
|
|
||||||
var pi = dest.traits.Get<Production>();
|
var pi = dest.traits.Get<Production>();
|
||||||
var offset = pi != null ? pi.Spawns.First().Key : float2.Zero;
|
var offset = pi != null ? pi.Spawns.First().First : float2.Zero;
|
||||||
|
|
||||||
return Util.SequenceActivities(
|
return Util.SequenceActivities(
|
||||||
new HeliFly(dest.CenterLocation + offset),
|
new HeliFly(dest.CenterLocation + offset),
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public Aircraft( ActorInitializer init , AircraftInfo info)
|
public Aircraft( ActorInitializer init , AircraftInfo info)
|
||||||
{
|
{
|
||||||
this.Location = init.Get<LocationInit,int2>();
|
if (init.Contains<LocationInit>())
|
||||||
|
this.Location = init.Get<LocationInit,int2>();
|
||||||
|
|
||||||
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : info.InitialFacing;
|
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit,int>() : info.InitialFacing;
|
||||||
this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit,int>() : 0;
|
this.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit,int>() : 0;
|
||||||
Info = info;
|
Info = info;
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ namespace OpenRA.Mods.RA
|
|||||||
reservation = res.Reserve(self);
|
reservation = res.Reserve(self);
|
||||||
|
|
||||||
var pi = order.TargetActor.traits.Get<Production>();
|
var pi = order.TargetActor.traits.Get<Production>();
|
||||||
var offset = pi != null ? pi.Spawns.First().Key : float2.Zero;
|
var offset = pi != null ? pi.Spawns.First().First : float2.Zero;
|
||||||
|
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
|
|||||||
@@ -162,7 +162,6 @@
|
|||||||
<Compile Include="SupportPowers\ParatroopersPower.cs" />
|
<Compile Include="SupportPowers\ParatroopersPower.cs" />
|
||||||
<Compile Include="Passenger.cs" />
|
<Compile Include="Passenger.cs" />
|
||||||
<Compile Include="Plane.cs" />
|
<Compile Include="Plane.cs" />
|
||||||
<Compile Include="ProductionSurround.cs" />
|
|
||||||
<Compile Include="Render\RenderBuildingCharge.cs" />
|
<Compile Include="Render\RenderBuildingCharge.cs" />
|
||||||
<Compile Include="Render\RenderBuildingOre.cs" />
|
<Compile Include="Render\RenderBuildingOre.cs" />
|
||||||
<Compile Include="Render\RenderBuildingWall.cs" />
|
<Compile Include="Render\RenderBuildingWall.cs" />
|
||||||
@@ -215,7 +214,6 @@
|
|||||||
<Compile Include="Invulnerable.cs" />
|
<Compile Include="Invulnerable.cs" />
|
||||||
<Compile Include="ReplaceWithActor.cs" />
|
<Compile Include="ReplaceWithActor.cs" />
|
||||||
<Compile Include="OreRefineryDockAction.cs" />
|
<Compile Include="OreRefineryDockAction.cs" />
|
||||||
<Compile Include="ProducesHelicopters.cs" />
|
|
||||||
<Compile Include="StoresOre.cs" />
|
<Compile Include="StoresOre.cs" />
|
||||||
<Compile Include="PaletteFromCurrentTheatre.cs" />
|
<Compile Include="PaletteFromCurrentTheatre.cs" />
|
||||||
<Compile Include="Widgets\Delegates\OrderButtonsChromeDelegate.cs" />
|
<Compile Include="Widgets\Delegates\OrderButtonsChromeDelegate.cs" />
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
#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;
|
|
||||||
using OpenRA.FileFormats;
|
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
|
||||||
{
|
|
||||||
public class ProducesHelicoptersInfo : ProductionInfo
|
|
||||||
{
|
|
||||||
public override object Create(ActorInitializer init) { return new ProducesHelicopters(this); }
|
|
||||||
}
|
|
||||||
|
|
||||||
class ProducesHelicopters : Production
|
|
||||||
{
|
|
||||||
public ProducesHelicopters(ProducesHelicoptersInfo info) : base(info) {}
|
|
||||||
|
|
||||||
|
|
||||||
// Hack around visibility bullshit in Production
|
|
||||||
public override bool Produce( Actor self, ActorInfo producee )
|
|
||||||
{
|
|
||||||
// Pick an exit that we can move to
|
|
||||||
var exit = int2.Zero;
|
|
||||||
var spawn = float2.Zero;
|
|
||||||
var success = false;
|
|
||||||
|
|
||||||
// Pick a spawn/exit point
|
|
||||||
// Todo: Reorder in a synced random way
|
|
||||||
foreach (var s in Spawns)
|
|
||||||
{
|
|
||||||
exit = self.Location + s.Value;
|
|
||||||
spawn = self.CenterLocation + s.Key;
|
|
||||||
if (!self.World.WorldActor.traits.Get<UnitInfluence>().GetUnitsAt( exit ).Any())
|
|
||||||
{
|
|
||||||
success = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!success)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Todo: Once Helicopter supports it, update UIM if its docked/landed
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
#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
|
|
||||||
{
|
|
||||||
class ProductionSurroundInfo : ProductionInfo
|
|
||||||
{
|
|
||||||
public override object Create(ActorInitializer init) { return new ProductionSurround(this); }
|
|
||||||
}
|
|
||||||
|
|
||||||
class ProductionSurround : Production
|
|
||||||
{
|
|
||||||
public ProductionSurround(ProductionSurroundInfo info) : base(info) {}
|
|
||||||
|
|
||||||
static int2? FindAdjacentTile(Actor self, bool waterBound)
|
|
||||||
{
|
|
||||||
var tiles = Footprint.Tiles(self);
|
|
||||||
var min = tiles.Aggregate(int2.Min) - new int2(1, 1);
|
|
||||||
var max = tiles.Aggregate(int2.Max) + new int2(1, 1);
|
|
||||||
|
|
||||||
for (var j = min.Y; j <= max.Y; j++)
|
|
||||||
for (var i = min.X; i <= max.X; i++)
|
|
||||||
if (self.World.IsCellBuildable(new int2(i, j), waterBound))
|
|
||||||
return new int2(i, j);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
public override int2? CreationLocation(Actor self, ActorInfo producee)
|
|
||||||
{
|
|
||||||
return FindAdjacentTile(self, self.Info.Traits.Get<BuildingInfo>().WaterBound);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override int CreationFacing(Actor self, Actor newUnit)
|
|
||||||
{
|
|
||||||
return Util.GetFacing(newUnit.CenterLocation - self.CenterLocation, 128);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
|
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using System.Linq;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
@@ -29,7 +31,35 @@ namespace OpenRA.Mods.RA
|
|||||||
if (Reservable.IsReserved(self))
|
if (Reservable.IsReserved(self))
|
||||||
return false;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,8 +342,8 @@ HPAD:
|
|||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 5
|
Range: 5
|
||||||
Bib:
|
Bib:
|
||||||
ProducesHelicopters:
|
ReservableProduction:
|
||||||
SpawnOffsets: 0,-4
|
SpawnOffsets: 0,-6
|
||||||
ExitCells: 0,0
|
ExitCells: 0,0
|
||||||
Produces: Plane
|
Produces: Plane
|
||||||
BelowUnits:
|
BelowUnits:
|
||||||
|
|||||||
@@ -77,7 +77,9 @@ SPEN:
|
|||||||
Armor: light
|
Armor: light
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 4
|
Range: 4
|
||||||
ProductionSurround:
|
Production:
|
||||||
|
SpawnOffsets: 0,-5, 0,-5, 0,0, 0,0
|
||||||
|
ExitCells: -1,2, 3,2, 0,0, 2,0
|
||||||
Produces: Ship
|
Produces: Ship
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
-EmitInfantryOnSell:
|
-EmitInfantryOnSell:
|
||||||
@@ -109,8 +111,10 @@ SYRD:
|
|||||||
Armor: light
|
Armor: light
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 4
|
Range: 4
|
||||||
ProductionSurround:
|
Production:
|
||||||
Produces: Ship
|
Produces: Ship
|
||||||
|
SpawnOffsets: -25,23, 26,23, -22,-25, 23,-25
|
||||||
|
ExitCells: 0,2, 2,2, 0,0, 2,0
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
-EmitInfantryOnSell:
|
-EmitInfantryOnSell:
|
||||||
RepairsUnits:
|
RepairsUnits:
|
||||||
@@ -444,6 +448,8 @@ WEAP:
|
|||||||
RenderWarFactory:
|
RenderWarFactory:
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Production:
|
Production:
|
||||||
|
SpawnOffsets: 5,0
|
||||||
|
ExitCells: 1,1
|
||||||
Produces: Vehicle
|
Produces: Vehicle
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
|
|
||||||
@@ -558,7 +564,8 @@ HPAD:
|
|||||||
Range: 5
|
Range: 5
|
||||||
Bib:
|
Bib:
|
||||||
ReservableProduction:
|
ReservableProduction:
|
||||||
SpawnOffset: 0,-4
|
SpawnOffsets: 0,-6
|
||||||
|
ExitCells: 0,0
|
||||||
Produces: Plane
|
Produces: Plane
|
||||||
BelowUnits:
|
BelowUnits:
|
||||||
Reservable:
|
Reservable:
|
||||||
@@ -586,6 +593,8 @@ AFLD:
|
|||||||
Range: 7
|
Range: 7
|
||||||
ReservableProduction:
|
ReservableProduction:
|
||||||
Produces: Plane
|
Produces: Plane
|
||||||
|
SpawnOffsets: 0,4
|
||||||
|
ExitCells: 1,1
|
||||||
BelowUnits:
|
BelowUnits:
|
||||||
Reservable:
|
Reservable:
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
@@ -685,6 +694,8 @@ BARR:
|
|||||||
Bib:
|
Bib:
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Production:
|
Production:
|
||||||
|
SpawnOffsets: -4,19, -17,15
|
||||||
|
ExitCells: 0,2, 0,2
|
||||||
Produces: Infantry
|
Produces: Infantry
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
|
|
||||||
@@ -713,6 +724,8 @@ TENT:
|
|||||||
RallyPoint:
|
RallyPoint:
|
||||||
Production:
|
Production:
|
||||||
Produces: Infantry
|
Produces: Infantry
|
||||||
|
SpawnOffsets: -1,19, -17,15
|
||||||
|
ExitCells: 0,2, 0,2
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
|
|
||||||
KENN:
|
KENN:
|
||||||
@@ -734,6 +747,8 @@ KENN:
|
|||||||
Range: 4
|
Range: 4
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
Production:
|
Production:
|
||||||
|
SpawnOffsets: 0,0
|
||||||
|
ExitCells: 0,0
|
||||||
Produces: Infantry
|
Produces: Infantry
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
-EmitInfantryOnSell:
|
-EmitInfantryOnSell:
|
||||||
|
|||||||
Reference in New Issue
Block a user