Allow Harvester to define the number of harvestable facings.

This commit is contained in:
Paul Chote
2013-06-22 18:52:51 +12:00
parent 0424b56af1
commit 0029cb8aec
2 changed files with 11 additions and 1 deletions

View File

@@ -146,6 +146,7 @@ namespace OpenRA.Mods.RA.Activities
}
var harv = self.Trait<Harvester>();
var harvInfo = self.Info.Traits.Get<HarvesterInfo>();
harv.LastHarvestedCell = self.Location;
if (harv.IsFull)
@@ -155,6 +156,15 @@ namespace OpenRA.Mods.RA.Activities
return NextActivity;
}
// Turn to one of the harvestable facings
if (harvInfo.HarvestFacings != 0)
{
var facing = self.Trait<IFacing>().Facing;
var desired = Util.QuantizeFacing(facing, harvInfo.HarvestFacings) * (256 / harvInfo.HarvestFacings);
if (desired != facing)
return Util.SequenceActivities(new Turn(desired), this);
}
var resLayer = self.World.WorldActor.Trait<ResourceLayer>();
var resource = resLayer.Harvest(self.Location);
if (resource == null)
@@ -169,7 +179,6 @@ namespace OpenRA.Mods.RA.Activities
foreach (var t in self.TraitsImplementing<INotifyHarvest>())
t.Harvested(self, resource);
var harvInfo = self.Info.Traits.Get<HarvesterInfo>();
return Util.SequenceActivities(new Wait(harvInfo.LoadTicksPerBale), this);
}
}

View File

@@ -24,6 +24,7 @@ namespace OpenRA.Mods.RA
public readonly int LoadTicksPerBale = 4;
public readonly int UnloadTicksPerBale = 4;
public readonly int PipCount = 7;
public readonly int HarvestFacings = 0;
public readonly string[] Resources = { };
public readonly decimal FullyLoadedSpeed = .85m;
/// <summary>