Some parts of some buildings are pathable.

- not handling WEAP/FIX yet; that's special-case logic.
This commit is contained in:
Bob
2009-10-13 19:11:32 +13:00
parent c6e739d162
commit 9ba0a632e2
5 changed files with 40 additions and 21 deletions

View File

@@ -6,7 +6,7 @@ using System.Text;
using IjwFramework.Types; using IjwFramework.Types;
using OpenRa.FileFormats; using OpenRa.FileFormats;
using OpenRa.Game.GameRules; using OpenRa.Game.GameRules;
using OpenRa.Game.Graphics; using OpenRa.Game.Graphics;
using System.Drawing; using System.Drawing;
namespace OpenRa.Game namespace OpenRa.Game
@@ -142,16 +142,16 @@ namespace OpenRa.Game
.Select( x => x.Order( this, game, xy ) ) .Select( x => x.Order( this, game, xy ) )
.Where( x => x != null ) .Where( x => x != null )
.FirstOrDefault(); .FirstOrDefault();
} }
public RectangleF Bounds public RectangleF Bounds
{ {
get get
{ {
var size = SelectedSize; var size = SelectedSize;
var loc = CenterLocation - 0.5f * size; var loc = CenterLocation - 0.5f * size;
return new RectangleF(loc.X, loc.Y, size.X, size.Y); return new RectangleF(loc.X, loc.Y, size.X, size.Y);
} }
} }
} }

View File

@@ -20,14 +20,14 @@ namespace OpenRa.Game
void AddInfluence(Actor a) void AddInfluence(Actor a)
{ {
foreach (var t in Footprint.Tiles(a.unitInfo.Name, a.Location)) foreach (var t in Footprint.UnpathableTiles(a.unitInfo.Name, a.Location))
if (IsValid(t)) if (IsValid(t))
influence[t.X, t.Y] = a; influence[t.X, t.Y] = a;
} }
void RemoveInfluence(Actor a) void RemoveInfluence(Actor a)
{ {
foreach (var t in Footprint.Tiles(a.unitInfo.Name, a.Location)) foreach (var t in Footprint.UnpathableTiles(a.unitInfo.Name, a.Location))
if (IsValid(t)) if (IsValid(t))
influence[t.X, t.Y] = null; influence[t.X, t.Y] = null;
} }

View File

@@ -53,5 +53,23 @@ namespace OpenRa.Game.GameRules
++j; ++j;
} }
} }
public static IEnumerable<int2> UnpathableTiles( string name, int2 position )
{
var footprint = Rules.Footprint.GetFootprint( name );
var j = 0;
foreach( var row in footprint )
{
var i = 0;
foreach( var c in row )
{
if( c == 'x' )
yield return position + new int2( i, j );
++i;
}
++j;
}
}
} }
} }

View File

@@ -95,10 +95,10 @@ namespace OpenRa.Game
Button = e.Button, Button = e.Button,
Event = MouseInputEvent.Move, Event = MouseInputEvent.Move,
Location = new int2(e.Location) Location = new int2(e.Location)
}); });
if (game.controller.orderGenerator != null) if (game.controller.orderGenerator != null)
game.controller.orderGenerator.PrepareOverlay(game, game.controller.orderGenerator.PrepareOverlay(game,
((1 / 24f) * (new float2(e.Location) + game.viewport.Location)).ToInt2()); ((1 / 24f) * (new float2(e.Location) + game.viewport.Location)).ToInt2());
} }

View File

@@ -6,10 +6,11 @@
x : ftur sbag brik fenc gun pbox hbox silo gap kenn * x : ftur sbag brik fenc gun pbox hbox silo gap kenn *
_ x : tsla agun _ x : tsla agun
xx xx xx : powr dome barr tent domf hpad atek xx xx == : powr dome barr tent domf hpad atek
xxx xxx xxx : fact facf syrf syrd weap weaf spen spef apwr stek xxx xxx === : fact facf weap weaf apwr stek
xxx xxx xxx : syrf syrd spen spef
xx : sam mslo xx : sam mslo
_x_ xxx xxx xxx : proc _x_ xxx x== === : proc
xxx xxx : afld xxx xxx : afld
_x_ xxx _x_ : fix _x_ xxx _x_ : fix
__ xx : iron xx xx : iron