Merge pull request #5807 from Mailaender/building-influence-reslayer
Fixed resources growing on building bibs and behind trees
This commit is contained in:
@@ -159,7 +159,6 @@
|
||||
<Compile Include="Traits\Util.cs" />
|
||||
<Compile Include="Traits\ValidateOrder.cs" />
|
||||
<Compile Include="Traits\World\Country.cs" />
|
||||
<Compile Include="Traits\World\ResourceLayer.cs" />
|
||||
<Compile Include="Traits\World\ResourceType.cs" />
|
||||
<Compile Include="Traits\World\ScreenShaker.cs" />
|
||||
<Compile Include="Traits\World\Shroud.cs" />
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace OpenRA.Traits
|
||||
|
||||
public readonly string[] AllowedTerrainTypes = { };
|
||||
public readonly bool AllowUnderActors = false;
|
||||
public readonly bool AllowUnderBuildings = false;
|
||||
|
||||
public PipType PipColor = PipType.Yellow;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Mods.RA;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
|
||||
@@ -11,8 +11,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.RA;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
namespace OpenRA.Mods.D2k
|
||||
{
|
||||
public class D2kResourceLayerInfo : TraitInfo<D2kResourceLayer> { }
|
||||
|
||||
|
||||
@@ -23,13 +23,13 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
var footprint = buildingInfo.Footprint.Where(x => !char.IsWhiteSpace(x));
|
||||
|
||||
var buildingTraits = rules.Actors[name].Traits;
|
||||
if (buildingTraits.Contains<BibInfo>() && !(buildingTraits.Get<BibInfo>().HasMinibib))
|
||||
if (buildingTraits.Contains<BibInfo>() && !buildingTraits.Get<BibInfo>().HasMinibib)
|
||||
{
|
||||
dim += new CVec(0, 1);
|
||||
footprint = footprint.Concat(new char[dim.X]);
|
||||
}
|
||||
|
||||
return TilesWhere( name, dim, footprint.ToArray(), a => a != '_' ).Select( t => t + topLeft );
|
||||
return TilesWhere(name, dim, footprint.ToArray(), a => a != '_').Select(t => t + topLeft);
|
||||
}
|
||||
|
||||
public static IEnumerable<CPos> Tiles(Actor a)
|
||||
@@ -39,20 +39,20 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
|
||||
public static IEnumerable<CPos> UnpathableTiles(string name, BuildingInfo buildingInfo, CPos position)
|
||||
{
|
||||
var footprint = buildingInfo.Footprint.Where( x => !char.IsWhiteSpace( x ) ).ToArray();
|
||||
foreach( var tile in TilesWhere( name, (CVec)buildingInfo.Dimensions, footprint, a => a == 'x' ) )
|
||||
var footprint = buildingInfo.Footprint.Where(x => !char.IsWhiteSpace(x)).ToArray();
|
||||
foreach (var tile in TilesWhere(name, (CVec)buildingInfo.Dimensions, footprint, a => a == 'x'))
|
||||
yield return tile + position;
|
||||
}
|
||||
|
||||
static IEnumerable<CVec> TilesWhere(string name, CVec dim, char[] footprint, Func<char, bool> cond)
|
||||
{
|
||||
if( footprint.Length != dim.X * dim.Y )
|
||||
throw new InvalidOperationException( "Invalid footprint for " + name );
|
||||
if (footprint.Length != dim.X * dim.Y)
|
||||
throw new InvalidOperationException("Invalid footprint for " + name);
|
||||
var index = 0;
|
||||
|
||||
for( var y = 0 ; y < dim.Y ; y++ )
|
||||
for( var x = 0 ; x < dim.X ; x++ )
|
||||
if( cond( footprint[ index++ ] ) )
|
||||
for (var y = 0; y < dim.Y; y++)
|
||||
for (var x = 0; x < dim.X; x++)
|
||||
if (cond(footprint[index++]))
|
||||
yield return new CVec(x, y);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,8 @@ namespace OpenRA.Mods.RA
|
||||
if (!info.TerrainTypes.Contains(type))
|
||||
return false;
|
||||
|
||||
if (self.World.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(cell) != null) return false;
|
||||
if (self.World.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(cell) != null)
|
||||
return false;
|
||||
|
||||
if (!checkTransientActors)
|
||||
return true;
|
||||
|
||||
@@ -520,6 +520,7 @@
|
||||
<Compile Include="Player\ProvidesCustomPrerequisite.cs" />
|
||||
<Compile Include="Lint\CheckActors.cs" />
|
||||
<Compile Include="Lint\CheckMapCordon.cs" />
|
||||
<Compile Include="World\ResourceLayer.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
@@ -12,9 +12,12 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.RA.Buildings;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Desc("Attach this to the world actor.")]
|
||||
public class ResourceLayerInfo : TraitInfo<ResourceLayer>, Requires<ResourceTypeInfo> { }
|
||||
|
||||
public class ResourceLayer : IRenderOverlay, IWorldLoaded, ITickRender
|
||||
@@ -22,6 +25,9 @@ namespace OpenRA.Traits
|
||||
static readonly CellContents EmptyCell = new CellContents();
|
||||
|
||||
World world;
|
||||
|
||||
BuildingInfluence buildingInfluence;
|
||||
|
||||
protected CellLayer<CellContents> content;
|
||||
protected CellLayer<CellContents> render;
|
||||
List<CPos> dirty;
|
||||
@@ -54,6 +60,9 @@ namespace OpenRA.Traits
|
||||
public void WorldLoaded(World w, WorldRenderer wr)
|
||||
{
|
||||
this.world = w;
|
||||
|
||||
buildingInfluence = world.WorldActor.Trait<BuildingInfluence>();
|
||||
|
||||
content = new CellLayer<CellContents>(w.Map);
|
||||
render = new CellLayer<CellContents>(w.Map);
|
||||
dirty = new List<CPos>();
|
||||
@@ -139,6 +148,9 @@ namespace OpenRA.Traits
|
||||
if (!rt.Info.AllowUnderActors && world.ActorMap.AnyUnitsAt(cell))
|
||||
return false;
|
||||
|
||||
if (!rt.Info.AllowUnderBuildings && buildingInfluence.GetBuildingAt(cell) != null)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ Chrome:
|
||||
mods/ts/chrome.yaml
|
||||
|
||||
Assemblies:
|
||||
mods/d2k/OpenRA.Mods.D2k.dll
|
||||
mods/ra/OpenRA.Mods.RA.dll
|
||||
mods/d2k/OpenRA.Mods.D2k.dll
|
||||
mods/cnc/OpenRA.Mods.Cnc.dll
|
||||
mods/ts/OpenRA.Mods.TS.dll
|
||||
|
||||
|
||||
Reference in New Issue
Block a user