rules-based terrain cost, part 1

This commit is contained in:
Chris Forbes
2010-04-02 15:14:58 +13:00
parent 45f9ec2f7e
commit 0596b08f2c
25 changed files with 235 additions and 239 deletions

View File

@@ -19,6 +19,7 @@
#endregion
using System.Linq;
using OpenRA.GameRules;
namespace OpenRA.Traits.Activities
{

View File

@@ -18,6 +18,7 @@
*/
#endregion
using OpenRA.GameRules;
namespace OpenRA.Traits.Activities
{
class HeliLand : IActivity

View File

@@ -19,6 +19,7 @@
#endregion
using System.Linq;
using OpenRA.GameRules;
namespace OpenRA.Traits.Activities
{

View File

@@ -23,6 +23,7 @@ using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.GameRules;
namespace OpenRA.Traits
{
@@ -128,10 +129,7 @@ namespace OpenRA.Traits
public float GetCost(int2 p, UnitMovementType umt)
{
// just use the standard walkability from templates.ini. no hackery.
return TerrainCosts.Cost(umt,
Templates[state].TerrainType[Tiles[p]]);
return Rules.TerrainTypes[Templates[state].TerrainType[Tiles[p]]].GetCost(umt);
}
static bool IsIntact(Bridge b)

View File

@@ -20,6 +20,7 @@
using System.Collections.Generic;
using OpenRA.Traits.Activities;
using OpenRA.GameRules;
namespace OpenRA.Traits
{

View File

@@ -19,6 +19,7 @@
#endregion
using OpenRA.Traits.Activities;
using OpenRA.GameRules;
namespace OpenRA.Traits
{
@@ -66,10 +67,7 @@ namespace OpenRA.Traits
}
// HACK: This should make reference to an MCV actor, and use of its Mobile trait
public UnitMovementType GetMovementType()
{
return UnitMovementType.Wheel;
}
public UnitMovementType GetMovementType() { return UnitMovementType.Wheel; }
public bool CanEnterCell(int2 a)
{
@@ -88,10 +86,10 @@ namespace OpenRA.Traits
}
if (!crushable) return false;
return self.World.Map.IsInMap(a.X, a.Y) &&
TerrainCosts.Cost(GetMovementType(),
self.World.TileSet.GetTerrainType(self.World.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
Rules.TerrainTypes[self.World.TileSet.GetTerrainType(self.World.Map.MapTiles[a.X, a.Y])]
.GetCost(GetMovementType()) < float.PositiveInfinity;
}
}
}

View File

@@ -21,6 +21,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.GameRules;
/*
* Crates left to implement:
@@ -75,24 +76,15 @@ namespace OpenRA.Traits
n -= s.Second;
}
public bool IsPathableCrush(UnitMovementType umt, Player player)
{
return true;
}
public bool IsCrushableBy(UnitMovementType umt, Player player)
{
return true;
}
public bool IsPathableCrush(UnitMovementType umt, Player player) { return true; }
public bool IsCrushableBy(UnitMovementType umt, Player player) { return true; }
public IEnumerable<int2> OccupiedCells() { yield return self.Location; }
public void Tick(Actor self)
{
if (++ticks >= self.Info.Traits.Get<CrateInfo>().Lifetime * 25)
{
self.World.AddFrameEndTask(w => w.Remove(self));
}
}
}
}

View File

@@ -20,6 +20,7 @@
using System;
using OpenRA.Traits.Activities;
using OpenRA.GameRules;
namespace OpenRA.Traits
{

View File

@@ -20,6 +20,7 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.GameRules;
namespace OpenRA.Traits
{
@@ -131,10 +132,10 @@ namespace OpenRA.Traits
}
if (!crushable) return false;
return self.World.Map.IsInMap(a.X, a.Y) &&
TerrainCosts.Cost(GetMovementType(),
self.World.TileSet.GetTerrainType(self.World.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
Rules.TerrainTypes[self.World.TileSet.GetTerrainType(self.World.Map.MapTiles[a.X, a.Y])]
.GetCost(GetMovementType()) < float.PositiveInfinity;
}
public IEnumerable<int2> GetCurrentPath()

View File

@@ -21,6 +21,7 @@
using System;
using System.Linq;
using OpenRA.Traits.Activities;
using OpenRA.GameRules;
namespace OpenRA.Traits
{

View File

@@ -18,6 +18,7 @@
*/
#endregion
using OpenRA.GameRules;
namespace OpenRA.Traits
{
class SquishByTankInfo : ITraitInfo