Merge pull request #11638 from reaperrr/deprecate-IsWater-p1
Deprecate terrain IsWater check - Part 1
This commit is contained in:
@@ -134,6 +134,9 @@ namespace OpenRA.Mods.Common.AI
|
||||
"Should match maximum adjacency of naval structures.")]
|
||||
public readonly int CheckForWaterRadius = 8;
|
||||
|
||||
[Desc("Terrain types which are considered water for base building purposes.")]
|
||||
public readonly HashSet<string> WaterTerrainTypes = new HashSet<string> { "Water" };
|
||||
|
||||
[Desc("Avoid enemy actors nearby when searching for a new resource patch. Should be somewhere near the max weapon range.")]
|
||||
public readonly WDist HarvesterEnemyAvoidanceRadius = WDist.FromCells(8);
|
||||
|
||||
@@ -323,14 +326,13 @@ namespace OpenRA.Mods.Common.AI
|
||||
|
||||
foreach (var b in baseProviders)
|
||||
{
|
||||
// TODO: Unhardcode terrain type
|
||||
// TODO2: Properly check building foundation rather than 3x3 area
|
||||
// TODO: Properly check building foundation rather than 3x3 area
|
||||
var playerWorld = Player.World;
|
||||
var countWaterCells = Map.FindTilesInCircle(b.Location, Info.MaxBaseRadius)
|
||||
.Where(c => playerWorld.Map.Contains(c)
|
||||
&& playerWorld.Map.GetTerrainInfo(c).IsWater
|
||||
&& Info.WaterTerrainTypes.Contains(playerWorld.Map.GetTerrainInfo(c).Type)
|
||||
&& Util.AdjacentCells(playerWorld, Target.FromCell(playerWorld, c))
|
||||
.All(a => playerWorld.Map.GetTerrainInfo(a).IsWater))
|
||||
.All(a => Info.WaterTerrainTypes.Contains(playerWorld.Map.GetTerrainInfo(a).Type)))
|
||||
.Count();
|
||||
|
||||
if (countWaterCells > 0)
|
||||
@@ -348,14 +350,13 @@ namespace OpenRA.Mods.Common.AI
|
||||
|
||||
foreach (var a in areaProviders)
|
||||
{
|
||||
// TODO: Unhardcode terrain type
|
||||
// TODO2: Properly check building foundation rather than 3x3 area
|
||||
// TODO: Properly check building foundation rather than 3x3 area
|
||||
var playerWorld = Player.World;
|
||||
var adjacentWater = Map.FindTilesInCircle(a.Location, Info.CheckForWaterRadius)
|
||||
.Where(c => playerWorld.Map.Contains(c)
|
||||
&& playerWorld.Map.GetTerrainInfo(c).IsWater
|
||||
&& Info.WaterTerrainTypes.Contains(playerWorld.Map.GetTerrainInfo(c).Type)
|
||||
&& Util.AdjacentCells(playerWorld, Target.FromCell(playerWorld, c))
|
||||
.All(b => playerWorld.Map.GetTerrainInfo(b).IsWater))
|
||||
.All(ac => Info.WaterTerrainTypes.Contains(playerWorld.Map.GetTerrainInfo(ac).Type)))
|
||||
.Count();
|
||||
|
||||
if (adjacentWater > 0)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Effects;
|
||||
using OpenRA.Traits;
|
||||
@@ -32,6 +33,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[SequenceReference("Image")] public readonly string WaterCorpseSequence = null;
|
||||
[PaletteReference] public readonly string WaterCorpsePalette = "effect";
|
||||
|
||||
[Desc("Terrain types on which to display WaterCorpseSequence.")]
|
||||
public readonly HashSet<string> WaterTerrainTypes = new HashSet<string> { "Water" };
|
||||
|
||||
public readonly int FallRate = 13;
|
||||
|
||||
[UpgradeGrantedReference]
|
||||
@@ -59,19 +63,23 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!info.KilledOnImpassableTerrain)
|
||||
return;
|
||||
|
||||
if (positionable.CanEnterCell(self.Location, self))
|
||||
var cell = self.Location;
|
||||
if (self.World.Map.Contains(cell))
|
||||
return;
|
||||
|
||||
if (ignore != null && self.World.ActorMap.GetActorsAt(self.Location).Any(a => a != ignore))
|
||||
if (positionable.CanEnterCell(cell, self))
|
||||
return;
|
||||
|
||||
var terrain = self.World.Map.GetTerrainInfo(self.Location);
|
||||
if (ignore != null && self.World.ActorMap.GetActorsAt(cell).Any(a => a != ignore))
|
||||
return;
|
||||
|
||||
var sound = terrain.IsWater ? info.WaterImpactSound : info.GroundImpactSound;
|
||||
var onWater = info.WaterTerrainTypes.Contains(self.World.Map.GetTerrainInfo(cell).Type);
|
||||
|
||||
var sound = onWater ? info.WaterImpactSound : info.GroundImpactSound;
|
||||
Game.Sound.Play(sound, self.CenterPosition);
|
||||
|
||||
var sequence = terrain.IsWater ? info.WaterCorpseSequence : info.GroundCorpseSequence;
|
||||
var palette = terrain.IsWater ? info.WaterCorpsePalette : info.GroundCorpsePalette;
|
||||
var sequence = onWater ? info.WaterCorpseSequence : info.GroundCorpseSequence;
|
||||
var palette = onWater ? info.WaterCorpsePalette : info.GroundCorpsePalette;
|
||||
if (sequence != null && palette != null)
|
||||
self.World.AddFrameEndTask(w => w.Add(new SpriteEffect(self.OccupiesSpace.CenterPosition, w, info.Image, sequence, palette)));
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
[Desc("Easteregg sequences to use in December.")]
|
||||
public readonly string[] XmasImages = { };
|
||||
|
||||
[Desc("Terrain types on which to display WaterSequence.")]
|
||||
public readonly HashSet<string> WaterTerrainTypes = new HashSet<string> { "Water" };
|
||||
|
||||
[SequenceReference] public readonly string IdleSequence = "idle";
|
||||
[SequenceReference] public readonly string WaterSequence = null;
|
||||
[SequenceReference] public readonly string LandSequence = null;
|
||||
@@ -74,7 +77,8 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
void PlaySequence()
|
||||
{
|
||||
var sequence = self.World.Map.GetTerrainInfo(self.Location).IsWater ? info.WaterSequence : info.LandSequence;
|
||||
var onWater = info.WaterTerrainTypes.Contains(self.World.Map.GetTerrainInfo(self.Location).Type);
|
||||
var sequence = onWater ? info.WaterSequence : info.LandSequence;
|
||||
if (!string.IsNullOrEmpty(sequence))
|
||||
anim.PlayRepeating(sequence);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user