PlayerProductionQueue -> ClassicProductionQueue.

This commit is contained in:
Paul Chote
2010-09-17 23:59:24 +12:00
committed by Chris Forbes
parent fb90400524
commit ad8038867d
3 changed files with 19 additions and 21 deletions

View File

@@ -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">

View File

@@ -15,23 +15,22 @@ using OpenRA.FileFormats;
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);
}
@@ -49,14 +48,13 @@ namespace OpenRA.Traits
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;

View File

@@ -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