Skip to content

Commit

Permalink
Fix and polish all ra production structures; remove some obsoleted Pr…
Browse files Browse the repository at this point in the history
…oduction subclasses
  • Loading branch information
pchote committed Aug 3, 2010
1 parent 8e82f6f commit 40b16e3
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 142 deletions.
8 changes: 4 additions & 4 deletions OpenRA.Game/Traits/Production.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ProductionInfo : ITraitInfo

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)
{
if (info.SpawnOffsets == null || info.ExitCells == null)
Expand All @@ -38,7 +38,7 @@ public Production(ProductionInfo info)
throw new System.InvalidOperationException("SpawnOffset, ExitCells length mismatch");

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)
Expand Down Expand Up @@ -100,8 +100,8 @@ public virtual bool Produce( Actor self, ActorInfo producee )
// Todo: Reorder in a synced random way
foreach (var s in Spawns)
{
var exit = self.Location + s.Value;
var spawn = self.CenterLocation + s.Key;
var exit = self.Location + s.Second;
var spawn = self.CenterLocation + s.First;
if (mobile.CanEnterCell(exit,self,true))
{
DoProduction(self, newUnit, exit, spawn);
Expand Down
4 changes: 2 additions & 2 deletions OpenRA.Mods.Cnc/ProductionAirdrop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public override bool Produce( Actor self, ActorInfo producee )


// Assume a single exit point for simplicity
var spawn = self.CenterLocation + Spawns.First().Key;
var exit = self.Location + Spawns.First().Value;
var spawn = self.CenterLocation + Spawns.First().First;
var exit = self.Location + Spawns.First().Second;

owner.World.AddFrameEndTask(w =>
{
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.RA/Activities/HeliReturn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public IActivity Tick(Actor self)
self.traits.Get<Helicopter>().reservation = res.Reserve(self);

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(
new HeliFly(dest.CenterLocation + offset),
Expand Down
4 changes: 3 additions & 1 deletion OpenRA.Mods.RA/Aircraft.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public class Aircraft : IMove, IFacing, IOccupySpace

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.Altitude = init.Contains<AltitudeInit>() ? init.Get<AltitudeInit,int>() : 0;
Info = info;
Expand Down
2 changes: 1 addition & 1 deletion OpenRA.Mods.RA/Helicopter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void ResolveOrder(Actor self, Order order)
reservation = res.Reserve(self);

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)
self.World.AddFrameEndTask(w =>
Expand Down
2 changes: 0 additions & 2 deletions OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@
<Compile Include="SupportPowers\ParatroopersPower.cs" />
<Compile Include="Passenger.cs" />
<Compile Include="Plane.cs" />
<Compile Include="ProductionSurround.cs" />
<Compile Include="Render\RenderBuildingCharge.cs" />
<Compile Include="Render\RenderBuildingOre.cs" />
<Compile Include="Render\RenderBuildingWall.cs" />
Expand Down Expand Up @@ -215,7 +214,6 @@
<Compile Include="Invulnerable.cs" />
<Compile Include="ReplaceWithActor.cs" />
<Compile Include="OreRefineryDockAction.cs" />
<Compile Include="ProducesHelicopters.cs" />
<Compile Include="StoresOre.cs" />
<Compile Include="PaletteFromCurrentTheatre.cs" />
<Compile Include="Widgets\Delegates\OrderButtonsChromeDelegate.cs" />
Expand Down
74 changes: 0 additions & 74 deletions OpenRA.Mods.RA/ProducesHelicopters.cs

This file was deleted.

51 changes: 0 additions & 51 deletions OpenRA.Mods.RA/ProductionSurround.cs

This file was deleted.

32 changes: 31 additions & 1 deletion OpenRA.Mods.RA/ReservableProduction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@


using OpenRA.Traits;
using System.Linq;
using OpenRA.FileFormats;

namespace OpenRA.Mods.RA
{
Expand All @@ -29,7 +31,35 @@ public override bool Produce(Actor self, ActorInfo producee)
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;
}
}
}
4 changes: 2 additions & 2 deletions mods/cnc/structures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ HPAD:
RevealsShroud:
Range: 5
Bib:
ProducesHelicopters:
SpawnOffsets: 0,-4
ReservableProduction:
SpawnOffsets: 0,-6
ExitCells: 0,0
Produces: Plane
BelowUnits:
Expand Down
21 changes: 18 additions & 3 deletions mods/ra/structures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ SPEN:
Armor: light
RevealsShroud:
Range: 4
ProductionSurround:
Production:
SpawnOffsets: 0,-5, 0,-5, 0,0, 0,0
ExitCells: -1,2, 3,2, 0,0, 2,0
Produces: Ship
IronCurtainable:
-EmitInfantryOnSell:
Expand Down Expand Up @@ -109,8 +111,10 @@ SYRD:
Armor: light
RevealsShroud:
Range: 4
ProductionSurround:
Production:
Produces: Ship
SpawnOffsets: -25,23, 26,23, -22,-25, 23,-25
ExitCells: 0,2, 2,2, 0,0, 2,0
IronCurtainable:
-EmitInfantryOnSell:
RepairsUnits:
Expand Down Expand Up @@ -444,6 +448,8 @@ WEAP:
RenderWarFactory:
RallyPoint:
Production:
SpawnOffsets: 5,0
ExitCells: 1,1
Produces: Vehicle
IronCurtainable:

Expand Down Expand Up @@ -558,7 +564,8 @@ HPAD:
Range: 5
Bib:
ReservableProduction:
SpawnOffset: 0,-4
SpawnOffsets: 0,-6
ExitCells: 0,0
Produces: Plane
BelowUnits:
Reservable:
Expand Down Expand Up @@ -586,6 +593,8 @@ AFLD:
Range: 7
ReservableProduction:
Produces: Plane
SpawnOffsets: 0,4
ExitCells: 1,1
BelowUnits:
Reservable:
IronCurtainable:
Expand Down Expand Up @@ -685,6 +694,8 @@ BARR:
Bib:
RallyPoint:
Production:
SpawnOffsets: -4,19, -17,15
ExitCells: 0,2, 0,2
Produces: Infantry
IronCurtainable:

Expand Down Expand Up @@ -713,6 +724,8 @@ TENT:
RallyPoint:
Production:
Produces: Infantry
SpawnOffsets: -1,19, -17,15
ExitCells: 0,2, 0,2
IronCurtainable:

KENN:
Expand All @@ -734,6 +747,8 @@ KENN:
Range: 4
RallyPoint:
Production:
SpawnOffsets: 0,0
ExitCells: 0,0
Produces: Infantry
IronCurtainable:
-EmitInfantryOnSell:
Expand Down

0 comments on commit 40b16e3

Please sign in to comment.