Skip to content

Commit

Permalink
PlayerProductionQueue -> ClassicProductionQueue.
Browse files Browse the repository at this point in the history
  • Loading branch information
pchote authored and chrisforbes committed Sep 17, 2010
1 parent fb90400 commit ad80388
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion OpenRA.Game/OpenRA.Game.csproj
Expand Up @@ -226,8 +226,8 @@
<Compile Include="Traits\ActorStance.cs" />
<Compile Include="Traits\Armor.cs" />
<Compile Include="Graphics\CursorProvider.cs" />
<Compile Include="Traits\Player\PlayerProductionQueue.cs" />
<Compile Include="Traits\Player\TechTree.cs" />
<Compile Include="Traits\Player\ClassicProductionQueue.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
Expand Down
Expand Up @@ -15,23 +15,22 @@

namespace OpenRA.Traits
{
public class PlayerProductionQueueInfo : ProductionQueueInfo, ITraitPrerequisite<TechTreeInfo>
public class ClassicProductionQueueInfo : ProductionQueueInfo, ITraitPrerequisite<TechTreeInfo>
{
public override object Create(ActorInitializer init) { return new PlayerProductionQueue(init.self, this); }
public override object Create(ActorInitializer init) { return new ClassicProductionQueue(init.self, this); }
}

public class PlayerProductionQueue : ProductionQueue
public class ClassicProductionQueue : ProductionQueue
{
public PlayerProductionQueue( Actor self, PlayerProductionQueueInfo info )
public ClassicProductionQueue( Actor self, ClassicProductionQueueInfo info )
: base(self, self, info as ProductionQueueInfo) {}

[Sync] bool QueueActive = true;
public override void Tick( Actor self )
{
if (self == self.Owner.PlayerActor)
QueueActive = self.World.Queries.OwnedBy[self.Owner].WithTrait<Production>()
.Where(x => x.Trait.Info.Produces.Contains(Info.Type))
.Any();
QueueActive = self.World.Queries.OwnedBy[self.Owner].WithTrait<Production>()
.Where(x => x.Trait.Info.Produces.Contains(Info.Type))
.Any();

base.Tick(self);
}
Expand All @@ -49,14 +48,13 @@ public override IEnumerable<ActorInfo> BuildableItems()

protected override void BuildUnit( string name )
{
// original ra behavior; queue lives on PlayerActor, need to find a production structure
// Find a production structure to build this actor
var producers = self.World.Queries.OwnedBy[self.Owner]
.WithTrait<Production>()
.Where(x => x.Trait.Info.Produces.Contains(Info.Type))
.OrderByDescending(x => x.Actor.IsPrimaryBuilding() ? 1 : 0 ) // prioritize the primary.
.ToArray();
.WithTrait<Production>()
.Where(x => x.Trait.Info.Produces.Contains(Info.Type))
.OrderByDescending(x => x.Actor.IsPrimaryBuilding() ? 1 : 0 ); // prioritize the primary.

if (producers.Length == 0)
if (producers.Count() == 0)
{
CancelProduction(name);
return;
Expand Down
12 changes: 6 additions & 6 deletions mods/ra/rules/system.yaml
@@ -1,26 +1,26 @@
Player:
TechTree:
PlayerProductionQueue@Building:
ClassicProductionQueue@Building:
Type: Building
BuildSpeed: .4
LowPowerSlowdown: 3
PlayerProductionQueue@Defense:
ClassicProductionQueue@Defense:
Type: Defense
BuildSpeed: .4
LowPowerSlowdown: 3
PlayerProductionQueue@Vehicle:
ClassicProductionQueue@Vehicle:
Type: Vehicle
BuildSpeed: .4
LowPowerSlowdown: 3
PlayerProductionQueue@Infantry:
ClassicProductionQueue@Infantry:
Type: Infantry
BuildSpeed: .4
LowPowerSlowdown: 3
PlayerProductionQueue@Ship:
ClassicProductionQueue@Ship:
Type: Ship
BuildSpeed: .4
LowPowerSlowdown: 3
PlayerProductionQueue@Plane:
ClassicProductionQueue@Plane:
Type: Plane
BuildSpeed: .4
LowPowerSlowdown: 3
Expand Down

0 comments on commit ad80388

Please sign in to comment.