Split Locomotor trait from Mobile

Add GrantConditionOn*Layer traits

This allows to
- drop some booleans from Locomotor
- drop a good part of the subterranean- and jumpjet-specific code/hacks from Mobile
- grant more than 1 condition per layer type (via multiple traits)
- easily add more traits of this kind for other layers
This commit is contained in:
reaperrr
2018-03-14 20:51:16 +01:00
committed by abcdefg30
parent f453d9c148
commit 81343926b6
29 changed files with 813 additions and 475 deletions

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Activities
readonly Harvester harv;
readonly HarvesterInfo harvInfo;
readonly Mobile mobile;
readonly MobileInfo mobileInfo;
readonly LocomotorInfo locomotorInfo;
readonly ResourceClaimLayer claimLayer;
readonly IPathFinder pathFinder;
readonly DomainIndex domainIndex;
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Activities
harv = self.Trait<Harvester>();
harvInfo = self.Info.TraitInfo<HarvesterInfo>();
mobile = self.Trait<Mobile>();
mobileInfo = self.Info.TraitInfo<MobileInfo>();
locomotorInfo = mobile.Info.LocomotorInfo;
claimLayer = self.World.WorldActor.Trait<ResourceClaimLayer>();
pathFinder = self.World.WorldActor.Trait<IPathFinder>();
domainIndex = self.World.WorldActor.Trait<DomainIndex>();
@@ -126,10 +126,10 @@ namespace OpenRA.Mods.Common.Activities
var searchRadiusSquared = searchRadius * searchRadius;
// Find any harvestable resources:
var passable = (uint)mobileInfo.GetMovementClass(self.World.Map.Rules.TileSet);
var passable = (uint)locomotorInfo.GetMovementClass(self.World.Map.Rules.TileSet);
List<CPos> path;
using (var search = PathSearch.Search(self.World, mobileInfo, self, true, loc =>
domainIndex.IsPassable(self.Location, loc, mobileInfo, passable) && harv.CanHarvestCell(self, loc) && claimLayer.CanClaimCell(self, loc))
using (var search = PathSearch.Search(self.World, locomotorInfo, self, true, loc =>
domainIndex.IsPassable(self.Location, loc, locomotorInfo, passable) && harv.CanHarvestCell(self, loc) && claimLayer.CanClaimCell(self, loc))
.WithCustomCost(loc =>
{
if ((avoidCell.HasValue && loc == avoidCell.Value) ||